Merge tag '0.9.17' into mare-classic

* tag '0.9.17':
  add census popup on connection
  api update
  census update
  heave fewer redraws as main method for data application, minor fixes
  remove unnecessary exists check
  add visibility for loaded mods size for pair, use menu bar for settings, remove settings button
  fix staging issues
  add download throttling, change header of mare, fix reverting players when going offline/paused when not visible
  use name for glamourer revert
  fix startup breaking
  add inner exception stacktraces
  calc correct button size
  wording
  add permission popup ui
  fix getting identifier during zoning
  indent nonscaled
  remove unnecessary usings
  ui icon boogaloo
  fix cache dict wtf
  add normalized icons
  add owner/moderator/pinned user icons
  check tokentime more precisely in both directions
  more cleanup
  fix sorting and cleanup
  make local groups more usable for pause/resume
  fix outlined font
  rework creation of popout windows into factory and some refactoring in general
  make syncshell admin ui to standalone window
  remove close button on intro ui
  do not allow to open main ui without finishing setup
  readonly bla
  wait for plugin disposal
  fix palette
  wording
  fix palette application and add experimental less redraws option
  some minor fixes
  check for timezone
  idk
  adjust token handling
  fix total user count in syncshell (distinct by UIDs)
  fix text alignment
  fix some shit maybe
  idk some fixes I guess
  fix offset for transfer bar at the bottom, use async collections, clear filter on tab change + add button to clear, require ctrl for align syncshells
  blah
  Some display options for DTR tooltip (#66)
  add ordering
  adjust api to latest
  rework main ui
  add total count on mouseover, make syncshell windows non-blocking
  fix token for character change, add online count to syncshells and groups
  argh
  fix broken font in header
  add more options for the compactui
  fix icons and text of buttons being static in place
  remove logspam
This commit is contained in:
Loporrit
2023-12-08 13:44:18 +00:00
54 changed files with 1646 additions and 743 deletions

View File

@@ -18,7 +18,6 @@ namespace MareSynchronos.UI.Components;
public class DrawGroupPair : DrawPairBase
{
protected readonly MareMediator _mediator;
private static string _banReason = string.Empty;
private readonly GroupPairFullInfoDto _fullInfoDto;
private readonly GroupFullInfoDto _group;
@@ -248,7 +247,7 @@ public class DrawGroupPair : DrawPairBase
if ((userIsModerator || userIsOwner) && !(entryIsMod || entryIsOwner))
{
var pinText = entryIsPinned ? "Unpin user" : "Pin user";
if (UiSharedService.IconTextButton(FontAwesomeIcon.Thumbtack, pinText))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Thumbtack, pinText))
{
ImGui.CloseCurrentPopup();
var userInfo = _fullInfoDto.GroupPairStatusInfo ^ GroupUserInfo.IsPinned;
@@ -256,14 +255,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.IconTextButton(FontAwesomeIcon.Trash, "Remove user") && UiSharedService.CtrlPressed())
if (UiSharedService.NormalizedIconTextButton(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.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
{
ImGui.CloseCurrentPopup();
_mediator.Publish(new OpenBanUserPopupMessage(_pair, _group));
@@ -274,7 +273,7 @@ public class DrawGroupPair : DrawPairBase
if (userIsOwner)
{
string modText = entryIsMod ? "Demod user" : "Mod user";
if (UiSharedService.IconTextButton(FontAwesomeIcon.UserShield, modText) && UiSharedService.CtrlPressed())
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserShield, modText) && UiSharedService.CtrlPressed())
{
ImGui.CloseCurrentPopup();
var userInfo = _fullInfoDto.GroupPairStatusInfo ^ GroupUserInfo.IsModerator;
@@ -282,7 +281,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.IconTextButton(FontAwesomeIcon.Crown, "Transfer Ownership") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Crown, "Transfer Ownership") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
{
ImGui.CloseCurrentPopup();
_ = _apiController.GroupChangeOwnership(_fullInfoDto);
@@ -293,13 +292,13 @@ public class DrawGroupPair : DrawPairBase
ImGui.Separator();
if (!_pair.IsPaused)
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.User, "Open Profile"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.User, "Open Profile"))
{
_displayHandler.OpenProfile(_pair);
ImGui.CloseCurrentPopup();
}
UiSharedService.AttachToolTip("Opens the profile for this user in a new window");
if (UiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Report Mare Profile"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ExclamationTriangle, "Report Mare Profile"))
{
ImGui.CloseCurrentPopup();
_mediator.Publish(new OpenReportPopupMessage(_pair));

View File

@@ -1,5 +1,6 @@
using Dalamud.Interface.Colors;
using Dalamud.Interface.Components;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface;
using ImGuiNET;
using MareSynchronos.PlayerData.Pairs;
@@ -66,7 +67,13 @@ public class DrawUserPair : DrawPairBase
ImGui.PushFont(UiBuilder.IconFont);
UiSharedService.ColorText(FontAwesomeIcon.Eye.ToIconString(), ImGuiColors.ParsedGreen);
ImGui.PopFont();
UiSharedService.AttachToolTip(_pair.UserData.AliasOrUID + " is visible: " + _pair.PlayerName!);
var visibleTooltip = _pair.UserData.AliasOrUID + " is visible: " + _pair.PlayerName!;
if (_pair.LastAppliedDataSize >= 0)
{
visibleTooltip += UiSharedService.TooltipSeparator +
"Loaded Mods Size: " + UiSharedService.ByteToString(_pair.LastAppliedDataSize, true);
}
UiSharedService.AttachToolTip(visibleTooltip);
}
}
@@ -90,7 +97,7 @@ public class DrawUserPair : DrawPairBase
{
var infoIconPosDist = windowEndX - barButtonSize.X - spacingX - pauseIconSize.X - spacingX;
var icon = FontAwesomeIcon.ExclamationTriangle;
var iconwidth = UiSharedService.GetIconSize(icon);
var iconwidth = UiSharedService.GetIconButtonSize(icon);
rightSideStart = infoIconPosDist - iconwidth.X;
ImGui.SameLine(infoIconPosDist - iconwidth.X);
@@ -172,7 +179,7 @@ public class DrawUserPair : DrawPairBase
}
if (ImGui.BeginPopup("User Flyout Menu"))
{
UiSharedService.DrawWithID($"buttons-{_pair.UserData.UID}", () => DrawPairedClientMenu(_pair));
using (ImRaii.PushId($"buttons-{_pair.UserData.UID}")) DrawPairedClientMenu(_pair);
ImGui.EndPopup();
}
@@ -183,7 +190,7 @@ public class DrawUserPair : DrawPairBase
{
if (!entry.IsPaused)
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.User, "Open Profile"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.User, "Open Profile"))
{
_displayHandler.OpenProfile(entry);
ImGui.CloseCurrentPopup();
@@ -192,7 +199,7 @@ public class DrawUserPair : DrawPairBase
}
if (entry.IsVisible)
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.Sync, "Reload last data"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Sync, "Reload last data"))
{
entry.ApplyLastReceivedData(forced: true);
ImGui.CloseCurrentPopup();
@@ -200,13 +207,13 @@ public class DrawUserPair : DrawPairBase
UiSharedService.AttachToolTip("This reapplies the last received character data to this character");
}
if (UiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Cycle pause state"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.PlayCircle, "Cycle pause state"))
{
_ = _apiController.CyclePause(entry.UserData);
ImGui.CloseCurrentPopup();
}
var entryUID = entry.UserData.AliasOrUID;
if (UiSharedService.IconTextButton(FontAwesomeIcon.Folder, "Pair Groups"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Folder, "Pair Groups"))
{
_selectGroupForPairUi.Open(entry);
}
@@ -215,7 +222,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.IconTextButton(disableSoundsIcon, disableSoundsText))
if (UiSharedService.NormalizedIconTextButton(disableSoundsIcon, disableSoundsText))
{
var permissions = entry.UserPair.OwnPermissions;
permissions.SetDisableSounds(!isDisableSounds);
@@ -225,7 +232,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.IconTextButton(disableAnimsIcon, disableAnimsText))
if (UiSharedService.NormalizedIconTextButton(disableAnimsIcon, disableAnimsText))
{
var permissions = entry.UserPair.OwnPermissions;
permissions.SetDisableAnimations(!isDisableAnims);
@@ -235,14 +242,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.IconTextButton(disableVFXIcon, disableVFXText))
if (UiSharedService.NormalizedIconTextButton(disableVFXIcon, disableVFXText))
{
var permissions = entry.UserPair.OwnPermissions;
permissions.SetDisableVFX(!isDisableVFX);
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(entry.UserData, permissions));
}
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently") && UiSharedService.CtrlPressed())
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently") && UiSharedService.CtrlPressed())
{
_ = _apiController.UserRemovePair(new(entry.UserData));
}
@@ -251,7 +258,7 @@ public class DrawUserPair : DrawPairBase
ImGui.Separator();
if (!entry.IsPaused)
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Report Mare Profile"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ExclamationTriangle, "Report Mare Profile"))
{
ImGui.CloseCurrentPopup();
_mediator.Publish(new OpenReportPopupMessage(_pair));

View File

@@ -1,4 +1,5 @@
using Dalamud.Interface.Components;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface;
using Dalamud.Utility;
using ImGuiNET;
@@ -62,8 +63,8 @@ internal sealed class GroupPanel
public void DrawSyncshells()
{
UiSharedService.DrawWithID("addsyncshell", DrawAddSyncshell);
UiSharedService.DrawWithID("syncshelllist", DrawSyncshellList);
using (ImRaii.PushId("addsyncshell")) DrawAddSyncshell();
using (ImRaii.PushId("syncshelllist")) DrawSyncshellList();
_mainUi.TransferPartHeight = ImGui.GetCursorPosY();
}
@@ -265,7 +266,7 @@ internal sealed class GroupPanel
}
else
{
var buttonSizes = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X + UiSharedService.GetIconSize(FontAwesomeIcon.LockOpen).X;
var buttonSizes = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X + UiSharedService.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))
{
@@ -280,7 +281,8 @@ internal sealed class GroupPanel
UiSharedService.AttachToolTip("Hit ENTER to save\nRight click to cancel");
}
UiSharedService.DrawWithID(groupDto.GID + "settings", () => DrawSyncShellButtons(groupDto, pairsInGroup));
using (ImRaii.PushId(groupDto.GID + "settings")) DrawSyncShellButtons(groupDto, pairsInGroup);
if (_showModalBanList && !_modalBanListOpened)
{
@@ -292,7 +294,7 @@ internal sealed class GroupPanel
if (ImGui.BeginPopupModal("Manage Banlist for " + groupDto.GID, ref _showModalBanList, UiSharedService.PopupWindowFlags))
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
{
_bannedUsers = ApiController.GroupGetBannedUsers(groupDto).Result;
}
@@ -321,7 +323,7 @@ internal sealed class GroupPanel
ImGui.TableNextColumn();
UiSharedService.TextWrapped(bannedUser.Reason);
ImGui.TableNextColumn();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Check, "Unban#" + bannedUser.UID))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Check, "Unban#" + bannedUser.UID))
{
_ = ApiController.GroupUnbanUser(bannedUser);
_bannedUsers.RemoveAll(b => string.Equals(b.UID, bannedUser.UID, StringComparison.Ordinal));
@@ -382,7 +384,7 @@ internal sealed class GroupPanel
{
ImGui.SetNextItemWidth(-1);
ImGui.SliderInt("Amount##bulkinvites", ref _bulkInviteCount, 1, 100);
if (UiSharedService.IconTextButton(FontAwesomeIcon.MailBulk, "Create invites"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.MailBulk, "Create invites"))
{
_bulkOneTimeInvites = ApiController.GroupCreateTempInvite(groupDto, _bulkInviteCount).Result;
}
@@ -390,7 +392,7 @@ internal sealed class GroupPanel
else
{
UiSharedService.TextWrapped("A total of " + _bulkOneTimeInvites.Count + " invites have been created.");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Copy, "Copy invites to clipboard"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Copy, "Copy invites to clipboard"))
{
ImGui.SetClipboardText(string.Join(Environment.NewLine, _bulkOneTimeInvites));
}
@@ -434,7 +436,7 @@ internal sealed class GroupPanel
ImGui.Separator();
foreach (var entry in visibleUsers)
{
UiSharedService.DrawWithID(groupDto.GID + entry.UID, () => entry.DrawPairedClient());
using (ImRaii.PushId(groupDto.GID + entry.UID)) entry.DrawPairedClient();
}
}
@@ -444,7 +446,7 @@ internal sealed class GroupPanel
ImGui.Separator();
foreach (var entry in onlineUsers)
{
UiSharedService.DrawWithID(groupDto.GID + entry.UID, () => entry.DrawPairedClient());
using (ImRaii.PushId(groupDto.GID + entry.UID)) entry.DrawPairedClient();
}
}
@@ -454,7 +456,7 @@ internal sealed class GroupPanel
ImGui.Separator();
foreach (var entry in offlineUsers)
{
UiSharedService.DrawWithID(groupDto.GID + entry.UID, () => entry.DrawPairedClient());
using (ImRaii.PushId(groupDto.GID + entry.UID)) entry.DrawPairedClient();
}
}
@@ -487,8 +489,8 @@ internal sealed class GroupPanel
var userSoundsIcon = userSoundsDisabled ? FontAwesomeIcon.VolumeOff : FontAwesomeIcon.VolumeUp;
var userVFXIcon = userVFXDisabled ? FontAwesomeIcon.Circle : FontAwesomeIcon.Sun;
var iconSize = UiSharedService.GetIconSize(infoIcon);
var diffLockUnlockIcons = showInfoIcon ? (UiSharedService.GetIconSize(infoIcon).X - iconSize.X) / 2 : 0;
var iconSize = UiSharedService.GetIconButtonSize(infoIcon);
var diffLockUnlockIcons = showInfoIcon ? (UiSharedService.GetIconButtonSize(infoIcon).X - iconSize.X) / 2 : 0;
var barbuttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
var isOwner = string.Equals(groupDto.OwnerUID, ApiController.UID, StringComparison.Ordinal);
@@ -583,21 +585,21 @@ internal sealed class GroupPanel
if (ImGui.BeginPopup("ShellPopup"))
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.ArrowCircleLeft, "Leave Syncshell") && UiSharedService.CtrlPressed())
if (UiSharedService.NormalizedIconTextButton(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.IconTextButton(FontAwesomeIcon.Copy, "Copy ID"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Copy, "Copy ID"))
{
ImGui.CloseCurrentPopup();
ImGui.SetClipboardText(groupDto.GroupAliasOrGID);
}
UiSharedService.AttachToolTip("Copy Syncshell ID to Clipboard");
if (UiSharedService.IconTextButton(FontAwesomeIcon.StickyNote, "Copy Notes"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.StickyNote, "Copy Notes"))
{
ImGui.CloseCurrentPopup();
ImGui.SetClipboardText(UiSharedService.GetNotes(groupPairs));
@@ -605,7 +607,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 -> Privacy -> Import Notes from Clipboard");
var soundsText = userSoundsDisabled ? "Enable sound sync" : "Disable sound sync";
if (UiSharedService.IconTextButton(userSoundsIcon, soundsText))
if (UiSharedService.NormalizedIconTextButton(userSoundsIcon, soundsText))
{
ImGui.CloseCurrentPopup();
var perm = groupDto.GroupUserPermissions;
@@ -618,7 +620,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.IconTextButton(userAnimIcon, animText))
if (UiSharedService.NormalizedIconTextButton(userAnimIcon, animText))
{
ImGui.CloseCurrentPopup();
var perm = groupDto.GroupUserPermissions;
@@ -632,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 vfxText = userVFXDisabled ? "Enable VFX sync" : "Disable VFX sync";
if (UiSharedService.IconTextButton(userVFXIcon, vfxText))
if (UiSharedService.NormalizedIconTextButton(userVFXIcon, vfxText))
{
ImGui.CloseCurrentPopup();
var perm = groupDto.GroupUserPermissions;
@@ -648,10 +650,10 @@ internal sealed class GroupPanel
if (isOwner || groupDto.GroupUserInfo.IsModerator())
{
ImGui.Separator();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Cog, "Open Admin Panel"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Cog, "Open Admin Panel"))
{
ImGui.CloseCurrentPopup();
_mainUi.Mediator.Publish(new OpenSyncshellAdminPanelPopupMessage(groupDto));
_mainUi.Mediator.Publish(new OpenSyncshellAdminPanel(groupDto));
}
}
@@ -667,7 +669,7 @@ internal sealed class GroupPanel
ImGui.BeginChild("list", new Vector2(_mainUi.WindowContentWidth, ySize), border: false);
foreach (var entry in _pairManager.GroupPairs.OrderBy(g => g.Key.Group.AliasOrGID, StringComparer.OrdinalIgnoreCase).ToList())
{
UiSharedService.DrawWithID(entry.Key.Group.GID, () => DrawSyncshell(entry.Key, entry.Value));
using (ImRaii.PushId(entry.Key.Group.GID)) DrawSyncshell(entry.Key, entry.Value);
}
ImGui.EndChild();
}

View File

@@ -1,5 +1,6 @@
using Dalamud.Interface;
using Dalamud.Interface.Components;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.MareConfiguration;
@@ -81,7 +82,7 @@ public class PairGroupsUi
if (ImGui.BeginPopup("Group Flyout Menu"))
{
UiSharedService.DrawWithID($"buttons-{tag}", () => DrawGroupMenu(tag));
using (ImRaii.PushId($"buttons-{tag}")) DrawGroupMenu(tag);
ImGui.EndPopup();
}
}
@@ -113,7 +114,7 @@ public class PairGroupsUi
{
if (onlineUsers.Any() && onlineUsers.First() is DrawUserPair)
{
UiSharedService.DrawWithID($"group-{tag}-buttons", () => DrawButtons(tag, allUsers.Cast<DrawUserPair>().Where(p => otherUidsTaggedWithTag!.Contains(p.UID)).ToList()));
using (ImRaii.PushId($"group-{tag}-buttons")) DrawButtons(tag, allUsers.Cast<DrawUserPair>().Where(p => otherUidsTaggedWithTag!.Contains(p.UID)).ToList());
}
}
@@ -126,13 +127,13 @@ public class PairGroupsUi
private void DrawGroupMenu(string tag)
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.Users, "Add people to " + tag))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Users, "Add people to " + tag))
{
_selectGroupForPairUi.Open(tag);
}
UiSharedService.AttachToolTip($"Add more users to Group {tag}");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete " + tag) && UiSharedService.CtrlPressed())
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Trash, "Delete " + tag) && UiSharedService.CtrlPressed())
{
_tagHandler.RemoveTag(tag);
}
@@ -183,7 +184,7 @@ public class PairGroupsUi
// These are all the OtherUIDs that are tagged with this tag
foreach (var pair in availablePairsInThisCategory)
{
UiSharedService.DrawWithID($"tag-{tag}-pair-${pair.UID}", () => pair.DrawPairedClient());
using (ImRaii.PushId($"tag-{tag}-pair-${pair.UID}")) pair.DrawPairedClient();
}
ImGui.Separator();
}
@@ -192,33 +193,33 @@ public class PairGroupsUi
{
if (_mareConfig.Current.ShowVisibleUsersSeparately)
{
UiSharedService.DrawWithID("$group-VisibleCustomTag", () => DrawCategory(TagHandler.CustomVisibleTag, visibleUsers, allUsers));
using (ImRaii.PushId("$group-VisibleCustomTag")) DrawCategory(TagHandler.CustomVisibleTag, visibleUsers, allUsers);
}
foreach (var tag in tagsWithPairsInThem)
{
if (_mareConfig.Current.ShowOfflineUsersSeparately)
{
UiSharedService.DrawWithID($"group-{tag}", () => DrawCategory(tag, onlineUsers, allUsers, visibleUsers));
using (ImRaii.PushId($"group-{tag}")) DrawCategory(tag, onlineUsers, allUsers, visibleUsers);
}
else
{
UiSharedService.DrawWithID($"group-{tag}", () => DrawCategory(tag, onlineUsers.Concat(offlineUsers).ToList(), allUsers, visibleUsers));
using (ImRaii.PushId($"group-{tag}")) DrawCategory(tag, onlineUsers.Concat(offlineUsers).ToList(), allUsers, visibleUsers);
}
}
if (_mareConfig.Current.ShowOfflineUsersSeparately)
{
UiSharedService.DrawWithID($"group-OnlineCustomTag", () => DrawCategory(TagHandler.CustomOnlineTag,
onlineUsers.Where(u => !_tagHandler.HasAnyTag(u.UID)).ToList(), allUsers));
UiSharedService.DrawWithID($"group-OfflineCustomTag", () => DrawCategory(TagHandler.CustomOfflineTag,
offlineUsers.Where(u => u.UserPair!.OtherPermissions.IsPaired()).ToList(), allUsers));
using (ImRaii.PushId($"group-OnlineCustomTag")) DrawCategory(TagHandler.CustomOnlineTag,
onlineUsers.Where(u => !_tagHandler.HasAnyTag(u.UID)).ToList(), allUsers);
using (ImRaii.PushId($"group-OfflineCustomTag")) DrawCategory(TagHandler.CustomOfflineTag,
offlineUsers.Where(u => u.UserPair!.OtherPermissions.IsPaired()).ToList(), allUsers);
}
else
{
UiSharedService.DrawWithID($"group-OnlineCustomTag", () => DrawCategory(TagHandler.CustomOnlineTag,
onlineUsers.Concat(offlineUsers).Where(u => u.UserPair!.OtherPermissions.IsPaired() && !_tagHandler.HasAnyTag(u.UID)).ToList(), allUsers));
using (ImRaii.PushId($"group-OnlineCustomTag")) DrawCategory(TagHandler.CustomOnlineTag,
onlineUsers.Concat(offlineUsers).Where(u => u.UserPair!.OtherPermissions.IsPaired() && !_tagHandler.HasAnyTag(u.UID)).ToList(), allUsers);
}
UiSharedService.DrawWithID($"group-UnpairedCustomTag", () => DrawCategory(TagHandler.CustomUnpairedTag,
offlineUsers.Where(u => !u.UserPair!.OtherPermissions.IsPaired()).ToList(), allUsers));
using (ImRaii.PushId($"group-UnpairedCustomTag")) DrawCategory(TagHandler.CustomUnpairedTag,
offlineUsers.Where(u => !u.UserPair!.OtherPermissions.IsPaired()).ToList(), allUsers);
}
private void PauseRemainingPairs(List<DrawUserPair> availablePairs)

View File

@@ -27,7 +27,7 @@ public class BanUserPopupHandler : IPopupHandler
UiSharedService.TextWrapped("User " + (_reportedPair.UserData.AliasOrUID) + " will be banned and removed from this Syncshell.");
ImGui.InputTextWithHint("##banreason", "Ban Reason", ref _banReason, 255);
if (UiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
{
ImGui.CloseCurrentPopup();
var reason = _banReason;
@@ -37,6 +37,10 @@ public class BanUserPopupHandler : IPopupHandler
UiSharedService.TextWrapped("The reason will be displayed in the banlist. The current server-side alias if present (Vanity ID) will automatically be attached to the reason.");
}
public void OnClose()
{
}
public void Open(OpenBanUserPopupMessage message)
{
_reportedPair = message.PairToBan;

View File

@@ -7,4 +7,6 @@ public interface IPopupHandler
Vector2 PopupSize { get; }
void DrawContent();
void OnClose();
}

View File

@@ -1,4 +1,5 @@
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using MareSynchronos.Services.Mediator;
@@ -43,15 +44,6 @@ public class PopupHandler : WindowMediatorSubscriberBase
((BanUserPopupHandler)_currentHandler).Open(msg);
IsOpen = true;
});
Mediator.Subscribe<OpenSyncshellAdminPanelPopupMessage>(this, (msg) =>
{
IsOpen = true;
_openPopup = true;
_currentHandler = _handlers.OfType<SyncshellAdminPopupHandler>().Single();
((SyncshellAdminPopupHandler)_currentHandler).Open(msg.GroupInfo);
IsOpen = true;
});
}
public override void Draw()
@@ -65,15 +57,22 @@ public class PopupHandler : WindowMediatorSubscriberBase
}
var viewportSize = ImGui.GetWindowViewport().Size;
ImGui.SetNextWindowSize(_currentHandler!.PopupSize);
ImGui.SetNextWindowSize(_currentHandler!.PopupSize * ImGuiHelpers.GlobalScale);
ImGui.SetNextWindowPos(viewportSize / 2, ImGuiCond.Always, new Vector2(0.5f));
using var popup = ImRaii.Popup(WindowName, ImGuiWindowFlags.Modal);
if (!popup) return;
_currentHandler.DrawContent();
ImGui.Separator();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Times, "Close"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.Times, "Close"))
{
ImGui.CloseCurrentPopup();
_currentHandler.OnClose();
}
}
public override void OnClose()
{
base.OnClose();
_currentHandler?.OnClose();
}
}

View File

@@ -40,7 +40,7 @@ internal class ReportPopupHandler : IPopupHandler
using (ImRaii.Disabled(string.IsNullOrEmpty(_reportReason)))
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Send Report"))
if (UiSharedService.NormalizedIconTextButton(FontAwesomeIcon.ExclamationTriangle, "Send Report"))
{
ImGui.CloseCurrentPopup();
var reason = _reportReason;
@@ -49,6 +49,10 @@ internal class ReportPopupHandler : IPopupHandler
}
}
public void OnClose()
{
}
public void Open(OpenReportPopupMessage msg)
{
_reportedPair = msg.PairToReport;

View File

@@ -1,232 +0,0 @@
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.API.Dto.Group;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.WebAPI;
using System.Globalization;
using System.Numerics;
namespace MareSynchronos.UI.Components.Popup;
internal class SyncshellAdminPopupHandler : IPopupHandler
{
private readonly ApiController _apiController;
private readonly List<string> _oneTimeInvites = [];
private readonly PairManager _pairManager;
private readonly UiSharedService _uiSharedService;
private List<BannedGroupUserDto> _bannedUsers = [];
private GroupFullInfoDto _groupFullInfo = null!;
private bool _isModerator = false;
private bool _isOwner = false;
private int _multiInvites = 30;
private string _newPassword = string.Empty;
private bool _pwChangeSuccess = true;
public SyncshellAdminPopupHandler(ApiController apiController, UiSharedService uiSharedService, PairManager pairManager)
{
_apiController = apiController;
_uiSharedService = uiSharedService;
_pairManager = pairManager;
}
public Vector2 PopupSize => new(700, 500);
public void DrawContent()
{
if (!_isModerator && !_isOwner) return;
_groupFullInfo = _pairManager.Groups[_groupFullInfo.Group];
using (ImRaii.PushFont(_uiSharedService.UidFont))
ImGui.TextUnformatted(_groupFullInfo.GroupAliasOrGID + " Administrative Panel");
ImGui.Separator();
var perm = _groupFullInfo.GroupPermissions;
var inviteNode = ImRaii.TreeNode("Invites");
if (inviteNode)
{
bool isInvitesDisabled = perm.IsDisableInvites();
if (UiSharedService.IconTextButton(isInvitesDisabled ? FontAwesomeIcon.Unlock : FontAwesomeIcon.Lock,
isInvitesDisabled ? "Unlock Syncshell" : "Lock Syncshell"))
{
perm.SetDisableInvites(!isInvitesDisabled);
_ = _apiController.GroupChangeGroupPermissionState(new(_groupFullInfo.Group, perm));
}
ImGui.Dummy(new(2f));
UiSharedService.TextWrapped("One-time invites work as single-use passwords. Use those if you do not want to distribute your Syncshell password.");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Envelope, "Single one-time invite"))
{
ImGui.SetClipboardText(_apiController.GroupCreateTempInvite(new(_groupFullInfo.Group), 1).Result.FirstOrDefault() ?? string.Empty);
}
UiSharedService.AttachToolTip("Creates a single-use password for joining the syncshell which is valid for 24h and copies it to the clipboard.");
ImGui.InputInt("##amountofinvites", ref _multiInvites);
ImGui.SameLine();
using (ImRaii.Disabled(_multiInvites <= 1 || _multiInvites > 100))
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.Envelope, "Generate " + _multiInvites + " one-time invites"))
{
_oneTimeInvites.AddRange(_apiController.GroupCreateTempInvite(new(_groupFullInfo.Group), _multiInvites).Result);
}
}
if (_oneTimeInvites.Any())
{
var invites = string.Join(Environment.NewLine, _oneTimeInvites);
ImGui.InputTextMultiline("Generated Multi Invites", ref invites, 5000, new(0, 0), ImGuiInputTextFlags.ReadOnly);
if (UiSharedService.IconTextButton(FontAwesomeIcon.Copy, "Copy Invites to clipboard"))
{
ImGui.SetClipboardText(invites);
}
}
}
inviteNode.Dispose();
var mgmtNode = ImRaii.TreeNode("User Management");
if (mgmtNode)
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.Broom, "Clear Syncshell"))
{
_ = _apiController.GroupClear(new(_groupFullInfo.Group));
}
UiSharedService.AttachToolTip("This will remove all non-pinned, non-moderator users from the Syncshell");
ImGui.Dummy(new(2f));
if (UiSharedService.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
{
_bannedUsers = _apiController.GroupGetBannedUsers(new GroupDto(_groupFullInfo.Group)).Result;
}
if (ImGui.BeginTable("bannedusertable" + _groupFullInfo.GID, 6, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.ScrollY))
{
ImGui.TableSetupColumn("UID", ImGuiTableColumnFlags.None, 1);
ImGui.TableSetupColumn("Alias", ImGuiTableColumnFlags.None, 1);
ImGui.TableSetupColumn("By", ImGuiTableColumnFlags.None, 1);
ImGui.TableSetupColumn("Date", ImGuiTableColumnFlags.None, 2);
ImGui.TableSetupColumn("Reason", ImGuiTableColumnFlags.None, 3);
ImGui.TableSetupColumn("Actions", ImGuiTableColumnFlags.None, 1);
ImGui.TableHeadersRow();
foreach (var bannedUser in _bannedUsers.ToList())
{
ImGui.TableNextColumn();
ImGui.TextUnformatted(bannedUser.UID);
ImGui.TableNextColumn();
ImGui.TextUnformatted(bannedUser.UserAlias ?? string.Empty);
ImGui.TableNextColumn();
ImGui.TextUnformatted(bannedUser.BannedBy);
ImGui.TableNextColumn();
ImGui.TextUnformatted(bannedUser.BannedOn.ToLocalTime().ToString(CultureInfo.CurrentCulture));
ImGui.TableNextColumn();
UiSharedService.TextWrapped(bannedUser.Reason);
ImGui.TableNextColumn();
if (UiSharedService.IconTextButton(FontAwesomeIcon.Check, "Unban#" + bannedUser.UID))
{
_ = _apiController.GroupUnbanUser(bannedUser);
_bannedUsers.RemoveAll(b => string.Equals(b.UID, bannedUser.UID, StringComparison.Ordinal));
}
}
ImGui.EndTable();
}
}
mgmtNode.Dispose();
var permNode = ImRaii.TreeNode("Permissions");
if (permNode)
{
bool isDisableAnimations = perm.IsDisableAnimations();
bool isDisableSounds = perm.IsDisableSounds();
bool isDisableVfx = perm.IsDisableVFX();
ImGui.AlignTextToFramePadding();
ImGui.Text("Sound Sync");
UiSharedService.BooleanToColoredIcon(!isDisableSounds);
ImGui.SameLine(230);
if (UiSharedService.IconTextButton(isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute,
isDisableSounds ? "Enable sound sync" : "Disable sound sync"))
{
perm.SetDisableSounds(!perm.IsDisableSounds());
_ = _apiController.GroupChangeGroupPermissionState(new(_groupFullInfo.Group, perm));
}
ImGui.AlignTextToFramePadding();
ImGui.Text("Animation Sync");
UiSharedService.BooleanToColoredIcon(!isDisableAnimations);
ImGui.SameLine(230);
if (UiSharedService.IconTextButton(isDisableAnimations ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop,
isDisableAnimations ? "Enable animation sync" : "Disable animation sync"))
{
perm.SetDisableAnimations(!perm.IsDisableAnimations());
_ = _apiController.GroupChangeGroupPermissionState(new(_groupFullInfo.Group, perm));
}
ImGui.AlignTextToFramePadding();
ImGui.Text("VFX Sync");
UiSharedService.BooleanToColoredIcon(!isDisableVfx);
ImGui.SameLine(230);
if (UiSharedService.IconTextButton(isDisableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle,
isDisableVfx ? "Enable VFX sync" : "Disable VFX sync"))
{
perm.SetDisableVFX(!perm.IsDisableVFX());
_ = _apiController.GroupChangeGroupPermissionState(new(_groupFullInfo.Group, perm));
}
}
permNode.Dispose();
if (_isOwner)
{
var ownerNode = ImRaii.TreeNode("Owner Settings");
if (ownerNode)
{
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("New Password");
ImGui.SameLine();
ImGui.InputTextWithHint("##changepw", "Min 10 characters", ref _newPassword, 50);
ImGui.SameLine();
using (ImRaii.Disabled(_newPassword.Length < 10))
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.Passport, "Change Password"))
{
_pwChangeSuccess = _apiController.GroupChangePassword(new GroupPasswordDto(_groupFullInfo.Group, _newPassword)).Result;
_newPassword = string.Empty;
}
}
UiSharedService.AttachToolTip("Password requires to be at least 10 characters long. This action is irreversible.");
if (!_pwChangeSuccess)
{
UiSharedService.ColorTextWrapped("Failed to change the password. Password requires to be at least 10 characters long.", ImGuiColors.DalamudYellow);
}
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete Syncshell") && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
{
ImGui.CloseCurrentPopup();
_ = _apiController.GroupDelete(new(_groupFullInfo.Group));
}
UiSharedService.AttachToolTip("Hold CTRL and Shift and click to delete this Syncshell." + Environment.NewLine + "WARNING: this action is irreversible.");
}
ownerNode.Dispose();
}
}
public void Open(GroupFullInfoDto groupFullInfo)
{
_groupFullInfo = groupFullInfo;
_isOwner = string.Equals(_groupFullInfo.OwnerUID, _apiController.UID, StringComparison.Ordinal);
_isModerator = _groupFullInfo.GroupUserInfo.IsModerator();
_newPassword = string.Empty;
_bannedUsers.Clear();
_oneTimeInvites.Clear();
_multiInvites = 30;
_pwChangeSuccess = true;
}
}

View File

@@ -1,7 +1,7 @@
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Components;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Utility;
using ImGuiNET;
using MareSynchronos.PlayerData.Pairs;
@@ -65,14 +65,14 @@ public class SelectGroupForPairUi
{
foreach (var tag in tags)
{
UiSharedService.DrawWithID($"groups-pair-{_pair.UserData.UID}-{tag}", () => DrawGroupName(_pair, tag));
using (ImRaii.PushId($"groups-pair-{_pair.UserData.UID}-{tag}")) DrawGroupName(_pair, tag);
}
ImGui.EndChild();
}
ImGui.Separator();
UiSharedService.FontText($"Create a new group for {name}.", UiBuilder.DefaultFont);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Plus))
if (UiSharedService.NormalizedIconButton(FontAwesomeIcon.Plus))
{
HandleAddTag();
}