 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>
		
			
				
	
	
		
			138 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			138 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Numerics;
 | |
| using Dalamud.Interface.Windowing;
 | |
| using ImGuiNET;
 | |
| using MareSynchronos.MareConfiguration;
 | |
| using MareSynchronos.Utils;
 | |
| using MareSynchronos.WebAPI;
 | |
| 
 | |
| namespace MareSynchronos.UI;
 | |
| 
 | |
| public class DownloadUi : Window, IDisposable
 | |
| {
 | |
|     private readonly WindowSystem _windowSystem;
 | |
|     private readonly ConfigurationService _configService;
 | |
|     private readonly ApiController _apiController;
 | |
|     private readonly UiShared _uiShared;
 | |
|     private bool _wasOpen = false;
 | |
| 
 | |
|     public void Dispose()
 | |
|     {
 | |
|         Logger.Verbose("Disposing " + nameof(DownloadUi));
 | |
|         _windowSystem.RemoveWindow(this);
 | |
|     }
 | |
| 
 | |
|     public DownloadUi(WindowSystem windowSystem, ConfigurationService configService, ApiController apiController, UiShared uiShared) : base("Mare Synchronos Downloads")
 | |
|     {
 | |
|         Logger.Verbose("Creating " + nameof(DownloadUi));
 | |
|         _windowSystem = windowSystem;
 | |
|         _configService = configService;
 | |
|         _apiController = apiController;
 | |
|         _uiShared = uiShared;
 | |
| 
 | |
|         SizeConstraints = new WindowSizeConstraints()
 | |
|         {
 | |
|             MaximumSize = new Vector2(300, 90),
 | |
|             MinimumSize = new Vector2(300, 90),
 | |
|         };
 | |
| 
 | |
|         Flags |= ImGuiWindowFlags.NoMove;
 | |
|         Flags |= ImGuiWindowFlags.NoBackground;
 | |
|         Flags |= ImGuiWindowFlags.NoInputs;
 | |
|         Flags |= ImGuiWindowFlags.NoNavFocus;
 | |
|         Flags |= ImGuiWindowFlags.NoResize;
 | |
|         Flags |= ImGuiWindowFlags.NoScrollbar;
 | |
|         Flags |= ImGuiWindowFlags.NoTitleBar;
 | |
|         Flags |= ImGuiWindowFlags.NoDecoration;
 | |
| 
 | |
|         ForceMainWindow = true;
 | |
| 
 | |
|         windowSystem.AddWindow(this);
 | |
|         IsOpen = true;
 | |
|     }
 | |
| 
 | |
|     public override void PreDraw()
 | |
|     {
 | |
|         if (_uiShared.IsInGpose)
 | |
|         {
 | |
|             _wasOpen = IsOpen;
 | |
|             IsOpen = false;
 | |
|         }
 | |
| 
 | |
| 
 | |
|         base.PreDraw();
 | |
|         if (_uiShared.EditTrackerPosition)
 | |
|         {
 | |
|             Flags &= ~ImGuiWindowFlags.NoMove;
 | |
|             Flags &= ~ImGuiWindowFlags.NoBackground;
 | |
|             Flags &= ~ImGuiWindowFlags.NoInputs;
 | |
|             Flags &= ~ImGuiWindowFlags.NoResize;
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             Flags |= ImGuiWindowFlags.NoMove;
 | |
|             Flags |= ImGuiWindowFlags.NoBackground;
 | |
|             Flags |= ImGuiWindowFlags.NoInputs;
 | |
|             Flags |= ImGuiWindowFlags.NoResize;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public override void Draw()
 | |
|     {
 | |
|         if (!_configService.Current.ShowTransferWindow) return;
 | |
|         if (!_apiController.IsDownloading && !_apiController.IsUploading) return;
 | |
| 
 | |
|         var drawList = ImGui.GetWindowDrawList();
 | |
|         var yDistance = 20;
 | |
|         var xDistance = 20;
 | |
| 
 | |
|         var basePosition = ImGui.GetWindowPos() + ImGui.GetWindowContentRegionMin();
 | |
| 
 | |
|         try
 | |
|         {
 | |
|             if (_apiController.CurrentUploads.Any())
 | |
|             {
 | |
|                 var currentUploads = _apiController.CurrentUploads.ToList();
 | |
|                 var totalUploads = currentUploads.Count;
 | |
| 
 | |
|                 var doneUploads = currentUploads.Count(c => c.IsTransferred);
 | |
|                 var totalUploaded = currentUploads.Sum(c => c.Transferred);
 | |
|                 var totalToUpload = currentUploads.Sum(c => c.Total);
 | |
| 
 | |
|                 UiShared.DrawOutlinedFont(drawList, "▲",
 | |
|                     new Vector2(basePosition.X + 0, basePosition.Y + (int)(yDistance * 0.5)),
 | |
|                     UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);
 | |
|                 UiShared.DrawOutlinedFont(drawList, $"Compressing+Uploading {doneUploads}/{totalUploads}",
 | |
|                     new Vector2(basePosition.X + xDistance, basePosition.Y + yDistance * 0),
 | |
|                     UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);
 | |
|                 UiShared.DrawOutlinedFont(drawList, $"{UiShared.ByteToString(totalUploaded)}/{UiShared.ByteToString(totalToUpload)}",
 | |
|                     new Vector2(basePosition.X + xDistance, basePosition.Y + yDistance * 1),
 | |
|                     UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);
 | |
| 
 | |
|             }
 | |
|         }
 | |
|         catch { }
 | |
| 
 | |
|         try
 | |
|         {
 | |
|             if (_apiController.CurrentDownloads.Any())
 | |
|             {
 | |
|                 var currentDownloads = _apiController.CurrentDownloads.Where(d => d.Value != null && d.Value.Any()).ToList().SelectMany(k => k.Value).ToList();
 | |
|                 var multBase = currentDownloads.Any() ? 0 : 2;
 | |
|                 var doneDownloads = currentDownloads.Count(c => c.IsTransferred);
 | |
|                 var totalDownloads = currentDownloads.Count;
 | |
|                 var totalDownloaded = currentDownloads.Sum(c => c.Transferred);
 | |
|                 var totalToDownload = currentDownloads.Sum(c => c.Total);
 | |
|                 UiShared.DrawOutlinedFont(drawList, "▼",
 | |
|                     new Vector2(basePosition.X + 0, basePosition.Y + (int)(yDistance * multBase + (yDistance * 0.5))),
 | |
|                     UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);
 | |
|                 UiShared.DrawOutlinedFont(drawList, $"Downloading {doneDownloads}/{totalDownloads}",
 | |
|                     new Vector2(basePosition.X + xDistance, basePosition.Y + yDistance * multBase),
 | |
|                     UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);
 | |
|                 UiShared.DrawOutlinedFont(drawList, $"{UiShared.ByteToString(totalDownloaded)}/{UiShared.ByteToString(totalToDownload)}",
 | |
|                     new Vector2(basePosition.X + xDistance, basePosition.Y + yDistance * (1 + multBase)),
 | |
|                     UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);
 | |
|             }
 | |
|         }
 | |
|         catch { }
 | |
|     }
 | |
| } |