diff --git a/Content/Core/Debug/DA_Debug_Engine.uasset b/Content/Core/Debug/DA_Debug_Engine.uasset index 67ca6d2..e7d7dbd 100644 Binary files a/Content/Core/Debug/DA_Debug_Engine.uasset and b/Content/Core/Debug/DA_Debug_Engine.uasset differ diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp index f60ef4f..bba5ab7 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp @@ -28,10 +28,11 @@ void FCogEngineWindow_Selection::Initialize() bHasMenu = true; bHasWidget = true; bIsWidgetVisible = true; - ActorClasses = { AActor::StaticClass(), ACharacter::StaticClass() }; Config = GetConfig(); + Asset = GetAsset(); + FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( *ToggleSelectionModeCommand, TEXT("Toggle the actor selection mode"), @@ -108,9 +109,10 @@ void FCogEngineWindow_Selection::TryReapplySelection() const TSubclassOf FCogEngineWindow_Selection::GetSelectedActorClass() const { TSubclassOf SelectedClass = AActor::StaticClass(); - if (ActorClasses.IsValidIndex(Config->SelectedClassIndex)) + const TArray>& SelectionFilters = GetSelectionFilters(); + if (SelectionFilters.IsValidIndex(Config->SelectedClassIndex)) { - SelectedClass = ActorClasses[Config->SelectedClassIndex]; + SelectedClass = SelectionFilters[Config->SelectedClassIndex]; } return SelectedClass; @@ -134,7 +136,10 @@ void FCogEngineWindow_Selection::RenderTick(float DeltaTime) if (GetOwner()->GetActivateSelectionMode()) { - TickSelectionMode(); + if (TickSelectionMode() == false) + { + GetOwner()->SetActivateSelectionMode(false); + } } if (const AActor* Actor = GetSelection()) @@ -185,7 +190,7 @@ void FCogEngineWindow_Selection::RenderContent() bool FCogEngineWindow_Selection::DrawSelectionCombo() { AActor* NewSelection = nullptr; - const bool result = FCogWindowWidgets::ActorsListWithFilters(NewSelection, *GetWorld(), ActorClasses, Config->SelectedClassIndex, &Filter, GetLocalPlayerPawn()); + const bool result = FCogWindowWidgets::ActorsListWithFilters(NewSelection, *GetWorld(), GetSelectionFilters(), Config->SelectedClassIndex, &Filter, GetLocalPlayerPawn()); if (result) { SetGlobalSelection(NewSelection); @@ -195,26 +200,18 @@ bool FCogEngineWindow_Selection::DrawSelectionCombo() } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Selection::TickSelectionMode() +bool FCogEngineWindow_Selection::TickSelectionMode() { if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) - { - GetOwner()->SetActivateSelectionMode(false); - return; - } + { return false; } APlayerController* PlayerController = GetLocalPlayerController(); if (PlayerController == nullptr) - { - GetOwner()->SetActivateSelectionMode(false); - return; - } + { return false; } ImGuiViewport* Viewport = ImGui::GetMainViewport(); if (Viewport == nullptr) - { - return; - } + { return false; } const ImVec2 ViewportPos = Viewport->Pos; const ImVec2 ViewportSize = Viewport->Size; @@ -245,7 +242,7 @@ void FCogEngineWindow_Selection::TickSelectionMode() FHitResult HitResult; for (int i = 0; i < 2; ++i) { - if (UKismetSystemLibrary::LineTraceSingle(GetWorld(), WorldOrigin, WorldOrigin + WorldDirection * 10000, TraceType, false, IgnoreList, EDrawDebugTrace::None, HitResult, true)) + if (UKismetSystemLibrary::LineTraceSingle(GetWorld(), WorldOrigin, WorldOrigin + WorldDirection * 10000, GetSelectionTraceChannel(), false, IgnoreList, EDrawDebugTrace::None, HitResult, true)) { if (SelectedActorClass == nullptr || HitResult.GetActor()->GetClass()->IsChildOf(SelectedActorClass)) { @@ -285,6 +282,8 @@ void FCogEngineWindow_Selection::TickSelectionMode() } } } + + return true; } //-------------------------------------------------------------------------------------------------------------------------- @@ -311,7 +310,7 @@ void FCogEngineWindow_Selection::RenderMainMenuWidget() "MenuActorSelection", NewSelection, *GetWorld(), - ActorClasses, + GetSelectionFilters(), Config->SelectedClassIndex, &Filter, GetLocalPlayerPawn(), @@ -343,4 +342,23 @@ void FCogEngineWindow_Selection::RenderPickButtonTooltip() "%s", TCHAR_TO_ANSI(*Shortcut)); FCogWindowWidgets::EndItemTooltipWrappedText(); } -} \ No newline at end of file +} + +//-------------------------------------------------------------------------------------------------------------------------- +const TArray>& FCogEngineWindow_Selection::GetSelectionFilters() const +{ + if (Asset != nullptr) + { return Asset->SelectionFilters; } + + static TArray> SelectionFilters = { ACharacter::StaticClass(), AActor::StaticClass(), AGameModeBase::StaticClass(), AGameStateBase::StaticClass() }; + return SelectionFilters; +} + +//-------------------------------------------------------------------------------------------------------------------------- + ETraceTypeQuery FCogEngineWindow_Selection::GetSelectionTraceChannel() const +{ + if (Asset != nullptr) + { return Asset->SelectionTraceChannel; } + + return UEngineTypes::ConvertToTraceType(ECC_Pawn); +} diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineDataAsset.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineDataAsset.h index 14b46fb..9da7bd9 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineDataAsset.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineDataAsset.h @@ -3,6 +3,9 @@ #include "CoreMinimal.h" #include "Engine/DataAsset.h" #include "Engine/EngineTypes.h" +#include "GameFramework/Character.h" +#include "GameFramework/GameModeBase.h" +#include "GameFramework/GameStateBase.h" #include "CogEngineDataAsset.generated.h" class FCogWindow; @@ -111,4 +114,10 @@ public: UPROPERTY(Category = "Spawns", EditAnywhere, meta = (TitleProperty = "Name")) TArray SpawnGroups; + + UPROPERTY(Category = "Selection", EditAnywhere) + TArray> SelectionFilters = { ACharacter::StaticClass(), AActor::StaticClass(), AGameModeBase::StaticClass(), AGameStateBase::StaticClass() }; + + UPROPERTY(Category = "Selection", EditAnywhere) + TEnumAsByte SelectionTraceChannel = UEngineTypes::ConvertToTraceType(ECC_Pawn); }; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h index d478301..81430e7 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h @@ -2,6 +2,7 @@ #include "CoreMinimal.h" #include "CogCommonConfig.h" +#include "CogEngineDataAsset.h" #include "GameFramework/Actor.h" #include "CogWindow.h" #include "CogEngineWindow_Selection.generated.h" @@ -23,14 +24,6 @@ public: virtual void Shutdown() override; - const TArray>& GetActorClasses() const { return ActorClasses; } - - void SetActorClasses(const TArray>& Value) { ActorClasses = Value; } - - ETraceTypeQuery GetTraceType() const { return TraceType; } - - void SetTraceType(ETraceTypeQuery Value) { TraceType = Value; } - protected: virtual void TryReapplySelection() const; @@ -55,9 +48,13 @@ protected: virtual void RenderActorContextMenu(AActor& Actor); + virtual const TArray>& GetSelectionFilters() const; + + virtual ETraceTypeQuery GetSelectionTraceChannel() const; + TSubclassOf GetSelectedActorClass() const; - void TickSelectionMode(); + bool TickSelectionMode(); FVector LastSelectedActorLocation = FVector::ZeroVector; @@ -65,13 +62,11 @@ protected: int32 WaitInputReleased = 0; - TArray> ActorClasses; + TWeakObjectPtr Config; - ETraceTypeQuery TraceType = TraceTypeQuery1; + TWeakObjectPtr Asset; - TObjectPtr Config; - - ImGuiTextFilter Filter; + ImGuiTextFilter Filter; }; //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp b/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp index a796f99..b9733dc 100644 --- a/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp +++ b/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp @@ -82,9 +82,7 @@ void Cog::AddAllWindows(UCogWindowManager& CogWindowManager) CogWindowManager.AddWindow("Engine.Plots"); - FCogEngineWindow_Selection* SelectionWindow = CogWindowManager.AddWindow("Engine.Selection"); - SelectionWindow->SetActorClasses({ ACharacter::StaticClass(), AActor::StaticClass(), AGameModeBase::StaticClass(), AGameStateBase::StaticClass() }); - SelectionWindow->SetTraceType(UEngineTypes::ConvertToTraceType(ECC_Pawn)); + CogWindowManager.AddWindow("Engine.Selection"); CogWindowManager.AddWindow("Engine.Scalability");