2022-05-23 18:41:30 +00:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
#include "Input/LyraMappableConfigPair.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
|
2022-05-23 18:41:30 +00:00
|
|
|
#include "CommonUISettings.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
#include "ICommonUIModule.h"
|
2022-05-23 18:41:30 +00:00
|
|
|
#include "PlayerMappableInputConfig.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
#include "Settings/LyraSettingsLocal.h"
|
|
|
|
#include "System/LyraAssetManager.h"
|
|
|
|
#include "Templates/Casts.h"
|
2022-05-23 18:41:30 +00:00
|
|
|
|
|
|
|
bool FMappableConfigPair::CanBeActivated() const
|
|
|
|
{
|
|
|
|
const FGameplayTagContainer& PlatformTraits = ICommonUIModule::GetSettings().GetPlatformTraits();
|
|
|
|
|
|
|
|
// If the current platform does NOT have all the dependent traits, then don't activate it
|
|
|
|
if (!DependentPlatformTraits.IsEmpty() && !PlatformTraits.HasAll(DependentPlatformTraits))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the platform has any of the excluded traits, then we shouldn't activate this config.
|
|
|
|
if (!ExcludedPlatformTraits.IsEmpty() && PlatformTraits.HasAny(ExcludedPlatformTraits))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FMappableConfigPair::RegisterPair(const FMappableConfigPair& Pair)
|
|
|
|
{
|
|
|
|
ULyraAssetManager& AssetManager = ULyraAssetManager::Get();
|
|
|
|
|
|
|
|
if (ULyraSettingsLocal* Settings = ULyraSettingsLocal::Get())
|
|
|
|
{
|
|
|
|
// Register the pair with the settings, but do not activate it yet
|
|
|
|
if (const UPlayerMappableInputConfig* LoadedConfig = AssetManager.GetAsset(Pair.Config))
|
|
|
|
{
|
|
|
|
Settings->RegisterInputConfig(Pair.Type, LoadedConfig, false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FMappableConfigPair::UnregisterPair(const FMappableConfigPair& Pair)
|
|
|
|
{
|
|
|
|
ULyraAssetManager& AssetManager = ULyraAssetManager::Get();
|
|
|
|
|
|
|
|
if (ULyraSettingsLocal* Settings = ULyraSettingsLocal::Get())
|
|
|
|
{
|
|
|
|
if (const UPlayerMappableInputConfig* LoadedConfig = AssetManager.GetAsset(Pair.Config))
|
|
|
|
{
|
|
|
|
Settings->UnregisterInputConfig(LoadedConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|