 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>
		
			
				
	
	
		
			106 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			106 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Dalamud.Game.Command;
 | |
| using Dalamud.Plugin.Services;
 | |
| using MareSynchronos.FileCache;
 | |
| using MareSynchronos.Services.Mediator;
 | |
| using MareSynchronos.Services.ServerConfiguration;
 | |
| using MareSynchronos.UI;
 | |
| using MareSynchronos.WebAPI;
 | |
| using System.Globalization;
 | |
| 
 | |
| namespace MareSynchronos.Services;
 | |
| 
 | |
| public sealed class CommandManagerService : IDisposable
 | |
| {
 | |
|     private const string _commandName = "/mare";
 | |
| 
 | |
|     private readonly ApiController _apiController;
 | |
|     private readonly ICommandManager _commandManager;
 | |
|     private readonly MareMediator _mediator;
 | |
|     private readonly PerformanceCollectorService _performanceCollectorService;
 | |
|     private readonly PeriodicFileScanner _periodicFileScanner;
 | |
|     private readonly ServerConfigurationManager _serverConfigurationManager;
 | |
| 
 | |
|     public CommandManagerService(ICommandManager commandManager, PerformanceCollectorService performanceCollectorService,
 | |
|         ServerConfigurationManager serverConfigurationManager, PeriodicFileScanner periodicFileScanner,
 | |
|         ApiController apiController, MareMediator mediator)
 | |
|     {
 | |
|         _commandManager = commandManager;
 | |
|         _performanceCollectorService = performanceCollectorService;
 | |
|         _serverConfigurationManager = serverConfigurationManager;
 | |
|         _periodicFileScanner = periodicFileScanner;
 | |
|         _apiController = apiController;
 | |
|         _mediator = mediator;
 | |
|         _commandManager.AddHandler(_commandName, new CommandInfo(OnCommand)
 | |
|         {
 | |
|             HelpMessage = "Opens the Mare Synchronos UI"
 | |
|         });
 | |
|     }
 | |
| 
 | |
|     public void Dispose()
 | |
|     {
 | |
|         _commandManager.RemoveHandler(_commandName);
 | |
|     }
 | |
| 
 | |
|     private void OnCommand(string command, string args)
 | |
|     {
 | |
|         var splitArgs = args.ToLowerInvariant().Trim().Split(" ", StringSplitOptions.RemoveEmptyEntries);
 | |
| 
 | |
|         if (splitArgs == null || splitArgs.Length == 0)
 | |
|         {
 | |
|             // Interpret this as toggling the UI
 | |
|             _mediator.Publish(new UiToggleMessage(typeof(CompactUi)));
 | |
|             return;
 | |
|         }
 | |
| 
 | |
|         if (string.Equals(splitArgs[0], "toggle", StringComparison.OrdinalIgnoreCase))
 | |
|         {
 | |
|             if (_apiController.ServerState == WebAPI.SignalR.Utils.ServerState.Disconnecting)
 | |
|             {
 | |
|                 _mediator.Publish(new NotificationMessage("Mare disconnecting", "Cannot use /toggle while Mare Synchronos is still disconnecting",
 | |
|                     Dalamud.Interface.Internal.Notifications.NotificationType.Error));
 | |
|             }
 | |
| 
 | |
|             if (_serverConfigurationManager.CurrentServer == null) return;
 | |
|             var fullPause = splitArgs.Length > 1 ? splitArgs[1] switch
 | |
|             {
 | |
|                 "on" => false,
 | |
|                 "off" => true,
 | |
|                 _ => !_serverConfigurationManager.CurrentServer.FullPause,
 | |
|             } : !_serverConfigurationManager.CurrentServer.FullPause;
 | |
| 
 | |
|             if (fullPause != _serverConfigurationManager.CurrentServer.FullPause)
 | |
|             {
 | |
|                 _serverConfigurationManager.CurrentServer.FullPause = fullPause;
 | |
|                 _serverConfigurationManager.Save();
 | |
|                 _ = _apiController.CreateConnections();
 | |
|             }
 | |
|         }
 | |
|         else if (string.Equals(splitArgs[0], "gpose", StringComparison.OrdinalIgnoreCase))
 | |
|         {
 | |
|             _mediator.Publish(new UiToggleMessage(typeof(GposeUi)));
 | |
|         }
 | |
|         else if (string.Equals(splitArgs[0], "rescan", StringComparison.OrdinalIgnoreCase))
 | |
|         {
 | |
|             _periodicFileScanner.InvokeScan(forced: true);
 | |
|         }
 | |
|         else if (string.Equals(splitArgs[0], "perf", StringComparison.OrdinalIgnoreCase))
 | |
|         {
 | |
|             if (splitArgs.Length > 1 && int.TryParse(splitArgs[1], CultureInfo.InvariantCulture, out var limitBySeconds))
 | |
|             {
 | |
|                 _performanceCollectorService.PrintPerformanceStats(limitBySeconds);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 _performanceCollectorService.PrintPerformanceStats();
 | |
|             }
 | |
|         }
 | |
|         else if (string.Equals(splitArgs[0], "medi", StringComparison.OrdinalIgnoreCase))
 | |
|         {
 | |
|             _mediator.PrintSubscriberInfo();
 | |
|         }
 | |
|         else if (string.Equals(splitArgs[0], "analyze", StringComparison.OrdinalIgnoreCase))
 | |
|         {
 | |
|             _mediator.Publish(new OpenDataAnalysisUiMessage());
 | |
|         }
 | |
|     }
 | |
| } |