fix icon font issues

This commit is contained in:
rootdarkarchon
2024-03-21 12:14:53 +01:00
parent 9898bbcca2
commit ee589f78c0
20 changed files with 190 additions and 142 deletions

View File

@@ -188,7 +188,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.IconTextButton(FontAwesomeIcon.Save, "Save Note"))
{ {
_serverManager.SetNoteForUid(_lastAddedUser.UserData.UID, _lastAddedUserComment); _serverManager.SetNoteForUid(_lastAddedUser.UserData.UID, _lastAddedUserComment);
_lastAddedUser = null; _lastAddedUser = null;
@@ -217,7 +217,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.IconTextButton(FontAwesomeIcon.Plus, "Add current character with secret key"))
{ {
_serverManager.CurrentServer!.Authentications.Add(new MareConfiguration.Models.Authentication() _serverManager.CurrentServer!.Authentications.Add(new MareConfiguration.Models.Authentication()
{ {
@@ -309,7 +309,7 @@ public class CompactUi : WindowMediatorSubscriberBase
{ {
using (ImRaii.PushColor(ImGuiCol.Text, color)) using (ImRaii.PushColor(ImGuiCol.Text, color))
{ {
if (UiSharedService.IconButton(connectedIcon)) if (_uiSharedService.IconButton(connectedIcon))
{ {
_serverManager.CurrentServer.FullPause = !_serverManager.CurrentServer.FullPause; _serverManager.CurrentServer.FullPause = !_serverManager.CurrentServer.FullPause;
_serverManager.Save(); _serverManager.Save();

View File

@@ -108,7 +108,7 @@ public abstract class DrawFolderBase : IDrawFolder
if (RenderMenu) if (RenderMenu)
{ {
ImGui.SameLine(windowEndX - barButtonSize.X); ImGui.SameLine(windowEndX - barButtonSize.X);
if (UiSharedService.IconButton(FontAwesomeIcon.EllipsisV)) if (_uiSharedService.IconButton(FontAwesomeIcon.EllipsisV))
{ {
ImGui.OpenPopup("User Flyout Menu"); ImGui.OpenPopup("User Flyout Menu");
} }

View File

@@ -85,21 +85,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.IconTextButton(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.IconTextButton(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.IconTextButton(FontAwesomeIcon.ArrowCircleLeft, "Leave Syncshell", menuWidth, true) && UiSharedService.CtrlPressed())
{ {
_ = _apiController.GroupLeave(_groupFullInfoDto); _ = _apiController.GroupLeave(_groupFullInfoDto);
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
@@ -117,7 +117,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.IconTextButton(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());
@@ -126,21 +126,21 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
if (UiSharedService.IconTextButton(disableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeOff, disableSounds ? "Enable Sound Sync" : "Disable Sound Sync", menuWidth, true)) if (_uiSharedService.IconTextButton(disableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeOff, disableSounds ? "Enable Sound Sync" : "Disable Sound Sync", menuWidth, true))
{ {
perm.SetDisableSounds(!disableSounds); perm.SetDisableSounds(!disableSounds);
_ = _apiController.GroupChangeIndividualPermissionState(new(_groupFullInfoDto.Group, new(_apiController.UID), perm)); _ = _apiController.GroupChangeIndividualPermissionState(new(_groupFullInfoDto.Group, new(_apiController.UID), perm));
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
if (UiSharedService.IconTextButton(disableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop, disableAnims ? "Enable Animation Sync" : "Disable Animation Sync", menuWidth, true)) if (_uiSharedService.IconTextButton(disableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop, disableAnims ? "Enable Animation Sync" : "Disable Animation Sync", menuWidth, true))
{ {
perm.SetDisableAnimations(!disableAnims); perm.SetDisableAnimations(!disableAnims);
_ = _apiController.GroupChangeIndividualPermissionState(new(_groupFullInfoDto.Group, new(_apiController.UID), perm)); _ = _apiController.GroupChangeIndividualPermissionState(new(_groupFullInfoDto.Group, new(_apiController.UID), perm));
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
if (UiSharedService.IconTextButton(disableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle, disableVfx ? "Enable VFX Sync" : "Disable VFX Sync", menuWidth, true)) if (_uiSharedService.IconTextButton(disableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle, disableVfx ? "Enable VFX Sync" : "Disable VFX Sync", menuWidth, true))
{ {
perm.SetDisableVFX(!disableVfx); perm.SetDisableVFX(!disableVfx);
_ = _apiController.GroupChangeIndividualPermissionState(new(_groupFullInfoDto.Group, new(_apiController.UID), perm)); _ = _apiController.GroupChangeIndividualPermissionState(new(_groupFullInfoDto.Group, new(_apiController.UID), perm));
@@ -151,7 +151,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.IconTextButton(FontAwesomeIcon.Cog, "Open Admin Panel", menuWidth, true))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
_mareMediator.Publish(new OpenSyncshellAdminPanel(_groupFullInfoDto)); _mareMediator.Publish(new OpenSyncshellAdminPanel(_groupFullInfoDto));
@@ -233,7 +233,7 @@ public class DrawFolderGroup : DrawFolderBase
} }
ImGui.SameLine(); ImGui.SameLine();
if (UiSharedService.IconButton(pauseIcon)) if (_uiSharedService.IconButton(pauseIcon))
{ {
var perm = _groupFullInfoDto.GroupUserPermissions; var perm = _groupFullInfoDto.GroupUserPermissions;
perm.SetPaused(!perm.IsPaused()); perm.SetPaused(!perm.IsPaused());

View File

@@ -100,12 +100,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.IconTextButton(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.IconTextButton(FontAwesomeIcon.Trash, "Delete Pair Group", menuWidth, true) && UiSharedService.CtrlPressed())
{ {
_tagHandler.RemoveTag(_id); _tagHandler.RemoveTag(_id);
} }
@@ -141,7 +141,7 @@ public class DrawFolderTag : DrawFolderBase
var buttonPauseOffset = currentRightSideX - pauseButtonX; var buttonPauseOffset = currentRightSideX - pauseButtonX;
ImGui.SameLine(buttonPauseOffset); ImGui.SameLine(buttonPauseOffset);
if (UiSharedService.IconButton(pauseButton)) if (_uiSharedService.IconButton(pauseButton))
{ {
if (allArePaused) if (allArePaused)
{ {

View File

@@ -71,7 +71,7 @@ public class DrawUserPair
{ {
if (!_pair.IsPaused) if (!_pair.IsPaused)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.User, "Open Profile", _menuWidth, true)) if (_uiSharedService.IconTextButton(FontAwesomeIcon.User, "Open Profile", _menuWidth, true))
{ {
_displayHandler.OpenProfile(_pair); _displayHandler.OpenProfile(_pair);
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
@@ -80,7 +80,7 @@ public class DrawUserPair
} }
if (_pair.IsVisible) if (_pair.IsVisible)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Sync, "Reload last data", _menuWidth, true)) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Sync, "Reload last data", _menuWidth, true))
{ {
_pair.ApplyLastReceivedData(forced: true); _pair.ApplyLastReceivedData(forced: true);
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
@@ -88,7 +88,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", _menuWidth, true)) if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Cycle pause state", _menuWidth, true))
{ {
_ = _apiController.CyclePause(_pair.UserData); _ = _apiController.CyclePause(_pair.UserData);
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
@@ -96,7 +96,7 @@ public class DrawUserPair
ImGui.Separator(); ImGui.Separator();
ImGui.TextUnformatted("Pair Permission Functions"); ImGui.TextUnformatted("Pair Permission Functions");
if (UiSharedService.IconTextButton(FontAwesomeIcon.WindowMaximize, "Open Permissions Window", _menuWidth, true)) if (_uiSharedService.IconTextButton(FontAwesomeIcon.WindowMaximize, "Open Permissions Window", _menuWidth, true))
{ {
_mediator.Publish(new OpenPermissionWindow(_pair)); _mediator.Publish(new OpenPermissionWindow(_pair));
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
@@ -106,7 +106,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, _menuWidth, true)) if (_uiSharedService.IconTextButton(stickyIcon, stickyText, _menuWidth, true))
{ {
var permissions = _pair.UserPair.OwnPermissions; var permissions = _pair.UserPair.OwnPermissions;
permissions.SetSticky(!isSticky); permissions.SetSticky(!isSticky);
@@ -122,7 +122,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, _menuWidth, true)) if (_uiSharedService.IconTextButton(disableSoundsIcon, disableSoundsText, _menuWidth, true))
{ {
var permissions = _pair.UserPair.OwnPermissions; var permissions = _pair.UserPair.OwnPermissions;
permissions.SetDisableSounds(!isDisableSounds); permissions.SetDisableSounds(!isDisableSounds);
@@ -133,7 +133,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, _menuWidth, true)) if (_uiSharedService.IconTextButton(disableAnimsIcon, disableAnimsText, _menuWidth, true))
{ {
var permissions = _pair.UserPair.OwnPermissions; var permissions = _pair.UserPair.OwnPermissions;
permissions.SetDisableAnimations(!isDisableAnims); permissions.SetDisableAnimations(!isDisableAnims);
@@ -144,7 +144,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, _menuWidth, true)) if (_uiSharedService.IconTextButton(disableVFXIcon, disableVFXText, _menuWidth, true))
{ {
var permissions = _pair.UserPair.OwnPermissions; var permissions = _pair.UserPair.OwnPermissions;
permissions.SetDisableVFX(!isDisableVFX); permissions.SetDisableVFX(!isDisableVFX);
@@ -156,7 +156,7 @@ public class DrawUserPair
{ {
ImGui.Separator(); ImGui.Separator();
ImGui.TextUnformatted("Pair reporting"); ImGui.TextUnformatted("Pair reporting");
if (UiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Report Mare Profile", _menuWidth, true)) if (_uiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Report Mare Profile", _menuWidth, true))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
_mediator.Publish(new OpenReportPopupMessage(_pair)); _mediator.Publish(new OpenReportPopupMessage(_pair));
@@ -172,12 +172,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", _menuWidth, true)) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Folder, "Pair Groups", _menuWidth, 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", _menuWidth, true) && UiSharedService.CtrlPressed()) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently", _menuWidth, true) && UiSharedService.CtrlPressed())
{ {
_ = _apiController.UserRemovePair(new(_pair.UserData)); _ = _apiController.UserRemovePair(new(_pair.UserData));
} }
@@ -185,7 +185,7 @@ public class DrawUserPair
} }
else else
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Pair individually", _menuWidth, true)) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Pair individually", _menuWidth, true))
{ {
_ = _apiController.UserAddPair(new(_pair.UserData)); _ = _apiController.UserAddPair(new(_pair.UserData));
} }
@@ -309,14 +309,14 @@ public class DrawUserPair
ImGui.SameLine(currentRightSide); ImGui.SameLine(currentRightSide);
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
if (UiSharedService.IconButton(FontAwesomeIcon.EllipsisV)) if (_uiSharedService.IconButton(FontAwesomeIcon.EllipsisV))
{ {
ImGui.OpenPopup("User Flyout Menu"); ImGui.OpenPopup("User Flyout Menu");
} }
currentRightSide -= (pauseIconSize.X + spacingX); currentRightSide -= (pauseIconSize.X + spacingX);
ImGui.SameLine(currentRightSide); ImGui.SameLine(currentRightSide);
if (UiSharedService.IconButton(pauseIcon)) if (_uiSharedService.IconButton(pauseIcon))
{ {
var perm = _pair.UserPair!.OwnPermissions; var perm = _pair.UserPair!.OwnPermissions;
perm.SetPaused(!perm.IsPaused()); perm.SetPaused(!perm.IsPaused());
@@ -475,7 +475,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, _menuWidth, true)) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Thumbtack, pinText, _menuWidth, 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))
@@ -490,14 +490,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", _menuWidth, true) && UiSharedService.CtrlPressed()) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Remove user", _menuWidth, 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", _menuWidth, true)) if (_uiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User", _menuWidth, true))
{ {
_mediator.Publish(new OpenBanUserPopupMessage(_pair, group)); _mediator.Publish(new OpenBanUserPopupMessage(_pair, group));
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
@@ -511,7 +511,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, _menuWidth, true) && UiSharedService.CtrlPressed()) if (_uiSharedService.IconTextButton(FontAwesomeIcon.UserShield, modText, _menuWidth, 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))
@@ -528,7 +528,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", _menuWidth, true) && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed()) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Crown, "Transfer Ownership", _menuWidth, 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

@@ -11,13 +11,15 @@ namespace MareSynchronos.UI.Components.Popup;
public class BanUserPopupHandler : IPopupHandler public class BanUserPopupHandler : IPopupHandler
{ {
private readonly ApiController _apiController; private readonly ApiController _apiController;
private readonly UiSharedService _uiSharedService;
private string _banReason = string.Empty; private string _banReason = string.Empty;
private GroupFullInfoDto _group = null!; private GroupFullInfoDto _group = null!;
private Pair _reportedPair = null!; private Pair _reportedPair = null!;
public BanUserPopupHandler(ApiController apiController) public BanUserPopupHandler(ApiController apiController, UiSharedService uiSharedService)
{ {
_apiController = apiController; _apiController = apiController;
_uiSharedService = uiSharedService;
} }
public Vector2 PopupSize => new(500, 250); public Vector2 PopupSize => new(500, 250);
@@ -29,7 +31,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.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
var reason = _banReason; var reason = _banReason;

View File

@@ -13,10 +13,11 @@ public class PopupHandler : WindowMediatorSubscriberBase
{ {
protected bool _openPopup = false; protected bool _openPopup = false;
private readonly HashSet<IPopupHandler> _handlers; private readonly HashSet<IPopupHandler> _handlers;
private readonly UiSharedService _uiSharedService;
private IPopupHandler? _currentHandler = null; private IPopupHandler? _currentHandler = null;
public PopupHandler(ILogger<PopupHandler> logger, MareMediator mediator, IEnumerable<IPopupHandler> popupHandlers, public PopupHandler(ILogger<PopupHandler> logger, MareMediator mediator, IEnumerable<IPopupHandler> popupHandlers,
PerformanceCollectorService performanceCollectorService) PerformanceCollectorService performanceCollectorService, UiSharedService uiSharedService)
: base(logger, mediator, "MarePopupHandler", performanceCollectorService) : base(logger, mediator, "MarePopupHandler", performanceCollectorService)
{ {
Flags = ImGuiWindowFlags.NoBringToFrontOnFocus Flags = ImGuiWindowFlags.NoBringToFrontOnFocus
@@ -53,6 +54,7 @@ public class PopupHandler : WindowMediatorSubscriberBase
_currentHandler = _handlers.OfType<CensusPopupHandler>().Single(); _currentHandler = _handlers.OfType<CensusPopupHandler>().Single();
IsOpen = true; IsOpen = true;
}); });
_uiSharedService = uiSharedService;
} }
protected override void DrawInternal() protected override void DrawInternal()
@@ -74,7 +76,7 @@ public class PopupHandler : WindowMediatorSubscriberBase
if (_currentHandler.ShowClose) if (_currentHandler.ShowClose)
{ {
ImGui.Separator(); ImGui.Separator();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Times, "Close")) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Times, "Close"))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }

View File

@@ -42,7 +42,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.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Send Report"))
{ {
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
var reason = _reportReason; var reason = _reportReason;

View File

@@ -14,6 +14,7 @@ public class SelectTagForPairUi
{ {
private readonly TagHandler _tagHandler; private readonly TagHandler _tagHandler;
private readonly IdDisplayHandler _uidDisplayHandler; private readonly IdDisplayHandler _uidDisplayHandler;
private readonly UiSharedService _uiSharedService;
/// <summary> /// <summary>
/// The group UI is always open for a specific pair. This defines which pair the UI is open for. /// The group UI is always open for a specific pair. This defines which pair the UI is open for.
@@ -31,12 +32,13 @@ public class SelectTagForPairUi
/// </summary> /// </summary>
private string _tagNameToAdd = ""; private string _tagNameToAdd = "";
public SelectTagForPairUi(TagHandler tagHandler, IdDisplayHandler uidDisplayHandler) public SelectTagForPairUi(TagHandler tagHandler, IdDisplayHandler uidDisplayHandler, UiSharedService uiSharedService)
{ {
_show = false; _show = false;
_pair = null; _pair = null;
_tagHandler = tagHandler; _tagHandler = tagHandler;
_uidDisplayHandler = uidDisplayHandler; _uidDisplayHandler = uidDisplayHandler;
_uiSharedService = uiSharedService;
} }
public void Draw() public void Draw()
@@ -73,7 +75,7 @@ public class SelectTagForPairUi
ImGui.Separator(); ImGui.Separator();
ImGui.TextUnformatted($"Create a new group for {name}."); ImGui.TextUnformatted($"Create a new group for {name}.");
if (UiSharedService.IconButton(FontAwesomeIcon.Plus)) if (_uiSharedService.IconButton(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.IconTextButton(FontAwesomeIcon.Plus, "Create Syncshell"))
{ {
try try
{ {
@@ -85,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 (UiSharedService.IconButton(FontAwesomeIcon.Copy)) if (_uiSharedService.IconButton(FontAwesomeIcon.Copy))
{ {
ImGui.SetClipboardText(_lastCreatedGroup.Password); ImGui.SetClipboardText(_lastCreatedGroup.Password);
} }

View File

@@ -69,7 +69,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.IconTextButton(FontAwesomeIcon.StopCircle, "Cancel conversion"))
{ {
_conversionCancellationTokenSource.Cancel(); _conversionCancellationTokenSource.Cancel();
} }
@@ -111,7 +111,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.IconTextButton(FontAwesomeIcon.StopCircle, "Cancel analysis"))
{ {
_characterAnalyzer.CancelAnalyze(); _characterAnalyzer.CancelAnalyze();
} }
@@ -122,14 +122,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.IconTextButton(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.IconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (recalculate all entries)"))
{ {
_ = _characterAnalyzer.ComputeAnalysis(print: false, recalculate: true); _ = _characterAnalyzer.ComputeAnalysis(print: false, recalculate: true);
} }
@@ -264,7 +264,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.IconTextButton(FontAwesomeIcon.PlayCircle, "Start conversion of " + _texturesToConvert.Count + " texture(s)"))
{ {
_conversionCancellationTokenSource = _conversionCancellationTokenSource.CancelRecreate(); _conversionCancellationTokenSource = _conversionCancellationTokenSource.CancelRecreate();
_conversionTask = _ipcManager.Penumbra.ConvertTextureFiles(_logger, _texturesToConvert, _conversionProgress, _conversionCancellationTokenSource.Token); _conversionTask = _ipcManager.Penumbra.ConvertTextureFiles(_logger, _texturesToConvert, _conversionProgress, _conversionCancellationTokenSource.Token);

View File

@@ -135,7 +135,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.IconTextButton(FontAwesomeIcon.FileUpload, "Upload new profile picture"))
{ {
_fileDialogManager.OpenFileDialog("Select new Profile picture", ".png", (success, file) => _fileDialogManager.OpenFileDialog("Select new Profile picture", ".png", (success, file) =>
{ {
@@ -166,7 +166,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.IconTextButton(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));
} }
@@ -215,13 +215,13 @@ public class EditProfileUi : WindowMediatorSubscriberBase
ImGui.EndChildFrame(); ImGui.EndChildFrame();
} }
if (UiSharedService.IconTextButton(FontAwesomeIcon.Save, "Save Description")) if (_uiSharedService.IconTextButton(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.IconTextButton(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

@@ -100,7 +100,7 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
{ {
using (ImRaii.Disabled(!_eventAggregator.NewEventsAvailable)) using (ImRaii.Disabled(!_eventAggregator.NewEventsAvailable))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.ArrowsToCircle, "Refresh events")) if (_uiSharedService.IconTextButton(FontAwesomeIcon.ArrowsToCircle, "Refresh events"))
{ {
CurrentEvents = _eventAggregator.EventList.Value.OrderByDescending(f => f.EventTime).ToList(); CurrentEvents = _eventAggregator.EventList.Value.OrderByDescending(f => f.EventTime).ToList();
} }
@@ -113,10 +113,10 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
UiSharedService.ColorTextWrapped("New events are available, press refresh to update", ImGuiColors.DalamudYellow); UiSharedService.ColorTextWrapped("New events are available, press refresh to update", ImGuiColors.DalamudYellow);
} }
var buttonSize = UiSharedService.GetIconTextButtonSize(FontAwesomeIcon.FolderOpen, "Open EventLog Folder"); var buttonSize = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.FolderOpen, "Open EventLog Folder");
var dist = ImGui.GetWindowContentRegionMax().X - buttonSize; var dist = ImGui.GetWindowContentRegionMax().X - buttonSize;
ImGui.SameLine(dist); ImGui.SameLine(dist);
if (UiSharedService.IconTextButton(FontAwesomeIcon.FolderOpen, "Open EventLog folder")) if (_uiSharedService.IconTextButton(FontAwesomeIcon.FolderOpen, "Open EventLog folder"))
{ {
ProcessStartInfo ps = new() ProcessStartInfo ps = new()
{ {
@@ -131,7 +131,7 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
var foldOut = ImRaii.TreeNode("Filter"); var foldOut = ImRaii.TreeNode("Filter");
if (foldOut) if (foldOut)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Ban, "Clear Filters")) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Ban, "Clear Filters"))
{ {
ClearFilters(); ClearFilters();
} }

View File

@@ -12,6 +12,7 @@ namespace MareSynchronos.UI;
public class GposeUi : WindowMediatorSubscriberBase public class GposeUi : WindowMediatorSubscriberBase
{ {
private readonly MareConfigService _configService; private readonly MareConfigService _configService;
private readonly UiSharedService _uiSharedService;
private readonly DalamudUtilService _dalamudUtil; private readonly DalamudUtilService _dalamudUtil;
private readonly FileDialogManager _fileDialogManager; private readonly FileDialogManager _fileDialogManager;
private readonly MareCharaFileManager _mareCharaFileManager; private readonly MareCharaFileManager _mareCharaFileManager;
@@ -20,13 +21,14 @@ public class GposeUi : WindowMediatorSubscriberBase
public GposeUi(ILogger<GposeUi> logger, MareCharaFileManager mareCharaFileManager, public GposeUi(ILogger<GposeUi> logger, MareCharaFileManager mareCharaFileManager,
DalamudUtilService dalamudUtil, FileDialogManager fileDialogManager, MareConfigService configService, DalamudUtilService dalamudUtil, FileDialogManager fileDialogManager, MareConfigService configService,
MareMediator mediator, PerformanceCollectorService performanceCollectorService) MareMediator mediator, PerformanceCollectorService performanceCollectorService, UiSharedService uiSharedService)
: base(logger, mediator, "Mare Synchronos Gpose Import UI###MareSynchronosGposeUI", performanceCollectorService) : base(logger, mediator, "Mare Synchronos Gpose Import UI###MareSynchronosGposeUI", performanceCollectorService)
{ {
_mareCharaFileManager = mareCharaFileManager; _mareCharaFileManager = mareCharaFileManager;
_dalamudUtil = dalamudUtil; _dalamudUtil = dalamudUtil;
_fileDialogManager = fileDialogManager; _fileDialogManager = fileDialogManager;
_configService = configService; _configService = configService;
_uiSharedService = uiSharedService;
Mediator.Subscribe<GposeStartMessage>(this, (_) => StartGpose()); Mediator.Subscribe<GposeStartMessage>(this, (_) => StartGpose());
Mediator.Subscribe<GposeEndMessage>(this, (_) => EndGpose()); Mediator.Subscribe<GposeEndMessage>(this, (_) => EndGpose());
IsOpen = _dalamudUtil.IsInGpose; IsOpen = _dalamudUtil.IsInGpose;
@@ -43,7 +45,7 @@ public class GposeUi : WindowMediatorSubscriberBase
if (!_mareCharaFileManager.CurrentlyWorking) if (!_mareCharaFileManager.CurrentlyWorking)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.FolderOpen, "Load MCDF")) if (_uiSharedService.IconTextButton(FontAwesomeIcon.FolderOpen, "Load MCDF"))
{ {
_fileDialogManager.OpenFileDialog("Pick MCDF file", ".mcdf", (success, paths) => _fileDialogManager.OpenFileDialog("Pick MCDF file", ".mcdf", (success, paths) =>
{ {
@@ -61,7 +63,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.IconTextButton(FontAwesomeIcon.Check, "Apply loaded MCDF"))
{ {
_applicationTask = Task.Run(async () => await _mareCharaFileManager.ApplyMareCharaFile(_dalamudUtil.GposeTargetGameObject, _expectedLength!.GetAwaiter().GetResult()).ConfigureAwait(false)); _applicationTask = Task.Run(async () => await _mareCharaFileManager.ApplyMareCharaFile(_dalamudUtil.GposeTargetGameObject, _expectedLength!.GetAwaiter().GetResult()).ConfigureAwait(false));
} }

View File

@@ -76,7 +76,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.IconTextButton(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;
@@ -123,7 +123,7 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
_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.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested"))
{ {
_ownPermissions.DisableGroupSounds = _groupJoinInfo.GroupPermissions.IsPreferDisableSounds(); _ownPermissions.DisableGroupSounds = _groupJoinInfo.GroupPermissions.IsPreferDisableSounds();
} }
@@ -139,7 +139,7 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
_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.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested"))
{ {
_ownPermissions.DisableGroupAnimations = _groupJoinInfo.GroupPermissions.IsPreferDisableAnimations(); _ownPermissions.DisableGroupAnimations = _groupJoinInfo.GroupPermissions.IsPreferDisableAnimations();
} }
@@ -155,7 +155,7 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
_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.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowRight, "Apply suggested"))
{ {
_ownPermissions.DisableGroupVFX = _groupJoinInfo.GroupPermissions.IsPreferDisableVFX(); _ownPermissions.DisableGroupVFX = _groupJoinInfo.GroupPermissions.IsPreferDisableVFX();
} }
@@ -167,7 +167,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.IconTextButton(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

@@ -133,7 +133,7 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
bool hasChanges = _ownPermissions != Pair.UserPair.OwnPermissions; bool hasChanges = _ownPermissions != Pair.UserPair.OwnPermissions;
using (ImRaii.Disabled(!hasChanges)) using (ImRaii.Disabled(!hasChanges))
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Save, "Save")) if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Save, "Save"))
{ {
_ = _apiController.SetBulkPermissions(new( _ = _apiController.SetBulkPermissions(new(
new(StringComparer.Ordinal) new(StringComparer.Ordinal)
@@ -145,21 +145,21 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
} }
UiSharedService.AttachToolTip("Save and apply all changes"); UiSharedService.AttachToolTip("Save and apply all changes");
var rightSideButtons = UiSharedService.GetIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.Undo, "Revert") + var rightSideButtons = _uiSharedService.GetIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.Undo, "Revert") +
UiSharedService.GetIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, "Reset to Default"); _uiSharedService.GetIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, "Reset to Default");
var availableWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X; var availableWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X;
ImGui.SameLine(availableWidth - rightSideButtons); ImGui.SameLine(availableWidth - rightSideButtons);
using (ImRaii.Disabled(!hasChanges)) using (ImRaii.Disabled(!hasChanges))
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Undo, "Revert")) if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Undo, "Revert"))
{ {
_ownPermissions = Pair.UserPair.OwnPermissions.DeepClone(); _ownPermissions = Pair.UserPair.OwnPermissions.DeepClone();
} }
UiSharedService.AttachToolTip("Revert all changes"); UiSharedService.AttachToolTip("Revert all changes");
ImGui.SameLine(); ImGui.SameLine();
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, "Reset to Default")) if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, "Reset to Default"))
{ {
var defaultPermissions = _apiController.DefaultPermissions!; var defaultPermissions = _apiController.DefaultPermissions!;
_ownPermissions.SetSticky(Pair.IsDirectlyPaired || defaultPermissions.IndividualIsSticky); _ownPermissions.SetSticky(Pair.IsDirectlyPaired || defaultPermissions.IndividualIsSticky);

View File

@@ -378,7 +378,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 (_uiShared.IconTextButton(FontAwesomeIcon.Copy, "[DEBUG] Copy Last created Character Data to clipboard"))
{ {
if (LastCreatedCharacterData != null) if (LastCreatedCharacterData != null)
{ {
@@ -406,12 +406,12 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("Enabling this can incur a (slight) performance impact. Enabling this for extended periods of time is not recommended."); _uiShared.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 (_uiShared.IconTextButton(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 (_uiShared.IconTextButton(FontAwesomeIcon.StickyNote, "Print Performance Stats (last 60s) to /xllog"))
{ {
_performanceCollector.PrintPerformanceStats(60); _performanceCollector.PrintPerformanceStats(60);
} }
@@ -437,7 +437,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 (_uiShared.IconTextButton(FontAwesomeIcon.Save, "Export Character as MCDF"))
{ {
string defaultFileName = string.IsNullOrEmpty(_exportDescription) string defaultFileName = string.IsNullOrEmpty(_exportDescription)
? "export.mcdf" ? "export.mcdf"
@@ -494,7 +494,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
{ {
ImGui.SameLine(); ImGui.SameLine();
using var id = ImRaii.PushId("penumbraMonitor"); using var id = ImRaii.PushId("penumbraMonitor");
if (UiSharedService.IconTextButton(FontAwesomeIcon.ArrowsToCircle, "Try to reinitialize Monitor")) if (_uiShared.IconTextButton(FontAwesomeIcon.ArrowsToCircle, "Try to reinitialize Monitor"))
{ {
_cacheMonitor.StartPenumbraWatcher(_ipcManager.Penumbra.ModDirectory); _cacheMonitor.StartPenumbraWatcher(_ipcManager.Penumbra.ModDirectory);
} }
@@ -506,14 +506,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
{ {
ImGui.SameLine(); ImGui.SameLine();
using var id = ImRaii.PushId("mareMonitor"); using var id = ImRaii.PushId("mareMonitor");
if (UiSharedService.IconTextButton(FontAwesomeIcon.ArrowsToCircle, "Try to reinitialize Monitor")) if (_uiShared.IconTextButton(FontAwesomeIcon.ArrowsToCircle, "Try to reinitialize Monitor"))
{ {
_cacheMonitor.StartMareWatcher(_configService.Current.CacheFolder); _cacheMonitor.StartMareWatcher(_configService.Current.CacheFolder);
} }
} }
if (_cacheMonitor.MareWatcher == null || _cacheMonitor.PenumbraWatcher == null) if (_cacheMonitor.MareWatcher == null || _cacheMonitor.PenumbraWatcher == null)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Play, "Resume Monitoring")) if (_uiShared.IconTextButton(FontAwesomeIcon.Play, "Resume Monitoring"))
{ {
_cacheMonitor.StartMareWatcher(_configService.Current.CacheFolder); _cacheMonitor.StartMareWatcher(_configService.Current.CacheFolder);
_cacheMonitor.StartPenumbraWatcher(_ipcManager.Penumbra.ModDirectory); _cacheMonitor.StartPenumbraWatcher(_ipcManager.Penumbra.ModDirectory);
@@ -527,7 +527,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
{ {
using (ImRaii.Disabled(!UiSharedService.CtrlPressed())) using (ImRaii.Disabled(!UiSharedService.CtrlPressed()))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Stop, "Stop Monitoring")) if (_uiShared.IconTextButton(FontAwesomeIcon.Stop, "Stop Monitoring"))
{ {
_cacheMonitor.StopMonitoring(); _cacheMonitor.StopMonitoring();
} }
@@ -562,7 +562,7 @@ 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 (_uiShared.IconTextButton(FontAwesomeIcon.FileArchive, "Compact all files in storage"))
{ {
_ = Task.Run(() => _ = Task.Run(() =>
{ {
@@ -573,7 +573,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
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 (_uiShared.IconTextButton(FontAwesomeIcon.File, "Decompact all files in storage"))
{ {
_ = Task.Run(() => _ = Task.Run(() =>
{ {
@@ -600,7 +600,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
"This operation, depending on how many files you have in your storage, can take a while and will be CPU and drive intensive."); "This operation, depending on how many files you have in your storage, can take a while and will be CPU and drive intensive.");
using (ImRaii.Disabled(_validationTask != null && !_validationTask.IsCompleted)) using (ImRaii.Disabled(_validationTask != null && !_validationTask.IsCompleted))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Check, "Start File Storage Validation")) if (_uiShared.IconTextButton(FontAwesomeIcon.Check, "Start File Storage Validation"))
{ {
_validationCts?.Cancel(); _validationCts?.Cancel();
_validationCts?.Dispose(); _validationCts?.Dispose();
@@ -612,7 +612,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (_validationTask != null && !_validationTask.IsCompleted) if (_validationTask != null && !_validationTask.IsCompleted)
{ {
ImGui.SameLine(); ImGui.SameLine();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Times, "Cancel")) if (_uiShared.IconTextButton(FontAwesomeIcon.Times, "Cancel"))
{ {
_validationCts?.Cancel(); _validationCts?.Cancel();
} }
@@ -646,7 +646,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 (_uiShared.IconTextButton(FontAwesomeIcon.Trash, "Clear local storage") && UiSharedService.CtrlPressed() && _readClearCache)
{ {
_ = Task.Run(() => _ = Task.Run(() =>
{ {
@@ -677,11 +677,11 @@ public class SettingsUi : WindowMediatorSubscriberBase
//ImGui.Separator(); //ImGui.Separator();
_uiShared.BigText("Notes"); _uiShared.BigText("Notes");
if (UiSharedService.IconTextButton(FontAwesomeIcon.StickyNote, "Export all your user notes to clipboard")) if (_uiShared.IconTextButton(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 (_uiShared.IconTextButton(FontAwesomeIcon.FileImport, "Import notes from clipboard"))
{ {
_notesSuccessfullyApplied = null; _notesSuccessfullyApplied = null;
var notes = ImGui.GetClipboardText(); var notes = ImGui.GetClipboardText();
@@ -1094,7 +1094,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 (_uiShared.IconTextButton(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.");
@@ -1108,14 +1108,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 (_uiShared.IconTextButton(FontAwesomeIcon.User, "Add current character"))
{ {
_serverConfigurationManager.AddCurrentCharacterToServer(idx); _serverConfigurationManager.AddCurrentCharacterToServer(idx);
} }
ImGui.SameLine(); ImGui.SameLine();
} }
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Add new character")) if (_uiShared.IconTextButton(FontAwesomeIcon.Plus, "Add new character"))
{ {
_serverConfigurationManager.AddEmptyCharacterToServer(idx); _serverConfigurationManager.AddEmptyCharacterToServer(idx);
} }
@@ -1147,7 +1147,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 (_uiShared.IconTextButton(FontAwesomeIcon.Trash, "Delete Secret Key") && UiSharedService.CtrlPressed())
{ {
selectedServer.SecretKeys.Remove(item.Key); selectedServer.SecretKeys.Remove(item.Key);
_serverConfigurationManager.Save(); _serverConfigurationManager.Save();
@@ -1164,7 +1164,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
ImGui.Separator(); ImGui.Separator();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Add new Secret Key")) if (_uiShared.IconTextButton(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()
{ {
@@ -1204,7 +1204,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 (_uiShared.IconTextButton(FontAwesomeIcon.Trash, "Delete Service") && UiSharedService.CtrlPressed())
{ {
_serverConfigurationManager.DeleteServer(selectedServer); _serverConfigurationManager.DeleteServer(selectedServer);
} }

View File

@@ -77,7 +77,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
{ {
bool isInvitesDisabled = perm.IsDisableInvites(); bool isInvitesDisabled = perm.IsDisableInvites();
if (UiSharedService.IconTextButton(isInvitesDisabled ? FontAwesomeIcon.Unlock : FontAwesomeIcon.Lock, if (_uiSharedService.IconTextButton(isInvitesDisabled ? FontAwesomeIcon.Unlock : FontAwesomeIcon.Lock,
isInvitesDisabled ? "Unlock Syncshell" : "Lock Syncshell")) isInvitesDisabled ? "Unlock Syncshell" : "Lock Syncshell"))
{ {
perm.SetDisableInvites(!isInvitesDisabled); perm.SetDisableInvites(!isInvitesDisabled);
@@ -87,7 +87,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.IconTextButton(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);
} }
@@ -96,7 +96,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.IconTextButton(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);
} }
@@ -106,7 +106,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.IconTextButton(FontAwesomeIcon.Copy, "Copy Invites to clipboard"))
{ {
ImGui.SetClipboardText(invites); ImGui.SetClipboardText(invites);
} }
@@ -186,7 +186,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.TableNextColumn(); // actions ImGui.TableNextColumn(); // actions
if (_isOwner) if (_isOwner)
{ {
if (UiSharedService.IconButton(FontAwesomeIcon.UserShield)) if (_uiSharedService.IconButton(FontAwesomeIcon.UserShield))
{ {
GroupPairUserInfo userInfo = pair.Value ?? GroupPairUserInfo.None; GroupPairUserInfo userInfo = pair.Value ?? GroupPairUserInfo.None;
@@ -200,7 +200,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
if (_isOwner || (pair.Value == null || (pair.Value != null && !pair.Value.Value.IsModerator()))) if (_isOwner || (pair.Value == null || (pair.Value != null && !pair.Value.Value.IsModerator())))
{ {
if (UiSharedService.IconButton(FontAwesomeIcon.Thumbtack)) if (_uiSharedService.IconButton(FontAwesomeIcon.Thumbtack))
{ {
GroupPairUserInfo userInfo = pair.Value ?? GroupPairUserInfo.None; GroupPairUserInfo userInfo = pair.Value ?? GroupPairUserInfo.None;
@@ -213,7 +213,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
using (ImRaii.Disabled(!UiSharedService.CtrlPressed())) using (ImRaii.Disabled(!UiSharedService.CtrlPressed()))
{ {
if (UiSharedService.IconButton(FontAwesomeIcon.Trash)) if (_uiSharedService.IconButton(FontAwesomeIcon.Trash))
{ {
_ = _apiController.GroupRemoveUser(new GroupPairDto(GroupFullInfo.Group, pair.Key.UserData)); _ = _apiController.GroupRemoveUser(new GroupPairDto(GroupFullInfo.Group, pair.Key.UserData));
} }
@@ -224,7 +224,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.SameLine(); ImGui.SameLine();
using (ImRaii.Disabled(!UiSharedService.CtrlPressed())) using (ImRaii.Disabled(!UiSharedService.CtrlPressed()))
{ {
if (UiSharedService.IconButton(FontAwesomeIcon.Ban)) if (_uiSharedService.IconButton(FontAwesomeIcon.Ban))
{ {
Mediator.Publish(new OpenBanUserPopupMessage(pair.Key, GroupFullInfo)); Mediator.Publish(new OpenBanUserPopupMessage(pair.Key, GroupFullInfo));
} }
@@ -242,7 +242,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
{ {
using (ImRaii.Disabled(!UiSharedService.CtrlPressed())) using (ImRaii.Disabled(!UiSharedService.CtrlPressed()))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Broom, "Clear Syncshell")) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Broom, "Clear Syncshell"))
{ {
_ = _apiController.GroupClear(new(GroupFullInfo.Group)); _ = _apiController.GroupClear(new(GroupFullInfo.Group));
} }
@@ -254,7 +254,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.Separator(); ImGui.Separator();
ImGuiHelpers.ScaledDummy(2f); ImGuiHelpers.ScaledDummy(2f);
if (UiSharedService.IconTextButton(FontAwesomeIcon.Unlink, "Check for Inactive Users")) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Unlink, "Check for Inactive Users"))
{ {
_pruneTestTask = _apiController.GroupPrune(new(GroupFullInfo.Group), _pruneDays, execute: false); _pruneTestTask = _apiController.GroupPrune(new(GroupFullInfo.Group), _pruneDays, execute: false);
_pruneTask = null; _pruneTask = null;
@@ -290,7 +290,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
{ {
using (ImRaii.Disabled(!UiSharedService.CtrlPressed())) using (ImRaii.Disabled(!UiSharedService.CtrlPressed()))
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Broom, "Prune Inactive Users")) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Broom, "Prune Inactive Users"))
{ {
_pruneTask = _apiController.GroupPrune(new(GroupFullInfo.Group), _pruneDays, execute: true); _pruneTask = _apiController.GroupPrune(new(GroupFullInfo.Group), _pruneDays, execute: true);
_pruneTestTask = null; _pruneTestTask = null;
@@ -318,7 +318,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
var banNode = ImRaii.TreeNode("User Bans"); var banNode = ImRaii.TreeNode("User Bans");
if (banNode) if (banNode)
{ {
if (UiSharedService.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server")) if (_uiSharedService.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
{ {
_bannedUsers = _apiController.GroupGetBannedUsers(new GroupDto(GroupFullInfo.Group)).Result; _bannedUsers = _apiController.GroupGetBannedUsers(new GroupDto(GroupFullInfo.Group)).Result;
} }
@@ -347,7 +347,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.IconTextButton(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));
@@ -372,7 +372,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.IconTextButton(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());
@@ -383,7 +383,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.IconTextButton(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());
@@ -394,7 +394,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.IconTextButton(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());
@@ -413,7 +413,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"); var buttonSize = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.Passport, "Change Password");
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;
@@ -423,7 +423,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.IconTextButton(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;
@@ -436,7 +436,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.IconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
{ {
IsOpen = false; IsOpen = false;
_ = _apiController.GroupDelete(new(GroupFullInfo.Group)); _ = _apiController.GroupDelete(new(GroupFullInfo.Group));

View File

@@ -179,14 +179,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.GetIconTextButtonSize(FontAwesomeIcon.UserPlus, "Add");
ImGui.SetNextItemWidth(availableXWidth - buttonSize - spacingX); ImGui.SetNextItemWidth(availableXWidth - buttonSize - 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.IconTextButton(FontAwesomeIcon.UserPlus, "Add"))
{ {
_ = _apiController.UserAddPair(new(new(_pairToAdd))); _ = _apiController.UserAddPair(new(new(_pairToAdd)));
_pairToAdd = string.Empty; _pairToAdd = string.Empty;
@@ -197,7 +197,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.GetIconTextButtonSize(FontAwesomeIcon.Ban, "Clear");
ImGui.SetNextItemWidth(availableWidth - buttonSize - spacingX); ImGui.SetNextItemWidth(availableWidth - buttonSize - 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))
@@ -206,7 +206,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.IconTextButton(FontAwesomeIcon.Ban, "Clear"))
{ {
Filter = string.Empty; Filter = string.Empty;
} }
@@ -467,7 +467,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.IconTextButton(FontAwesomeIcon.Plus, "Create new Syncshell", buttonX))
{ {
_mareMediator.Publish(new UiToggleMessage(typeof(CreateSyncshellUI))); _mareMediator.Publish(new UiToggleMessage(typeof(CreateSyncshellUI)));
} }
@@ -476,7 +476,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.IconTextButton(FontAwesomeIcon.Users, "Join existing Syncshell", buttonX))
{ {
_mareMediator.Publish(new UiToggleMessage(typeof(JoinSyncshellUI))); _mareMediator.Publish(new UiToggleMessage(typeof(JoinSyncshellUI)));
} }
@@ -486,13 +486,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.IconTextButton(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.IconTextButton(FontAwesomeIcon.PersonCircleQuestion, "Chara Data Analysis", buttonX))
{ {
_mareMediator.Publish(new UiToggleMessage(typeof(DataAnalysisUi))); _mareMediator.Publish(new UiToggleMessage(typeof(DataAnalysisUi)));
} }
@@ -519,7 +519,7 @@ public class TopTabMenu
{ {
if (ImGui.BeginPopup(popupTitle)) if (ImGui.BeginPopup(popupTitle))
{ {
if (UiSharedService.IconTextButton(enableIcon, enableText, null, true)) if (_uiSharedService.IconTextButton(enableIcon, enableText, null, true))
{ {
_ = GlobalControlCountdown(10); _ = GlobalControlCountdown(10);
var bulkIndividualPairs = _pairManager.PairsWithGroups.Keys var bulkIndividualPairs = _pairManager.PairsWithGroups.Keys
@@ -533,7 +533,7 @@ public class TopTabMenu
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
if (UiSharedService.IconTextButton(disableIcon, disableText, null, true)) if (_uiSharedService.IconTextButton(disableIcon, disableText, null, true))
{ {
_ = GlobalControlCountdown(10); _ = GlobalControlCountdown(10);
var bulkIndividualPairs = _pairManager.PairsWithGroups.Keys var bulkIndividualPairs = _pairManager.PairsWithGroups.Keys
@@ -557,7 +557,7 @@ public class TopTabMenu
if (ImGui.BeginPopup(popupTitle)) if (ImGui.BeginPopup(popupTitle))
{ {
if (UiSharedService.IconTextButton(enableIcon, enableText, null, true)) if (_uiSharedService.IconTextButton(enableIcon, enableText, null, true))
{ {
_ = GlobalControlCountdown(10); _ = GlobalControlCountdown(10);
var bulkSyncshells = _pairManager.GroupPairs.Keys var bulkSyncshells = _pairManager.GroupPairs.Keys
@@ -571,7 +571,7 @@ public class TopTabMenu
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }
if (UiSharedService.IconTextButton(disableIcon, disableText, null, true)) if (_uiSharedService.IconTextButton(disableIcon, disableText, null, true))
{ {
_ = GlobalControlCountdown(10); _ = GlobalControlCountdown(10);
var bulkSyncshells = _pairManager.GroupPairs.Keys var bulkSyncshells = _pairManager.GroupPairs.Keys

View File

@@ -113,8 +113,38 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
})); }));
}); });
GameFont = _pluginInterface.UiBuilder.FontAtlas.NewGameFontHandle(new(GameFontFamilyAndSize.Axis12)); GameFont = _pluginInterface.UiBuilder.FontAtlas.NewGameFontHandle(new(GameFontFamilyAndSize.Axis12));
IconFont = _pluginInterface.UiBuilder.IconFontHandle; IconFont = _pluginInterface.UiBuilder.FontAtlas.NewDelegateFontHandle(e =>
{
e.OnPreBuild(tk => tk.AddFontAwesomeIconFont(new()
{
SizePx = _pluginInterface.UiBuilder.DefaultFontSpec.SizePx,
GlyphMinAdvanceX = _pluginInterface.UiBuilder.DefaultFontSpec.SizePx,
GlyphMaxAdvanceX = _pluginInterface.UiBuilder.DefaultFontSpec.SizePx
}));
e.OnPostBuild(tk =>
{
var font = tk.Font;
var nsize = font.FontSize;
var glyphs = font.GlyphsWrapped();
foreach (ref var glyph in glyphs.DataSpan)
{
var ratio = 1f;
if (glyph.X1 - glyph.X0 > nsize)
ratio = Math.Max(ratio, (glyph.X1 - glyph.X0) / nsize);
if (glyph.Y1 - glyph.Y0 > nsize)
ratio = Math.Max(ratio, (glyph.Y1 - glyph.Y0) / nsize);
var w = MathF.Round((glyph.X1 - glyph.X0) / ratio, MidpointRounding.ToZero);
var h = MathF.Round((glyph.Y1 - glyph.Y0) / ratio, MidpointRounding.AwayFromZero);
glyph.X0 = MathF.Round((nsize - w) / 2f, MidpointRounding.ToZero);
glyph.Y0 = MathF.Round((nsize - h) / 2f, MidpointRounding.AwayFromZero);
glyph.X1 = glyph.X0 + w;
glyph.Y1 = glyph.Y0 + h;
glyph.AdvanceX = nsize;
}
tk.BuildLookupTable(font);
});
});
} }
public ApiController ApiController => _apiController; public ApiController ApiController => _apiController;
@@ -264,11 +294,12 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
public static Vector4 GetBoolColor(bool input) => input ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed; public static Vector4 GetBoolColor(bool input) => input ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed;
public static float GetIconTextButtonSize(FontAwesomeIcon icon, string text) public float GetIconTextButtonSize(FontAwesomeIcon icon, string text)
{ {
ImGui.PushFont(UiBuilder.IconFont); Vector2 vector;
Vector2 vector = ImGui.CalcTextSize(icon.ToIconString()); using (IconFont.Push())
ImGui.PopFont(); vector = ImGui.CalcTextSize(icon.ToIconString());
Vector2 vector2 = ImGui.CalcTextSize(text); Vector2 vector2 = ImGui.CalcTextSize(text);
float num = 3f * ImGuiHelpers.GlobalScale; float num = 3f * ImGuiHelpers.GlobalScale;
return vector.X + vector2.X + ImGui.GetStyle().FramePadding.X * 2f + num; return vector.X + vector2.X + ImGui.GetStyle().FramePadding.X * 2f + num;
@@ -295,14 +326,14 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
return ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X; return ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X;
} }
public static bool IconButton(FontAwesomeIcon icon, float? height = null) public bool IconButton(FontAwesomeIcon icon, float? height = null)
{ {
string text = icon.ToIconString(); string text = icon.ToIconString();
ImGui.PushID(text); ImGui.PushID(text);
ImGui.PushFont(UiBuilder.IconFont); Vector2 vector;
Vector2 vector = ImGui.CalcTextSize(text); using (IconFont.Push())
ImGui.PopFont(); vector = ImGui.CalcTextSize(text);
ImDrawListPtr windowDrawList = ImGui.GetWindowDrawList(); ImDrawListPtr windowDrawList = ImGui.GetWindowDrawList();
Vector2 cursorScreenPos = ImGui.GetCursorScreenPos(); Vector2 cursorScreenPos = ImGui.GetCursorScreenPos();
float x = vector.X + ImGui.GetStyle().FramePadding.X * 2f; float x = vector.X + ImGui.GetStyle().FramePadding.X * 2f;
@@ -310,15 +341,14 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
bool result = ImGui.Button(string.Empty, new Vector2(x, frameHeight)); bool result = ImGui.Button(string.Empty, new Vector2(x, frameHeight));
Vector2 pos = new Vector2(cursorScreenPos.X + ImGui.GetStyle().FramePadding.X, Vector2 pos = new Vector2(cursorScreenPos.X + ImGui.GetStyle().FramePadding.X,
cursorScreenPos.Y + (height ?? ImGui.GetFrameHeight()) / 2f - (vector.Y / 2f)); cursorScreenPos.Y + (height ?? ImGui.GetFrameHeight()) / 2f - (vector.Y / 2f));
ImGui.PushFont(UiBuilder.IconFont); using (IconFont.Push())
windowDrawList.AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), text); windowDrawList.AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), text);
ImGui.PopFont();
ImGui.PopID(); ImGui.PopID();
return result; return result;
} }
private static bool IconTextButtonInternal(FontAwesomeIcon icon, string text, Vector4? defaultColor = null, float? width = null) private bool IconTextButtonInternal(FontAwesomeIcon icon, string text, Vector4? defaultColor = null, float? width = null)
{ {
int num = 0; int num = 0;
if (defaultColor.HasValue) if (defaultColor.HasValue)
@@ -328,9 +358,9 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
} }
ImGui.PushID(text); ImGui.PushID(text);
ImGui.PushFont(UiBuilder.IconFont); Vector2 vector;
Vector2 vector = ImGui.CalcTextSize(icon.ToIconString()); using (IconFont.Push())
ImGui.PopFont(); vector = ImGui.CalcTextSize(icon.ToIconString());
Vector2 vector2 = ImGui.CalcTextSize(text); Vector2 vector2 = ImGui.CalcTextSize(text);
ImDrawListPtr windowDrawList = ImGui.GetWindowDrawList(); ImDrawListPtr windowDrawList = ImGui.GetWindowDrawList();
Vector2 cursorScreenPos = ImGui.GetCursorScreenPos(); Vector2 cursorScreenPos = ImGui.GetCursorScreenPos();
@@ -339,9 +369,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
float frameHeight = ImGui.GetFrameHeight(); float frameHeight = ImGui.GetFrameHeight();
bool result = ImGui.Button(string.Empty, new Vector2(x, frameHeight)); bool result = ImGui.Button(string.Empty, new Vector2(x, frameHeight));
Vector2 pos = new Vector2(cursorScreenPos.X + ImGui.GetStyle().FramePadding.X, cursorScreenPos.Y + ImGui.GetStyle().FramePadding.Y); Vector2 pos = new Vector2(cursorScreenPos.X + ImGui.GetStyle().FramePadding.X, cursorScreenPos.Y + ImGui.GetStyle().FramePadding.Y);
ImGui.PushFont(UiBuilder.IconFont); using (IconFont.Push())
windowDrawList.AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString()); windowDrawList.AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString());
ImGui.PopFont();
Vector2 pos2 = new Vector2(pos.X + vector.X + num2, cursorScreenPos.Y + ImGui.GetStyle().FramePadding.Y); Vector2 pos2 = new Vector2(pos.X + vector.X + num2, cursorScreenPos.Y + ImGui.GetStyle().FramePadding.Y);
windowDrawList.AddText(pos2, ImGui.GetColorU32(ImGuiCol.Text), text); windowDrawList.AddText(pos2, ImGui.GetColorU32(ImGuiCol.Text), text);
ImGui.PopID(); ImGui.PopID();
@@ -353,7 +382,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
return result; return result;
} }
public static bool IconTextButton(FontAwesomeIcon icon, string text, float? width = null, bool isInPopup = false) public bool IconTextButton(FontAwesomeIcon icon, string text, float? width = null, bool isInPopup = false)
{ {
return IconTextButtonInternal(icon, text, return IconTextButtonInternal(icon, text,
isInPopup ? ColorHelpers.RgbaUintToVector4(ImGui.GetColorU32(ImGuiCol.PopupBg)) : null, isInPopup ? ColorHelpers.RgbaUintToVector4(ImGui.GetColorU32(ImGuiCol.PopupBg)) : null,
@@ -843,4 +872,15 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
} }
public sealed record IconScaleData(Vector2 IconSize, Vector2 NormalizedIconScale, float OffsetX, float IconScaling); public sealed record IconScaleData(Vector2 IconSize, Vector2 NormalizedIconScale, float OffsetX, float IconScaling);
protected override void Dispose(bool disposing)
{
if (!disposing) return;
base.Dispose(disposing);
IconFont.Dispose();
UidFont.Dispose();
GameFont.Dispose();
}
} }