From bac46f4224091d61e7e1fd0e5e363ea5ed79af12 Mon Sep 17 00:00:00 2001 From: Xorus Date: Sun, 4 Feb 2024 14:50:57 +0100 Subject: [PATCH] add an option to ignore the original countdown when drawing the custom one #56 --- CHANGELOG.md | 6 +- Plugin/Commands/MainCommand.cs | 6 +- Plugin/Commands/SettingsCommand.cs | 1 + .../Configuration/CountdownConfiguration.cs | 4 +- Plugin/EngageTimer.csproj | 2 +- Plugin/Localization/Extensions.cs | 37 +++++ Plugin/{Ui => Localization}/Translator.cs | 16 +-- Plugin/Plugin.cs | 6 +- Plugin/Properties/Resources.Designer.cs | 36 +++++ Plugin/Properties/Resources.resx | 12 ++ Plugin/Status/CombatAlarm.cs | 1 + Plugin/Ui/Components.cs | 1 + Plugin/Ui/CountDown.cs | 30 ++-- Plugin/Ui/CustomEasing/NumberEasing.cs | 37 +++++ Plugin/Ui/CustomEasing/OpacityEasing.cs | 11 +- Plugin/Ui/Modal.cs | 1 + Plugin/Ui/Settings.cs | 10 +- Plugin/Ui/SettingsTab/AlarmsTab.cs | 1 + Plugin/Ui/SettingsTab/CountdownTab.cs | 132 ++++++++++++------ Plugin/Ui/SettingsTab/DtrTab.cs | 1 + Plugin/Ui/SettingsTab/FloatingWindowTab.cs | 1 + Plugin/Ui/SettingsTab/WebServerTab.cs | 1 + 22 files changed, 265 insertions(+), 88 deletions(-) create mode 100644 Plugin/Localization/Extensions.cs rename Plugin/{Ui => Localization}/Translator.cs (87%) create mode 100644 Plugin/Ui/CustomEasing/NumberEasing.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 92b8209..2c144a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -# v2.3.1.0 - unreleased +# v2.3.2.0 + +- Adds + +# v2.3.1.0 - You can set alarms to play a game sound effect, change stopwatch color or display text at specified combat durations - Big code rewrite and a bit of optimization diff --git a/Plugin/Commands/MainCommand.cs b/Plugin/Commands/MainCommand.cs index 22ee831..f577f7f 100644 --- a/Plugin/Commands/MainCommand.cs +++ b/Plugin/Commands/MainCommand.cs @@ -15,7 +15,7 @@ using System; using Dalamud.Game.Command; -using EngageTimer.Ui; +using EngageTimer.Localization; namespace EngageTimer.Commands; @@ -27,12 +27,12 @@ public sealed class MainCommand : IDisposable public MainCommand() { Register(); - Plugin.Translator.LocaleChanged += OnLocaleChanged; + Translator.LocaleChanged += OnLocaleChanged; } public void Dispose() { - Plugin.Translator.LocaleChanged -= OnLocaleChanged; + Translator.LocaleChanged -= OnLocaleChanged; Unregister(); } diff --git a/Plugin/Commands/SettingsCommand.cs b/Plugin/Commands/SettingsCommand.cs index 2c7b118..862e048 100644 --- a/Plugin/Commands/SettingsCommand.cs +++ b/Plugin/Commands/SettingsCommand.cs @@ -15,6 +15,7 @@ using System; using Dalamud.Game.Command; +using EngageTimer.Localization; using EngageTimer.Ui; namespace EngageTimer.Commands; diff --git a/Plugin/Configuration/CountdownConfiguration.cs b/Plugin/Configuration/CountdownConfiguration.cs index b59d67c..4cc7a0e 100644 --- a/Plugin/Configuration/CountdownConfiguration.cs +++ b/Plugin/Configuration/CountdownConfiguration.cs @@ -24,14 +24,14 @@ namespace EngageTimer.Configuration; public class CountdownConfiguration { public static readonly string[] BundledTextures = - { "default", "yellow", "wow", "awk", "tall", "misaligned", "pixel", "moire", "mspaint" }; + {"default", "yellow", "wow", "awk", "tall", "misaligned", "pixel", "moire", "mspaint"}; // Countdown [AutoField("Settings_CountdownTab_Enable")] public bool Display { get; set; } = true; - [AutoField("Settings_CountdownTab_HideOriginalCountDown"), Help("Settings_CountdownTab_HideOriginalCountDown_Help")] public bool HideOriginalAddon { get; set; } = false; + public bool IgnoreOriginalAddon { get; set; } = false; [AutoField("Settings_CountdownTab_Audio_Enable")] public bool EnableTickingSound { get; set; } = false; diff --git a/Plugin/EngageTimer.csproj b/Plugin/EngageTimer.csproj index 0dc96ab..d1809a8 100644 --- a/Plugin/EngageTimer.csproj +++ b/Plugin/EngageTimer.csproj @@ -8,7 +8,7 @@ true false false - 2.3.1.1 + 2.3.2.0 false true true diff --git a/Plugin/Localization/Extensions.cs b/Plugin/Localization/Extensions.cs new file mode 100644 index 0000000..7350c91 --- /dev/null +++ b/Plugin/Localization/Extensions.cs @@ -0,0 +1,37 @@ +// This file is part of EngageTimer +// Copyright (C) 2024 Xorus +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +namespace EngageTimer.Localization; + +/** + * For the lazy dogs out there (me) + */ +public static class Extensions +{ + public static string Tr(this string id) + { + return Translator.Tr(id); + } + + public static string TrId(this string id) + { + return Translator.TrId(id); + } + + public static string TrYesNo(this bool yesNo, string yes, string no) + { + return yesNo ? Tr(yes) : Tr(no); + } +} \ No newline at end of file diff --git a/Plugin/Ui/Translator.cs b/Plugin/Localization/Translator.cs similarity index 87% rename from Plugin/Ui/Translator.cs rename to Plugin/Localization/Translator.cs index 080b2dd..1b57eab 100644 --- a/Plugin/Ui/Translator.cs +++ b/Plugin/Localization/Translator.cs @@ -17,23 +17,23 @@ using System.Globalization; using EngageTimer.Properties; -namespace EngageTimer.Ui; +namespace EngageTimer.Localization; -public sealed class Translator : IDisposable +public static class Translator { - public Translator() + public static event EventHandler? LocaleChanged; + + public static void Register() { Plugin.PluginInterface.LanguageChanged += ConfigureLanguage; ConfigureLanguage(); } - public void Dispose() + public static void Unregister() { Plugin.PluginInterface.LanguageChanged -= ConfigureLanguage; } - public event EventHandler? LocaleChanged; - public static string TrId(string id) { return $"{Resources.ResourceManager.GetString(id, Resources.Culture) ?? id}###EngageTimer_{id}"; @@ -61,7 +61,7 @@ public static string Tr(string id, params string[] replacements) return str; } - private void ConfigureLanguage(string? langCode = null) + private static void ConfigureLanguage(string? langCode = null) { var lang = (langCode ?? Plugin.PluginInterface.UiLanguage) switch { @@ -72,6 +72,6 @@ private void ConfigureLanguage(string? langCode = null) _ => "en" }; Resources.Culture = new CultureInfo(lang ?? "en"); - LocaleChanged?.Invoke(this, EventArgs.Empty); + LocaleChanged?.Invoke(null, EventArgs.Empty); } } \ No newline at end of file diff --git a/Plugin/Plugin.cs b/Plugin/Plugin.cs index 622110b..ba36161 100644 --- a/Plugin/Plugin.cs +++ b/Plugin/Plugin.cs @@ -20,6 +20,7 @@ using EngageTimer.Commands; using EngageTimer.Configuration; using EngageTimer.Game; +using EngageTimer.Localization; using EngageTimer.Status; using EngageTimer.Ui; using JetBrains.Annotations; @@ -43,7 +44,6 @@ public sealed class Plugin : IDalamudPlugin [PluginService] public static IToastGui ToastGui { get; private set; } = null!; public static ConfigurationFile Config { get; private set; } = null!; public static State State { get; private set; } = null!; - public static Translator Translator { get; private set; } = null!; public static PluginUi PluginUi { get; private set; } = null!; public static NumberTextures NumberTextures { get; set; } = null!; public static string PluginPath { get; private set; } = null!; @@ -57,9 +57,9 @@ public Plugin(DalamudPluginInterface pluginInterface) { PluginPath = PluginInterface.AssemblyLocation.DirectoryName ?? throw new InvalidOperationException("Cannot find plugin directory"); + Translator.Register(); Config = ConfigurationLoader.Load(); State = new State(); - Translator = new Translator(); FrameworkThings = new FrameworkThings(); MainCommand = new MainCommand(); SettingsCommand = new SettingsCommand(); @@ -70,12 +70,12 @@ public Plugin(DalamudPluginInterface pluginInterface) void IDisposable.Dispose() { + Translator.Unregister(); PluginInterface.SavePluginConfig(Config); CombatAlarm.Dispose(); PluginUi.Dispose(); FrameworkThings.Dispose(); MainCommand.Dispose(); SettingsCommand.Dispose(); - Translator.Dispose(); } } \ No newline at end of file diff --git a/Plugin/Properties/Resources.Designer.cs b/Plugin/Properties/Resources.Designer.cs index 63ace22..11fe5b2 100644 --- a/Plugin/Properties/Resources.Designer.cs +++ b/Plugin/Properties/Resources.Designer.cs @@ -693,6 +693,24 @@ internal static string Settings_CountdownTab_CountdownWindowCentered { } } + /// + /// Looks up a localized string similar to Don't overlap with game countdown (default). + /// + internal static string Settings_CountdownTab_DefaultOriginalCountDown { + get { + return ResourceManager.GetString("Settings_CountdownTab_DefaultOriginalCountDown", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hides the custom countdown under 5 to prevent overlapping with the vanilla one.. + /// + internal static string Settings_CountdownTab_DefaultOriginalCountDown_Help { + get { + return ResourceManager.GetString("Settings_CountdownTab_DefaultOriginalCountDown_Help", resourceCulture); + } + } + /// /// Looks up a localized string similar to Enable big countdown. /// @@ -729,6 +747,24 @@ internal static string Settings_CountdownTab_HideOriginalCountDown_Help { } } + /// + /// Looks up a localized string similar to Draw even if original countdown is visible. + /// + internal static string Settings_CountdownTab_IgnoreOriginalCountDown { + get { + return ResourceManager.GetString("Settings_CountdownTab_IgnoreOriginalCountDown", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Allows you to have the vanilla countdown showing on your game but still use the custom one in a corner or overlaping if you like chaos. Useful if you setup your OBS to not capture addons and want to look unmodified.. + /// + internal static string Settings_CountdownTab_IgnoreOriginalCountDown_Help { + get { + return ResourceManager.GetString("Settings_CountdownTab_IgnoreOriginalCountDown_Help", resourceCulture); + } + } + /// /// Looks up a localized string similar to The "big countdown" feature adds the missing numbers to the in-game timer !. /// diff --git a/Plugin/Properties/Resources.resx b/Plugin/Properties/Resources.resx index c1e6dca..05983f1 100644 --- a/Plugin/Properties/Resources.resx +++ b/Plugin/Properties/Resources.resx @@ -617,4 +617,16 @@ help text for the /eg settings command An empty or invalid alarm list was imported + + Draw even if original countdown is visible + + + Allows you to have the vanilla countdown showing on your game but still use the custom one in a corner or overlaping if you like chaos. Useful if you setup your OBS to not capture addons and want to look unmodified. + + + Don't overlap with game countdown (default) + + + Hides the custom countdown under 5 to prevent overlapping with the vanilla one. + \ No newline at end of file diff --git a/Plugin/Status/CombatAlarm.cs b/Plugin/Status/CombatAlarm.cs index 6360244..1a5dd77 100644 --- a/Plugin/Status/CombatAlarm.cs +++ b/Plugin/Status/CombatAlarm.cs @@ -22,6 +22,7 @@ using Dalamud.Plugin.Services; using EngageTimer.Configuration; using EngageTimer.Game; +using EngageTimer.Localization; using EngageTimer.Ui; using Newtonsoft.Json; diff --git a/Plugin/Ui/Components.cs b/Plugin/Ui/Components.cs index 454c21f..5060353 100644 --- a/Plugin/Ui/Components.cs +++ b/Plugin/Ui/Components.cs @@ -20,6 +20,7 @@ using Dalamud.Interface.Colors; using Dalamud.Interface.Components; using EngageTimer.Attributes; +using EngageTimer.Localization; using ImGuiNET; namespace EngageTimer.Ui; diff --git a/Plugin/Ui/CountDown.cs b/Plugin/Ui/CountDown.cs index 25773c5..70ae630 100644 --- a/Plugin/Ui/CountDown.cs +++ b/Plugin/Ui/CountDown.cs @@ -18,7 +18,6 @@ using System.Globalization; using System.Numerics; using Dalamud.Interface.Animation; -using Dalamud.Interface.Animation.EasingFunctions; using EngageTimer.Configuration; using EngageTimer.Game; using EngageTimer.Ui.CustomEasing; @@ -30,14 +29,9 @@ public sealed class CountDown : IDisposable { private const float BaseNumberScale = 1f; private const int GameCountdownWidth = 60; // just trust in the magic numbers - private const float AnimationSize = .7f; - private readonly Easing _easing = new OutCubic(new TimeSpan(0, 0, 0, 0, 1000)); - - private readonly Easing _easingOpacity = new OpacityEasing( - new TimeSpan(0, 0, 0, 0, 1000), - 1, -0.02, .71, 1 - ); + private readonly Easing _easing = new NumberEasing(); + private readonly Easing _easingOpacity = new OpacityEasing(); private bool _accurateMode; private const string WindowTitle = "EngageTimer Countdown"; @@ -76,13 +70,12 @@ private void ConfigurationOnOnSave(object? sender, EventArgs e) */ private void UpdateFromConfig() { - _accurateMode = Plugin.Config.Countdown.HideOriginalAddon && Plugin.Config.Countdown.AccurateMode; + _accurateMode = Plugin.Config.Countdown.AccurateMode && + (Plugin.Config.Countdown.HideOriginalAddon || Plugin.Config.Countdown.IgnoreOriginalAddon); } private void FirstDraw() { - if (!_firstDraw) return; - var visible = true; var flags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoTitleBar @@ -119,10 +112,11 @@ public void Draw() // ImGui.End(); // #endif - FirstDraw(); + if (_firstDraw) FirstDraw(); if (!Plugin.Config.Countdown.Display || !Plugin.State.CountingDown) return; - var showMainCountdown = Plugin.State.CountDownValue > 5 || Plugin.Config.Countdown.HideOriginalAddon; + var showMainCountdown = Plugin.Config.Countdown.HideOriginalAddon || + Plugin.Config.Countdown.IgnoreOriginalAddon || Plugin.State.CountDownValue > 5; if (showMainCountdown && Plugin.Config.Countdown.EnableDisplayThreshold && Plugin.State.CountDownValue > Plugin.Config.Countdown.DisplayThreshold) return; @@ -136,7 +130,7 @@ public void Draw() if (Plugin.Config.Countdown.Animate) { - var second = (int)Plugin.State.CountDownValue; + var second = (int) Plugin.State.CountDownValue; if (_lastSecond != second) { _easing.Restart(); @@ -148,8 +142,8 @@ public void Draw() _easingOpacity.Update(); if (Plugin.Config.Countdown.AnimateScale) { - maxNumberScale = numberScale + AnimationSize; - numberScale += AnimationSize * (1 - (float)_easing.Value); + maxNumberScale = numberScale + NumberEasing.StartSize; + numberScale += NumberEasing.StartSize * (1 - (float) _easing.Value); } } } @@ -196,7 +190,7 @@ public void Draw() ImGui.GetWindowPos(), ImGui.GetWindowPos() + ImGui.GetWindowSize(), ImGui.GetColorU32(ImGuiCol.Text), 0f, ImDrawFlags.None, - 7f + (float)Math.Sin(ImGui.GetTime() * 2) * 5f); + 7f + (float) Math.Sin(ImGui.GetTime() * 2) * 5f); d.AddRect( ImGui.GetWindowPos(), ImGui.GetWindowPos() + ImGui.GetWindowSize(), @@ -208,7 +202,7 @@ public void Draw() DrawCountdown(showMainCountdown, numberScale, negativeMargin, false); if (Plugin.Config.Countdown.Animate && Plugin.Config.Countdown.AnimateOpacity) { - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, (float)_easingOpacity.Value); + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, (float) _easingOpacity.Value); DrawCountdown(showMainCountdown, numberScale, negativeMargin, true); ImGui.PopStyleVar(); } diff --git a/Plugin/Ui/CustomEasing/NumberEasing.cs b/Plugin/Ui/CustomEasing/NumberEasing.cs new file mode 100644 index 0000000..10d5b1f --- /dev/null +++ b/Plugin/Ui/CustomEasing/NumberEasing.cs @@ -0,0 +1,37 @@ +// This file is part of EngageTimer +// Copyright (C) 2023 Xorus +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +using System; +using Dalamud.Interface.Animation; + +namespace EngageTimer.Ui.CustomEasing; + +public class NumberEasing : Easing +{ + public const float StartSize = .76f; + + public NumberEasing() : base(new TimeSpan(0, 0, 0, 0, 400)) + { + } + + /** + * I did not do a frame analysis yet, but it seems linear, I hate it but must match it. + */ + public override void Update() + { + if (this.Progress > 1) return; + this.Value = this.Progress; + } +} \ No newline at end of file diff --git a/Plugin/Ui/CustomEasing/OpacityEasing.cs b/Plugin/Ui/CustomEasing/OpacityEasing.cs index 4f44ff5..52967c3 100644 --- a/Plugin/Ui/CustomEasing/OpacityEasing.cs +++ b/Plugin/Ui/CustomEasing/OpacityEasing.cs @@ -20,17 +20,8 @@ namespace EngageTimer.Ui.CustomEasing; public class OpacityEasing : Easing { - private readonly double _p0; - private readonly double _p1; - private readonly double _p2; - private readonly double _p3; - - public OpacityEasing(TimeSpan duration, double p0, double p1, double p2, double p3) : base(duration) + public OpacityEasing() : base(new TimeSpan(0, 0, 0, 0, 1000)) { - _p0 = p0; - _p1 = p1; - _p2 = p2; - _p3 = p3; } // https://www.desmos.com/calculator/6btgm8tjk0 diff --git a/Plugin/Ui/Modal.cs b/Plugin/Ui/Modal.cs index dc62816..2c3503d 100644 --- a/Plugin/Ui/Modal.cs +++ b/Plugin/Ui/Modal.cs @@ -15,6 +15,7 @@ using System; using System.Numerics; +using EngageTimer.Localization; using ImGuiNET; namespace EngageTimer.Ui; diff --git a/Plugin/Ui/Settings.cs b/Plugin/Ui/Settings.cs index 0781b58..0fcfdd3 100644 --- a/Plugin/Ui/Settings.cs +++ b/Plugin/Ui/Settings.cs @@ -22,6 +22,7 @@ using Dalamud.Interface.Components; using Dalamud.Interface.Windowing; using EngageTimer.Configuration; +using EngageTimer.Localization; using EngageTimer.Ui.Color; using EngageTimer.Ui.SettingsTab; using ImGuiNET; @@ -33,13 +34,18 @@ public class Settings : Window { public Settings() : base("Settings", ImGuiWindowFlags.AlwaysAutoResize) { - Plugin.Translator.LocaleChanged += (_, _) => UpdateWindowName(); + Translator.LocaleChanged += (_, _) => UpdateWindowName(); UpdateWindowName(); #if DEBUG IsOpen = true; #endif } + public override void OnClose() + { + CountdownTab.OnClose(); + } + private void UpdateWindowName() { WindowName = Translator.TrId("Settings_Title"); @@ -49,7 +55,7 @@ public override void Draw() { CountdownTab.DebounceTextureCreation(); CountdownTab.UpdateMock(); - + if (ImGui.BeginTabBar("EngageTimerSettingsTabBar", ImGuiTabBarFlags.None)) { ImGui.PushItemWidth(100f); diff --git a/Plugin/Ui/SettingsTab/AlarmsTab.cs b/Plugin/Ui/SettingsTab/AlarmsTab.cs index a5cde89..538ef63 100644 --- a/Plugin/Ui/SettingsTab/AlarmsTab.cs +++ b/Plugin/Ui/SettingsTab/AlarmsTab.cs @@ -19,6 +19,7 @@ using Dalamud.Interface.Components; using Dalamud.Interface.ImGuiFileDialog; using EngageTimer.Configuration; +using EngageTimer.Localization; using EngageTimer.Status; using ImGuiNET; diff --git a/Plugin/Ui/SettingsTab/CountdownTab.cs b/Plugin/Ui/SettingsTab/CountdownTab.cs index 6176569..0ac122a 100644 --- a/Plugin/Ui/SettingsTab/CountdownTab.cs +++ b/Plugin/Ui/SettingsTab/CountdownTab.cs @@ -19,7 +19,9 @@ using Dalamud.Interface; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; +using Dalamud.Plugin.Internal.Profiles; using EngageTimer.Configuration; +using EngageTimer.Localization; using EngageTimer.Ui.Color; using ImGuiNET; @@ -55,7 +57,13 @@ public static void UpdateMock() if (_mockTarget == 0 || _mockTarget < ImGui.GetTime()) _mockTarget = ImGui.GetTime() + 30d; Plugin.State.CountingDown = true; - Plugin.State.CountDownValue = (float)(_mockTarget - ImGui.GetTime()); + Plugin.State.CountDownValue = (float) (_mockTarget - ImGui.GetTime()); + } + + public static void OnClose() + { + _mocking = false; + Plugin.State.Mocked = false; } private static void ToggleMock() @@ -79,21 +87,26 @@ public static void Draw() { var configuration = Plugin.Config; ImGui.PushTextWrapPos(); - ImGui.Text(Translator.Tr("Settings_CountdownTab_Info1")); - if (ImGui.Button( - (_mocking - ? Translator.Tr("Settings_CountdownTab_Test_Stop") - : Translator.Tr("Settings_CountdownTab_Test_Start")) - + "###Settings_CountdownTab_Test")) ToggleMock(); + ImGui.Text("Settings_CountdownTab_Info1".Tr()); + if (ImGui.Button(_mocking.TrYesNo("Settings_CountdownTab_Test_Stop", "Settings_CountdownTab_Test_Start") + + "###Settings_CountdownTab_Test")) ToggleMock(); ImGui.PopTextWrapPos(); ImGui.Separator(); Components.AutoField(Plugin.Config.Countdown, "Display"); - Components.AutoField(Plugin.Config.Countdown, "HideOriginalAddon"); + ImGui.Indent(); + CountdownHideOptions(); + ImGui.Unindent(); Components.AutoField(Plugin.Config.Countdown, "EnableDecimals"); Components.AutoField(Plugin.Config.Countdown, "DecimalPrecision", sameLine: true); Components.AutoField(Plugin.Config.Countdown, "EnableTickingSound"); + if (Plugin.Config.Countdown.HideOriginalAddon && Plugin.Config.Countdown.IgnoreOriginalAddon) + { + Plugin.Config.Countdown.IgnoreOriginalAddon = false; + Plugin.Config.Save(); + } + if (Plugin.Config.Countdown.EnableTickingSound) { ImGui.Indent(); @@ -113,26 +126,65 @@ public static void Draw() Components.AutoField(Plugin.Config.Countdown, "DisplayThreshold", sameLine: true); ImGui.Separator(); - if (ImGui.CollapsingHeader(Translator.TrId("Settings_CountdownTab_PositioningTitle"))) + if (ImGui.CollapsingHeader("Settings_CountdownTab_PositioningTitle".TrId())) CountdownPositionAndSize(); - if (ImGui.CollapsingHeader(Translator.TrId("Settings_CountdownTab_Texture"), ImGuiTreeNodeFlags.DefaultOpen)) + if (ImGui.CollapsingHeader("Settings_CountdownTab_Texture".TrId(), ImGuiTreeNodeFlags.DefaultOpen)) CountdownNumberStyle(); ImGui.Separator(); - var hideOriginal = !configuration.Countdown.HideOriginalAddon; - if (hideOriginal) ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.5f); + var hideAccurate = !(configuration.Countdown.HideOriginalAddon || configuration.Countdown.IgnoreOriginalAddon); + if (hideAccurate) ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.3f); Components.AutoField(Plugin.Config.Countdown, "AccurateMode"); - if (hideOriginal) ImGui.PopStyleVar(); + if (hideAccurate) ImGui.PopStyleVar(); ImGui.Indent(); ImGui.PushTextWrapPos(500f); ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudGrey); - ImGui.TextWrapped(Translator.Tr("Settings_CountdownTab_AccurateMode_Help")); + ImGui.TextWrapped("Settings_CountdownTab_AccurateMode_Help".Tr()); ImGui.PopTextWrapPos(); ImGui.PopStyleColor(); ImGui.Unindent(); } + public static void CountdownHideOptions() + { + var cdStatus = 0; + if (Plugin.Config.Countdown.HideOriginalAddon) cdStatus = 1; + else if (Plugin.Config.Countdown.IgnoreOriginalAddon) cdStatus = 2; + + // ReSharper disable once ReplaceWithSingleAssignment.False - unreadable + var changed = false; + // ReSharper disable once ConvertIfToOrExpression - would hide the next button on the click frame + if (ImGui.RadioButton("Settings_CountdownTab_DefaultOriginalCountDown".Tr(), ref cdStatus, 0)) + changed = true; + Components.TooltipOnItemHovered("Settings_CountdownTab_DefaultOriginalCountDown_Help".Tr()); + if (ImGui.RadioButton("Settings_CountdownTab_HideOriginalCountDown".Tr(), ref cdStatus, 1)) + changed = true; + Components.TooltipOnItemHovered("Settings_CountdownTab_HideOriginalCountDown_Help".Tr()); + if (ImGui.RadioButton("Settings_CountdownTab_IgnoreOriginalCountDown".Tr(), ref cdStatus, 2)) + changed = true; + Components.TooltipOnItemHovered("Settings_CountdownTab_IgnoreOriginalCountDown_Help".Tr()); + if (!changed) return; + + switch (cdStatus) + { + case 0: + Plugin.Config.Countdown.HideOriginalAddon = false; + Plugin.Config.Countdown.IgnoreOriginalAddon = false; + break; + case 1: + Plugin.Config.Countdown.HideOriginalAddon = true; + Plugin.Config.Countdown.IgnoreOriginalAddon = false; + break; + case 2: + Plugin.Config.Countdown.HideOriginalAddon = false; + Plugin.Config.Countdown.IgnoreOriginalAddon = true; + break; + } + + Plugin.Config.Save(); + } + private static void CountdownPositionAndSize() { CountDown.ShowOutline = true; @@ -140,32 +192,32 @@ private static void CountdownPositionAndSize() if (!Plugin.Config.Countdown.HideOriginalAddon) { ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed); - ImGui.TextWrapped(Translator.Tr("Settings_CountdownTab_PositionWarning")); + ImGui.TextWrapped("Settings_CountdownTab_PositionWarning".Tr()); ImGui.PopStyleColor(); } - ImGui.TextWrapped(Translator.Tr("Settings_CountdownTab_MultiMonitorWarning")); + ImGui.TextWrapped("Settings_CountdownTab_MultiMonitorWarning".Tr()); var countdownOffsetX = Plugin.Config.Countdown.WindowOffset.X * 100; - if (ImGui.DragFloat(Translator.TrId("Settings_CountdownTab_OffsetX"), ref countdownOffsetX, .1f)) + if (ImGui.DragFloat("Settings_CountdownTab_OffsetX".TrId(), ref countdownOffsetX, .1f)) { Plugin.Config.Countdown.WindowOffset = - new Vector2(countdownOffsetX / 100, Plugin.Config.Countdown.WindowOffset.Y); + Plugin.Config.Countdown.WindowOffset with {X = countdownOffsetX / 100}; Plugin.Config.Save(); } ImGui.SameLine(); var countdownOffsetY = Plugin.Config.Countdown.WindowOffset.Y * 100; - if (ImGui.DragFloat(Translator.TrId("Settings_CountdownTab_OffsetY"), ref countdownOffsetY, .1f)) + if (ImGui.DragFloat("Settings_CountdownTab_OffsetY".TrId(), ref countdownOffsetY, .1f)) { Plugin.Config.Countdown.WindowOffset = - new Vector2(Plugin.Config.Countdown.WindowOffset.X, countdownOffsetY / 100); + Plugin.Config.Countdown.WindowOffset with {Y = countdownOffsetY / 100}; Plugin.Config.Save(); } ImGui.SameLine(); - ImGui.Text(Translator.Tr("Settings_CountdownTab_OffsetText")); + ImGui.Text("Settings_CountdownTab_OffsetText".Tr()); ImGui.SameLine(); if (ImGuiComponents.IconButton(FontAwesomeIcon.Undo.ToIconString() + "###reset_cd_offset")) @@ -176,7 +228,7 @@ private static void CountdownPositionAndSize() var countdownScale = Plugin.Config.Countdown.Scale; ImGui.PushItemWidth(100f); - if (ImGui.InputFloat(Translator.TrId("Settings_CountdownTab_CountdownScale"), ref countdownScale, .01f)) + if (ImGui.InputFloat("Settings_CountdownTab_CountdownScale".TrId(), ref countdownScale, .01f)) { Plugin.Config.Countdown.Scale = Math.Clamp(countdownScale, 0.05f, 15f); Plugin.Config.Save(); @@ -184,13 +236,13 @@ private static void CountdownPositionAndSize() ImGui.PopItemWidth(); - var align = (int)Plugin.Config.Countdown.Align; - if (ImGui.Combo(Translator.TrId("Settings_CountdownTab_CountdownAlign"), ref align, - Translator.Tr("Settings_FWTab_TextAlign_Left") + "###Left\0" + - Translator.Tr("Settings_FWTab_TextAlign_Center") + "###Center\0" + - Translator.Tr("Settings_FWTab_TextAlign_Right") + "###Right")) + var align = (int) Plugin.Config.Countdown.Align; + if (ImGui.Combo("Settings_CountdownTab_CountdownAlign".TrId(), ref align, + "Settings_FWTab_TextAlign_Left".Tr() + "###Left\0" + + "Settings_FWTab_TextAlign_Center".Tr() + "###Center\0" + + "Settings_FWTab_TextAlign_Right".Tr() + "###Right")) { - Plugin.Config.Countdown.Align = (ConfigurationFile.TextAlign)align; + Plugin.Config.Countdown.Align = (ConfigurationFile.TextAlign) align; Plugin.Config.Save(); } @@ -226,8 +278,8 @@ private static void CountdownNumberStyle() ImGui.BeginGroup(); ImGui.PushItemWidth(200f); - choiceString += Translator.TrId("Settings_CountdownTab_Texture_custom"); - if (ImGui.Combo("###DropDown_" + Translator.Tr("Settings_CountdownTab_Texture"), ref currentTexture, + choiceString += "Settings_CountdownTab_Texture_custom".TrId(); + if (ImGui.Combo("###DropDown_" + "Settings_CountdownTab_Texture".Tr(), ref currentTexture, choiceString)) { configuration.Countdown.TexturePreset = currentTexture < choices.Count() ? choices[currentTexture] : ""; @@ -242,9 +294,9 @@ private static void CountdownNumberStyle() { _tempTexturePath ??= configuration.Countdown.TextureDirectory ?? ""; ImGui.PushItemWidth(400f); - ImGui.InputText(Translator.TrId("Settings_CountdownTab_Texture_Custom_Path"), ref _tempTexturePath, 1024); + ImGui.InputText("Settings_CountdownTab_Texture_Custom_Path".TrId(), ref _tempTexturePath, 1024); ImGui.PopItemWidth(); - if (ImGui.Button(Translator.TrId("Settings_CountdownTab_Texture_Custom_Load"))) + if (ImGui.Button("Settings_CountdownTab_Texture_Custom_Load".TrId())) { configuration.Countdown.TextureDirectory = _tempTexturePath; configuration.Save(); @@ -252,13 +304,13 @@ private static void CountdownNumberStyle() } } - if (ImGui.CollapsingHeader(Translator.TrId("Settings_CountdownTab_NumberStyleTitle"))) CountdownNumberColor(); + if (ImGui.CollapsingHeader("Settings_CountdownTab_NumberStyleTitle".TrId())) CountdownNumberColor(); - if (ImGui.CollapsingHeader(Translator.TrId("Settings_CountdownTab_NumberStyle_Advanced"))) + if (ImGui.CollapsingHeader("Settings_CountdownTab_NumberStyle_Advanced".TrId())) { Components.AutoField(Plugin.Config.Countdown, "LeadingZero"); Components.Checkbox(Plugin.Config.Countdown.CustomNegativeMargin != null, - Translator.TrId("Settings_CountdownTab_NumberStyle_EnableCustomNegativeMargin"), + "Settings_CountdownTab_NumberStyle_EnableCustomNegativeMargin".TrId(), v => Plugin.Config.Countdown.CustomNegativeMargin = v ? 20f : null); if (Plugin.Config.Countdown.CustomNegativeMargin != null) @@ -266,7 +318,7 @@ private static void CountdownNumberStyle() ImGui.Indent(); ImGui.PushItemWidth(100f); var nm = configuration.Countdown.CustomNegativeMargin ?? 20f; - if (ImGui.InputFloat(Translator.TrId("Settings_CountdownTab_NumberStyle_CustomNegativeMargin"), ref nm, + if (ImGui.InputFloat("Settings_CountdownTab_NumberStyle_CustomNegativeMargin".TrId(), ref nm, 1f)) { configuration.Countdown.CustomNegativeMargin = nm; @@ -288,7 +340,7 @@ private static void CountdownNumberColor() // --- Luminance --- ImGui.PushItemWidth(250f); { - Components.ResettableSlider("lum", "± " + Translator.TrId("Settings_CountdownTab_NumberLuminance"), + Components.ResettableSlider("lum", "± " + "Settings_CountdownTab_NumberLuminance".TrId(), c.Luminance, 0f, -1f, 1f, value => { c.Luminance = value; @@ -296,7 +348,7 @@ private static void CountdownNumberColor() }); // --- Saturation --- - Components.ResettableSlider("sat", "± " + Translator.TrId("Settings_CountdownTab_NumberSaturation"), + Components.ResettableSlider("sat", "± " + "Settings_CountdownTab_NumberSaturation".TrId(), c.Saturation, 0f, -1f, 1f, value => { c.Saturation = value; @@ -312,7 +364,7 @@ private static void CountdownNumberColor() } Components.ResettableDraggable("hue", - (c.NumberRecolorMode ? "" : "± ") + Translator.TrId("Settings_CountdownTab_NumberHue"), + (c.NumberRecolorMode ? "" : "± ") + "Settings_CountdownTab_NumberHue".TrId(), c.Hue, 0, 0, 360, value => { c.Hue = value; @@ -322,7 +374,7 @@ private static void CountdownNumberColor() } ImGui.PopItemWidth(); - Components.Checkbox(c.NumberRecolorMode, Translator.TrId("Settings_CountdownTab_NumberRecolor"), + Components.Checkbox(c.NumberRecolorMode, "Settings_CountdownTab_NumberRecolor".TrId(), v => { c.NumberRecolorMode = v; diff --git a/Plugin/Ui/SettingsTab/DtrTab.cs b/Plugin/Ui/SettingsTab/DtrTab.cs index a4eb4d5..ccc540f 100644 --- a/Plugin/Ui/SettingsTab/DtrTab.cs +++ b/Plugin/Ui/SettingsTab/DtrTab.cs @@ -14,6 +14,7 @@ // along with this program. If not, see . using EngageTimer.Configuration; +using EngageTimer.Localization; using ImGuiNET; namespace EngageTimer.Ui.SettingsTab; diff --git a/Plugin/Ui/SettingsTab/FloatingWindowTab.cs b/Plugin/Ui/SettingsTab/FloatingWindowTab.cs index 020e64f..6cb54d4 100644 --- a/Plugin/Ui/SettingsTab/FloatingWindowTab.cs +++ b/Plugin/Ui/SettingsTab/FloatingWindowTab.cs @@ -16,6 +16,7 @@ using System; using Dalamud.Interface.Components; using EngageTimer.Configuration; +using EngageTimer.Localization; using ImGuiNET; namespace EngageTimer.Ui.SettingsTab; diff --git a/Plugin/Ui/SettingsTab/WebServerTab.cs b/Plugin/Ui/SettingsTab/WebServerTab.cs index 57ea251..d6d3bcb 100644 --- a/Plugin/Ui/SettingsTab/WebServerTab.cs +++ b/Plugin/Ui/SettingsTab/WebServerTab.cs @@ -15,6 +15,7 @@ using Dalamud.Interface; using Dalamud.Interface.Components; +using EngageTimer.Localization; using ImGuiNET; namespace EngageTimer.Ui.SettingsTab;