add normalized icons

This commit is contained in:
rootdarkarchon
2023-10-28 15:36:45 +02:00
parent 4d975372cc
commit e65c363d0f
13 changed files with 146 additions and 95 deletions

View File

@@ -175,7 +175,7 @@ public class CompactUi : WindowMediatorSubscriberBase
private void DrawAddCharacter() private void DrawAddCharacter()
{ {
ImGui.Dummy(new(10)); ImGuiHelpers.ScaledDummy(10f);
var keys = _serverManager.CurrentServer!.SecretKeys; var keys = _serverManager.CurrentServer!.SecretKeys;
if (keys.Any()) if (keys.Any())
{ {

View File

@@ -1,5 +1,6 @@
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Components; using Dalamud.Interface.Components;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using ImGuiNET; using ImGuiNET;
using MareSynchronos.PlayerData.Pairs; using MareSynchronos.PlayerData.Pairs;
@@ -41,7 +42,7 @@ public abstract class DrawFolderBase : IDrawFolder
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont); UiSharedService.NormalizedIcon(icon);
if (ImGui.IsItemClicked()) if (ImGui.IsItemClicked())
{ {
_tagHandler.SetTagOpen(_id, !_tagHandler.IsTagOpen(_id)); _tagHandler.SetTagOpen(_id, !_tagHandler.IsTagOpen(_id));

View File

@@ -42,8 +42,7 @@ public class DrawFolderGroup : DrawFolderBase
{ {
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
using (ImRaii.PushFont(UiBuilder.IconFont)) UiSharedService.NormalizedIcon(_groupFullInfoDto.GroupPermissions.IsDisableInvites() ? FontAwesomeIcon.Lock : FontAwesomeIcon.Users);
ImGui.TextUnformatted(_groupFullInfoDto.GroupPermissions.IsDisableInvites() ? FontAwesomeIcon.Lock.ToIconString() : FontAwesomeIcon.Users.ToIconString());
if (_groupFullInfoDto.GroupPermissions.IsDisableInvites()) if (_groupFullInfoDto.GroupPermissions.IsDisableInvites())
{ {
UiSharedService.AttachToolTip("Syncshell " + _groupFullInfoDto.GroupAliasOrGID + " is closed for invites"); UiSharedService.AttachToolTip("Syncshell " + _groupFullInfoDto.GroupAliasOrGID + " is closed for invites");
@@ -62,22 +61,19 @@ public class DrawFolderGroup : DrawFolderBase
if (IsOwner) if (IsOwner)
{ {
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
using (ImRaii.PushFont(UiBuilder.IconFont)) UiSharedService.NormalizedIcon(FontAwesomeIcon.Crown);
ImGui.TextUnformatted(FontAwesomeIcon.Crown.ToIconString());
UiSharedService.AttachToolTip("You are the owner of " + _groupFullInfoDto.GroupAliasOrGID); UiSharedService.AttachToolTip("You are the owner of " + _groupFullInfoDto.GroupAliasOrGID);
} }
else if (IsModerator) else if (IsModerator)
{ {
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
using (ImRaii.PushFont(UiBuilder.IconFont)) UiSharedService.NormalizedIcon(FontAwesomeIcon.UserShield);
ImGui.TextUnformatted(FontAwesomeIcon.UserShield.ToIconString());
UiSharedService.AttachToolTip("You are a moderator in " + _groupFullInfoDto.GroupAliasOrGID); UiSharedService.AttachToolTip("You are a moderator in " + _groupFullInfoDto.GroupAliasOrGID);
} }
else if (IsPinned) else if (IsPinned)
{ {
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
using (ImRaii.PushFont(UiBuilder.IconFont)) UiSharedService.NormalizedIcon(FontAwesomeIcon.Thumbtack);
ImGui.TextUnformatted(FontAwesomeIcon.Thumbtack.ToIconString());
UiSharedService.AttachToolTip("You are pinned in " + _groupFullInfoDto.GroupAliasOrGID); UiSharedService.AttachToolTip("You are pinned in " + _groupFullInfoDto.GroupAliasOrGID);
} }
ImGui.SameLine(); ImGui.SameLine();
@@ -179,8 +175,7 @@ public class DrawFolderGroup : DrawFolderBase
FontAwesomeIcon pauseIcon = _groupFullInfoDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; FontAwesomeIcon pauseIcon = _groupFullInfoDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseButtonSize = UiSharedService.GetIconButtonSize(pauseIcon); var pauseButtonSize = UiSharedService.GetIconButtonSize(pauseIcon);
var folderIcon = FontAwesomeIcon.UsersCog; var userCogButtonSize = UiSharedService.GetNormalizedIconSize(FontAwesomeIcon.UsersCog);
var userCogButtonSize = UiSharedService.GetIconSize(folderIcon);
var individualSoundsDisabled = _groupFullInfoDto.GroupUserPermissions.IsDisableSounds(); var individualSoundsDisabled = _groupFullInfoDto.GroupUserPermissions.IsDisableSounds();
var individualAnimDisabled = _groupFullInfoDto.GroupUserPermissions.IsDisableAnimations(); var individualAnimDisabled = _groupFullInfoDto.GroupUserPermissions.IsDisableAnimations();
@@ -192,17 +187,15 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow, UiSharedService.NormalizedIcon(FontAwesomeIcon.UsersCog, (_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations() != individualAnimDisabled
_groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations() != individualAnimDisabled
|| _groupFullInfoDto.GroupPermissions.IsPreferDisableSounds() != individualSoundsDisabled || _groupFullInfoDto.GroupPermissions.IsPreferDisableSounds() != individualSoundsDisabled
|| _groupFullInfoDto.GroupPermissions.IsPreferDisableVFX() != individualVFXDisabled)) || _groupFullInfoDto.GroupPermissions.IsPreferDisableVFX() != individualVFXDisabled) ? ImGuiColors.DalamudYellow : null);
UiSharedService.FontText(folderIcon.ToIconString(), UiBuilder.IconFont);
if (ImGui.IsItemHovered()) if (ImGui.IsItemHovered())
{ {
ImGui.BeginTooltip(); ImGui.BeginTooltip();
ImGui.TextUnformatted("Syncshell Permissions"); ImGui.TextUnformatted("Syncshell Permissions");
ImGui.Dummy(new(2f)); ImGuiHelpers.ScaledDummy(2f);
UiSharedService.BooleanToColoredIcon(!individualSoundsDisabled, inline: false); UiSharedService.BooleanToColoredIcon(!individualSoundsDisabled, inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
@@ -218,9 +211,9 @@ public class DrawFolderGroup : DrawFolderBase
ImGui.Separator(); ImGui.Separator();
ImGui.Dummy(new(2f)); ImGuiHelpers.ScaledDummy(2f);
ImGui.TextUnformatted("Suggested Permissions"); ImGui.TextUnformatted("Suggested Permissions");
ImGui.Dummy(new(2f)); ImGuiHelpers.ScaledDummy(2f);
UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableSounds(), inline: false); UiSharedService.BooleanToColoredIcon(!_groupFullInfoDto.GroupPermissions.IsPreferDisableSounds(), inline: false);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale); ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);

View File

@@ -69,22 +69,20 @@ public class DrawFolderTag : DrawFolderBase
protected override float DrawIcon() protected override float DrawIcon()
{ {
using (ImRaii.PushFont(UiBuilder.IconFont)) var icon = _id switch
{ {
var icon = _id switch TagHandler.CustomUnpairedTag => FontAwesomeIcon.ArrowsLeftRight,
{ TagHandler.CustomOnlineTag => FontAwesomeIcon.Link,
TagHandler.CustomUnpairedTag => FontAwesomeIcon.ArrowsLeftRight.ToIconString(), TagHandler.CustomOfflineTag => FontAwesomeIcon.Unlink,
TagHandler.CustomOnlineTag => FontAwesomeIcon.Link.ToIconString(), TagHandler.CustomOfflineSyncshellTag => FontAwesomeIcon.Unlink,
TagHandler.CustomOfflineTag => FontAwesomeIcon.Unlink.ToIconString(), TagHandler.CustomVisibleTag => FontAwesomeIcon.Eye,
TagHandler.CustomOfflineSyncshellTag => FontAwesomeIcon.Unlink.ToIconString(), TagHandler.CustomAllTag => FontAwesomeIcon.User,
TagHandler.CustomVisibleTag => FontAwesomeIcon.Eye.ToIconString(), _ => FontAwesomeIcon.Folder
TagHandler.CustomAllTag => FontAwesomeIcon.User.ToIconString(), };
_ => FontAwesomeIcon.Folder.ToIconString()
}; ImGui.AlignTextToFramePadding();
UiSharedService.NormalizedIcon(icon);
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(icon);
}
if (RenderCount) if (RenderCount)
{ {
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f })) using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f }))

View File

@@ -1,8 +1,10 @@
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using ImGuiNET; using ImGuiNET;
using MareSynchronos.UI.Handlers; using MareSynchronos.UI.Handlers;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Numerics;
namespace MareSynchronos.UI.Components; namespace MareSynchronos.UI.Components;
@@ -27,24 +29,28 @@ public class DrawGroupedGroupFolder : IDrawFolder
string _id = "__folder_syncshells"; string _id = "__folder_syncshells";
using var id = ImRaii.PushId(_id); using var id = ImRaii.PushId(_id);
ImGui.Dummy(new Vector2(0f, ImGui.GetFrameHeight()));
ImGui.SameLine();
var icon = _tagHandler.IsTagOpen(_id) ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight; var icon = _tagHandler.IsTagOpen(_id) ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight;
UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont); UiSharedService.NormalizedIcon(icon);
if (ImGui.IsItemClicked()) if (ImGui.IsItemClicked())
{ {
_tagHandler.SetTagOpen(_id, !_tagHandler.IsTagOpen(_id)); _tagHandler.SetTagOpen(_id, !_tagHandler.IsTagOpen(_id));
} }
ImGui.SameLine(); ImGui.SameLine();
using (ImRaii.PushFont(UiBuilder.IconFont)) UiSharedService.NormalizedIcon(FontAwesomeIcon.UsersRectangle);
ImGui.TextUnformatted(FontAwesomeIcon.UsersRectangle.ToIconString());
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f })) using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f }))
{ {
ImGui.SameLine(); ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]"); ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]");
} }
UiSharedService.AttachToolTip(OnlinePairs + " online in all of your joined syncshells" + Environment.NewLine + UiSharedService.AttachToolTip(OnlinePairs + " online in all of your joined syncshells" + Environment.NewLine +
TotalPairs + " pairs combined in all of your joined syncshells"); TotalPairs + " pairs combined in all of your joined syncshells");
ImGui.SameLine(); ImGui.SameLine();
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("All Syncshells"); ImGui.TextUnformatted("All Syncshells");
ImGui.Separator(); ImGui.Separator();

View File

@@ -189,30 +189,31 @@ public class DrawUserPair
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
using var font = ImRaii.PushFont(UiBuilder.IconFont); //using var font = ImRaii.PushFont(UiBuilder.IconFont);
ImGui.TextUnformatted(FontAwesomeIcon.PauseCircle.ToIconString()); UiSharedService.NormalizedIcon(FontAwesomeIcon.PauseCircle);
userPairText = _pair.UserData.AliasOrUID + " is paused"; userPairText = _pair.UserData.AliasOrUID + " is paused";
ImGui.SameLine();
} }
else if (!_pair.IsOnline) else if (!_pair.IsOnline)
{ {
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed); using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
using var font = ImRaii.PushFont(UiBuilder.IconFont); UiSharedService.NormalizedIcon(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.OneSided
ImGui.TextUnformatted(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.OneSided ? FontAwesomeIcon.ArrowsLeftRight
? FontAwesomeIcon.ArrowsLeftRight.ToIconString()
: (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional : (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional
? FontAwesomeIcon.User.ToIconString() : FontAwesomeIcon.Users.ToIconString())); ? FontAwesomeIcon.User : FontAwesomeIcon.Users));
userPairText = _pair.UserData.AliasOrUID + " is offline"; userPairText = _pair.UserData.AliasOrUID + " is offline";
ImGui.SameLine();
} }
else else
{ {
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
using var font = ImRaii.PushFont(UiBuilder.IconFont);
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen); using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen);
ImGui.TextUnformatted(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional UiSharedService.NormalizedIcon(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional
? FontAwesomeIcon.User.ToIconString() : FontAwesomeIcon.Users.ToIconString()); ? FontAwesomeIcon.User : FontAwesomeIcon.Users);
userPairText = _pair.UserData.AliasOrUID + " is online"; userPairText = _pair.UserData.AliasOrUID + " is online";
ImGui.SameLine();
} }
if (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.OneSided) if (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.OneSided)
@@ -241,31 +242,22 @@ public class DrawUserPair
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
if (string.Equals(_currentGroup.OwnerUID, _pair.UserData.UID, StringComparison.Ordinal)) if (string.Equals(_currentGroup.OwnerUID, _pair.UserData.UID, StringComparison.Ordinal))
{ {
using (ImRaii.PushFont(UiBuilder.IconFont)) ImGui.SameLine();
{ UiSharedService.NormalizedIcon(FontAwesomeIcon.Crown);
ImGui.SameLine();
ImGui.TextUnformatted(FontAwesomeIcon.Crown.ToIconString());
}
UiSharedService.AttachToolTip("User is owner of this syncshell"); UiSharedService.AttachToolTip("User is owner of this syncshell");
} }
else if (_currentGroup.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var userinfo)) else if (_currentGroup.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var userinfo))
{ {
if (userinfo.IsModerator()) if (userinfo.IsModerator())
{ {
using (ImRaii.PushFont(UiBuilder.IconFont)) ImGui.SameLine();
{ UiSharedService.NormalizedIcon(FontAwesomeIcon.UserShield);
ImGui.SameLine();
ImGui.TextUnformatted(FontAwesomeIcon.UserShield.ToIconString());
}
UiSharedService.AttachToolTip("User is moderator in this syncshell"); UiSharedService.AttachToolTip("User is moderator in this syncshell");
} }
else if (userinfo.IsPinned()) else if (userinfo.IsPinned())
{ {
using (ImRaii.PushFont(UiBuilder.IconFont)) ImGui.SameLine();
{ UiSharedService.NormalizedIcon(FontAwesomeIcon.Thumbtack);
ImGui.SameLine();
ImGui.TextUnformatted(FontAwesomeIcon.Thumbtack.ToIconString());
}
UiSharedService.AttachToolTip("User is pinned in this syncshell"); UiSharedService.AttachToolTip("User is pinned in this syncshell");
} }
} }
@@ -273,32 +265,26 @@ public class DrawUserPair
if (_pair.UserPair.OwnPermissions.IsSticky()) if (_pair.UserPair.OwnPermissions.IsSticky())
{ {
ImGui.SameLine();
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X * 3 / 4f })) using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X * 3 / 4f }))
using (ImRaii.PushFont(UiBuilder.IconFont)) UiSharedService.NormalizedIcon(FontAwesomeIcon.ArrowCircleUp);
{
ImGui.SameLine();
ImGui.TextUnformatted(FontAwesomeIcon.ArrowCircleUp.ToIconString());
}
UiSharedService.AttachToolTip(_pair.UserData.AliasOrUID + " has preferred permissions enabled"); UiSharedService.AttachToolTip(_pair.UserData.AliasOrUID + " has preferred permissions enabled");
} }
if (_pair.IsVisible) if (_pair.IsVisible)
{ {
ImGui.SameLine();
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X * 3 / 4f })) using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X * 3 / 4f }))
using (ImRaii.PushFont(UiBuilder.IconFont)) UiSharedService.NormalizedIcon(FontAwesomeIcon.Eye, ImGuiColors.ParsedGreen);
{
ImGui.SameLine();
using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.ParsedGreen);
ImGui.TextUnformatted(FontAwesomeIcon.Eye.ToIconString());
}
UiSharedService.AttachToolTip("User is visible: " + _pair.PlayerName); UiSharedService.AttachToolTip("User is visible: " + _pair.PlayerName);
} }
ImGui.SameLine();
} }
private void DrawName(float leftSide, float rightSide) private void DrawName(float leftSide, float rightSide)
@@ -352,7 +338,7 @@ public class DrawUserPair
{ {
var infoIconPosDist = windowEndX - barButtonSize.X - spacingX - pauseIconSize.X - spacingX; var infoIconPosDist = windowEndX - barButtonSize.X - spacingX - pauseIconSize.X - spacingX;
var icon = FontAwesomeIcon.InfoCircle; var icon = FontAwesomeIcon.InfoCircle;
var iconwidth = UiSharedService.GetIconSize(icon); var iconwidth = UiSharedService.GetNormalizedIconSize(icon);
infoIconDist = iconwidth.X; infoIconDist = iconwidth.X;
ImGui.SameLine(infoIconPosDist - iconwidth.X); ImGui.SameLine(infoIconPosDist - iconwidth.X);

View File

@@ -1,5 +1,6 @@
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Components; using Dalamud.Interface.Components;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using ImGuiNET; using ImGuiNET;
using MareSynchronos.API.Data.Extensions; using MareSynchronos.API.Data.Extensions;
@@ -64,7 +65,7 @@ public class CreateSyncshellUI : WindowMediatorSubscriberBase
"- You can own up to " + _apiController.ServerInfo.MaxGroupsCreatedByUser + " Syncshells on this server." + Environment.NewLine + "- You can own up to " + _apiController.ServerInfo.MaxGroupsCreatedByUser + " Syncshells on this server." + Environment.NewLine +
"- You can join up to " + _apiController.ServerInfo.MaxGroupsJoinedByUser + " Syncshells on this server (including your own)" + Environment.NewLine + "- You can join up to " + _apiController.ServerInfo.MaxGroupsJoinedByUser + " Syncshells on this server (including your own)" + Environment.NewLine +
"- Syncshells on this server can have a maximum of " + _apiController.ServerInfo.MaxGroupUserCount + " users"); "- Syncshells on this server can have a maximum of " + _apiController.ServerInfo.MaxGroupUserCount + " users");
ImGui.Dummy(new(2f)); ImGuiHelpers.ScaledDummy(2f);
ImGui.TextUnformatted("Your current Syncshell preferred permissions are:"); ImGui.TextUnformatted("Your current Syncshell preferred permissions are:");
ImGui.TextUnformatted("- Animations"); ImGui.TextUnformatted("- Animations");
UiSharedService.BooleanToColoredIcon(!_apiController.DefaultPermissions!.DisableGroupAnimations); UiSharedService.BooleanToColoredIcon(!_apiController.DefaultPermissions!.DisableGroupAnimations);
@@ -88,7 +89,7 @@ public class CreateSyncshellUI : WindowMediatorSubscriberBase
UiSharedService.TextWrapped("You can change the Syncshell password later at any time."); UiSharedService.TextWrapped("You can change the Syncshell password later at any time.");
ImGui.Separator(); ImGui.Separator();
UiSharedService.TextWrapped("These settings were set based on your preferred syncshell permissions:"); UiSharedService.TextWrapped("These settings were set based on your preferred syncshell permissions:");
ImGui.Dummy(new(2f)); ImGuiHelpers.ScaledDummy(2f);
UiSharedService.TextWrapped("Suggest Animation sync:"); UiSharedService.TextWrapped("Suggest Animation sync:");
UiSharedService.BooleanToColoredIcon(!_lastCreatedGroup.GroupUserPreferredPermissions.IsDisableAnimations()); UiSharedService.BooleanToColoredIcon(!_lastCreatedGroup.GroupUserPreferredPermissions.IsDisableAnimations());
UiSharedService.TextWrapped("Suggest Sounds sync:"); UiSharedService.TextWrapped("Suggest Sounds sync:");

View File

@@ -1,4 +1,5 @@
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using ImGuiNET; using ImGuiNET;
using MareSynchronos.API.Data.Enum; using MareSynchronos.API.Data.Enum;
@@ -91,7 +92,7 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
else else
{ {
ImGui.TextUnformatted("You are about to join the Syncshell " + _groupJoinInfo.GroupAliasOrGID + " by " + _groupJoinInfo.OwnerAliasOrUID); ImGui.TextUnformatted("You are about to join the Syncshell " + _groupJoinInfo.GroupAliasOrGID + " by " + _groupJoinInfo.OwnerAliasOrUID);
ImGui.Dummy(new(2)); ImGuiHelpers.ScaledDummy(2f);
ImGui.TextUnformatted("This Syncshell staff has set the following suggested Syncshell permissions:"); ImGui.TextUnformatted("This Syncshell staff has set the following suggested Syncshell permissions:");
ImGui.TextUnformatted("- Sounds "); ImGui.TextUnformatted("- Sounds ");
UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableSounds()); UiSharedService.BooleanToColoredIcon(!_groupJoinInfo.GroupPermissions.IsPreferDisableSounds());
@@ -104,7 +105,7 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
|| _groupJoinInfo.GroupPermissions.IsPreferDisableVFX() != _ownPermissions.DisableGroupVFX || _groupJoinInfo.GroupPermissions.IsPreferDisableVFX() != _ownPermissions.DisableGroupVFX
|| _groupJoinInfo.GroupPermissions.IsPreferDisableAnimations() != _ownPermissions.DisableGroupAnimations) || _groupJoinInfo.GroupPermissions.IsPreferDisableAnimations() != _ownPermissions.DisableGroupAnimations)
{ {
ImGui.Dummy(new(2)); ImGuiHelpers.ScaledDummy(2f);
UiSharedService.ColorText("Your current preferred default Syncshell permissions deviate from the suggested permissions:", ImGuiColors.DalamudYellow); UiSharedService.ColorText("Your current preferred default Syncshell permissions deviate from the suggested permissions:", ImGuiColors.DalamudYellow);
if (_groupJoinInfo.GroupPermissions.IsPreferDisableSounds() != _ownPermissions.DisableGroupSounds) if (_groupJoinInfo.GroupPermissions.IsPreferDisableSounds() != _ownPermissions.DisableGroupSounds)
{ {
@@ -157,7 +158,7 @@ internal class JoinSyncshellUI : WindowMediatorSubscriberBase
{ {
UiSharedService.TextWrapped("Your default syncshell permissions on joining are in line with the suggested Syncshell permissions through the owner."); UiSharedService.TextWrapped("Your default syncshell permissions on joining are in line with the suggested Syncshell permissions through the owner.");
} }
ImGui.Dummy(new(2)); ImGuiHelpers.ScaledDummy(2f);
if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Plus, "Finalize and join " + _groupJoinInfo.GroupAliasOrGID)) if (UiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Plus, "Finalize and join " + _groupJoinInfo.GroupAliasOrGID))
{ {
GroupUserPreferredPermissions joinPermissions = GroupUserPreferredPermissions.NoneSet; GroupUserPreferredPermissions joinPermissions = GroupUserPreferredPermissions.NoneSet;

View File

@@ -114,11 +114,11 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
using (ImRaii.PushFont(_uiSharedService.UidFont, _uiSharedService.UidFontBuilt)) using (ImRaii.PushFont(_uiSharedService.UidFont, _uiSharedService.UidFontBuilt))
UiSharedService.ColorText(_pair.UserData.AliasOrUID, ImGuiColors.HealerGreen); UiSharedService.ColorText(_pair.UserData.AliasOrUID, ImGuiColors.HealerGreen);
ImGui.Dummy(new(spacing.Y, spacing.Y)); ImGuiHelpers.ScaledDummy(spacing.Y, spacing.Y);
var textPos = ImGui.GetCursorPosY(); var textPos = ImGui.GetCursorPosY();
ImGui.Separator(); ImGui.Separator();
var imagePos = ImGui.GetCursorPos(); var imagePos = ImGui.GetCursorPos();
ImGui.Dummy(new(256, 256 * ImGuiHelpers.GlobalScale + spacing.Y)); ImGuiHelpers.ScaledDummy(256, 256 * ImGuiHelpers.GlobalScale + spacing.Y);
var note = _serverManager.GetNoteForUid(_pair.UserData.UID); var note = _serverManager.GetNoteForUid(_pair.UserData.UID);
if (!string.IsNullOrEmpty(note)) if (!string.IsNullOrEmpty(note))
{ {

View File

@@ -1,5 +1,6 @@
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using Dalamud.Utility; using Dalamud.Utility;
using ImGuiNET; using ImGuiNET;
@@ -476,7 +477,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.TextUnformatted("The file compactor is only available on Windows."); ImGui.TextUnformatted("The file compactor is only available on Windows.");
} }
ImGui.Dummy(new Vector2(10, 10)); ImGuiHelpers.ScaledDummy(new Vector2(10, 10));
ImGui.TextUnformatted("To clear the local storage accept the following disclaimer"); ImGui.TextUnformatted("To clear the local storage accept the following disclaimer");
ImGui.Indent(); ImGui.Indent();
ImGui.Checkbox("##readClearCache", ref _readClearCache); ImGui.Checkbox("##readClearCache", ref _readClearCache);
@@ -865,7 +866,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
var idx = _uiShared.DrawServiceSelection(); var idx = _uiShared.DrawServiceSelection();
ImGui.Dummy(new Vector2(10, 10)); ImGuiHelpers.ScaledDummy(new Vector2(10, 10));
var selectedServer = _serverConfigurationManager.GetServerByIndex(idx); var selectedServer = _serverConfigurationManager.GetServerByIndex(idx);
if (selectedServer == _serverConfigurationManager.CurrentServer) if (selectedServer == _serverConfigurationManager.CurrentServer)
@@ -1056,7 +1057,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
{ {
UiSharedService.TextWrapped("Note: The default permissions settings here are not applied retroactively to existing pairs or joined Syncshells."); UiSharedService.TextWrapped("Note: The default permissions settings here are not applied retroactively to existing pairs or joined Syncshells.");
UiSharedService.TextWrapped("Note: The default permissions settings here are sent and stored on the connected service."); UiSharedService.TextWrapped("Note: The default permissions settings here are sent and stored on the connected service.");
ImGui.Dummy(new(5f)); ImGuiHelpers.ScaledDummy(5f);
var perms = _apiController.DefaultPermissions!; var perms = _apiController.DefaultPermissions!;
bool individualIsSticky = perms.IndividualIsSticky; bool individualIsSticky = perms.IndividualIsSticky;
bool disableIndividualSounds = perms.DisableIndividualSounds; bool disableIndividualSounds = perms.DisableIndividualSounds;
@@ -1075,7 +1076,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
" - All individually set permissions for any pair will also automatically become preferred permissions. This includes pairs in Syncshells." + Environment.NewLine + Environment.NewLine + " - All individually set permissions for any pair will also automatically become preferred permissions. This includes pairs in Syncshells." + Environment.NewLine + Environment.NewLine +
"It is possible to remove or set the preferred permission state for any pair at any time." + Environment.NewLine + Environment.NewLine + "It is possible to remove or set the preferred permission state for any pair at any time." + Environment.NewLine + Environment.NewLine +
"If unsure, leave this setting off."); "If unsure, leave this setting off.");
ImGui.Dummy(new(3f)); ImGuiHelpers.ScaledDummy(3f);
if (ImGui.Checkbox("Disable individual pair sounds", ref disableIndividualSounds)) if (ImGui.Checkbox("Disable individual pair sounds", ref disableIndividualSounds))
{ {
@@ -1095,7 +1096,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_ = _apiController.UserUpdateDefaultPermissions(perms); _ = _apiController.UserUpdateDefaultPermissions(perms);
} }
UiSharedService.DrawHelpText("This setting will disable VFX sync for all new individual pairs."); UiSharedService.DrawHelpText("This setting will disable VFX sync for all new individual pairs.");
ImGui.Dummy(new(5f)); ImGuiHelpers.ScaledDummy(5f);
bool disableGroundSounds = perms.DisableGroupSounds; bool disableGroundSounds = perms.DisableGroupSounds;
bool disableGroupAnimations = perms.DisableGroupAnimations; bool disableGroupAnimations = perms.DisableGroupAnimations;
bool disableGroupVFX = perms.DisableGroupVFX; bool disableGroupVFX = perms.DisableGroupVFX;

View File

@@ -1,5 +1,6 @@
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using ImGuiNET; using ImGuiNET;
using MareSynchronos.API.Data.Extensions; using MareSynchronos.API.Data.Extensions;
@@ -77,7 +78,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
_ = _apiController.GroupChangeGroupPermissionState(new(GroupFullInfo.Group, perm)); _ = _apiController.GroupChangeGroupPermissionState(new(GroupFullInfo.Group, perm));
} }
ImGui.Dummy(new(2f)); ImGuiHelpers.ScaledDummy(2f);
UiSharedService.TextWrapped("One-time invites work as single-use passwords. Use those if you do not want to distribute your Syncshell password."); UiSharedService.TextWrapped("One-time invites work as single-use passwords. Use those if you do not want to distribute your Syncshell password.");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Envelope, "Single one-time invite")) if (UiSharedService.IconTextButton(FontAwesomeIcon.Envelope, "Single one-time invite"))
@@ -116,7 +117,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
} }
UiSharedService.AttachToolTip("This will remove all non-pinned, non-moderator users from the Syncshell"); UiSharedService.AttachToolTip("This will remove all non-pinned, non-moderator users from the Syncshell");
ImGui.Dummy(new(2f)); ImGuiHelpers.ScaledDummy(2f);
if (UiSharedService.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server")) if (UiSharedService.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
{ {

View File

@@ -174,7 +174,6 @@ public class TopTabMenu
if (TabSelection != SelectedTab.None) ImGuiHelpers.ScaledDummy(3f); if (TabSelection != SelectedTab.None) ImGuiHelpers.ScaledDummy(3f);
ImGui.Separator(); ImGui.Separator();
ImGuiHelpers.ScaledDummy(1f);
} }
private void DrawAddPair(float availableXWidth, float spacingX) private void DrawAddPair(float availableXWidth, float spacingX)

View File

@@ -310,13 +310,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
return buttonSize; return buttonSize;
} }
public static Vector2 GetIconSize(FontAwesomeIcon icon)
{
using var font = ImRaii.PushFont(UiBuilder.IconFont);
var iconSize = ImGui.CalcTextSize(icon.ToIconString());
return iconSize;
}
public static string GetNotes(List<Pair> pairs) public static string GetNotes(List<Pair> pairs)
{ {
StringBuilder sb = new(); StringBuilder sb = new();
@@ -416,6 +409,77 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
return wasClicked; return wasClicked;
} }
public static Vector2 GetIconSize(FontAwesomeIcon icon)
{
if (_iconCacheDict.TryGetValue(ImGuiHelpers.GlobalScale, out var iconCache))
{
if (iconCache.TryGetValue(icon, out var size)) return size;
iconCache[icon] = CalcIconSize(icon);
return iconCache[icon];
}
_iconCacheDict.Add(ImGuiHelpers.GlobalScale, new());
return _iconCacheDict[ImGuiHelpers.GlobalScale][icon] = CalcIconSize(icon);
}
private static Vector2 CalcIconSize(FontAwesomeIcon icon)
{
using var font = ImRaii.PushFont(UiBuilder.IconFont);
var iconSize = ImGui.CalcTextSize(icon.ToIconString());
return iconSize;
}
public static (float xOffset, float scaling) GetIconScaling(FontAwesomeIcon icon)
{
var iconSize = GetIconSize(icon);
return (iconSize.X < iconSize.Y ? (iconSize.Y - iconSize.X) / 2f : 0f, iconSize.X > iconSize.Y ? 1f / (iconSize.X / iconSize.Y) : 1f);
}
private static Vector2 CalcIconScale(FontAwesomeIcon icon)
{
var iconSize = GetIconSize(icon);
var (iconXoffset, iconScaling) = GetIconScaling(icon);
return new((iconSize.X * iconScaling) + (iconXoffset * 2),
(iconSize.X * iconScaling) + (iconXoffset * 2));
}
public static Vector2 GetNormalizedIconSize(FontAwesomeIcon icon)
{
if (_iconCacheDict.TryGetValue(ImGuiHelpers.GlobalScale, out var iconCache))
{
if (iconCache.TryGetValue(icon, out var size)) return size;
return iconCache[icon] = CalcIconScale(icon);
}
_iconCacheDict.Add(ImGuiHelpers.GlobalScale, new());
return _iconCacheDict[ImGuiHelpers.GlobalScale][icon] = CalcIconScale(icon);
}
public static void NormalizedIcon(FontAwesomeIcon icon, Vector4? color = null)
{
var cursorPos = ImGui.GetCursorPos();
var iconSize = GetIconSize(icon);
var normalizedIconSize = GetNormalizedIconSize(icon);
var drawList = ImGui.GetWindowDrawList();
var windowPos = ImGui.GetWindowPos();
var scrollPosX = ImGui.GetScrollX();
var scrollPosY = ImGui.GetScrollY();
var frameHeight = ImGui.GetFrameHeight();
var (iconXoffset, iconScaling) = GetIconScaling(icon);
var frameOffsetY = ((frameHeight - iconSize.Y * iconScaling) / 2f);
drawList.AddText(UiBuilder.IconFont, ImGui.GetFontSize() * iconScaling,
new(windowPos.X - scrollPosX + cursorPos.X + iconXoffset,
windowPos.Y - scrollPosY + cursorPos.Y + frameOffsetY),
color != null ? ImGui.GetColorU32(color.Value) : ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString());
ImGui.Dummy(new(normalizedIconSize.X, ImGui.GetFrameHeight()));
}
private static Dictionary<float, Dictionary<FontAwesomeIcon, Vector2>> _normalizedIconScales = new();
private static Dictionary<float, Dictionary<FontAwesomeIcon, Vector2>> _iconCacheDict = new();
public static bool IsDirectoryWritable(string dirPath, bool throwIfFails = false) public static bool IsDirectoryWritable(string dirPath, bool throwIfFails = false)
{ {
try try