mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 00:01:37 -07: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;
|
||||
bHasWidget = true;
|
||||
bIsWidgetVisible = true;
|
||||
ActorClasses = { AActor::StaticClass(), ACharacter::StaticClass() };
|
||||
|
||||
Config = GetConfig<UCogEngineConfig_Selection>();
|
||||
|
||||
Asset = GetAsset<UCogEngineDataAsset>();
|
||||
|
||||
FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand(
|
||||
*ToggleSelectionModeCommand,
|
||||
TEXT("Toggle the actor selection mode"),
|
||||
@@ -108,9 +109,10 @@ void FCogEngineWindow_Selection::TryReapplySelection() const
|
||||
TSubclassOf<AActor> FCogEngineWindow_Selection::GetSelectedActorClass() const
|
||||
{
|
||||
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;
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
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 "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<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 "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<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:
|
||||
|
||||
virtual void TryReapplySelection() const;
|
||||
@@ -55,9 +48,13 @@ protected:
|
||||
|
||||
virtual void RenderActorContextMenu(AActor& Actor);
|
||||
|
||||
virtual const TArray<TSubclassOf<AActor>>& GetSelectionFilters() const;
|
||||
|
||||
virtual ETraceTypeQuery GetSelectionTraceChannel() const;
|
||||
|
||||
TSubclassOf<AActor> GetSelectedActorClass() const;
|
||||
|
||||
void TickSelectionMode();
|
||||
bool TickSelectionMode();
|
||||
|
||||
FVector LastSelectedActorLocation = FVector::ZeroVector;
|
||||
|
||||
@@ -65,13 +62,11 @@ protected:
|
||||
|
||||
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");
|
||||
|
||||
FCogEngineWindow_Selection* SelectionWindow = 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_Selection>("Engine.Selection");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Scalability>("Engine.Scalability");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user