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:");
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);
_lastAddedUser = null;
@@ -180,7 +180,7 @@ public class CompactUi : WindowMediatorSubscriberBase
if (keys.Any())
{
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()
{
@@ -220,7 +220,7 @@ public class CompactUi : WindowMediatorSubscriberBase
}
private void DrawServerStatus()
{
var buttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Link);
var buttonSize = UiSharedService.NormalizedIconButtonSize(FontAwesomeIcon.Link);
var userCount = _apiController.OnlineUsers.ToString(CultureInfo.InvariantCulture);
var userSize = ImGui.CalcTextSize(userCount);
var textSize = ImGui.CalcTextSize("Users Online");
@@ -272,7 +272,7 @@ public class CompactUi : WindowMediatorSubscriberBase
{
using (ImRaii.PushColor(ImGuiCol.Text, color))
{
if (ImGuiComponents.IconButton(connectedIcon))
if (UiSharedService.NormalizedIconButton(connectedIcon))
{
_serverManager.CurrentServer.FullPause = !_serverManager.CurrentServer.FullPause;
_serverManager.Save();
@@ -287,7 +287,7 @@ public class CompactUi : WindowMediatorSubscriberBase
private void DrawTransfers()
{
var currentUploads = _fileTransferManager.CurrentUploads.ToList();
UiSharedService.FontText(FontAwesomeIcon.Upload.ToIconString(), UiBuilder.IconFont);
UiSharedService.NormalizedIcon(FontAwesomeIcon.Upload);
ImGui.SameLine(35 * ImGuiHelpers.GlobalScale);
if (currentUploads.Any())
@@ -302,15 +302,17 @@ public class CompactUi : WindowMediatorSubscriberBase
var uploadText = $"({UiSharedService.ByteToString(totalUploaded)}/{UiSharedService.ByteToString(totalToUpload)})";
var textSize = ImGui.CalcTextSize(uploadText);
ImGui.SameLine(_windowContentWidth - textSize.X);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(uploadText);
}
else
{
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("No uploads in progress");
}
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);
if (currentDownloads.Any())
@@ -325,10 +327,12 @@ public class CompactUi : WindowMediatorSubscriberBase
$"({UiSharedService.ByteToString(totalDownloaded)}/{UiSharedService.ByteToString(totalToDownload)})";
var textSize = ImGui.CalcTextSize(downloadText);
ImGui.SameLine(_windowContentWidth - textSize.X);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(downloadText);
}
else
{
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("No downloads in progress");
}
}

View File

@@ -62,7 +62,7 @@ public abstract class DrawFolderBase : IDrawFolder
// if opened draw content
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())
{
foreach (var item in DrawPairs)
@@ -89,7 +89,7 @@ public abstract class DrawFolderBase : IDrawFolder
private float DrawRightSideInternal()
{
var barButtonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
var barButtonSize = UiSharedService.NormalizedIconButtonSize(FontAwesomeIcon.Bars);
var spacingX = ImGui.GetStyle().ItemSpacing.X;
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
@@ -99,7 +99,7 @@ public abstract class DrawFolderBase : IDrawFolder
if (RenderMenu)
{
ImGui.SameLine(windowEndX - barButtonSize.X);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars))
if (UiSharedService.NormalizedIconButton(FontAwesomeIcon.Bars))
{
ImGui.OpenPopup("User Flyout Menu");
}

View File

@@ -86,21 +86,21 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.Separator();
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.SetClipboardText(_groupFullInfoDto.GroupAliasOrGID);
}
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.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");
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);
ImGui.CloseCurrentPopup();
@@ -118,7 +118,7 @@ public class DrawFolderGroup : DrawFolderBase
if ((_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations() != disableAnims
|| _groupFullInfoDto.GroupPermissions.IsPreferDisableSounds() != disableSounds
|| _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.SetDisableSounds(_groupFullInfoDto.GroupPermissions.IsPreferDisableSounds());
@@ -127,7 +127,7 @@ public class DrawFolderGroup : DrawFolderBase
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))
{
perm.SetDisableSounds(!disableSounds);
@@ -135,7 +135,7 @@ public class DrawFolderGroup : DrawFolderBase
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))
{
perm.SetDisableAnimations(!disableAnims);
@@ -143,7 +143,7 @@ public class DrawFolderGroup : DrawFolderBase
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))
{
perm.SetDisableVFX(!disableVfx);
@@ -155,7 +155,7 @@ public class DrawFolderGroup : DrawFolderBase
{
ImGui.Separator();
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();
_mareMediator.Publish(new OpenSyncshellAdminPanel(_groupFullInfoDto));
@@ -173,9 +173,9 @@ public class DrawFolderGroup : DrawFolderBase
var spacingX = ImGui.GetStyle().ItemSpacing.X;
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 individualAnimDisabled = _groupFullInfoDto.GroupUserPermissions.IsDisableAnimations();
@@ -199,14 +199,17 @@ public class DrawFolderGroup : DrawFolderBase
UiSharedService.BooleanToColoredIcon(!individualSoundsDisabled, inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Sound Sync");
UiSharedService.BooleanToColoredIcon(!individualAnimDisabled, inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Animation Sync");
UiSharedService.BooleanToColoredIcon(!individualVFXDisabled, inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("VFX Sync");
ImGui.Separator();
@@ -217,21 +220,24 @@ public class DrawFolderGroup : DrawFolderBase
UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableSounds(), inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Sound Sync");
UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations(), inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Animation Sync");
UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableVFX(), inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("VFX Sync");
ImGui.EndTooltip();
}
ImGui.SameLine();
if (ImGuiComponents.IconButton(pauseIcon))
if (UiSharedService.NormalizedIconButton(pauseIcon))
{
var perm = _groupFullInfoDto.GroupUserPermissions;
perm.SetPaused(!perm.IsPaused());

View File

@@ -101,12 +101,12 @@ public class DrawFolderTag : DrawFolderBase
protected override void DrawMenu(float menuWidth)
{
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);
}
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);
}
@@ -138,11 +138,11 @@ public class DrawFolderTag : DrawFolderBase
var allArePaused = _allPairs.All(pair => pair.UserPair!.OwnPermissions.IsPaused());
var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseButtonX = UiSharedService.GetIconButtonSize(pauseButton).X;
var pauseButtonX = UiSharedService.NormalizedIconButtonSize(pauseButton).X;
var buttonPauseOffset = currentRightSideX - pauseButtonX;
ImGui.SameLine(buttonPauseOffset);
if (ImGuiComponents.IconButton(pauseButton))
if (UiSharedService.NormalizedIconButton(pauseButton))
{
if (allArePaused)
{

View File

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

View File

@@ -4,6 +4,7 @@ using Dalamud.Interface.Components;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.API.Dto.Group;
using MareSynchronos.API.Dto.User;
@@ -63,7 +64,7 @@ public class DrawUserPair
{
if (!_pair.IsPaused)
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.User, "Open Profile", _menuRenderWidth, true))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.User, "Open Profile", _menuRenderWidth, true))
{
_displayHandler.OpenProfile(_pair);
ImGui.CloseCurrentPopup();
@@ -72,7 +73,7 @@ public class DrawUserPair
}
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);
ImGui.CloseCurrentPopup();
@@ -80,7 +81,7 @@ public class DrawUserPair
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);
ImGui.CloseCurrentPopup();
@@ -91,7 +92,7 @@ public class DrawUserPair
var isSticky = _pair.UserPair!.OwnPermissions.IsSticky();
string stickyText = isSticky ? "Disable Preferred Permissions" : "Enable Preferred Permissions";
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;
permissions.SetSticky(!isSticky);
@@ -107,7 +108,7 @@ public class DrawUserPair
var isDisableSounds = _pair.UserPair!.OwnPermissions.IsDisableSounds();
string disableSoundsText = isDisableSounds ? "Enable sound sync" : "Disable sound sync";
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;
permissions.SetDisableSounds(!isDisableSounds);
@@ -118,7 +119,7 @@ public class DrawUserPair
var isDisableAnims = _pair.UserPair!.OwnPermissions.IsDisableAnimations();
string disableAnimsText = isDisableAnims ? "Enable animation sync" : "Disable animation sync";
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;
permissions.SetDisableAnimations(!isDisableAnims);
@@ -129,7 +130,7 @@ public class DrawUserPair
var isDisableVFX = _pair.UserPair!.OwnPermissions.IsDisableVFX();
string disableVFXText = isDisableVFX ? "Enable VFX sync" : "Disable VFX sync";
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;
permissions.SetDisableVFX(!isDisableVFX);
@@ -141,7 +142,7 @@ public class DrawUserPair
{
ImGui.Separator();
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();
_mediator.Publish(new OpenReportPopupMessage(_pair));
@@ -157,12 +158,12 @@ public class DrawUserPair
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);
}
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));
}
@@ -170,7 +171,7 @@ public class DrawUserPair
}
else
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Pair individually", _menuRenderWidth, true))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Pair individually", _menuRenderWidth, true))
{
_ = _apiController.UserAddPair(new(_pair.UserData));
}
@@ -186,34 +187,30 @@ public class DrawUserPair
if (_pair.IsPaused)
{
ImGui.AlignTextToFramePadding();
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
//using var font = ImRaii.PushFont(UiBuilder.IconFont);
UiSharedService.NormalizedIcon(FontAwesomeIcon.PauseCircle);
userPairText = _pair.UserData.AliasOrUID + " is paused";
ImGui.SameLine();
}
else if (!_pair.IsOnline)
{
ImGui.AlignTextToFramePadding();
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
UiSharedService.NormalizedIcon(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.OneSided
? FontAwesomeIcon.ArrowsLeftRight
: (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional
? FontAwesomeIcon.User : FontAwesomeIcon.Users));
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
{
ImGui.AlignTextToFramePadding();
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen);
UiSharedService.NormalizedIcon(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional
? FontAwesomeIcon.User : FontAwesomeIcon.Users);
userPairText = _pair.UserData.AliasOrUID + " is online";
ImGui.SameLine();
}
if (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.OneSided)
@@ -237,53 +234,6 @@ public class DrawUserPair
}
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();
}
@@ -320,32 +270,46 @@ public class DrawUserPair
private float DrawRightSide()
{
var pauseIcon = _pair.UserPair!.OwnPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseIconSize = UiSharedService.GetIconButtonSize(pauseIcon);
var barButtonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
var entryUID = _pair.UserData.AliasOrUID;
var pauseIconSize = UiSharedService.NormalizedIconButtonSize(pauseIcon);
var barButtonSize = UiSharedService.NormalizedIconButtonSize(FontAwesomeIcon.Bars);
var spacingX = ImGui.GetStyle().ItemSpacing.X;
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
var rightSideStart = 0f;
float infoIconDist = 0f;
float currentRightSide = windowEndX - barButtonSize.X;
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)
{
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 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;
var icon = FontAwesomeIcon.InfoCircle;
var iconwidth = UiSharedService.GetNormalizedIconSize(icon);
currentRightSide -= (UiSharedService.GetIconData(individualIcon).NormalizedIconScale.X + spacingX);
infoIconDist = iconwidth.X;
ImGui.SameLine(infoIconPosDist - iconwidth.X);
ImGui.AlignTextToFramePadding();
UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont);
ImGui.SameLine(currentRightSide);
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen, individualIsSticky))
UiSharedService.NormalizedIcon(individualIcon);
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
@@ -353,17 +317,30 @@ public class DrawUserPair
ImGui.TextUnformatted("Individual User permissions");
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)
{
var userSoundsText = "Sound sync";
UiSharedService.FontText(FontAwesomeIcon.VolumeOff.ToIconString(), UiBuilder.IconFont);
UiSharedService.NormalizedIcon(FontAwesomeIcon.VolumeOff);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(userSoundsText);
ImGui.NewLine();
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("You");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableSounds());
ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("They");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableSounds());
}
@@ -371,14 +348,17 @@ public class DrawUserPair
if (individualAnimDisabled)
{
var userAnimText = "Animation sync";
UiSharedService.FontText(FontAwesomeIcon.Stop.ToIconString(), UiBuilder.IconFont);
UiSharedService.NormalizedIcon(FontAwesomeIcon.Stop);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(userAnimText);
ImGui.NewLine();
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("You");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableAnimations());
ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("They");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableAnimations());
}
@@ -386,14 +366,17 @@ public class DrawUserPair
if (individualVFXDisabled)
{
var userVFXText = "VFX sync";
UiSharedService.FontText(FontAwesomeIcon.Circle.ToIconString(), UiBuilder.IconFont);
UiSharedService.NormalizedIcon(FontAwesomeIcon.Circle);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(userVFXText);
ImGui.NewLine();
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("You");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableVFX());
ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("They");
UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableVFX());
}
@@ -403,29 +386,38 @@ public class DrawUserPair
}
}
rightSideStart = windowEndX - barButtonSize.X - spacingX * 3 - pauseIconSize.X - infoIconDist;
ImGui.SameLine(windowEndX - barButtonSize.X - spacingX - pauseIconSize.X);
if (ImGuiComponents.IconButton(pauseIcon))
if (_currentGroup != null)
{
var perm = _pair.UserPair!.OwnPermissions;
perm.SetPaused(!perm.IsPaused());
_ = _apiController.UserSetPairPermissions(new(_pair.UserData, perm));
var icon = FontAwesomeIcon.None;
var text = string.Empty;
if (string.Equals(_currentGroup.OwnerUID, _pair.UserData.UID, StringComparison.Ordinal))
{
icon = FontAwesomeIcon.Crown;
text = "User is owner of this syncshell";
}
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";
}
}
UiSharedService.AttachToolTip(!_pair.UserPair!.OwnPermissions.IsPaused()
? "Pause pairing with " + entryUID
: "Resume pairing with " + entryUID);
// Flyout Menu
if (rightSideStart == 0f)
if (!string.IsNullOrEmpty(text))
{
rightSideStart = windowEndX - barButtonSize.X;
currentRightSide -= (UiSharedService.GetIconData(icon).NormalizedIconScale.X + spacingX);
ImGui.SameLine(currentRightSide);
UiSharedService.NormalizedIcon(icon);
UiSharedService.AttachToolTip(text);
}
ImGui.SameLine(windowEndX - barButtonSize.X);
ImGui.AlignTextToFramePadding();
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars))
{
ImGui.OpenPopup("User Flyout Menu");
}
if (ImGui.BeginPopup("User Flyout Menu"))
{
using (ImRaii.PushId($"buttons-{_pair.UserData.UID}"))
@@ -443,7 +435,7 @@ public class DrawUserPair
ImGui.EndPopup();
}
return rightSideStart;
return currentRightSide - spacingX;
}
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");
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();
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");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Remove user", _menuRenderWidth, true) && UiSharedService.CtrlPressed())
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Remove user", _menuRenderWidth, true) && UiSharedService.CtrlPressed())
{
ImGui.CloseCurrentPopup();
_ = _apiController.GroupRemoveUser(new(group.Group, _pair.UserData));
}
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));
ImGui.CloseCurrentPopup();
@@ -488,7 +480,7 @@ public class DrawUserPair
{
ImGui.TextUnformatted("Syncshell Owner Functions");
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();
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 +
"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();
_ = _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.");
ImGui.InputTextWithHint("##banreason", "Ban Reason", ref _banReason, 255);
if (UiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
{
ImGui.CloseCurrentPopup();
var reason = _banReason;

View File

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

View File

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

View File

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

View File

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

View File

@@ -65,7 +65,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
{
ImGui.TextUnformatted("BC7 Conversion in progress: " + _conversionCurrentFileProgress + "/" + _texturesToConvert.Count);
UiSharedService.TextWrapped("Current file: " + _conversionCurrentFileName);
if (UiSharedService.IconTextButton(FontAwesomeIcon.StopCircle, "Cancel conversion"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StopCircle, "Cancel conversion"))
{
_conversionCancellationTokenSource.Cancel();
}
@@ -107,7 +107,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
{
UiSharedService.ColorTextWrapped($"Analyzing {_characterAnalyzer.CurrentFile}/{_characterAnalyzer.TotalFiles}",
ImGuiColors.DalamudYellow);
if (UiSharedService.IconTextButton(FontAwesomeIcon.StopCircle, "Cancel analysis"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StopCircle, "Cancel analysis"))
{
_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",
ImGuiColors.DalamudYellow);
if (UiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (missing entries)"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (missing entries)"))
{
_ = _characterAnalyzer.ComputeAnalysis(print: false);
}
}
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);
}
@@ -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 + "- 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);
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();
_conversionTask = _ipcManager.PenumbraConvertTextureFiles(_logger, _texturesToConvert, _conversionProgress, _conversionCancellationTokenSource.Token);

View File

@@ -131,7 +131,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
ImGui.Separator();
_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) =>
{
@@ -162,7 +162,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
}
UiSharedService.AttachToolTip("Select and upload a new profile picture");
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));
}
@@ -211,13 +211,13 @@ public class EditProfileUi : WindowMediatorSubscriberBase
ImGui.EndChildFrame();
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));
}
UiSharedService.AttachToolTip("Sets your profile description text");
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, ""));
}

View File

@@ -41,7 +41,7 @@ public class GposeUi : WindowMediatorSubscriberBase
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) =>
{
@@ -59,7 +59,7 @@ public class GposeUi : WindowMediatorSubscriberBase
{
UiSharedService.TextWrapped("Loaded file: " + _mareCharaFileManager.LoadedCharaFile.FilePath);
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));
}

View File

@@ -74,7 +74,7 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
ImGui.InputTextWithHint("##syncshellpw", "Password", ref _syncshellPassword, 50, ImGuiInputTextFlags.Password);
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;
_previousPassword = _syncshellPassword;
@@ -94,10 +94,13 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
ImGui.TextUnformatted("You are about to join the Syncshell " + _groupJoinInfo.GroupAliasOrGID + " by " + _groupJoinInfo.OwnerAliasOrUID);
ImGuiHelpers.ScaledDummy(2f);
ImGui.TextUnformatted("This Syncshell staff has set the following suggested Syncshell permissions:");
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("- Sounds ");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableSounds());
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("- Animations");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableAnimations());
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("- VFX");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableVFX());
@@ -113,11 +116,12 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
ImGui.TextUnformatted("- Sounds");
UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupSounds);
ImGui.SameLine(200);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Suggested");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableSounds());
ImGui.SameLine();
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();
}
@@ -128,11 +132,12 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
ImGui.TextUnformatted("- Animations");
UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupAnimations);
ImGui.SameLine(200);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Suggested");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableAnimations());
ImGui.SameLine();
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();
}
@@ -143,11 +148,12 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
ImGui.TextUnformatted("- VFX");
UiSharedService.BooleanToColoredIcon(!_ownPermissions.DisableGroupVFX);
ImGui.SameLine(200);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Suggested");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableVFX());
ImGui.SameLine();
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();
}
@@ -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.");
}
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;
joinPermissions.SetDisableSounds(_ownPermissions.DisableGroupSounds);

View File

@@ -327,7 +327,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.TreePop();
}
#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)
{
@@ -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.");
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();
}
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);
}
@@ -386,7 +386,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (!_mareCharaFileManager.CurrentlyWorking)
{
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)
? "export.mcdf"
@@ -454,14 +454,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.SameLine();
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));
}
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.");
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));
}
@@ -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.");
if (!_readClearCache)
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(() =>
{
@@ -529,11 +529,11 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Separator();
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()));
}
if (UiSharedService.IconTextButton(FontAwesomeIcon.FileImport, "Import notes from clipboard"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FileImport, "Import notes from clipboard"))
{
_notesSuccessfullyApplied = null;
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));
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Character") && UiSharedService.CtrlPressed())
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete Character") && UiSharedService.CtrlPressed())
_serverConfigurationManager.RemoveCharacterFromServer(idx, item);
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)
&& c.WorldId == _uiShared.WorldId))
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.User, "Add current character"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.User, "Add current character"))
{
_serverConfigurationManager.AddCurrentCharacterToServer(idx);
}
ImGui.SameLine();
}
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Add new character"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Add new character"))
{
_serverConfigurationManager.AddEmptyCharacterToServer(idx);
}
@@ -984,7 +984,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
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);
_serverConfigurationManager.Save();
@@ -1001,7 +1001,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
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()
{
@@ -1041,7 +1041,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
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);
}

View File

@@ -71,7 +71,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
{
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"))
{
perm.SetDisableInvites(!isInvitesDisabled);
@@ -81,7 +81,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
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.");
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);
}
@@ -90,7 +90,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.SameLine();
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);
}
@@ -100,7 +100,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
{
var invites = string.Join(Environment.NewLine, _oneTimeInvites);
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);
}
@@ -111,7 +111,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
var mgmtTab = ImRaii.TabItem("User Management");
if (mgmtTab)
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.Broom, "Clear Syncshell"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Broom, "Clear Syncshell"))
{
_ = _apiController.GroupClear(new(GroupFullInfo.Group));
}
@@ -119,7 +119,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
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;
}
@@ -148,7 +148,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.TableNextColumn();
UiSharedService.TextWrapped(bannedUser.Reason);
ImGui.TableNextColumn();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Check, "Unban#" + bannedUser.UID))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Check, "Unban#" + bannedUser.UID))
{
_ = _apiController.GroupUnbanUser(bannedUser);
_bannedUsers.RemoveAll(b => string.Equals(b.UID, bannedUser.UID, StringComparison.Ordinal));
@@ -171,7 +171,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.Text("Suggest Sound Sync");
UiSharedService.BooleanToColoredIcon(!isDisableSounds);
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"))
{
perm.SetPreferDisableSounds(!perm.IsPreferDisableSounds());
@@ -182,7 +182,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.Text("Suggest Animation Sync");
UiSharedService.BooleanToColoredIcon(!isDisableAnimations);
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"))
{
perm.SetPreferDisableAnimations(!perm.IsPreferDisableAnimations());
@@ -193,7 +193,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.Text("Suggest VFX Sync");
UiSharedService.BooleanToColoredIcon(!isDisableVfx);
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"))
{
perm.SetPreferDisableVFX(!perm.IsPreferDisableVFX());
@@ -212,7 +212,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("New Password");
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 spacing = ImGui.GetStyle().ItemSpacing.X;
@@ -222,7 +222,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.SameLine();
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;
_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);
}
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
{
IsOpen = false;
_ = _apiController.GroupDelete(new(GroupFullInfo.Group));

View File

@@ -178,14 +178,14 @@ public class TopTabMenu
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.InputTextWithHint("##otheruid", "Other players UID/Alias", ref _pairToAdd, 20);
ImGui.SameLine();
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)))
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.UserPlus, "Add"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserPlus, "Add"))
{
_ = _apiController.UserAddPair(new(new(_pairToAdd)));
_pairToAdd = string.Empty;
@@ -196,7 +196,7 @@ public class TopTabMenu
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);
string filter = Filter;
if (ImGui.InputTextWithHint("##filter", "Filter for UID/notes", ref filter, 255))
@@ -205,7 +205,7 @@ public class TopTabMenu
}
ImGui.SameLine();
using var disabled = ImRaii.Disabled(string.IsNullOrEmpty(Filter));
if (UiSharedService.IconTextButton(FontAwesomeIcon.Ban, "Clear"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Ban, "Clear"))
{
Filter = string.Empty;
}
@@ -466,7 +466,7 @@ public class TopTabMenu
using (ImRaii.Disabled(_pairManager.GroupPairs.Select(k => k.Key).Distinct()
.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)));
}
@@ -475,7 +475,7 @@ public class TopTabMenu
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)));
}
@@ -485,13 +485,13 @@ public class TopTabMenu
private void DrawUserConfig(float availableWidth, float spacingX)
{
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)));
}
UiSharedService.AttachToolTip("Edit your Mare Profile");
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)));
}
@@ -518,7 +518,7 @@ public class TopTabMenu
{
if (ImGui.BeginPopup(popupTitle))
{
if (UiSharedService.IconTextButton(enableIcon, enableText, 0, true))
if (UiSharedService.NormalizedIconTextButton(enableIcon, enableText, 0, true))
{
_ = GlobalControlCountdown(10);
var bulkIndividualPairs = _pairManager.PairsWithGroups.Keys
@@ -532,7 +532,7 @@ public class TopTabMenu
ImGui.CloseCurrentPopup();
}
if (UiSharedService.IconTextButton(disableIcon, disableText, 0, true))
if (UiSharedService.NormalizedIconTextButton(disableIcon, disableText, 0, true))
{
_ = GlobalControlCountdown(10);
var bulkIndividualPairs = _pairManager.PairsWithGroups.Keys
@@ -556,7 +556,7 @@ public class TopTabMenu
if (ImGui.BeginPopup(popupTitle))
{
if (UiSharedService.IconTextButton(enableIcon, enableText, 0, true))
if (UiSharedService.NormalizedIconTextButton(enableIcon, enableText, 0, true))
{
_ = GlobalControlCountdown(10);
var bulkSyncshells = _pairManager.GroupPairs.Keys
@@ -570,7 +570,7 @@ public class TopTabMenu
ImGui.CloseCurrentPopup();
}
if (UiSharedService.IconTextButton(disableIcon, disableText, 0, true))
if (UiSharedService.NormalizedIconTextButton(disableIcon, disableText, 0, true))
{
_ = GlobalControlCountdown(10);
var bulkSyncshells = _pairManager.GroupPairs.Keys

View File

@@ -23,6 +23,7 @@ using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Net.Mime.MediaTypeNames;
namespace MareSynchronos.UI;
@@ -153,7 +154,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
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 colorred = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed, !value);
@@ -161,11 +161,11 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
if (value)
{
ImGui.TextUnformatted(FontAwesomeIcon.Check.ToIconString());
NormalizedIcon(FontAwesomeIcon.Check);
}
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;
}
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 padding = ImGui.GetStyle().FramePadding;
var spacing = ImGui.GetStyle().ItemSpacing;
var buttonSizeY = textSize.Y + padding.Y * 2;
var buttonSizeY = ImGui.GetFrameHeight();
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);
return new Vector2(buttonSizeX + iconExtraSpacing, buttonSizeY);
var buttonSizeX = iconData.NormalizedIconScale.X + (padding.X * 4) + iconExtraSpacing + textSize.X;
return new Vector2(buttonSizeX, buttonSizeY);
}
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 iconSize = GetIconSize(icon);
var textSize = ImGui.CalcTextSize(text);
var iconData = GetIconData(icon);
var padding = ImGui.GetStyle().FramePadding;
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 spacing = ImGui.GetStyle().ItemSpacing;
var cursor = ImGui.GetCursorPos();
var drawList = ImGui.GetWindowDrawList();
var pos = ImGui.GetWindowPos();
var scrollPosY = ImGui.GetScrollY();
var scrollPosX = ImGui.GetScrollX();
Vector2 buttonSize;
var buttonSizeY = textSize.Y + padding.Y * 2;
var buttonSize = NormalizedIconButtonSize(icon);
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 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))
{
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(),
new(pos.X - scrollPosX + cursor.X + (padding.X) + spacing.X + (iconSize.X * iconScaling) + (iconXoffset * 2) + iconExtraSpacing,
pos.Y - scrollPosY + cursor.Y + ((buttonSizeY - textSize.Y) / 2f)),
new(pos.X - scrollPosX + cursor.X + iconData.NormalizedIconScale.X + (padding.X * 2) + iconExtraSpacing,
pos.Y - scrollPosY + cursor.Y + ((buttonSize.Y - textSize.Y) / 2f)),
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;
}
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)
{
var cursorPos = ImGui.GetCursorPos();
var iconSize = GetIconSize(icon);
var normalizedIconSize = GetNormalizedIconSize(icon);
var iconData = GetIconData(icon);
var drawList = ImGui.GetWindowDrawList();
var windowPos = ImGui.GetWindowPos();
var scrollPosX = ImGui.GetScrollX();
var scrollPosY = ImGui.GetScrollY();
var frameHeight = ImGui.GetFrameHeight();
var (iconXoffset, iconScaling) = GetIconScaling(icon);
var frameOffsetY = ((frameHeight - iconSize.Y * iconScaling) / 2f);
var frameOffsetY = ((frameHeight - iconData.IconSize.Y * iconData.IconScaling) / 2f);
drawList.AddText(UiBuilder.IconFont, ImGui.GetFontSize() * iconScaling,
new(windowPos.X - scrollPosX + cursorPos.X + iconXoffset,
drawList.AddText(UiBuilder.IconFont, ImGui.GetFontSize() * iconData.IconScaling,
new(windowPos.X - scrollPosX + cursorPos.X + iconData.OffsetX,
windowPos.Y - scrollPosY + cursorPos.Y + frameOffsetY),
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 Dictionary<float, Dictionary<FontAwesomeIcon, Vector2>> _iconCacheDict = new();
private static IconScaleData CalcIconScaleData(FontAwesomeIcon icon)
{
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)
{
@@ -831,7 +818,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.SameLine();
var text = "Connect";
if (_serverSelectionIndex == _serverConfigurationManager.CurrentServerIndex) text = "Reconnect";
if (IconTextButton(FontAwesomeIcon.Link, text))
if (NormalizedIconTextButton(FontAwesomeIcon.Link, text))
{
_serverConfigurationManager.SelectServer(_serverSelectionIndex);
_ = _apiController.CreateConnections();
@@ -844,7 +831,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.InputText("Custom Service URI", ref _customServerUri, 255);
ImGui.SetNextItemWidth(250);
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(_customServerName))
{