mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-29 03:49:19 +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>
|
||||
|
|
@ -317,6 +318,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
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue