minor refactoring

This commit is contained in:
rootdarkarchon 2024-03-17 14:43:34 +01:00
parent 142c65cc9d
commit 7baca3565a
34 changed files with 554 additions and 627 deletions

View file

@ -22,8 +22,8 @@ public class DrawFolderGroup : DrawFolderBase
public DrawFolderGroup(string id, GroupFullInfoDto groupFullInfoDto, ApiController apiController,
IImmutableList<DrawUserPair> drawPairs, IImmutableList<Pair> allPairs, TagHandler tagHandler, IdDisplayHandler idDisplayHandler,
MareMediator mareMediator) :
base(id, drawPairs, allPairs, tagHandler)
MareMediator mareMediator, UiSharedService uiSharedService) :
base(id, drawPairs, allPairs, tagHandler, uiSharedService)
{
_groupFullInfoDto = groupFullInfoDto;
_apiController = apiController;
@ -41,7 +41,7 @@ public class DrawFolderGroup : DrawFolderBase
{
ImGui.AlignTextToFramePadding();
UiSharedService.NormalizedIcon(_groupFullInfoDto.GroupPermissions.IsDisableInvites() ? FontAwesomeIcon.Lock : FontAwesomeIcon.Users);
_uiSharedService.IconText(_groupFullInfoDto.GroupPermissions.IsDisableInvites() ? FontAwesomeIcon.Lock : FontAwesomeIcon.Users);
if (_groupFullInfoDto.GroupPermissions.IsDisableInvites())
{
UiSharedService.AttachToolTip("Syncshell " + _groupFullInfoDto.GroupAliasOrGID + " is closed for invites");
@ -60,19 +60,19 @@ public class DrawFolderGroup : DrawFolderBase
if (IsOwner)
{
ImGui.AlignTextToFramePadding();
UiSharedService.NormalizedIcon(FontAwesomeIcon.Crown);
_uiSharedService.IconText(FontAwesomeIcon.Crown);
UiSharedService.AttachToolTip("You are the owner of " + _groupFullInfoDto.GroupAliasOrGID);
}
else if (IsModerator)
{
ImGui.AlignTextToFramePadding();
UiSharedService.NormalizedIcon(FontAwesomeIcon.UserShield);
_uiSharedService.IconText(FontAwesomeIcon.UserShield);
UiSharedService.AttachToolTip("You are a moderator in " + _groupFullInfoDto.GroupAliasOrGID);
}
else if (IsPinned)
{
ImGui.AlignTextToFramePadding();
UiSharedService.NormalizedIcon(FontAwesomeIcon.Thumbtack);
_uiSharedService.IconText(FontAwesomeIcon.Thumbtack);
UiSharedService.AttachToolTip("You are pinned in " + _groupFullInfoDto.GroupAliasOrGID);
}
ImGui.SameLine();
@ -85,21 +85,21 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.Separator();
ImGui.TextUnformatted("General Syncshell Actions");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Copy, "Copy ID", menuWidth, true))
if (UiSharedService.IconTextButton(FontAwesomeIcon.Copy, "Copy ID", menuWidth, true))
{
ImGui.CloseCurrentPopup();
ImGui.SetClipboardText(_groupFullInfoDto.GroupAliasOrGID);
}
UiSharedService.AttachToolTip("Copy Syncshell ID to Clipboard");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StickyNote, "Copy Notes", menuWidth, true))
if (UiSharedService.IconTextButton(FontAwesomeIcon.StickyNote, "Copy Notes", menuWidth, true))
{
ImGui.CloseCurrentPopup();
ImGui.SetClipboardText(UiSharedService.GetNotes(DrawPairs.Select(k => k.Pair).ToList()));
}
UiSharedService.AttachToolTip("Copies all your notes for all users in this Syncshell to the clipboard." + Environment.NewLine + "They can be imported via Settings -> Privacy -> Import Notes from Clipboard");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ArrowCircleLeft, "Leave Syncshell", menuWidth, true) && UiSharedService.CtrlPressed())
if (UiSharedService.IconTextButton(FontAwesomeIcon.ArrowCircleLeft, "Leave Syncshell", menuWidth, true) && UiSharedService.CtrlPressed())
{
_ = _apiController.GroupLeave(_groupFullInfoDto);
ImGui.CloseCurrentPopup();
@ -117,7 +117,7 @@ public class DrawFolderGroup : DrawFolderBase
if ((_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations() != disableAnims
|| _groupFullInfoDto.GroupPermissions.IsPreferDisableSounds() != disableSounds
|| _groupFullInfoDto.GroupPermissions.IsPreferDisableVFX() != disableVfx)
&& UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Check, "Align with suggested permissions", menuWidth, true))
&& UiSharedService.IconTextButton(FontAwesomeIcon.Check, "Align with suggested permissions", menuWidth, true))
{
perm.SetDisableVFX(_groupFullInfoDto.GroupPermissions.IsPreferDisableVFX());
perm.SetDisableSounds(_groupFullInfoDto.GroupPermissions.IsPreferDisableSounds());
@ -126,24 +126,21 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.CloseCurrentPopup();
}
if (UiSharedService.NormalizedIconTextButton(disableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeOff, disableSounds ? "Enable Sound Sync" : "Disable Sound Sync",
menuWidth, true))
if (UiSharedService.IconTextButton(disableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeOff, disableSounds ? "Enable Sound Sync" : "Disable Sound Sync", menuWidth, true))
{
perm.SetDisableSounds(!disableSounds);
_ = _apiController.GroupChangeIndividualPermissionState(new(_groupFullInfoDto.Group, new(_apiController.UID), perm));
ImGui.CloseCurrentPopup();
}
if (UiSharedService.NormalizedIconTextButton(disableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop, disableAnims ? "Enable Animation Sync" : "Disable Animation Sync",
menuWidth, true))
if (UiSharedService.IconTextButton(disableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop, disableAnims ? "Enable Animation Sync" : "Disable Animation Sync", menuWidth, true))
{
perm.SetDisableAnimations(!disableAnims);
_ = _apiController.GroupChangeIndividualPermissionState(new(_groupFullInfoDto.Group, new(_apiController.UID), perm));
ImGui.CloseCurrentPopup();
}
if (UiSharedService.NormalizedIconTextButton(disableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle, disableVfx ? "Enable VFX Sync" : "Disable VFX Sync",
menuWidth, true))
if (UiSharedService.IconTextButton(disableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle, disableVfx ? "Enable VFX Sync" : "Disable VFX Sync", menuWidth, true))
{
perm.SetDisableVFX(!disableVfx);
_ = _apiController.GroupChangeIndividualPermissionState(new(_groupFullInfoDto.Group, new(_apiController.UID), perm));
@ -154,7 +151,7 @@ public class DrawFolderGroup : DrawFolderBase
{
ImGui.Separator();
ImGui.TextUnformatted("Syncshell Admin Functions");
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Cog, "Open Admin Panel", menuWidth, true))
if (UiSharedService.IconTextButton(FontAwesomeIcon.Cog, "Open Admin Panel", menuWidth, true))
{
ImGui.CloseCurrentPopup();
_mareMediator.Publish(new OpenSyncshellAdminPanel(_groupFullInfoDto));
@ -172,9 +169,9 @@ public class DrawFolderGroup : DrawFolderBase
var spacingX = ImGui.GetStyle().ItemSpacing.X;
FontAwesomeIcon pauseIcon = _groupFullInfoDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseButtonSize = UiSharedService.NormalizedIconButtonSize(pauseIcon);
var pauseButtonSize = _uiSharedService.IconButtonSize(pauseIcon);
var userCogButtonSize = UiSharedService.GetIconData(FontAwesomeIcon.UsersCog).NormalizedIconScale;
var userCogButtonSize = _uiSharedService.GetIconData(FontAwesomeIcon.UsersCog);
var individualSoundsDisabled = _groupFullInfoDto.GroupUserPermissions.IsDisableSounds();
var individualAnimDisabled = _groupFullInfoDto.GroupUserPermissions.IsDisableAnimations();
@ -186,7 +183,7 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.AlignTextToFramePadding();
UiSharedService.NormalizedIcon(FontAwesomeIcon.UsersCog, (_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations() != individualAnimDisabled
_uiSharedService.IconText(FontAwesomeIcon.UsersCog, (_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations() != individualAnimDisabled
|| _groupFullInfoDto.GroupPermissions.IsPreferDisableSounds() != individualSoundsDisabled
|| _groupFullInfoDto.GroupPermissions.IsPreferDisableVFX() != individualVFXDisabled) ? ImGuiColors.DalamudYellow : null);
if (ImGui.IsItemHovered())
@ -196,17 +193,17 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.TextUnformatted("Syncshell Permissions");
ImGuiHelpers.ScaledDummy(2f);
UiSharedService.BooleanToColoredIcon(!individualSoundsDisabled, inline: false);
_uiSharedService.BooleanToColoredIcon(!individualSoundsDisabled, inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Sound Sync");
UiSharedService.BooleanToColoredIcon(!individualAnimDisabled, inline: false);
_uiSharedService.BooleanToColoredIcon(!individualAnimDisabled, inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Animation Sync");
UiSharedService.BooleanToColoredIcon(!individualVFXDisabled, inline: false);
_uiSharedService.BooleanToColoredIcon(!individualVFXDisabled, inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("VFX Sync");
@ -217,17 +214,17 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.TextUnformatted("Suggested Permissions");
ImGuiHelpers.ScaledDummy(2f);
UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableSounds(), inline: false);
_uiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableSounds(), inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Sound Sync");
UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations(), inline: false);
_uiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations(), inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("Animation Sync");
UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableVFX(), inline: false);
_uiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableVFX(), inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("VFX Sync");
@ -236,7 +233,7 @@ public class DrawFolderGroup : DrawFolderBase
}
ImGui.SameLine();
if (UiSharedService.NormalizedIconButton(pauseIcon))
if (UiSharedService.IconButton(pauseIcon))
{
var perm = _groupFullInfoDto.GroupUserPermissions;
perm.SetPaused(!perm.IsPaused());