mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-29 11:59:21 +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]
|
[ServiceManager.ServiceConstructor]
|
||||||
public ConsoleManager()
|
public ConsoleManager()
|
||||||
{
|
{
|
||||||
|
this.AddCommand("toggle", "Toggle a boolean variable.", this.OnToggleVariable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -317,6 +318,19 @@ internal partial class ConsoleManager : IServiceType
|
||||||
{
|
{
|
||||||
return this.entries.TryGetValue(name, out var entry) ? entry as ConsoleEntry : null;
|
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
|
private static class Traits
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue