mirror of
https://github.com/Ed94/Cog.git
synced 2026-07-28 18:30:04 +00:00
unify data assets
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "CogInputWindow_Actions.h"
|
||||
|
||||
#include "CogInputDataAsset_Actions.h"
|
||||
#include "CogInputDataAsset.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
@@ -15,7 +15,7 @@ void UCogInputWindow_Actions::RenderHelp()
|
||||
"This window displays the current state of each Input Action. "
|
||||
"It can also be used to inject inputs to help debugging. "
|
||||
"The input action are read from a Input Mapping Context defined in '%s' data asset. "
|
||||
, TCHAR_TO_ANSI(*GetNameSafe(ActionsAsset.Get()))
|
||||
, TCHAR_TO_ANSI(*GetNameSafe(Asset.Get()))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ void UCogInputWindow_Actions::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
if (ActionsAsset == nullptr)
|
||||
if (Asset == nullptr)
|
||||
{
|
||||
ImGui::Text("No Actions Asset");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActionsAsset->MappingContext == nullptr)
|
||||
if (Asset->MappingContext == nullptr)
|
||||
{
|
||||
ImGui::Text("No MappingContext");
|
||||
return;
|
||||
@@ -77,7 +77,7 @@ void UCogInputWindow_Actions::RenderContent()
|
||||
|
||||
if (Actions.Num() == 0)
|
||||
{
|
||||
for (const FEnhancedActionKeyMapping& Mapping : ActionsAsset->MappingContext->GetMappings())
|
||||
for (const FEnhancedActionKeyMapping& Mapping : Asset->MappingContext->GetMappings())
|
||||
{
|
||||
if (Mapping.Action != nullptr && Actions.ContainsByPredicate([&Mapping](const FCogInjectActionInfo& ActionInfo) { return Mapping.Action == ActionInfo.Action; }) == false)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CogInputWindow_Gamepad.h"
|
||||
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogInputDataAsset.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "imgui_internal.h"
|
||||
@@ -16,10 +17,10 @@ void UCogInputWindow_Gamepad::PreRender(ImGuiWindowFlags& WindowFlags)
|
||||
if (bShowAsOverlay)
|
||||
{
|
||||
WindowFlags = ImGuiWindowFlags_NoTitleBar
|
||||
| ImGuiWindowFlags_NoScrollbar
|
||||
| ImGuiWindowFlags_NoCollapse
|
||||
| ImGuiWindowFlags_NoBackground
|
||||
| ImGuiWindowFlags_NoResize;
|
||||
| ImGuiWindowFlags_NoScrollbar
|
||||
| ImGuiWindowFlags_NoCollapse
|
||||
| ImGuiWindowFlags_NoBackground
|
||||
| ImGuiWindowFlags_NoResize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +198,7 @@ void UCogInputWindow_Gamepad::RenderContent()
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActionsAsset != nullptr && ActionsAsset->MappingContext != nullptr)
|
||||
if (Asset != nullptr && Asset->MappingContext != nullptr)
|
||||
{
|
||||
if (Actions.Num() == 0)
|
||||
{
|
||||
@@ -228,7 +229,7 @@ void UCogInputWindow_Gamepad::RenderContent()
|
||||
Actions.FindOrAdd(EKeys:: Gamepad_DPad_Right);
|
||||
Actions.FindOrAdd(EKeys:: Gamepad_DPad_Left);
|
||||
|
||||
for (const FEnhancedActionKeyMapping& Mapping : ActionsAsset->MappingContext->GetMappings())
|
||||
for (const FEnhancedActionKeyMapping& Mapping : Asset->MappingContext->GetMappings())
|
||||
{
|
||||
if (Mapping.Action != nullptr)
|
||||
{
|
||||
|
||||
+3
-3
@@ -1,18 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogInputDataAsset_Actions.generated.h"
|
||||
#include "CogInputDataAsset.generated.h"
|
||||
|
||||
class UInputAction;
|
||||
class UInputMappingContext;
|
||||
|
||||
UCLASS(Blueprintable)
|
||||
class COGINPUT_API UCogInputDataAsset_Actions : public UPrimaryDataAsset
|
||||
class COGINPUT_API UCogInputDataAsset : public UPrimaryDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UCogInputDataAsset_Actions() {}
|
||||
UCogInputDataAsset() {}
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TObjectPtr<const UInputMappingContext> MappingContext;
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "CogInputWindow_Actions.generated.h"
|
||||
|
||||
class UInputAction;
|
||||
class UCogInputDataAsset_Actions;
|
||||
class UCogInputDataAsset;
|
||||
|
||||
UCLASS(Config = Cog)
|
||||
class COGINPUT_API UCogInputWindow_Actions : public UCogWindow
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
|
||||
UCogInputWindow_Actions();
|
||||
|
||||
TWeakObjectPtr<UCogInputDataAsset_Actions> ActionsAsset;
|
||||
TWeakObjectPtr<const UCogInputDataAsset> Asset;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "CogInputWindow_Gamepad.generated.h"
|
||||
|
||||
class UEnhancedPlayerInput;
|
||||
class UCogInputDataAsset;
|
||||
struct ImDrawList;
|
||||
|
||||
UCLASS(Config = Cog)
|
||||
@@ -22,13 +23,16 @@ public:
|
||||
|
||||
virtual void RenderTick(float DeltaSeconds) override;
|
||||
|
||||
TWeakObjectPtr<UCogInputDataAsset_Actions> ActionsAsset;
|
||||
TWeakObjectPtr<const UCogInputDataAsset> Asset;
|
||||
|
||||
private:
|
||||
|
||||
void AddButton(const FKey& Key, const ImVec2& Position, const ImVec2& Size, const ImVec2& Alignment, float Rounding, ImDrawFlags Flags = 0);
|
||||
|
||||
void AddStick(const FKey& Key2D, const FKey& KeyBool, bool InvertY, float Amplitude, const ImVec2& Position, float Radius);
|
||||
|
||||
void InputContextMenu(const FKey& Key, FCogInjectActionInfo* ActionInfoBool, FCogInjectActionInfo* ActionInfo2D);
|
||||
|
||||
void OnButtonClicked(FCogInjectActionInfo* ActionInfo);
|
||||
|
||||
UPROPERTY(Config)
|
||||
@@ -61,10 +65,16 @@ private:
|
||||
TMap<FKey, FCogInjectActionInfo> Actions;
|
||||
|
||||
UEnhancedPlayerInput* Input = nullptr;
|
||||
|
||||
ImDrawList* DrawList = nullptr;
|
||||
|
||||
float RepeatPeriod = 0.5f;
|
||||
|
||||
float RepeatTime = 0.0f;
|
||||
|
||||
ImVec2 CanvasMin;
|
||||
|
||||
ImVec2 CanvasSize;
|
||||
|
||||
ImVec2 CanvasMax;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user