alterNERDtive-base: added config.dump
plugin context
Dumps a list of all configuration options + their current value to the VoiceAttack log. Will also mention if they are set to the default.
This commit is contained in:
parent
58435a350e
commit
f6a4861a06
2 changed files with 62 additions and 2 deletions
|
@ -46,6 +46,11 @@ namespace alterNERDtive
|
|||
| plugin contexts |
|
||||
\================*/
|
||||
|
||||
private static void Context_Config_Dump(dynamic vaProxy)
|
||||
{
|
||||
Config.DumpConfig();
|
||||
}
|
||||
|
||||
private static void Context_Config_Setup(dynamic vaProxy)
|
||||
{
|
||||
Log.Debug("Loading default configuration …");
|
||||
|
@ -282,12 +287,15 @@ namespace alterNERDtive
|
|||
Context_Startup(vaProxy);
|
||||
break;
|
||||
// config
|
||||
case "config.setup":
|
||||
Context_Config_Setup(vaProxy);
|
||||
case "config.dump":
|
||||
Context_Config_Dump(vaProxy);
|
||||
break;
|
||||
case "config.getvariables":
|
||||
Context_Config_SetVariables(vaProxy);
|
||||
break;
|
||||
case "config.setup":
|
||||
Context_Config_Setup(vaProxy);
|
||||
break;
|
||||
case "config.versionmigration":
|
||||
Context_Config_VersionMigration(vaProxy);
|
||||
break;
|
||||
|
|
|
@ -270,6 +270,58 @@ namespace alterNERDtive.util
|
|||
ApplyDefault(id, key);
|
||||
}
|
||||
}
|
||||
|
||||
public void DumpConfig()
|
||||
{
|
||||
foreach (string id in Defaults.Keys)
|
||||
{
|
||||
DumpConfig(id);
|
||||
}
|
||||
}
|
||||
public void DumpConfig(string id)
|
||||
{
|
||||
Log.Notice($"===== {id} configuration: =====");
|
||||
foreach (string name in Defaults[id].Keys)
|
||||
{
|
||||
DumpConfig(id, name);
|
||||
}
|
||||
}
|
||||
public void DumpConfig(string id, string name)
|
||||
{
|
||||
Option option = Defaults[id][name];
|
||||
string variable = $"{id}.{option.Name}#";
|
||||
dynamic defaultValue = option.DefaultValue;
|
||||
dynamic value;
|
||||
if (defaultValue is bool)
|
||||
{
|
||||
value = VA.GetBoolean(variable);
|
||||
}
|
||||
else if (defaultValue is DateTime)
|
||||
{
|
||||
value = VA.GetDate(variable);
|
||||
}
|
||||
else if (defaultValue is decimal)
|
||||
{
|
||||
value = VA.GetDecimal(variable);
|
||||
}
|
||||
else if (defaultValue is int)
|
||||
{
|
||||
value = VA.GetInt(variable);
|
||||
}
|
||||
else if (defaultValue is short)
|
||||
{
|
||||
value = VA.GetSmallInt(variable);
|
||||
}
|
||||
else if (defaultValue is string)
|
||||
{
|
||||
value = VA.GetText(variable);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidDataException($"Invalid data type for option '{id}.{name}': '{defaultValue}'");
|
||||
}
|
||||
Log.Notice($"{variable} = {value}{(value == defaultValue? " (default)" : "")}");
|
||||
}
|
||||
}
|
||||
|
||||
public class PythonProxy
|
||||
|
|
Loading…
Reference in a new issue