ui icon boogaloo

This commit is contained in:
rootdarkarchon
2023-10-29 14:56:44 +01:00
parent 11bb84bd61
commit c23add802a
19 changed files with 300 additions and 298 deletions

View File

@@ -151,7 +151,7 @@ public class CompactUi : WindowMediatorSubscriberBase
{ {
UiSharedService.TextWrapped($"You have successfully added {_lastAddedUser.UserData.AliasOrUID}. Set a local note for the user in the field below:"); UiSharedService.TextWrapped($"You have successfully added {_lastAddedUser.UserData.AliasOrUID}. Set a local note for the user in the field below:");
ImGui.InputTextWithHint("##noteforuser", $"Note for {_lastAddedUser.UserData.AliasOrUID}", ref _lastAddedUserComment, 100); ImGui.InputTextWithHint("##noteforuser", $"Note for {_lastAddedUser.UserData.AliasOrUID}", ref _lastAddedUserComment, 100);
if (UiSharedService.IconTextButton(FontAwesomeIcon.Save, "Save Note")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Save, "Save Note"))
{ {
_serverManager.SetNoteForUid(_lastAddedUser.UserData.UID, _lastAddedUserComment); _serverManager.SetNoteForUid(_lastAddedUser.UserData.UID, _lastAddedUserComment);
_lastAddedUser = null; _lastAddedUser = null;
@@ -180,7 +180,7 @@ public class CompactUi : WindowMediatorSubscriberBase
if (keys.Any()) if (keys.Any())
{ {
if (_secretKeyIdx == -1) _secretKeyIdx = keys.First().Key; if (_secretKeyIdx == -1) _secretKeyIdx = keys.First().Key;
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Add current character with secret key")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Add current character with secret key"))
{ {
_serverManager.CurrentServer!.Authentications.Add(new MareConfiguration.Models.Authentication() _serverManager.CurrentServer!.Authentications.Add(new MareConfiguration.Models.Authentication()
{ {
@@ -220,7 +220,7 @@ public class CompactUi : WindowMediatorSubscriberBase
} }
private void DrawServerStatus() private void DrawServerStatus()
{ {
var buttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Link); var buttonSize = UiSharedService.NormalizedIconButtonSize(FontAwesomeIcon.Link);
var userCount = _apiController.OnlineUsers.ToString(CultureInfo.InvariantCulture); var userCount = _apiController.OnlineUsers.ToString(CultureInfo.InvariantCulture);
var userSize = ImGui.CalcTextSize(userCount); var userSize = ImGui.CalcTextSize(userCount);
var textSize = ImGui.CalcTextSize("Users Online"); var textSize = ImGui.CalcTextSize("Users Online");
@@ -272,7 +272,7 @@ public class CompactUi : WindowMediatorSubscriberBase
{ {
using (ImRaii.PushColor(ImGuiCol.Text, color)) using (ImRaii.PushColor(ImGuiCol.Text, color))
{ {
if (ImGuiComponents.IconButton(connectedIcon)) if (UiSharedService.NormalizedIconButton(connectedIcon))
{ {
_serverManager.CurrentServer.FullPause = !_serverManager.CurrentServer.FullPause; _serverManager.CurrentServer.FullPause = !_serverManager.CurrentServer.FullPause;
_serverManager.Save(); _serverManager.Save();
@@ -287,7 +287,7 @@ public class CompactUi : WindowMediatorSubscriberBase
private void DrawTransfers() private void DrawTransfers()
{ {
var currentUploads = _fileTransferManager.CurrentUploads.ToList(); var currentUploads = _fileTransferManager.CurrentUploads.ToList();
UiSharedService.FontText(FontAwesomeIcon.Upload.ToIconString(), UiBuilder.IconFont); UiSharedService.NormalizedIcon(FontAwesomeIcon.Upload);
ImGui.SameLine(35 * ImGuiHelpers.GlobalScale); ImGui.SameLine(35 * ImGuiHelpers.GlobalScale);
if (currentUploads.Any()) if (currentUploads.Any())
@@ -302,15 +302,17 @@ public class CompactUi : WindowMediatorSubscriberBase
var uploadText = $"({UiSharedService.ByteToString(totalUploaded)}/{UiSharedService.ByteToString(totalToUpload)})"; var uploadText = $"({UiSharedService.ByteToString(totalUploaded)}/{UiSharedService.ByteToString(totalToUpload)})";
var textSize = ImGui.CalcTextSize(uploadText); var textSize = ImGui.CalcTextSize(uploadText);
ImGui.SameLine(_windowContentWidth - textSize.X); ImGui.SameLine(_windowContentWidth - textSize.X);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(uploadText); ImGui.TextUnformatted(uploadText);
} }
else else
{ {
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("No uploads in progress"); ImGui.TextUnformatted("No uploads in progress");
} }
var currentDownloads = _currentDownloads.SelectMany(d => d.Value.Values).ToList(); var currentDownloads = _currentDownloads.SelectMany(d => d.Value.Values).ToList();
UiSharedService.FontText(FontAwesomeIcon.Download.ToIconString(), UiBuilder.IconFont); UiSharedService.NormalizedIcon(FontAwesomeIcon.Download);
ImGui.SameLine(35 * ImGuiHelpers.GlobalScale); ImGui.SameLine(35 * ImGuiHelpers.GlobalScale);
if (currentDownloads.Any()) if (currentDownloads.Any())
@@ -325,10 +327,12 @@ public class CompactUi : WindowMediatorSubscriberBase
$"({UiSharedService.ByteToString(totalDownloaded)}/{UiSharedService.ByteToString(totalToDownload)})"; $"({UiSharedService.ByteToString(totalDownloaded)}/{UiSharedService.ByteToString(totalToDownload)})";
var textSize = ImGui.CalcTextSize(downloadText); var textSize = ImGui.CalcTextSize(downloadText);
ImGui.SameLine(_windowContentWidth - textSize.X); ImGui.SameLine(_windowContentWidth - textSize.X);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(downloadText); ImGui.TextUnformatted(downloadText);
} }
else else
{ {
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("No downloads in progress"); ImGui.TextUnformatted("No downloads in progress");
} }
} }

View File

@@ -62,7 +62,7 @@ public abstract class DrawFolderBase : IDrawFolder
// if opened draw content // if opened draw content
if (_tagHandler.IsTagOpen(_id)) if (_tagHandler.IsTagOpen(_id))
{ {
using var indent = ImRaii.PushIndent(20f); using var indent = ImRaii.PushIndent(UiSharedService.GetIconData(FontAwesomeIcon.Bars).NormalizedIconScale.X + ImGui.GetStyle().ItemSpacing.X);
if (DrawPairs.Any()) if (DrawPairs.Any())
{ {
foreach (var item in DrawPairs) foreach (var item in DrawPairs)
@@ -89,7 +89,7 @@ public abstract class DrawFolderBase : IDrawFolder
private float DrawRightSideInternal() private float DrawRightSideInternal()
{ {
var barButtonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars); var barButtonSize = UiSharedService.NormalizedIconButtonSize(FontAwesomeIcon.Bars);
var spacingX = ImGui.GetStyle().ItemSpacing.X; var spacingX = ImGui.GetStyle().ItemSpacing.X;
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth(); var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
@@ -99,7 +99,7 @@ public abstract class DrawFolderBase : IDrawFolder
if (RenderMenu) if (RenderMenu)
{ {
ImGui.SameLine(windowEndX - barButtonSize.X); ImGui.SameLine(windowEndX - barButtonSize.X);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars)) if (UiSharedService.NormalizedIconButton(FontAwesomeIcon.Bars))
{ {
ImGui.OpenPopup("User Flyout Menu"); ImGui.OpenPopup("User Flyout Menu");
} }

View File

@@ -86,21 +86,21 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.Separator(); ImGui.Separator();
ImGui.TextUnformatted("General Syncshell Actions"); ImGui.TextUnformatted("General Syncshell Actions");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Copy, "Copy ID", menuWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Copy, "Copy ID", menuWidth, true))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
ImGui.SetClipboardText(_groupFullInfoDto.GroupAliasOrGID); ImGui.SetClipboardText(_groupFullInfoDto.GroupAliasOrGID);
} }
UiSharedService.AttachToolTip("Copy Syncshell ID to Clipboard"); UiSharedService.AttachToolTip("Copy Syncshell ID to Clipboard");
if (UiSharedService.IconTextButton(FontAwesomeIcon.StickyNote, "Copy Notes", menuWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StickyNote, "Copy Notes", menuWidth, true))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
ImGui.SetClipboardText(UiSharedService.GetNotes(DrawPairs.Select(k => k.Pair).ToList())); ImGui.SetClipboardText(UiSharedService.GetNotes(DrawPairs.Select(k => k.Pair).ToList()));
} }
UiSharedService.AttachToolTip("Copies all your notes for all users in this Syncshell to the clipboard." + Environment.NewLine + "They can be imported via Settings -> Privacy -> Import Notes from Clipboard"); UiSharedService.AttachToolTip("Copies all your notes for all users in this Syncshell to the clipboard." + Environment.NewLine + "They can be imported via Settings -> Privacy -> Import Notes from Clipboard");
if (UiSharedService.IconTextButton(FontAwesomeIcon.ArrowCircleLeft, "Leave Syncshell", menuWidth, true) && UiSharedService.CtrlPressed()) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ArrowCircleLeft, "Leave Syncshell", menuWidth, true) && UiSharedService.CtrlPressed())
{ {
_ = _apiController.GroupLeave(_groupFullInfoDto); _ = _apiController.GroupLeave(_groupFullInfoDto);
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
@@ -118,7 +118,7 @@ public class DrawFolderGroup : DrawFolderBase
if ((_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations() != disableAnims if ((_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations() != disableAnims
|| _groupFullInfoDto.GroupPermissions.IsPreferDisableSounds() != disableSounds || _groupFullInfoDto.GroupPermissions.IsPreferDisableSounds() != disableSounds
|| _groupFullInfoDto.GroupPermissions.IsPreferDisableVFX() != disableVfx) || _groupFullInfoDto.GroupPermissions.IsPreferDisableVFX() != disableVfx)
&& UiSharedService.IconTextButton(FontAwesomeIcon.Check, "Align with suggested permissions", menuWidth, true)) && UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Check, "Align with suggested permissions", menuWidth, true))
{ {
perm.SetDisableVFX(_groupFullInfoDto.GroupPermissions.IsPreferDisableVFX()); perm.SetDisableVFX(_groupFullInfoDto.GroupPermissions.IsPreferDisableVFX());
perm.SetDisableSounds(_groupFullInfoDto.GroupPermissions.IsPreferDisableSounds()); perm.SetDisableSounds(_groupFullInfoDto.GroupPermissions.IsPreferDisableSounds());
@@ -127,7 +127,7 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
if (UiSharedService.IconTextButton(disableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeOff, disableSounds ? "Enable Sound Sync" : "Disable Sound Sync", if (UiSharedService.NormalizedIconTextButton(disableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeOff, disableSounds ? "Enable Sound Sync" : "Disable Sound Sync",
menuWidth, true)) menuWidth, true))
{ {
perm.SetDisableSounds(!disableSounds); perm.SetDisableSounds(!disableSounds);
@@ -135,7 +135,7 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
if (UiSharedService.IconTextButton(disableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop, disableAnims ? "Enable Animation Sync" : "Disable Animation Sync", if (UiSharedService.NormalizedIconTextButton(disableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop, disableAnims ? "Enable Animation Sync" : "Disable Animation Sync",
menuWidth, true)) menuWidth, true))
{ {
perm.SetDisableAnimations(!disableAnims); perm.SetDisableAnimations(!disableAnims);
@@ -143,7 +143,7 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
if (UiSharedService.IconTextButton(disableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle, disableVfx ? "Enable VFX Sync" : "Disable VFX Sync", if (UiSharedService.NormalizedIconTextButton(disableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle, disableVfx ? "Enable VFX Sync" : "Disable VFX Sync",
menuWidth, true)) menuWidth, true))
{ {
perm.SetDisableVFX(!disableVfx); perm.SetDisableVFX(!disableVfx);
@@ -155,7 +155,7 @@ public class DrawFolderGroup : DrawFolderBase
{ {
ImGui.Separator(); ImGui.Separator();
ImGui.TextUnformatted("Syncshell Admin Functions"); ImGui.TextUnformatted("Syncshell Admin Functions");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Cog, "Open Admin Panel", menuWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Cog, "Open Admin Panel", menuWidth, true))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
_mareMediator.Publish(new OpenSyncshellAdminPanel(_groupFullInfoDto)); _mareMediator.Publish(new OpenSyncshellAdminPanel(_groupFullInfoDto));
@@ -173,9 +173,9 @@ public class DrawFolderGroup : DrawFolderBase
var spacingX = ImGui.GetStyle().ItemSpacing.X; var spacingX = ImGui.GetStyle().ItemSpacing.X;
FontAwesomeIcon pauseIcon = _groupFullInfoDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; FontAwesomeIcon pauseIcon = _groupFullInfoDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseButtonSize = UiSharedService.GetIconButtonSize(pauseIcon); var pauseButtonSize = UiSharedService.NormalizedIconButtonSize(pauseIcon);
var userCogButtonSize = UiSharedService.GetNormalizedIconSize(FontAwesomeIcon.UsersCog); var userCogButtonSize = UiSharedService.GetIconData(FontAwesomeIcon.UsersCog).NormalizedIconScale;
var individualSoundsDisabled = _groupFullInfoDto.GroupUserPermissions.IsDisableSounds(); var individualSoundsDisabled = _groupFullInfoDto.GroupUserPermissions.IsDisableSounds();
var individualAnimDisabled = _groupFullInfoDto.GroupUserPermissions.IsDisableAnimations(); var individualAnimDisabled = _groupFullInfoDto.GroupUserPermissions.IsDisableAnimations();
@@ -199,14 +199,17 @@ public class DrawFolderGroup : DrawFolderBase
UiSharedService.BooleanToColoredIcon(!individualSoundsDisabled, inline: false); UiSharedService.BooleanToColoredIcon(!individualSoundsDisabled, inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Sound Sync"); ImGui.TextUnformatted("Sound Sync");
UiSharedService.BooleanToColoredIcon(!individualAnimDisabled, inline: false); UiSharedService.BooleanToColoredIcon(!individualAnimDisabled, inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Animation Sync"); ImGui.TextUnformatted("Animation Sync");
UiSharedService.BooleanToColoredIcon(!individualVFXDisabled, inline: false); UiSharedService.BooleanToColoredIcon(!individualVFXDisabled, inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("VFX Sync"); ImGui.TextUnformatted("VFX Sync");
ImGui.Separator(); ImGui.Separator();
@@ -217,21 +220,24 @@ public class DrawFolderGroup : DrawFolderBase
UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableSounds(), inline: false); UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableSounds(), inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Sound Sync"); ImGui.TextUnformatted("Sound Sync");
UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations(), inline: false); UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations(), inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Animation Sync"); ImGui.TextUnformatted("Animation Sync");
UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableVFX(), inline: false); UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableVFX(), inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("VFX Sync"); ImGui.TextUnformatted("VFX Sync");
ImGui.EndTooltip(); ImGui.EndTooltip();
} }
ImGui.SameLine(); ImGui.SameLine();
if (ImGuiComponents.IconButton(pauseIcon)) if (UiSharedService.NormalizedIconButton(pauseIcon))
{ {
var perm = _groupFullInfoDto.GroupUserPermissions; var perm = _groupFullInfoDto.GroupUserPermissions;
perm.SetPaused(!perm.IsPaused()); perm.SetPaused(!perm.IsPaused());

View File

@@ -101,12 +101,12 @@ public class DrawFolderTag : DrawFolderBase
protected override void DrawMenu(float menuWidth) protected override void DrawMenu(float menuWidth)
{ {
ImGui.TextUnformatted("Group Menu"); ImGui.TextUnformatted("Group Menu");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Users, "Select Pairs", menuWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Users, "Select Pairs", menuWidth, true))
{ {
_selectPairForTagUi.Open(_id); _selectPairForTagUi.Open(_id);
} }
UiSharedService.AttachToolTip("Select Individual Pairs for this Pair Group"); UiSharedService.AttachToolTip("Select Individual Pairs for this Pair Group");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Pair Group", menuWidth, true) && UiSharedService.CtrlPressed()) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete Pair Group", menuWidth, true) && UiSharedService.CtrlPressed())
{ {
_tagHandler.RemoveTag(_id); _tagHandler.RemoveTag(_id);
} }
@@ -138,11 +138,11 @@ public class DrawFolderTag : DrawFolderBase
var allArePaused = _allPairs.All(pair => pair.UserPair!.OwnPermissions.IsPaused()); var allArePaused = _allPairs.All(pair => pair.UserPair!.OwnPermissions.IsPaused());
var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseButtonX = UiSharedService.GetIconButtonSize(pauseButton).X; var pauseButtonX = UiSharedService.NormalizedIconButtonSize(pauseButton).X;
var buttonPauseOffset = currentRightSideX - pauseButtonX; var buttonPauseOffset = currentRightSideX - pauseButtonX;
ImGui.SameLine(buttonPauseOffset); ImGui.SameLine(buttonPauseOffset);
if (ImGuiComponents.IconButton(pauseButton)) if (UiSharedService.NormalizedIconButton(pauseButton))
{ {
if (allArePaused) if (allArePaused)
{ {

View File

@@ -30,7 +30,8 @@ public class DrawGroupedGroupFolder : IDrawFolder
using var id = ImRaii.PushId(_id); using var id = ImRaii.PushId(_id);
ImGui.Dummy(new Vector2(0f, ImGui.GetFrameHeight())); ImGui.Dummy(new Vector2(0f, ImGui.GetFrameHeight()));
ImGui.SameLine(); using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 0f)))
ImGui.SameLine();
var icon = _tagHandler.IsTagOpen(_id) ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight; var icon = _tagHandler.IsTagOpen(_id) ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight;
UiSharedService.NormalizedIcon(icon); UiSharedService.NormalizedIcon(icon);

View File

@@ -4,6 +4,7 @@ using Dalamud.Interface.Components;
using Dalamud.Interface.Utility; using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using ImGuiNET; using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using MareSynchronos.API.Data.Extensions; using MareSynchronos.API.Data.Extensions;
using MareSynchronos.API.Dto.Group; using MareSynchronos.API.Dto.Group;
using MareSynchronos.API.Dto.User; using MareSynchronos.API.Dto.User;
@@ -63,7 +64,7 @@ public class DrawUserPair
{ {
if (!_pair.IsPaused) if (!_pair.IsPaused)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.User, "Open Profile", _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.User, "Open Profile", _menuRenderWidth, true))
{ {
_displayHandler.OpenProfile(_pair); _displayHandler.OpenProfile(_pair);
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
@@ -72,7 +73,7 @@ public class DrawUserPair
} }
if (_pair.IsVisible) if (_pair.IsVisible)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Sync, "Reload last data", _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Sync, "Reload last data", _menuRenderWidth, true))
{ {
_pair.ApplyLastReceivedData(forced: true); _pair.ApplyLastReceivedData(forced: true);
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
@@ -80,7 +81,7 @@ public class DrawUserPair
UiSharedService.AttachToolTip("This reapplies the last received character data to this character"); UiSharedService.AttachToolTip("This reapplies the last received character data to this character");
} }
if (UiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Cycle pause state", _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PlayCircle, "Cycle pause state", _menuRenderWidth, true))
{ {
_ = _apiController.CyclePause(_pair.UserData); _ = _apiController.CyclePause(_pair.UserData);
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
@@ -91,7 +92,7 @@ public class DrawUserPair
var isSticky = _pair.UserPair!.OwnPermissions.IsSticky(); var isSticky = _pair.UserPair!.OwnPermissions.IsSticky();
string stickyText = isSticky ? "Disable Preferred Permissions" : "Enable Preferred Permissions"; string stickyText = isSticky ? "Disable Preferred Permissions" : "Enable Preferred Permissions";
var stickyIcon = isSticky ? FontAwesomeIcon.ArrowCircleDown : FontAwesomeIcon.ArrowCircleUp; var stickyIcon = isSticky ? FontAwesomeIcon.ArrowCircleDown : FontAwesomeIcon.ArrowCircleUp;
if (UiSharedService.IconTextButton(stickyIcon, stickyText, _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(stickyIcon, stickyText, _menuRenderWidth, true))
{ {
var permissions = _pair.UserPair.OwnPermissions; var permissions = _pair.UserPair.OwnPermissions;
permissions.SetSticky(!isSticky); permissions.SetSticky(!isSticky);
@@ -107,7 +108,7 @@ public class DrawUserPair
var isDisableSounds = _pair.UserPair!.OwnPermissions.IsDisableSounds(); var isDisableSounds = _pair.UserPair!.OwnPermissions.IsDisableSounds();
string disableSoundsText = isDisableSounds ? "Enable sound sync" : "Disable sound sync"; string disableSoundsText = isDisableSounds ? "Enable sound sync" : "Disable sound sync";
var disableSoundsIcon = isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute; var disableSoundsIcon = isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute;
if (UiSharedService.IconTextButton(disableSoundsIcon, disableSoundsText, _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(disableSoundsIcon, disableSoundsText, _menuRenderWidth, true))
{ {
var permissions = _pair.UserPair.OwnPermissions; var permissions = _pair.UserPair.OwnPermissions;
permissions.SetDisableSounds(!isDisableSounds); permissions.SetDisableSounds(!isDisableSounds);
@@ -118,7 +119,7 @@ public class DrawUserPair
var isDisableAnims = _pair.UserPair!.OwnPermissions.IsDisableAnimations(); var isDisableAnims = _pair.UserPair!.OwnPermissions.IsDisableAnimations();
string disableAnimsText = isDisableAnims ? "Enable animation sync" : "Disable animation sync"; string disableAnimsText = isDisableAnims ? "Enable animation sync" : "Disable animation sync";
var disableAnimsIcon = isDisableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop; var disableAnimsIcon = isDisableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop;
if (UiSharedService.IconTextButton(disableAnimsIcon, disableAnimsText, _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(disableAnimsIcon, disableAnimsText, _menuRenderWidth, true))
{ {
var permissions = _pair.UserPair.OwnPermissions; var permissions = _pair.UserPair.OwnPermissions;
permissions.SetDisableAnimations(!isDisableAnims); permissions.SetDisableAnimations(!isDisableAnims);
@@ -129,7 +130,7 @@ public class DrawUserPair
var isDisableVFX = _pair.UserPair!.OwnPermissions.IsDisableVFX(); var isDisableVFX = _pair.UserPair!.OwnPermissions.IsDisableVFX();
string disableVFXText = isDisableVFX ? "Enable VFX sync" : "Disable VFX sync"; string disableVFXText = isDisableVFX ? "Enable VFX sync" : "Disable VFX sync";
var disableVFXIcon = isDisableVFX ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle; var disableVFXIcon = isDisableVFX ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle;
if (UiSharedService.IconTextButton(disableVFXIcon, disableVFXText, _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(disableVFXIcon, disableVFXText, _menuRenderWidth, true))
{ {
var permissions = _pair.UserPair.OwnPermissions; var permissions = _pair.UserPair.OwnPermissions;
permissions.SetDisableVFX(!isDisableVFX); permissions.SetDisableVFX(!isDisableVFX);
@@ -141,7 +142,7 @@ public class DrawUserPair
{ {
ImGui.Separator(); ImGui.Separator();
ImGui.TextUnformatted("Pair reporting"); ImGui.TextUnformatted("Pair reporting");
if (UiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Report Mare Profile", _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ExclamationTriangle, "Report Mare Profile", _menuRenderWidth, true))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
_mediator.Publish(new OpenReportPopupMessage(_pair)); _mediator.Publish(new OpenReportPopupMessage(_pair));
@@ -157,12 +158,12 @@ public class DrawUserPair
if (_pair.IndividualPairStatus != API.Data.Enum.IndividualPairStatus.None) if (_pair.IndividualPairStatus != API.Data.Enum.IndividualPairStatus.None)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Folder, "Pair Groups", _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Folder, "Pair Groups", _menuRenderWidth, true))
{ {
_selectTagForPairUi.Open(_pair); _selectTagForPairUi.Open(_pair);
} }
UiSharedService.AttachToolTip("Choose pair groups for " + entryUID); UiSharedService.AttachToolTip("Choose pair groups for " + entryUID);
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently", _menuRenderWidth, true) && UiSharedService.CtrlPressed()) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently", _menuRenderWidth, true) && UiSharedService.CtrlPressed())
{ {
_ = _apiController.UserRemovePair(new(_pair.UserData)); _ = _apiController.UserRemovePair(new(_pair.UserData));
} }
@@ -170,7 +171,7 @@ public class DrawUserPair
} }
else else
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Pair individually", _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Pair individually", _menuRenderWidth, true))
{ {
_ = _apiController.UserAddPair(new(_pair.UserData)); _ = _apiController.UserAddPair(new(_pair.UserData));
} }
@@ -186,34 +187,30 @@ public class DrawUserPair
if (_pair.IsPaused) if (_pair.IsPaused)
{ {
ImGui.AlignTextToFramePadding();
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
//using var font = ImRaii.PushFont(UiBuilder.IconFont);
UiSharedService.NormalizedIcon(FontAwesomeIcon.PauseCircle); UiSharedService.NormalizedIcon(FontAwesomeIcon.PauseCircle);
userPairText = _pair.UserData.AliasOrUID + " is paused"; userPairText = _pair.UserData.AliasOrUID + " is paused";
ImGui.SameLine();
} }
else if (!_pair.IsOnline) else if (!_pair.IsOnline)
{ {
ImGui.AlignTextToFramePadding();
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed); using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
UiSharedService.NormalizedIcon(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.OneSided UiSharedService.NormalizedIcon(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.OneSided
? FontAwesomeIcon.ArrowsLeftRight ? FontAwesomeIcon.ArrowsLeftRight
: (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional : (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional
? FontAwesomeIcon.User : FontAwesomeIcon.Users)); ? FontAwesomeIcon.User : FontAwesomeIcon.Users));
userPairText = _pair.UserData.AliasOrUID + " is offline"; userPairText = _pair.UserData.AliasOrUID + " is offline";
ImGui.SameLine(); }
else if (_pair.IsVisible)
{
UiSharedService.NormalizedIcon(FontAwesomeIcon.Eye, ImGuiColors.ParsedGreen);
userPairText = _pair.UserData.AliasOrUID + " is visible";
} }
else else
{ {
ImGui.AlignTextToFramePadding();
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen); using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen);
UiSharedService.NormalizedIcon(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional UiSharedService.NormalizedIcon(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional
? FontAwesomeIcon.User : FontAwesomeIcon.Users); ? FontAwesomeIcon.User : FontAwesomeIcon.Users);
userPairText = _pair.UserData.AliasOrUID + " is online"; userPairText = _pair.UserData.AliasOrUID + " is online";
ImGui.SameLine();
} }
if (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.OneSided) if (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.OneSided)
@@ -237,53 +234,6 @@ public class DrawUserPair
} }
UiSharedService.AttachToolTip(userPairText); UiSharedService.AttachToolTip(userPairText);
if (_currentGroup != null)
{
ImGui.AlignTextToFramePadding();
if (string.Equals(_currentGroup.OwnerUID, _pair.UserData.UID, StringComparison.Ordinal))
{
ImGui.SameLine();
UiSharedService.NormalizedIcon(FontAwesomeIcon.Crown);
UiSharedService.AttachToolTip("User is owner of this syncshell");
}
else if (_currentGroup.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var userinfo))
{
if (userinfo.IsModerator())
{
ImGui.SameLine();
UiSharedService.NormalizedIcon(FontAwesomeIcon.UserShield);
UiSharedService.AttachToolTip("User is moderator in this syncshell");
}
else if (userinfo.IsPinned())
{
ImGui.SameLine();
UiSharedService.NormalizedIcon(FontAwesomeIcon.Thumbtack);
UiSharedService.AttachToolTip("User is pinned in this syncshell");
}
}
}
if (_pair.UserPair.OwnPermissions.IsSticky())
{
ImGui.SameLine();
ImGui.AlignTextToFramePadding();
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X * 3 / 4f }))
UiSharedService.NormalizedIcon(FontAwesomeIcon.ArrowCircleUp);
UiSharedService.AttachToolTip(_pair.UserData.AliasOrUID + " has preferred permissions enabled");
}
if (_pair.IsVisible)
{
ImGui.SameLine();
ImGui.AlignTextToFramePadding();
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X * 3 / 4f }))
UiSharedService.NormalizedIcon(FontAwesomeIcon.Eye, ImGuiColors.ParsedGreen);
UiSharedService.AttachToolTip("User is visible: " + _pair.PlayerName);
}
ImGui.SameLine(); ImGui.SameLine();
} }
@@ -320,32 +270,46 @@ public class DrawUserPair
private float DrawRightSide() private float DrawRightSide()
{ {
var pauseIcon = _pair.UserPair!.OwnPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; var pauseIcon = _pair.UserPair!.OwnPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseIconSize = UiSharedService.GetIconButtonSize(pauseIcon); var pauseIconSize = UiSharedService.NormalizedIconButtonSize(pauseIcon);
var barButtonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars); var barButtonSize = UiSharedService.NormalizedIconButtonSize(FontAwesomeIcon.Bars);
var entryUID = _pair.UserData.AliasOrUID;
var spacingX = ImGui.GetStyle().ItemSpacing.X; var spacingX = ImGui.GetStyle().ItemSpacing.X;
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth(); var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
var rightSideStart = 0f; float currentRightSide = windowEndX - barButtonSize.X;
float infoIconDist = 0f;
ImGui.SameLine(currentRightSide);
ImGui.AlignTextToFramePadding();
if (UiSharedService.NormalizedIconButton(FontAwesomeIcon.Bars))
{
ImGui.OpenPopup("User Flyout Menu");
}
currentRightSide -= (pauseIconSize.X + spacingX);
ImGui.SameLine(currentRightSide);
if (UiSharedService.NormalizedIconButton(pauseIcon))
{
var perm = _pair.UserPair!.OwnPermissions;
perm.SetPaused(!perm.IsPaused());
_ = _apiController.UserSetPairPermissions(new(_pair.UserData, perm));
}
UiSharedService.AttachToolTip(!_pair.UserPair!.OwnPermissions.IsPaused()
? "Pause pairing with " + _pair.UserData.AliasOrUID
: "Resume pairing with " + _pair.UserData.AliasOrUID);
if (_pair.IsPaired) if (_pair.IsPaired)
{ {
var individualSoundsDisabled = (_pair.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableSounds() ?? false); var individualSoundsDisabled = (_pair.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableSounds() ?? false);
var individualAnimDisabled = (_pair.UserPair?.OwnPermissions.IsDisableAnimations() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableAnimations() ?? false); var individualAnimDisabled = (_pair.UserPair?.OwnPermissions.IsDisableAnimations() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableAnimations() ?? false);
var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false); var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false);
var individualIsSticky = _pair.UserPair!.OwnPermissions.IsSticky();
var individualIcon = individualIsSticky ? FontAwesomeIcon.ArrowCircleUp : FontAwesomeIcon.InfoCircle;
if (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled) if (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled || individualIsSticky)
{ {
var infoIconPosDist = windowEndX - barButtonSize.X - spacingX - pauseIconSize.X - spacingX; currentRightSide -= (UiSharedService.GetIconData(individualIcon).NormalizedIconScale.X + spacingX);
var icon = FontAwesomeIcon.InfoCircle;
var iconwidth = UiSharedService.GetNormalizedIconSize(icon);
infoIconDist = iconwidth.X; ImGui.SameLine(currentRightSide);
ImGui.SameLine(infoIconPosDist - iconwidth.X); using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen, individualIsSticky))
UiSharedService.NormalizedIcon(individualIcon);
ImGui.AlignTextToFramePadding();
UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont);
if (ImGui.IsItemHovered()) if (ImGui.IsItemHovered())
{ {
ImGui.BeginTooltip(); ImGui.BeginTooltip();
@@ -353,17 +317,30 @@ public class DrawUserPair
ImGui.TextUnformatted("Individual User permissions"); ImGui.TextUnformatted("Individual User permissions");
ImGui.Separator(); ImGui.Separator();
if (individualIsSticky)
{
UiSharedService.NormalizedIcon(individualIcon);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Preferred permissions enabled");
if (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled)
ImGui.Separator();
}
if (individualSoundsDisabled) if (individualSoundsDisabled)
{ {
var userSoundsText = "Sound sync"; var userSoundsText = "Sound sync";
UiSharedService.FontText(FontAwesomeIcon.VolumeOff.ToIconString(), UiBuilder.IconFont); UiSharedService.NormalizedIcon(FontAwesomeIcon.VolumeOff);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(userSoundsText); ImGui.TextUnformatted(userSoundsText);
ImGui.NewLine(); ImGui.NewLine();
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("You"); ImGui.TextUnformatted("You");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableSounds()); UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableSounds());
ImGui.SameLine(); ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("They"); ImGui.TextUnformatted("They");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableSounds()); UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableSounds());
} }
@@ -371,14 +348,17 @@ public class DrawUserPair
if (individualAnimDisabled) if (individualAnimDisabled)
{ {
var userAnimText = "Animation sync"; var userAnimText = "Animation sync";
UiSharedService.FontText(FontAwesomeIcon.Stop.ToIconString(), UiBuilder.IconFont); UiSharedService.NormalizedIcon(FontAwesomeIcon.Stop);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(userAnimText); ImGui.TextUnformatted(userAnimText);
ImGui.NewLine(); ImGui.NewLine();
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("You"); ImGui.TextUnformatted("You");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableAnimations()); UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableAnimations());
ImGui.SameLine(); ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("They"); ImGui.TextUnformatted("They");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableAnimations()); UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableAnimations());
} }
@@ -386,14 +366,17 @@ public class DrawUserPair
if (individualVFXDisabled) if (individualVFXDisabled)
{ {
var userVFXText = "VFX sync"; var userVFXText = "VFX sync";
UiSharedService.FontText(FontAwesomeIcon.Circle.ToIconString(), UiBuilder.IconFont); UiSharedService.NormalizedIcon(FontAwesomeIcon.Circle);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(userVFXText); ImGui.TextUnformatted(userVFXText);
ImGui.NewLine(); ImGui.NewLine();
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("You"); ImGui.TextUnformatted("You");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableVFX()); UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableVFX());
ImGui.SameLine(); ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("They"); ImGui.TextUnformatted("They");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableVFX()); UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableVFX());
} }
@@ -403,29 +386,38 @@ public class DrawUserPair
} }
} }
rightSideStart = windowEndX - barButtonSize.X - spacingX * 3 - pauseIconSize.X - infoIconDist; if (_currentGroup != null)
ImGui.SameLine(windowEndX - barButtonSize.X - spacingX - pauseIconSize.X);
if (ImGuiComponents.IconButton(pauseIcon))
{ {
var perm = _pair.UserPair!.OwnPermissions; var icon = FontAwesomeIcon.None;
perm.SetPaused(!perm.IsPaused()); var text = string.Empty;
_ = _apiController.UserSetPairPermissions(new(_pair.UserData, perm)); if (string.Equals(_currentGroup.OwnerUID, _pair.UserData.UID, StringComparison.Ordinal))
} {
UiSharedService.AttachToolTip(!_pair.UserPair!.OwnPermissions.IsPaused() icon = FontAwesomeIcon.Crown;
? "Pause pairing with " + entryUID text = "User is owner of this syncshell";
: "Resume pairing with " + entryUID); }
else if (_currentGroup.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var userinfo))
{
if (userinfo.IsModerator())
{
icon = FontAwesomeIcon.UserShield;
text = "User is moderator in this syncshell";
}
else if (userinfo.IsPinned())
{
icon = FontAwesomeIcon.Thumbtack;
text = "User is pinned in this syncshell";
}
}
// Flyout Menu if (!string.IsNullOrEmpty(text))
if (rightSideStart == 0f) {
{ currentRightSide -= (UiSharedService.GetIconData(icon).NormalizedIconScale.X + spacingX);
rightSideStart = windowEndX - barButtonSize.X; ImGui.SameLine(currentRightSide);
} UiSharedService.NormalizedIcon(icon);
ImGui.SameLine(windowEndX - barButtonSize.X); UiSharedService.AttachToolTip(text);
ImGui.AlignTextToFramePadding(); }
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars))
{
ImGui.OpenPopup("User Flyout Menu");
} }
if (ImGui.BeginPopup("User Flyout Menu")) if (ImGui.BeginPopup("User Flyout Menu"))
{ {
using (ImRaii.PushId($"buttons-{_pair.UserData.UID}")) using (ImRaii.PushId($"buttons-{_pair.UserData.UID}"))
@@ -443,7 +435,7 @@ public class DrawUserPair
ImGui.EndPopup(); ImGui.EndPopup();
} }
return rightSideStart; return currentRightSide - spacingX;
} }
private void DrawSyncshellMenu(GroupFullInfoDto group, bool selfIsOwner, bool selfIsModerator, bool userIsPinned, bool userIsModerator) private void DrawSyncshellMenu(GroupFullInfoDto group, bool selfIsOwner, bool selfIsModerator, bool userIsPinned, bool userIsModerator)
@@ -452,7 +444,7 @@ public class DrawUserPair
{ {
ImGui.TextUnformatted("Syncshell Moderator Functions"); ImGui.TextUnformatted("Syncshell Moderator Functions");
var pinText = userIsPinned ? "Unpin user" : "Pin user"; var pinText = userIsPinned ? "Unpin user" : "Pin user";
if (UiSharedService.IconTextButton(FontAwesomeIcon.Thumbtack, pinText, _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Thumbtack, pinText, _menuRenderWidth, true))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
if (!group.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var userinfo)) if (!group.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var userinfo))
@@ -467,14 +459,14 @@ public class DrawUserPair
} }
UiSharedService.AttachToolTip("Pin this user to the Syncshell. Pinned users will not be deleted in case of a manually initiated Syncshell clean"); UiSharedService.AttachToolTip("Pin this user to the Syncshell. Pinned users will not be deleted in case of a manually initiated Syncshell clean");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Remove user", _menuRenderWidth, true) && UiSharedService.CtrlPressed()) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Remove user", _menuRenderWidth, true) && UiSharedService.CtrlPressed())
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
_ = _apiController.GroupRemoveUser(new(group.Group, _pair.UserData)); _ = _apiController.GroupRemoveUser(new(group.Group, _pair.UserData));
} }
UiSharedService.AttachToolTip("Hold CTRL and click to remove user " + (_pair.UserData.AliasOrUID) + " from Syncshell"); UiSharedService.AttachToolTip("Hold CTRL and click to remove user " + (_pair.UserData.AliasOrUID) + " from Syncshell");
if (UiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User", _menuRenderWidth, true)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserSlash, "Ban User", _menuRenderWidth, true))
{ {
_mediator.Publish(new OpenBanUserPopupMessage(_pair, group)); _mediator.Publish(new OpenBanUserPopupMessage(_pair, group));
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
@@ -488,7 +480,7 @@ public class DrawUserPair
{ {
ImGui.TextUnformatted("Syncshell Owner Functions"); ImGui.TextUnformatted("Syncshell Owner Functions");
string modText = userIsModerator ? "Demod user" : "Mod user"; string modText = userIsModerator ? "Demod user" : "Mod user";
if (UiSharedService.IconTextButton(FontAwesomeIcon.UserShield, modText, _menuRenderWidth, true) && UiSharedService.CtrlPressed()) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserShield, modText, _menuRenderWidth, true) && UiSharedService.CtrlPressed())
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
if (!group.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var userinfo)) if (!group.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var userinfo))
@@ -505,7 +497,7 @@ public class DrawUserPair
UiSharedService.AttachToolTip("Hold CTRL to change the moderator status for " + (_pair.UserData.AliasOrUID) + Environment.NewLine + UiSharedService.AttachToolTip("Hold CTRL to change the moderator status for " + (_pair.UserData.AliasOrUID) + Environment.NewLine +
"Moderators can kick, ban/unban, pin/unpin users and clear the Syncshell."); "Moderators can kick, ban/unban, pin/unpin users and clear the Syncshell.");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Crown, "Transfer Ownership", _menuRenderWidth, true) && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed()) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Crown, "Transfer Ownership", _menuRenderWidth, true) && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
_ = _apiController.GroupChangeOwnership(new(group.Group, _pair.UserData)); _ = _apiController.GroupChangeOwnership(new(group.Group, _pair.UserData));

View File

@@ -27,7 +27,7 @@ public class BanUserPopupHandler : IPopupHandler
UiSharedService.TextWrapped("User " + (_reportedPair.UserData.AliasOrUID) + " will be banned and removed from this Syncshell."); UiSharedService.TextWrapped("User " + (_reportedPair.UserData.AliasOrUID) + " will be banned and removed from this Syncshell.");
ImGui.InputTextWithHint("##banreason", "Ban Reason", ref _banReason, 255); ImGui.InputTextWithHint("##banreason", "Ban Reason", ref _banReason, 255);
if (UiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
var reason = _banReason; var reason = _banReason;

View File

@@ -63,7 +63,7 @@ public class PopupHandler : WindowMediatorSubscriberBase
if (!popup) return; if (!popup) return;
_currentHandler.DrawContent(); _currentHandler.DrawContent();
ImGui.Separator(); ImGui.Separator();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Times, "Close")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Times, "Close"))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }

View File

@@ -40,7 +40,7 @@ internal class ReportPopupHandler : IPopupHandler
using (ImRaii.Disabled(string.IsNullOrEmpty(_reportReason))) using (ImRaii.Disabled(string.IsNullOrEmpty(_reportReason)))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Send Report")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ExclamationTriangle, "Send Report"))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
var reason = _reportReason; var reason = _reportReason;

View File

@@ -74,7 +74,7 @@ public class SelectTagForPairUi
ImGui.Separator(); ImGui.Separator();
UiSharedService.FontText($"Create a new group for {name}.", UiBuilder.DefaultFont); UiSharedService.FontText($"Create a new group for {name}.", UiBuilder.DefaultFont);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Plus)) if (UiSharedService.NormalizedIconButton(FontAwesomeIcon.Plus))
{ {
HandleAddTag(); HandleAddTag();
} }

View File

@@ -42,7 +42,7 @@ public class CreateSyncshellUI : WindowMediatorSubscriberBase
if (_lastCreatedGroup == null) if (_lastCreatedGroup == null)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Create Syncshell")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Create Syncshell"))
{ {
try try
{ {
@@ -67,10 +67,13 @@ public class CreateSyncshellUI : WindowMediatorSubscriberBase
"- Syncshells on this server can have a maximum of " + _apiController.ServerInfo.MaxGroupUserCount + " users"); "- Syncshells on this server can have a maximum of " + _apiController.ServerInfo.MaxGroupUserCount + " users");
ImGuiHelpers.ScaledDummy(2f); ImGuiHelpers.ScaledDummy(2f);
ImGui.TextUnformatted("Your current Syncshell preferred permissions are:"); ImGui.TextUnformatted("Your current Syncshell preferred permissions are:");
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("- Animations"); ImGui.TextUnformatted("- Animations");
UiSharedService.BooleanToColoredIcon(!_apiController.DefaultPermissions!.DisableGroupAnimations); UiSharedService.BooleanToColoredIcon(!_apiController.DefaultPermissions!.DisableGroupAnimations);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("- Sounds"); ImGui.TextUnformatted("- Sounds");
UiSharedService.BooleanToColoredIcon(!_apiController.DefaultPermissions!.DisableGroupSounds); UiSharedService.BooleanToColoredIcon(!_apiController.DefaultPermissions!.DisableGroupSounds);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("- VFX"); ImGui.TextUnformatted("- VFX");
UiSharedService.BooleanToColoredIcon(!_apiController.DefaultPermissions!.DisableGroupVFX); UiSharedService.BooleanToColoredIcon(!_apiController.DefaultPermissions!.DisableGroupVFX);
UiSharedService.TextWrapped("(Those preferred permissions can be changed anytime after Syncshell creation, your defaults can be changed anytime in the Mare Settings)"); UiSharedService.TextWrapped("(Those preferred permissions can be changed anytime after Syncshell creation, your defaults can be changed anytime in the Mare Settings)");
@@ -82,7 +85,7 @@ public class CreateSyncshellUI : WindowMediatorSubscriberBase
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Syncshell Password: " + _lastCreatedGroup.Password); ImGui.TextUnformatted("Syncshell Password: " + _lastCreatedGroup.Password);
ImGui.SameLine(); ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.Copy)) if (UiSharedService.NormalizedIconButton(FontAwesomeIcon.Copy))
{ {
ImGui.SetClipboardText(_lastCreatedGroup.Password); ImGui.SetClipboardText(_lastCreatedGroup.Password);
} }
@@ -90,10 +93,13 @@ public class CreateSyncshellUI : WindowMediatorSubscriberBase
ImGui.Separator(); ImGui.Separator();
UiSharedService.TextWrapped("These settings were set based on your preferred syncshell permissions:"); UiSharedService.TextWrapped("These settings were set based on your preferred syncshell permissions:");
ImGuiHelpers.ScaledDummy(2f); ImGuiHelpers.ScaledDummy(2f);
ImGui.AlignTextToFramePadding();
UiSharedService.TextWrapped("Suggest Animation sync:"); UiSharedService.TextWrapped("Suggest Animation sync:");
UiSharedService.BooleanToColoredIcon(!_lastCreatedGroup.GroupUserPreferredPermissions.IsDisableAnimations()); UiSharedService.BooleanToColoredIcon(!_lastCreatedGroup.GroupUserPreferredPermissions.IsDisableAnimations());
ImGui.AlignTextToFramePadding();
UiSharedService.TextWrapped("Suggest Sounds sync:"); UiSharedService.TextWrapped("Suggest Sounds sync:");
UiSharedService.BooleanToColoredIcon(!_lastCreatedGroup.GroupUserPreferredPermissions.IsDisableSounds()); UiSharedService.BooleanToColoredIcon(!_lastCreatedGroup.GroupUserPreferredPermissions.IsDisableSounds());
ImGui.AlignTextToFramePadding();
UiSharedService.TextWrapped("Suggest VFX sync:"); UiSharedService.TextWrapped("Suggest VFX sync:");
UiSharedService.BooleanToColoredIcon(!_lastCreatedGroup.GroupUserPreferredPermissions.IsDisableVFX()); UiSharedService.BooleanToColoredIcon(!_lastCreatedGroup.GroupUserPreferredPermissions.IsDisableVFX());
} }

View File

@@ -65,7 +65,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
{ {
ImGui.TextUnformatted("BC7 Conversion in progress: " + _conversionCurrentFileProgress + "/" + _texturesToConvert.Count); ImGui.TextUnformatted("BC7 Conversion in progress: " + _conversionCurrentFileProgress + "/" + _texturesToConvert.Count);
UiSharedService.TextWrapped("Current file: " + _conversionCurrentFileName); UiSharedService.TextWrapped("Current file: " + _conversionCurrentFileName);
if (UiSharedService.IconTextButton(FontAwesomeIcon.StopCircle, "Cancel conversion")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StopCircle, "Cancel conversion"))
{ {
_conversionCancellationTokenSource.Cancel(); _conversionCancellationTokenSource.Cancel();
} }
@@ -107,7 +107,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
{ {
UiSharedService.ColorTextWrapped($"Analyzing {_characterAnalyzer.CurrentFile}/{_characterAnalyzer.TotalFiles}", UiSharedService.ColorTextWrapped($"Analyzing {_characterAnalyzer.CurrentFile}/{_characterAnalyzer.TotalFiles}",
ImGuiColors.DalamudYellow); ImGuiColors.DalamudYellow);
if (UiSharedService.IconTextButton(FontAwesomeIcon.StopCircle, "Cancel analysis")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StopCircle, "Cancel analysis"))
{ {
_characterAnalyzer.CancelAnalyze(); _characterAnalyzer.CancelAnalyze();
} }
@@ -118,14 +118,14 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
{ {
UiSharedService.ColorTextWrapped("Some entries in the analysis have file size not determined yet, press the button below to analyze your current data", UiSharedService.ColorTextWrapped("Some entries in the analysis have file size not determined yet, press the button below to analyze your current data",
ImGuiColors.DalamudYellow); ImGuiColors.DalamudYellow);
if (UiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (missing entries)")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (missing entries)"))
{ {
_ = _characterAnalyzer.ComputeAnalysis(print: false); _ = _characterAnalyzer.ComputeAnalysis(print: false);
} }
} }
else else
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (recalculate all entries)")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (recalculate all entries)"))
{ {
_ = _characterAnalyzer.ComputeAnalysis(print: false, recalculate: true); _ = _characterAnalyzer.ComputeAnalysis(print: false, recalculate: true);
} }
@@ -259,7 +259,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
Environment.NewLine + "- Conversion will convert all found texture duplicates (entries with more than 1 file path) automatically." + Environment.NewLine + "- Conversion will convert all found texture duplicates (entries with more than 1 file path) automatically." +
Environment.NewLine + "- Converting textures to BC7 is a very expensive operation and, depending on the amount of textures to convert, will take a while to complete." Environment.NewLine + "- Converting textures to BC7 is a very expensive operation and, depending on the amount of textures to convert, will take a while to complete."
, ImGuiColors.DalamudYellow); , ImGuiColors.DalamudYellow);
if (_texturesToConvert.Count > 0 && UiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Start conversion of " + _texturesToConvert.Count + " texture(s)")) if (_texturesToConvert.Count > 0 && UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PlayCircle, "Start conversion of " + _texturesToConvert.Count + " texture(s)"))
{ {
_conversionCancellationTokenSource = _conversionCancellationTokenSource.CancelRecreate(); _conversionCancellationTokenSource = _conversionCancellationTokenSource.CancelRecreate();
_conversionTask = _ipcManager.PenumbraConvertTextureFiles(_logger, _texturesToConvert, _conversionProgress, _conversionCancellationTokenSource.Token); _conversionTask = _ipcManager.PenumbraConvertTextureFiles(_logger, _texturesToConvert, _conversionProgress, _conversionCancellationTokenSource.Token);

View File

@@ -131,7 +131,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
ImGui.Separator(); ImGui.Separator();
_uiSharedService.BigText("Profile Settings"); _uiSharedService.BigText("Profile Settings");
if (UiSharedService.IconTextButton(FontAwesomeIcon.FileUpload, "Upload new profile picture")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FileUpload, "Upload new profile picture"))
{ {
_fileDialogManager.OpenFileDialog("Select new Profile picture", ".png", (success, file) => _fileDialogManager.OpenFileDialog("Select new Profile picture", ".png", (success, file) =>
{ {
@@ -162,7 +162,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
} }
UiSharedService.AttachToolTip("Select and upload a new profile picture"); UiSharedService.AttachToolTip("Select and upload a new profile picture");
ImGui.SameLine(); ImGui.SameLine();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Clear uploaded profile picture")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Clear uploaded profile picture"))
{ {
_ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, IsNSFW: null, "", Description: null)); _ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, IsNSFW: null, "", Description: null));
} }
@@ -211,13 +211,13 @@ public class EditProfileUi : WindowMediatorSubscriberBase
ImGui.EndChildFrame(); ImGui.EndChildFrame();
ImGui.PopFont(); ImGui.PopFont();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Save, "Save Description")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Save, "Save Description"))
{ {
_ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, IsNSFW: null, ProfilePictureBase64: null, _descriptionText)); _ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, IsNSFW: null, ProfilePictureBase64: null, _descriptionText));
} }
UiSharedService.AttachToolTip("Sets your profile description text"); UiSharedService.AttachToolTip("Sets your profile description text");
ImGui.SameLine(); ImGui.SameLine();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Clear Description")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Clear Description"))
{ {
_ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, IsNSFW: null, ProfilePictureBase64: null, "")); _ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, IsNSFW: null, ProfilePictureBase64: null, ""));
} }

View File

@@ -41,7 +41,7 @@ public class GposeUi : WindowMediatorSubscriberBase
if (!_mareCharaFileManager.CurrentlyWorking) if (!_mareCharaFileManager.CurrentlyWorking)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.FolderOpen, "Load MCDF")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FolderOpen, "Load MCDF"))
{ {
_fileDialogManager.OpenFileDialog("Pick MCDF file", ".mcdf", (success, paths) => _fileDialogManager.OpenFileDialog("Pick MCDF file", ".mcdf", (success, paths) =>
{ {
@@ -59,7 +59,7 @@ public class GposeUi : WindowMediatorSubscriberBase
{ {
UiSharedService.TextWrapped("Loaded file: " + _mareCharaFileManager.LoadedCharaFile.FilePath); UiSharedService.TextWrapped("Loaded file: " + _mareCharaFileManager.LoadedCharaFile.FilePath);
UiSharedService.TextWrapped("File Description: " + _mareCharaFileManager.LoadedCharaFile.CharaFileData.Description); UiSharedService.TextWrapped("File Description: " + _mareCharaFileManager.LoadedCharaFile.CharaFileData.Description);
if (UiSharedService.IconTextButton(FontAwesomeIcon.Check, "Apply loaded MCDF")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Check, "Apply loaded MCDF"))
{ {
_ = Task.Run(async () => await _mareCharaFileManager.ApplyMareCharaFile(_dalamudUtil.GposeTargetGameObject).ConfigureAwait(false)); _ = Task.Run(async () => await _mareCharaFileManager.ApplyMareCharaFile(_dalamudUtil.GposeTargetGameObject).ConfigureAwait(false));
} }

View File

@@ -74,7 +74,7 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
ImGui.InputTextWithHint("##syncshellpw", "Password", ref _syncshellPassword, 50, ImGuiInputTextFlags.Password); ImGui.InputTextWithHint("##syncshellpw", "Password", ref _syncshellPassword, 50, ImGuiInputTextFlags.Password);
using (ImRaii.Disabled(string.IsNullOrEmpty(_desiredSyncshellToJoin) || string.IsNullOrEmpty(_syncshellPassword))) using (ImRaii.Disabled(string.IsNullOrEmpty(_desiredSyncshellToJoin) || string.IsNullOrEmpty(_syncshellPassword)))
{ {
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Plus, "Join Syncshell")) if (UiSharedService.NormalizedIconTextButton(Dalamud.Interface.FontAwesomeIcon.Plus, "Join Syncshell"))
{ {
_groupJoinInfo = _apiController.GroupJoin(new GroupPasswordDto(new API.Data.GroupData(_desiredSyncshellToJoin), _syncshellPassword)).Result; _groupJoinInfo = _apiController.GroupJoin(new GroupPasswordDto(new API.Data.GroupData(_desiredSyncshellToJoin), _syncshellPassword)).Result;
_previousPassword = _syncshellPassword; _previousPassword = _syncshellPassword;
@@ -94,10 +94,13 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
ImGui.TextUnformatted("You are about to join the Syncshell " + _groupJoinInfo.GroupAliasOrGID + " by " + _groupJoinInfo.OwnerAliasOrUID); ImGui.TextUnformatted("You are about to join the Syncshell " + _groupJoinInfo.GroupAliasOrGID + " by " + _groupJoinInfo.OwnerAliasOrUID);
ImGuiHelpers.ScaledDummy(2f); ImGuiHelpers.ScaledDummy(2f);
ImGui.TextUnformatted("This Syncshell staff has set the following suggested Syncshell permissions:"); ImGui.TextUnformatted("This Syncshell staff has set the following suggested Syncshell permissions:");
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("- Sounds "); ImGui.TextUnformatted("- Sounds ");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableSounds()); UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableSounds());
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("- Animations"); ImGui.TextUnformatted("- Animations");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableAnimations()); UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableAnimations());
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("- VFX"); ImGui.TextUnformatted("- VFX");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableVFX()); UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableVFX());
@@ -113,11 +116,12 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
ImGui.TextUnformatted("- Sounds"); ImGui.TextUnformatted("- Sounds");
UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupSounds); UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupSounds);
ImGui.SameLine(200); ImGui.SameLine(200);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Suggested"); ImGui.TextUnformatted("Suggested");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableSounds()); UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableSounds());
ImGui.SameLine(); ImGui.SameLine();
using var id = ImRaii.PushId("suggestedSounds"); using var id = ImRaii.PushId("suggestedSounds");
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested")) if (UiSharedService.NormalizedIconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested"))
{ {
_ownPermissions.DisableGroupSounds = _groupJoinInfo.GroupPermissions.IsPreferDisableSounds(); _ownPermissions.DisableGroupSounds = _groupJoinInfo.GroupPermissions.IsPreferDisableSounds();
} }
@@ -128,11 +132,12 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
ImGui.TextUnformatted("- Animations"); ImGui.TextUnformatted("- Animations");
UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupAnimations); UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupAnimations);
ImGui.SameLine(200); ImGui.SameLine(200);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Suggested"); ImGui.TextUnformatted("Suggested");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableAnimations()); UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableAnimations());
ImGui.SameLine(); ImGui.SameLine();
using var id = ImRaii.PushId("suggestedAnims"); using var id = ImRaii.PushId("suggestedAnims");
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested")) if (UiSharedService.NormalizedIconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested"))
{ {
_ownPermissions.DisableGroupAnimations = _groupJoinInfo.GroupPermissions.IsPreferDisableAnimations(); _ownPermissions.DisableGroupAnimations = _groupJoinInfo.GroupPermissions.IsPreferDisableAnimations();
} }
@@ -143,11 +148,12 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
ImGui.TextUnformatted("- VFX"); ImGui.TextUnformatted("- VFX");
UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupVFX); UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupVFX);
ImGui.SameLine(200); ImGui.SameLine(200);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Suggested"); ImGui.TextUnformatted("Suggested");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableVFX()); UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableVFX());
ImGui.SameLine(); ImGui.SameLine();
using var id = ImRaii.PushId("suggestedVfx"); using var id = ImRaii.PushId("suggestedVfx");
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested")) if (UiSharedService.NormalizedIconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested"))
{ {
_ownPermissions.DisableGroupVFX = _groupJoinInfo.GroupPermissions.IsPreferDisableVFX(); _ownPermissions.DisableGroupVFX = _groupJoinInfo.GroupPermissions.IsPreferDisableVFX();
} }
@@ -159,7 +165,7 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
UiSharedService.TextWrapped("Your default syncshell permissions on joining are in line with the suggested Syncshell permissions through the owner."); UiSharedService.TextWrapped("Your default syncshell permissions on joining are in line with the suggested Syncshell permissions through the owner.");
} }
ImGuiHelpers.ScaledDummy(2f); ImGuiHelpers.ScaledDummy(2f);
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Plus, "Finalize and join " + _groupJoinInfo.GroupAliasOrGID)) if (UiSharedService.NormalizedIconTextButton(Dalamud.Interface.FontAwesomeIcon.Plus, "Finalize and join " + _groupJoinInfo.GroupAliasOrGID))
{ {
GroupUserPreferredPermissions joinPermissions = GroupUserPreferredPermissions.NoneSet; GroupUserPreferredPermissions joinPermissions = GroupUserPreferredPermissions.NoneSet;
joinPermissions.SetDisableSounds(_ownPermissions.DisableGroupSounds); joinPermissions.SetDisableSounds(_ownPermissions.DisableGroupSounds);

View File

@@ -327,7 +327,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.TreePop(); ImGui.TreePop();
} }
#endif #endif
if (UiSharedService.IconTextButton(FontAwesomeIcon.Copy, "[DEBUG] Copy Last created Character Data to clipboard")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Copy, "[DEBUG] Copy Last created Character Data to clipboard"))
{ {
if (LastCreatedCharacterData != null) if (LastCreatedCharacterData != null)
{ {
@@ -355,12 +355,12 @@ public class SettingsUi : WindowMediatorSubscriberBase
UiSharedService.DrawHelpText("Enabling this can incur a (slight) performance impact. Enabling this for extended periods of time is not recommended."); UiSharedService.DrawHelpText("Enabling this can incur a (slight) performance impact. Enabling this for extended periods of time is not recommended.");
using var disabled = ImRaii.Disabled(!logPerformance); using var disabled = ImRaii.Disabled(!logPerformance);
if (UiSharedService.IconTextButton(FontAwesomeIcon.StickyNote, "Print Performance Stats to /xllog")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StickyNote, "Print Performance Stats to /xllog"))
{ {
_performanceCollector.PrintPerformanceStats(); _performanceCollector.PrintPerformanceStats();
} }
ImGui.SameLine(); ImGui.SameLine();
if (UiSharedService.IconTextButton(FontAwesomeIcon.StickyNote, "Print Performance Stats (last 60s) to /xllog")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StickyNote, "Print Performance Stats (last 60s) to /xllog"))
{ {
_performanceCollector.PrintPerformanceStats(60); _performanceCollector.PrintPerformanceStats(60);
} }
@@ -386,7 +386,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (!_mareCharaFileManager.CurrentlyWorking) if (!_mareCharaFileManager.CurrentlyWorking)
{ {
ImGui.InputTextWithHint("Export Descriptor", "This description will be shown on loading the data", ref _exportDescription, 255); ImGui.InputTextWithHint("Export Descriptor", "This description will be shown on loading the data", ref _exportDescription, 255);
if (UiSharedService.IconTextButton(FontAwesomeIcon.Save, "Export Character as MCDF")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Save, "Export Character as MCDF"))
{ {
string defaultFileName = string.IsNullOrEmpty(_exportDescription) string defaultFileName = string.IsNullOrEmpty(_exportDescription)
? "export.mcdf" ? "export.mcdf"
@@ -454,14 +454,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.SameLine(); ImGui.SameLine();
if (!_fileCompactor.MassCompactRunning) if (!_fileCompactor.MassCompactRunning)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.FileArchive, "Compact all files in storage")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FileArchive, "Compact all files in storage"))
{ {
_ = Task.Run(() => _fileCompactor.CompactStorage(compress: true)); _ = Task.Run(() => _fileCompactor.CompactStorage(compress: true));
} }
UiSharedService.AttachToolTip("This will run compression on all files in your current Mare Storage." + Environment.NewLine UiSharedService.AttachToolTip("This will run compression on all files in your current Mare Storage." + Environment.NewLine
+ "You do not need to run this manually if you keep the file compactor enabled."); + "You do not need to run this manually if you keep the file compactor enabled.");
ImGui.SameLine(); ImGui.SameLine();
if (UiSharedService.IconTextButton(FontAwesomeIcon.File, "Decompact all files in storage")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.File, "Decompact all files in storage"))
{ {
_ = Task.Run(() => _fileCompactor.CompactStorage(compress: false)); _ = Task.Run(() => _fileCompactor.CompactStorage(compress: false));
} }
@@ -487,7 +487,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
+ Environment.NewLine + "- This can make the situation of not getting other players data worse in situations of heavy file server load."); + Environment.NewLine + "- This can make the situation of not getting other players data worse in situations of heavy file server load.");
if (!_readClearCache) if (!_readClearCache)
ImGui.BeginDisabled(); ImGui.BeginDisabled();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Clear local storage") && UiSharedService.CtrlPressed() && _readClearCache) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Clear local storage") && UiSharedService.CtrlPressed() && _readClearCache)
{ {
_ = Task.Run(() => _ = Task.Run(() =>
{ {
@@ -529,11 +529,11 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Separator(); ImGui.Separator();
UiSharedService.FontText("Notes", _uiShared.UidFont); UiSharedService.FontText("Notes", _uiShared.UidFont);
if (UiSharedService.IconTextButton(FontAwesomeIcon.StickyNote, "Export all your user notes to clipboard")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StickyNote, "Export all your user notes to clipboard"))
{ {
ImGui.SetClipboardText(UiSharedService.GetNotes(_pairManager.DirectPairs.UnionBy(_pairManager.GroupPairs.SelectMany(p => p.Value), p => p.UserData, UserDataComparer.Instance).ToList())); ImGui.SetClipboardText(UiSharedService.GetNotes(_pairManager.DirectPairs.UnionBy(_pairManager.GroupPairs.SelectMany(p => p.Value), p => p.UserData, UserDataComparer.Instance).ToList()));
} }
if (UiSharedService.IconTextButton(FontAwesomeIcon.FileImport, "Import notes from clipboard")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FileImport, "Import notes from clipboard"))
{ {
_notesSuccessfullyApplied = null; _notesSuccessfullyApplied = null;
var notes = ImGui.GetClipboardText(); var notes = ImGui.GetClipboardText();
@@ -931,7 +931,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
}, EqualityComparer<KeyValuePair<int, SecretKey>>.Default.Equals(keys.FirstOrDefault(f => f.Key == item.SecretKeyIdx), default) ? keys.First() : keys.First(f => f.Key == item.SecretKeyIdx)); }, EqualityComparer<KeyValuePair<int, SecretKey>>.Default.Equals(keys.FirstOrDefault(f => f.Key == item.SecretKeyIdx), default) ? keys.First() : keys.First(f => f.Key == item.SecretKeyIdx));
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Character") && UiSharedService.CtrlPressed()) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete Character") && UiSharedService.CtrlPressed())
_serverConfigurationManager.RemoveCharacterFromServer(idx, item); _serverConfigurationManager.RemoveCharacterFromServer(idx, item);
UiSharedService.AttachToolTip("Hold CTRL to delete this entry."); UiSharedService.AttachToolTip("Hold CTRL to delete this entry.");
@@ -945,14 +945,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (!selectedServer.Authentications.Exists(c => string.Equals(c.CharacterName, _uiShared.PlayerName, StringComparison.Ordinal) if (!selectedServer.Authentications.Exists(c => string.Equals(c.CharacterName, _uiShared.PlayerName, StringComparison.Ordinal)
&& c.WorldId == _uiShared.WorldId)) && c.WorldId == _uiShared.WorldId))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.User, "Add current character")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.User, "Add current character"))
{ {
_serverConfigurationManager.AddCurrentCharacterToServer(idx); _serverConfigurationManager.AddCurrentCharacterToServer(idx);
} }
ImGui.SameLine(); ImGui.SameLine();
} }
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Add new character")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Add new character"))
{ {
_serverConfigurationManager.AddEmptyCharacterToServer(idx); _serverConfigurationManager.AddEmptyCharacterToServer(idx);
} }
@@ -984,7 +984,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
if (!selectedServer.Authentications.Exists(p => p.SecretKeyIdx == item.Key)) if (!selectedServer.Authentications.Exists(p => p.SecretKeyIdx == item.Key))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Secret Key") && UiSharedService.CtrlPressed()) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete Secret Key") && UiSharedService.CtrlPressed())
{ {
selectedServer.SecretKeys.Remove(item.Key); selectedServer.SecretKeys.Remove(item.Key);
_serverConfigurationManager.Save(); _serverConfigurationManager.Save();
@@ -1001,7 +1001,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
ImGui.Separator(); ImGui.Separator();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Add new Secret Key")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Add new Secret Key"))
{ {
selectedServer.SecretKeys.Add(selectedServer.SecretKeys.Any() ? selectedServer.SecretKeys.Max(p => p.Key) + 1 : 0, new SecretKey() selectedServer.SecretKeys.Add(selectedServer.SecretKeys.Any() ? selectedServer.SecretKeys.Max(p => p.Key) + 1 : 0, new SecretKey()
{ {
@@ -1041,7 +1041,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (!isMain && selectedServer != _serverConfigurationManager.CurrentServer) if (!isMain && selectedServer != _serverConfigurationManager.CurrentServer)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Service") && UiSharedService.CtrlPressed()) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete Service") && UiSharedService.CtrlPressed())
{ {
_serverConfigurationManager.DeleteServer(selectedServer); _serverConfigurationManager.DeleteServer(selectedServer);
} }

View File

@@ -71,7 +71,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
{ {
bool isInvitesDisabled = perm.IsDisableInvites(); bool isInvitesDisabled = perm.IsDisableInvites();
if (UiSharedService.IconTextButton(isInvitesDisabled ? FontAwesomeIcon.Unlock : FontAwesomeIcon.Lock, if (UiSharedService.NormalizedIconTextButton(isInvitesDisabled ? FontAwesomeIcon.Unlock : FontAwesomeIcon.Lock,
isInvitesDisabled ? "Unlock Syncshell" : "Lock Syncshell")) isInvitesDisabled ? "Unlock Syncshell" : "Lock Syncshell"))
{ {
perm.SetDisableInvites(!isInvitesDisabled); perm.SetDisableInvites(!isInvitesDisabled);
@@ -81,7 +81,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGuiHelpers.ScaledDummy(2f); ImGuiHelpers.ScaledDummy(2f);
UiSharedService.TextWrapped("One-time invites work as single-use passwords. Use those if you do not want to distribute your Syncshell password."); UiSharedService.TextWrapped("One-time invites work as single-use passwords. Use those if you do not want to distribute your Syncshell password.");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Envelope, "Single one-time invite")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Envelope, "Single one-time invite"))
{ {
ImGui.SetClipboardText(_apiController.GroupCreateTempInvite(new(GroupFullInfo.Group), 1).Result.FirstOrDefault() ?? string.Empty); ImGui.SetClipboardText(_apiController.GroupCreateTempInvite(new(GroupFullInfo.Group), 1).Result.FirstOrDefault() ?? string.Empty);
} }
@@ -90,7 +90,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.SameLine(); ImGui.SameLine();
using (ImRaii.Disabled(_multiInvites <= 1 || _multiInvites > 100)) using (ImRaii.Disabled(_multiInvites <= 1 || _multiInvites > 100))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Envelope, "Generate " + _multiInvites + " one-time invites")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Envelope, "Generate " + _multiInvites + " one-time invites"))
{ {
_oneTimeInvites.AddRange(_apiController.GroupCreateTempInvite(new(GroupFullInfo.Group), _multiInvites).Result); _oneTimeInvites.AddRange(_apiController.GroupCreateTempInvite(new(GroupFullInfo.Group), _multiInvites).Result);
} }
@@ -100,7 +100,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
{ {
var invites = string.Join(Environment.NewLine, _oneTimeInvites); var invites = string.Join(Environment.NewLine, _oneTimeInvites);
ImGui.InputTextMultiline("Generated Multi Invites", ref invites, 5000, new(0, 0), ImGuiInputTextFlags.ReadOnly); ImGui.InputTextMultiline("Generated Multi Invites", ref invites, 5000, new(0, 0), ImGuiInputTextFlags.ReadOnly);
if (UiSharedService.IconTextButton(FontAwesomeIcon.Copy, "Copy Invites to clipboard")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Copy, "Copy Invites to clipboard"))
{ {
ImGui.SetClipboardText(invites); ImGui.SetClipboardText(invites);
} }
@@ -111,7 +111,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
var mgmtTab = ImRaii.TabItem("User Management"); var mgmtTab = ImRaii.TabItem("User Management");
if (mgmtTab) if (mgmtTab)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Broom, "Clear Syncshell")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Broom, "Clear Syncshell"))
{ {
_ = _apiController.GroupClear(new(GroupFullInfo.Group)); _ = _apiController.GroupClear(new(GroupFullInfo.Group));
} }
@@ -119,7 +119,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGuiHelpers.ScaledDummy(2f); ImGuiHelpers.ScaledDummy(2f);
if (UiSharedService.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
{ {
_bannedUsers = _apiController.GroupGetBannedUsers(new GroupDto(GroupFullInfo.Group)).Result; _bannedUsers = _apiController.GroupGetBannedUsers(new GroupDto(GroupFullInfo.Group)).Result;
} }
@@ -148,7 +148,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.TableNextColumn(); ImGui.TableNextColumn();
UiSharedService.TextWrapped(bannedUser.Reason); UiSharedService.TextWrapped(bannedUser.Reason);
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Check, "Unban#" + bannedUser.UID)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Check, "Unban#" + bannedUser.UID))
{ {
_ = _apiController.GroupUnbanUser(bannedUser); _ = _apiController.GroupUnbanUser(bannedUser);
_bannedUsers.RemoveAll(b => string.Equals(b.UID, bannedUser.UID, StringComparison.Ordinal)); _bannedUsers.RemoveAll(b => string.Equals(b.UID, bannedUser.UID, StringComparison.Ordinal));
@@ -171,7 +171,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.Text("Suggest Sound Sync"); ImGui.Text("Suggest Sound Sync");
UiSharedService.BooleanToColoredIcon(!isDisableSounds); UiSharedService.BooleanToColoredIcon(!isDisableSounds);
ImGui.SameLine(230); ImGui.SameLine(230);
if (UiSharedService.IconTextButton(isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute, if (UiSharedService.NormalizedIconTextButton(isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute,
isDisableSounds ? "Suggest to enable sound sync" : "Suggest to disable sound sync")) isDisableSounds ? "Suggest to enable sound sync" : "Suggest to disable sound sync"))
{ {
perm.SetPreferDisableSounds(!perm.IsPreferDisableSounds()); perm.SetPreferDisableSounds(!perm.IsPreferDisableSounds());
@@ -182,7 +182,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.Text("Suggest Animation Sync"); ImGui.Text("Suggest Animation Sync");
UiSharedService.BooleanToColoredIcon(!isDisableAnimations); UiSharedService.BooleanToColoredIcon(!isDisableAnimations);
ImGui.SameLine(230); ImGui.SameLine(230);
if (UiSharedService.IconTextButton(isDisableAnimations ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop, if (UiSharedService.NormalizedIconTextButton(isDisableAnimations ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop,
isDisableAnimations ? "Suggest to enable animation sync" : "Suggest to disable animation sync")) isDisableAnimations ? "Suggest to enable animation sync" : "Suggest to disable animation sync"))
{ {
perm.SetPreferDisableAnimations(!perm.IsPreferDisableAnimations()); perm.SetPreferDisableAnimations(!perm.IsPreferDisableAnimations());
@@ -193,7 +193,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.Text("Suggest VFX Sync"); ImGui.Text("Suggest VFX Sync");
UiSharedService.BooleanToColoredIcon(!isDisableVfx); UiSharedService.BooleanToColoredIcon(!isDisableVfx);
ImGui.SameLine(230); ImGui.SameLine(230);
if (UiSharedService.IconTextButton(isDisableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle, if (UiSharedService.NormalizedIconTextButton(isDisableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle,
isDisableVfx ? "Suggest to enable vfx sync" : "Suggest to disable vfx sync")) isDisableVfx ? "Suggest to enable vfx sync" : "Suggest to disable vfx sync"))
{ {
perm.SetPreferDisableVFX(!perm.IsPreferDisableVFX()); perm.SetPreferDisableVFX(!perm.IsPreferDisableVFX());
@@ -212,7 +212,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("New Password"); ImGui.TextUnformatted("New Password");
var availableWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X; var availableWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X;
var buttonSize = UiSharedService.GetIconTextButtonSize(FontAwesomeIcon.Passport, "Change Password").X; var buttonSize = UiSharedService.GetNormalizedIconTextButtonSize(FontAwesomeIcon.Passport, "Change Password").X;
var textSize = ImGui.CalcTextSize("New Password").X; var textSize = ImGui.CalcTextSize("New Password").X;
var spacing = ImGui.GetStyle().ItemSpacing.X; var spacing = ImGui.GetStyle().ItemSpacing.X;
@@ -222,7 +222,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.SameLine(); ImGui.SameLine();
using (ImRaii.Disabled(_newPassword.Length < 10)) using (ImRaii.Disabled(_newPassword.Length < 10))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Passport, "Change Password")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Passport, "Change Password"))
{ {
_pwChangeSuccess = _apiController.GroupChangePassword(new GroupPasswordDto(GroupFullInfo.Group, _newPassword)).Result; _pwChangeSuccess = _apiController.GroupChangePassword(new GroupPasswordDto(GroupFullInfo.Group, _newPassword)).Result;
_newPassword = string.Empty; _newPassword = string.Empty;
@@ -235,7 +235,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
UiSharedService.ColorTextWrapped("Failed to change the password. Password requires to be at least 10 characters long.", ImGuiColors.DalamudYellow); UiSharedService.ColorTextWrapped("Failed to change the password. Password requires to be at least 10 characters long.", ImGuiColors.DalamudYellow);
} }
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed()) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
{ {
IsOpen = false; IsOpen = false;
_ = _apiController.GroupDelete(new(GroupFullInfo.Group)); _ = _apiController.GroupDelete(new(GroupFullInfo.Group));

View File

@@ -178,14 +178,14 @@ public class TopTabMenu
private void DrawAddPair(float availableXWidth, float spacingX) private void DrawAddPair(float availableXWidth, float spacingX)
{ {
var buttonSize = UiSharedService.GetIconTextButtonSize(FontAwesomeIcon.UserPlus, "Add"); var buttonSize = UiSharedService.GetNormalizedIconTextButtonSize(FontAwesomeIcon.UserPlus, "Add");
ImGui.SetNextItemWidth(availableXWidth - buttonSize.X - spacingX); ImGui.SetNextItemWidth(availableXWidth - buttonSize.X - spacingX);
ImGui.InputTextWithHint("##otheruid", "Other players UID/Alias", ref _pairToAdd, 20); ImGui.InputTextWithHint("##otheruid", "Other players UID/Alias", ref _pairToAdd, 20);
ImGui.SameLine(); ImGui.SameLine();
var alreadyExisting = _pairManager.DirectPairs.Exists(p => string.Equals(p.UserData.UID, _pairToAdd, StringComparison.Ordinal) || string.Equals(p.UserData.Alias, _pairToAdd, StringComparison.Ordinal)); var alreadyExisting = _pairManager.DirectPairs.Exists(p => string.Equals(p.UserData.UID, _pairToAdd, StringComparison.Ordinal) || string.Equals(p.UserData.Alias, _pairToAdd, StringComparison.Ordinal));
using (ImRaii.Disabled(alreadyExisting || string.IsNullOrEmpty(_pairToAdd))) using (ImRaii.Disabled(alreadyExisting || string.IsNullOrEmpty(_pairToAdd)))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.UserPlus, "Add")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserPlus, "Add"))
{ {
_ = _apiController.UserAddPair(new(new(_pairToAdd))); _ = _apiController.UserAddPair(new(new(_pairToAdd)));
_pairToAdd = string.Empty; _pairToAdd = string.Empty;
@@ -196,7 +196,7 @@ public class TopTabMenu
private void DrawFilter(float availableWidth, float spacingX) private void DrawFilter(float availableWidth, float spacingX)
{ {
var buttonSize = UiSharedService.GetIconTextButtonSize(FontAwesomeIcon.Ban, "Clear"); var buttonSize = UiSharedService.GetNormalizedIconTextButtonSize(FontAwesomeIcon.Ban, "Clear");
ImGui.SetNextItemWidth(availableWidth - buttonSize.X - spacingX); ImGui.SetNextItemWidth(availableWidth - buttonSize.X - spacingX);
string filter = Filter; string filter = Filter;
if (ImGui.InputTextWithHint("##filter", "Filter for UID/notes", ref filter, 255)) if (ImGui.InputTextWithHint("##filter", "Filter for UID/notes", ref filter, 255))
@@ -205,7 +205,7 @@ public class TopTabMenu
} }
ImGui.SameLine(); ImGui.SameLine();
using var disabled = ImRaii.Disabled(string.IsNullOrEmpty(Filter)); using var disabled = ImRaii.Disabled(string.IsNullOrEmpty(Filter));
if (UiSharedService.IconTextButton(FontAwesomeIcon.Ban, "Clear")) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Ban, "Clear"))
{ {
Filter = string.Empty; Filter = string.Empty;
} }
@@ -466,7 +466,7 @@ public class TopTabMenu
using (ImRaii.Disabled(_pairManager.GroupPairs.Select(k => k.Key).Distinct() using (ImRaii.Disabled(_pairManager.GroupPairs.Select(k => k.Key).Distinct()
.Count(g => string.Equals(g.OwnerUID, _apiController.UID, StringComparison.Ordinal)) >= _apiController.ServerInfo.MaxGroupsCreatedByUser)) .Count(g => string.Equals(g.OwnerUID, _apiController.UID, StringComparison.Ordinal)) >= _apiController.ServerInfo.MaxGroupsCreatedByUser))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Create new Syncshell", buttonX)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Create new Syncshell", buttonX))
{ {
_mareMediator.Publish(new UiToggleMessage(typeof(CreateSyncshellUI))); _mareMediator.Publish(new UiToggleMessage(typeof(CreateSyncshellUI)));
} }
@@ -475,7 +475,7 @@ public class TopTabMenu
using (ImRaii.Disabled(_pairManager.GroupPairs.Select(k => k.Key).Distinct().Count() >= _apiController.ServerInfo.MaxGroupsJoinedByUser)) using (ImRaii.Disabled(_pairManager.GroupPairs.Select(k => k.Key).Distinct().Count() >= _apiController.ServerInfo.MaxGroupsJoinedByUser))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Users, "Join existing Syncshell", buttonX)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Users, "Join existing Syncshell", buttonX))
{ {
_mareMediator.Publish(new UiToggleMessage(typeof(JoinSyncshellUI))); _mareMediator.Publish(new UiToggleMessage(typeof(JoinSyncshellUI)));
} }
@@ -485,13 +485,13 @@ public class TopTabMenu
private void DrawUserConfig(float availableWidth, float spacingX) private void DrawUserConfig(float availableWidth, float spacingX)
{ {
var buttonX = (availableWidth - spacingX) / 2f; var buttonX = (availableWidth - spacingX) / 2f;
if (UiSharedService.IconTextButton(FontAwesomeIcon.UserCircle, "Edit Mare Profile", buttonX)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserCircle, "Edit Mare Profile", buttonX))
{ {
_mareMediator.Publish(new UiToggleMessage(typeof(EditProfileUi))); _mareMediator.Publish(new UiToggleMessage(typeof(EditProfileUi)));
} }
UiSharedService.AttachToolTip("Edit your Mare Profile"); UiSharedService.AttachToolTip("Edit your Mare Profile");
ImGui.SameLine(); ImGui.SameLine();
if (UiSharedService.IconTextButton(FontAwesomeIcon.PersonCircleQuestion, "Chara Data Analysis", buttonX)) if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PersonCircleQuestion, "Chara Data Analysis", buttonX))
{ {
_mareMediator.Publish(new UiToggleMessage(typeof(DataAnalysisUi))); _mareMediator.Publish(new UiToggleMessage(typeof(DataAnalysisUi)));
} }
@@ -518,7 +518,7 @@ public class TopTabMenu
{ {
if (ImGui.BeginPopup(popupTitle)) if (ImGui.BeginPopup(popupTitle))
{ {
if (UiSharedService.IconTextButton(enableIcon, enableText, 0, true)) if (UiSharedService.NormalizedIconTextButton(enableIcon, enableText, 0, true))
{ {
_ = GlobalControlCountdown(10); _ = GlobalControlCountdown(10);
var bulkIndividualPairs = _pairManager.PairsWithGroups.Keys var bulkIndividualPairs = _pairManager.PairsWithGroups.Keys
@@ -532,7 +532,7 @@ public class TopTabMenu
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
if (UiSharedService.IconTextButton(disableIcon, disableText, 0, true)) if (UiSharedService.NormalizedIconTextButton(disableIcon, disableText, 0, true))
{ {
_ = GlobalControlCountdown(10); _ = GlobalControlCountdown(10);
var bulkIndividualPairs = _pairManager.PairsWithGroups.Keys var bulkIndividualPairs = _pairManager.PairsWithGroups.Keys
@@ -556,7 +556,7 @@ public class TopTabMenu
if (ImGui.BeginPopup(popupTitle)) if (ImGui.BeginPopup(popupTitle))
{ {
if (UiSharedService.IconTextButton(enableIcon, enableText, 0, true)) if (UiSharedService.NormalizedIconTextButton(enableIcon, enableText, 0, true))
{ {
_ = GlobalControlCountdown(10); _ = GlobalControlCountdown(10);
var bulkSyncshells = _pairManager.GroupPairs.Keys var bulkSyncshells = _pairManager.GroupPairs.Keys
@@ -570,7 +570,7 @@ public class TopTabMenu
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
if (UiSharedService.IconTextButton(disableIcon, disableText, 0, true)) if (UiSharedService.NormalizedIconTextButton(disableIcon, disableText, 0, true))
{ {
_ = GlobalControlCountdown(10); _ = GlobalControlCountdown(10);
var bulkSyncshells = _pairManager.GroupPairs.Keys var bulkSyncshells = _pairManager.GroupPairs.Keys

View File

@@ -23,6 +23,7 @@ using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using static System.Net.Mime.MediaTypeNames;
namespace MareSynchronos.UI; namespace MareSynchronos.UI;
@@ -153,7 +154,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
public static void BooleanToColoredIcon(bool value, bool inline = true) public static void BooleanToColoredIcon(bool value, bool inline = true)
{ {
using var font = ImRaii.PushFont(UiBuilder.IconFont);
using var colorgreen = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen, value); using var colorgreen = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen, value);
using var colorred = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed, !value); using var colorred = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed, !value);
@@ -161,11 +161,11 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
if (value) if (value)
{ {
ImGui.TextUnformatted(FontAwesomeIcon.Check.ToIconString()); NormalizedIcon(FontAwesomeIcon.Check);
} }
else else
{ {
ImGui.TextUnformatted(FontAwesomeIcon.Times.ToIconString()); NormalizedIcon(FontAwesomeIcon.Times);
} }
} }
@@ -329,24 +329,18 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
return ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X; return ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X;
} }
public static Vector2 GetIconTextButtonSize(FontAwesomeIcon icon, string text, float? width = null, bool isInPopup = false) public static Vector2 GetNormalizedIconTextButtonSize(FontAwesomeIcon icon, string text, float? width = null, bool isInPopup = false)
{ {
var iconSize = GetIconSize(icon); var iconData = GetIconData(icon);
var textSize = ImGui.CalcTextSize(text); var textSize = ImGui.CalcTextSize(text);
var padding = ImGui.GetStyle().FramePadding; var padding = ImGui.GetStyle().FramePadding;
var spacing = ImGui.GetStyle().ItemSpacing; var buttonSizeY = ImGui.GetFrameHeight();
var buttonSizeY = textSize.Y + padding.Y * 2;
var iconExtraSpacing = isInPopup ? padding.X * 2 : 0; var iconExtraSpacing = isInPopup ? padding.X * 2 : 0;
var iconXoffset = iconSize.X <= iconSize.Y ? (iconSize.Y - iconSize.X) / 2f : 0;
var iconScaling = iconSize.X > iconSize.Y ? 1 / (iconSize.X / iconSize.Y) : 1;
if (width == null || width <= 0) if (width == null || width <= 0)
{ {
var buttonSizeX = (iconScaling == 1 ? iconSize.Y : (iconSize.X * iconScaling)) var buttonSizeX = iconData.NormalizedIconScale.X + (padding.X * 4) + iconExtraSpacing + textSize.X;
+ textSize.X + padding.X * 2 + spacing.X + (iconXoffset * 2); return new Vector2(buttonSizeX, buttonSizeY);
return new Vector2(buttonSizeX + iconExtraSpacing, buttonSizeY);
} }
else else
{ {
@@ -354,38 +348,56 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
} }
} }
public static bool IconTextButton(FontAwesomeIcon icon, string text, float? width = null, bool isInPopup = false) public static Vector2 NormalizedIconButtonSize(FontAwesomeIcon icon)
{ {
var wasClicked = false; var iconData = GetIconData(icon);
var padding = ImGui.GetStyle().FramePadding;
var iconSize = GetIconSize(icon);
var textSize = ImGui.CalcTextSize(text); return iconData.NormalizedIconScale with { X = iconData.NormalizedIconScale.X + padding.X * 2, Y = iconData.NormalizedIconScale.Y + padding.Y * 2 };
}
public static bool NormalizedIconButton(FontAwesomeIcon icon)
{
bool wasClicked = false;
var iconData = GetIconData(icon);
var padding = ImGui.GetStyle().FramePadding; var padding = ImGui.GetStyle().FramePadding;
var spacing = ImGui.GetStyle().ItemSpacing;
var cursor = ImGui.GetCursorPos(); var cursor = ImGui.GetCursorPos();
var drawList = ImGui.GetWindowDrawList(); var drawList = ImGui.GetWindowDrawList();
var pos = ImGui.GetWindowPos(); var pos = ImGui.GetWindowPos();
var scrollPosY = ImGui.GetScrollY(); var scrollPosY = ImGui.GetScrollY();
var scrollPosX = ImGui.GetScrollX(); var scrollPosX = ImGui.GetScrollX();
Vector2 buttonSize; var buttonSize = NormalizedIconButtonSize(icon);
var buttonSizeY = textSize.Y + padding.Y * 2;
if (ImGui.Button("###" + icon.ToIconString(), buttonSize))
{
wasClicked = true;
}
drawList.AddText(UiBuilder.IconFont, ImGui.GetFontSize() * iconData.IconScaling,
new(pos.X - scrollPosX + cursor.X + iconData.OffsetX + padding.X,
pos.Y - scrollPosY + cursor.Y + (buttonSize.Y - (iconData.IconSize.Y * iconData.IconScaling)) / 2f),
ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString());
return wasClicked;
}
public static bool NormalizedIconTextButton(FontAwesomeIcon icon, string text, float? width = null, bool isInPopup = false)
{
var wasClicked = false;
var iconData = GetIconData(icon);
var textSize = ImGui.CalcTextSize(text);
var padding = ImGui.GetStyle().FramePadding;
var cursor = ImGui.GetCursorPos();
var drawList = ImGui.GetWindowDrawList();
var pos = ImGui.GetWindowPos();
var scrollPosY = ImGui.GetScrollY();
var scrollPosX = ImGui.GetScrollX();
Vector2 buttonSize = GetNormalizedIconTextButtonSize(icon, text, width, isInPopup);
var iconExtraSpacing = isInPopup ? padding.X * 2 : 0; var iconExtraSpacing = isInPopup ? padding.X * 2 : 0;
var iconXoffset = iconSize.X <= iconSize.Y ? (iconSize.Y - iconSize.X) / 2f : 0;
var iconScaling = iconSize.X > iconSize.Y ? 1 / (iconSize.X / iconSize.Y) : 1;
if (width == null || width <= 0)
{
var buttonSizeX = (iconScaling == 1 ? iconSize.Y : (iconSize.X * iconScaling))
+ textSize.X + padding.X * 2 + spacing.X + (iconXoffset * 2);
buttonSize = new Vector2(buttonSizeX + iconExtraSpacing, buttonSizeY);
}
else
{
buttonSize = new Vector2(width.Value, buttonSizeY);
}
using (ImRaii.PushColor(ImGuiCol.Button, ImGui.GetColorU32(ImGuiCol.PopupBg), isInPopup)) using (ImRaii.PushColor(ImGuiCol.Button, ImGui.GetColorU32(ImGuiCol.PopupBg), isInPopup))
{ {
if (ImGui.Button("###" + icon.ToIconString() + text, buttonSize)) if (ImGui.Button("###" + icon.ToIconString() + text, buttonSize))
@@ -394,89 +406,64 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
} }
} }
drawList.AddText(UiBuilder.IconFont, ImGui.GetFontSize() * iconScaling,
new(pos.X - scrollPosX + cursor.X + iconXoffset + padding.X,
pos.Y - scrollPosY + cursor.Y + (buttonSizeY - (iconSize.Y * iconScaling)) / 2f),
ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString());
drawList.AddText(UiBuilder.DefaultFont, ImGui.GetFontSize(), drawList.AddText(UiBuilder.DefaultFont, ImGui.GetFontSize(),
new(pos.X - scrollPosX + cursor.X + (padding.X) + spacing.X + (iconSize.X * iconScaling) + (iconXoffset * 2) + iconExtraSpacing, new(pos.X - scrollPosX + cursor.X + iconData.NormalizedIconScale.X + (padding.X * 2) + iconExtraSpacing,
pos.Y - scrollPosY + cursor.Y + ((buttonSizeY - textSize.Y) / 2f)), pos.Y - scrollPosY + cursor.Y + ((buttonSize.Y - textSize.Y) / 2f)),
ImGui.GetColorU32(ImGuiCol.Text), text); ImGui.GetColorU32(ImGuiCol.Text), text);
drawList.AddText(UiBuilder.IconFont, ImGui.GetFontSize() * iconData.IconScaling,
new(pos.X - scrollPosX + cursor.X + iconData.OffsetX + padding.X,
pos.Y - scrollPosY + cursor.Y + (buttonSize.Y - (iconData.IconSize.Y * iconData.IconScaling)) / 2f),
ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString());
return wasClicked; return wasClicked;
} }
public static Vector2 GetIconSize(FontAwesomeIcon icon)
{
if (_iconCacheDict.TryGetValue(ImGuiHelpers.GlobalScale, out var iconCache))
{
if (iconCache.TryGetValue(icon, out var size)) return size;
iconCache[icon] = CalcIconSize(icon);
return iconCache[icon];
}
_iconCacheDict.Add(ImGuiHelpers.GlobalScale, new());
return _iconCacheDict[ImGuiHelpers.GlobalScale][icon] = CalcIconSize(icon);
}
private static Vector2 CalcIconSize(FontAwesomeIcon icon)
{
using var font = ImRaii.PushFont(UiBuilder.IconFont);
var iconSize = ImGui.CalcTextSize(icon.ToIconString());
return iconSize;
}
public static (float xOffset, float scaling) GetIconScaling(FontAwesomeIcon icon)
{
var iconSize = GetIconSize(icon);
return (iconSize.X < iconSize.Y ? (iconSize.Y - iconSize.X) / 2f : 0f, iconSize.X > iconSize.Y ? 1f / (iconSize.X / iconSize.Y) : 1f);
}
private static Vector2 CalcIconScale(FontAwesomeIcon icon)
{
var iconSize = GetIconSize(icon);
var (iconXoffset, iconScaling) = GetIconScaling(icon);
return new((iconSize.X * iconScaling) + (iconXoffset * 2),
(iconSize.X * iconScaling) + (iconXoffset * 2));
}
public static Vector2 GetNormalizedIconSize(FontAwesomeIcon icon)
{
if (_normalizedIconScales.TryGetValue(ImGuiHelpers.GlobalScale, out var iconCache))
{
if (iconCache.TryGetValue(icon, out var size)) return size;
return iconCache[icon] = CalcIconScale(icon);
}
_normalizedIconScales.Add(ImGuiHelpers.GlobalScale, new());
return _normalizedIconScales[ImGuiHelpers.GlobalScale][icon] = CalcIconScale(icon);
}
public static void NormalizedIcon(FontAwesomeIcon icon, Vector4? color = null) public static void NormalizedIcon(FontAwesomeIcon icon, Vector4? color = null)
{ {
var cursorPos = ImGui.GetCursorPos(); var cursorPos = ImGui.GetCursorPos();
var iconSize = GetIconSize(icon); var iconData = GetIconData(icon);
var normalizedIconSize = GetNormalizedIconSize(icon);
var drawList = ImGui.GetWindowDrawList(); var drawList = ImGui.GetWindowDrawList();
var windowPos = ImGui.GetWindowPos(); var windowPos = ImGui.GetWindowPos();
var scrollPosX = ImGui.GetScrollX(); var scrollPosX = ImGui.GetScrollX();
var scrollPosY = ImGui.GetScrollY(); var scrollPosY = ImGui.GetScrollY();
var frameHeight = ImGui.GetFrameHeight(); var frameHeight = ImGui.GetFrameHeight();
var (iconXoffset, iconScaling) = GetIconScaling(icon); var frameOffsetY = ((frameHeight - iconData.IconSize.Y * iconData.IconScaling) / 2f);
var frameOffsetY = ((frameHeight - iconSize.Y * iconScaling) / 2f);
drawList.AddText(UiBuilder.IconFont, ImGui.GetFontSize() * iconScaling, drawList.AddText(UiBuilder.IconFont, ImGui.GetFontSize() * iconData.IconScaling,
new(windowPos.X - scrollPosX + cursorPos.X + iconXoffset, new(windowPos.X - scrollPosX + cursorPos.X + iconData.OffsetX,
windowPos.Y - scrollPosY + cursorPos.Y + frameOffsetY), windowPos.Y - scrollPosY + cursorPos.Y + frameOffsetY),
color != null ? ImGui.GetColorU32(color.Value) : ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString()); color != null ? ImGui.GetColorU32(color.Value) : ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString());
ImGui.Dummy(new(normalizedIconSize.X, ImGui.GetFrameHeight())); ImGui.Dummy(new(iconData.NormalizedIconScale.X, ImGui.GetFrameHeight()));
} }
private static Dictionary<float, Dictionary<FontAwesomeIcon, Vector2>> _normalizedIconScales = new(); private static IconScaleData CalcIconScaleData(FontAwesomeIcon icon)
private static Dictionary<float, Dictionary<FontAwesomeIcon, Vector2>> _iconCacheDict = new(); {
using var font = ImRaii.PushFont(UiBuilder.IconFont);
var iconSize = ImGui.CalcTextSize(icon.ToIconString());
var iconscaling = (iconSize.X < iconSize.Y ? (iconSize.Y - iconSize.X) / 2f : 0f, iconSize.X > iconSize.Y ? 1f / (iconSize.X / iconSize.Y) : 1f);
var normalized = iconscaling.Item2 == 1f ?
new Vector2(iconSize.Y, iconSize.Y)
: new((iconSize.X * iconscaling.Item2) + (iconscaling.Item1 * 2), (iconSize.X * iconscaling.Item2) + (iconscaling.Item1 * 2));
return new(iconSize, normalized, iconscaling.Item1, iconscaling.Item2);
}
public static IconScaleData GetIconData(FontAwesomeIcon icon)
{
if (_iconData.TryGetValue(ImGuiHelpers.GlobalScale, out var iconCache))
{
if (iconCache.TryGetValue(icon, out var iconData)) return iconData;
return iconCache[icon] = CalcIconScaleData(icon);
}
_iconData.Add(ImGuiHelpers.GlobalScale, new());
return _iconData[ImGuiHelpers.GlobalScale][icon] = CalcIconScaleData(icon);
}
public sealed record IconScaleData(Vector2 IconSize, Vector2 NormalizedIconScale, float OffsetX, float IconScaling);
private static Dictionary<float, Dictionary<FontAwesomeIcon, IconScaleData>> _iconData = new();
public static bool IsDirectoryWritable(string dirPath, bool throwIfFails = false) public static bool IsDirectoryWritable(string dirPath, bool throwIfFails = false)
{ {
@@ -831,7 +818,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.SameLine(); ImGui.SameLine();
var text = "Connect"; var text = "Connect";
if (_serverSelectionIndex == _serverConfigurationManager.CurrentServerIndex) text = "Reconnect"; if (_serverSelectionIndex == _serverConfigurationManager.CurrentServerIndex) text = "Reconnect";
if (IconTextButton(FontAwesomeIcon.Link, text)) if (NormalizedIconTextButton(FontAwesomeIcon.Link, text))
{ {
_serverConfigurationManager.SelectServer(_serverSelectionIndex); _serverConfigurationManager.SelectServer(_serverSelectionIndex);
_ = _apiController.CreateConnections(); _ = _apiController.CreateConnections();
@@ -844,7 +831,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.InputText("Custom Service URI", ref _customServerUri, 255); ImGui.InputText("Custom Service URI", ref _customServerUri, 255);
ImGui.SetNextItemWidth(250); ImGui.SetNextItemWidth(250);
ImGui.InputText("Custom Service Name", ref _customServerName, 255); ImGui.InputText("Custom Service Name", ref _customServerName, 255);
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Add Custom Service") if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Add Custom Service")
&& !string.IsNullOrEmpty(_customServerUri) && !string.IsNullOrEmpty(_customServerUri)
&& !string.IsNullOrEmpty(_customServerName)) && !string.IsNullOrEmpty(_customServerName))
{ {