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:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "CogDebugDrawHelper.h"
|
||||
#include "CogDebugSettings.h"
|
||||
#include "CogEngineDataAsset.h"
|
||||
#include "CogImGuiHelper.h"
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
@@ -368,7 +369,7 @@ void UCogEngineWindow_Collisions::RenderContent()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Collisions::SetCollisionsAsset(const UCogEngineDataAsset_Collisions* Asset)
|
||||
void UCogEngineWindow_Collisions::SetAsset(const UCogEngineDataAsset* Asset)
|
||||
{
|
||||
if (Asset == nullptr)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "CogEngineWindow_Spawns.h"
|
||||
|
||||
#include "CogEngineDataAsset.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogEngineWindow_Spawns::RenderHelp()
|
||||
{
|
||||
|
||||
+21
-3
@@ -2,7 +2,20 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "CogEngineDataAsset_Spawns.generated.h"
|
||||
#include "CogEngineDataAsset.generated.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
USTRUCT()
|
||||
struct COGENGINE_API FCogCollisionChannel
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TEnumAsByte<ECollisionChannel> Channel = ECollisionChannel::ECC_WorldStatic;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FLinearColor Color = FLinearColor(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
USTRUCT()
|
||||
@@ -35,12 +48,17 @@ struct COGENGINE_API FCogEngineSpawnGroup
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(Blueprintable)
|
||||
class COGENGINE_API UCogEngineDataAsset_Spawns : public UPrimaryDataAsset
|
||||
class COGENGINE_API UCogEngineDataAsset : public UPrimaryDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditAnywhere, meta = (TitleProperty = "Name"))
|
||||
UCogEngineDataAsset() {}
|
||||
|
||||
UPROPERTY(Category = "Spawns", EditAnywhere, meta = (TitleProperty = "Name"))
|
||||
TArray<FCogEngineSpawnGroup> SpawnGroups;
|
||||
|
||||
UPROPERTY(Category = "Collisions", EditAnywhere, meta = (TitleProperty = "Channel"))
|
||||
TArray<FCogCollisionChannel> Channels;
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "CogEngineDataAsset_Collisions.generated.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
USTRUCT()
|
||||
struct COGENGINE_API FCogCollisionChannel
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TEnumAsByte<ECollisionChannel> Channel = ECollisionChannel::ECC_WorldStatic;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FLinearColor Color = FLinearColor(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(Blueprintable)
|
||||
class COGENGINE_API UCogEngineDataAsset_Collisions : public UPrimaryDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UCogEngineDataAsset_Collisions() {}
|
||||
|
||||
UPROPERTY(EditAnywhere, meta = (TitleProperty = "Channel"))
|
||||
TArray<FCogCollisionChannel> Channels;
|
||||
};
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
|
||||
UCogEngineWindow_Collisions();
|
||||
|
||||
void SetCollisionsAsset(const UCogEngineDataAsset_Collisions* Asset);
|
||||
void SetAsset(const UCogEngineDataAsset* Asset);
|
||||
|
||||
private:
|
||||
|
||||
@@ -29,7 +29,7 @@ private:
|
||||
FColor Color;
|
||||
};
|
||||
|
||||
TWeakObjectPtr<UCogEngineDataAsset_Collisions> CollisionsAsset;
|
||||
TWeakObjectPtr<UCogEngineDataAsset> CollisionsAsset;
|
||||
|
||||
FChannel Channels[ECC_MAX];
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "CogWindow.h"
|
||||
#include "CogEngineWindow_Spawns.generated.h"
|
||||
|
||||
class UCogEngineDataAsset_Spawns;
|
||||
class UCogEngineDataAsset;
|
||||
struct FCogEngineSpawnGroup;
|
||||
|
||||
UCLASS()
|
||||
@@ -14,9 +14,9 @@ class COGENGINE_API UCogEngineWindow_Spawns : public UCogWindow
|
||||
|
||||
public:
|
||||
|
||||
const UCogEngineDataAsset_Spawns* GetSpawnsAsset() const { return SpawnAsset; }
|
||||
const UCogEngineDataAsset* GetSpawnsAsset() const { return SpawnAsset; }
|
||||
|
||||
void SetSpawnsAsset(const UCogEngineDataAsset_Spawns* Value) { SpawnAsset = Value; }
|
||||
void SetAsset(const UCogEngineDataAsset* Value) { SpawnAsset = Value; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -30,5 +30,5 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
const UCogEngineDataAsset_Spawns* SpawnAsset = nullptr;
|
||||
const UCogEngineDataAsset* SpawnAsset = nullptr;
|
||||
};
|
||||
|
||||
@@ -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