 b2276a1883
			
		
	
	b2276a1883
	
	
	
		
			
			* most of the groups refactoring on client * register OnMethods for group stuff * start implementing client (still pretty broken) * finish implementing new api first iteration * idk rework everything for pair shit (still WIP); goal is to remove PairedClients and GroupPairClients from ApiController * move everything to PairManager, remove dictionaries from APiController * remove admin stuff from client, cleanup * adjust reconnection handling, add new settings, todo still to remove access from old stuff that's marked obsolete from config * add back adding servers, fix intro ui * fix obsolete calls * adjust config namespace * add UI for setting animation/sound permissions to syncshells * add ConfigurationService to hot reload config on change from external * move transient data cache to configuration * add deleting service to ui * fix saving of transient resources * fix group pair user assignments * halt scanner when penumbra inactive, add visible/online/offline split to individual pairs and tags * add presence to syncshell ui * move fullpause from config to server config * fixes in code style * more codestyle * show info icon on player in shells, don't show icon when no changes from default state are made, add online notifs * fixes to intro UI --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
		
			
				
	
	
		
			94 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			94 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Numerics;
 | |
| using Dalamud.Interface;
 | |
| using ImGuiNET;
 | |
| using MareSynchronos.Models;
 | |
| using MareSynchronos.UI.Handlers;
 | |
| 
 | |
| namespace MareSynchronos.UI.Components;
 | |
| 
 | |
| public class SelectPairForGroupUi
 | |
| {
 | |
|     private bool _show = false;
 | |
|     private bool _opened = false;
 | |
|     private HashSet<string> _peopleInGroup = new(StringComparer.Ordinal);
 | |
|     private string _tag = string.Empty;
 | |
|     private readonly TagHandler _tagHandler;
 | |
|     private string _filter = string.Empty;
 | |
| 
 | |
|     public SelectPairForGroupUi(TagHandler tagHandler)
 | |
|     {
 | |
|         _tagHandler = tagHandler;
 | |
|     }
 | |
| 
 | |
|     public void Open(string tag)
 | |
|     {
 | |
|         _peopleInGroup = _tagHandler.GetOtherUidsForTag(tag);
 | |
|         _tag = tag;
 | |
|         _show = true;
 | |
|     }
 | |
| 
 | |
|     public void Draw(List<Pair> pairs, Dictionary<string, bool> showUidForEntry)
 | |
|     {
 | |
|         var workHeight = ImGui.GetMainViewport().WorkSize.Y / ImGuiHelpers.GlobalScale;
 | |
|         var minSize = new Vector2(300, workHeight < 400 ? workHeight : 400) * ImGuiHelpers.GlobalScale;
 | |
|         var maxSize = new Vector2(300, 1000) * ImGuiHelpers.GlobalScale;
 | |
|         
 | |
|         var popupName = $"Choose Users for Group {_tag}";
 | |
| 
 | |
|         if (!_show)
 | |
|         {
 | |
|             _opened = false;
 | |
|         }
 | |
| 
 | |
|         if (_show && !_opened)
 | |
|         {
 | |
|             ImGui.SetNextWindowSize(minSize);
 | |
|             UiShared.CenterNextWindow(minSize.X, minSize.Y, ImGuiCond.Always);
 | |
|             ImGui.OpenPopup(popupName);
 | |
|             _opened = true;
 | |
|         }
 | |
| 
 | |
|         ImGui.SetNextWindowSizeConstraints(minSize, maxSize);
 | |
|         if (ImGui.BeginPopupModal(popupName, ref _show, ImGuiWindowFlags.Popup | ImGuiWindowFlags.Modal))
 | |
|         {
 | |
|             UiShared.FontText($"Select users for group {_tag}", UiBuilder.DefaultFont);
 | |
|             ImGui.InputTextWithHint("##filter", "Filter", ref _filter, 255, ImGuiInputTextFlags.None);
 | |
|             foreach (var item in pairs.OrderBy(p => PairName(showUidForEntry, p), StringComparer.OrdinalIgnoreCase)
 | |
|                 .Where(p => string.IsNullOrEmpty(_filter) || PairName(showUidForEntry, p).Contains(_filter, StringComparison.OrdinalIgnoreCase)).ToList())
 | |
|             {
 | |
|                 var isInGroup = _peopleInGroup.Contains(item.UserData.UID);
 | |
|                 if (ImGui.Checkbox(PairName(showUidForEntry, item), ref isInGroup))
 | |
|                 {
 | |
|                     if (isInGroup)
 | |
|                     {
 | |
|                         _tagHandler.AddTagToPairedUid(item.UserPair!, _tag);
 | |
|                         _peopleInGroup.Add(item.UserData.UID);
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         _tagHandler.RemoveTagFromPairedUid(item.UserPair!, _tag);
 | |
|                         _peopleInGroup.Remove(item.UserData.UID);
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             ImGui.EndPopup();
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             _filter = string.Empty;
 | |
|             _show = false;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private string PairName(Dictionary<string, bool> showUidForEntry, Pair pair)
 | |
|     {
 | |
|         showUidForEntry.TryGetValue(pair.UserData.UID, out var showUidInsteadOfName);
 | |
|         var playerText = pair.GetNote();
 | |
|         if (showUidInsteadOfName || string.IsNullOrEmpty(playerText))
 | |
|         {
 | |
|             playerText = pair.UserData.AliasOrUID;
 | |
|         }
 | |
|         return playerText;
 | |
|     }
 | |
| }
 |