@ -46,44 +46,44 @@ protected function BuildData(CommandDataBuilder builder)
.Summary(P("Managing features."))
.Describe(P("Command for managing features and their configs."));
builder.SubCommand(P("enable"))
.ParamText(P("feature"))
.ParamText(P("feature"),, P("feature") )
.OptionalParams()
.ParamText(P("config"))
.Describe(P("Enables specified <feature>. If <config> isn't specified -"
@ "choses the \"default\" one, making new config with default"
@ "settings if it doesn't exist."));
builder.SubCommand(P("disable"))
.ParamText(P("feature"))
.ParamText(P("feature"),, P("feature") )
.Describe(P("Disables specified <feature>."));
builder.SubCommand(P("showconf"))
.ParamText(P("feature"))
.ParamText(P("feature"),, P("feature") )
.OptionalParams()
.ParamText(P("config"))
.Describe(P("Show given <config> for the given <feature>."));
builder.SubCommand(P("editconf"))
.ParamText(P("feature"))
.ParamText(P("feature"),, P("feature") )
.ParamText(P("config"))
.ParamText(P("variable_path"))
.ParamRemainder (P("value"))
.ParamJSON (P("value"))
.Describe(P("Changes a value inside given <config> of the given"
@ "<feature> by setting value at JSON path <variable_path> to"
@ "the JSON value <value>. Changes won't be immediately applied to"
@ "the game and kept as pending."));
builder.SubCommand(P("saveconf"))
.ParamText(P("feature"))
.ParamText(P("feature"),, P("feature") )
.ParamText(P("config"))
.Describe(P("Saves pending changes for the given <config> of the given"
@ "<feature>."));
builder.SubCommand(P("newconf"))
.ParamText(P("feature"))
.ParamText(P("feature"),, P("feature") )
.ParamText(P("config"))
.Describe(P("Creates new config for the given <feature>."));
builder.SubCommand(P("removeconf"))
.ParamText(P("feature"))
.ParamText(P("feature"),, P("feature") )
.ParamText(P("config"))
.Describe(P("Removes specified <config> of the specified <feature>."));
builder.SubCommand(P("autoconf"))
.ParamText(P("feature"))
.ParamText(P("feature"),, P("feature") )
.OptionalParams()
.ParamText(P("config"))
.Describe(P("Changes current auto config config of the specified"
@ -124,7 +124,7 @@ protected function Executed(CallData arguments, EPlayer instigator)
{
EditFeatureConfig(
arguments.parameters.GetText(P("variable_path")),
arguments.parameters.GetText (P("value")),
arguments.parameters.GetItem (P("value")),
saveFlag);
}
else if (arguments.subCommandName.Compare(P("saveconf"))) {
@ -145,14 +145,14 @@ protected function Executed(CallData arguments, EPlayer instigator)
protected function SelectFeatureAndConfig(CallData arguments)
{
local Text userGivenFeature Name, userGivenConfigName;
local Text featureClass Name, userGivenConfigName;
userGivenFeature Name = arguments.parameters.GetText(P("feature"));
selectedFeatureClass = LoadFeatureClass(userGivenFeature Name);
featureClass Name = arguments.parameters.GetText(P("feature"));
selectedFeatureClass = LoadFeatureClass(featureClass Name);
if (selectedFeatureClass == none && !arguments.subCommandName.IsEmpty()) {
return;
}
_.memory.Free(userGivenFeature Name);
_.memory.Free(featureClass Name);
userGivenConfigName = arguments.parameters.GetText(P("config"));
if (userGivenConfigName != none)
{
@ -313,24 +313,17 @@ protected function Text PickConfigBasedOnParameter()
return resolvedConfig;
}
protected function class<Feature> LoadFeatureClass(BaseText featureName)
protected function class<Feature> LoadFeatureClass(BaseText featureClass Name)
{
local Text featureClassName ;
local class<Feature> featureClass;
if (featureName == none) {
local class<Feature> featureClass ;
if (featureClass Name == none) {
return none;
}
if (featureName.StartsWith(P("$"))) {
featureClassName = _.alias.ResolveFeature(featureName, true);
}
else {
featureClassName = featureName.Copy();
}
featureClass = class<Feature>(_.memory.LoadClass(featureClassName));
if (featureClass == none) {
announcer.AnnounceFailedToLoadFeatureClass(featureName);
announcer.AnnounceFailedToLoadFeatureClass(featureClassName);
}
_.memory.Free(featureClassName);
return featureClass;
}
@ -430,14 +423,17 @@ protected function MutableText PrettyPrintValueAt(BaseText pathToValue)
}
protected function EditFeatureConfig(
BaseText pathToValue,
BaseTex t newValue,
bool saveConfig)
BaseText pathToValue,
AcediaObjec t newValue,
bool saveConfig)
{
local MutableText printedOldValue;
local MutableText printedNewValue;
local PendingConfigsTool.PendingConfigToolResult error;
if (selectedFeatureClass == none) {
return;
}
printedOldValue = PrettyPrintValueAt(pathToValue);
error = pendingConfigs.EditConfig(pathToValue, newValue);
if (error == PCTE_None) {
@ -478,6 +474,8 @@ protected function EditFeatureConfig(
}
_.memory.Free(printedOldValue);
_.memory.Free(printedNewValue);
_.memory.Free(pathToValue);
_.memory.Free(newValue);
}
protected function SaveFeatureConfig()