Added option to not display confirmations for chat commands

This commit is contained in:
RisaDev
2024-02-04 22:46:25 +03:00
parent 82e064dc29
commit 205f60480c
3 changed files with 51 additions and 12 deletions

View File

@@ -78,6 +78,14 @@ public class PluginConfiguration : IPluginConfiguration, ISavable
public EditorConfigurationEntries EditorConfiguration { get; set; } = new(); public EditorConfigurationEntries EditorConfiguration { get; set; } = new();
[Serializable]
public class CommandSettingsEntries
{
public bool PrintSuccessMessages { get; set; } = true;
}
public CommandSettingsEntries CommandSettings { get; set; } = new();
[JsonIgnore] [JsonIgnore]
private readonly SaveService _saveService; private readonly SaveService _saveService;

View File

@@ -12,6 +12,7 @@ using CustomizePlus.UI.Windows.MainWindow.Tabs.Templates;
using CustomizePlus.UI.Windows.MainWindow; using CustomizePlus.UI.Windows.MainWindow;
using static System.Windows.Forms.AxHost; using static System.Windows.Forms.AxHost;
using CustomizePlus.Profiles.Data; using CustomizePlus.Profiles.Data;
using CustomizePlus.Configuration.Data;
namespace CustomizePlus.Core.Services; namespace CustomizePlus.Core.Services;
@@ -25,6 +26,7 @@ public class CommandService : IDisposable
private readonly MainWindow _mainWindow; private readonly MainWindow _mainWindow;
private readonly BoneEditorPanel _boneEditorPanel; private readonly BoneEditorPanel _boneEditorPanel;
private readonly MessageService _messageService; private readonly MessageService _messageService;
private readonly PluginConfiguration _pluginConfiguration;
private static readonly string[] Commands = new[] { "/customize", "/c+" }; private static readonly string[] Commands = new[] { "/customize", "/c+" };
@@ -36,7 +38,8 @@ public class CommandService : IDisposable
ChatService chatService, ChatService chatService,
BoneEditorPanel boneEditorPanel, BoneEditorPanel boneEditorPanel,
Logger logger, Logger logger,
MessageService messageService) MessageService messageService,
PluginConfiguration pluginConfiguration)
{ {
_profileManager = profileManager; _profileManager = profileManager;
_gameObjectService = gameObjectService; _gameObjectService = gameObjectService;
@@ -46,12 +49,14 @@ public class CommandService : IDisposable
_mainWindow = mainWindow; _mainWindow = mainWindow;
_boneEditorPanel = boneEditorPanel; _boneEditorPanel = boneEditorPanel;
_messageService = messageService; _messageService = messageService;
_pluginConfiguration = pluginConfiguration;
foreach (var command in Commands) 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." }); _commandManager.AddHandler(command, new CommandInfo(OnMainCommand) { HelpMessage = "Toggles main plugin window if no commands passed. Use \"/customize help\" for list of available commands." });
} }
if (_pluginConfiguration.CommandSettings.PrintSuccessMessages)
chatService.PrintInChat($"Started!"); //safe to assume at this point we have successfully initialized chatService.PrintInChat($"Started!"); //safe to assume at this point we have successfully initialized
} }
@@ -212,6 +217,7 @@ public class CommandService : IDisposable
else else
_profileManager.SetEnabled(targetProfile, !targetProfile.Enabled); _profileManager.SetEnabled(targetProfile, !targetProfile.Enabled);
if (_pluginConfiguration.CommandSettings.PrintSuccessMessages)
_chatService.PrintInChat(new SeStringBuilder() _chatService.PrintInChat(new SeStringBuilder()
.AddText("Profile ") .AddText("Profile ")
.AddYellow(targetProfile.Name) .AddYellow(targetProfile.Name)

View File

@@ -64,6 +64,7 @@ public class SettingsTab
using (var child2 = ImRaii.Child("SettingsChild")) using (var child2 = ImRaii.Child("SettingsChild"))
{ {
DrawInterface(); DrawInterface();
DrawCommands();
DrawAdvancedSettings(); DrawAdvancedSettings();
} }
@@ -95,6 +96,30 @@ public class SettingsTab
} }
#endregion #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 #region Interface Settings
private void DrawInterface() private void DrawInterface()
@@ -117,8 +142,8 @@ public class SettingsTab
{ {
var isChecked = _configuration.UISettings.HideWindowInCutscene; var isChecked = _configuration.UISettings.HideWindowInCutscene;
if (CtrlHelper.CheckboxWithTextAndHelp("##hidewindowincutscene", "Hide plugin windows in cutscenes", if (CtrlHelper.CheckboxWithTextAndHelp("##hidewindowincutscene", "Hide Plugin Windows in Cutscenes",
"Controls whether any Fantasia+ windows are hidden during cutscenes or not.", ref isChecked)) "Controls whether any Customize+ windows are hidden during cutscenes or not.", ref isChecked))
{ {
_configuration.UISettings.HideWindowInCutscene = isChecked; _configuration.UISettings.HideWindowInCutscene = isChecked;
_configuration.Save(); _configuration.Save();
@@ -129,7 +154,7 @@ public class SettingsTab
{ {
var isChecked = _configuration.UISettings.FoldersDefaultOpen; 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)) "Controls whether folders in template and profile lists are open by default or not.", ref isChecked))
{ {
_configuration.UISettings.FoldersDefaultOpen = isChecked; _configuration.UISettings.FoldersDefaultOpen = isChecked;