@ -21,89 +21,141 @@ class ACommandFeature extends Command
dependson(PendingConfigsTool);
dependson(PendingConfigsTool);
var private class<Feature> selectedFeatureClass;
var private class<Feature> selectedFeatureClass;
var private Text selectedFeatureName;
var private Text selectedConfigName;
var private Text selectedConfigName;
var private PendingConfigsTool pendingConfigs;
var private PendingConfigsTool pendingConfigs;
var private ACommandFeature_Announcer announcer;
var private ACommandFeature_Announcer announcer;
protected function Constructor()
protected function Constructor() {
{
pendingConfigs = PendingConfigsTool(_.memory.Allocate(class'PendingConfigsTool'));
pendingConfigs =
PendingConfigsTool(_.memory.Allocate(class'PendingConfigsTool'));
super.Constructor();
super.Constructor();
}
}
protected function Finalizer()
protected function Finalizer() {
{
_.memory.Free(announcer);
_.memory.Free(announcer);
_.memory.Free(pendingConfigs);
_.memory.Free(pendingConfigs);
super.Finalizer();
super.Finalizer();
}
}
protected function BuildData(CommandDataBuilder builder)
protected function BuildData(CommandDataBuilder builder) {
{
builder.Group(P("admin"));
builder.Name(P("feature")).Group(P("admin"))
builder.Summary(P("Managing features."));
.Summary(P("Managing features."))
builder.Describe(P("Command for managing features and their configs."));
.Describe(P("Command for displaying and enabling/disabling features."));
builder.SubCommand(P("enable"));
builder.SubCommand(P("enable"))
builder.ParamText(P("feature"),, P("feature"));
.ParamText(P("feature"))
builder.OptionalParams();
.OptionalParams()
builder.ParamText(P("config"));
.ParamText(P("config"))
builder.Describe(P("Enables specified <feature>. If <config> isn't specified -"
.Describe(P("Enables specified <feature>."));
@ "choses the \"default\" one, making new config with default"
builder.SubCommand(P("disable"))
@ "settings if it doesn't exist."));
.ParamText(P("feature"))
builder.SubCommand(P("disable"));
.Describe(P("Disables specified <feature>."));
builder.ParamText(P("feature"),, P("feature"));
builder.SubCommand(P("showconf"))
builder.Describe(P("Disables specified <feature>."));
.ParamText(P("feature"))
builder.SubCommand(P("showconf"));
.ParamText(P("config"));
builder.ParamText(P("feature"),, P("feature"));
builder.SubCommand(P("editconf"))
builder.OptionalParams();
.ParamText(P("feature"))
builder.ParamText(P("config"));
.ParamText(P("config"))
builder.Describe(P("Show given <config> for the given <feature>."));
.ParamText(P("variable path"))
builder.SubCommand(P("editconf"));
.ParamRemainder(P("value"));
builder.ParamText(P("feature"),, P("feature"));
builder.ParamText(P("config"));
builder.ParamText(P("variable_path"));
builder.ParamJSON(P("value"));
builder.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"));
builder.ParamText(P("feature"),, P("feature"));
builder.ParamText(P("config"));
builder.Describe(P("Saves pending changes for the given <config> of the given"
@ "<feature>."));
builder.SubCommand(P("newconf"));
builder.ParamText(P("feature"),, P("feature"));
builder.ParamText(P("config"));
builder.Describe(P("Creates new config for the given <feature>."));
builder.SubCommand(P("removeconf"));
builder.ParamText(P("feature"),, P("feature"));
builder.ParamText(P("config"));
builder.Describe(P("Removes specified <config> of the specified <feature>."));
builder.SubCommand(P("autoconf"));
builder.ParamText(P("feature"),, P("feature"));
builder.OptionalParams();
builder.ParamText(P("config"));
builder.Describe(P("Changes current auto config config of the specified"
@ "<feature>. Auto config is a config that is supposed to be"
@ "automatically enabled at the start of the Acedia, unless"
@ "otherwise specified for the loader."));
builder.Option(P("all"));
builder.Describe(F("Affects subcommand {$TextEmphasis showconf} by making it"
@ "show all available configs."));
builder.Option(P("save"));
builder.Describe(F("Affects subcommand {$TextEmphasis editconf} by making it"
@ "also save all pending changes."));
announcer = ACommandFeature_Announcer(
announcer = ACommandFeature_Announcer(
_.memory.Allocate(class'ACommandFeature_Announcer'));
_.memory.Allocate(class'ACommandFeature_Announcer'));
}
}
protected function Executed(CallData arguments, EPlayer instigator)
protected function Executed(
{
CallData arguments,
local Text userGivenFeatureName, userGivenConfigName;
EPlayer instigator,
CommandPermissions permissions
) {
local bool saveFlag, allFlag;
announcer.Setup(none, instigator, othersConsole);
announcer.Setup(none, instigator, othersConsole);
userGivenFeatureName = arguments.parameters.GetText(P("feature"));
saveFlag = arguments.options.HasKey(P("save"));
selectedFeatureClass = LoadFeatureClass(userGivenFeatureName);
allFlag = arguments.options.HasKey(P("all"));
_.memory.Free(userGivenFeatureName);
SelectFeatureAndConfig(arguments);
userGivenConfigName = arguments.parameters.GetText(P("config"));
if (userGivenConfigName != none)
{
selectedConfigName = userGivenConfigName.LowerCopy();
userGivenConfigName.FreeSelf();
}
pendingConfigs.SelectConfig(selectedFeatureClass, selectedConfigName);
if (arguments.subCommandName.IsEmpty()) {
if (arguments.subCommandName.IsEmpty()) {
ShowAllFeatures();
ShowAllFeatures();
}
} else if (arguments.subCommandName.Compare(P("enable"))) {
else if (arguments.subCommandName.Compare(P("enable"))) {
EnableFeature();
EnableFeature();
}
} else if (arguments.subCommandName.Compare(P("disable"))) {
else if (arguments.subCommandName.Compare(P("disable"))) {
DisableFeature();
DisableFeature();
}
} else if (arguments.subCommandName.Compare(P("showconf"))) {
else if (arguments.subCommandName.Compare(P("showconf"))) {
ShowSelectedConfigs(allFlag);
ShowFeatureConfig();
} else if (arguments.subCommandName.Compare(P("editconf"))) {
}
else if (arguments.subCommandName.Compare(P("editconf")))
{
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);
_.memory.Free(selectedConfigName);
} else if (arguments.subCommandName.Compare(P("saveconf"))) {
SaveFeatureConfig();
} else if (arguments.subCommandName.Compare(P("newconf"))) {
NewFeatureConfig();
} else if (arguments.subCommandName.Compare(P("removeconf"))) {
RemoveFeatureConfig();
} else if (arguments.subCommandName.Compare(P("autoconf"))) {
SetAutoFeatureConfig();
}
_.memory.Free2(selectedConfigName, selectedFeatureName);
selectedConfigName = none;
selectedConfigName = none;
selectedFeatureName = none;
}
}
protected function EnableFeature()
protected function SelectFeatureAndConfig(CallData arguments) {
{
local Text featureClassName, userGivenConfigName;
selectedFeatureName = arguments.parameters.GetTextBy(P("/feature/alias"));
featureClassName = arguments.parameters.GetTextBy(P("/feature/value"));
selectedFeatureClass = LoadFeatureClass(featureClassName);
if (selectedFeatureClass == none && !arguments.subCommandName.IsEmpty()) {
_.memory.Free(selectedFeatureName);
selectedFeatureName = none;
return;
}
_.memory.Free(featureClassName);
userGivenConfigName = arguments.parameters.GetText(P("config"));
if (userGivenConfigName != none) {
selectedConfigName = userGivenConfigName.LowerCopy();
userGivenConfigName.FreeSelf();
}
pendingConfigs.SelectConfig(selectedFeatureClass, selectedConfigName);
}
protected function EnableFeature() {
local bool wasEnabled;
local bool wasEnabled;
local Text oldConfig, newConfig;
local Text oldConfig, newConfig;
local Feature instance;
local Feature instance;
@ -112,79 +164,99 @@ protected function EnableFeature()
oldConfig = selectedFeatureClass.static.GetCurrentConfig();
oldConfig = selectedFeatureClass.static.GetCurrentConfig();
newConfig = PickConfigBasedOnParameter();
newConfig = PickConfigBasedOnParameter();
// Already enabled with the same config!
// Already enabled with the same config!
if (oldConfig != none && oldConfig.Compare(newConfig, SCASE_INSENSITIVE))
if (oldConfig != none && oldConfig.Compare(newConfig, SCASE_INSENSITIVE)) {
{
announcer.AnnounceFailedAlreadyEnabled(selectedFeatureName, newConfig);
announcer.AnnounceFailedAlreadyEnabled(selectedFeatureClass, newConfig);
_.memory.Free(newConfig);
_.memory.Free(newConfig);
_.memory.Free(oldConfig);
_.memory.Free(oldConfig);
return;
return;
}
}
// Try enabling and report the result
// Try enabling and report the result
instance = selectedFeatureClass.static.EnableMe(newConfig);
instance = selectedFeatureClass.static.EnableMe(newConfig);
if (instance == none)
if (instance == none) {
{
announcer.AnnounceFailedCannotEnableFeature(
announcer.AnnounceFailedCannotEnableFeature(
selectedFeatureClass ,
selectedFeatureName ,
newConfig);
newConfig);
}
} else if (wasEnabled) {
else if (wasEnabled)
{
announcer.AnnounceSwappedConfig(
announcer.AnnounceSwappedConfig(
selectedFeatureClass ,
selectedFeatureName,
oldConfig,
oldConfig,
newConfig);
newConfig);
}
} else {
else {
announcer.AnnounceEnabledFeature(selectedFeatureName, newConfig);
announcer.AnnounceEnabledFeature(selectedFeatureClass, newConfig);
}
}
_.memory.Free(newConfig);
_.memory.Free(newConfig);
_.memory.Free(oldConfig);
_.memory.Free(oldConfig);
}
}
protected function DisableFeature()
protected function DisableFeature() {
{
if (!selectedFeatureClass.static.IsEnabled()) {
if (!selectedFeatureClass.static.IsEnabled())
announcer.AnnounceFailedAlreadyDisabled(selectedFeatureName);
{
announcer.AnnounceFailedAlreadyDisabled(selectedFeatureClass);
return;
return;
}
}
selectedFeatureClass.static.DisableMe();
selectedFeatureClass.static.DisableMe();
// It is possible that this command itself is destroyed after above command
// It is possible that this command itself is destroyed after above command
// so do the check just in case
// so do the check just in case
if (IsAllocated()) {
if (IsAllocated()) {
announcer.AnnounceDisabledFeature(selectedFeatureClass );
announcer.AnnounceDisabledFeature(selectedFeatureName );
}
}
}
}
protected function ShowFeatureConfig()
protected function ShowSelectedConfigs(bool showAllFeatures) {
{
local int i;
local array<Text> availableConfigs;
local MutableText configList;
local class<FeatureConfig> configClass;
if (showAllFeatures) {
configClass = selectedFeatureClass.default.configClass;
if (configClass != none) {
availableConfigs = configClass.static.AvailableConfigs();
}
for (i = 0; i < availableConfigs.length; i += 1) {
ShowFeatureConfig(availableConfigs[i]);
}
_.memory.FreeMany(availableConfigs);
return;
}
if (selectedConfigName != none) {
ShowFeatureConfig(selectedConfigName);
return;
}
configList = PrintConfigList(selectedFeatureClass);
callerConsole
.Flush()
.Write(P("Available configs: "))
.WriteLine(configList);
_.memory.Free(configList);
}
protected function ShowFeatureConfig(BaseText configName) {
local MutableText dataAsJSON;
local MutableText dataAsJSON;
local HashTable currentData, pendingData;
local HashTable currentData, pendingData;
if (selectedConfigName == none) {
if (configName == none) {
return;
return;
}
}
currentData = GetCurrentConfigData();
currentData = GetCurrentConfigData(configName);
if (currentData == none)
if (currentData == none) {
{
announcer.AnnounceFailedNoDataForConfig(
announcer.AnnounceFailedNoDataForConfig(
selectedFeatureClass,
selectedFeatureName ,
selectedConfigName);
configName);
return;
return;
}
}
// Display current data
// Display current data
dataAsJSON = _.json.PrettyPrint(currentData);
dataAsJSON = _.json.PrettyPrint(currentData);
announcer.AnnounceCurrentConfig(selectedFeatureClass, selectedConfigName);
announcer.AnnounceCurrentConfig(selectedFeatureName, c onfigName);
callerConsole.Flush().WriteLine(dataAsJSON);
callerConsole.Flush().WriteLine(dataAsJSON);
_.memory.Free(dataAsJSON);
_.memory.Free(dataAsJSON);
// Display pending data
// Display pending data
pendingConfigs.SelectConfig(selectedFeatureClass, configName);
pendingData = pendingConfigs.GetPendingConfigData();
pendingData = pendingConfigs.GetPendingConfigData();
if (pendingData != none)
if (pendingData != none) {
{
dataAsJSON = _.json.PrettyPrint(pendingData);
dataAsJSON = _.json.PrettyPrint(pendingData);
announcer.AnnouncePendingConfig(
announcer.AnnouncePendingConfig(
selectedFeatureClass,
selectedFeatureName ,
selectedConfigName);
configName);
callerConsole.Flush().WriteLine(dataAsJSON);
callerConsole.Flush().WriteLine(dataAsJSON);
_.memory.Free(dataAsJSON);
_.memory.Free(dataAsJSON);
}
}
@ -192,20 +264,17 @@ protected function ShowFeatureConfig()
_.memory.Free(currentData);
_.memory.Free(currentData);
}
}
protected function Text PickConfigBasedOnParameter()
protected function Text PickConfigBasedOnParameter() {
{
local Text resolvedConfig;
local Text resolvedConfig;
local class<FeatureConfig> configClass;
local class<FeatureConfig> configClass;
configClass = selectedFeatureClass.default.configClass;
configClass = selectedFeatureClass.default.configClass;
if (configClass == none)
if (configClass == none) {
{
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
announcer.AnnounceFailedNoConfigClass(selectedFeatureClass);
return none;
return none;
}
}
// If config was specified - simply check that it exists
// If config was specified - simply check that it exists
if (selectedConfigName != none)
if (selectedConfigName != none) {
{
if (configClass.static.Exists(selectedConfigName)) {
if (configClass.static.Exists(selectedConfigName)) {
return selectedConfigName.Copy();
return selectedConfigName.Copy();
}
}
@ -215,143 +284,296 @@ protected function Text PickConfigBasedOnParameter()
// If it wasn't specified - try auto config instead
// If it wasn't specified - try auto config instead
resolvedConfig = configClass.static.GetAutoEnabledConfig();
resolvedConfig = configClass.static.GetAutoEnabledConfig();
if (resolvedConfig == none) {
if (resolvedConfig == none) {
announcer.AnnounceFailedNoConfigProvided(selectedFeatureClass );
announcer.AnnounceFailedNoConfigProvided(selectedFeatureName );
}
}
return resolvedConfig;
return resolvedConfig;
}
}
protected function class<Feature> LoadFeatureClass(BaseText featureName)
protected function class<Feature> LoadFeatureClass(BaseText featureClassName) {
{
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;
}
}
protected function ShowAllFeatures()
protected function ShowAllFeatures() {
{
local int i;
local int i;
local array< class<Feature> > availableFeatures;
local array< class<Feature> > availableFeatures;
availableFeatures = _.environment.GetAvailableFeatures();
availableFeatures = _.environment.GetAvailableFeatures();
for (i = 0; i < availableFeatures.length; i ++) {
for (i = 0; i < availableFeatures.length; i ++) {
ShowFeature(availableFeatures[i]);
ShowFeature(availableFeatures[i]);
}
}
}
}
protected function ShowFeature(class<Feature> feature)
protected function ShowFeature(class<Feature> featureClass )
{
{
local int i;
local MutableText featureName;
local Text autoConfig;
local MutableText configList;
local MutableText featureName, builder, nextConfig;
local ListBuilder configList;
local array<Text> availableConfigs;
local class<FeatureConfig> configClass;
if (feature == none) {
if (featureClass == none) {
return;
return;
}
}
configClass = feature.default.configClass;
if (configClass != none) {
availableConfigs = configClass.static.AvailableConfigs();
}
featureName = _.text
featureName = _.text
.FromClassM(feature)
.FromClassM(featureClass)
.ChangeDefaultColor(_.color.TextEmphasis);
.ChangeDefaultColor(_.color.TextEmphasis);
builder = _.text.Empty();
configList = PrintConfigList(featureClass);
if (feature.static.IsEnabled()) {
callerConsole.Flush();
builder.Append(F("[ {$TextPositive enabled} ] "));
if (featureClass.static.IsEnabled()) {
callerConsole.Write(F("[ {$TextPositive enabled} ] "));
}
}
else {
else {
builder.Append (F("[ {$TextNegative disabled} ] "));
callerConsole.Write (F("[ {$TextNegative disabled} ] "));
}
}
builder.Append(featureName);
callerConsole.Write(featureName)
.Write(P(" with configs: "))
.WriteLine(configList);
_.memory.Free(featureName);
_.memory.Free(featureName);
if (availableConfigs.length == 1) {
_.memory.Free(configList);
builder.Append(P(" with config: "));
}
}
else if (availableConfigs.length > 1) {
protected function MutableText PrintConfigList(class<Feature> featureClass) {
builder.Append(P(" with configs: "));
local int i;
}
local Text autoConfig, enabledConfig;
callerConsole.Write(builder);
local ListBuilder configList;
_.memory.Free(builder);
local MutableText result, nextConfig;
configList = ListBuilder(_.memory.Allocate(class'ListBuilder'));
local array<Text> availableConfigs;
local class<FeatureConfig> configClass;
if (featureClass == none) return none;
configClass = featureClass.default.configClass;
if (configClass == none) return none;
availableConfigs = configClass.static.AvailableConfigs();
enabledConfig = featureClass.static.GetCurrentConfig();
autoConfig = configClass.static.GetAutoEnabledConfig();
autoConfig = configClass.static.GetAutoEnabledConfig();
for (i = 0; i < availableConfigs.length; i += 1)
configList = ListBuilder(_.memory.Allocate(class'ListBuilder'));
{
for (i = 0; i < availableConfigs.length; i += 1) {
nextConfig = availableConfigs[i].MutableCopy();
nextConfig = availableConfigs[i].MutableCopy();
if (pendingConfigs.HasPendingConfigFor(feature, nextConfig)) {
if (enabledConfig != none && enabledConfig.Compare(nextConfig, SCASE_INSENSITIVE)) {
nextConfig.Append(P("*"));
nextConfig.ChangeDefaultColor(_.color.TextPositive);
}
if (pendingConfigs.HasPendingConfigFor(featureClass, nextConfig)) {
nextConfig.Append(F("{$TextEmphasis *}"));
}
}
configList.Item(nextConfig);
configList.Item(nextConfig);
_.memory.Free(nextConfig);
_.memory.Free(nextConfig);
if ( autoConfig != none
if (autoConfig != none && autoConfig.Compare(availableConfigs[i], SCASE_INSENSITIVE)) {
&& autoConfig.Compare(availableConfigs[i], SCASE_INSENSITIVE))
if (autoConfig.Compare(enabledConfig, SCASE_INSENSITIVE)) {
{
configList.Comment(F("{$TextPositive auto enabled}"));
configList.Comment(F("{$TextPositive auto enabled}"));
} else {
configList.Comment(F("{$TextNegative auto enabled}"));
}
}
}
}
}
builder = configList.GetMutable();
result = configList.GetMutable();
callerConsole.WriteLine(builder );
_.memory.Free3(configList, autoConfig, enabledConfig );
_.memory.FreeMany(availableConfigs);
_.memory.FreeMany(availableConfigs);
_.memory.Free(configList);
return result;
_.memory.Free(autoConfig);
_.memory.Free(builder);
}
}
protected function EditFeatureConfig(BaseText pathToValue, BaseText newValue)
protected function MutableText PrettyPrintValueAt(BaseText pathToValue) {
{
local MutableText printedValue;
local PendingConfigsTool.PendingConfigToolError error;
local AcediaObject value;
local HashTable relevantData;
error = pendingConfigs.ChangeConfig(pathToValue, newValue);
relevantData = pendingConfigs.GetPendingConfigData();
if (relevantData == none) {
relevantData = GetCurrentSelectedConfigData();
}
if (relevantData != none) {
value = relevantData.GetItemBy(pathToValue);
}
if (value != none) {
printedValue = _.json.PrettyPrint(value);
_.memory.Free(value);
}
_.memory.Free(relevantData);
return printedValue;
}
protected function EditFeatureConfig(BaseText pathToValue, AcediaObject 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) {
printedNewValue = PrettyPrintValueAt(pathToValue);
}
if (error == PCTE_ConfigMissing) {
if (error == PCTE_ConfigMissing) {
announcer.AnnounceFailedConfigMissing(selectedConfigName);
announcer.AnnounceFailedConfigMissing(selectedConfigName);
}
}
else if (error == PCTE_ExpectedObject) {
else if (error == PCTE_ExpectedObject) {
announcer.AnnounceFailedExpectedObject();
announcer.AnnounceFailedExpectedObject();
}
} else if (error == PCTE_BadPointer) {
else if (error == PCTE_BadPointer)
{
announcer.AnnounceFailedBadPointer(
announcer.AnnounceFailedBadPointer(
selectedFeatureClass,
selectedFeatureName,
selectedConfigName,
selectedConfigName,
pathToValue);
pathToValue);
} else if (printedOldValue == none) {
announcer.AnnounceConfigNewValue(
selectedFeatureName,
selectedConfigName,
pathToValue,
printedNewValue);
} else {
announcer.AnnounceConfigEdited(
selectedFeatureName,
selectedConfigName,
pathToValue,
printedOldValue,
printedNewValue);
}
}
if (saveConfig && error == PCTE_None) {
SaveFeatureConfig();
}
_.memory.Free(printedOldValue);
_.memory.Free(printedNewValue);
_.memory.Free(pathToValue);
_.memory.Free(newValue);
}
}
private function HashTable GetCurrentConfigData()
protected function SaveFeatureConfig() {
{
local BaseText enabledConfigName;
local HashTable pendingData;
local class<FeatureConfig> configClass;
configClass = selectedFeatureClass.default.configClass;
if (configClass == none) {
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
return;
}
pendingData = pendingConfigs.GetPendingConfigData();
if (pendingData == none) {
announcer.AnnounceFailedPendingConfigMissing(selectedConfigName);
return;
}
// Make sure config exists
configClass.static.NewConfig(selectedConfigName);
configClass.static.SaveData(selectedConfigName, pendingData);
// Re-apply config if it is active?
enabledConfigName = selectedFeatureClass.static.GetCurrentConfig();
if (selectedConfigName.Compare(enabledConfigName, SCASE_INSENSITIVE)) {
selectedFeatureClass.static.EnableMe(selectedConfigName);
announcer.AnnouncePublicPendingConfigSaved(selectedFeatureName);
} else {
announcer.AnnouncePrivatePendingConfigSaved(selectedFeatureName, selectedConfigName);
}
_.memory.Free(enabledConfigName);
pendingData.FreeSelf();
pendingConfigs.RemoveConfig();
return;
}
protected function NewFeatureConfig() {
local BaseText enabledConfigName;
local class<FeatureConfig> configClass;
configClass = selectedFeatureClass.default.configClass;
if (configClass == none) {
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
return;
}
if (configClass.static.Exists(selectedConfigName)) {
announcer.AnnounceFailedConfigAlreadyExists(selectedFeatureName, selectedConfigName);
return;
}
if (!configClass.static.NewConfig(selectedConfigName)) {
announcer.AnnounceFailedBadConfigName(selectedConfigName);
return;
}
enabledConfigName = selectedFeatureClass.static.GetCurrentConfig();
if (selectedConfigName.Compare(enabledConfigName, SCASE_INSENSITIVE)) {
selectedFeatureClass.static.EnableMe(selectedConfigName);
announcer.AnnouncePublicPendingConfigSaved(selectedFeatureName);
}
_.memory.Free(enabledConfigName);
announcer.AnnounceConfigCreated(selectedFeatureName, selectedConfigName);
}
protected function RemoveFeatureConfig() {
local class<FeatureConfig> configClass;
local class<FeatureConfig> configClass;
if (selectedConfigName == none) {
configClass = selectedFeatureClass.default.configClass;
if (configClass == none) {
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
return;
}
if (!configClass.static.Exists(selectedConfigName)) {
announcer.AnnounceFailedConfigDoesNotExist(
selectedFeatureName,
selectedConfigName);
return;
}
pendingConfigs.RemoveConfig();
configClass.static.DeleteConfig(selectedConfigName);
announcer.AnnounceConfigRemoved(selectedFeatureName, selectedConfigName);
}
protected function SetAutoFeatureConfig() {
local Text currentAutoEnabledConfig;
local class<FeatureConfig> configClass;
configClass = selectedFeatureClass.default.configClass;
if (configClass == none) {
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
return;
}
if (selectedConfigName != none && !configClass.static.Exists(selectedConfigName)) {
announcer.AnnounceFailedConfigDoesNotExist(selectedFeatureName, selectedConfigName);
return;
}
currentAutoEnabledConfig = configClass.static.GetAutoEnabledConfig();
if (selectedConfigName == none && currentAutoEnabledConfig == none) {
announcer.AnnounceFailedAlreadyNoAutoEnabled(selectedFeatureName);
}
else if (selectedConfigName != none &&
selectedConfigName.Compare(currentAutoEnabledConfig, SCASE_INSENSITIVE)) {
announcer.AnnounceFailedAlreadySameAutoEnabled(
selectedFeatureName,
selectedConfigName);
} else {
configClass.static.SetAutoEnabledConfig(selectedConfigName);
if (selectedConfigName != none) {
announcer.AnnounceAutoEnabledConfig(
selectedFeatureName,
selectedConfigName);
} else {
announcer.AnnounceRemovedAutoEnabledConfig(selectedFeatureName);
}
}
_.memory.Free(currentAutoEnabledConfig);
}
private function HashTable GetCurrentConfigData(BaseText configName) {
local class<FeatureConfig> configClass;
if (configName == none) {
return none;
return none;
}
}
configClass = selectedFeatureClass.default.configClass;
configClass = selectedFeatureClass.default.configClass;
if (configClass == none)
if (configClass == none) {
{
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
announcer.AnnounceFailedNoConfigClass(selectedFeatureClass);
return none;
return none;
}
}
return configClass.static.LoadData(selectedConfigName);
return configClass.static.LoadData(configName);
}
}
// 5. Add `saveconf` and `--save` flag
private function HashTable GetCurrentSelectedConfigData() {
// 6. Add `removeconf`
return GetCurrentConfigData(selectedConfigName);
// 7. Add `newconf`
}
// 8. Add `autoconf` for setting auto config
defaultproperties
defaultproperties {
{
preferredName = "feature"
}
}