搬了lyra的hudlayout
This commit is contained in:
52
Source/TG_ARPG/Private/TGCommonActivatableWidget.cpp
Normal file
52
Source/TG_ARPG/Private/TGCommonActivatableWidget.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "TGCommonActivatableWidget.h"
|
||||
#include "Editor/WidgetCompilerLog.h"
|
||||
#include UE_INLINE_GENERATED_CPP_BY_NAME(TGCommonActivatableWidget)
|
||||
|
||||
#define LOCTEXT_NAMESPACE "Lyra"
|
||||
|
||||
UTGCommonActivatableWidget::UTGCommonActivatableWidget(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
}
|
||||
TOptional<FUIInputConfig> UTGCommonActivatableWidget::GetDesiredInputConfig() const
|
||||
{
|
||||
switch (InputConfig)
|
||||
{
|
||||
case ELyraWidgetInputMode::GameAndMenu:
|
||||
return FUIInputConfig(ECommonInputMode::All, GameMouseCaptureMode);
|
||||
case ELyraWidgetInputMode::Game:
|
||||
return FUIInputConfig(ECommonInputMode::Game, GameMouseCaptureMode);
|
||||
case ELyraWidgetInputMode::Menu:
|
||||
return FUIInputConfig(ECommonInputMode::Menu, EMouseCaptureMode::NoCapture);
|
||||
case ELyraWidgetInputMode::Default:
|
||||
default:
|
||||
return TOptional<FUIInputConfig>();
|
||||
}
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
|
||||
void UTGCommonActivatableWidget::ValidateCompiledWidgetTree(const UWidgetTree& BlueprintWidgetTree, class IWidgetCompilerLog& CompileLog) const
|
||||
{
|
||||
Super::ValidateCompiledWidgetTree(BlueprintWidgetTree, CompileLog);
|
||||
|
||||
if (!GetClass()->IsFunctionImplementedInScript(GET_FUNCTION_NAME_CHECKED(UTGCommonActivatableWidget, BP_GetDesiredFocusTarget)))
|
||||
{
|
||||
if (GetParentNativeClass(GetClass()) == UTGCommonActivatableWidget::StaticClass())
|
||||
{
|
||||
CompileLog.Warning(LOCTEXT("ValidateGetDesiredFocusTarget_Warning", "GetDesiredFocusTarget wasn't implemented, you're going to have trouble using gamepads on this screen."));
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO - Note for now, because we can't guarantee it isn't implemented in a native subclass of this one.
|
||||
CompileLog.Note(LOCTEXT("ValidateGetDesiredFocusTarget_Note", "GetDesiredFocusTarget wasn't implemented, you're going to have trouble using gamepads on this screen. If it was implemented in the native base class you can ignore this message."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
36
Source/TG_ARPG/Private/TGHUDLayout.cpp
Normal file
36
Source/TG_ARPG/Private/TGHUDLayout.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "TGHUDLayout.h"
|
||||
|
||||
#include "Input/CommonUIInputTypes.h"
|
||||
#include "CommonUIExtensions.h"
|
||||
#include "NativeGameplayTags.h"
|
||||
#include "TGCommonActivatableWidget.h"
|
||||
|
||||
#include UE_INLINE_GENERATED_CPP_BY_NAME(TGHUDLayout)
|
||||
|
||||
UE_DEFINE_GAMEPLAY_TAG_STATIC(TAG_UI_LAYER_MENU, "UI.Layer.Menu");
|
||||
UE_DEFINE_GAMEPLAY_TAG_STATIC(TAG_UI_ACTION_ESCAPE, "UI.Action.Escape");
|
||||
|
||||
|
||||
UTGHUDLayout::UTGHUDLayout(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
}
|
||||
|
||||
void UTGHUDLayout::NativeOnInitialized()
|
||||
{
|
||||
Super::NativeOnInitialized();
|
||||
RegisterUIActionBinding(FBindUIActionArgs(FUIActionTag::ConvertChecked(TAG_UI_ACTION_ESCAPE), false, FSimpleDelegate::CreateUObject(this, &ThisClass::HandleEscapeAction)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void UTGHUDLayout::HandleEscapeAction()
|
||||
{
|
||||
if (ensure(!EscapeMenuClass.IsNull()))
|
||||
{
|
||||
UCommonUIExtensions::PushStreamedContentToLayer_ForPlayer(GetOwningLocalPlayer(), TAG_UI_LAYER_MENU, EscapeMenuClass);
|
||||
}
|
||||
}
|
||||
50
Source/TG_ARPG/Public/TGCommonActivatableWidget.h
Normal file
50
Source/TG_ARPG/Public/TGCommonActivatableWidget.h
Normal file
@@ -0,0 +1,50 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CommonActivatableWidget.h"
|
||||
#include "TGCommonActivatableWidget.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
struct FUIInputConfig;
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class ELyraWidgetInputMode : uint8
|
||||
{
|
||||
Default,
|
||||
GameAndMenu,
|
||||
Game,
|
||||
Menu
|
||||
};
|
||||
|
||||
|
||||
UCLASS(Abstract, Blueprintable)
|
||||
class TG_ARPG_API UTGCommonActivatableWidget : public UCommonActivatableWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UTGCommonActivatableWidget(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
public:
|
||||
|
||||
//~UCommonActivatableWidget interface
|
||||
virtual TOptional<FUIInputConfig> GetDesiredInputConfig() const override;
|
||||
//~End of UCommonActivatableWidget interface
|
||||
|
||||
#if WITH_EDITOR
|
||||
virtual void ValidateCompiledWidgetTree(const UWidgetTree& BlueprintWidgetTree, class IWidgetCompilerLog& CompileLog) const override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
/** The desired input mode to use while this UI is activated, for example do you want key presses to still reach the game/player controller? */
|
||||
UPROPERTY(EditDefaultsOnly, Category = Input)
|
||||
ELyraWidgetInputMode InputConfig = ELyraWidgetInputMode::Default;
|
||||
|
||||
/** The desired mouse behavior when the game gets input. */
|
||||
UPROPERTY(EditDefaultsOnly, Category = Input)
|
||||
EMouseCaptureMode GameMouseCaptureMode = EMouseCaptureMode::CapturePermanently;
|
||||
};
|
||||
|
||||
29
Source/TG_ARPG/Public/TGHUDLayout.h
Normal file
29
Source/TG_ARPG/Public/TGHUDLayout.h
Normal file
@@ -0,0 +1,29 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "TGCommonActivatableWidget.h"
|
||||
#include "TGHUDLayout.generated.h"
|
||||
|
||||
|
||||
class UCommonActivatableWidget;
|
||||
class UObject;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(Abstract, BlueprintType, Blueprintable, Meta = (DisplayName = "TenGen HUD Layout", Category = "TenGen|HUD"))
|
||||
class TG_ARPG_API UTGHUDLayout : public UTGCommonActivatableWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UTGHUDLayout(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
void NativeOnInitialized() override;
|
||||
|
||||
protected:
|
||||
void HandleEscapeAction();
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TSoftClassPtr<UCommonActivatableWidget> EscapeMenuClass;
|
||||
};
|
||||
@@ -8,7 +8,7 @@ public class TG_ARPG : ModuleRules
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "EnhancedInput","GameplayAbilities", "GameplayTags", "GameplayTasks" });
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "EnhancedInput","GameplayAbilities", "GameplayTags", "GameplayTasks", "CommonUI" ,"UMG","CommonGame"});
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user