From d6d5151e90f8f36a1b020e3a5e563fa198d195b8 Mon Sep 17 00:00:00 2001 From: xorus Date: Sat, 5 Oct 2024 12:31:51 +0200 Subject: [PATCH] Hide stopwatch in cutscenes option, fixes #68 --- Plugin/Configuration/FloatingWindowConfiguration.cs | 3 +++ Plugin/EngageTimer.csproj | 2 +- Plugin/Game/CountdownHook.cs | 1 + Plugin/Properties/Strings.resx | 3 +++ Plugin/Status/State.cs | 1 + Plugin/Ui/FloatingWindow.cs | 2 ++ Plugin/Ui/SettingsTab/FloatingWindowTab.cs | 3 ++- 7 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Plugin/Configuration/FloatingWindowConfiguration.cs b/Plugin/Configuration/FloatingWindowConfiguration.cs index c890dc7..a87c2c9 100644 --- a/Plugin/Configuration/FloatingWindowConfiguration.cs +++ b/Plugin/Configuration/FloatingWindowConfiguration.cs @@ -50,6 +50,9 @@ public class FloatingWindowConfiguration [AutoField("Settings_FWTab_DisplayStopwatchOnlyInDuty")] public bool StopwatchOnlyInDuty { get; set; } = false; + + [AutoField("Settings_FWTab_HideInCutscenes")] + public bool HideInCutscenes { get; set; } = true; [AutoField("Settings_FWTab_StopwatchAsSeconds")] public bool StopwatchAsSeconds { get; set; } = false; diff --git a/Plugin/EngageTimer.csproj b/Plugin/EngageTimer.csproj index 8f3696a..537ba52 100644 --- a/Plugin/EngageTimer.csproj +++ b/Plugin/EngageTimer.csproj @@ -8,7 +8,7 @@ true false false - 2.4.0.1 + 2.4.1.0 false true true diff --git a/Plugin/Game/CountdownHook.cs b/Plugin/Game/CountdownHook.cs index f642108..cabbfe4 100644 --- a/Plugin/Game/CountdownHook.cs +++ b/Plugin/Game/CountdownHook.cs @@ -63,6 +63,7 @@ public void Update() if (_state.Mocked) return; UpdateCountDown(); _state.InInstance = Plugin.Condition[ConditionFlag.BoundByDuty]; + _state.InCutscene = Plugin.Condition[ConditionFlag.OccupiedInCutSceneEvent]; } private void UpdateCountDown() diff --git a/Plugin/Properties/Strings.resx b/Plugin/Properties/Strings.resx index 78c1969..f161ae6 100644 --- a/Plugin/Properties/Strings.resx +++ b/Plugin/Properties/Strings.resx @@ -641,4 +641,7 @@ help text for the /eg settings command Hide window border + + Hide in cutscenes + \ No newline at end of file diff --git a/Plugin/Status/State.cs b/Plugin/Status/State.cs index dc080a5..f82c171 100644 --- a/Plugin/Status/State.cs +++ b/Plugin/Status/State.cs @@ -22,6 +22,7 @@ public class State { private bool _countingDown; private bool _inCombat; + public bool InCutscene { get; set; } public TimeSpan CombatDuration { get; set; } public DateTime CombatEnd { get; set; } public DateTime CombatStart { get; set; } diff --git a/Plugin/Ui/FloatingWindow.cs b/Plugin/Ui/FloatingWindow.cs index fbc21c5..1884269 100644 --- a/Plugin/Ui/FloatingWindow.cs +++ b/Plugin/Ui/FloatingWindow.cs @@ -55,6 +55,8 @@ private static bool StopwatchActive() var displayStopwatch = Plugin.Config.FloatingWindow.EnableStopwatch; if (!displayStopwatch) return false; + if (Plugin.Config.FloatingWindow.HideInCutscenes && Plugin.State.InCutscene) return false; + if (Plugin.Config.FloatingWindow.AutoHide && (DateTime.Now - Plugin.State.CombatEnd).TotalSeconds > Plugin.Config.FloatingWindow.AutoHideTimeout) return false; diff --git a/Plugin/Ui/SettingsTab/FloatingWindowTab.cs b/Plugin/Ui/SettingsTab/FloatingWindowTab.cs index 0a577bb..7378644 100644 --- a/Plugin/Ui/SettingsTab/FloatingWindowTab.cs +++ b/Plugin/Ui/SettingsTab/FloatingWindowTab.cs @@ -41,6 +41,7 @@ public static void Draw() Components.AutoField(Plugin.Config.FloatingWindow, "Lock"); ImGuiComponents.HelpMarker(Strings.Settings_FWTab_Lock_Help); + Components.AutoField(Plugin.Config.FloatingWindow, "HideInCutscenes"); Components.AutoField(Plugin.Config.FloatingWindow, "AutoHide"); Components.AutoField(Plugin.Config.FloatingWindow, "AutoHideTimeout", sameLine: true); @@ -51,7 +52,7 @@ public static void Draw() Components.AutoField(Plugin.Config.FloatingWindow, "EnableStopwatch"); Components.AutoField(Plugin.Config.FloatingWindow, "DecimalStopwatchPrecision", sameLine: true); - + ImGui.Separator(); if (ImGui.CollapsingHeader(Translator.TrId("Settings_FWTab_Styling"))) FwStyling(); ImGui.Separator();