RealtimeStyleTransferRuntime/Source/LyraGame/Settings/CustomSettings/LyraSettingKeyboardInput.h

76 lines
2.0 KiB
C
Raw Permalink Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "EnhancedActionKeyMapping.h"
2022-09-13 07:18:28 +00:00
#include "GameSettingValue.h"
#include "HAL/Platform.h"
#include "InputCoreTypes.h"
#include "Internationalization/Text.h"
#include "UObject/UObjectGlobals.h"
2022-05-23 18:41:30 +00:00
#include "LyraSettingKeyboardInput.generated.h"
2022-09-13 07:18:28 +00:00
class UObject;
2022-05-23 18:41:30 +00:00
//--------------------------------------
// ULyraSettingKeyboardInput
//--------------------------------------
class UPlayerMappableInputConfig;
struct FKeyboardOption
{
FKeyboardOption() = default;
FEnhancedActionKeyMapping InputMapping {};
const UPlayerMappableInputConfig* OwningConfig = nullptr;
void ResetToDefault();
/** Store the currently set FKey that this is bound to */
void SetInitialValue(FKey InKey);
/** Get the most recently stored initial value */
FKey GetInitialStoredValue() const { return InitialMapping; };
private:
/** The key that this option is bound to initially, used in case the user wants to cancel their mapping */
FKey InitialMapping;
};
UCLASS()
class ULyraSettingKeyboardInput : public UGameSettingValue
{
GENERATED_BODY()
public:
ULyraSettingKeyboardInput();
/** Initalize this setting widget based off the given mapping */
void SetInputData(FEnhancedActionKeyMapping& BaseMapping, const UPlayerMappableInputConfig* InOwningConfig, int32 InKeyBindSlot);
FText GetPrimaryKeyText() const;
FText GetSecondaryKeyText() const;
virtual void StoreInitial() override;
virtual void ResetToDefault() override;
virtual void RestoreToInitial() override;
bool ChangeBinding(int32 InKeyBindSlot, FKey NewKey);
2022-09-13 07:18:28 +00:00
void GetAllMappedActionsFromKey(int32 InKeyBindSlot, FKey Key, TArray<FName>& OutActionNames) const;
2022-05-23 18:41:30 +00:00
FText GetSettingDisplayName() const { return FirstMappableOption.InputMapping.PlayerMappableOptions.DisplayName; }
protected:
/** ULyraSetting */
virtual void OnInitialized() override;
protected:
FKeyboardOption FirstMappableOption;
FKeyboardOption SecondaryMappableOption;
};