diff --git a/Penumbra/CommandHandler.cs b/Penumbra/CommandHandler.cs index 0af75477..4f53a7b6 100644 --- a/Penumbra/CommandHandler.cs +++ b/Penumbra/CommandHandler.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Runtime.CompilerServices; using Dalamud.Game.Command; using Dalamud.Game.Text.SeStringHandling; using ImGuiNET; @@ -139,7 +140,8 @@ public class CommandHandler : IDisposable Dalamud.Chat.Print( new SeStringBuilder().AddCommand( "collection", "Change your active collection setup. Use without further parameters for more detailed help." ) .BuiltString ); Dalamud.Chat.Print( new SeStringBuilder().AddCommand( "mod", "Change a specific mods settings. Use without further parameters for more detailed help." ).BuiltString ); - Dalamud.Chat.Print( new SeStringBuilder().AddCommand( "bulktag", "Change multiple mods settings based on their tags. Use without further parameters for more detailed help." ) + Dalamud.Chat.Print( new SeStringBuilder() + .AddCommand( "bulktag", "Change multiple mods settings based on their tags. Use without further parameters for more detailed help." ) .BuiltString ); return true; } @@ -159,7 +161,7 @@ public class CommandHandler : IDisposable private bool Reload( string _ ) { _modManager.DiscoverMods(); - Dalamud.Chat.Print( $"Reloaded Penumbra mods. You have {_modManager.Count} mods." ); + Print( $"Reloaded Penumbra mods. You have {_modManager.Count} mods." ); return true; } @@ -185,9 +187,7 @@ public class CommandHandler : IDisposable return false; } - Dalamud.Chat.Print( value - ? "Debug mode enabled." - : "Debug mode disabled." ); + Print( value ? "Debug mode enabled." : "Debug mode disabled." ); _config.DebugMode = value; _config.Save(); @@ -200,13 +200,13 @@ public class CommandHandler : IDisposable if( value == _config.EnableMods ) { - Dalamud.Chat.Print( value + Print( value ? "Your mods are already enabled. To disable your mods, please run the following command instead: /penumbra disable" : "Your mods are already disabled. To enable your mods, please run the following command instead: /penumbra enable" ); return false; } - Dalamud.Chat.Print( value + Print( value ? "Your mods have been enabled." : "Your mods have been disabled." ); return _penumbra.SetEnabled( value ); @@ -222,12 +222,12 @@ public class CommandHandler : IDisposable if( value ) { - Dalamud.Chat.Print( "Penumbra UI locked in place." ); + Print( "Penumbra UI locked in place." ); _configWindow.Flags |= ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize; } else { - Dalamud.Chat.Print( "Penumbra UI unlocked." ); + Print( "Penumbra UI unlocked." ); _configWindow.Flags &= ~( ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize ); } @@ -251,7 +251,7 @@ public class CommandHandler : IDisposable Dalamud.Chat.Print( new SeStringBuilder().AddText( " 》 If the type is " ).AddBlue( "Individual" ) .AddText( " you need to specify an individual with an identifier of the form:" ).BuiltString ); Dalamud.Chat.Print( new SeStringBuilder().AddText( " 》》》 " ).AddGreen( "" ).AddText( " or " ).AddGreen( "" ).AddText( " or " ).AddGreen( "" ) - .AddText( " or " ).AddGreen( "" ).AddText( " as placeholders for your character, your target, your mouseover or your focus, if they exist." ).BuiltString ); + .AddText( " or " ).AddGreen( "" ).AddText( " as placeholders for your character, your target, your mouseover or your focus, if they exist." ).BuiltString ); Dalamud.Chat.Print( new SeStringBuilder().AddText( " 》》》 " ).AddGreen( "p" ).AddText( " | " ).AddWhite( "[Player Name]@" ) .AddText( ", if no @ is provided, Any World is used." ).BuiltString ); Dalamud.Chat.Print( new SeStringBuilder().AddText( " 》》》 " ).AddGreen( "r" ).AddText( " | " ).AddWhite( "[Retainer Name]" ).BuiltString ); @@ -358,12 +358,12 @@ public class CommandHandler : IDisposable return false; } - Dalamud.Chat.Print( $"Removed {oldCollection.Name} as {type.ToName()} Collection assignment {( identifier.IsValid ? $" for {identifier}." : "." )}" ); + Print( $"Removed {oldCollection.Name} as {type.ToName()} Collection assignment {( identifier.IsValid ? $" for {identifier}." : "." )}" ); return true; } _collectionManager.SetCollection( collection!, type, individualIndex ); - Dalamud.Chat.Print( $"Assigned {collection!.Name} as {type.ToName()} Collection{( identifier.IsValid ? $" for {identifier}." : "." )}" ); + Print( $"Assigned {collection!.Name} as {type.ToName()} Collection{( identifier.IsValid ? $" for {identifier}." : "." )}" ); return true; } @@ -462,7 +462,7 @@ public class CommandHandler : IDisposable if( !changes ) { - Dalamud.Chat.Print( new SeStringBuilder().AddText( "No mod states were changed in collection " ).AddYellow( collection!.Name, true ).AddText( "." ).BuiltString ); + Print( () => new SeStringBuilder().AddText( "No mod states were changed in collection " ).AddYellow( collection!.Name, true ).AddText( "." ).BuiltString ); } return true; @@ -528,7 +528,7 @@ public class CommandHandler : IDisposable case 0: if( collection.SetModState( mod.Index, true ) ) { - Dalamud.Chat.Print( new SeStringBuilder().AddText( "Enabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ) + Print( () => new SeStringBuilder().AddText( "Enabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ) .AddYellow( collection.Name, true ) .AddText( "." ).BuiltString ); return true; @@ -538,7 +538,7 @@ public class CommandHandler : IDisposable case 1: if( collection.SetModState( mod.Index, false ) ) { - Dalamud.Chat.Print( new SeStringBuilder().AddText( "Disabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ) + Print( () => new SeStringBuilder().AddText( "Disabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ) .AddYellow( collection.Name, true ) .AddText( "." ).BuiltString ); return true; @@ -549,7 +549,7 @@ public class CommandHandler : IDisposable var setting = !( settings?.Enabled ?? false ); if( collection.SetModState( mod.Index, setting ) ) { - Dalamud.Chat.Print( new SeStringBuilder().AddText( setting ? "Enabled mod " : "Disabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ) + Print( () => new SeStringBuilder().AddText( setting ? "Enabled mod " : "Disabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ) .AddYellow( collection.Name, true ) .AddText( "." ).BuiltString ); return true; @@ -559,7 +559,7 @@ public class CommandHandler : IDisposable case 3: if( collection.SetModInheritance( mod.Index, true ) ) { - Dalamud.Chat.Print( new SeStringBuilder().AddText( "Set mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ).AddYellow( collection.Name, true ) + Print( () => new SeStringBuilder().AddText( "Set mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ).AddYellow( collection.Name, true ) .AddText( " to inherit." ).BuiltString ); return true; } @@ -569,4 +569,28 @@ public class CommandHandler : IDisposable return false; } + + private static void Print( string text ) + { + if( Penumbra.Config.PrintSuccessfulCommandsToChat ) + { + Dalamud.Chat.Print( text ); + } + } + + private static void Print( DefaultInterpolatedStringHandler text ) + { + if( Penumbra.Config.PrintSuccessfulCommandsToChat ) + { + Dalamud.Chat.Print( text.ToStringAndClear() ); + } + } + + private static void Print( Func text ) + { + if( Penumbra.Config.PrintSuccessfulCommandsToChat ) + { + Dalamud.Chat.Print( text() ); + } + } } \ No newline at end of file diff --git a/Penumbra/Configuration.cs b/Penumbra/Configuration.cs index 6fd70b03..878b4a3b 100644 --- a/Penumbra/Configuration.cs +++ b/Penumbra/Configuration.cs @@ -72,6 +72,7 @@ public partial class Configuration : IPluginConfiguration public string DefaultImportFolder { get; set; } = string.Empty; public DoubleModifier DeleteModModifier { get; set; } = new(ModifierHotkey.Control, ModifierHotkey.Shift); + public bool PrintSuccessfulCommandsToChat { get; set; } = true; public bool FixMainWindow { get; set; } = false; public bool AutoDeduplicateOnImport { get; set; } = true; public bool EnableHttpApi { get; set; } = true; diff --git a/Penumbra/UI/ConfigWindow.SettingsTab.General.cs b/Penumbra/UI/ConfigWindow.SettingsTab.General.cs index 62acbba7..d8f5808d 100644 --- a/Penumbra/UI/ConfigWindow.SettingsTab.General.cs +++ b/Penumbra/UI/ConfigWindow.SettingsTab.General.cs @@ -28,17 +28,21 @@ public partial class ConfigWindow } private static int _singleGroupRadioMax = int.MaxValue; + private void DrawSingleSelectRadioMax() { - if ( _singleGroupRadioMax == int.MaxValue) + if( _singleGroupRadioMax == int.MaxValue ) + { _singleGroupRadioMax = Penumbra.Config.SingleGroupRadioMax; + } + ImGui.SetNextItemWidth( _window._inputTextWidth.X ); if( ImGui.DragInt( "##SingleSelectRadioMax", ref _singleGroupRadioMax, 0.01f, 1 ) ) { _singleGroupRadioMax = Math.Max( 1, _singleGroupRadioMax ); } - if (ImGui.IsItemDeactivated()) + if( ImGui.IsItemDeactivated() ) { if( _singleGroupRadioMax != Penumbra.Config.SingleGroupRadioMax ) { @@ -48,6 +52,7 @@ public partial class ConfigWindow _singleGroupRadioMax = int.MaxValue; } + ImGuiUtil.LabeledHelpMarker( "Upper Limit for Single-Selection Group Radio Buttons", "All Single-Selection Groups with more options than specified here will be displayed as Combo-Boxes at the top.\n" + "All other Single-Selection Groups will be displayed as a set of Radio-Buttons." ); @@ -89,6 +94,9 @@ public partial class ConfigWindow } ); ImGui.Dummy( _window._defaultSpace ); + Checkbox( "Print Chat Command Success Messages to Chat", + "Chat Commands usually print messages on failure but also on success to confirm your action. You can disable this here.", + Penumbra.Config.PrintSuccessfulCommandsToChat, v => Penumbra.Config.PrintSuccessfulCommandsToChat = v ); Checkbox( "Hide Redraw Bar in Mod Panel", "Hides the lower redraw buttons in the mod panel in your Mods tab.", Penumbra.Config.HideRedrawBar, v => Penumbra.Config.HideRedrawBar = v ); ImGui.Dummy( _window._defaultSpace );