Skip to content

Commit

Permalink
Other 0.3.11 things
Browse files Browse the repository at this point in the history
- Fix bad enum logic for GameConfig (again)
- Some base string changes
- Make DebugWindow more responsive
- Automated cleanup pass (again)
  • Loading branch information
KazWolfe committed Mar 11, 2023
1 parent 19c6385 commit 599b877
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 42 deletions.
2 changes: 1 addition & 1 deletion FFXIVPlugin/ActionExecutor/Strategies/EmoteStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down
19 changes: 12 additions & 7 deletions FFXIVPlugin/Game/GameConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 8 additions & 9 deletions FFXIVPlugin/Game/Watchers/VolumeWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -11,14 +10,14 @@
namespace XIVDeck.FFXIVPlugin.Game.Watchers;

public class VolumeWatcher : IDisposable {
public static readonly Dictionary<SoundChannel, (ConfigOption Level, ConfigOption MuteState)> 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<SoundChannel, (string Level, string MuteState)> 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
Expand Down
6 changes: 3 additions & 3 deletions FFXIVPlugin/Resources/Localization/UIStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions FFXIVPlugin/Resources/Localization/UIStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ Default: Off</value>
<value>Listen IP: {0}</value>
</data>
<data name="SettingsWindow_APIPort_Help" xml:space="preserve">
<value>Default port: {0}

Range: {1}-{2}</value>
<value>Changing this setting will re-trigger the Welcome screen.
Default port: {0}, Range: {1}-{2}</value>
</data>
<data name="ForcedUpdateNag_Headline" xml:space="preserve">
<value>The XIVDeck Stream Deck Plugin is out of date!</value>
Expand Down
3 changes: 0 additions & 3 deletions FFXIVPlugin/Server/Messages/Inbound/WSInitOpcode.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions FFXIVPlugin/UI/Windows/DebugWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ internal static DebugWindow GetOrCreate() {

return _instance;
}

private readonly XIVDeckPlugin _plugin = XIVDeckPlugin.Instance;


// secret configs
private bool _listenOnAllInterfaces;
private int _httpListenerMode;
Expand All @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions FFXIVPlugin/UI/Windows/Nags/ForcedUpdateNag.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion FFXIVPlugin/UI/Windows/Nags/PortInUseNag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions FFXIVPlugin/UI/Windows/Nags/SetupNag.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Components;
using ImGuiNET;
Expand Down
1 change: 0 additions & 1 deletion FFXIVPlugin/UI/Windows/Nags/TestingUpdateNag.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions FFXIVPlugin/Utils/InputUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 0 additions & 5 deletions FFXIVPlugin/Utils/VersionUtils.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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(""))
Expand Down

0 comments on commit 599b877

Please sign in to comment.