mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 06:13:40 +01:00
console: add "toggle" command to flip boolean convars
This commit is contained in:
parent
b3727a0f2a
commit
0f2aaa4241
1 changed files with 14 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ internal partial class ConsoleManager : IServiceType
|
|||
[ServiceManager.ServiceConstructor]
|
||||
public ConsoleManager()
|
||||
{
|
||||
this.AddCommand("toggle", "Toggle a boolean variable.", this.OnToggleVariable);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -318,6 +319,19 @@ internal partial class ConsoleManager : IServiceType
|
|||
return this.entries.TryGetValue(name, out var entry) ? entry as ConsoleEntry : null;
|
||||
}
|
||||
|
||||
private bool OnToggleVariable(string name)
|
||||
{
|
||||
if (this.FindEntry(name) is not IConsoleVariable<bool> variable)
|
||||
{
|
||||
Log.Error("Variable {VariableName} not found or not a boolean", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
variable.Value = !variable.Value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class Traits
|
||||
{
|
||||
public static void ThrowIfTIsNullableAndNull<T>(T? argument, [CallerArgumentExpression("argument")] string? paramName = null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue