UI icon refactoring stuff

minor refactoring

add mouseover in main ui

fix icon font issues

fix uploads/downloads icon alignment

fix code dupe

use fixed width icon handle, update deps

Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
Loporrit
2025-02-18 10:38:41 +00:00
parent 9bf36765e4
commit d48dcaf555
28 changed files with 504 additions and 545 deletions

View File

@@ -34,7 +34,7 @@ public class FileReplacementComparer : IEqualityComparer<FileReplacement>
return true;
}
private static int GetOrderIndependentHashCode<T>(IEnumerable<T> source)
private static int GetOrderIndependentHashCode<T>(IEnumerable<T> source) where T : notnull
{
int hash = 0;
foreach (T element in source)

View File

@@ -36,7 +36,7 @@ public class FileReplacementDataComparer : IEqualityComparer<FileReplacementData
return true;
}
private static int GetOrderIndependentHashCode<T>(IEnumerable<T> source)
private static int GetOrderIndependentHashCode<T>(IEnumerable<T> source) where T : notnull
{
int hash = 0;
foreach (T element in source)

View File

@@ -79,11 +79,11 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
.Where(x => x.RowId != 0 && !(x.RowId >= 500 && (x.UIForeground & 0xFFFFFF00) == 0))
.ToDictionary(x => (int)x.RowId);
});
mediator.Subscribe<TargetPairMessage>(this, async (msg) =>
mediator.Subscribe<TargetPairMessage>(this, (msg) =>
{
if (clientState.IsPvP) return;
var ident = msg.Pair.GetPlayerNameHash();
await RunOnFrameworkThread(() =>
_ = RunOnFrameworkThread(() =>
{
var addr = GetPlayerCharacterFromCachedTableByIdent(ident);
var pc = _clientState.LocalPlayer!;

View File

@@ -45,7 +45,7 @@ public class CompactUi : WindowMediatorSubscriberBase
private readonly ServerConfigurationManager _serverManager;
private readonly Stopwatch _timeout = new();
private readonly UidDisplayHandler _uidDisplayHandler;
private readonly UiSharedService _uiShared;
private readonly UiSharedService _uiSharedService;
private bool _buttonState;
private string _characterOrCommentFilter = string.Empty;
private Pair? _lastAddedUser;
@@ -63,7 +63,7 @@ public class CompactUi : WindowMediatorSubscriberBase
PerformanceCollectorService performanceCollectorService)
: base(logger, mediator, "###LoporritSyncMainUI", performanceCollectorService)
{
_uiShared = uiShared;
_uiSharedService = uiShared;
_configService = configService;
_apiController = apiController;
_pairManager = pairManager;
@@ -74,9 +74,9 @@ public class CompactUi : WindowMediatorSubscriberBase
var tagHandler = new TagHandler(_serverManager);
_groupPanel = new(this, uiShared, _pairManager, _chatService, uidDisplayHandler, _configService, _serverManager);
_selectGroupForPairUi = new(tagHandler, uidDisplayHandler);
_selectGroupForPairUi = new(tagHandler, uidDisplayHandler, _uiSharedService);
_selectPairsForGroupUi = new(tagHandler, uidDisplayHandler);
_pairGroupsUi = new(configService, tagHandler, uidDisplayHandler, apiController, _selectPairsForGroupUi);
_pairGroupsUi = new(configService, tagHandler, uidDisplayHandler, apiController, _selectPairsForGroupUi, _uiSharedService);
#if DEBUG
string dev = "Dev Build";
@@ -121,12 +121,14 @@ public class CompactUi : WindowMediatorSubscriberBase
if (!_apiController.IsCurrentVersion)
{
var ver = _apiController.CurrentClientVersion;
_uiShared.UidFont.Push();
var unsupported = "UNSUPPORTED VERSION";
var uidTextSize = ImGui.CalcTextSize(unsupported);
ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMax().X + ImGui.GetWindowContentRegionMin().X) / 2 - uidTextSize.X / 2);
using (_uiSharedService.UidFont.Push())
{
var uidTextSize = ImGui.CalcTextSize(unsupported);
ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMax().X + ImGui.GetWindowContentRegionMin().X) / 2 - uidTextSize.X / 2);
ImGui.AlignTextToFramePadding();
ImGui.TextColored(ImGuiColors.DalamudRed, unsupported);
_uiShared.UidFont.Pop();
}
UiSharedService.ColorTextWrapped($"Your Loporrit installation is out of date, the current version is {ver.Major}.{ver.Minor}.{ver.Build}. " +
$"It is highly recommended to keep Loporrit up to date. Open /xlplugins and update the plugin.", ImGuiColors.DalamudRed);
}
@@ -209,7 +211,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.NormalizedIconTextButton(FontAwesomeIcon.Save, "Save Note"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Save, "Save Note"))
{
_serverManager.SetNoteForUid(_lastAddedUser.UserData.UID, _lastAddedUserComment);
_lastAddedUser = null;
@@ -244,12 +246,12 @@ public class CompactUi : WindowMediatorSubscriberBase
if (keys.Any())
{
if (_secretKeyIdx == -1) _secretKeyIdx = keys.First().Key;
if (UiSharedService.NormalizedIconTextButton(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()
{
CharacterName = _uiShared.PlayerName,
WorldId = _uiShared.WorldId,
CharacterName = _uiSharedService.PlayerName,
WorldId = _uiSharedService.WorldId,
SecretKeyIdx = _secretKeyIdx
});
@@ -258,7 +260,7 @@ public class CompactUi : WindowMediatorSubscriberBase
_ = _apiController.CreateConnections();
}
_uiShared.DrawCombo("Secret Key##addCharacterSecretKey", keys, (f) => f.Value.FriendlyName, (f) => _secretKeyIdx = f.Key);
_uiSharedService.DrawCombo("Secret Key##addCharacterSecretKey", keys, (f) => f.Value.FriendlyName, (f) => _secretKeyIdx = f.Key);
}
else
{
@@ -268,7 +270,7 @@ public class CompactUi : WindowMediatorSubscriberBase
private void DrawAddPair()
{
var buttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Plus);
var buttonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Plus);
ImGui.SetNextItemWidth(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X - buttonSize.X);
ImGui.InputTextWithHint("##otheruid", "Other players UID/Alias", ref _pairToAdd, 20);
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X);
@@ -292,8 +294,8 @@ public class CompactUi : WindowMediatorSubscriberBase
private void DrawFilter()
{
var buttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.ArrowUp);
var playButtonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Play);
var buttonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.ArrowUp);
var playButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Play);
var users = GetFilteredUsers();
var userCount = users.Count;
@@ -375,9 +377,9 @@ public class CompactUi : WindowMediatorSubscriberBase
: (ImGui.GetWindowContentRegionMax().Y - ImGui.GetWindowContentRegionMin().Y) - TransferPartHeight - ImGui.GetCursorPosY();
var users = GetFilteredUsers().OrderBy(u => u.GetNoteOrName());
var onlineUsers = users.Where(u => u.UserPair!.OtherPermissions.IsPaired() && (u.IsOnline || u.UserPair!.OwnPermissions.IsPaused())).Select(c => new DrawUserPair("Online" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi)).ToList();
var visibleUsers = users.Where(u => u.IsVisible).Select(c => new DrawUserPair("Visible" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi)).ToList();
var offlineUsers = users.Where(u => !u.UserPair!.OtherPermissions.IsPaired() || (!u.IsOnline && !u.UserPair!.OwnPermissions.IsPaused())).Select(c => new DrawUserPair("Offline" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi)).ToList();
var onlineUsers = users.Where(u => u.UserPair!.OtherPermissions.IsPaired() && (u.IsOnline || u.UserPair!.OwnPermissions.IsPaused())).Select(c => new DrawUserPair("Online" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi, _uiSharedService)).ToList();
var visibleUsers = users.Where(u => u.IsVisible).Select(c => new DrawUserPair("Visible" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi, _uiSharedService)).ToList();
var offlineUsers = users.Where(u => !u.UserPair!.OtherPermissions.IsPaired() || (!u.IsOnline && !u.UserPair!.OwnPermissions.IsPaused())).Select(c => new DrawUserPair("Offline" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi, _uiSharedService)).ToList();
ImGui.BeginChild("list", new Vector2(WindowContentWidth, ySize), border: false);
@@ -388,7 +390,7 @@ public class CompactUi : WindowMediatorSubscriberBase
private void DrawServerStatus()
{
var buttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Link);
var buttonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Link);
var userCount = _apiController.OnlineUsers.ToString(CultureInfo.InvariantCulture);
var userSize = ImGui.CalcTextSize(userCount);
var textSize = ImGui.CalcTextSize("Users Online");
@@ -445,7 +447,7 @@ public class CompactUi : WindowMediatorSubscriberBase
if (_apiController.ServerState is not (ServerState.Reconnecting or ServerState.Disconnecting))
{
ImGui.PushStyleColor(ImGuiCol.Text, color);
if (ImGuiComponents.IconButton(connectedIcon))
if (_uiSharedService.IconButton(connectedIcon))
{
_serverManager.CurrentServer.FullPause = !_serverManager.CurrentServer.FullPause;
_serverManager.Save();
@@ -462,9 +464,8 @@ public class CompactUi : WindowMediatorSubscriberBase
if (currentUploads.Any())
{
ImGui.PushFont(UiBuilder.IconFont);
ImGui.TextUnformatted(FontAwesomeIcon.Upload.ToIconString());
ImGui.PopFont();
ImGui.AlignTextToFramePadding();
_uiSharedService.IconText(FontAwesomeIcon.Upload);
ImGui.SameLine(35 * ImGuiHelpers.GlobalScale);
var totalUploads = currentUploads.Count;
@@ -484,9 +485,8 @@ public class CompactUi : WindowMediatorSubscriberBase
if (currentDownloads.Any())
{
ImGui.PushFont(UiBuilder.IconFont);
ImGui.TextUnformatted(FontAwesomeIcon.Download.ToIconString());
ImGui.PopFont();
ImGui.AlignTextToFramePadding();
_uiSharedService.IconText(FontAwesomeIcon.Download);
ImGui.SameLine(35 * ImGuiHelpers.GlobalScale);
var totalDownloads = currentDownloads.Sum(c => c.TotalFiles);
@@ -504,14 +504,14 @@ public class CompactUi : WindowMediatorSubscriberBase
var bottomButtonWidth = (WindowContentWidth - ImGui.GetStyle().ItemSpacing.X) / 2;
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PersonCircleQuestion, "Character Analysis", bottomButtonWidth))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PersonCircleQuestion, "Character Analysis", bottomButtonWidth))
{
Mediator.Publish(new UiToggleMessage(typeof(DataAnalysisUi)));
}
ImGui.SameLine();
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.NotesMedical, "Event Viewer", bottomButtonWidth))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.NotesMedical, "Event Viewer", bottomButtonWidth))
{
Mediator.Publish(new UiToggleMessage(typeof(EventViewerUI)));
}
@@ -523,14 +523,16 @@ public class CompactUi : WindowMediatorSubscriberBase
{
var uidText = GetUidText();
var buttonSizeX = 0f;
Vector2 uidTextSize;
_uiShared.UidFont.Push();
var uidTextSize = ImGui.CalcTextSize(uidText);
_uiShared.UidFont.Pop();
using (_uiSharedService.UidFont.Push())
{
uidTextSize = ImGui.CalcTextSize(uidText);
}
var originalPos = ImGui.GetCursorPos();
ImGui.SetWindowFontScale(1.5f);
var buttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Cog);
var buttonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Cog);
buttonSizeX -= buttonSize.X - ImGui.GetStyle().ItemSpacing.X * 2;
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X);
ImGui.SetCursorPosY(originalPos.Y + uidTextSize.Y / 2 - buttonSize.Y / 2);
@@ -545,7 +547,7 @@ public class CompactUi : WindowMediatorSubscriberBase
if (_apiController.ServerState is ServerState.Connected)
{
buttonSizeX += UiSharedService.GetIconButtonSize(FontAwesomeIcon.Copy).X - ImGui.GetStyle().ItemSpacing.X * 2;
buttonSizeX += _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Copy).X - ImGui.GetStyle().ItemSpacing.X * 2;
ImGui.SetCursorPosY(originalPos.Y + uidTextSize.Y / 2 - buttonSize.Y / 2);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Copy))
{
@@ -558,9 +560,8 @@ public class CompactUi : WindowMediatorSubscriberBase
ImGui.SetCursorPosY(originalPos.Y + buttonSize.Y / 2 - uidTextSize.Y / 2 - ImGui.GetStyle().ItemSpacing.Y / 2);
ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMax().X + ImGui.GetWindowContentRegionMin().X) / 2 + buttonSizeX - uidTextSize.X / 2);
_uiShared.UidFont.Push();
ImGui.TextColored(GetUidColor(), uidText);
_uiShared.UidFont.Pop();
using (_uiSharedService.UidFont.Push())
ImGui.TextColored(GetUidColor(), uidText);
if (_apiController.ServerState is not ServerState.Connected)
{

View File

@@ -21,7 +21,10 @@ public class DrawGroupPair : DrawPairBase
private readonly GroupPairFullInfoDto _fullInfoDto;
private readonly GroupFullInfoDto _group;
public DrawGroupPair(string id, Pair entry, ApiController apiController, MareMediator mareMediator, GroupFullInfoDto group, GroupPairFullInfoDto fullInfoDto, UidDisplayHandler handler) : base(id, entry, apiController, handler)
public DrawGroupPair(string id, Pair entry, ApiController apiController,
MareMediator mareMediator, GroupFullInfoDto group, GroupPairFullInfoDto fullInfoDto,
UidDisplayHandler handler, UiSharedService uiSharedService)
: base(id, entry, apiController, handler, uiSharedService)
{
_group = group;
_fullInfoDto = fullInfoDto;
@@ -145,8 +148,8 @@ public class DrawGroupPair : DrawPairBase
var permIcon = (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled) ? FontAwesomeIcon.ExclamationTriangle
: ((soundsDisabled || animDisabled || vfxDisabled) ? FontAwesomeIcon.InfoCircle : FontAwesomeIcon.None);
var infoIconWidth = UiSharedService.GetIconSize(permIcon).X;
var plusButtonWidth = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Plus).X;
var barButtonWidth = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X;
var plusButtonWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Plus).X;
var barButtonWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X;
var pos = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() + spacing
- (showInfo ? (infoIconWidth + spacing) : 0)
@@ -158,7 +161,7 @@ public class DrawGroupPair : DrawPairBase
{
ImGui.SetCursorPosY(textPosY);
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
UiSharedService.FontText(permIcon.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(permIcon);
ImGui.PopStyleColor();
if (ImGui.IsItemHovered())
{
@@ -169,7 +172,7 @@ public class DrawGroupPair : DrawPairBase
if (individualSoundsDisabled)
{
var userSoundsText = "Sound sync disabled with " + _pair.UserData.AliasOrUID;
UiSharedService.FontText(FontAwesomeIcon.VolumeOff.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.VolumeOff);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userSoundsText);
ImGui.NewLine();
@@ -180,7 +183,7 @@ public class DrawGroupPair : DrawPairBase
if (individualAnimDisabled)
{
var userAnimText = "Animation sync disabled with " + _pair.UserData.AliasOrUID;
UiSharedService.FontText(FontAwesomeIcon.Stop.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.Stop);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userAnimText);
ImGui.NewLine();
@@ -191,7 +194,7 @@ public class DrawGroupPair : DrawPairBase
if (individualVFXDisabled)
{
var userVFXText = "VFX sync disabled with " + _pair.UserData.AliasOrUID;
UiSharedService.FontText(FontAwesomeIcon.Circle.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.Circle);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userVFXText);
ImGui.NewLine();
@@ -206,7 +209,7 @@ public class DrawGroupPair : DrawPairBase
else if ((animDisabled || soundsDisabled))
{
ImGui.SetCursorPosY(textPosY);
UiSharedService.FontText(permIcon.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(permIcon);
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
@@ -216,7 +219,7 @@ public class DrawGroupPair : DrawPairBase
if (soundsDisabled)
{
var userSoundsText = "Sound sync disabled by " + _pair.UserData.AliasOrUID;
UiSharedService.FontText(FontAwesomeIcon.VolumeOff.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.VolumeOff);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userSoundsText);
}
@@ -224,7 +227,7 @@ public class DrawGroupPair : DrawPairBase
if (animDisabled)
{
var userAnimText = "Animation sync disabled by " + _pair.UserData.AliasOrUID;
UiSharedService.FontText(FontAwesomeIcon.Stop.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.Stop);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userAnimText);
}
@@ -232,7 +235,7 @@ public class DrawGroupPair : DrawPairBase
if (vfxDisabled)
{
var userVFXText = "VFX sync disabled by " + _pair.UserData.AliasOrUID;
UiSharedService.FontText(FontAwesomeIcon.Circle.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.Circle);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userVFXText);
}
@@ -269,7 +272,7 @@ public class DrawGroupPair : DrawPairBase
if ((userIsModerator || userIsOwner) && !(entryIsMod || entryIsOwner))
{
var pinText = entryIsPinned ? "Unpin user" : "Pin user";
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Thumbtack, pinText))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Thumbtack, pinText))
{
ImGui.CloseCurrentPopup();
var userInfo = _fullInfoDto.GroupPairStatusInfo ^ GroupUserInfo.IsPinned;
@@ -277,14 +280,14 @@ public class DrawGroupPair : DrawPairBase
}
UiSharedService.AttachToolTip("Pin this user to the Syncshell. Pinned users will not be deleted in case of a manually initiated Syncshell clean");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Remove user") && UiSharedService.CtrlPressed())
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Remove user") && UiSharedService.CtrlPressed())
{
ImGui.CloseCurrentPopup();
_ = _apiController.GroupRemoveUser(_fullInfoDto);
}
UiSharedService.AttachToolTip("Hold CTRL and click to remove user " + (_pair.UserData.AliasOrUID) + " from Syncshell");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
{
ImGui.CloseCurrentPopup();
_mediator.Publish(new OpenBanUserPopupMessage(_pair, _group));
@@ -295,7 +298,7 @@ public class DrawGroupPair : DrawPairBase
if (userIsOwner)
{
string modText = entryIsMod ? "Demod user" : "Mod user";
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserShield, modText) && UiSharedService.CtrlPressed())
if (_uiSharedService.IconTextButton(FontAwesomeIcon.UserShield, modText) && UiSharedService.CtrlPressed())
{
ImGui.CloseCurrentPopup();
var userInfo = _fullInfoDto.GroupPairStatusInfo ^ GroupUserInfo.IsModerator;
@@ -303,7 +306,7 @@ public class DrawGroupPair : DrawPairBase
}
UiSharedService.AttachToolTip("Hold CTRL to change the moderator status for " + (_fullInfoDto.UserAliasOrUID) + Environment.NewLine +
"Moderators can kick, ban/unban, pin/unpin users and clear the Syncshell.");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Crown, "Transfer Ownership") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Crown, "Transfer Ownership") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
{
ImGui.CloseCurrentPopup();
_ = _apiController.GroupChangeOwnership(_fullInfoDto);
@@ -314,7 +317,7 @@ public class DrawGroupPair : DrawPairBase
ImGui.Separator();
if (_pair.IsVisible)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Eye, "Target player"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Eye, "Target player"))
{
_mediator.Publish(new TargetPairMessage(_pair));
ImGui.CloseCurrentPopup();
@@ -322,13 +325,13 @@ public class DrawGroupPair : DrawPairBase
}
if (!_pair.IsPaused)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.User, "Open Profile"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.User, "Open Profile"))
{
_displayHandler.OpenProfile(_pair);
ImGui.CloseCurrentPopup();
}
UiSharedService.AttachToolTip("Opens the profile for this user in a new window");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ExclamationTriangle, "Report Profile"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Report Profile"))
{
ImGui.CloseCurrentPopup();
_mediator.Publish(new OpenReportPopupMessage(_pair));

View File

@@ -1,5 +1,4 @@
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using ImGuiNET;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.UI.Handlers;
@@ -11,15 +10,17 @@ public abstract class DrawPairBase
{
protected readonly ApiController _apiController;
protected readonly UidDisplayHandler _displayHandler;
protected readonly UiSharedService _uiSharedService;
protected Pair _pair;
private readonly string _id;
protected DrawPairBase(string id, Pair entry, ApiController apiController, UidDisplayHandler uIDDisplayHandler)
protected DrawPairBase(string id, Pair entry, ApiController apiController, UidDisplayHandler uIDDisplayHandler, UiSharedService uiSharedService)
{
_id = id;
_pair = entry;
_apiController = apiController;
_displayHandler = uIDDisplayHandler;
_uiSharedService = uiSharedService;
}
public string ImGuiID => _id;
@@ -28,7 +29,7 @@ public abstract class DrawPairBase
public void DrawPairedClient()
{
var originalY = ImGui.GetCursorPosY();
var pauseIconSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Play);
var pauseIconSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Play);
var textSize = ImGui.CalcTextSize(_pair.UserData.AliasOrUID);
var startPos = ImGui.GetCursorStartPos();

View File

@@ -19,7 +19,10 @@ public class DrawUserPair : DrawPairBase
protected readonly MareMediator _mediator;
private readonly SelectGroupForPairUi _selectGroupForPairUi;
public DrawUserPair(string id, Pair entry, UidDisplayHandler displayHandler, ApiController apiController, MareMediator mareMediator, SelectGroupForPairUi selectGroupForPairUi) : base(id, entry, apiController, displayHandler)
public DrawUserPair(string id, Pair entry, UidDisplayHandler displayHandler, ApiController apiController,
MareMediator mareMediator, SelectGroupForPairUi selectGroupForPairUi,
UiSharedService uiSharedService)
: base(id, entry, apiController, displayHandler, uiSharedService)
{
if (_pair.UserPair == null) throw new ArgumentException("Pair must be UserPair", nameof(entry));
_pair = entry;
@@ -95,8 +98,8 @@ public class DrawUserPair : DrawPairBase
protected override float DrawRightSide(float textPosY, float originalY)
{
var pauseIcon = _pair.UserPair!.OwnPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseIconSize = UiSharedService.GetIconButtonSize(pauseIcon);
var barButtonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
var pauseIconSize = _uiSharedService.GetIconButtonSize(pauseIcon);
var barButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
var entryUID = _pair.UserData.AliasOrUID;
var spacingX = ImGui.GetStyle().ItemSpacing.X;
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
@@ -112,13 +115,13 @@ public class DrawUserPair : DrawPairBase
{
var infoIconPosDist = windowEndX - barButtonSize.X - spacingX - pauseIconSize.X - spacingX;
var icon = FontAwesomeIcon.ExclamationTriangle;
var iconwidth = UiSharedService.GetIconButtonSize(icon);
var iconwidth = _uiSharedService.GetIconButtonSize(icon);
rightSideStart = infoIconPosDist - iconwidth.X;
ImGui.SameLine(infoIconPosDist - iconwidth.X);
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(icon);
ImGui.PopStyleColor();
if (ImGui.IsItemHovered())
{
@@ -129,7 +132,7 @@ public class DrawUserPair : DrawPairBase
if (individualSoundsDisabled)
{
var userSoundsText = "Sound sync disabled with " + _pair.UserData.AliasOrUID;
UiSharedService.FontText(FontAwesomeIcon.VolumeOff.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.VolumeOff);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userSoundsText);
ImGui.NewLine();
@@ -140,7 +143,7 @@ public class DrawUserPair : DrawPairBase
if (individualAnimDisabled)
{
var userAnimText = "Animation sync disabled with " + _pair.UserData.AliasOrUID;
UiSharedService.FontText(FontAwesomeIcon.Stop.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.Stop);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userAnimText);
ImGui.NewLine();
@@ -151,7 +154,7 @@ public class DrawUserPair : DrawPairBase
if (individualVFXDisabled)
{
var userVFXText = "VFX sync disabled with " + _pair.UserData.AliasOrUID;
UiSharedService.FontText(FontAwesomeIcon.Circle.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.Circle);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userVFXText);
ImGui.NewLine();
@@ -205,7 +208,7 @@ public class DrawUserPair : DrawPairBase
{
if (entry.IsVisible)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Eye, "Target player"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Eye, "Target player"))
{
_mediator.Publish(new TargetPairMessage(entry));
ImGui.CloseCurrentPopup();
@@ -213,7 +216,7 @@ public class DrawUserPair : DrawPairBase
}
if (!entry.IsPaused)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.User, "Open Profile"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.User, "Open Profile"))
{
_displayHandler.OpenProfile(entry);
ImGui.CloseCurrentPopup();
@@ -222,7 +225,7 @@ public class DrawUserPair : DrawPairBase
}
if (entry.IsVisible)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Sync, "Reload last data"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Sync, "Reload last data"))
{
entry.ApplyLastReceivedData(forced: true);
ImGui.CloseCurrentPopup();
@@ -230,13 +233,13 @@ public class DrawUserPair : DrawPairBase
UiSharedService.AttachToolTip("This reapplies the last received character data to this character");
}
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PlayCircle, "Cycle pause state"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Cycle pause state"))
{
_ = _apiController.CyclePause(entry.UserData);
ImGui.CloseCurrentPopup();
}
var entryUID = entry.UserData.AliasOrUID;
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Folder, "Pair Groups"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Folder, "Pair Groups"))
{
_selectGroupForPairUi.Open(entry);
}
@@ -245,7 +248,7 @@ public class DrawUserPair : DrawPairBase
var isDisableSounds = entry.UserPair!.OwnPermissions.IsDisableSounds();
string disableSoundsText = isDisableSounds ? "Enable sound sync" : "Disable sound sync";
var disableSoundsIcon = isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute;
if (UiSharedService.NormalizedIconTextButton(disableSoundsIcon, disableSoundsText))
if (_uiSharedService.IconTextButton(disableSoundsIcon, disableSoundsText))
{
var permissions = entry.UserPair.OwnPermissions;
permissions.SetDisableSounds(!isDisableSounds);
@@ -255,7 +258,7 @@ public class DrawUserPair : DrawPairBase
var isDisableAnims = entry.UserPair!.OwnPermissions.IsDisableAnimations();
string disableAnimsText = isDisableAnims ? "Enable animation sync" : "Disable animation sync";
var disableAnimsIcon = isDisableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop;
if (UiSharedService.NormalizedIconTextButton(disableAnimsIcon, disableAnimsText))
if (_uiSharedService.IconTextButton(disableAnimsIcon, disableAnimsText))
{
var permissions = entry.UserPair.OwnPermissions;
permissions.SetDisableAnimations(!isDisableAnims);
@@ -265,14 +268,14 @@ public class DrawUserPair : DrawPairBase
var isDisableVFX = entry.UserPair!.OwnPermissions.IsDisableVFX();
string disableVFXText = isDisableVFX ? "Enable VFX sync" : "Disable VFX sync";
var disableVFXIcon = isDisableVFX ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle;
if (UiSharedService.NormalizedIconTextButton(disableVFXIcon, disableVFXText))
if (_uiSharedService.IconTextButton(disableVFXIcon, disableVFXText))
{
var permissions = entry.UserPair.OwnPermissions;
permissions.SetDisableVFX(!isDisableVFX);
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(entry.UserData, permissions));
}
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently") && UiSharedService.CtrlPressed())
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently") && UiSharedService.CtrlPressed())
{
_ = _apiController.UserRemovePair(new(entry.UserData));
}

View File

@@ -77,7 +77,7 @@ internal sealed class GroupPanel
private void DrawAddSyncshell()
{
var buttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Plus);
var buttonSize = _uiShared.GetIconButtonSize(FontAwesomeIcon.Plus);
ImGui.SetNextItemWidth(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X - buttonSize.X);
ImGui.InputTextWithHint("##syncshellid", "Syncshell GID/Alias (leave empty to create)", ref _syncShellToJoin, 20);
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X);
@@ -202,7 +202,7 @@ internal sealed class GroupPanel
}
var icon = isExpanded ? FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight;
UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont);
_uiShared.IconText(icon);
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{
_expandedGroupState[groupDto.GID] = !_expandedGroupState[groupDto.GID];
@@ -273,7 +273,7 @@ internal sealed class GroupPanel
}
else
{
var buttonSizes = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X + UiSharedService.GetIconButtonSize(FontAwesomeIcon.LockOpen).X;
var buttonSizes = _uiShared.GetIconButtonSize(FontAwesomeIcon.Bars).X + _uiShared.GetIconButtonSize(FontAwesomeIcon.LockOpen).X;
ImGui.SetNextItemWidth(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetCursorPosX() - buttonSizes - ImGui.GetStyle().ItemSpacing.X * 2);
if (ImGui.InputTextWithHint("", "Comment/Notes", ref _editGroupComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
{
@@ -302,7 +302,7 @@ internal sealed class GroupPanel
if (ImGui.BeginPopupModal("Manage Banlist for " + groupDto.GID, ref _showModalBanList, UiSharedService.PopupWindowFlags))
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
{
_bannedUsers = ApiController.GroupGetBannedUsers(groupDto).Result;
}
@@ -331,7 +331,7 @@ internal sealed class GroupPanel
ImGui.TableNextColumn();
UiSharedService.TextWrapped(bannedUser.Reason);
ImGui.TableNextColumn();
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Check, "Unban#" + bannedUser.UID))
if (_uiShared.IconTextButton(FontAwesomeIcon.Check, "Unban#" + bannedUser.UID))
{
_ = ApiController.GroupUnbanUser(bannedUser);
_bannedUsers.RemoveAll(b => string.Equals(b.UID, bannedUser.UID, StringComparison.Ordinal));
@@ -392,7 +392,7 @@ internal sealed class GroupPanel
{
ImGui.SetNextItemWidth(-1);
ImGui.SliderInt("Amount##bulkinvites", ref _bulkInviteCount, 1, 100);
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.MailBulk, "Create invites"))
if (_uiShared.IconTextButton(FontAwesomeIcon.MailBulk, "Create invites"))
{
_bulkOneTimeInvites = ApiController.GroupCreateTempInvite(groupDto, _bulkInviteCount).Result;
}
@@ -400,7 +400,7 @@ internal sealed class GroupPanel
else
{
UiSharedService.TextWrapped("A total of " + _bulkOneTimeInvites.Count + " invites have been created.");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Copy, "Copy invites to clipboard"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Copy, "Copy invites to clipboard"))
{
ImGui.SetClipboardText(string.Join(Environment.NewLine, _bulkOneTimeInvites));
}
@@ -431,7 +431,8 @@ internal sealed class GroupPanel
pair.GroupPair.Single(
g => GroupDataComparer.Instance.Equals(g.Key.Group, groupDto.Group)
).Value,
_uidDisplayHandler);
_uidDisplayHandler,
_uiShared);
if (pair.IsVisible)
visibleUsers.Add(drawPair);
@@ -491,19 +492,19 @@ internal sealed class GroupPanel
var userVFXIcon = userVFXDisabled ? FontAwesomeIcon.Circle : FontAwesomeIcon.Sun;
var iconSize = UiSharedService.GetIconSize(infoIcon);
var barbuttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
var barbuttonSize = _uiShared.GetIconButtonSize(FontAwesomeIcon.Bars);
var isOwner = string.Equals(groupDto.OwnerUID, ApiController.UID, StringComparison.Ordinal);
var spacingX = ImGui.GetStyle().ItemSpacing.X;
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
var pauseIcon = groupDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseIconSize = UiSharedService.GetIconButtonSize(pauseIcon);
var pauseIconSize = _uiShared.GetIconButtonSize(pauseIcon);
ImGui.SameLine(windowEndX - barbuttonSize.X - (showInfoIcon ? iconSize.X : 0) - (showInfoIcon ? spacingX : 0) - pauseIconSize.X - spacingX);
if (showInfoIcon)
{
UiSharedService.FontText(infoIcon.ToIconString(), UiBuilder.IconFont);
_uiShared.IconText(infoIcon);
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
@@ -514,7 +515,7 @@ internal sealed class GroupPanel
if (!invitesEnabled)
{
var lockedText = "Syncshell is closed for joining";
UiSharedService.FontText(lockedIcon.ToIconString(), UiBuilder.IconFont);
_uiShared.IconText(lockedIcon);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(lockedText);
}
@@ -522,7 +523,7 @@ internal sealed class GroupPanel
if (soundsDisabled)
{
var soundsText = "Sound sync disabled through owner";
UiSharedService.FontText(soundsIcon.ToIconString(), UiBuilder.IconFont);
_uiShared.IconText(soundsIcon);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(soundsText);
}
@@ -530,7 +531,7 @@ internal sealed class GroupPanel
if (animDisabled)
{
var animText = "Animation sync disabled through owner";
UiSharedService.FontText(animIcon.ToIconString(), UiBuilder.IconFont);
_uiShared.IconText(animIcon);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(animText);
}
@@ -538,7 +539,7 @@ internal sealed class GroupPanel
if (vfxDisabled)
{
var vfxText = "VFX sync disabled through owner";
UiSharedService.FontText(vfxIcon.ToIconString(), UiBuilder.IconFont);
_uiShared.IconText(vfxIcon);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(vfxText);
}
@@ -554,7 +555,7 @@ internal sealed class GroupPanel
if (userSoundsDisabled)
{
var userSoundsText = "Sound sync disabled through you";
UiSharedService.FontText(userSoundsIcon.ToIconString(), UiBuilder.IconFont);
_uiShared.IconText(userSoundsIcon);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userSoundsText);
}
@@ -562,7 +563,7 @@ internal sealed class GroupPanel
if (userAnimDisabled)
{
var userAnimText = "Animation sync disabled through you";
UiSharedService.FontText(userAnimIcon.ToIconString(), UiBuilder.IconFont);
_uiShared.IconText(userAnimIcon);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userAnimText);
}
@@ -570,7 +571,7 @@ internal sealed class GroupPanel
if (userVFXDisabled)
{
var userVFXText = "VFX sync disabled through you";
UiSharedService.FontText(userVFXIcon.ToIconString(), UiBuilder.IconFont);
_uiShared.IconText(userVFXIcon);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userVFXText);
}
@@ -598,21 +599,21 @@ internal sealed class GroupPanel
if (ImGui.BeginPopup("ShellPopup"))
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ArrowCircleLeft, "Leave Syncshell") && UiSharedService.CtrlPressed())
if (_uiShared.IconTextButton(FontAwesomeIcon.ArrowCircleLeft, "Leave Syncshell") && UiSharedService.CtrlPressed())
{
_ = ApiController.GroupLeave(groupDto);
}
UiSharedService.AttachToolTip("Hold CTRL and click to leave this Syncshell" + (!string.Equals(groupDto.OwnerUID, ApiController.UID, StringComparison.Ordinal) ? string.Empty : Environment.NewLine
+ "WARNING: This action is irreversible" + Environment.NewLine + "Leaving an owned Syncshell will transfer the ownership to a random person in the Syncshell."));
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Copy, "Copy ID"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Copy, "Copy ID"))
{
ImGui.CloseCurrentPopup();
ImGui.SetClipboardText(groupDto.GroupAliasOrGID);
}
UiSharedService.AttachToolTip("Copy Syncshell ID to Clipboard");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StickyNote, "Copy Notes"))
if (_uiShared.IconTextButton(FontAwesomeIcon.StickyNote, "Copy Notes"))
{
ImGui.CloseCurrentPopup();
ImGui.SetClipboardText(UiSharedService.GetNotes(groupPairs));
@@ -620,7 +621,7 @@ internal sealed class GroupPanel
UiSharedService.AttachToolTip("Copies all your notes for all users in this Syncshell to the clipboard." + Environment.NewLine + "They can be imported via Settings -> General -> Notes -> Import notes from clipboard");
var soundsText = userSoundsDisabled ? "Enable sound sync" : "Disable sound sync";
if (UiSharedService.NormalizedIconTextButton(userSoundsIcon, soundsText))
if (_uiShared.IconTextButton(userSoundsIcon, soundsText))
{
ImGui.CloseCurrentPopup();
var perm = groupDto.GroupUserPermissions;
@@ -633,7 +634,7 @@ internal sealed class GroupPanel
+ Environment.NewLine + "Note: this setting does not apply to individual pairs that are also in the syncshell.");
var animText = userAnimDisabled ? "Enable animations sync" : "Disable animations sync";
if (UiSharedService.NormalizedIconTextButton(userAnimIcon, animText))
if (_uiShared.IconTextButton(userAnimIcon, animText))
{
ImGui.CloseCurrentPopup();
var perm = groupDto.GroupUserPermissions;
@@ -647,7 +648,7 @@ internal sealed class GroupPanel
+ Environment.NewLine + "Note: this setting does not apply to individual pairs that are also in the syncshell.");
var vfxText = userVFXDisabled ? "Enable VFX sync" : "Disable VFX sync";
if (UiSharedService.NormalizedIconTextButton(userVFXIcon, vfxText))
if (_uiShared.IconTextButton(userVFXIcon, vfxText))
{
ImGui.CloseCurrentPopup();
var perm = groupDto.GroupUserPermissions;
@@ -663,7 +664,7 @@ internal sealed class GroupPanel
if (isOwner || groupDto.GroupUserInfo.IsModerator())
{
ImGui.Separator();
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Cog, "Open Admin Panel"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Cog, "Open Admin Panel"))
{
ImGui.CloseCurrentPopup();
_mainUi.Mediator.Publish(new OpenSyncshellAdminPanel(groupDto));

View File

@@ -17,14 +17,17 @@ public class PairGroupsUi
private readonly SelectPairForGroupUi _selectGroupForPairUi;
private readonly TagHandler _tagHandler;
private readonly UidDisplayHandler _uidDisplayHandler;
private readonly UiSharedService _uiSharedService;
public PairGroupsUi(MareConfigService mareConfig, TagHandler tagHandler, UidDisplayHandler uidDisplayHandler, ApiController apiController, SelectPairForGroupUi selectGroupForPairUi)
public PairGroupsUi(MareConfigService mareConfig, TagHandler tagHandler, UidDisplayHandler uidDisplayHandler, ApiController apiController,
SelectPairForGroupUi selectGroupForPairUi, UiSharedService uiSharedService)
{
_mareConfig = mareConfig;
_tagHandler = tagHandler;
_uidDisplayHandler = uidDisplayHandler;
_apiController = apiController;
_selectGroupForPairUi = selectGroupForPairUi;
_uiSharedService = uiSharedService;
}
public void Draw<T>(List<T> visibleUsers, List<T> onlineUsers, List<T> offlineUsers) where T : DrawPairBase
@@ -43,8 +46,8 @@ public class PairGroupsUi
{
var allArePaused = availablePairsInThisTag.All(pair => pair.UserPair!.OwnPermissions.IsPaused());
var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var flyoutMenuX = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X;
var pauseButtonX = UiSharedService.GetIconButtonSize(pauseButton).X;
var flyoutMenuX = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X;
var pauseButtonX = _uiSharedService.GetIconButtonSize(pauseButton).X;
var windowX = ImGui.GetWindowContentRegionMin().X;
var windowWidth = UiSharedService.GetWindowContentRegionWidth();
var spacingX = ImGui.GetStyle().ItemSpacing.X;
@@ -137,13 +140,13 @@ public class PairGroupsUi
private void DrawGroupMenu(string tag)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Users, "Add people to " + tag))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Users, "Add people to " + tag))
{
_selectGroupForPairUi.Open(tag);
}
UiSharedService.AttachToolTip($"Add more users to Group {tag}");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete " + tag) && UiSharedService.CtrlPressed())
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete " + tag) && UiSharedService.CtrlPressed())
{
_tagHandler.RemoveTag(tag);
}
@@ -165,13 +168,13 @@ public class PairGroupsUi
// FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight
var icon = _tagHandler.IsTagOpen(tag) ? FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight;
UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(icon);
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{
ToggleTagOpen(tag);
}
ImGui.SameLine();
UiSharedService.FontText(resultFolderName, UiBuilder.DefaultFont);
ImGui.TextUnformatted(resultFolderName);
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{
ToggleTagOpen(tag);

View File

@@ -11,13 +11,15 @@ namespace MareSynchronos.UI.Components.Popup;
public class BanUserPopupHandler : IPopupHandler
{
private readonly ApiController _apiController;
private readonly UiSharedService _uiSharedService;
private string _banReason = string.Empty;
private GroupFullInfoDto _group = null!;
private Pair _reportedPair = null!;
public BanUserPopupHandler(ApiController apiController)
public BanUserPopupHandler(ApiController apiController, UiSharedService uiSharedService)
{
_apiController = apiController;
_uiSharedService = uiSharedService;
}
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.");
ImGui.InputTextWithHint("##banreason", "Ban Reason", ref _banReason, 255);
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
{
ImGui.CloseCurrentPopup();
var reason = _banReason;

View File

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

View File

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

View File

@@ -13,6 +13,7 @@ public class SelectGroupForPairUi
{
private readonly TagHandler _tagHandler;
private readonly UidDisplayHandler _uidDisplayHandler;
private readonly UiSharedService _uiSharedService;
/// <summary>
/// The group UI is always open for a specific pair. This defines which pair the UI is open for.
@@ -30,12 +31,13 @@ public class SelectGroupForPairUi
/// </summary>
private string _tagNameToAdd = "";
public SelectGroupForPairUi(TagHandler tagHandler, UidDisplayHandler uidDisplayHandler)
public SelectGroupForPairUi(TagHandler tagHandler, UidDisplayHandler uidDisplayHandler, UiSharedService uiSharedService)
{
_show = false;
_pair = null;
_tagHandler = tagHandler;
_uidDisplayHandler = uidDisplayHandler;
_uiSharedService = uiSharedService;
}
public void Draw()
@@ -60,7 +62,7 @@ public class SelectGroupForPairUi
var childHeight = tags.Count != 0 ? tags.Count * 25 : 1;
var childSize = new Vector2(0, childHeight > 100 ? 100 : childHeight) * ImGuiHelpers.GlobalScale;
UiSharedService.FontText($"Select the groups you want {name} to be in.", UiBuilder.DefaultFont);
ImGui.TextUnformatted($"Select the groups you want {name} to be in.");
if (ImGui.BeginChild(name + "##listGroups", childSize))
{
foreach (var tag in tags)
@@ -71,8 +73,8 @@ public class SelectGroupForPairUi
}
ImGui.Separator();
UiSharedService.FontText($"Create a new group for {name}.", UiBuilder.DefaultFont);
if (UiSharedService.NormalizedIconButton(FontAwesomeIcon.Plus))
ImGui.TextUnformatted($"Create a new group for {name}.");
if (_uiSharedService.IconButton(FontAwesomeIcon.Plus))
{
HandleAddTag();
}

View File

@@ -1,9 +1,8 @@
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility;
using ImGuiNET;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.UI.Handlers;
using System.Numerics;
namespace MareSynchronos.UI.Components;
@@ -47,7 +46,8 @@ public class SelectPairForGroupUi
ImGui.SetNextWindowSizeConstraints(minSize, maxSize);
if (ImGui.BeginPopupModal(popupName, ref _show, ImGuiWindowFlags.Popup | ImGuiWindowFlags.Modal))
{
UiSharedService.FontText($"Select users for group {_tag}", UiBuilder.DefaultFont);
ImGui.TextUnformatted($"Select users for group {_tag}");
ImGui.InputTextWithHint("##filter", "Filter", ref _filter, 255, ImGuiInputTextFlags.None);
foreach (var item in pairs
.Where(p => string.IsNullOrEmpty(_filter) || PairName(p).Contains(_filter, StringComparison.OrdinalIgnoreCase))

View File

@@ -17,6 +17,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
private readonly CharacterAnalyzer _characterAnalyzer;
private readonly Progress<(string, int)> _conversionProgress = new();
private readonly IpcManager _ipcManager;
private readonly UiSharedService _uiSharedService;
private readonly Dictionary<string, string[]> _texturesToConvert = new(StringComparer.Ordinal);
private Dictionary<ObjectKind, Dictionary<string, CharacterAnalyzer.FileDataEntry>>? _cachedAnalysis;
private CancellationTokenSource _conversionCancellationTokenSource = new();
@@ -33,11 +34,13 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
public DataAnalysisUi(ILogger<DataAnalysisUi> logger, MareMediator mediator,
CharacterAnalyzer characterAnalyzer, IpcManager ipcManager,
PerformanceCollectorService performanceCollectorService)
PerformanceCollectorService performanceCollectorService,
UiSharedService uiSharedService)
: base(logger, mediator, "Character Data Analysis", performanceCollectorService)
{
_characterAnalyzer = characterAnalyzer;
_ipcManager = ipcManager;
_uiSharedService = uiSharedService;
Mediator.Subscribe<CharacterDataAnalyzedMessage>(this, (_) =>
{
_hasUpdate = true;
@@ -68,7 +71,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
{
ImGui.TextUnformatted("BC7 Conversion in progress: " + _conversionCurrentFileProgress + "/" + _texturesToConvert.Count);
UiSharedService.TextWrapped("Current file: " + _conversionCurrentFileName);
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StopCircle, "Cancel conversion"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.StopCircle, "Cancel conversion"))
{
_conversionCancellationTokenSource.Cancel();
}
@@ -111,7 +114,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
{
UiSharedService.ColorTextWrapped($"Analyzing {_characterAnalyzer.CurrentFile}/{_characterAnalyzer.TotalFiles}",
ImGuiColors.DalamudYellow);
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StopCircle, "Cancel analysis"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.StopCircle, "Cancel analysis"))
{
_characterAnalyzer.CancelAnalyze();
}
@@ -122,14 +125,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.NormalizedIconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (missing entries)"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (missing entries)"))
{
_ = _characterAnalyzer.ComputeAnalysis(print: false);
}
}
else
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (recalculate all entries)"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (recalculate all entries)"))
{
_ = _characterAnalyzer.ComputeAnalysis(print: false, recalculate: true);
}
@@ -292,7 +295,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.NormalizedIconTextButton(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();
_conversionTask = _ipcManager.Penumbra.ConvertTextureFiles(_logger, _texturesToConvert, _conversionProgress, _conversionCancellationTokenSource.Token);
@@ -325,7 +328,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
ImGui.SameLine();
ImGui.TextUnformatted($"(and {filePaths.Count - 1} more)");
ImGui.SameLine();
UiSharedService.FontText(FontAwesomeIcon.InfoCircle.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.InfoCircle);
UiSharedService.AttachToolTip(string.Join(Environment.NewLine, filePaths.Skip(1)));
}
@@ -338,7 +341,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
ImGui.SameLine();
ImGui.TextUnformatted($"(and {gamepaths.Count - 1} more)");
ImGui.SameLine();
UiSharedService.FontText(FontAwesomeIcon.InfoCircle.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.InfoCircle);
UiSharedService.AttachToolTip(string.Join(Environment.NewLine, gamepaths.Skip(1)));
}
}

View File

@@ -190,7 +190,7 @@ public class DownloadUi : WindowMediatorSubscriberBase
try
{
if (_configService.Current.ShowUploadingBigText) _uiShared.UidFont.Push();
using var _ = _uiShared.UidFont.Push();
var uploadText = "Uploading";
var textSize = ImGui.CalcTextSize(uploadText);
@@ -205,10 +205,6 @@ public class DownloadUi : WindowMediatorSubscriberBase
{
// ignore errors thrown on UI
}
finally
{
if (_configService.Current.ShowUploadingBigText) _uiShared.UidFont.Pop();
}
}
}
}

View File

@@ -95,27 +95,28 @@ public class EditProfileUi : WindowMediatorSubscriberBase
var spacing = ImGui.GetStyle().ItemSpacing.X;
ImGuiHelpers.ScaledRelativeSameLine(256, spacing);
_uiSharedService.GameFont.Push();
var descriptionTextSize = ImGui.CalcTextSize(profile.Description, 256f);
var childFrame = ImGuiHelpers.ScaledVector2(256 + ImGui.GetStyle().WindowPadding.X + ImGui.GetStyle().WindowBorderSize, 256);
if (descriptionTextSize.Y > childFrame.Y)
using (_uiSharedService.GameFont.Push())
{
_adjustedForScollBarsOnlineProfile = true;
var descriptionTextSize = ImGui.CalcTextSize(profile.Description, 256f);
var childFrame = ImGuiHelpers.ScaledVector2(256 + ImGui.GetStyle().WindowPadding.X + ImGui.GetStyle().WindowBorderSize, 256);
if (descriptionTextSize.Y > childFrame.Y)
{
_adjustedForScollBarsOnlineProfile = true;
}
else
{
_adjustedForScollBarsOnlineProfile = false;
}
childFrame = childFrame with
{
X = childFrame.X + (_adjustedForScollBarsOnlineProfile ? ImGui.GetStyle().ScrollbarSize : 0),
};
if (ImGui.BeginChildFrame(101, childFrame))
{
UiSharedService.TextWrapped(profile.Description);
}
ImGui.EndChildFrame();
}
else
{
_adjustedForScollBarsOnlineProfile = false;
}
childFrame = childFrame with
{
X = childFrame.X + (_adjustedForScollBarsOnlineProfile ? ImGui.GetStyle().ScrollbarSize : 0),
};
if (ImGui.BeginChildFrame(101, childFrame))
{
UiSharedService.TextWrapped(profile.Description);
}
ImGui.EndChildFrame();
_uiSharedService.GameFont.Pop();
var nsfw = profile.IsNSFW;
ImGui.BeginDisabled();
@@ -139,7 +140,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
ImGui.Separator();
_uiSharedService.BigText("Profile Settings");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FileUpload, "Upload new profile picture"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FileUpload, "Upload new profile picture"))
{
_fileDialogManager.OpenFileDialog("Select new Profile picture", ".png", (success, file) =>
{
@@ -170,7 +171,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
}
UiSharedService.AttachToolTip("Select and upload a new profile picture");
ImGui.SameLine();
if (UiSharedService.NormalizedIconTextButton(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));
}
@@ -184,7 +185,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
{
_ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, isNsfw, ProfilePictureBase64: null, Description: null));
}
UiSharedService.DrawHelpText("If your profile description or image can be considered NSFW, toggle this to ON");
_uiSharedService.DrawHelpText("If your profile description or image can be considered NSFW, toggle this to ON");
var widthTextBox = 400;
var posX = ImGui.GetCursorPosX();
ImGui.TextUnformatted($"Description {_descriptionText.Length}/1500");
@@ -196,35 +197,36 @@ public class EditProfileUi : WindowMediatorSubscriberBase
ImGui.SameLine();
_uiSharedService.GameFont.Push();
var descriptionTextSizeLocal = ImGui.CalcTextSize(_descriptionText, 256f);
var childFrameLocal = ImGuiHelpers.ScaledVector2(256 + ImGui.GetStyle().WindowPadding.X + ImGui.GetStyle().WindowBorderSize, 200);
if (descriptionTextSizeLocal.Y > childFrameLocal.Y)
using (_uiSharedService.GameFont.Push())
{
_adjustedForScollBarsLocalProfile = true;
var descriptionTextSizeLocal = ImGui.CalcTextSize(_descriptionText, 256f);
var childFrameLocal = ImGuiHelpers.ScaledVector2(256 + ImGui.GetStyle().WindowPadding.X + ImGui.GetStyle().WindowBorderSize, 200);
if (descriptionTextSizeLocal.Y > childFrameLocal.Y)
{
_adjustedForScollBarsLocalProfile = true;
}
else
{
_adjustedForScollBarsLocalProfile = false;
}
childFrameLocal = childFrameLocal with
{
X = childFrameLocal.X + (_adjustedForScollBarsLocalProfile ? ImGui.GetStyle().ScrollbarSize : 0),
};
if (ImGui.BeginChildFrame(102, childFrameLocal))
{
UiSharedService.TextWrapped(_descriptionText);
}
ImGui.EndChildFrame();
}
else
{
_adjustedForScollBarsLocalProfile = false;
}
childFrameLocal = childFrameLocal with
{
X = childFrameLocal.X + (_adjustedForScollBarsLocalProfile ? ImGui.GetStyle().ScrollbarSize : 0),
};
if (ImGui.BeginChildFrame(102, childFrameLocal))
{
UiSharedService.TextWrapped(_descriptionText);
}
ImGui.EndChildFrame();
_uiSharedService.GameFont.Pop();
if (UiSharedService.NormalizedIconTextButton(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));
}
UiSharedService.AttachToolTip("Sets your profile description text");
ImGui.SameLine();
if (UiSharedService.NormalizedIconTextButton(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, ""));
}

View File

@@ -41,7 +41,8 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
public EventViewerUI(ILogger<EventViewerUI> logger, MareMediator mediator,
EventAggregator eventAggregator, UiSharedService uiSharedService, MareConfigService configService,
PerformanceCollectorService performanceCollectorService) : base(logger, mediator, "Event Viewer", performanceCollectorService)
PerformanceCollectorService performanceCollectorService)
: base(logger, mediator, "Event Viewer", performanceCollectorService)
{
_eventAggregator = eventAggregator;
_uiSharedService = uiSharedService;
@@ -82,12 +83,12 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
{
var newEventsAvailable = _eventAggregator.NewEventsAvailable;
var freezeSize = UiSharedService.GetNormalizedIconTextButtonSize(FontAwesomeIcon.PlayCircle, "Unfreeze View").X;
var freezeSize = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.PlayCircle, "Unfreeze View");
if (_isPaused)
{
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow, newEventsAvailable))
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PlayCircle, "Unfreeze View"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Unfreeze View"))
_isPaused = false;
if (newEventsAvailable)
UiSharedService.AttachToolTip("New events are available. Click to resume updating.");
@@ -95,7 +96,7 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
}
else
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PauseCircle, "Freeze View"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PauseCircle, "Freeze View"))
_isPaused = true;
}
@@ -121,10 +122,10 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
if (_configService.Current.LogEvents)
{
var buttonSize = UiSharedService.GetNormalizedIconTextButtonSize(FontAwesomeIcon.FolderOpen, "Open EventLog Folder");
var dist = ImGui.GetWindowContentRegionMax().X - buttonSize.X;
var buttonSize = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.FolderOpen, "Open EventLog Folder");
var dist = ImGui.GetWindowContentRegionMax().X - buttonSize;
ImGui.SameLine(dist);
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FolderOpen, "Open EventLog folder"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FolderOpen, "Open EventLog folder"))
{
ProcessStartInfo ps = new()
{
@@ -181,7 +182,7 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
};
ImGui.TableNextColumn();
UiSharedService.NormalizedIcon(icon, iconColor == new Vector4() ? null : iconColor);
_uiSharedService.IconText(icon, iconColor == new Vector4() ? null : iconColor);
UiSharedService.AttachToolTip(ev.EventSeverity.ToString());
ImGui.TableNextColumn();
ImGui.AlignTextToFramePadding();

View File

@@ -12,6 +12,7 @@ namespace MareSynchronos.UI;
public class GposeUi : WindowMediatorSubscriberBase
{
private readonly MareConfigService _configService;
private readonly UiSharedService _uiSharedService;
private readonly DalamudUtilService _dalamudUtil;
private readonly FileDialogManager _fileDialogManager;
private readonly MareCharaFileManager _mareCharaFileManager;
@@ -20,13 +21,14 @@ public class GposeUi : WindowMediatorSubscriberBase
public GposeUi(ILogger<GposeUi> logger, MareCharaFileManager mareCharaFileManager,
DalamudUtilService dalamudUtil, FileDialogManager fileDialogManager, MareConfigService configService,
MareMediator mediator, PerformanceCollectorService performanceCollectorService)
MareMediator mediator, PerformanceCollectorService performanceCollectorService, UiSharedService uiSharedService)
: base(logger, mediator, "Loporrit Gpose Import UI###LoporritSyncGposeUI", performanceCollectorService)
{
_mareCharaFileManager = mareCharaFileManager;
_dalamudUtil = dalamudUtil;
_fileDialogManager = fileDialogManager;
_configService = configService;
_uiSharedService = uiSharedService;
Mediator.Subscribe<GposeStartMessage>(this, (_) => StartGpose());
Mediator.Subscribe<GposeEndMessage>(this, (_) => EndGpose());
IsOpen = _dalamudUtil.IsInGpose;
@@ -43,7 +45,7 @@ public class GposeUi : WindowMediatorSubscriberBase
if (!_mareCharaFileManager.CurrentlyWorking)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FolderOpen, "Load MCDF"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FolderOpen, "Load MCDF"))
{
_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("File Description: " + _mareCharaFileManager.LoadedCharaFile.CharaFileData.Description);
if (UiSharedService.NormalizedIconTextButton(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));
}

View File

@@ -108,10 +108,12 @@ public partial class IntroUi : WindowMediatorSubscriberBase
}
else if (!_configService.Current.AcceptedAgreement && _readFirstPage)
{
_uiShared.UidFont.Push();
var textSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
ImGui.TextUnformatted(Strings.ToS.AgreementLabel);
_uiShared.UidFont.Pop();
Vector2 textSize;
using (_uiShared.UidFont.Push())
{
textSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
ImGui.TextUnformatted(Strings.ToS.AgreementLabel);
}
ImGui.SameLine();
var languageSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
@@ -162,9 +164,9 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|| !_configService.Current.InitialScanComplete
|| !Directory.Exists(_configService.Current.CacheFolder)))
{
_uiShared.UidFont.Push();
ImGui.TextUnformatted("File Storage Setup");
_uiShared.UidFont.Pop();
using (_uiShared.UidFont.Push())
ImGui.TextUnformatted("File Storage Setup");
ImGui.Separator();
if (!_uiShared.HasValidPenumbraModPath)
@@ -208,9 +210,8 @@ public partial class IntroUi : WindowMediatorSubscriberBase
}
else if (!_uiShared.ApiController.ServerAlive)
{
_uiShared.UidFont.Push();
ImGui.TextUnformatted("Service Registration");
_uiShared.UidFont.Pop();
using (_uiShared.UidFont.Push())
ImGui.TextUnformatted("Service Registration");
ImGui.Separator();
UiSharedService.TextWrapped("To be able to use Loporrit you will have to register an account.");
UiSharedService.TextWrapped("Refer to the instructions at the location you obtained this plugin for more information or support.");
@@ -266,7 +267,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
ImGui.BeginDisabled(_registrationInProgress || _registrationSuccess || _secretKey.Length > 0);
ImGui.Separator();
ImGui.TextUnformatted("If you do not have a secret key already click below to register a new account.");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Register a new Loporrit account"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Plus, "Register a new Loporrit account"))
{
_registrationInProgress = true;
_ = Task.Run(async () => {

View File

@@ -53,7 +53,7 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
{
_ownPermissions.SetPaused(paused);
}
UiSharedService.DrawHelpText("Pausing will completely cease any sync with this user." + UiSharedService.TooltipSeparator
_uiSharedService.DrawHelpText("Pausing will completely cease any sync with this user." + UiSharedService.TooltipSeparator
+ "Note: this is bidirectional, either user pausing will cease sync completely.");
var otherPerms = Pair.UserPair.OtherPermissions;
@@ -64,7 +64,7 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
using (ImRaii.PushIndent(indentSize, false))
{
UiSharedService.BooleanToColoredIcon(!otherIsPaused, false);
_uiSharedService.BooleanToColoredIcon(!otherIsPaused, false);
ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.Text(Pair.UserData.AliasOrUID + " has " + (!otherIsPaused ? "not " : string.Empty) + "paused you");
@@ -78,11 +78,11 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
{
_ownPermissions.SetDisableSounds(disableSounds);
}
UiSharedService.DrawHelpText("Disabling sounds will remove all sounds synced with this user on both sides." + UiSharedService.TooltipSeparator
_uiSharedService.DrawHelpText("Disabling sounds will remove all sounds synced with this user on both sides." + UiSharedService.TooltipSeparator
+ "Note: this is bidirectional, either user disabling sound sync will stop sound sync on both sides.");
using (ImRaii.PushIndent(indentSize, false))
{
UiSharedService.BooleanToColoredIcon(!otherDisableSounds, false);
_uiSharedService.BooleanToColoredIcon(!otherDisableSounds, false);
ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.Text(Pair.UserData.AliasOrUID + " has " + (!otherDisableSounds ? "not " : string.Empty) + "disabled sound sync with you");
@@ -92,11 +92,11 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
{
_ownPermissions.SetDisableAnimations(disableAnimations);
}
UiSharedService.DrawHelpText("Disabling sounds will remove all animations synced with this user on both sides." + UiSharedService.TooltipSeparator
_uiSharedService.DrawHelpText("Disabling sounds will remove all animations synced with this user on both sides." + UiSharedService.TooltipSeparator
+ "Note: this is bidirectional, either user disabling animation sync will stop animation sync on both sides.");
using (ImRaii.PushIndent(indentSize, false))
{
UiSharedService.BooleanToColoredIcon(!otherDisableAnimations, false);
_uiSharedService.BooleanToColoredIcon(!otherDisableAnimations, false);
ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.Text(Pair.UserData.AliasOrUID + " has " + (!otherDisableAnimations ? "not " : string.Empty) + "disabled animation sync with you");
@@ -106,11 +106,11 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
{
_ownPermissions.SetDisableVFX(disableVfx);
}
UiSharedService.DrawHelpText("Disabling sounds will remove all VFX synced with this user on both sides." + UiSharedService.TooltipSeparator
_uiSharedService.DrawHelpText("Disabling sounds will remove all VFX synced with this user on both sides." + UiSharedService.TooltipSeparator
+ "Note: this is bidirectional, either user disabling VFX sync will stop VFX sync on both sides.");
using (ImRaii.PushIndent(indentSize, false))
{
UiSharedService.BooleanToColoredIcon(!otherDisableVFX, false);
_uiSharedService.BooleanToColoredIcon(!otherDisableVFX, false);
ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.Text(Pair.UserData.AliasOrUID + " has " + (!otherDisableVFX ? "not " : string.Empty) + "disabled VFX sync with you");
@@ -123,27 +123,27 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
bool hasChanges = _ownPermissions != Pair.UserPair.OwnPermissions;
using (ImRaii.Disabled(!hasChanges))
if (UiSharedService.NormalizedIconTextButton(Dalamud.Interface.FontAwesomeIcon.Save, "Save"))
if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Save, "Save"))
{
_ = _apiController.UserSetPairPermissions(new(Pair.UserData, _ownPermissions));
}
UiSharedService.AttachToolTip("Save and apply all changes");
var rightSideButtons = UiSharedService.GetNormalizedIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.Undo, "Revert").X +
UiSharedService.GetNormalizedIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, "Reset to Default").X;
var rightSideButtons = _uiSharedService.GetIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.Undo, "Revert") +
_uiSharedService.GetIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, "Reset to Default");
var availableWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X;
ImGui.SameLine(availableWidth - rightSideButtons);
using (ImRaii.Disabled(!hasChanges))
if (UiSharedService.NormalizedIconTextButton(Dalamud.Interface.FontAwesomeIcon.Undo, "Revert"))
if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Undo, "Revert"))
{
_ownPermissions = Pair.UserPair.OwnPermissions.DeepClone();
}
UiSharedService.AttachToolTip("Revert all changes");
ImGui.SameLine();
if (UiSharedService.NormalizedIconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, "Reset to Default"))
if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, "Reset to Default"))
{
_ownPermissions.SetPaused(false);
_ownPermissions.SetDisableVFX(false);

View File

@@ -1,7 +1,6 @@
using Dalamud.Interface.Colors;
using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.MareConfiguration;

View File

@@ -173,7 +173,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
private void DrawCurrentTransfers()
{
_lastTab = "Transfers";
UiSharedService.FontText("Transfer Settings", _uiShared.UidFont);
_uiShared.BigText("Transfer Settings");
int maxParallelDownloads = _configService.Current.ParallelDownloads;
bool useAlternativeUpload = _configService.Current.UseAlternativeFileUpload;
@@ -220,10 +220,10 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.UseAlternativeFileUpload = useAlternativeUpload;
_configService.Save();
}
UiSharedService.DrawHelpText("This will attempt to upload files in one go instead of a stream. Typically not necessary to enable. Use if you have upload issues.");
_uiShared.DrawHelpText("This will attempt to upload files in one go instead of a stream. Typically not necessary to enable. Use if you have upload issues.");
ImGui.Separator();
UiSharedService.FontText("Transfer UI", _uiShared.UidFont);
_uiShared.BigText("Transfer UI");
bool showTransferWindow = _configService.Current.ShowTransferWindow;
if (ImGui.Checkbox("Show separate transfer window", ref showTransferWindow))
@@ -231,7 +231,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.ShowTransferWindow = showTransferWindow;
_configService.Save();
}
UiSharedService.DrawHelpText($"The download window will show the current progress of outstanding downloads.{Environment.NewLine}{Environment.NewLine}" +
_uiShared.DrawHelpText($"The download window will show the current progress of outstanding downloads.{Environment.NewLine}{Environment.NewLine}" +
$"What do W/Q/P/D stand for?{Environment.NewLine}W = Waiting for Slot (see Maximum Parallel Downloads){Environment.NewLine}" +
$"Q = Queued on Server, waiting for queue ready signal{Environment.NewLine}" +
$"P = Processing download (aka downloading){Environment.NewLine}" +
@@ -252,7 +252,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.ShowTransferBars = showTransferBars;
_configService.Save();
}
UiSharedService.DrawHelpText("This will render a progress bar during the download at the feet of the player you are downloading from.");
_uiShared.DrawHelpText("This will render a progress bar during the download at the feet of the player you are downloading from.");
if (!showTransferBars) ImGui.BeginDisabled();
ImGui.Indent();
@@ -262,7 +262,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.TransferBarsShowText = transferBarShowText;
_configService.Save();
}
UiSharedService.DrawHelpText("Shows download text (amount of MiB downloaded) in the transfer bars");
_uiShared.DrawHelpText("Shows download text (amount of MiB downloaded) in the transfer bars");
int transferBarWidth = _configService.Current.TransferBarsWidth;
ImGui.SetNextItemWidth(250 * ImGuiHelpers.GlobalScale);
if (ImGui.SliderInt("Transfer Bar Width", ref transferBarWidth, 0, 500))
@@ -272,7 +272,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.TransferBarsWidth = transferBarWidth;
_configService.Save();
}
UiSharedService.DrawHelpText("Width of the displayed transfer bars (will never be less wide than the displayed text)");
_uiShared.DrawHelpText("Width of the displayed transfer bars (will never be less wide than the displayed text)");
int transferBarHeight = _configService.Current.TransferBarsHeight;
ImGui.SetNextItemWidth(250 * ImGuiHelpers.GlobalScale);
if (ImGui.SliderInt("Transfer Bar Height", ref transferBarHeight, 0, 50))
@@ -282,14 +282,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.TransferBarsHeight = transferBarHeight;
_configService.Save();
}
UiSharedService.DrawHelpText("Height of the displayed transfer bars (will never be less tall than the displayed text)");
_uiShared.DrawHelpText("Height of the displayed transfer bars (will never be less tall than the displayed text)");
bool showUploading = _configService.Current.ShowUploading;
if (ImGui.Checkbox("Show 'Uploading' text below players that are currently uploading", ref showUploading))
{
_configService.Current.ShowUploading = showUploading;
_configService.Save();
}
UiSharedService.DrawHelpText("This will render an 'Uploading' text at the feet of the player that is in progress of uploading data.");
_uiShared.DrawHelpText("This will render an 'Uploading' text at the feet of the player that is in progress of uploading data.");
ImGui.Unindent();
if (!showUploading) ImGui.BeginDisabled();
@@ -300,7 +300,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.ShowUploadingBigText = showUploadingBigText;
_configService.Save();
}
UiSharedService.DrawHelpText("This will render an 'Uploading' text in a larger font.");
_uiShared.DrawHelpText("This will render an 'Uploading' text in a larger font.");
ImGui.Unindent();
@@ -308,7 +308,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (!showTransferBars) ImGui.EndDisabled();
ImGui.Separator();
UiSharedService.FontText("Current Transfers", _uiShared.UidFont);
_uiShared.BigText("Current Transfers");
if (ImGui.BeginTabBar("TransfersTabBar"))
{
@@ -400,7 +400,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
{
_lastTab = "Chat";
UiSharedService.FontText("Chat Settings", _uiShared.UidFont);
_uiShared.BigText("Chat Settings");
var disableSyncshellChat = _configService.Current.DisableSyncshellChat;
@@ -409,7 +409,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.DisableSyncshellChat = disableSyncshellChat;
_configService.Save();
}
UiSharedService.DrawHelpText("Global setting to disable chat for all syncshells.");
_uiShared.DrawHelpText("Global setting to disable chat for all syncshells.");
using var pushDisableGlobal = ImRaii.Disabled(disableSyncshellChat);
@@ -450,10 +450,10 @@ public class SettingsUi : WindowMediatorSubscriberBase
_chatService.PrintChannelExample($"Selected channel: {_syncshellChatTypes[i].Item2}");
_configService.Save();
}, globalChatTypeIdx);
UiSharedService.DrawHelpText("FFXIV chat channel to output chat messages on.");
_uiShared.DrawHelpText("FFXIV chat channel to output chat messages on.");
ImGui.SetWindowFontScale(0.6f);
UiSharedService.FontText("\"Chat 2\" Plugin Integration", _uiShared.UidFont);
_uiShared.BigText("\"Chat 2\" Plugin Integration");
ImGui.SetWindowFontScale(1.0f);
// TODO: ExtraChat API impersonation
@@ -478,11 +478,11 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.ExtraChatAPI = false;
_configService.Save();
}
UiSharedService.DrawHelpText("If enabled, messages will be filtered under the category \"ExtraChat channels: All\".\n\nThis works even if ExtraChat is also installed and enabled.");
_uiShared.DrawHelpText("If enabled, messages will be filtered under the category \"ExtraChat channels: All\".\n\nThis works even if ExtraChat is also installed and enabled.");
ImGui.Separator();
UiSharedService.FontText("Syncshell Settings", _uiShared.UidFont);
_uiShared.BigText("Syncshell Settings");
if (!ApiController.ServerAlive)
{
@@ -504,7 +504,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
shellName = $"[{shellNumber}] {shellName}";
ImGui.SetWindowFontScale(0.6f);
UiSharedService.FontText(shellName, _uiShared.UidFont);
_uiShared.BigText(shellName);
ImGui.SetWindowFontScale(1.0f);
using var pushIndent = ImRaii.PushIndent();
@@ -607,7 +607,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
shellConfig.LogKind = (int)_syncshellChatTypes[i].Item1;
_serverConfigurationManager.SaveShellConfigForGid(gid, shellConfig);
}, shellChatTypeIdx);
UiSharedService.DrawHelpText("Override the FFXIV chat channel used for this syncshell.");
_uiShared.DrawHelpText("Override the FFXIV chat channel used for this syncshell.");
}
}
@@ -615,7 +615,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
{
_lastTab = "Debug";
UiSharedService.FontText("Debug", _uiShared.UidFont);
_uiShared.BigText("Debug");
#if DEBUG
if (LastCreatedCharacterData != null && ImGui.TreeNode("Last created character data"))
{
@@ -627,7 +627,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.TreePop();
}
#endif
if (UiSharedService.NormalizedIconTextButton(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)
{
@@ -652,16 +652,16 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.LogPerformance = logPerformance;
_configService.Save();
}
UiSharedService.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 (ImRaii.Disabled(!logPerformance))
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StickyNote, "Print Performance Stats to /xllog"))
if (_uiShared.IconTextButton(FontAwesomeIcon.StickyNote, "Print Performance Stats to /xllog"))
{
_performanceCollector.PrintPerformanceStats();
}
ImGui.SameLine();
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StickyNote, "Print Performance Stats (last 60s) to /xllog"))
if (_uiShared.IconTextButton(FontAwesomeIcon.StickyNote, "Print Performance Stats (last 60s) to /xllog"))
{
_performanceCollector.PrintPerformanceStats(60);
}
@@ -679,7 +679,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
{
_lastTab = "FileCache";
UiSharedService.FontText("Export MCDF", _uiShared.UidFont);
_uiShared.BigText("Export MCDF");
UiSharedService.TextWrapped("This feature allows you to pack your character appearance into a MCDF file and manually send it to other people. MCDF files can imported during GPose.");
@@ -694,7 +694,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.NormalizedIconTextButton(FontAwesomeIcon.Save, "Export Character as MCDF"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Save, "Export Character as MCDF"))
{
string defaultFileName = string.IsNullOrEmpty(_exportDescription)
? "export.mcdf"
@@ -735,11 +735,11 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.OpenGposeImportOnGposeStart = openInGpose;
_configService.Save();
}
UiSharedService.DrawHelpText("This will automatically open the import menu when loading into Gpose. If unchecked you can open the menu manually with /sync gpose");
_uiShared.DrawHelpText("This will automatically open the import menu when loading into Gpose. If unchecked you can open the menu manually with /sync gpose");
ImGui.Separator();
UiSharedService.FontText("Storage", _uiShared.UidFont);
_uiShared.BigText("Storage");
UiSharedService.TextWrapped("Loporrit stores downloaded files from paired people permanently. This is to improve loading performance and requiring less downloads. " +
"The storage governs itself by clearing data beyond the set storage size. Please set the storage size accordingly. It is not necessary to manually clear the storage.");
@@ -751,7 +751,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
{
ImGui.SameLine();
using var id = ImRaii.PushId("penumbraMonitor");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ArrowsToCircle, "Try to reinitialize Monitor"))
if (_uiShared.IconTextButton(FontAwesomeIcon.ArrowsToCircle, "Try to reinitialize Monitor"))
{
_cacheMonitor.StartPenumbraWatcher(_ipcManager.Penumbra.ModDirectory);
}
@@ -763,14 +763,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
{
ImGui.SameLine();
using var id = ImRaii.PushId("mareMonitor");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ArrowsToCircle, "Try to reinitialize Monitor"))
if (_uiShared.IconTextButton(FontAwesomeIcon.ArrowsToCircle, "Try to reinitialize Monitor"))
{
_cacheMonitor.StartMareWatcher(_configService.Current.CacheFolder);
}
}
if (_cacheMonitor.MareWatcher == null || _cacheMonitor.PenumbraWatcher == null)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Play, "Resume Monitoring"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Play, "Resume Monitoring"))
{
_cacheMonitor.StartMareWatcher(_configService.Current.CacheFolder);
_cacheMonitor.StartPenumbraWatcher(_ipcManager.Penumbra.ModDirectory);
@@ -784,7 +784,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
{
using (ImRaii.Disabled(!UiSharedService.CtrlPressed()))
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Stop, "Stop Monitoring"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Stop, "Stop Monitoring"))
{
_cacheMonitor.StopMonitoring();
}
@@ -815,12 +815,12 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.UseCompactor = useFileCompactor;
_configService.Save();
}
UiSharedService.DrawHelpText("The file compactor can massively reduce your saved files. It might incur a minor penalty on loading files on a slow CPU." + Environment.NewLine
_uiShared.DrawHelpText("The file compactor can massively reduce your saved files. It might incur a minor penalty on loading files on a slow CPU." + Environment.NewLine
+ "It is recommended to leave it enabled to save on space.");
if (!_fileCompactor.MassCompactRunning)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FileArchive, "Compact all files in storage"))
if (_uiShared.IconTextButton(FontAwesomeIcon.FileArchive, "Compact all files in storage"))
{
_ = Task.Run(() =>
{
@@ -831,12 +831,11 @@ public class SettingsUi : WindowMediatorSubscriberBase
UiSharedService.AttachToolTip("This will run compression on all files in your current storage folder." + Environment.NewLine
+ "You do not need to run this manually if you keep the file compactor enabled.");
ImGui.SameLine();
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.File, "Decompact all files in storage"))
if (_uiShared.IconTextButton(FontAwesomeIcon.File, "Decompact all files in storage"))
{
_ = Task.Run(() =>
{
_fileCompactor.CompactStorage(compress: false);
CancellationTokenSource cts = new();
_cacheMonitor.RecalculateFileCacheSize(CancellationToken.None);
});
}
@@ -859,7 +858,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.");
using (ImRaii.Disabled(_validationTask != null && !_validationTask.IsCompleted))
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Check, "Start File Storage Validation"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Check, "Start File Storage Validation"))
{
_validationCts?.Cancel();
_validationCts?.Dispose();
@@ -871,7 +870,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (_validationTask != null && !_validationTask.IsCompleted)
{
ImGui.SameLine();
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Times, "Cancel"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Times, "Cancel"))
{
_validationCts?.Cancel();
}
@@ -905,7 +904,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.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Clear local storage") && UiSharedService.CtrlPressed() && _readClearCache)
if (_uiShared.IconTextButton(FontAwesomeIcon.Trash, "Clear local storage") && UiSharedService.CtrlPressed() && _readClearCache)
{
_ = Task.Run(() =>
{
@@ -935,12 +934,12 @@ public class SettingsUi : WindowMediatorSubscriberBase
//UiSharedService.FontText("Experimental", _uiShared.UidFont);
//ImGui.Separator();
UiSharedService.FontText("Notes", _uiShared.UidFont);
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StickyNote, "Export all your user notes to clipboard"))
_uiShared.BigText("Notes");
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()));
}
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.FileImport, "Import notes from clipboard"))
if (_uiShared.IconTextButton(FontAwesomeIcon.FileImport, "Import notes from clipboard"))
{
_notesSuccessfullyApplied = null;
var notes = ImGui.GetClipboardText();
@@ -949,7 +948,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.SameLine();
ImGui.Checkbox("Overwrite existing notes", ref _overwriteExistingLabels);
UiSharedService.DrawHelpText("If this option is selected all already existing notes for UIDs will be overwritten by the imported notes.");
_uiShared.DrawHelpText("If this option is selected all already existing notes for UIDs will be overwritten by the imported notes.");
if (_notesSuccessfullyApplied.HasValue && _notesSuccessfullyApplied.Value)
{
UiSharedService.ColorTextWrapped("User Notes successfully imported", ImGuiColors.HealerGreen);
@@ -966,10 +965,10 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.OpenPopupOnAdd = openPopupOnAddition;
_configService.Save();
}
UiSharedService.DrawHelpText("This will open a popup that allows you to set the notes for a user after successfully adding them to your individual pairs.");
_uiShared.DrawHelpText("This will open a popup that allows you to set the notes for a user after successfully adding them to your individual pairs.");
ImGui.Separator();
UiSharedService.FontText("UI", _uiShared.UidFont);
_uiShared.BigText("UI");
var showCharacterNames = _configService.Current.ShowCharacterNames;
var showVisibleSeparate = _configService.Current.ShowVisibleUsersSeparately;
var showOfflineSeparate = _configService.Current.ShowOfflineUsersSeparately;
@@ -991,14 +990,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.EnableRightClickMenus = enableRightClickMenu;
_configService.Save();
}
UiSharedService.DrawHelpText("This will add Loporrit related right click menu entries in the game UI on paired players.");
_uiShared.DrawHelpText("This will add Loporrit related right click menu entries in the game UI on paired players.");
if (ImGui.Checkbox("Display status and visible pair count in Server Info Bar", ref enableDtrEntry))
{
_configService.Current.EnableDtrEntry = enableDtrEntry;
_configService.Save();
}
UiSharedService.DrawHelpText("This will add Loporrit connection status and visible pair count in the Server Info Bar.\nYou can further configure this through your Dalamud Settings.");
_uiShared.DrawHelpText("This will add Loporrit connection status and visible pair count in the Server Info Bar.\nYou can further configure this through your Dalamud Settings.");
using (ImRaii.Disabled(!enableDtrEntry))
{
@@ -1079,21 +1078,21 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.ShowVisibleUsersSeparately = showVisibleSeparate;
_configService.Save();
}
UiSharedService.DrawHelpText("This will show all currently visible users in a special 'Visible' group in the main UI.");
_uiShared.DrawHelpText("This will show all currently visible users in a special 'Visible' group in the main UI.");
if (ImGui.Checkbox("Show separate Offline group", ref showOfflineSeparate))
{
_configService.Current.ShowOfflineUsersSeparately = showOfflineSeparate;
_configService.Save();
}
UiSharedService.DrawHelpText("This will show all currently offline users in a special 'Offline' group in the main UI.");
_uiShared.DrawHelpText("This will show all currently offline users in a special 'Offline' group in the main UI.");
if (ImGui.Checkbox("Show player names", ref showCharacterNames))
{
_configService.Current.ShowCharacterNames = showCharacterNames;
_configService.Save();
}
UiSharedService.DrawHelpText("This will show character names instead of UIDs when possible");
_uiShared.DrawHelpText("This will show character names instead of UIDs when possible");
if (ImGui.Checkbox("Show Profiles on Hover", ref showProfiles))
{
@@ -1101,7 +1100,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.ProfilesShow = showProfiles;
_configService.Save();
}
UiSharedService.DrawHelpText("This will show the configured user profile after a set delay");
_uiShared.DrawHelpText("This will show the configured user profile after a set delay");
ImGui.Indent();
if (!showProfiles) ImGui.BeginDisabled();
if (ImGui.Checkbox("Popout profiles on the right", ref profileOnRight))
@@ -1110,14 +1109,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Save();
Mediator.Publish(new CompactUiChange(Vector2.Zero, Vector2.Zero));
}
UiSharedService.DrawHelpText("Will show profiles on the right side of the main UI");
_uiShared.DrawHelpText("Will show profiles on the right side of the main UI");
ImGui.SetNextItemWidth(250 * ImGuiHelpers.GlobalScale);
if (ImGui.SliderFloat("Hover Delay", ref profileDelay, 1, 10))
{
_configService.Current.ProfileDelay = profileDelay;
_configService.Save();
}
UiSharedService.DrawHelpText("Delay until the profile should be displayed");
_uiShared.DrawHelpText("Delay until the profile should be displayed");
if (!showProfiles) ImGui.EndDisabled();
ImGui.Unindent();
if (ImGui.Checkbox("Show profiles marked as NSFW", ref showNsfwProfiles))
@@ -1126,7 +1125,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.ProfilesAllowNsfw = showNsfwProfiles;
_configService.Save();
}
UiSharedService.DrawHelpText("Will show profiles that have the NSFW tag enabled");
_uiShared.DrawHelpText("Will show profiles that have the NSFW tag enabled");
ImGui.Separator();
@@ -1134,7 +1133,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
var onlineNotifs = _configService.Current.ShowOnlineNotifications;
var onlineNotifsPairsOnly = _configService.Current.ShowOnlineNotificationsOnlyForIndividualPairs;
var onlineNotifsNamedOnly = _configService.Current.ShowOnlineNotificationsOnlyForNamedPairs;
UiSharedService.FontText("Notifications", _uiShared.UidFont);
_uiShared.BigText("Notifications");
ImGui.SetNextItemWidth(250 * ImGuiHelpers.GlobalScale);
_uiShared.DrawCombo("Info Notification Display##settingsUi", (NotificationLocation[])Enum.GetValues(typeof(NotificationLocation)), (i) => i.ToString(),
@@ -1143,7 +1142,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.InfoNotification = i;
_configService.Save();
}, _configService.Current.InfoNotification);
UiSharedService.DrawHelpText("The location where \"Info\" notifications will display."
_uiShared.DrawHelpText("The location where \"Info\" notifications will display."
+ Environment.NewLine + "'Nowhere' will not show any Info notifications"
+ Environment.NewLine + "'Chat' will print Info notifications in chat"
+ Environment.NewLine + "'Toast' will show Warning toast notifications in the bottom right corner"
@@ -1156,7 +1155,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.WarningNotification = i;
_configService.Save();
}, _configService.Current.WarningNotification);
UiSharedService.DrawHelpText("The location where \"Warning\" notifications will display."
_uiShared.DrawHelpText("The location where \"Warning\" notifications will display."
+ Environment.NewLine + "'Nowhere' will not show any Warning notifications"
+ Environment.NewLine + "'Chat' will print Warning notifications in chat"
+ Environment.NewLine + "'Toast' will show Warning toast notifications in the bottom right corner"
@@ -1169,7 +1168,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.ErrorNotification = i;
_configService.Save();
}, _configService.Current.ErrorNotification);
UiSharedService.DrawHelpText("The location where \"Error\" notifications will display."
_uiShared.DrawHelpText("The location where \"Error\" notifications will display."
+ Environment.NewLine + "'Nowhere' will not show any Error notifications"
+ Environment.NewLine + "'Chat' will print Error notifications in chat"
+ Environment.NewLine + "'Toast' will show Error toast notifications in the bottom right corner"
@@ -1180,13 +1179,13 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.DisableOptionalPluginWarnings = disableOptionalPluginWarnings;
_configService.Save();
}
UiSharedService.DrawHelpText("Enabling this will not show any \"Warning\" labeled messages for missing optional plugins.");
_uiShared.DrawHelpText("Enabling this will not show any \"Warning\" labeled messages for missing optional plugins.");
if (ImGui.Checkbox("Enable online notifications", ref onlineNotifs))
{
_configService.Current.ShowOnlineNotifications = onlineNotifs;
_configService.Save();
}
UiSharedService.DrawHelpText("Enabling this will show a small notification (type: Info) in the bottom right corner when pairs go online.");
_uiShared.DrawHelpText("Enabling this will show a small notification (type: Info) in the bottom right corner when pairs go online.");
using (ImRaii.Disabled(!onlineNotifs))
{
@@ -1196,13 +1195,13 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.ShowOnlineNotificationsOnlyForIndividualPairs = onlineNotifsPairsOnly;
_configService.Save();
}
UiSharedService.DrawHelpText("Enabling this will only show online notifications (type: Info) for individual pairs.");
_uiShared.DrawHelpText("Enabling this will only show online notifications (type: Info) for individual pairs.");
if (ImGui.Checkbox("Notify only for named pairs", ref onlineNotifsNamedOnly))
{
_configService.Current.ShowOnlineNotificationsOnlyForNamedPairs = onlineNotifsNamedOnly;
_configService.Save();
}
UiSharedService.DrawHelpText("Enabling this will only show online notifications (type: Info) for pairs where you have set an individual note.");
_uiShared.DrawHelpText("Enabling this will only show online notifications (type: Info) for pairs where you have set an individual note.");
}
}
@@ -1242,7 +1241,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_lastTab = "Service Settings";
if (ApiController.ServerAlive)
{
UiSharedService.FontText("Service Actions", _uiShared.UidFont);
_uiShared.BigText("Service Actions");
ImGuiHelpers.ScaledDummy(new Vector2(5, 5));
if (ImGui.Button("Delete all my files"))
{
@@ -1250,7 +1249,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.OpenPopup("Delete all your files?");
}
UiSharedService.DrawHelpText("Completely deletes all your uploaded files on the service.");
_uiShared.DrawHelpText("Completely deletes all your uploaded files on the service.");
if (ImGui.BeginPopupModal("Delete all your files?", ref _deleteFilesPopupModalShown, UiSharedService.PopupWindowFlags))
{
@@ -1286,7 +1285,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.OpenPopup("Delete your account?");
}
UiSharedService.DrawHelpText("Completely deletes your account and all uploaded files to the service.");
_uiShared.DrawHelpText("Completely deletes your account and all uploaded files to the service.");
if (ImGui.BeginPopupModal("Delete your account?", ref _deleteAccountPopupModalShown, UiSharedService.PopupWindowFlags))
{
@@ -1320,7 +1319,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Separator();
}
UiSharedService.FontText("Service & Character Settings", _uiShared.UidFont);
_uiShared.BigText("Service & Character Settings");
var idx = _uiShared.DrawServiceSelection();
@@ -1395,7 +1394,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.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete Character") && UiSharedService.CtrlPressed())
if (_uiShared.IconTextButton(FontAwesomeIcon.Trash, "Delete Character") && UiSharedService.CtrlPressed())
_serverConfigurationManager.RemoveCharacterFromServer(idx, item);
UiSharedService.AttachToolTip("Hold CTRL to delete this entry.");
@@ -1409,14 +1408,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (!selectedServer.Authentications.Exists(c => string.Equals(c.CharacterName, _uiShared.PlayerName, StringComparison.Ordinal)
&& c.WorldId == _uiShared.WorldId))
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.User, "Add current character"))
if (_uiShared.IconTextButton(FontAwesomeIcon.User, "Add current character"))
{
_serverConfigurationManager.AddCurrentCharacterToServer(idx);
}
ImGui.SameLine();
}
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Add new character"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Plus, "Add new character"))
{
_serverConfigurationManager.AddEmptyCharacterToServer(idx);
}
@@ -1451,7 +1450,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (keyInUse) ImGui.PopStyleColor();
if (!keyInUse)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete Secret Key") && UiSharedService.CtrlPressed())
if (_uiShared.IconTextButton(FontAwesomeIcon.Trash, "Delete Secret Key") && UiSharedService.CtrlPressed())
{
selectedServer.SecretKeys.Remove(item.Key);
_serverConfigurationManager.Save();
@@ -1468,7 +1467,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
ImGui.Separator();
if (UiSharedService.NormalizedIconTextButton(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()
{
@@ -1480,7 +1479,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (selectedServer.ServerUri == ApiController.LoporritServiceUri)
{
ImGui.SameLine();
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Register a new Loporrit account"))
if (_uiShared.IconTextButton(FontAwesomeIcon.Plus, "Register a new Loporrit account"))
{
_registrationInProgress = true;
_ = Task.Run(async () => {
@@ -1554,7 +1553,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
if (isMain)
{
UiSharedService.DrawHelpText("You cannot edit the URI of the main service.");
_uiShared.DrawHelpText("You cannot edit the URI of the main service.");
}
if (ImGui.InputText("Service Name", ref serverName, 255, flags))
@@ -1564,16 +1563,16 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
if (isMain)
{
UiSharedService.DrawHelpText("You cannot edit the name of the main service.");
_uiShared.DrawHelpText("You cannot edit the name of the main service.");
}
if (!isMain && selectedServer != _serverConfigurationManager.CurrentServer)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete Service") && UiSharedService.CtrlPressed())
if (_uiShared.IconTextButton(FontAwesomeIcon.Trash, "Delete Service") && UiSharedService.CtrlPressed())
{
_serverConfigurationManager.DeleteServer(selectedServer);
}
UiSharedService.DrawHelpText("Hold CTRL to delete this service");
_uiShared.DrawHelpText("Hold CTRL to delete this service");
}
ImGui.EndTabItem();
}

View File

@@ -1,7 +1,6 @@
using Dalamud.Interface.Colors;
using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.PlayerData.Pairs;
@@ -107,8 +106,8 @@ public class StandaloneProfileUi : WindowMediatorSubscriberBase
};
if (ImGui.BeginChildFrame(1000, childFrame))
{
using (_uiSharedService.GameFont.Push())
ImGui.TextWrapped(mareProfile.Description);
using var _ = _uiSharedService.GameFont.Push();
ImGui.TextWrapped(mareProfile.Description);
}
ImGui.EndChildFrame();

View File

@@ -77,7 +77,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
{
bool isInvitesDisabled = perm.IsDisableInvites();
if (UiSharedService.NormalizedIconTextButton(isInvitesDisabled ? FontAwesomeIcon.Unlock : FontAwesomeIcon.Lock,
if (_uiSharedService.IconTextButton(isInvitesDisabled ? FontAwesomeIcon.Unlock : FontAwesomeIcon.Lock,
isInvitesDisabled ? "Unlock Syncshell" : "Lock Syncshell"))
{
perm.SetDisableInvites(!isInvitesDisabled);
@@ -87,7 +87,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.NormalizedIconTextButton(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);
}
@@ -96,7 +96,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.SameLine();
using (ImRaii.Disabled(_multiInvites <= 1 || _multiInvites > 100))
{
if (UiSharedService.NormalizedIconTextButton(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);
}
@@ -106,7 +106,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.NormalizedIconTextButton(FontAwesomeIcon.Copy, "Copy Invites to clipboard"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Copy, "Copy Invites to clipboard"))
{
ImGui.SetClipboardText(invites);
}
@@ -170,24 +170,24 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
{
if (pair.Value.Value.IsModerator())
{
UiSharedService.NormalizedIcon(FontAwesomeIcon.UserShield);
_uiSharedService.IconText(FontAwesomeIcon.UserShield);
UiSharedService.AttachToolTip("Moderator");
}
if (pair.Value.Value.IsPinned())
{
UiSharedService.NormalizedIcon(FontAwesomeIcon.Thumbtack);
_uiSharedService.IconText(FontAwesomeIcon.Thumbtack);
UiSharedService.AttachToolTip("Pinned");
}
}
else
{
UiSharedService.FontText(FontAwesomeIcon.None.ToIconString(), UiBuilder.IconFont);
_uiSharedService.IconText(FontAwesomeIcon.None);
}
ImGui.TableNextColumn(); // actions
if (_isOwner)
{
if (UiSharedService.NormalizedIconButton(FontAwesomeIcon.UserShield))
if (_uiSharedService.IconButton(FontAwesomeIcon.UserShield))
{
GroupUserInfo userInfo = pair.Value ?? GroupUserInfo.None;
@@ -201,7 +201,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
if (_isOwner || (pair.Value == null || (pair.Value != null && !pair.Value.Value.IsModerator())))
{
if (UiSharedService.NormalizedIconButton(FontAwesomeIcon.Thumbtack))
if (_uiSharedService.IconButton(FontAwesomeIcon.Thumbtack))
{
GroupUserInfo userInfo = pair.Value ?? GroupUserInfo.None;
@@ -214,7 +214,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
using (ImRaii.Disabled(!UiSharedService.CtrlPressed()))
{
if (UiSharedService.NormalizedIconButton(FontAwesomeIcon.Trash))
if (_uiSharedService.IconButton(FontAwesomeIcon.Trash))
{
_ = _apiController.GroupRemoveUser(new GroupPairDto(GroupFullInfo.Group, pair.Key.UserData));
}
@@ -225,7 +225,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.SameLine();
using (ImRaii.Disabled(!UiSharedService.CtrlPressed()))
{
if (UiSharedService.NormalizedIconButton(FontAwesomeIcon.Ban))
if (_uiSharedService.IconButton(FontAwesomeIcon.Ban))
{
Mediator.Publish(new OpenBanUserPopupMessage(pair.Key, GroupFullInfo));
}
@@ -243,7 +243,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
{
using (ImRaii.Disabled(!UiSharedService.CtrlPressed()))
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Broom, "Clear Syncshell"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Broom, "Clear Syncshell"))
{
_ = _apiController.GroupClear(new(GroupFullInfo.Group));
}
@@ -255,7 +255,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.Separator();
ImGuiHelpers.ScaledDummy(2f);
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Unlink, "Check for Inactive Users"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Unlink, "Check for Inactive Users"))
{
_pruneTestTask = _apiController.GroupPrune(new(GroupFullInfo.Group), _pruneDays, execute: false);
_pruneTask = null;
@@ -291,7 +291,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
{
using (ImRaii.Disabled(!UiSharedService.CtrlPressed()))
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Broom, "Prune Inactive Users"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Broom, "Prune Inactive Users"))
{
_pruneTask = _apiController.GroupPrune(new(GroupFullInfo.Group), _pruneDays, execute: true);
_pruneTestTask = null;
@@ -319,7 +319,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
var banNode = ImRaii.TreeNode("User Bans");
if (banNode)
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
{
_bannedUsers = _apiController.GroupGetBannedUsers(new GroupDto(GroupFullInfo.Group)).Result;
}
@@ -349,7 +349,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
UiSharedService.TextWrapped(bannedUser.Reason);
ImGui.TableNextColumn();
using var pushId = ImRaii.PushId(bannedUser.UID);
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Check, "Unban"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Check, "Unban"))
{
_ = _apiController.GroupUnbanUser(bannedUser);
_bannedUsers.RemoveAll(b => string.Equals(b.UID, bannedUser.UID, StringComparison.Ordinal));
@@ -372,9 +372,9 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.AlignTextToFramePadding();
ImGui.Text("Sound Sync");
UiSharedService.BooleanToColoredIcon(!isDisableSounds);
_uiSharedService.BooleanToColoredIcon(!isDisableSounds);
ImGui.SameLine(230);
if (UiSharedService.NormalizedIconTextButton(isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute,
if (_uiSharedService.IconTextButton(isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute,
isDisableSounds ? "Enable sound sync" : "Disable sound sync"))
{
perm.SetDisableSounds(!perm.IsDisableSounds());
@@ -383,9 +383,9 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.AlignTextToFramePadding();
ImGui.Text("Animation Sync");
UiSharedService.BooleanToColoredIcon(!isDisableAnimations);
_uiSharedService.BooleanToColoredIcon(!isDisableAnimations);
ImGui.SameLine(230);
if (UiSharedService.NormalizedIconTextButton(isDisableAnimations ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop,
if (_uiSharedService.IconTextButton(isDisableAnimations ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop,
isDisableAnimations ? "Enable animation sync" : "Disable animation sync"))
{
perm.SetDisableAnimations(!perm.IsDisableAnimations());
@@ -394,9 +394,9 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.AlignTextToFramePadding();
ImGui.Text("VFX Sync");
UiSharedService.BooleanToColoredIcon(!isDisableVfx);
_uiSharedService.BooleanToColoredIcon(!isDisableVfx);
ImGui.SameLine(230);
if (UiSharedService.NormalizedIconTextButton(isDisableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle,
if (_uiSharedService.IconTextButton(isDisableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle,
isDisableVfx ? "Enable VFX sync" : "Disable VFX sync"))
{
perm.SetDisableVFX(!perm.IsDisableVFX());
@@ -413,7 +413,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("New Password");
var availableWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X;
var buttonSize = UiSharedService.GetNormalizedIconTextButtonSize(FontAwesomeIcon.Passport, "Change Password").X;
var buttonSize = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.Passport, "Change Password");
var textSize = ImGui.CalcTextSize("New Password").X;
var spacing = ImGui.GetStyle().ItemSpacing.X;
@@ -423,7 +423,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
ImGui.SameLine();
using (ImRaii.Disabled(_newPassword.Length < 10))
{
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Passport, "Change Password"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Passport, "Change Password"))
{
_pwChangeSuccess = _apiController.GroupChangePassword(new GroupPasswordDto(GroupFullInfo.Group, _newPassword)).Result;
_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);
}
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
{
IsOpen = false;
_ = _apiController.GroupDelete(new(GroupFullInfo.Group));

View File

@@ -1,5 +1,6 @@
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Components;
using Dalamud.Interface.GameFonts;
using Dalamud.Interface.ImGuiFileDialog;
using Dalamud.Interface.ManagedFontAtlas;
@@ -30,8 +31,10 @@ namespace MareSynchronos.UI;
public partial class UiSharedService : DisposableMediatorSubscriberBase
{
public const string TooltipSeparator = "--SEP--";
public static readonly ImGuiWindowFlags PopupWindowFlags = ImGuiWindowFlags.NoResize |
ImGuiWindowFlags.NoScrollbar |
ImGuiWindowFlags.NoScrollbar |
ImGuiWindowFlags.NoScrollWithMouse;
public static Vector4 AccentColor = ImGuiColors.DalamudYellow;
@@ -70,10 +73,9 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
private bool _honorificExists = false;
private bool _isDirectoryWritable = false;
private bool _isPenumbraDirectory = false;
private bool _isOneDrive = false;
private bool _isPenumbraDirectory = false;
private bool _moodlesExists = false;
private bool _penumbraExists = false;
private bool _petNamesExists = false;
@@ -96,21 +98,10 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
_textureProvider = textureProvider;
_localization = localization;
_serverConfigurationManager = serverManager;
_localization.SetupWithLangCode("en");
_isDirectoryWritable = IsDirectoryWritable(_configService.Current.CacheFolder);
UidFont = _pluginInterface.UiBuilder.FontAtlas.NewDelegateFontHandle(e =>
{
e.OnPreBuild(tk => tk.AddDalamudAssetFont(Dalamud.DalamudAsset.NotoSansJpMedium, new()
{
SizePx = 35,
GlyphRanges = [0x20, 0x7E, 0]
}));
});
GameFont = _pluginInterface.UiBuilder.FontAtlas.NewGameFontHandle(new(GameFontFamilyAndSize.Axis12));
Mediator.Subscribe<DelayedFrameworkUpdateMessage>(this, (_) =>
{
_penumbraExists = _ipcManager.Penumbra.APIAvailable;
@@ -120,27 +111,36 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
_honorificExists = _ipcManager.Honorific.APIAvailable;
_petNamesExists = _ipcManager.PetNames.APIAvailable;
});
UidFont = _pluginInterface.UiBuilder.FontAtlas.NewDelegateFontHandle(e =>
{
e.OnPreBuild(tk => tk.AddDalamudAssetFont(Dalamud.DalamudAsset.NotoSansJpMedium, new()
{
SizePx = 35,
GlyphRanges = [0x20, 0x7E, 0]
}));
});
GameFont = _pluginInterface.UiBuilder.FontAtlas.NewGameFontHandle(new(GameFontFamilyAndSize.Axis12));
IconFont = _pluginInterface.UiBuilder.IconFontFixedWidthHandle;
}
public ApiController ApiController => _apiController;
public bool EditTrackerPosition { get; set; }
public IFontHandle GameFont { get; init; }
public bool HasValidPenumbraModPath => !(_ipcManager.Penumbra.ModDirectory ?? string.Empty).IsNullOrEmpty() && Directory.Exists(_ipcManager.Penumbra.ModDirectory);
public IFontHandle IconFont { get; init; }
public bool IsInGpose => _dalamudUtil.IsInCutscene;
public string PlayerName => _dalamudUtil.GetPlayerName();
public IFontHandle UidFont { get; init; }
public IFontHandle GameFont { get; init; }
public Dictionary<ushort, string> WorldData => _dalamudUtil.WorldData.Value;
public uint WorldId => _dalamudUtil.GetHomeWorldId();
public const string TooltipSeparator = "--SEP--";
public static void AttachToolTip(string text)
{
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
@@ -165,23 +165,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
}
}
public static void BooleanToColoredIcon(bool value, bool inline = true)
{
using var colorgreen = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen, value);
using var colorred = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed, !value);
if (inline) ImGui.SameLine();
if (value)
{
NormalizedIcon(FontAwesomeIcon.Check);
}
else
{
NormalizedIcon(FontAwesomeIcon.Times);
}
}
public static string ByteToString(long bytes, bool addSuffix = true)
{
_ = addSuffix;
@@ -231,13 +214,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
public static bool CtrlPressed() => (GetKeyState(0xA2) & 0x8000) != 0 || (GetKeyState(0xA3) & 0x8000) != 0;
public static void DrawHelpText(string helpText)
{
ImGui.SameLine();
NormalizedIcon(FontAwesomeIcon.QuestionCircle, ImGui.GetColorU32(ImGuiCol.TextDisabled));
AttachToolTip(helpText);
}
public static void DrawOutlinedFont(string text, Vector4 fontColor, Vector4 outlineColor, int thickness)
{
var original = ImGui.GetCursorPos();
@@ -294,27 +270,17 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
drawList.AddText(textPos, fontColor, text);
}
public static void FontText(string text, ImFontPtr font, Vector4? color = null)
{
using var pushedFont = ImRaii.PushFont(font);
using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, Color(color ?? new Vector4(1, 1, 1, 1)), color != null);
ImGui.TextUnformatted(text);
}
public static void FontText(string text, IFontHandle font, Vector4? color = null)
{
using var pushedFont = font.Push();
using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, Color(color ?? new Vector4(1, 1, 1, 1)), color != null);
ImGui.TextUnformatted(text);
}
public static Vector4 GetBoolColor(bool input) => input ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed;
public static Vector2 GetIconButtonSize(FontAwesomeIcon icon)
public float GetIconTextButtonSize(FontAwesomeIcon icon, string text)
{
using var font = ImRaii.PushFont(UiBuilder.IconFont);
var buttonSize = ImGuiHelpers.GetButtonSize(icon.ToIconString());
return buttonSize;
Vector2 vector;
using (IconFont.Push())
vector = ImGui.CalcTextSize(icon.ToIconString());
Vector2 vector2 = ImGui.CalcTextSize(text);
float num = 3f * ImGuiHelpers.GlobalScale;
return vector.X + vector2.X + ImGui.GetStyle().FramePadding.X * 2f + num;
}
public static Vector2 GetIconSize(FontAwesomeIcon icon)
@@ -350,147 +316,69 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
return ImGui.GetWindowContentRegionMax().Y - ImGui.GetWindowContentRegionMin().Y;
}
public static Vector2 GetNormalizedIconTextButtonSize(FontAwesomeIcon icon, string text, float? width = null, bool isInPopup = false)
public bool IconButton(FontAwesomeIcon icon, float? height = null)
{
var iconData = GetIconData(icon);
var textSize = ImGui.CalcTextSize(text);
var padding = ImGui.GetStyle().FramePadding;
var buttonSizeY = ImGui.GetFrameHeight();
var iconExtraSpacing = isInPopup ? padding.X * 2 : 0;
string text = icon.ToIconString();
if (width == null || width <= 0)
{
var buttonSizeX = iconData.NormalizedIconScale.X + (padding.X * 3) + iconExtraSpacing + textSize.X;
return new Vector2(buttonSizeX, buttonSizeY);
}
else
{
return new Vector2(width.Value, buttonSizeY);
}
ImGui.PushID(text);
Vector2 vector;
using (IconFont.Push())
vector = ImGui.CalcTextSize(text);
ImDrawListPtr windowDrawList = ImGui.GetWindowDrawList();
Vector2 cursorScreenPos = ImGui.GetCursorScreenPos();
float x = vector.X + ImGui.GetStyle().FramePadding.X * 2f;
float frameHeight = height ?? ImGui.GetFrameHeight();
bool result = ImGui.Button(string.Empty, new Vector2(x, frameHeight));
Vector2 pos = new Vector2(cursorScreenPos.X + ImGui.GetStyle().FramePadding.X,
cursorScreenPos.Y + (height ?? ImGui.GetFrameHeight()) / 2f - (vector.Y / 2f));
using (IconFont.Push())
windowDrawList.AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), text);
ImGui.PopID();
return result;
}
public static Vector2 NormalizedIconButtonSize(FontAwesomeIcon icon)
private bool IconTextButtonInternal(FontAwesomeIcon icon, string text, Vector4? defaultColor = null, float? width = null)
{
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 cursor = ImGui.GetCursorPos();
var drawList = ImGui.GetWindowDrawList();
var pos = ImGui.GetWindowPos();
var scrollPosY = ImGui.GetScrollY();
var scrollPosX = ImGui.GetScrollX();
var buttonSize = NormalizedIconButtonSize(icon);
if (ImGui.Button("###" + icon.ToIconString(), buttonSize))
int num = 0;
if (defaultColor.HasValue)
{
wasClicked = true;
ImGui.PushStyleColor(ImGuiCol.Button, defaultColor.Value);
num++;
}
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;
using (ImRaii.PushColor(ImGuiCol.Button, ImGui.GetColorU32(ImGuiCol.PopupBg), isInPopup))
ImGui.PushID(text);
Vector2 vector;
using (IconFont.Push())
vector = ImGui.CalcTextSize(icon.ToIconString());
Vector2 vector2 = ImGui.CalcTextSize(text);
ImDrawListPtr windowDrawList = ImGui.GetWindowDrawList();
Vector2 cursorScreenPos = ImGui.GetCursorScreenPos();
float num2 = 3f * ImGuiHelpers.GlobalScale;
float x = width ?? vector.X + vector2.X + ImGui.GetStyle().FramePadding.X * 2f + num2;
float frameHeight = ImGui.GetFrameHeight();
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);
using (IconFont.Push())
windowDrawList.AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString());
Vector2 pos2 = new Vector2(pos.X + vector.X + num2, cursorScreenPos.Y + ImGui.GetStyle().FramePadding.Y);
windowDrawList.AddText(pos2, ImGui.GetColorU32(ImGuiCol.Text), text);
ImGui.PopID();
if (num > 0)
{
if (ImGui.Button("###" + icon.ToIconString() + text, buttonSize))
{
wasClicked = true;
}
ImGui.PopStyleColor(num);
}
drawList.AddText(UiBuilder.DefaultFont, ImGui.GetFontSize(),
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;
return result;
}
public static void NormalizedIcon(FontAwesomeIcon icon, uint color)
public bool IconTextButton(FontAwesomeIcon icon, string text, float? width = null, bool isInPopup = false)
{
var cursorPos = ImGui.GetCursorPos();
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 frameOffsetY = ((frameHeight - iconData.IconSize.Y * iconData.IconScaling) / 2f);
drawList.AddText(UiBuilder.IconFont, UiBuilder.IconFont.FontSize * iconData.IconScaling,
new(windowPos.X - scrollPosX + cursorPos.X + iconData.OffsetX,
windowPos.Y - scrollPosY + cursorPos.Y + frameOffsetY),
color, icon.ToIconString());
ImGui.Dummy(new(iconData.NormalizedIconScale.X, ImGui.GetFrameHeight()));
return IconTextButtonInternal(icon, text,
isInPopup ? ColorHelpers.RgbaUintToVector4(ImGui.GetColorU32(ImGuiCol.PopupBg)) : null,
width <= 0 ? null : width);
}
public static void NormalizedIcon(FontAwesomeIcon icon, Vector4? color = null)
{
NormalizedIcon(icon, color == null ? ImGui.GetColorU32(ImGuiCol.Text) : ImGui.GetColorU32(color.Value));
}
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)
{
try
@@ -582,10 +470,26 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
return true;
}
public void BigText(string text)
public void BigText(string text, Vector4? color = null)
{
using var font = UidFont.Push();
ImGui.TextUnformatted(text);
FontText(text, UidFont, color);
}
public void BooleanToColoredIcon(bool value, bool inline = true)
{
using var colorgreen = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen, value);
using var colorred = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed, !value);
if (inline) ImGui.SameLine();
if (value)
{
IconText(FontAwesomeIcon.Check);
}
else
{
IconText(FontAwesomeIcon.Times);
}
}
public void DrawCacheDirectorySetting()
@@ -598,7 +502,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.SameLine();
using (ImRaii.Disabled(_cacheMonitor.MareWatcher != null))
{
if (NormalizedIconButton(FontAwesomeIcon.Folder))
if (IconButton(FontAwesomeIcon.Folder))
{
FileDialogManager.OpenFolderDialog("Pick Loporrit Storage Folder", (success, path) =>
{
@@ -665,7 +569,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
}
public T? DrawCombo<T>(string comboName, IEnumerable<T> comboItems, Func<T, string> toName,
Action<T>? onSelected = null, T? initialSelectedItem = default)
Action<T?>? onSelected = null, T? initialSelectedItem = default)
{
if (!comboItems.Any()) return default;
@@ -689,7 +593,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
{
foreach (var item in comboItems)
{
bool isSelected = EqualityComparer<T>.Default.Equals(item, (T)selectedItem);
bool isSelected = EqualityComparer<T>.Default.Equals(item, (T?)selectedItem);
if (ImGui.Selectable(toName(item), isSelected))
{
_selectedComboItems[comboName] = item!;
@@ -784,24 +688,24 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
if (_configService.Current.InitialScanComplete)
{
ImGui.SameLine();
if (NormalizedIconTextButton(FontAwesomeIcon.Play, "Force rescan"))
if (IconTextButton(FontAwesomeIcon.Play, "Force rescan"))
{
_cacheMonitor.InvokeScan();
}
}
}
}
public void DrawHelpText(string helpText)
{
ImGui.SameLine();
IconText(FontAwesomeIcon.QuestionCircle, ImGui.GetColorU32(ImGuiCol.TextDisabled));
AttachToolTip(helpText);
}
public bool DrawOtherPluginState(bool intro = false)
{
var penumbraColor = _penumbraExists ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed;
var glamourerColor = _glamourerExists ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed;
var heelsColor = _heelsExists ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed;
var customizeColor = _customizePlusExists ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed;
var honorificColor = _honorificExists ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed;
var petNamesColor = _petNamesExists ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed;
var check = FontAwesomeIcon.Check.ToIconString();
var cross = FontAwesomeIcon.SquareXmark.ToIconString();
var check = FontAwesomeIcon.Check;
var cross = FontAwesomeIcon.SquareXmark;
if (intro)
{
@@ -817,7 +721,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.TextUnformatted("Penumbra");
ImGui.SameLine();
FontText(_penumbraExists ? check : cross, UiBuilder.IconFont, penumbraColor);
IconText(_penumbraExists ? check : cross, GetBoolColor(_penumbraExists));
ImGui.SameLine();
AttachToolTip($"Penumbra is " + (_penumbraExists ? "available and up to date." : "unavailable or not up to date."));
ImGui.Spacing();
@@ -825,7 +729,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.SameLine();
ImGui.TextUnformatted("Glamourer");
ImGui.SameLine();
FontText(_glamourerExists ? check : cross, UiBuilder.IconFont, glamourerColor);
IconText(_glamourerExists ? check : cross, GetBoolColor(_glamourerExists));
ImGui.SameLine();
AttachToolTip($"Glamourer is " + (_glamourerExists ? "available and up to date." : "unavailable or not up to date."));
ImGui.Spacing();
@@ -845,7 +749,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.TextUnformatted("SimpleHeels");
ImGui.SameLine();
FontText(_heelsExists ? check : cross, UiBuilder.IconFont, heelsColor);
IconText(_heelsExists ? check : cross, GetBoolColor(_heelsExists));
ImGui.SameLine();
AttachToolTip($"SimpleHeels is " + (_heelsExists ? "available and up to date." : "unavailable or not up to date."));
ImGui.Spacing();
@@ -853,7 +757,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.SameLine();
ImGui.TextUnformatted("Customize+");
ImGui.SameLine();
FontText(_customizePlusExists ? check : cross, UiBuilder.IconFont, customizeColor);
IconText(_customizePlusExists ? check : cross, GetBoolColor(_customizePlusExists));
ImGui.SameLine();
AttachToolTip($"Customize+ is " + (_customizePlusExists ? "available and up to date." : "unavailable or not up to date."));
ImGui.Spacing();
@@ -861,7 +765,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.SameLine();
ImGui.TextUnformatted("Honorific");
ImGui.SameLine();
FontText(_honorificExists ? check : cross, UiBuilder.IconFont, honorificColor);
IconText(_honorificExists ? check : cross, GetBoolColor(_honorificExists));
ImGui.SameLine();
AttachToolTip($"Honorific is " + (_honorificExists ? "available and up to date." : "unavailable or not up to date."));
ImGui.Spacing();
@@ -869,7 +773,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.SameLine();
ImGui.TextUnformatted("PetNicknames");
ImGui.SameLine();
FontText(_petNamesExists ? check : cross, UiBuilder.IconFont,petNamesColor);
IconText(_petNamesExists ? check : cross, GetBoolColor(_petNamesExists));
ImGui.SameLine();
AttachToolTip($"PetNicknames is " + (_petNamesExists ? "available and up to date." : "unavailable or not up to date."));
ImGui.Spacing();
@@ -927,7 +831,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.SameLine();
var text = "Connect";
if (_serverSelectionIndex == _serverConfigurationManager.CurrentServerIndex) text = "Reconnect";
if (NormalizedIconTextButton(FontAwesomeIcon.Link, text))
if (IconTextButton(FontAwesomeIcon.Link, text))
{
_serverConfigurationManager.SelectServer(_serverSelectionIndex);
_ = _apiController.CreateConnections();
@@ -939,7 +843,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.InputText("Custom Service URI", ref _customServerUri, 255);
ImGui.SetNextItemWidth(250 * ImGuiHelpers.GlobalScale);
ImGui.InputText("Custom Service Name", ref _customServerName, 255);
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Plus, "Add Custom Service")
if (IconTextButton(FontAwesomeIcon.Plus, "Add Custom Service")
&& !string.IsNullOrEmpty(_customServerUri)
&& !string.IsNullOrEmpty(_customServerName))
{
@@ -958,6 +862,33 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
return _serverSelectionIndex;
}
public Vector2 GetIconButtonSize(FontAwesomeIcon icon)
{
using var font = IconFont.Push();
return ImGuiHelpers.GetButtonSize(icon.ToIconString());
}
public Vector2 GetIconData(FontAwesomeIcon icon)
{
using var font = IconFont.Push();
return ImGui.CalcTextSize(icon.ToIconString());
}
public void IconText(FontAwesomeIcon icon, uint color)
{
FontText(icon.ToIconString(), IconFont, color);
}
public void IconText(FontAwesomeIcon icon, Vector4? color = null)
{
IconText(icon, color == null ? ImGui.GetColorU32(ImGuiCol.Text) : ImGui.GetColorU32(color.Value));
}
public IDalamudTextureWrap LoadImage(byte[] imageData)
{
return _textureProvider.CreateFromImageAsync(imageData).Result;
}
public void LoadLocalization(string languageCode)
{
_localization.SetupWithLangCode(languageCode);
@@ -967,22 +898,29 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
[LibraryImport("user32")]
internal static partial short GetKeyState(int nVirtKey);
internal IDalamudTextureWrap LoadImage(byte[] imageData)
{
return _textureProvider.CreateFromImageAsync(imageData).Result;
}
private static void CenterWindow(float width, float height, ImGuiCond cond = ImGuiCond.None)
{
var center = ImGui.GetMainViewport().GetCenter();
ImGui.SetWindowPos(new Vector2(center.X - width / 2, center.Y - height / 2), cond);
}
#pragma warning disable MA0009 // Add regex evaluation timeout
[GeneratedRegex(@"^(?:[a-zA-Z]:\\[\w\s\-\\]+?|\/(?:[\w\s\-\/])+?)$", RegexOptions.ECMAScript)]
#pragma warning restore MA0009 // Add regex evaluation timeout
[GeneratedRegex(@"^(?:[a-zA-Z]:\\[\w\s\-\\]+?|\/(?:[\w\s\-\/])+?)$", RegexOptions.ECMAScript, 5000)]
private static partial Regex PathRegex();
private void FontText(string text, IFontHandle font, Vector4? color = null)
{
FontText(text, font, color == null ? ImGui.GetColorU32(ImGuiCol.Text) : ImGui.GetColorU32(color.Value));
}
private void FontText(string text, IFontHandle font, uint color)
{
using var pushedFont = font.Push();
using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, color);
ImGui.TextUnformatted(text);
}
public sealed record IconScaleData(Vector2 IconSize, Vector2 NormalizedIconScale, float OffsetX, float IconScaling);
protected override void Dispose(bool disposing)
{
if (!disposing) return;

View File

@@ -152,10 +152,10 @@
/// <inheritdoc />
public override string ToString()
{
return _baseStream.ToString();
return _baseStream?.ToString() ?? string.Empty;
}
private class Bandwidth
private sealed class Bandwidth
{
private long _count;
private int _lastSecondCheckpoint;
@@ -175,7 +175,7 @@
{
int elapsedTime = Environment.TickCount - _lastSecondCheckpoint + 1;
receivedBytesCount = Interlocked.Add(ref _lastTransferredBytesCount, receivedBytesCount);
double momentSpeed = receivedBytesCount * 1000 / elapsedTime; // B/s
double momentSpeed = receivedBytesCount * 1000 / (double)elapsedTime; // B/s
if (1000 < elapsedTime)
{

View File

@@ -55,7 +55,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
Mediator.Subscribe<DalamudLoginMessage>(this, (_) => DalamudUtilOnLogIn());
Mediator.Subscribe<DalamudLogoutMessage>(this, (_) => DalamudUtilOnLogOut());
Mediator.Subscribe<HubClosedMessage>(this, (msg) => MareHubOnClosed(msg.Exception));
Mediator.Subscribe<HubReconnectedMessage>(this, async (msg) => await MareHubOnReconnected().ConfigureAwait(false));
Mediator.Subscribe<HubReconnectedMessage>(this, (msg) => _ = MareHubOnReconnected());
Mediator.Subscribe<HubReconnectingMessage>(this, (msg) => MareHubOnReconnecting(msg.Exception));
Mediator.Subscribe<CyclePauseMessage>(this, (msg) => _ = CyclePause(msg.UserData));
Mediator.Subscribe<CensusUpdateMessage>(this, (msg) => _lastCensus = msg);
@@ -113,7 +113,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
Logger.LogInformation("Not recreating Connection, paused");
_connectionDto = null;
await StopConnection(ServerState.Disconnected).ConfigureAwait(false);
_connectionCancellationTokenSource.Cancel();
_connectionCancellationTokenSource?.Cancel();
return;
}
@@ -134,7 +134,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
Logger.LogWarning("No secret key set for current character");
_connectionDto = null;
await StopConnection(ServerState.NoSecretKey).ConfigureAwait(false);
_connectionCancellationTokenSource.Cancel();
_connectionCancellationTokenSource?.Cancel();
return;
}
@@ -144,7 +144,8 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
Mediator.Publish(new EventMessage(new Services.Events.Event(nameof(ApiController), Services.Events.EventSeverity.Informational,
$"Starting Connection to {_serverManager.CurrentServer.ServerName}")));
_connectionCancellationTokenSource.Cancel();
_connectionCancellationTokenSource?.Cancel();
_connectionCancellationTokenSource?.Dispose();
_connectionCancellationTokenSource = new CancellationTokenSource();
var token = _connectionCancellationTokenSource.Token;
while (ServerState is not ServerState.Connected && !token.IsCancellationRequested)