From f371df7aa10a7e51eff3da482cab3e7d99479af0 Mon Sep 17 00:00:00 2001 From: rootdarkarchon Date: Wed, 4 Oct 2023 01:37:53 +0200 Subject: [PATCH] more api9 updates --- MareSynchronos/MareSynchronos.csproj | 12 ++-- .../PlayerData/Factories/PlayerDataFactory.cs | 1 + MareSynchronos/Plugin.cs | 3 + MareSynchronos/UI/UISharedService.cs | 61 ++++++++++++++----- MareSynchronos/WebAPI/SignalR/HubFactory.cs | 10 ++- 5 files changed, 60 insertions(+), 27 deletions(-) diff --git a/MareSynchronos/MareSynchronos.csproj b/MareSynchronos/MareSynchronos.csproj index 5e0ecb8..14a1732 100644 --- a/MareSynchronos/MareSynchronos.csproj +++ b/MareSynchronos/MareSynchronos.csproj @@ -26,17 +26,17 @@ - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + @@ -87,10 +87,6 @@ $(DalamudLibPath)CheapLoc.dll false - - $(DalamudLibPath)Dalamud.Interface.dll - false - diff --git a/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs b/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs index fb15747..79b8af2 100644 --- a/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs +++ b/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs @@ -13,6 +13,7 @@ using MareSynchronos.PlayerData.Data; using MareSynchronos.PlayerData.Handlers; using MareSynchronos.Services; using FFXIVClientStructs.FFXIV.Client.Graphics.Render; +using CharacterData = MareSynchronos.PlayerData.Data.CharacterData; namespace MareSynchronos.PlayerData.Factories; diff --git a/MareSynchronos/Plugin.cs b/MareSynchronos/Plugin.cs index 25da158..d392770 100644 --- a/MareSynchronos/Plugin.cs +++ b/MareSynchronos/Plugin.cs @@ -68,6 +68,7 @@ public sealed class Plugin : IDalamudPlugin collection.AddSingleton(); collection.AddSingleton(); collection.AddSingleton(); + collection.AddSingleton((s) => new DalamudContextMenu(pluginInterface)); collection.AddSingleton((s) => new DalamudUtilService(s.GetRequiredService>(), clientState, objectTable, framework, gameGui, condition, gameData, s.GetRequiredService(), s.GetRequiredService())); @@ -82,6 +83,8 @@ public sealed class Plugin : IDalamudPlugin collection.AddSingleton((s) => new ServerTagConfigService(pluginInterface.ConfigDirectory.FullName)); collection.AddSingleton((s) => new TransientConfigService(pluginInterface.ConfigDirectory.FullName)); collection.AddSingleton((s) => new ConfigurationMigrator(s.GetRequiredService>(), pluginInterface)); + collection.AddSingleton((s) => new HubFactory(s.GetRequiredService>(), s.GetRequiredService(), + s.GetRequiredService(), s.GetRequiredService(), pluginLog)); // func factory method singletons collection.AddSingleton(s => diff --git a/MareSynchronos/UI/UISharedService.cs b/MareSynchronos/UI/UISharedService.cs index 2d88fe2..461a8f5 100644 --- a/MareSynchronos/UI/UISharedService.cs +++ b/MareSynchronos/UI/UISharedService.cs @@ -4,6 +4,7 @@ using Dalamud.Interface.GameFonts; using Dalamud.Interface.ImGuiFileDialog; using Dalamud.Interface.Internal; using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using Dalamud.Plugin; using Dalamud.Utility; using ImGuiNET; @@ -265,11 +266,11 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase ImGui.PopID(); } - public static void FontText(string text, ImFontPtr font) + public static void FontText(string text, ImFontPtr font, Vector4? color = null) { - ImGui.PushFont(font); + using var pushedFont = ImRaii.PushFont(font); + using var pushedColor = ImRaii.PushColor(ImGuiCol.Text, Color(color ?? new Vector4(1, 1, 1, 1)), color != null); ImGui.TextUnformatted(text); - ImGui.PopFont(); } public static Vector4 GetBoolColor(bool input) => input ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed; @@ -616,30 +617,58 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase var customizeColor = _customizePlusExists ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed; var paletteColor = _palettePlusExists ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed; var honorificColor = _honorificExists ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed; - ImGui.Text("Penumbra:"); + var check = FontAwesomeIcon.Check.ToIconString(); + var cross = FontAwesomeIcon.SquareXmark.ToIconString(); + ImGui.Text("Mandatory Plugins:"); + ImGui.SameLine(); - ImGui.TextColored(penumbraColor, _penumbraExists ? "Available" : "Unavailable"); + ImGui.Text("Penumbra"); ImGui.SameLine(); - ImGui.Text("Glamourer:"); + FontText(_penumbraExists ? check : cross, UiBuilder.IconFont, penumbraColor); ImGui.SameLine(); - ImGui.TextColored(glamourerColor, _glamourerExists ? "Available" : "Unavailable"); - ImGui.Text("Optional Addons"); + AttachToolTip($"Penumbra is " + (_penumbraExists ? "available and up to date." : "unavailable or not up to date.")); + ImGui.Spacing(); + ImGui.SameLine(); - ImGui.Text("SimpleHeels:"); + ImGui.Text("Glamourer"); ImGui.SameLine(); - ImGui.TextColored(heelsColor, _heelsExists ? "Available" : "Unavailable"); + FontText(_glamourerExists ? check : cross, UiBuilder.IconFont, penumbraColor); ImGui.SameLine(); - ImGui.Text("Customize+:"); + AttachToolTip($"Glamourer is " + (_glamourerExists ? "available and up to date." : "unavailable or not up to date.")); + ImGui.Spacing(); + + ImGui.Text("Optional Plugins:"); ImGui.SameLine(); - ImGui.TextColored(customizeColor, _customizePlusExists ? "Available" : "Unavailable"); + ImGui.Text("SimpleHeels"); ImGui.SameLine(); - ImGui.Text("Palette+:"); + FontText(_heelsExists ? check : cross, UiBuilder.IconFont, penumbraColor); ImGui.SameLine(); - ImGui.TextColored(paletteColor, _palettePlusExists ? "Available" : "Unavailable"); + AttachToolTip($"SimpleHeels is " + (_heelsExists ? "available and up to date." : "unavailable or not up to date.")); + ImGui.Spacing(); + ImGui.SameLine(); - ImGui.Text("Honorific:"); + ImGui.Text("Customize+"); ImGui.SameLine(); - ImGui.TextColored(honorificColor, _honorificExists ? "Available" : "Unavailable"); + FontText(_customizePlusExists ? check : cross, UiBuilder.IconFont, penumbraColor); + ImGui.SameLine(); + AttachToolTip($"Customize+ is " + (_customizePlusExists ? "available and up to date." : "unavailable or not up to date.")); + ImGui.Spacing(); + + ImGui.SameLine(); + ImGui.Text("Palette+"); + ImGui.SameLine(); + FontText(_palettePlusExists ? check : cross, UiBuilder.IconFont, penumbraColor); + ImGui.SameLine(); + AttachToolTip($"Palette+ is " + (_palettePlusExists ? "available and up to date." : "unavailable or not up to date.")); + ImGui.Spacing(); + + ImGui.SameLine(); + ImGui.Text("Honorific"); + ImGui.SameLine(); + FontText(_honorificExists ? check : cross, UiBuilder.IconFont, penumbraColor); + ImGui.SameLine(); + AttachToolTip($"Honorific is " + (_honorificExists ? "available and up to date." : "unavailable or not up to date.")); + ImGui.Spacing(); if (!_penumbraExists || !_glamourerExists) { diff --git a/MareSynchronos/WebAPI/SignalR/HubFactory.cs b/MareSynchronos/WebAPI/SignalR/HubFactory.cs index c09bc31..bf1a43b 100644 --- a/MareSynchronos/WebAPI/SignalR/HubFactory.cs +++ b/MareSynchronos/WebAPI/SignalR/HubFactory.cs @@ -1,4 +1,5 @@ -using MareSynchronos.API.SignalR; +using Dalamud.Plugin.Services; +using MareSynchronos.API.SignalR; using MareSynchronos.Interop; using MareSynchronos.MareConfiguration; using MareSynchronos.Services.Mediator; @@ -17,13 +18,16 @@ public class HubFactory : MediatorSubscriberBase { private readonly ServerConfigurationManager _serverConfigurationManager; private readonly MareConfigService _configService; + private readonly IPluginLog _pluginLog; private HubConnection? _instance; private bool _isDisposed = false; - public HubFactory(ILogger logger, MareMediator mediator, ServerConfigurationManager serverConfigurationManager, MareConfigService configService) : base(logger, mediator) + public HubFactory(ILogger logger, MareMediator mediator, ServerConfigurationManager serverConfigurationManager, MareConfigService configService, + IPluginLog pluginLog) : base(logger, mediator) { _serverConfigurationManager = serverConfigurationManager; _configService = configService; + _pluginLog = pluginLog; } private HubConnection BuildHubConnection() @@ -58,7 +62,7 @@ public class HubFactory : MediatorSubscriberBase .WithAutomaticReconnect(new ForeverRetryPolicy(Mediator)) .ConfigureLogging(a => { - a.ClearProviders().AddProvider(new DalamudLoggingProvider(_configService)); + a.ClearProviders().AddProvider(new DalamudLoggingProvider(_configService, _pluginLog)); a.SetMinimumLevel(LogLevel.Information); }) .Build();