59 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Dalamud.Interface;
 | |
| using Dalamud.Interface.Utility.Raii;
 | |
| using ImGuiNET;
 | |
| using MareSynchronos.UI.Handlers;
 | |
| 
 | |
| namespace MareSynchronos.UI.Components;
 | |
| 
 | |
| public class DrawGroupedGroupFolder : IDrawFolder
 | |
| {
 | |
|     private readonly IEnumerable<IDrawFolder> _groups;
 | |
|     private readonly TagHandler _tagHandler;
 | |
|     public int OnlinePairs => _groups.Sum(g => g.OnlinePairs);
 | |
|     public int TotalPairs => _groups.Sum(g => g.TotalPairs);
 | |
| 
 | |
|     public DrawGroupedGroupFolder(IEnumerable<IDrawFolder> groups, TagHandler tagHandler)
 | |
|     {
 | |
|         _groups = groups;
 | |
|         _tagHandler = tagHandler;
 | |
|     }
 | |
| 
 | |
|     public void Draw()
 | |
|     {
 | |
|         if (!_groups.Any()) return;
 | |
| 
 | |
|         string _id = "__folder_syncshells";
 | |
|         using var id = ImRaii.PushId(_id);
 | |
| 
 | |
|         var icon = _tagHandler.IsTagOpen(_id) ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight;
 | |
|         UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont);
 | |
|         if (ImGui.IsItemClicked())
 | |
|         {
 | |
|             _tagHandler.SetTagOpen(_id, !_tagHandler.IsTagOpen(_id));
 | |
|         }
 | |
| 
 | |
|         ImGui.SameLine();
 | |
|         using (ImRaii.PushFont(UiBuilder.IconFont))
 | |
|             ImGui.TextUnformatted(FontAwesomeIcon.UsersRectangle.ToIconString());
 | |
|         using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f }))
 | |
|         {
 | |
|             ImGui.SameLine();
 | |
|             ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]");
 | |
|         }
 | |
|         UiSharedService.AttachToolTip(OnlinePairs + " online in all of your joined syncshells" + Environment.NewLine +
 | |
|             TotalPairs + " pairs combined in all of your joined syncshells");
 | |
|         ImGui.SameLine();
 | |
|         ImGui.TextUnformatted("All Syncshells");
 | |
|         ImGui.Separator();
 | |
| 
 | |
|         if (_tagHandler.IsTagOpen(_id))
 | |
|         {
 | |
|             using var indent = ImRaii.PushIndent(20f);
 | |
|             foreach (var entry in _groups)
 | |
|             {
 | |
|                 entry.Draw();
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 | 
