From 90bd5fa4df771c350388552946ce7ddac5261f96 Mon Sep 17 00:00:00 2001 From: RisaDev <151885272+RisaDev@users.noreply.github.com> Date: Fri, 18 Oct 2024 23:44:55 +0300 Subject: [PATCH] Added several settings to control when plugin window is being hidden/shown --- .../Configuration/Data/PluginConfiguration.cs | 6 ++ CustomizePlus/UI/CPlusWindowSystem.cs | 3 +- CustomizePlus/UI/UiHelpers.cs | 31 ++++++++++ .../UI/Windows/MainWindow/MainWindow.cs | 3 +- .../UI/Windows/MainWindow/Tabs/SettingsTab.cs | 57 +++++++++++++++++++ 5 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 CustomizePlus/UI/UiHelpers.cs diff --git a/CustomizePlus/Configuration/Data/PluginConfiguration.cs b/CustomizePlus/Configuration/Data/PluginConfiguration.cs index 39de743..6ff7446 100644 --- a/CustomizePlus/Configuration/Data/PluginConfiguration.cs +++ b/CustomizePlus/Configuration/Data/PluginConfiguration.cs @@ -53,8 +53,14 @@ public class PluginConfiguration : IPluginConfiguration, ISavable public bool FoldersDefaultOpen { get; set; } = true; + public bool OpenWindowAtStart { get; set; } = false; + public bool HideWindowInCutscene { get; set; } = true; + public bool HideWindowWhenUiHidden { get; set; } = true; + + public bool HideWindowInGPose { get; set; } = false; + public bool IncognitoMode { get; set; } = false; public List ViewedMessageWindows { get; set; } = new(); diff --git a/CustomizePlus/UI/CPlusWindowSystem.cs b/CustomizePlus/UI/CPlusWindowSystem.cs index bfbf28f..b02c874 100644 --- a/CustomizePlus/UI/CPlusWindowSystem.cs +++ b/CustomizePlus/UI/CPlusWindowSystem.cs @@ -30,8 +30,9 @@ public class CPlusWindowSystem : IDisposable _uiBuilder.Draw += OnDraw; _uiBuilder.OpenConfigUi += _mainWindow.Toggle; - _uiBuilder.DisableGposeUiHide = true; + _uiBuilder.DisableGposeUiHide = !configuration.UISettings.HideWindowInGPose; //seems to be broken as of 2024/10/18 _uiBuilder.DisableCutsceneUiHide = !configuration.UISettings.HideWindowInCutscene; + _uiBuilder.DisableUserUiHide = !configuration.UISettings.HideWindowWhenUiHidden; } private void OnDraw() diff --git a/CustomizePlus/UI/UiHelpers.cs b/CustomizePlus/UI/UiHelpers.cs new file mode 100644 index 0000000..313a468 --- /dev/null +++ b/CustomizePlus/UI/UiHelpers.cs @@ -0,0 +1,31 @@ +using Dalamud.Interface.Utility; +using ImGuiNET; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using System.Text; +using System.Threading.Tasks; + +namespace CustomizePlus.UI; +internal class UiHelpers +{ + /// Vertical spacing between groups. + public static Vector2 DefaultSpace; + + /// Multiples of the current Global Scale + public static float Scale; + + /// Draw default vertical space. + public static void DefaultLineSpace() + => ImGui.Dummy(DefaultSpace); + + public static void SetupCommonSizes() + { + if (ImGuiHelpers.GlobalScale != Scale) + { + Scale = ImGuiHelpers.GlobalScale; + DefaultSpace = new Vector2(0, 10 * Scale); + } + } +} diff --git a/CustomizePlus/UI/Windows/MainWindow/MainWindow.cs b/CustomizePlus/UI/Windows/MainWindow/MainWindow.cs index de5fcfb..ab8da19 100644 --- a/CustomizePlus/UI/Windows/MainWindow/MainWindow.cs +++ b/CustomizePlus/UI/Windows/MainWindow/MainWindow.cs @@ -78,14 +78,13 @@ public class MainWindow : Window, IDisposable _templateEditorEvent.Subscribe(OnTemplateEditorEvent, TemplateEditorEvent.Priority.MainWindow); - pluginInterface.UiBuilder.DisableGposeUiHide = true; SizeConstraints = new WindowSizeConstraints() { MinimumSize = new Vector2(700, 675), MaximumSize = ImGui.GetIO().DisplaySize, }; - IsOpen = pluginInterface.IsDevMenuOpen && configuration.DebuggingModeEnabled; + IsOpen = configuration.UISettings.OpenWindowAtStart; } public void Dispose() diff --git a/CustomizePlus/UI/Windows/MainWindow/Tabs/SettingsTab.cs b/CustomizePlus/UI/Windows/MainWindow/Tabs/SettingsTab.cs index f8fa47e..2287d63 100644 --- a/CustomizePlus/UI/Windows/MainWindow/Tabs/SettingsTab.cs +++ b/CustomizePlus/UI/Windows/MainWindow/Tabs/SettingsTab.cs @@ -14,6 +14,7 @@ using CustomizePlus.Templates; using CustomizePlus.Core.Helpers; using CustomizePlus.Armatures.Services; using Dalamud.Interface.ImGuiNotification; +using Dalamud.Plugin; namespace CustomizePlus.UI.Windows.MainWindow.Tabs; @@ -21,6 +22,7 @@ public class SettingsTab { private const uint DiscordColor = 0xFFDA8972; + private readonly IDalamudPluginInterface _pluginInterface; private readonly PluginConfiguration _configuration; private readonly ArmatureManager _armatureManager; private readonly HookingService _hookingService; @@ -30,6 +32,7 @@ public class SettingsTab private readonly SupportLogBuilderService _supportLogBuilderService; public SettingsTab( + IDalamudPluginInterface pluginInterface, PluginConfiguration configuration, ArmatureManager armatureManager, HookingService hookingService, @@ -38,6 +41,7 @@ public class SettingsTab MessageService messageService, SupportLogBuilderService supportLogBuilderService) { + _pluginInterface = pluginInterface; _configuration = configuration; _armatureManager = armatureManager; _hookingService = hookingService; @@ -49,6 +53,7 @@ public class SettingsTab public void Draw() { + UiHelpers.SetupCommonSizes(); using var child = ImRaii.Child("MainWindowChild"); if (!child) return; @@ -209,16 +214,40 @@ public class SettingsTab if (!isShouldDraw) return; + DrawOpenWindowAtStart(); DrawHideWindowInCutscene(); + DrawHideWindowWhenUiHidden(); + DrawHideWindowInGPose(); + + UiHelpers.DefaultLineSpace(); + DrawFoldersDefaultOpen(); + + UiHelpers.DefaultLineSpace(); + DrawSetPreviewToCurrentCharacterOnLogin(); + UiHelpers.DefaultLineSpace(); + if (Widget.DoubleModifierSelector("Template Deletion Modifier", "A modifier you need to hold while clicking the Delete Template button for it to take effect.", 100 * ImGuiHelpers.GlobalScale, _configuration.UISettings.DeleteTemplateModifier, v => _configuration.UISettings.DeleteTemplateModifier = v)) _configuration.Save(); } + private void DrawOpenWindowAtStart() + { + var isChecked = _configuration.UISettings.OpenWindowAtStart; + + if (CtrlHelper.CheckboxWithTextAndHelp("##openwindowatstart", "Open Customize+ Window at Game Start", + "Controls whether main Customize+ window will be opened when you launch the game or not.", ref isChecked)) + { + _configuration.UISettings.OpenWindowAtStart = isChecked; + + _configuration.Save(); + } + } + private void DrawHideWindowInCutscene() { var isChecked = _configuration.UISettings.HideWindowInCutscene; @@ -226,7 +255,35 @@ public class SettingsTab if (CtrlHelper.CheckboxWithTextAndHelp("##hidewindowincutscene", "Hide Plugin Windows in Cutscenes", "Controls whether any Customize+ windows are hidden during cutscenes or not.", ref isChecked)) { + _pluginInterface.UiBuilder.DisableCutsceneUiHide = !isChecked; _configuration.UISettings.HideWindowInCutscene = isChecked; + + _configuration.Save(); + } + } + + private void DrawHideWindowWhenUiHidden() + { + var isChecked = _configuration.UISettings.HideWindowWhenUiHidden; + + if (CtrlHelper.CheckboxWithTextAndHelp("##hidewindowwhenuihidden", "Hide Plugin Windows when UI is Hidden", + "Controls whether any Customize+ windows are hidden when you manually hide the in-game user interface.", ref isChecked)) + { + _pluginInterface.UiBuilder.DisableUserUiHide = !isChecked; + _configuration.UISettings.HideWindowWhenUiHidden = isChecked; + _configuration.Save(); + } + } + + private void DrawHideWindowInGPose() + { + var isChecked = _configuration.UISettings.HideWindowInGPose; + + if (CtrlHelper.CheckboxWithTextAndHelp("##hidewindowingpose", "Hide Plugin Windows in GPose", + "Controls whether any Customize+ windows are hidden when you enter GPose.", ref isChecked)) + { + _pluginInterface.UiBuilder.DisableGposeUiHide = !isChecked; + _configuration.UISettings.HideWindowInGPose = isChecked; _configuration.Save(); } }