From 599b877189b8ef03fb0edb76f12b071b790910a3 Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Sat, 11 Mar 2023 15:06:11 -0800 Subject: [PATCH] Other 0.3.11 things - Fix bad enum logic for GameConfig (again) - Some base string changes - Make DebugWindow more responsive - Automated cleanup pass (again) --- .../Strategies/EmoteStrategy.cs | 2 +- FFXIVPlugin/Game/GameConfig.cs | 19 ++++++++++++------- FFXIVPlugin/Game/Watchers/VolumeWatcher.cs | 17 ++++++++--------- .../Localization/UIStrings.Designer.cs | 6 +++--- .../Resources/Localization/UIStrings.resx | 6 +++--- .../Server/Messages/Inbound/WSInitOpcode.cs | 3 --- FFXIVPlugin/UI/Windows/DebugWindow.cs | 8 ++++---- .../UI/Windows/Nags/ForcedUpdateNag.cs | 4 +--- FFXIVPlugin/UI/Windows/Nags/PortInUseNag.cs | 2 +- FFXIVPlugin/UI/Windows/Nags/SetupNag.cs | 3 +-- .../UI/Windows/Nags/TestingUpdateNag.cs | 1 - FFXIVPlugin/Utils/InputUtil.cs | 1 + FFXIVPlugin/Utils/VersionUtils.cs | 5 ----- 13 files changed, 35 insertions(+), 42 deletions(-) diff --git a/FFXIVPlugin/ActionExecutor/Strategies/EmoteStrategy.cs b/FFXIVPlugin/ActionExecutor/Strategies/EmoteStrategy.cs index 2fc767b..50fcc18 100644 --- a/FFXIVPlugin/ActionExecutor/Strategies/EmoteStrategy.cs +++ b/FFXIVPlugin/ActionExecutor/Strategies/EmoteStrategy.cs @@ -73,7 +73,7 @@ public void Execute(uint actionId, ActionPayload? payload) { PluginLog.Debug($"Executing command: {textCommand.Command}"); Injections.Framework.RunOnFrameworkThread(delegate { - using var _ = logMode != null ? GameConfig.UiConfig.TemporarySet(ConfigOption.EmoteTextType, logMode.Value) : null; + using var _ = logMode != null ? GameConfig.UiConfig.TemporarySet("EmoteTextType", logMode.Value) : null; ChatHelper.GetInstance().SendSanitizedChatMessage(textCommand.Command); }); } diff --git a/FFXIVPlugin/Game/GameConfig.cs b/FFXIVPlugin/Game/GameConfig.cs index 8d46b0c..dc5a5a4 100644 --- a/FFXIVPlugin/Game/GameConfig.cs +++ b/FFXIVPlugin/Game/GameConfig.cs @@ -66,45 +66,50 @@ private bool TryGetEntry(ConfigOption option, out ConfigEntry* entry, bool searc return this.TryGetEntry(index, out entry); } - public bool TryGetBool(ConfigOption option, out bool value) { + private bool TryGetEntry(string option, out ConfigEntry* entry) { + entry = null; + return this.TryGetIndex(option, out var index) && this.TryGetEntry(index, out entry); + } + + public bool TryGetBool(string option, out bool value) { value = false; if (!this.TryGetEntry(option, out var entry)) return false; value = entry->Value.UInt != 0; return true; } - public bool GetBool(ConfigOption option) { + public bool GetBool(string option) { if (!this.TryGetBool(option, out var value)) throw new ArgumentOutOfRangeException(nameof(option), @$"No option {option} was found."); return value; } - public void Set(ConfigOption option, bool value) { + public void Set(string option, bool value) { if (!this.TryGetEntry(option, out var entry)) return; entry->SetValue(value ? 1U : 0U); } - public bool TryGetUInt(ConfigOption option, out uint value) { + public bool TryGetUInt(string option, out uint value) { value = 0; if (!this.TryGetEntry(option, out var entry)) return false; value = entry->Value.UInt; return true; } - public uint GetUInt(ConfigOption option) { + public uint GetUInt(string option) { if (!this.TryGetUInt(option, out var value)) throw new ArgumentOutOfRangeException(nameof(option), @$"No option {option} was found."); return value; } - public void Set(ConfigOption option, uint value) { + public void Set(string option, uint value) { if (!this.TryGetEntry(option, out var entry)) return; entry->SetValue(value); } - public IDisposable TemporarySet(ConfigOption option, bool value) { + public IDisposable TemporarySet(string option, bool value) { var oldValue = this.GetBool(option); this.Set(option, value); diff --git a/FFXIVPlugin/Game/Watchers/VolumeWatcher.cs b/FFXIVPlugin/Game/Watchers/VolumeWatcher.cs index 26cc086..f3d1a6f 100644 --- a/FFXIVPlugin/Game/Watchers/VolumeWatcher.cs +++ b/FFXIVPlugin/Game/Watchers/VolumeWatcher.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using Dalamud.Game; using Dalamud.Logging; -using FFXIVClientStructs.FFXIV.Client.UI.Misc; using XIVDeck.FFXIVPlugin.Base; using XIVDeck.FFXIVPlugin.Game.Data; using XIVDeck.FFXIVPlugin.Server; @@ -11,14 +10,14 @@ namespace XIVDeck.FFXIVPlugin.Game.Watchers; public class VolumeWatcher : IDisposable { - public static readonly Dictionary Channels = new() { - {SoundChannel.Master, (ConfigOption.SoundMaster, ConfigOption.IsSndMaster)}, - {SoundChannel.BackgroundMusic, (ConfigOption.SoundBgm, ConfigOption.IsSndBgm)}, - {SoundChannel.SoundEffects, (ConfigOption.SoundSe, ConfigOption.IsSndSe)}, - {SoundChannel.Voice, (ConfigOption.SoundVoice, ConfigOption.IsSndVoice)}, - {SoundChannel.System, (ConfigOption.SoundSystem, ConfigOption.IsSndSystem)}, - {SoundChannel.Ambient, (ConfigOption.SoundEnv, ConfigOption.IsSndEnv)}, - {SoundChannel.Performance, (ConfigOption.SoundPerform, ConfigOption.IsSndPerform)} + public static readonly Dictionary Channels = new() { + {SoundChannel.Master, ("SoundMaster", "IsSndMaster")}, + {SoundChannel.BackgroundMusic, ("SoundBgm", "IsSndBgm")}, + {SoundChannel.SoundEffects, ("SoundSe", "IsSndSe")}, + {SoundChannel.Voice, ("SoundVoice", "IsSndVoice")}, + {SoundChannel.System, ("SoundSystem", "IsSndSystem")}, + {SoundChannel.Ambient, ("SoundEnv", "IsSndEnv")}, + {SoundChannel.Performance, ("SoundPerform", "IsSndPerform")} }; // internal cache of volume states for known update diff --git a/FFXIVPlugin/Resources/Localization/UIStrings.Designer.cs b/FFXIVPlugin/Resources/Localization/UIStrings.Designer.cs index 1e544d3..2e006ec 100644 --- a/FFXIVPlugin/Resources/Localization/UIStrings.Designer.cs +++ b/FFXIVPlugin/Resources/Localization/UIStrings.Designer.cs @@ -493,9 +493,9 @@ internal static string SettingsWindow_APIPort { } /// - /// Looks up a localized string similar to Default port: {0} - /// - ///Range: {1}-{2}. + /// Looks up a localized string similar to Changing this setting will re-trigger the Welcome screen. + /// + ///Default port: {0}, Range: {1}-{2}. /// internal static string SettingsWindow_APIPort_Help { get { diff --git a/FFXIVPlugin/Resources/Localization/UIStrings.resx b/FFXIVPlugin/Resources/Localization/UIStrings.resx index 1bfa728..040fd90 100644 --- a/FFXIVPlugin/Resources/Localization/UIStrings.resx +++ b/FFXIVPlugin/Resources/Localization/UIStrings.resx @@ -138,9 +138,9 @@ Default: Off Listen IP: {0} - Default port: {0} - -Range: {1}-{2} + Changing this setting will re-trigger the Welcome screen. + +Default port: {0}, Range: {1}-{2} The XIVDeck Stream Deck Plugin is out of date! diff --git a/FFXIVPlugin/Server/Messages/Inbound/WSInitOpcode.cs b/FFXIVPlugin/Server/Messages/Inbound/WSInitOpcode.cs index 621e858..2784615 100644 --- a/FFXIVPlugin/Server/Messages/Inbound/WSInitOpcode.cs +++ b/FFXIVPlugin/Server/Messages/Inbound/WSInitOpcode.cs @@ -1,7 +1,5 @@ using System.Reflection; using System.Threading.Tasks; -using Dalamud.Game.Text.SeStringHandling; -using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Logging; using EmbedIO.WebSockets; using Newtonsoft.Json; @@ -10,7 +8,6 @@ using XIVDeck.FFXIVPlugin.Resources.Localization; using XIVDeck.FFXIVPlugin.Server.Helpers; using XIVDeck.FFXIVPlugin.Server.Messages.Outbound; -using XIVDeck.FFXIVPlugin.UI; using XIVDeck.FFXIVPlugin.UI.Windows; using XIVDeck.FFXIVPlugin.UI.Windows.Nags; using XIVDeck.FFXIVPlugin.Utils; diff --git a/FFXIVPlugin/UI/Windows/DebugWindow.cs b/FFXIVPlugin/UI/Windows/DebugWindow.cs index 99d3789..28036a2 100644 --- a/FFXIVPlugin/UI/Windows/DebugWindow.cs +++ b/FFXIVPlugin/UI/Windows/DebugWindow.cs @@ -29,9 +29,7 @@ internal static DebugWindow GetOrCreate() { return _instance; } - - private readonly XIVDeckPlugin _plugin = XIVDeckPlugin.Instance; - + // secret configs private bool _listenOnAllInterfaces; private int _httpListenerMode; @@ -41,7 +39,9 @@ private DebugWindow() : base(WindowKey) { this.SizeCondition = ImGuiCond.FirstUseEver; } - public override void OnOpen() { + public override void PreDraw() { + base.PreDraw(); + this._listenOnAllInterfaces = XIVDeckPlugin.Instance.Configuration.ListenOnAllInterfaces; this._httpListenerMode = (int) XIVDeckPlugin.Instance.Configuration.HttpListenerMode; } diff --git a/FFXIVPlugin/UI/Windows/Nags/ForcedUpdateNag.cs b/FFXIVPlugin/UI/Windows/Nags/ForcedUpdateNag.cs index 77c547e..edcda6b 100644 --- a/FFXIVPlugin/UI/Windows/Nags/ForcedUpdateNag.cs +++ b/FFXIVPlugin/UI/Windows/Nags/ForcedUpdateNag.cs @@ -1,6 +1,4 @@ -using System.Numerics; -using Dalamud.Interface; -using Dalamud.Interface.Colors; +using Dalamud.Interface.Colors; using Dalamud.Interface.Components; using ImGuiNET; using XIVDeck.FFXIVPlugin.Resources.Localization; diff --git a/FFXIVPlugin/UI/Windows/Nags/PortInUseNag.cs b/FFXIVPlugin/UI/Windows/Nags/PortInUseNag.cs index 893fb13..1ea6e00 100644 --- a/FFXIVPlugin/UI/Windows/Nags/PortInUseNag.cs +++ b/FFXIVPlugin/UI/Windows/Nags/PortInUseNag.cs @@ -18,7 +18,7 @@ internal static void Hide() { _instance.IsOpen = false; } - private PortInUseNag() : base("sdPortInUse", 300) { } + private PortInUseNag() : base("sdPortInUse") { } protected override void _internalDraw() { ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); diff --git a/FFXIVPlugin/UI/Windows/Nags/SetupNag.cs b/FFXIVPlugin/UI/Windows/Nags/SetupNag.cs index fc2ee68..1db28f6 100644 --- a/FFXIVPlugin/UI/Windows/Nags/SetupNag.cs +++ b/FFXIVPlugin/UI/Windows/Nags/SetupNag.cs @@ -1,5 +1,4 @@ -using System.Numerics; -using Dalamud.Interface; +using Dalamud.Interface; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; using ImGuiNET; diff --git a/FFXIVPlugin/UI/Windows/Nags/TestingUpdateNag.cs b/FFXIVPlugin/UI/Windows/Nags/TestingUpdateNag.cs index 2c303fb..62f4278 100644 --- a/FFXIVPlugin/UI/Windows/Nags/TestingUpdateNag.cs +++ b/FFXIVPlugin/UI/Windows/Nags/TestingUpdateNag.cs @@ -1,6 +1,5 @@ using Dalamud.Interface; using Dalamud.Interface.Colors; -using Dalamud.Interface.Components; using ImGuiNET; using XIVDeck.FFXIVPlugin.Resources.Localization; using XIVDeck.FFXIVPlugin.Utils; diff --git a/FFXIVPlugin/Utils/InputUtil.cs b/FFXIVPlugin/Utils/InputUtil.cs index 0751483..563eeb0 100644 --- a/FFXIVPlugin/Utils/InputUtil.cs +++ b/FFXIVPlugin/Utils/InputUtil.cs @@ -15,6 +15,7 @@ internal static partial class InputUtil { [LibraryImport("user32.dll")] private static partial int GetWindowThreadProcessId(nint hWnd, out int processId); + // ReSharper disable once UnusedMethodReturnValue.Local [LibraryImport("user32.dll")] private static partial nint SendMessageW(nint hWnd, uint msg, nint wParam, nint lParam); diff --git a/FFXIVPlugin/Utils/VersionUtils.cs b/FFXIVPlugin/Utils/VersionUtils.cs index bf95be6..e69663c 100644 --- a/FFXIVPlugin/Utils/VersionUtils.cs +++ b/FFXIVPlugin/Utils/VersionUtils.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; using XIVDeck.FFXIVPlugin.Game.Chat; @@ -37,8 +34,6 @@ public static SeString GenerateUpdateNagString(Version xivPluginVersion) { .Build(); var outer = UIStrings.VersionUtils_UpdateAlert.Split("{0}", 2); - var components = outer.Select(segment => (SeString) segment).ToList(); - components.Insert(1, versionHighlight); return new SeStringBuilder() .Append(ErrorNotifier.BuildPrefixedString(""))