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