From 4ffdfd1fffc93cd559a80445d63c3a7277a283f2 Mon Sep 17 00:00:00 2001 From: Denys Dubinin Date: Sat, 18 Jun 2022 10:32:29 -0400 Subject: [PATCH] [UE-156718] Enable / Disable Behaviours - API support. API support: 1) bIsEnabled boolean flag for URCBehaviour objects 2) SetIsBehaviourEnabled(bool) function in FRCBehaviourModel UI model. 3) IsBehaviourEnabled() function in FRCBehaviourModel UI model. Usage: Invoked SetIsBehaviourEnabled as required on a checkbox (or other appropriate widget) change event. Note: Also includes a minor UI change for storing Behaviour Title Text widget (part of the current Behaviours list panel) as a variable #preflight 62ade0cd26346e9ac5301561 [CL 20717629 by Denys Dubinin in ue5-main branch] --- .../Private/Controller/RCController.cpp | 5 ++- .../Public/Behaviour/RCBehaviour.h | 6 ++++ .../Private/UI/Behaviour/RCBehaviourModel.cpp | 31 ++++++++++++++++--- .../Private/UI/Behaviour/RCBehaviourModel.h | 12 ++++++- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlLogic/Private/Controller/RCController.cpp b/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlLogic/Private/Controller/RCController.cpp index 3e662083bdde..0aafaa3712d6 100644 --- a/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlLogic/Private/Controller/RCController.cpp +++ b/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlLogic/Private/Controller/RCController.cpp @@ -71,6 +71,9 @@ void URCController::ExecuteBehaviours() { for (URCBehaviour* Behaviour : Behaviours) { - Behaviour->Execute(); + if (Behaviour->bIsEnabled) + { + Behaviour->Execute(); + } } } diff --git a/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlLogic/Public/Behaviour/RCBehaviour.h b/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlLogic/Public/Behaviour/RCBehaviour.h index 3f7077d61886..b801781915b0 100644 --- a/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlLogic/Public/Behaviour/RCBehaviour.h +++ b/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlLogic/Public/Behaviour/RCBehaviour.h @@ -100,4 +100,10 @@ private: /** Cached behaviour node */ UPROPERTY(Instanced) TObjectPtr CachedBehaviourNode; + +public: + /** Whether this Behaviour is currently enabled. + * If disabled, it will be not evaluated when the associated Controller changes */ + UPROPERTY() + bool bIsEnabled = true; }; diff --git a/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlUI/Private/UI/Behaviour/RCBehaviourModel.cpp b/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlUI/Private/UI/Behaviour/RCBehaviourModel.cpp index 99ed06981243..e8d9e6e9ec09 100644 --- a/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlUI/Private/UI/Behaviour/RCBehaviourModel.cpp +++ b/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlUI/Private/UI/Behaviour/RCBehaviourModel.cpp @@ -8,12 +8,18 @@ #include "UI/RemoteControlPanelStyle.h" #include "UI/SRemoteControlPanel.h" #include "Widgets/SNullWidget.h" +#include "Widgets/Text/STextBlock.h" #define LOCTEXT_NAMESPACE "FRCBehaviourModel" FRCBehaviourModel::FRCBehaviourModel(URCBehaviour* InBehaviour) : BehaviourWeakPtr(InBehaviour) { + const FText BehaviorDisplayName = BehaviourWeakPtr->GetDisplayName().ToUpper(); + + SAssignNew(BehaviourTitleText, STextBlock) + .Text(BehaviorDisplayName) + .Font(FRemoteControlPanelStyle::Get()->GetFontStyle("RemoteControlPanel.Behaviours.Title")); } TSharedRef FRCBehaviourModel::GetWidget() const @@ -23,8 +29,6 @@ TSharedRef FRCBehaviourModel::GetWidget() const return SNullWidget::NullWidget; } - const FText BehaviorDisplayName = BehaviourWeakPtr->GetDisplayName().ToUpper(); - return SNew(SHorizontalBox) .Clipping(EWidgetClipping::OnDemand) // Behaviour name @@ -33,8 +37,7 @@ TSharedRef FRCBehaviourModel::GetWidget() const .AutoWidth() .Padding(FMargin(8.f)) [ - SNew(STextBlock).Text(BehaviorDisplayName) - .Font(FRemoteControlPanelStyle::Get()->GetFontStyle("RemoteControlPanel.Behaviours.Title")) + BehaviourTitleText.ToSharedRef() ]; } @@ -58,6 +61,26 @@ void FRCBehaviourModel::OnOverrideBlueprint() const } } +bool FRCBehaviourModel::IsBehaviourEnabled() const +{ + if (URCBehaviour* Behaviour = BehaviourWeakPtr.Get()) + { + return Behaviour->bIsEnabled; + } + + return false; +} + +void FRCBehaviourModel::SetIsBehaviourEnabled(const bool bIsEnabled) +{ + if (URCBehaviour* Behaviour = BehaviourWeakPtr.Get()) + { + Behaviour->bIsEnabled = bIsEnabled; + + BehaviourTitleText->SetEnabled(bIsEnabled); + } +} + URCBehaviour* FRCBehaviourModel::GetBehaviour() const { return BehaviourWeakPtr.Get(); diff --git a/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlUI/Private/UI/Behaviour/RCBehaviourModel.h b/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlUI/Private/UI/Behaviour/RCBehaviourModel.h index fd9f8cc49648..1be18706d418 100644 --- a/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlUI/Private/UI/Behaviour/RCBehaviourModel.h +++ b/Engine/Plugins/VirtualProduction/RemoteControl/Source/RemoteControlUI/Private/UI/Behaviour/RCBehaviourModel.h @@ -5,6 +5,7 @@ #include "UI/BaseLogicUI/RCLogicModeBase.h" class IPropertyRowGenerator; +class STextBlock; class SWidget; class URCBehaviour; @@ -31,9 +32,18 @@ public: URCBehaviour* GetBehaviour() const; /** Handling for user action to override this behaviour via new Blueprint class */ - void OnOverrideBlueprint() const; + void OnOverrideBlueprint() const; + + /** Whether the underlying Behaviour is currently enabled */ + bool IsBehaviourEnabled() const; + + /** Set the Enabled state of our underlying Behaviour */ + void SetIsBehaviourEnabled(const bool bIsEnabled); private: /** The Behaviour (Data model) associated with us*/ TWeakObjectPtr BehaviourWeakPtr; + + /** Text block widget for representing the Behaviour's title */ + TSharedPtr BehaviourTitleText; }; \ No newline at end of file