lyra_game_ue/Source/LyraGame/UI/Common/LyraBoundActionButton.cpp
Goran Lazarevski 3bcab085f8 Initial commit
2025-03-20 11:06:26 +01:00

46 lines
965 B
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "LyraBoundActionButton.h"
#include "CommonInputSubsystem.h"
#include "CommonInputTypeEnum.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(LyraBoundActionButton)
class UCommonButtonStyle;
void ULyraBoundActionButton::NativeConstruct()
{
Super::NativeConstruct();
if (UCommonInputSubsystem* InputSubsystem = GetInputSubsystem())
{
InputSubsystem->OnInputMethodChangedNative.AddUObject(this, &ThisClass::HandleInputMethodChanged);
HandleInputMethodChanged(InputSubsystem->GetCurrentInputType());
}
}
void ULyraBoundActionButton::HandleInputMethodChanged(ECommonInputType NewInputMethod)
{
TSubclassOf<UCommonButtonStyle> NewStyle = nullptr;
if (NewInputMethod == ECommonInputType::Gamepad)
{
NewStyle = GamepadStyle;
}
else if (NewInputMethod == ECommonInputType::Touch)
{
NewStyle = TouchStyle;
}
else
{
NewStyle = KeyboardStyle;
}
if (NewStyle)
{
SetStyle(NewStyle);
}
}