From 205f60480cb042721dd0acf488d43e5df64f6f33 Mon Sep 17 00:00:00 2001 From: RisaDev <151885272+RisaDev@users.noreply.github.com> Date: Sun, 4 Feb 2024 22:46:25 +0300 Subject: [PATCH] Added option to not display confirmations for chat commands --- .../Configuration/Data/PluginConfiguration.cs | 8 +++++ CustomizePlus/Core/Services/CommandService.cs | 24 ++++++++------ .../UI/Windows/MainWindow/Tabs/SettingsTab.cs | 31 +++++++++++++++++-- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/CustomizePlus/Configuration/Data/PluginConfiguration.cs b/CustomizePlus/Configuration/Data/PluginConfiguration.cs index 0a21120..b4e1bd7 100644 --- a/CustomizePlus/Configuration/Data/PluginConfiguration.cs +++ b/CustomizePlus/Configuration/Data/PluginConfiguration.cs @@ -78,6 +78,14 @@ public class PluginConfiguration : IPluginConfiguration, ISavable public EditorConfigurationEntries EditorConfiguration { get; set; } = new(); + [Serializable] + public class CommandSettingsEntries + { + public bool PrintSuccessMessages { get; set; } = true; + } + + public CommandSettingsEntries CommandSettings { get; set; } = new(); + [JsonIgnore] private readonly SaveService _saveService; diff --git a/CustomizePlus/Core/Services/CommandService.cs b/CustomizePlus/Core/Services/CommandService.cs index 6750720..8caf576 100644 --- a/CustomizePlus/Core/Services/CommandService.cs +++ b/CustomizePlus/Core/Services/CommandService.cs @@ -12,6 +12,7 @@ using CustomizePlus.UI.Windows.MainWindow.Tabs.Templates; using CustomizePlus.UI.Windows.MainWindow; using static System.Windows.Forms.AxHost; using CustomizePlus.Profiles.Data; +using CustomizePlus.Configuration.Data; namespace CustomizePlus.Core.Services; @@ -25,6 +26,7 @@ public class CommandService : IDisposable private readonly MainWindow _mainWindow; private readonly BoneEditorPanel _boneEditorPanel; private readonly MessageService _messageService; + private readonly PluginConfiguration _pluginConfiguration; private static readonly string[] Commands = new[] { "/customize", "/c+" }; @@ -36,7 +38,8 @@ public class CommandService : IDisposable ChatService chatService, BoneEditorPanel boneEditorPanel, Logger logger, - MessageService messageService) + MessageService messageService, + PluginConfiguration pluginConfiguration) { _profileManager = profileManager; _gameObjectService = gameObjectService; @@ -46,13 +49,15 @@ public class CommandService : IDisposable _mainWindow = mainWindow; _boneEditorPanel = boneEditorPanel; _messageService = messageService; + _pluginConfiguration = pluginConfiguration; foreach (var command in Commands) { _commandManager.AddHandler(command, new CommandInfo(OnMainCommand) { HelpMessage = "Toggles main plugin window if no commands passed. Use \"/customize help\" for list of available commands." }); } - chatService.PrintInChat($"Started!"); //safe to assume at this point we have successfully initialized + if (_pluginConfiguration.CommandSettings.PrintSuccessMessages) + chatService.PrintInChat($"Started!"); //safe to assume at this point we have successfully initialized } public void Dispose() @@ -212,13 +217,14 @@ public class CommandService : IDisposable else _profileManager.SetEnabled(targetProfile, !targetProfile.Enabled); - _chatService.PrintInChat(new SeStringBuilder() - .AddText("Profile ") - .AddYellow(targetProfile.Name) - .AddText(" was successfully ") - .AddBlue(state != null ? ((bool)state ? "enabled" : "disabled") : "toggled") - .AddText(" for ") - .AddRed(targetProfile.CharacterName).BuiltString); + if (_pluginConfiguration.CommandSettings.PrintSuccessMessages) + _chatService.PrintInChat(new SeStringBuilder() + .AddText("Profile ") + .AddYellow(targetProfile.Name) + .AddText(" was successfully ") + .AddBlue(state != null ? ((bool)state ? "enabled" : "disabled") : "toggled") + .AddText(" for ") + .AddRed(targetProfile.CharacterName).BuiltString); } catch (Exception e) { diff --git a/CustomizePlus/UI/Windows/MainWindow/Tabs/SettingsTab.cs b/CustomizePlus/UI/Windows/MainWindow/Tabs/SettingsTab.cs index d4cb126..0627202 100644 --- a/CustomizePlus/UI/Windows/MainWindow/Tabs/SettingsTab.cs +++ b/CustomizePlus/UI/Windows/MainWindow/Tabs/SettingsTab.cs @@ -64,6 +64,7 @@ public class SettingsTab using (var child2 = ImRaii.Child("SettingsChild")) { DrawInterface(); + DrawCommands(); DrawAdvancedSettings(); } @@ -95,6 +96,30 @@ public class SettingsTab } #endregion + #region Chat Commands Settings + private void DrawCommands() + { + var isShouldDraw = ImGui.CollapsingHeader("Chat Commands"); + + if (!isShouldDraw) + return; + + DrawPrintSuccessMessages(); + } + + private void DrawPrintSuccessMessages() + { + var isChecked = _configuration.CommandSettings.PrintSuccessMessages; + + if (CtrlHelper.CheckboxWithTextAndHelp("##displaychatcommandconfirms", "Print Successful Command Execution Messages to Chat", + "Controls whether successful execution of chat commands will be acknowledged by separate chat message or not.", ref isChecked)) + { + _configuration.CommandSettings.PrintSuccessMessages = isChecked; + _configuration.Save(); + } + } + #endregion + #region Interface Settings private void DrawInterface() @@ -117,8 +142,8 @@ public class SettingsTab { var isChecked = _configuration.UISettings.HideWindowInCutscene; - if (CtrlHelper.CheckboxWithTextAndHelp("##hidewindowincutscene", "Hide plugin windows in cutscenes", - "Controls whether any Fantasia+ windows are hidden during cutscenes or not.", ref isChecked)) + if (CtrlHelper.CheckboxWithTextAndHelp("##hidewindowincutscene", "Hide Plugin Windows in Cutscenes", + "Controls whether any Customize+ windows are hidden during cutscenes or not.", ref isChecked)) { _configuration.UISettings.HideWindowInCutscene = isChecked; _configuration.Save(); @@ -129,7 +154,7 @@ public class SettingsTab { var isChecked = _configuration.UISettings.FoldersDefaultOpen; - if (CtrlHelper.CheckboxWithTextAndHelp("##foldersdefaultopen", "Open all folders by default", + if (CtrlHelper.CheckboxWithTextAndHelp("##foldersdefaultopen", "Open All Folders by Default", "Controls whether folders in template and profile lists are open by default or not.", ref isChecked)) { _configuration.UISettings.FoldersDefaultOpen = isChecked;