diff --git a/SoundFilter/Commands.cs b/SoundFilter/Commands.cs
index eec7486..f403475 100755
--- a/SoundFilter/Commands.cs
+++ b/SoundFilter/Commands.cs
@@ -1,5 +1,7 @@
using System;
+using System.Linq;
using Dalamud.Game.Command;
+using SoundFilter.Resources;
namespace SoundFilter {
internal class Commands : IDisposable {
@@ -20,7 +22,45 @@ namespace SoundFilter {
}
private void OnCommand(string command, string args) {
- this.Plugin.Ui.Settings.Toggle();
+ if (string.IsNullOrWhiteSpace(args)) {
+ this.Plugin.Ui.Settings.Toggle();
+ return;
+ }
+
+ var chat = this.Plugin.Interface.Framework.Gui.Chat;
+
+ var split = args.Split(' ');
+ if (split.Length < 1) {
+ chat.PrintError($"[{SoundFilterPlugin.Name}] {Language.CommandNotEnoughArguments}");
+ return;
+ }
+
+ var filterName = split.Length > 1 ? string.Join(" ", split.Skip(1)) : null;
+ var filter = filterName == null ? null : this.Plugin.Config.Filtered.Values.FirstOrDefault(filter => filter.Name == filterName);
+ if (filterName != null && filter == null) {
+ chat.PrintError($"[{SoundFilterPlugin.Name}] {Language.CommandNoSuchFilter}");
+ return;
+ }
+
+ bool? enabled = split[0] switch {
+ "enable" => true,
+ "disable" => false,
+ "toggle" when filter == null => !this.Plugin.Config.Enabled,
+ "toggle" => !filter.Enabled,
+ _ => null,
+ };
+ if (enabled == null) {
+ chat.PrintError($"[{SoundFilterPlugin.Name}] {Language.CommandInvalidSubcommand}");
+ return;
+ }
+
+ if (filter != null) {
+ filter.Enabled = enabled.Value;
+ } else {
+ this.Plugin.Config.Enabled = enabled.Value;
+ }
+
+ this.Plugin.Config.Save();
}
}
}
diff --git a/SoundFilter/Resources/Language.Designer.cs b/SoundFilter/Resources/Language.Designer.cs
index aa996cd..996840d 100755
--- a/SoundFilter/Resources/Language.Designer.cs
+++ b/SoundFilter/Resources/Language.Designer.cs
@@ -1,144 +1,171 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace SoundFilter.Resources {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Language {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Language() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SoundFilter.Resources.Language", typeof(Language).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to Due to the way FFXIV's resource loading works, {0} has to hear a sound once before it can filter it after a fresh install or update. Restart your game after installing or updating if this is a problem for you..
- ///
- internal static string LoadWarning {
- get {
- return ResourceManager.GetString("LoadWarning", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Max sounds.
- ///
- internal static string LogMaxRecentSounds {
- get {
- return ResourceManager.GetString("LogMaxRecentSounds", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Search.
- ///
- internal static string LogSearch {
- get {
- return ResourceManager.GetString("LogSearch", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Sound log.
- ///
- internal static string LogWindowTitle {
- get {
- return ResourceManager.GetString("LogWindowTitle", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Filter name.
- ///
- internal static string SettingsAddFilterName {
- get {
- return ResourceManager.GetString("SettingsAddFilterName", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Sound path to filter.
- ///
- internal static string SettingsAddPathToFilter {
- get {
- return ResourceManager.GetString("SettingsAddPathToFilter", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Enable sound filter.
- ///
- internal static string SettingsEnableSoundFilter {
- get {
- return ResourceManager.GetString("SettingsEnableSoundFilter", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Show sound log window.
- ///
- internal static string SettingsShowSoundLogWindow {
- get {
- return ResourceManager.GetString("SettingsShowSoundLogWindow", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to {0} settings.
- ///
- internal static string SettingsWindowTitle {
- get {
- return ResourceManager.GetString("SettingsWindowTitle", resourceCulture);
- }
- }
- }
-}
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace SoundFilter.Resources {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Language {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Language() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SoundFilter.Resources.Language", typeof(Language).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Invalid subcommand..
+ ///
+ internal static string CommandInvalidSubcommand {
+ get {
+ return ResourceManager.GetString("CommandInvalidSubcommand", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to No such filter..
+ ///
+ internal static string CommandNoSuchFilter {
+ get {
+ return ResourceManager.GetString("CommandNoSuchFilter", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Not enough arguments. Please specify 'enable' or 'disable' and an optional filter name.
+ ///
+ internal static string CommandNotEnoughArguments {
+ get {
+ return ResourceManager.GetString("CommandNotEnoughArguments", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Due to the way FFXIV's resource loading works, {0} has to hear a sound once before it can filter it after a fresh install or update. Restart your game after installing or updating if this is a problem for you..
+ ///
+ internal static string LoadWarning {
+ get {
+ return ResourceManager.GetString("LoadWarning", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Max sounds.
+ ///
+ internal static string LogMaxRecentSounds {
+ get {
+ return ResourceManager.GetString("LogMaxRecentSounds", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Search.
+ ///
+ internal static string LogSearch {
+ get {
+ return ResourceManager.GetString("LogSearch", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Sound log.
+ ///
+ internal static string LogWindowTitle {
+ get {
+ return ResourceManager.GetString("LogWindowTitle", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Filter name.
+ ///
+ internal static string SettingsAddFilterName {
+ get {
+ return ResourceManager.GetString("SettingsAddFilterName", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Sound path to filter.
+ ///
+ internal static string SettingsAddPathToFilter {
+ get {
+ return ResourceManager.GetString("SettingsAddPathToFilter", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Enable sound filter.
+ ///
+ internal static string SettingsEnableSoundFilter {
+ get {
+ return ResourceManager.GetString("SettingsEnableSoundFilter", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Show sound log window.
+ ///
+ internal static string SettingsShowSoundLogWindow {
+ get {
+ return ResourceManager.GetString("SettingsShowSoundLogWindow", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to {0} settings.
+ ///
+ internal static string SettingsWindowTitle {
+ get {
+ return ResourceManager.GetString("SettingsWindowTitle", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/SoundFilter/Resources/Language.resx b/SoundFilter/Resources/Language.resx
index b4212ac..f16f33b 100755
--- a/SoundFilter/Resources/Language.resx
+++ b/SoundFilter/Resources/Language.resx
@@ -45,4 +45,13 @@
Sound path to filter
+
+ Not enough arguments. Please specify 'enable' or 'disable' and an optional filter name
+
+
+ Invalid subcommand.
+
+
+ No such filter.
+