 14575a4a6b
			
		
	
	14575a4a6b
	
	
	
		
			
			* add jwt expiry * start of 0.9 api impl * some stuff idk * some more impl * some cleanup * remove grouppair, add configuration, rework some pair drawing stuff * do some stuff * rework some ui * I don't even know anymore * add cancellationtoken * token bla * ui fixes etc * probably individual adding/removing now working fully as expected * add working report popup * I guess it's more syncshell shit or so * popup shit idk * work out most of the syncshell bullshit I guess * delete some old crap * are we actually getting closer to the end * update pair info stuff * more fixes/adjustments, idk * refactor some things * some rework * some more cleanup * cleanup * make menu buttons w i d e * better icon text buttons * add all syncshell folder and ordering fixes --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
		
			
				
	
	
		
			492 lines
		
	
	
		
			23 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			492 lines
		
	
	
		
			23 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Dalamud.Interface;
 | |
| using Dalamud.Interface.Colors;
 | |
| using Dalamud.Interface.Components;
 | |
| using Dalamud.Interface.Utility;
 | |
| using Dalamud.Interface.Utility.Raii;
 | |
| using ImGuiNET;
 | |
| using MareSynchronos.API.Data.Extensions;
 | |
| using MareSynchronos.API.Dto.Group;
 | |
| using MareSynchronos.API.Dto.User;
 | |
| using MareSynchronos.PlayerData.Pairs;
 | |
| using MareSynchronos.Services.Mediator;
 | |
| using MareSynchronos.Services.ServerConfiguration;
 | |
| using MareSynchronos.UI.Handlers;
 | |
| using MareSynchronos.WebAPI;
 | |
| 
 | |
| namespace MareSynchronos.UI.Components;
 | |
| 
 | |
| public class DrawUserPair
 | |
| {
 | |
|     protected readonly ApiController _apiController;
 | |
|     protected readonly IdDisplayHandler _displayHandler;
 | |
|     protected readonly MareMediator _mediator;
 | |
|     protected readonly List<GroupFullInfoDto> _syncedGroups;
 | |
|     protected Pair _pair;
 | |
|     private readonly string _id;
 | |
|     private readonly SelectTagForPairUi _selectTagForPairUi;
 | |
|     private readonly ServerConfigurationManager _serverConfigurationManager;
 | |
|     private float _menuRenderWidth = -1;
 | |
| 
 | |
|     public DrawUserPair(string id, Pair entry, List<GroupFullInfoDto> syncedGroups,
 | |
|         ApiController apiController, IdDisplayHandler uIDDisplayHandler,
 | |
|         MareMediator mareMediator, SelectTagForPairUi selectTagForPairUi,
 | |
|         ServerConfigurationManager serverConfigurationManager)
 | |
|     {
 | |
|         _id = id;
 | |
|         _pair = entry;
 | |
|         _syncedGroups = syncedGroups;
 | |
|         _apiController = apiController;
 | |
|         _displayHandler = uIDDisplayHandler;
 | |
|         _mediator = mareMediator;
 | |
|         _selectTagForPairUi = selectTagForPairUi;
 | |
|         _serverConfigurationManager = serverConfigurationManager;
 | |
|     }
 | |
| 
 | |
|     public Pair Pair => _pair;
 | |
|     public string UID => _pair.UserData.UID;
 | |
|     public UserFullPairDto UserPair => _pair.UserPair!;
 | |
| 
 | |
|     public void DrawPairedClient()
 | |
|     {
 | |
|         using var id = ImRaii.PushId(GetType() + _id);
 | |
|         var originalY = ImGui.GetCursorPosY();
 | |
|         var pauseIconSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
 | |
|         var textSize = ImGui.CalcTextSize(_pair.UserData.AliasOrUID);
 | |
| 
 | |
|         var textPosY = originalY + pauseIconSize.Y / 2 - textSize.Y / 2;
 | |
|         DrawLeftSide(textPosY);
 | |
|         ImGui.SameLine();
 | |
|         var posX = ImGui.GetCursorPosX();
 | |
|         var rightSide = DrawRightSide(originalY);
 | |
|         DrawName(originalY, posX, rightSide);
 | |
|     }
 | |
| 
 | |
|     private void DrawCommonClientMenu()
 | |
|     {
 | |
|         if (!_pair.IsPaused)
 | |
|         {
 | |
|             if (UiSharedService.IconTextButton(FontAwesomeIcon.User, "Open Profile", _menuRenderWidth, true))
 | |
|             {
 | |
|                 _displayHandler.OpenProfile(_pair);
 | |
|                 ImGui.CloseCurrentPopup();
 | |
|             }
 | |
|             UiSharedService.AttachToolTip("Opens the profile for this user in a new window");
 | |
|         }
 | |
|         if (_pair.IsVisible)
 | |
|         {
 | |
|             if (UiSharedService.IconTextButton(FontAwesomeIcon.Sync, "Reload last data", _menuRenderWidth, true))
 | |
|             {
 | |
|                 _pair.ApplyLastReceivedData(forced: true);
 | |
|                 ImGui.CloseCurrentPopup();
 | |
|             }
 | |
|             UiSharedService.AttachToolTip("This reapplies the last received character data to this character");
 | |
|         }
 | |
| 
 | |
|         if (UiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Cycle pause state", _menuRenderWidth, true))
 | |
|         {
 | |
|             _ = _apiController.CyclePause(_pair.UserData);
 | |
|             ImGui.CloseCurrentPopup();
 | |
|         }
 | |
|         ImGui.Separator();
 | |
| 
 | |
|         ImGui.TextUnformatted("Pair Permission Functions");
 | |
|         var isSticky = _pair.UserPair!.OwnPermissions.IsSticky();
 | |
|         string stickyText = isSticky ? "Disable Preferred Permissions" : "Enable Preferred Permissions";
 | |
|         var stickyIcon = isSticky ? FontAwesomeIcon.ArrowCircleDown : FontAwesomeIcon.ArrowCircleUp;
 | |
|         if (UiSharedService.IconTextButton(stickyIcon, stickyText, _menuRenderWidth, true))
 | |
|         {
 | |
|             var permissions = _pair.UserPair.OwnPermissions;
 | |
|             permissions.SetSticky(!isSticky);
 | |
|             _ = _apiController.UserSetPairPermissions(new(_pair.UserData, permissions));
 | |
|         }
 | |
|         UiSharedService.AttachToolTip("Preferred permissions means that this pair will not" + Environment.NewLine + " be affected by any syncshell permission changes through you.");
 | |
| 
 | |
|         string individualText = Environment.NewLine + Environment.NewLine + "Note: changing this permission will turn the permissions for this"
 | |
|             + Environment.NewLine + "user to preferred permissions. You can change this behavior"
 | |
|             + Environment.NewLine + "in the permission settings.";
 | |
|         bool individual = !_pair.IsDirectlyPaired && _apiController.DefaultPermissions!.IndividualIsSticky;
 | |
| 
 | |
|         var isDisableSounds = _pair.UserPair!.OwnPermissions.IsDisableSounds();
 | |
|         string disableSoundsText = isDisableSounds ? "Enable sound sync" : "Disable sound sync";
 | |
|         var disableSoundsIcon = isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute;
 | |
|         if (UiSharedService.IconTextButton(disableSoundsIcon, disableSoundsText, _menuRenderWidth, true))
 | |
|         {
 | |
|             var permissions = _pair.UserPair.OwnPermissions;
 | |
|             permissions.SetDisableSounds(!isDisableSounds);
 | |
|             _ = _apiController.UserSetPairPermissions(new UserPermissionsDto(_pair.UserData, permissions));
 | |
|         }
 | |
|         UiSharedService.AttachToolTip("Changes sound sync permissions with this user." + (individual ? individualText : string.Empty));
 | |
| 
 | |
|         var isDisableAnims = _pair.UserPair!.OwnPermissions.IsDisableAnimations();
 | |
|         string disableAnimsText = isDisableAnims ? "Enable animation sync" : "Disable animation sync";
 | |
|         var disableAnimsIcon = isDisableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop;
 | |
|         if (UiSharedService.IconTextButton(disableAnimsIcon, disableAnimsText, _menuRenderWidth, true))
 | |
|         {
 | |
|             var permissions = _pair.UserPair.OwnPermissions;
 | |
|             permissions.SetDisableAnimations(!isDisableAnims);
 | |
|             _ = _apiController.UserSetPairPermissions(new UserPermissionsDto(_pair.UserData, permissions));
 | |
|         }
 | |
|         UiSharedService.AttachToolTip("Changes animation sync permissions with this user." + (individual ? individualText : string.Empty));
 | |
| 
 | |
|         var isDisableVFX = _pair.UserPair!.OwnPermissions.IsDisableVFX();
 | |
|         string disableVFXText = isDisableVFX ? "Enable VFX sync" : "Disable VFX sync";
 | |
|         var disableVFXIcon = isDisableVFX ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle;
 | |
|         if (UiSharedService.IconTextButton(disableVFXIcon, disableVFXText, _menuRenderWidth, true))
 | |
|         {
 | |
|             var permissions = _pair.UserPair.OwnPermissions;
 | |
|             permissions.SetDisableVFX(!isDisableVFX);
 | |
|             _ = _apiController.UserSetPairPermissions(new UserPermissionsDto(_pair.UserData, permissions));
 | |
|         }
 | |
|         UiSharedService.AttachToolTip("Changes VFX sync permissions with this user." + (individual ? individualText : string.Empty));
 | |
| 
 | |
|         if (!_pair.IsPaused)
 | |
|         {
 | |
|             ImGui.Separator();
 | |
|             ImGui.TextUnformatted("Pair reporting");
 | |
|             if (UiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Report Mare Profile", _menuRenderWidth, true))
 | |
|             {
 | |
|                 ImGui.CloseCurrentPopup();
 | |
|                 _mediator.Publish(new OpenReportPopupMessage(_pair));
 | |
|             }
 | |
|             UiSharedService.AttachToolTip("Report this users Mare Profile to the administrative team.");
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void DrawIndividualMenu()
 | |
|     {
 | |
|         ImGui.TextUnformatted("Individual Pair Functions");
 | |
|         var entryUID = _pair.UserData.AliasOrUID;
 | |
| 
 | |
|         if (_pair.IndividualPairStatus != API.Data.Enum.IndividualPairStatus.None)
 | |
|         {
 | |
|             if (UiSharedService.IconTextButton(FontAwesomeIcon.Folder, "Pair Groups", _menuRenderWidth, true))
 | |
|             {
 | |
|                 _selectTagForPairUi.Open(_pair);
 | |
|             }
 | |
|             UiSharedService.AttachToolTip("Choose pair groups for " + entryUID);
 | |
|             if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently", _menuRenderWidth, true) && UiSharedService.CtrlPressed())
 | |
|             {
 | |
|                 _ = _apiController.UserRemovePair(new(_pair.UserData));
 | |
|             }
 | |
|             UiSharedService.AttachToolTip("Hold CTRL and click to unpair permanently from " + entryUID);
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Pair individually", _menuRenderWidth, true))
 | |
|             {
 | |
|                 _ = _apiController.UserAddPair(new(_pair.UserData));
 | |
|             }
 | |
|             UiSharedService.AttachToolTip("Pair individually with " + entryUID);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void DrawLeftSide(float textPosY)
 | |
|     {
 | |
|         string userPairText = string.Empty;
 | |
| 
 | |
|         ImGui.SetCursorPosY(textPosY);
 | |
| 
 | |
|         if (_pair.IsPaused)
 | |
|         {
 | |
|             ImGui.SetCursorPosY(textPosY);
 | |
|             using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
 | |
|             using var font = ImRaii.PushFont(UiBuilder.IconFont);
 | |
|             ImGui.TextUnformatted(FontAwesomeIcon.PauseCircle.ToIconString());
 | |
|             userPairText = _pair.UserData.AliasOrUID + " is paused";
 | |
|         }
 | |
|         else if (!_pair.IsOnline)
 | |
|         {
 | |
|             ImGui.SetCursorPosY(textPosY);
 | |
|             using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
 | |
|             using var font = ImRaii.PushFont(UiBuilder.IconFont);
 | |
|             ImGui.TextUnformatted(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional
 | |
|                 ? FontAwesomeIcon.User.ToIconString() : FontAwesomeIcon.Users.ToIconString());
 | |
|             userPairText = _pair.UserData.AliasOrUID + " is offline";
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.ParsedGreen);
 | |
|             using var font = ImRaii.PushFont(UiBuilder.IconFont);
 | |
|             ImGui.TextUnformatted(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional
 | |
|                 ? FontAwesomeIcon.User.ToIconString() : FontAwesomeIcon.Users.ToIconString());
 | |
|             userPairText = _pair.UserData.AliasOrUID + " is online";
 | |
|         }
 | |
| 
 | |
|         if (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.OneSided)
 | |
|         {
 | |
|             userPairText += UiSharedService.TooltipSeparator + "User has not added you back";
 | |
|         }
 | |
|         else if (_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional)
 | |
|         {
 | |
|             userPairText += UiSharedService.TooltipSeparator + "You are directly Paired";
 | |
|         }
 | |
| 
 | |
|         if (_syncedGroups.Any())
 | |
|         {
 | |
|             userPairText += UiSharedService.TooltipSeparator + string.Join(Environment.NewLine,
 | |
|                 _syncedGroups.Select(g =>
 | |
|                 {
 | |
|                     var groupNote = _serverConfigurationManager.GetNoteForGid(g.GID);
 | |
|                     var groupString = string.IsNullOrEmpty(groupNote) ? g.GroupAliasOrGID : $"{groupNote} ({g.GroupAliasOrGID})";
 | |
|                     return "Paired through " + groupString;
 | |
|                 }));
 | |
|         }
 | |
|         UiSharedService.AttachToolTip(userPairText);
 | |
| 
 | |
|         if (_pair.UserPair.OwnPermissions.IsSticky())
 | |
|         {
 | |
|             ImGui.SetCursorPosY(textPosY);
 | |
| 
 | |
|             using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X * 3 / 4f }))
 | |
|             using (ImRaii.PushFont(UiBuilder.IconFont))
 | |
|             {
 | |
|                 ImGui.SameLine();
 | |
|                 ImGui.TextUnformatted(FontAwesomeIcon.ArrowCircleUp.ToIconString());
 | |
|             }
 | |
| 
 | |
|             UiSharedService.AttachToolTip(_pair.UserData.AliasOrUID + " has preferred permissions enabled");
 | |
|         }
 | |
| 
 | |
|         if (_pair.IsVisible)
 | |
|         {
 | |
|             ImGui.SetCursorPosY(textPosY);
 | |
|             using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X * 3 / 4f }))
 | |
|             using (ImRaii.PushFont(UiBuilder.IconFont))
 | |
|             {
 | |
|                 ImGui.SameLine();
 | |
|                 using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.ParsedGreen);
 | |
|                 ImGui.TextUnformatted(FontAwesomeIcon.Eye.ToIconString());
 | |
|             }
 | |
| 
 | |
|             UiSharedService.AttachToolTip("User is visible: " + _pair.PlayerName);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void DrawName(float originalY, float leftSide, float rightSide)
 | |
|     {
 | |
|         _displayHandler.DrawPairText(_id, _pair, leftSide, originalY, () => rightSide - leftSide);
 | |
|     }
 | |
| 
 | |
|     private void DrawPairedClientMenu()
 | |
|     {
 | |
|         DrawIndividualMenu();
 | |
| 
 | |
|         if (_syncedGroups.Any()) ImGui.Separator();
 | |
|         foreach (var entry in _syncedGroups)
 | |
|         {
 | |
|             bool selfIsOwner = string.Equals(_apiController.UID, entry.Owner.UID, StringComparison.Ordinal);
 | |
|             bool selfIsModerator = entry.GroupUserInfo.IsModerator();
 | |
|             bool userIsModerator = entry.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var modinfo) && modinfo.IsModerator();
 | |
|             bool userIsPinned = entry.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var info) && info.IsPinned();
 | |
|             if (selfIsOwner || selfIsModerator)
 | |
|             {
 | |
|                 var groupNote = _serverConfigurationManager.GetNoteForGid(entry.GID);
 | |
|                 var groupString = string.IsNullOrEmpty(groupNote) ? entry.GroupAliasOrGID : $"{groupNote} ({entry.GroupAliasOrGID})";
 | |
| 
 | |
|                 if (ImGui.BeginMenu(groupString + " Moderation Functions"))
 | |
|                 {
 | |
|                     DrawSyncshellMenu(entry, selfIsOwner, selfIsModerator, userIsPinned, userIsModerator);
 | |
|                     ImGui.EndMenu();
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private float DrawRightSide(float originalY)
 | |
|     {
 | |
|         var pauseIcon = _pair.UserPair!.OwnPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
 | |
|         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();
 | |
|         var rightSideStart = 0f;
 | |
|         float infoIconDist = 0f;
 | |
| 
 | |
|         if (_pair.IsPaired)
 | |
|         {
 | |
|             var individualSoundsDisabled = (_pair.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableSounds() ?? false);
 | |
|             var individualAnimDisabled = (_pair.UserPair?.OwnPermissions.IsDisableAnimations() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableAnimations() ?? false);
 | |
|             var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false);
 | |
| 
 | |
|             if (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled)
 | |
|             {
 | |
|                 var infoIconPosDist = windowEndX - barButtonSize.X - spacingX - pauseIconSize.X - spacingX;
 | |
|                 var icon = FontAwesomeIcon.InfoCircle;
 | |
|                 var iconwidth = UiSharedService.GetIconSize(icon);
 | |
| 
 | |
|                 infoIconDist = iconwidth.X;
 | |
|                 ImGui.SameLine(infoIconPosDist - iconwidth.X);
 | |
| 
 | |
|                 UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont);
 | |
|                 if (ImGui.IsItemHovered())
 | |
|                 {
 | |
|                     ImGui.BeginTooltip();
 | |
| 
 | |
|                     ImGui.TextUnformatted("Individual User permissions");
 | |
|                     ImGui.Separator();
 | |
| 
 | |
|                     if (individualSoundsDisabled)
 | |
|                     {
 | |
|                         var userSoundsText = "Sound sync";
 | |
|                         UiSharedService.FontText(FontAwesomeIcon.VolumeOff.ToIconString(), UiBuilder.IconFont);
 | |
|                         ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
 | |
|                         ImGui.TextUnformatted(userSoundsText);
 | |
|                         ImGui.NewLine();
 | |
|                         ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
 | |
|                         ImGui.TextUnformatted("You");
 | |
|                         UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableSounds());
 | |
|                         ImGui.SameLine();
 | |
|                         ImGui.TextUnformatted("They");
 | |
|                         UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableSounds());
 | |
|                     }
 | |
| 
 | |
|                     if (individualAnimDisabled)
 | |
|                     {
 | |
|                         var userAnimText = "Animation sync";
 | |
|                         UiSharedService.FontText(FontAwesomeIcon.Stop.ToIconString(), UiBuilder.IconFont);
 | |
|                         ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
 | |
|                         ImGui.TextUnformatted(userAnimText);
 | |
|                         ImGui.NewLine();
 | |
|                         ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
 | |
|                         ImGui.TextUnformatted("You");
 | |
|                         UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableAnimations());
 | |
|                         ImGui.SameLine();
 | |
|                         ImGui.TextUnformatted("They");
 | |
|                         UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableAnimations());
 | |
|                     }
 | |
| 
 | |
|                     if (individualVFXDisabled)
 | |
|                     {
 | |
|                         var userVFXText = "VFX sync";
 | |
|                         UiSharedService.FontText(FontAwesomeIcon.Circle.ToIconString(), UiBuilder.IconFont);
 | |
|                         ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
 | |
|                         ImGui.TextUnformatted(userVFXText);
 | |
|                         ImGui.NewLine();
 | |
|                         ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
 | |
|                         ImGui.TextUnformatted("You");
 | |
|                         UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OwnPermissions.IsDisableVFX());
 | |
|                         ImGui.SameLine();
 | |
|                         ImGui.TextUnformatted("They");
 | |
|                         UiSharedService.BooleanToColoredIcon(!_pair.UserPair!.OtherPermissions.IsDisableVFX());
 | |
|                     }
 | |
| 
 | |
|                     ImGui.EndTooltip();
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         rightSideStart = windowEndX - barButtonSize.X - spacingX * 3 - pauseIconSize.X - infoIconDist;
 | |
|         ImGui.SameLine(windowEndX - barButtonSize.X - spacingX - pauseIconSize.X);
 | |
|         ImGui.SetCursorPosY(originalY);
 | |
|         if (ImGuiComponents.IconButton(pauseIcon))
 | |
|         {
 | |
|             var perm = _pair.UserPair!.OwnPermissions;
 | |
|             perm.SetPaused(!perm.IsPaused());
 | |
|             _ = _apiController.UserSetPairPermissions(new(_pair.UserData, perm));
 | |
|         }
 | |
|         UiSharedService.AttachToolTip(!_pair.UserPair!.OwnPermissions.IsPaused()
 | |
|             ? "Pause pairing with " + entryUID
 | |
|             : "Resume pairing with " + entryUID);
 | |
| 
 | |
|         // Flyout Menu
 | |
|         if (rightSideStart == 0f)
 | |
|         {
 | |
|             rightSideStart = windowEndX - barButtonSize.X;
 | |
|         }
 | |
|         ImGui.SameLine(windowEndX - barButtonSize.X);
 | |
|         ImGui.SetCursorPosY(originalY);
 | |
| 
 | |
|         if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars))
 | |
|         {
 | |
|             ImGui.OpenPopup("User Flyout Menu");
 | |
|         }
 | |
|         if (ImGui.BeginPopup("User Flyout Menu"))
 | |
|         {
 | |
|             UiSharedService.DrawWithID($"buttons-{_pair.UserData.UID}", () =>
 | |
|             {
 | |
|                 ImGui.TextUnformatted("Common Pair Functions");
 | |
|                 DrawCommonClientMenu();
 | |
|                 ImGui.Separator();
 | |
|                 DrawPairedClientMenu();
 | |
|                 if (_menuRenderWidth <= 0)
 | |
|                 {
 | |
|                     _menuRenderWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X;
 | |
|                 }
 | |
|             });
 | |
| 
 | |
|             ImGui.EndPopup();
 | |
|         }
 | |
| 
 | |
|         return rightSideStart;
 | |
|     }
 | |
| 
 | |
|     private void DrawSyncshellMenu(GroupFullInfoDto group, bool selfIsOwner, bool selfIsModerator, bool userIsPinned, bool userIsModerator)
 | |
|     {
 | |
|         if (selfIsOwner || ((selfIsModerator) && (!userIsModerator)))
 | |
|         {
 | |
|             ImGui.TextUnformatted("Syncshell Moderator Functions");
 | |
|             var pinText = userIsPinned ? "Unpin user" : "Pin user";
 | |
|             if (UiSharedService.IconTextButton(FontAwesomeIcon.Thumbtack, pinText, _menuRenderWidth, true))
 | |
|             {
 | |
|                 ImGui.CloseCurrentPopup();
 | |
|                 if (!group.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var userinfo))
 | |
|                 {
 | |
|                     userinfo = API.Data.Enum.GroupPairUserInfo.IsPinned;
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     userinfo.SetPinned(!userinfo.IsPinned());
 | |
|                 }
 | |
|                 _ = _apiController.GroupSetUserInfo(new GroupPairUserInfoDto(group.Group, _pair.UserData, userinfo));
 | |
|             }
 | |
|             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", _menuRenderWidth, true) && UiSharedService.CtrlPressed())
 | |
|             {
 | |
|                 ImGui.CloseCurrentPopup();
 | |
|                 _ = _apiController.GroupRemoveUser(new(group.Group, _pair.UserData));
 | |
|             }
 | |
|             UiSharedService.AttachToolTip("Hold CTRL and click to remove user " + (_pair.UserData.AliasOrUID) + " from Syncshell");
 | |
| 
 | |
|             if (UiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User", _menuRenderWidth, true))
 | |
|             {
 | |
|                 _mediator.Publish(new OpenBanUserPopupMessage(_pair, group));
 | |
|                 ImGui.CloseCurrentPopup();
 | |
|             }
 | |
|             UiSharedService.AttachToolTip("Ban user from this Syncshell");
 | |
| 
 | |
|             ImGui.Separator();
 | |
|         }
 | |
| 
 | |
|         if (selfIsOwner)
 | |
|         {
 | |
|             ImGui.TextUnformatted("Syncshell Owner Functions");
 | |
|             string modText = userIsModerator ? "Demod user" : "Mod user";
 | |
|             if (UiSharedService.IconTextButton(FontAwesomeIcon.UserShield, modText, _menuRenderWidth, true) && UiSharedService.CtrlPressed())
 | |
|             {
 | |
|                 ImGui.CloseCurrentPopup();
 | |
|                 if (!group.GroupPairUserInfos.TryGetValue(_pair.UserData.UID, out var userinfo))
 | |
|                 {
 | |
|                     userinfo = API.Data.Enum.GroupPairUserInfo.IsModerator;
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     userinfo.SetModerator(!userinfo.IsModerator());
 | |
|                 }
 | |
| 
 | |
|                 _ = _apiController.GroupSetUserInfo(new GroupPairUserInfoDto(group.Group, _pair.UserData, userinfo));
 | |
|             }
 | |
|             UiSharedService.AttachToolTip("Hold CTRL to change the moderator status for " + (_pair.UserData.AliasOrUID) + Environment.NewLine +
 | |
|                 "Moderators can kick, ban/unban, pin/unpin users and clear the Syncshell.");
 | |
| 
 | |
|             if (UiSharedService.IconTextButton(FontAwesomeIcon.Crown, "Transfer Ownership", _menuRenderWidth, true) && UiSharedService.CtrlPressed() && UiSharedService.ShiftPressed())
 | |
|             {
 | |
|                 ImGui.CloseCurrentPopup();
 | |
|                 _ = _apiController.GroupChangeOwnership(new(group.Group, _pair.UserData));
 | |
|             }
 | |
|             UiSharedService.AttachToolTip("Hold CTRL and SHIFT and click to transfer ownership of this Syncshell to "
 | |
|                 + (_pair.UserData.AliasOrUID) + Environment.NewLine + "WARNING: This action is irreversible.");
 | |
|         }
 | |
|     }
 | |
| } |