feat: add enable/disable/toggle commands
This commit is contained in:
parent
5a85476cac
commit
3ee6213cf7
|
@ -1,5 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Dalamud.Game.Command;
|
using Dalamud.Game.Command;
|
||||||
|
using SoundFilter.Resources;
|
||||||
|
|
||||||
namespace SoundFilter {
|
namespace SoundFilter {
|
||||||
internal class Commands : IDisposable {
|
internal class Commands : IDisposable {
|
||||||
|
@ -20,7 +22,45 @@ namespace SoundFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCommand(string command, string args) {
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,144 +1,171 @@
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.42000
|
// Runtime Version:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace SoundFilter.Resources {
|
namespace SoundFilter.Resources {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
// class via a tool like ResGen or Visual Studio.
|
// class via a tool like ResGen or Visual Studio.
|
||||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
// with the /str option, or rebuild your VS project.
|
// with the /str option, or rebuild your VS project.
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class Language {
|
internal class Language {
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
internal Language() {
|
internal Language() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SoundFilter.Resources.Language", typeof(Language).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SoundFilter.Resources.Language", typeof(Language).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides the current thread's CurrentUICulture property for all
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
/// resource lookups using this strongly typed resource class.
|
/// resource lookups using this strongly typed resource class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
get {
|
get {
|
||||||
return resourceCulture;
|
return resourceCulture;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
resourceCulture = value;
|
resourceCulture = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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..
|
/// Looks up a localized string similar to Invalid subcommand..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string LoadWarning {
|
internal static string CommandInvalidSubcommand {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("LoadWarning", resourceCulture);
|
return ResourceManager.GetString("CommandInvalidSubcommand", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Max sounds.
|
/// Looks up a localized string similar to No such filter..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string LogMaxRecentSounds {
|
internal static string CommandNoSuchFilter {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("LogMaxRecentSounds", resourceCulture);
|
return ResourceManager.GetString("CommandNoSuchFilter", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Search.
|
/// Looks up a localized string similar to Not enough arguments. Please specify 'enable' or 'disable' and an optional filter name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string LogSearch {
|
internal static string CommandNotEnoughArguments {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("LogSearch", resourceCulture);
|
return ResourceManager.GetString("CommandNotEnoughArguments", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Sound log.
|
/// 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..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string LogWindowTitle {
|
internal static string LoadWarning {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("LogWindowTitle", resourceCulture);
|
return ResourceManager.GetString("LoadWarning", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Filter name.
|
/// Looks up a localized string similar to Max sounds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string SettingsAddFilterName {
|
internal static string LogMaxRecentSounds {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("SettingsAddFilterName", resourceCulture);
|
return ResourceManager.GetString("LogMaxRecentSounds", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Sound path to filter.
|
/// Looks up a localized string similar to Search.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string SettingsAddPathToFilter {
|
internal static string LogSearch {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("SettingsAddPathToFilter", resourceCulture);
|
return ResourceManager.GetString("LogSearch", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Enable sound filter.
|
/// Looks up a localized string similar to Sound log.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string SettingsEnableSoundFilter {
|
internal static string LogWindowTitle {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("SettingsEnableSoundFilter", resourceCulture);
|
return ResourceManager.GetString("LogWindowTitle", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Show sound log window.
|
/// Looks up a localized string similar to Filter name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string SettingsShowSoundLogWindow {
|
internal static string SettingsAddFilterName {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("SettingsShowSoundLogWindow", resourceCulture);
|
return ResourceManager.GetString("SettingsAddFilterName", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to {0} settings.
|
/// Looks up a localized string similar to Sound path to filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string SettingsWindowTitle {
|
internal static string SettingsAddPathToFilter {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("SettingsWindowTitle", resourceCulture);
|
return ResourceManager.GetString("SettingsAddPathToFilter", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Enable sound filter.
|
||||||
|
/// </summary>
|
||||||
|
internal static string SettingsEnableSoundFilter {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SettingsEnableSoundFilter", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Show sound log window.
|
||||||
|
/// </summary>
|
||||||
|
internal static string SettingsShowSoundLogWindow {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SettingsShowSoundLogWindow", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to {0} settings.
|
||||||
|
/// </summary>
|
||||||
|
internal static string SettingsWindowTitle {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SettingsWindowTitle", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -45,4 +45,13 @@
|
||||||
<data name="SettingsAddPathToFilter" xml:space="preserve">
|
<data name="SettingsAddPathToFilter" xml:space="preserve">
|
||||||
<value>Sound path to filter</value>
|
<value>Sound path to filter</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="CommandNotEnoughArguments" xml:space="preserve">
|
||||||
|
<value>Not enough arguments. Please specify 'enable' or 'disable' and an optional filter name</value>
|
||||||
|
</data>
|
||||||
|
<data name="CommandInvalidSubcommand" xml:space="preserve">
|
||||||
|
<value>Invalid subcommand.</value>
|
||||||
|
</data>
|
||||||
|
<data name="CommandNoSuchFilter" xml:space="preserve">
|
||||||
|
<value>No such filter.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
Loading…
Reference in New Issue