mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-05 15:18:47 +00:00
Remove the Selection window runtime setter for the raycast. Replace it with settings defined in the CogEngine asset.
This commit is contained in:
Binary file not shown.
@@ -28,10 +28,11 @@ void FCogEngineWindow_Selection::Initialize()
|
|||||||
bHasMenu = true;
|
bHasMenu = true;
|
||||||
bHasWidget = true;
|
bHasWidget = true;
|
||||||
bIsWidgetVisible = true;
|
bIsWidgetVisible = true;
|
||||||
ActorClasses = { AActor::StaticClass(), ACharacter::StaticClass() };
|
|
||||||
|
|
||||||
Config = GetConfig<UCogEngineConfig_Selection>();
|
Config = GetConfig<UCogEngineConfig_Selection>();
|
||||||
|
|
||||||
|
Asset = GetAsset<UCogEngineDataAsset>();
|
||||||
|
|
||||||
FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand(
|
FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand(
|
||||||
*ToggleSelectionModeCommand,
|
*ToggleSelectionModeCommand,
|
||||||
TEXT("Toggle the actor selection mode"),
|
TEXT("Toggle the actor selection mode"),
|
||||||
@@ -108,9 +109,10 @@ void FCogEngineWindow_Selection::TryReapplySelection() const
|
|||||||
TSubclassOf<AActor> FCogEngineWindow_Selection::GetSelectedActorClass() const
|
TSubclassOf<AActor> FCogEngineWindow_Selection::GetSelectedActorClass() const
|
||||||
{
|
{
|
||||||
TSubclassOf<AActor> SelectedClass = AActor::StaticClass();
|
TSubclassOf<AActor> SelectedClass = AActor::StaticClass();
|
||||||
if (ActorClasses.IsValidIndex(Config->SelectedClassIndex))
|
const TArray<TSubclassOf<AActor>>& SelectionFilters = GetSelectionFilters();
|
||||||
|
if (SelectionFilters.IsValidIndex(Config->SelectedClassIndex))
|
||||||
{
|
{
|
||||||
SelectedClass = ActorClasses[Config->SelectedClassIndex];
|
SelectedClass = SelectionFilters[Config->SelectedClassIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
return SelectedClass;
|
return SelectedClass;
|
||||||
@@ -134,7 +136,10 @@ void FCogEngineWindow_Selection::RenderTick(float DeltaTime)
|
|||||||
|
|
||||||
if (GetOwner()->GetActivateSelectionMode())
|
if (GetOwner()->GetActivateSelectionMode())
|
||||||
{
|
{
|
||||||
TickSelectionMode();
|
if (TickSelectionMode() == false)
|
||||||
|
{
|
||||||
|
GetOwner()->SetActivateSelectionMode(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const AActor* Actor = GetSelection())
|
if (const AActor* Actor = GetSelection())
|
||||||
@@ -185,7 +190,7 @@ void FCogEngineWindow_Selection::RenderContent()
|
|||||||
bool FCogEngineWindow_Selection::DrawSelectionCombo()
|
bool FCogEngineWindow_Selection::DrawSelectionCombo()
|
||||||
{
|
{
|
||||||
AActor* NewSelection = nullptr;
|
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)
|
if (result)
|
||||||
{
|
{
|
||||||
SetGlobalSelection(NewSelection);
|
SetGlobalSelection(NewSelection);
|
||||||
@@ -195,26 +200,18 @@ bool FCogEngineWindow_Selection::DrawSelectionCombo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void FCogEngineWindow_Selection::TickSelectionMode()
|
bool FCogEngineWindow_Selection::TickSelectionMode()
|
||||||
{
|
{
|
||||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||||
{
|
{ return false; }
|
||||||
GetOwner()->SetActivateSelectionMode(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
APlayerController* PlayerController = GetLocalPlayerController();
|
APlayerController* PlayerController = GetLocalPlayerController();
|
||||||
if (PlayerController == nullptr)
|
if (PlayerController == nullptr)
|
||||||
{
|
{ return false; }
|
||||||
GetOwner()->SetActivateSelectionMode(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGuiViewport* Viewport = ImGui::GetMainViewport();
|
ImGuiViewport* Viewport = ImGui::GetMainViewport();
|
||||||
if (Viewport == nullptr)
|
if (Viewport == nullptr)
|
||||||
{
|
{ return false; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ImVec2 ViewportPos = Viewport->Pos;
|
const ImVec2 ViewportPos = Viewport->Pos;
|
||||||
const ImVec2 ViewportSize = Viewport->Size;
|
const ImVec2 ViewportSize = Viewport->Size;
|
||||||
@@ -245,7 +242,7 @@ void FCogEngineWindow_Selection::TickSelectionMode()
|
|||||||
FHitResult HitResult;
|
FHitResult HitResult;
|
||||||
for (int i = 0; i < 2; ++i)
|
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))
|
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",
|
"MenuActorSelection",
|
||||||
NewSelection,
|
NewSelection,
|
||||||
*GetWorld(),
|
*GetWorld(),
|
||||||
ActorClasses,
|
GetSelectionFilters(),
|
||||||
Config->SelectedClassIndex,
|
Config->SelectedClassIndex,
|
||||||
&Filter,
|
&Filter,
|
||||||
GetLocalPlayerPawn(),
|
GetLocalPlayerPawn(),
|
||||||
@@ -344,3 +343,22 @@ void FCogEngineWindow_Selection::RenderPickButtonTooltip()
|
|||||||
FCogWindowWidgets::EndItemTooltipWrappedText();
|
FCogWindowWidgets::EndItemTooltipWrappedText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
const TArray<TSubclassOf<AActor>>& FCogEngineWindow_Selection::GetSelectionFilters() const
|
||||||
|
{
|
||||||
|
if (Asset != nullptr)
|
||||||
|
{ return Asset->SelectionFilters; }
|
||||||
|
|
||||||
|
static TArray<TSubclassOf<AActor>> 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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Engine/DataAsset.h"
|
#include "Engine/DataAsset.h"
|
||||||
#include "Engine/EngineTypes.h"
|
#include "Engine/EngineTypes.h"
|
||||||
|
#include "GameFramework/Character.h"
|
||||||
|
#include "GameFramework/GameModeBase.h"
|
||||||
|
#include "GameFramework/GameStateBase.h"
|
||||||
#include "CogEngineDataAsset.generated.h"
|
#include "CogEngineDataAsset.generated.h"
|
||||||
|
|
||||||
class FCogWindow;
|
class FCogWindow;
|
||||||
@@ -111,4 +114,10 @@ public:
|
|||||||
|
|
||||||
UPROPERTY(Category = "Spawns", EditAnywhere, meta = (TitleProperty = "Name"))
|
UPROPERTY(Category = "Spawns", EditAnywhere, meta = (TitleProperty = "Name"))
|
||||||
TArray<FCogEngineSpawnGroup> SpawnGroups;
|
TArray<FCogEngineSpawnGroup> SpawnGroups;
|
||||||
|
|
||||||
|
UPROPERTY(Category = "Selection", EditAnywhere)
|
||||||
|
TArray<TSubclassOf<AActor>> SelectionFilters = { ACharacter::StaticClass(), AActor::StaticClass(), AGameModeBase::StaticClass(), AGameStateBase::StaticClass() };
|
||||||
|
|
||||||
|
UPROPERTY(Category = "Selection", EditAnywhere)
|
||||||
|
TEnumAsByte<ETraceTypeQuery> SelectionTraceChannel = UEngineTypes::ConvertToTraceType(ECC_Pawn);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "CogCommonConfig.h"
|
#include "CogCommonConfig.h"
|
||||||
|
#include "CogEngineDataAsset.h"
|
||||||
#include "GameFramework/Actor.h"
|
#include "GameFramework/Actor.h"
|
||||||
#include "CogWindow.h"
|
#include "CogWindow.h"
|
||||||
#include "CogEngineWindow_Selection.generated.h"
|
#include "CogEngineWindow_Selection.generated.h"
|
||||||
@@ -23,14 +24,6 @@ public:
|
|||||||
|
|
||||||
virtual void Shutdown() override;
|
virtual void Shutdown() override;
|
||||||
|
|
||||||
const TArray<TSubclassOf<AActor>>& GetActorClasses() const { return ActorClasses; }
|
|
||||||
|
|
||||||
void SetActorClasses(const TArray<TSubclassOf<AActor>>& Value) { ActorClasses = Value; }
|
|
||||||
|
|
||||||
ETraceTypeQuery GetTraceType() const { return TraceType; }
|
|
||||||
|
|
||||||
void SetTraceType(ETraceTypeQuery Value) { TraceType = Value; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void TryReapplySelection() const;
|
virtual void TryReapplySelection() const;
|
||||||
@@ -55,9 +48,13 @@ protected:
|
|||||||
|
|
||||||
virtual void RenderActorContextMenu(AActor& Actor);
|
virtual void RenderActorContextMenu(AActor& Actor);
|
||||||
|
|
||||||
|
virtual const TArray<TSubclassOf<AActor>>& GetSelectionFilters() const;
|
||||||
|
|
||||||
|
virtual ETraceTypeQuery GetSelectionTraceChannel() const;
|
||||||
|
|
||||||
TSubclassOf<AActor> GetSelectedActorClass() const;
|
TSubclassOf<AActor> GetSelectedActorClass() const;
|
||||||
|
|
||||||
void TickSelectionMode();
|
bool TickSelectionMode();
|
||||||
|
|
||||||
FVector LastSelectedActorLocation = FVector::ZeroVector;
|
FVector LastSelectedActorLocation = FVector::ZeroVector;
|
||||||
|
|
||||||
@@ -65,13 +62,11 @@ protected:
|
|||||||
|
|
||||||
int32 WaitInputReleased = 0;
|
int32 WaitInputReleased = 0;
|
||||||
|
|
||||||
TArray<TSubclassOf<AActor>> ActorClasses;
|
TWeakObjectPtr<UCogEngineConfig_Selection> Config;
|
||||||
|
|
||||||
ETraceTypeQuery TraceType = TraceTypeQuery1;
|
TWeakObjectPtr<const UCogEngineDataAsset> Asset;
|
||||||
|
|
||||||
TObjectPtr<UCogEngineConfig_Selection> Config;
|
ImGuiTextFilter Filter;
|
||||||
|
|
||||||
ImGuiTextFilter Filter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -82,9 +82,7 @@ void Cog::AddAllWindows(UCogWindowManager& CogWindowManager)
|
|||||||
|
|
||||||
CogWindowManager.AddWindow<FCogEngineWindow_Plots>("Engine.Plots");
|
CogWindowManager.AddWindow<FCogEngineWindow_Plots>("Engine.Plots");
|
||||||
|
|
||||||
FCogEngineWindow_Selection* SelectionWindow = CogWindowManager.AddWindow<FCogEngineWindow_Selection>("Engine.Selection");
|
CogWindowManager.AddWindow<FCogEngineWindow_Selection>("Engine.Selection");
|
||||||
SelectionWindow->SetActorClasses({ ACharacter::StaticClass(), AActor::StaticClass(), AGameModeBase::StaticClass(), AGameStateBase::StaticClass() });
|
|
||||||
SelectionWindow->SetTraceType(UEngineTypes::ConvertToTraceType(ECC_Pawn));
|
|
||||||
|
|
||||||
CogWindowManager.AddWindow<FCogEngineWindow_Scalability>("Engine.Scalability");
|
CogWindowManager.AddWindow<FCogEngineWindow_Scalability>("Engine.Scalability");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user