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();
[Serializable]
public class CommandSettingsEntries
{
public bool PrintSuccessMessages { get; set; } = true;
}
public CommandSettingsEntries CommandSettings { get; set; } = new();
[JsonIgnore]
private readonly SaveService _saveService;

View File

@@ -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)
{

View File

@@ -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;