From 059c7322c8ed588901369c68ae3c81220d39ea60 Mon Sep 17 00:00:00 2001 From: Infi Date: Wed, 10 Apr 2024 19:07:35 +0200 Subject: [PATCH] Add option to hide chat during loading screens [default false] --- ChatTwo/Configuration.cs | 2 ++ ChatTwo/Plugin.cs | 30 +++++++++++++++++--------- ChatTwo/Resources/Language.Designer.cs | 20 ++++++++++++++++- ChatTwo/Resources/Language.resx | 8 ++++++- ChatTwo/Ui/SettingsTabs/Display.cs | 6 ++++++ 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index 6f7a2b0..4cd9a41 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -17,6 +17,7 @@ internal class Configuration : IPluginConfiguration { public bool HideDuringCutscenes = true; public bool HideWhenNotLoggedIn = true; public bool HideWhenUiHidden = true; + public bool HideInLoadingScreens; public bool NativeItemTooltips = true; public bool PrettierTimestamps = true; public bool MoreCompactPretty; @@ -60,6 +61,7 @@ internal class Configuration : IPluginConfiguration { HideDuringCutscenes = other.HideDuringCutscenes; HideWhenNotLoggedIn = other.HideWhenNotLoggedIn; HideWhenUiHidden = other.HideWhenUiHidden; + HideInLoadingScreens = other.HideInLoadingScreens; NativeItemTooltips = other.NativeItemTooltips; PrettierTimestamps = other.PrettierTimestamps; MoreCompactPretty = other.MoreCompactPretty; diff --git a/ChatTwo/Plugin.cs b/ChatTwo/Plugin.cs index 158f53e..b9b4c8d 100755 --- a/ChatTwo/Plugin.cs +++ b/ChatTwo/Plugin.cs @@ -5,8 +5,8 @@ using ChatTwo.Ipc; using ChatTwo.Resources; using ChatTwo.Ui; using ChatTwo.Util; +using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Objects; -using Dalamud.Interface.Style; using Dalamud.Interface.Windowing; using Dalamud.IoC; using Dalamud.Plugin; @@ -17,7 +17,8 @@ using XivCommon; namespace ChatTwo; // ReSharper disable once ClassNeverInstantiated.Global -public sealed class Plugin : IDalamudPlugin { +public sealed class Plugin : IDalamudPlugin +{ internal const string PluginName = "Chat 2"; [PluginService] internal static IPluginLog Log { get; private set; } = null!; @@ -63,7 +64,8 @@ public sealed class Plugin : IDalamudPlugin { internal DateTime GameStarted { get; } #pragma warning disable CS8618 - public Plugin() { + public Plugin() + { GameStarted = Process.GetCurrentProcess().StartTime.ToUniversalTime(); Config = Interface.GetPluginConfig() as Configuration ?? new Configuration(); @@ -112,7 +114,8 @@ public sealed class Plugin : IDalamudPlugin { } #pragma warning restore CS8618 - public void Dispose() { + public void Dispose() + { Interface.LanguageChanged -= LanguageChanged; Interface.UiBuilder.Draw -= Draw; Framework.Update -= FrameworkUpdate; @@ -135,6 +138,9 @@ public sealed class Plugin : IDalamudPlugin { private void Draw() { + if (Config.HideInLoadingScreens && Condition[ConditionFlag.BetweenAreas]) + return; + Interface.UiBuilder.DisableUserUiHide = !Config.HideWhenUiHidden; ChatLogWindow.DefaultText = ImGui.GetStyle().Colors[(int) ImGuiCol.Text]; @@ -144,11 +150,13 @@ public sealed class Plugin : IDalamudPlugin { } } - internal void SaveConfig() { + internal void SaveConfig() + { Interface.SavePluginConfig(Config); } - internal void LanguageChanged(string langCode) { + internal void LanguageChanged(string langCode) + { var info = Config.LanguageOverride is LanguageOverride.None ? new CultureInfo(langCode) : new CultureInfo(Config.LanguageOverride.Code()); @@ -156,15 +164,17 @@ public sealed class Plugin : IDalamudPlugin { Language.Culture = info; } - private static readonly string[] ChatAddonNames = { + private static readonly string[] ChatAddonNames = + [ "ChatLog", "ChatLogPanel_0", "ChatLogPanel_1", "ChatLogPanel_2", - "ChatLogPanel_3", - }; + "ChatLogPanel_3" + ]; - private void FrameworkUpdate(IFramework framework) { + private void FrameworkUpdate(IFramework framework) + { if (DeferredSaveFrames >= 0 && DeferredSaveFrames-- == 0) { SaveConfig(); } diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index 785641f..cd67b93 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -1770,7 +1770,7 @@ namespace ChatTwo.Resources { } /// - /// Looks up a localized string similar to Hide chat during cutscenes. + /// Looks up a localized string similar to Hide during cutscenes. /// internal static string Options_HideDuringCutscenes_Name { get { @@ -1778,6 +1778,24 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Hide {0} during loading screens.. + /// + internal static string Options_HideInLoadingScreens_Description { + get { + return ResourceManager.GetString("Options_HideInLoadingScreens_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hide during loading screens. + /// + internal static string Options_HideInLoadingScreens_Name { + get { + return ResourceManager.GetString("Options_HideInLoadingScreens_Name", resourceCulture); + } + } + /// /// Looks up a localized string similar to Hide timestamps when previous messages have the same timestamp.. /// diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 80236d4..3e600c4 100644 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -128,7 +128,7 @@ Hide the in-game chat window when the plugin is active. - Hide chat during cutscenes + Hide during cutscenes Hide {0} during cutscenes. @@ -923,4 +923,10 @@ Override your selected dalamud style with a different one + + Hide during loading screens + + + Hide {0} during loading screens. + diff --git a/ChatTwo/Ui/SettingsTabs/Display.cs b/ChatTwo/Ui/SettingsTabs/Display.cs index 2c938c5..c127086 100755 --- a/ChatTwo/Ui/SettingsTabs/Display.cs +++ b/ChatTwo/Ui/SettingsTabs/Display.cs @@ -41,6 +41,12 @@ internal sealed class Display : ISettingsTab { ); ImGui.Spacing(); + ImGuiUtil.OptionCheckbox( + ref Mutable.HideInLoadingScreens, + Language.Options_HideInLoadingScreens_Name, + string.Format(Language.Options_HideInLoadingScreens_Description, Plugin.PluginName)); + ImGui.Spacing(); + ImGuiUtil.OptionCheckbox( ref Mutable.NativeItemTooltips, Language.Options_NativeItemTooltips_Name,