2021-10-12 21:21:22 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "ConsoleVariablesAsset.h"
|
|
|
|
|
|
2021-11-07 23:43:01 -05:00
|
|
|
#include "ConsoleVariablesEditorCommandInfo.h"
|
|
|
|
|
|
2021-10-12 21:21:22 -04:00
|
|
|
#include "Algo/Find.h"
|
|
|
|
|
|
|
|
|
|
void UConsoleVariablesAsset::SetVariableCollectionDescription(const FString& InVariableCollectionDescription)
|
|
|
|
|
{
|
|
|
|
|
VariableCollectionDescription = InVariableCollectionDescription;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-09 16:29:56 -05:00
|
|
|
void UConsoleVariablesAsset::ReplaceSavedCommands(const TArray<FConsoleVariablesEditorAssetSaveData>& Replacement)
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-09 16:29:56 -05:00
|
|
|
SavedCommands = Replacement;
|
2021-10-12 21:21:22 -04:00
|
|
|
}
|
|
|
|
|
|
2021-12-09 16:29:56 -05:00
|
|
|
bool UConsoleVariablesAsset::FindSavedDataByCommandString(const FString& InCommandString, FConsoleVariablesEditorAssetSaveData& OutValue) const
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-09 16:29:56 -05:00
|
|
|
if (const auto* Match = Algo::FindByPredicate(
|
|
|
|
|
SavedCommands,
|
|
|
|
|
[&InCommandString] (const FConsoleVariablesEditorAssetSaveData& Comparator)
|
|
|
|
|
{
|
|
|
|
|
return Comparator.CommandName.Equals(InCommandString);
|
|
|
|
|
}))
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-07 21:18:09 -05:00
|
|
|
OutValue = *Match;
|
2021-11-22 23:55:32 -05:00
|
|
|
return true;
|
2021-10-12 21:21:22 -04:00
|
|
|
}
|
2021-11-07 23:43:01 -05:00
|
|
|
|
2021-10-12 21:21:22 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-09 16:29:56 -05:00
|
|
|
void UConsoleVariablesAsset::AddOrSetConsoleVariableSavedData(const FConsoleVariablesEditorAssetSaveData& InData)
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-09 16:29:56 -05:00
|
|
|
RemoveConsoleVariable(InData.CommandName);
|
|
|
|
|
SavedCommands.Add(InData);
|
2021-10-12 21:21:22 -04:00
|
|
|
}
|
|
|
|
|
|
2021-11-07 23:43:01 -05:00
|
|
|
bool UConsoleVariablesAsset::RemoveConsoleVariable(const FString& InCommandString)
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-09 16:29:56 -05:00
|
|
|
FConsoleVariablesEditorAssetSaveData ExistingData;
|
|
|
|
|
if (FindSavedDataByCommandString(InCommandString, ExistingData))
|
2021-11-07 23:43:01 -05:00
|
|
|
{
|
2021-12-09 16:29:56 -05:00
|
|
|
return SavedCommands.Remove(ExistingData) > 0;
|
2021-11-07 23:43:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
2021-10-12 21:21:22 -04:00
|
|
|
}
|
|
|
|
|
|
2021-12-09 16:29:56 -05:00
|
|
|
void UConsoleVariablesAsset::CopyFrom(const UConsoleVariablesAsset* InAssetToCopy)
|
2021-10-12 21:21:22 -04:00
|
|
|
{
|
2021-12-09 16:29:56 -05:00
|
|
|
VariableCollectionDescription = InAssetToCopy->GetVariableCollectionDescription();
|
|
|
|
|
SavedCommands = InAssetToCopy->GetSavedCommands();
|
2021-10-12 21:21:22 -04:00
|
|
|
}
|