Files
UnrealEngineUWP/Engine/Plugins/EnhancedInput/Source/InputEditor/Private/EnhancedInputPlayerMappableNameValidator.cpp
ben hoffman f180f2cf58 Add a name validator to player mappable setting names. This makes it easier to avoid mistakes and possibly stomping a key binding.
The "Name" here is the FName that will be used as a key to save each key mapping during serialization, so they should be unique for each key mapping that you want the player to be able to set.

#jira UE-177248
#preflight 63f4ef2290198dffba48f6ee
#rb benjamin.fox
#rb nate.strohmyer
#rnx

[CL 24344605 by ben hoffman in ue5-main branch]
2023-02-21 13:37:27 -05:00

20 lines
659 B
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "EnhancedInputPlayerMappableNameValidator.h"
#include "InputEditorModule.h"
FEnhancedInputPlayerMappableNameValidator::FEnhancedInputPlayerMappableNameValidator(FName InExistingName)
: FStringSetNameValidator(InExistingName.ToString())
{ }
EValidatorResult FEnhancedInputPlayerMappableNameValidator::IsValid(const FString& Name, bool bOriginal)
{
EValidatorResult Result = FStringSetNameValidator::IsValid(Name, bOriginal);
if (Result != EValidatorResult::ExistingName && FInputEditorModule::IsMappingNameInUse(FName(Name)))
{
Result = EValidatorResult::AlreadyInUse;
}
return Result;
}