Skip to content
Snippets Groups Projects
Commit 53c84a3f authored by Timon Römer's avatar Timon Römer
Browse files

Refactors IntenSelectable Component

parent 0ab1f9ce
No related branches found
No related tags found
1 merge request!85UE5.3-2023.1-rc3
......@@ -6,6 +6,7 @@
#include "Kismet/KismetSystemLibrary.h"
#include "Misc/MessageDialog.h"
#include "Pawn/IntenSelectComponent.h"
#include "Utility/RWTHVRUtilities.h"
UIntenSelectable::UIntenSelectable() { PrimaryComponentTick.bCanEverTick = true; }
......@@ -45,8 +46,9 @@ void UIntenSelectable::BeginPlay()
{
if (ScoringBehaviours.Num() == 0)
{
ShowErrorAndQuit(
"Please assign the Scoring Behaviour manually when using more than one IntenSelectable Component!");
URWTHVRUtilities::ShowErrorAndQuit(
"Please assign the Scoring Behaviour manually when using more than one IntenSelectable Component!",
false, this);
}
}
else
......@@ -57,36 +59,36 @@ void UIntenSelectable::BeginPlay()
void UIntenSelectable::HandleOnSelectStartEvents(const UIntenSelectComponent* IntenSelect, const FHitResult& HitResult)
{
for (const UHoverBehaviour* b : OnSelectBehaviours)
for (const UHoverBehaviour* CurrentHoverBehaviour : OnHoverBehaviours)
{
b->OnHoverStartEvent.Broadcast(IntenSelect, HitResult);
CurrentHoverBehaviour->OnHoverStartEvent.Broadcast(IntenSelect, HitResult);
}
}
void UIntenSelectable::HandleOnSelectEndEvents(const UIntenSelectComponent* IntenSelect)
{
for (const UHoverBehaviour* b : OnSelectBehaviours)
for (const UHoverBehaviour* CurrentHoverBehaviour : OnHoverBehaviours)
{
b->OnHoverEndEvent.Broadcast(IntenSelect);
CurrentHoverBehaviour->OnHoverEndEvent.Broadcast(IntenSelect);
}
}
void UIntenSelectable::HandleOnClickStartEvents(UIntenSelectComponent* IntenSelect)
{
for (const UActionBehaviour* b : OnClickBehaviours)
for (const UActionBehaviour* CurrentActionBehaviour : OnActionBehaviours)
{
FInputActionValue v{};
const UInputAction* a{};
b->OnActionBeginEvent.Broadcast(IntenSelect, a, v);
FInputActionValue EmptyInputActionValue{};
const UInputAction* EmptyInputAction{};
CurrentActionBehaviour->OnActionBeginEvent.Broadcast(IntenSelect, EmptyInputAction, EmptyInputActionValue);
}
}
void UIntenSelectable::HandleOnClickEndEvents(UIntenSelectComponent* IntenSelect, FInputActionValue& InputValue)
{
for (const UActionBehaviour* b : OnClickBehaviours)
for (const UActionBehaviour* CurrentActionBehaviour : OnActionBehaviours)
{
const UInputAction* a{};
b->OnActionEndEvent.Broadcast(IntenSelect, a, InputValue);
const UInputAction* EmptyInputActionValue{};
CurrentActionBehaviour->OnActionEndEvent.Broadcast(IntenSelect, EmptyInputActionValue, InputValue);
}
}
......@@ -114,23 +116,14 @@ void UIntenSelectable::InitDefaultBehaviourReferences()
}
// Selecting
TInlineComponentArray<UHoverBehaviour*> AttachedSelectionBehaviours;
GetOwner()->GetComponents(AttachedSelectionBehaviours, true);
TInlineComponentArray<UHoverBehaviour*> AttachedHoverBehaviours;
GetOwner()->GetComponents(AttachedHoverBehaviours, true);
this->OnSelectBehaviours = AttachedSelectionBehaviours;
OnHoverBehaviours = AttachedHoverBehaviours;
// Clicking
TInlineComponentArray<UActionBehaviour*> AttachedClickBehaviours;
GetOwner()->GetComponents(AttachedClickBehaviours, true);
this->OnClickBehaviours = AttachedClickBehaviours;
}
void UIntenSelectable::ShowErrorAndQuit(const FString& Message) const
{
UE_LOG(LogTemp, Error, TEXT("%s"), *Message)
#if WITH_EDITOR
FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(FString("RUNTIME ERROR")));
#endif
UKismetSystemLibrary::QuitGame(this, nullptr, EQuitPreference::Quit, false);
OnActionBehaviours = AttachedClickBehaviours;
}
\ No newline at end of file
......@@ -20,10 +20,7 @@
DEFINE_LOG_CATEGORY(Toolkit);
bool URWTHVRUtilities::IsDesktopMode()
{
return !IsRoomMountedMode() && !IsHeadMountedMode();
}
bool URWTHVRUtilities::IsDesktopMode() { return !IsRoomMountedMode() && !IsHeadMountedMode(); }
bool URWTHVRUtilities::IsRoomMountedMode()
{
......@@ -48,8 +45,8 @@ bool URWTHVRUtilities::IsCave()
return false;
const UDisplayClusterConfigurationData* ClusterConfig = IDisplayCluster::Get().GetConfigMgr()->GetConfig();
return ClusterConfig->CustomParameters.Contains("Hardware_Platform")
&& ClusterConfig->CustomParameters.Find("Hardware_Platform")->Equals("aixcave", ESearchCase::IgnoreCase);
return ClusterConfig->CustomParameters.Contains("Hardware_Platform") &&
ClusterConfig->CustomParameters.Find("Hardware_Platform")->Equals("aixcave", ESearchCase::IgnoreCase);
#else
return false;
#endif
......@@ -62,8 +59,8 @@ bool URWTHVRUtilities::IsRolv()
return false;
const UDisplayClusterConfigurationData* ClusterConfig = IDisplayCluster::Get().GetConfigMgr()->GetConfig();
return ClusterConfig->CustomParameters.Contains("Hardware_Platform")
&& ClusterConfig->CustomParameters.Find("Hardware_Platform")->Equals("ROLV", ESearchCase::IgnoreCase);
return ClusterConfig->CustomParameters.Contains("Hardware_Platform") &&
ClusterConfig->CustomParameters.Find("Hardware_Platform")->Equals("ROLV", ESearchCase::IgnoreCase);
#else
return false;
#endif
......@@ -88,10 +85,7 @@ bool URWTHVRUtilities::IsPrimaryNode()
#endif
}
bool URWTHVRUtilities::IsSecondaryNode()
{
return !IsPrimaryNode();
}
bool URWTHVRUtilities::IsSecondaryNode() { return !IsPrimaryNode(); }
FString URWTHVRUtilities::GetNodeName()
{
......@@ -123,13 +117,23 @@ EEyeStereoOffset URWTHVRUtilities::GetNodeEyeType()
{
#if PLATFORM_SUPPORTS_NDISPLAY
const ADisplayClusterRootActor* RootActor = IDisplayCluster::Get().GetGameMgr()->GetRootActor();
return static_cast<EEyeStereoOffset>((RootActor)
? RootActor->GetDefaultCamera()->GetStereoOffset()
return static_cast<EEyeStereoOffset>((RootActor) ? RootActor->GetDefaultCamera()->GetStereoOffset()
: EDisplayClusterEyeStereoOffset::None);
#else
return EDisplayClusterEyeStereoOffset::None;
#endif
}
void URWTHVRUtilities::ShowErrorAndQuit(const FString& Message, bool ShouldQuit, const UObject* WorldContext)
{
UE_LOG(LogTemp, Error, TEXT("%s"), *Message)
#if WITH_EDITOR
FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(Message));
#endif
if (ShouldQuit)
{
UKismetSystemLibrary::QuitGame(WorldContext, nullptr, EQuitPreference::Quit, false);
}
}
USceneComponent* URWTHVRUtilities::GetClusterComponent(const FString& Name)
{
......
......@@ -28,10 +28,10 @@ public:
TArray<UIntenSelectableScoring*> ScoringBehaviours;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<UHoverBehaviour*> OnSelectBehaviours;
TArray<UHoverBehaviour*> OnHoverBehaviours;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<UActionBehaviour*> OnClickBehaviours;
TArray<UActionBehaviour*> OnActionBehaviours;
public:
......@@ -48,8 +48,6 @@ public:
void InitDefaultBehaviourReferences();
void ShowErrorAndQuit(const FString& Message) const;
protected:
virtual void BeginPlay() override;
};
......@@ -70,6 +70,8 @@ public:
UFUNCTION(BlueprintPure, Category = "DisplayCluster")
static EEyeStereoOffset GetNodeEyeType();
static void ShowErrorAndQuit(const FString& Message, bool ShouldQuit, const UObject* WorldContext);
// Get Component of Display Cluster by it's name, which is specified in the nDisplay config
UE_DEPRECATED(5.4, "GetClusterComponent has been removed because it is obsolete.")
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "DisplayCluster", meta = (DeprecatedFunction))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment