From 5c4c2acb02d3b8cefd96ef70c563d9dbd1ffeb02 Mon Sep 17 00:00:00 2001 From: Dominik Morse Date: Sat, 31 Aug 2024 16:04:06 +0200 Subject: [PATCH 1/3] Update ActorInteractionPlugin.uplugin --- ActorInteractionPlugin.uplugin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ActorInteractionPlugin.uplugin b/ActorInteractionPlugin.uplugin index ba67f1b..d17d105 100644 --- a/ActorInteractionPlugin.uplugin +++ b/ActorInteractionPlugin.uplugin @@ -1,13 +1,13 @@ { "FileVersion": 3, "Version": 3, - "VersionName": "4.0.0.51", + "VersionName": "4.0.1.51", "FriendlyName": "Mountea Interaction System", "Description": "Mountea Interaction System is an Open-source Mountea Framework components-based simple framework providing utilities for smart Actor Interaction with other Actors. Developed with Game Developers in mind to allow as easy as possible implementation while maintaining high scalability and diverse options to tweak everything.", "Category": "Mountea Framework", "CreatedBy": "Dominik Pavlicek", "CreatedByURL": "https://github.com/Mountea-Framework", - "DocsURL": "https://github.com/Mountea-Framework/ActorInteractionPlugin/wiki", + "DocsURL": "https://github.com/Mountea-Framework/MounteaInteractionSystem/wiki", "MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/ca842c00ec0d4db0b3aad17701e1637b", "SupportURL": "https://bit.ly/DominikPavlicek_SupportServer", "EngineVersion": "5.1.0", From 49e8f0c2b3abfa1becd9299d4a03e9e2d7ea2efa Mon Sep 17 00:00:00 2001 From: Dominik Morse Date: Sat, 31 Aug 2024 16:04:17 +0200 Subject: [PATCH 2/3] Update ActorInteractionPlugin.uplugin --- ActorInteractionPlugin.uplugin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ActorInteractionPlugin.uplugin b/ActorInteractionPlugin.uplugin index ba67f1b..d17d105 100644 --- a/ActorInteractionPlugin.uplugin +++ b/ActorInteractionPlugin.uplugin @@ -1,13 +1,13 @@ { "FileVersion": 3, "Version": 3, - "VersionName": "4.0.0.51", + "VersionName": "4.0.1.51", "FriendlyName": "Mountea Interaction System", "Description": "Mountea Interaction System is an Open-source Mountea Framework components-based simple framework providing utilities for smart Actor Interaction with other Actors. Developed with Game Developers in mind to allow as easy as possible implementation while maintaining high scalability and diverse options to tweak everything.", "Category": "Mountea Framework", "CreatedBy": "Dominik Pavlicek", "CreatedByURL": "https://github.com/Mountea-Framework", - "DocsURL": "https://github.com/Mountea-Framework/ActorInteractionPlugin/wiki", + "DocsURL": "https://github.com/Mountea-Framework/MounteaInteractionSystem/wiki", "MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/ca842c00ec0d4db0b3aad17701e1637b", "SupportURL": "https://bit.ly/DominikPavlicek_SupportServer", "EngineVersion": "5.1.0", From 311f2572e531329d7366d141c43d6d7d9277133a Mon Sep 17 00:00:00 2001 From: Dominik Morse Date: Fri, 13 Sep 2024 17:53:32 +0200 Subject: [PATCH 3/3] Fixing errors & Defaults button - Fixing issue with defaults not being properly used in build (likely to config override) - Added `Load Defaults` button using the panel customization (to enable it for Actor Component Native) --- .../ActorInteractableComponentBase.cpp | 18 +---- .../ActorInteractableComponentBase.h | 4 +- .../Private/ActorInteractionPluginEditor.cpp | 20 ++++++ .../MounteaInteractableBase_DetailsPanel.cpp | 72 +++++++++++++++++++ .../MounteaInteractableBase_DetailsPanel.h | 31 ++++++++ .../InteractableComponentAssetFactory.cpp | 2 +- .../Public/ActorInteractionPluginEditor.h | 2 +- 7 files changed, 128 insertions(+), 21 deletions(-) create mode 100644 Source/ActorInteractionPluginEditor/Private/DetailsPanel/MounteaInteractableBase_DetailsPanel.cpp create mode 100644 Source/ActorInteractionPluginEditor/Private/DetailsPanel/MounteaInteractableBase_DetailsPanel.h diff --git a/Source/ActorInteractionPlugin/Private/Components/Interactable/ActorInteractableComponentBase.cpp b/Source/ActorInteractionPlugin/Private/Components/Interactable/ActorInteractableComponentBase.cpp index ded77eb..8160b02 100644 --- a/Source/ActorInteractionPlugin/Private/Components/Interactable/ActorInteractableComponentBase.cpp +++ b/Source/ActorInteractionPlugin/Private/Components/Interactable/ActorInteractableComponentBase.cpp @@ -65,20 +65,6 @@ UActorInteractableComponentBase::UActorInteractableComponentBase() : #if WITH_EDITORONLY_DATA bVisualizeComponent = true; #endif - -#if WITH_EDITOR && !UE_GAME - - if (!bInteractableInitialized) - { - if (GetOwner() == nullptr) - { - SetDefaultValues(); - } - - bInteractableInitialized = true; - } -#endif - } void UActorInteractableComponentBase::BeginPlay() @@ -199,9 +185,7 @@ void UActorInteractableComponentBase::InitWidget() void UActorInteractableComponentBase::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { - Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - - + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); } void UActorInteractableComponentBase::OnComponentCreated() diff --git a/Source/ActorInteractionPlugin/Public/Components/Interactable/ActorInteractableComponentBase.h b/Source/ActorInteractionPlugin/Public/Components/Interactable/ActorInteractableComponentBase.h index 42252ed..744f5de 100644 --- a/Source/ActorInteractionPlugin/Public/Components/Interactable/ActorInteractableComponentBase.h +++ b/Source/ActorInteractionPlugin/Public/Components/Interactable/ActorInteractableComponentBase.h @@ -242,9 +242,9 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractableComponentBase : public UWidge /** * Overrides data with default values from Project Settings. - * Interactable Defaults are set automatically! + * Project Settings must be defined! */ - UFUNCTION(BlueprintCallable, CallInEditor, Category="MounteaInteraction") + UFUNCTION(BlueprintCallable, Category="MounteaInteraction") void SetDefaultValues(); #endif diff --git a/Source/ActorInteractionPluginEditor/Private/ActorInteractionPluginEditor.cpp b/Source/ActorInteractionPluginEditor/Private/ActorInteractionPluginEditor.cpp index c8ee9a5..6568ef0 100644 --- a/Source/ActorInteractionPluginEditor/Private/ActorInteractionPluginEditor.cpp +++ b/Source/ActorInteractionPluginEditor/Private/ActorInteractionPluginEditor.cpp @@ -22,6 +22,7 @@ #include "ToolMenus.h" #include "AssetActions/InteractionSettingsConfig.h" +#include "DetailsPanel/MounteaInteractableBase_DetailsPanel.h" #include "Helpers/MounteaInteractionSystemEditorLog.h" #include "Interfaces/IHttpResponse.h" @@ -138,6 +139,25 @@ void FActorInteractionPluginEditor::StartupModule() ); } + // Register Custom Detail Panels + { + FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked("PropertyEditor"); + { + TArray CustomClassLayouts = + { + FOnGetDetailCustomizationInstance::CreateStatic(&MounteaInteractableBase_DetailsPanel::MakeInstance), + }; + RegisteredCustomClassLayouts = + { + UActorInteractableComponentBase::StaticClass()->GetFName(), + }; + for (int32 i = 0; i < RegisteredCustomClassLayouts.Num(); i++) + { + PropertyModule.RegisterCustomClassLayout(RegisteredCustomClassLayouts[i], CustomClassLayouts[i]); + } + } + } + // Register Help Button { FAIntPHelpStyle::Initialize(); diff --git a/Source/ActorInteractionPluginEditor/Private/DetailsPanel/MounteaInteractableBase_DetailsPanel.cpp b/Source/ActorInteractionPluginEditor/Private/DetailsPanel/MounteaInteractableBase_DetailsPanel.cpp new file mode 100644 index 0000000..5d2429d --- /dev/null +++ b/Source/ActorInteractionPluginEditor/Private/DetailsPanel/MounteaInteractableBase_DetailsPanel.cpp @@ -0,0 +1,72 @@ +// All rights reserved Dominik Morse (Pavlicek) 2024 + +#include "MounteaInteractableBase_DetailsPanel.h" +#include "DetailCategoryBuilder.h" +#include "DetailLayoutBuilder.h" +#include "DetailWidgetRow.h" +#include "Components/Interactable/ActorInteractableComponentBase.h" +#include "Widgets/Layout/SScaleBox.h" + +#define LOCTEXT_NAMESPACE "InteractableComponentsPanel" + +void MounteaInteractableBase_DetailsPanel::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) +{ + TArray> ObjectsBeingCustomized; + DetailBuilder.GetObjectsBeingCustomized(ObjectsBeingCustomized); + + // Only support one object being customized + if (ObjectsBeingCustomized.Num() != 1) return; + + const TWeakObjectPtr weakComponent = Cast(ObjectsBeingCustomized[0].Get()); + if (!weakComponent.IsValid()) return; + + EditingComponent = weakComponent.Get(); + if (!EditingComponent) return; + + // Only edit if editing from Actor Editor + /*if (DetailBuilder.GetBaseClass()->IsChildOf(AActor::StaticClass()) == false) + { return; };*/ + + IDetailCategoryBuilder& ItrCategoryBuild = DetailBuilder.EditCategory(TEXT("MounteaInteraction"), FText::GetEmpty(), ECategoryPriority::Important); + ItrCategoryBuild.AddCustomRow(LOCTEXT("InteractableComponentsPanel_Defaults", "Load Defaults"), false) + .WholeRowWidget + [ + SNew(SBox) + .HAlign(HAlign_Fill) + [ + SNew(SScaleBox) + .HAlign(EHorizontalAlignment::HAlign_Fill) + .Stretch(EStretch::ScaleToFit) + [ + SAssignNew(DefaultsButton, SButton) + .HAlign(HAlign_Fill) + .Text(LOCTEXT("InteractableComponentsPanel_Defaults_Text", "Load Defaults")) + .ToolTipText(LOCTEXT("InteractableComponentsPanel_Defaults_Tooltip", "Overrides data with default values from Project Settings.\nProject Settings must be defined!")) + .OnClicked(this, &MounteaInteractableBase_DetailsPanel::OnDefaultsClicked) + .OnHovered(this, &MounteaInteractableBase_DetailsPanel::OnDefaultsHovered) + .OnUnhovered(this, &MounteaInteractableBase_DetailsPanel::OnDefaultsHovered) + + ] + ] + ]; +} + +FReply MounteaInteractableBase_DetailsPanel::OnDefaultsClicked() const +{ + if (EditingComponent) + { + EditingComponent->SetDefaultValues(); + + if (SavedLayoutBuilder) SavedLayoutBuilder->ForceRefreshDetails(); + + return FReply::Handled(); + } + return FReply::Unhandled(); +} + +void MounteaInteractableBase_DetailsPanel::OnDefaultsHovered() +{ + +} + +#undef LOCTEXT_NAMESPACE \ No newline at end of file diff --git a/Source/ActorInteractionPluginEditor/Private/DetailsPanel/MounteaInteractableBase_DetailsPanel.h b/Source/ActorInteractionPluginEditor/Private/DetailsPanel/MounteaInteractableBase_DetailsPanel.h new file mode 100644 index 0000000..64fc8df --- /dev/null +++ b/Source/ActorInteractionPluginEditor/Private/DetailsPanel/MounteaInteractableBase_DetailsPanel.h @@ -0,0 +1,31 @@ +// All rights reserved Dominik Morse (Pavlicek) 2024 + +#pragma once + +#include "IDetailCustomization.h" + +class UActorInteractableComponentBase; + +class MounteaInteractableBase_DetailsPanel : public IDetailCustomization +{ + typedef MounteaInteractableBase_DetailsPanel Self; + +public: + // Makes a new instance of this detail layout class for a specific detail view requesting it + static TSharedRef MakeInstance() { return MakeShared(); } + + // IDetailCustomization interface + /** Called when details should be customized */ + virtual void CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) override; + + FReply OnDefaultsClicked() const; + void OnDefaultsHovered(); + +private: + + IDetailLayoutBuilder* SavedLayoutBuilder = nullptr; + + UActorInteractableComponentBase* EditingComponent = nullptr; + + TSharedPtr DefaultsButton; +}; diff --git a/Source/ActorInteractionPluginEditor/Private/Factories/InteractableComponentAssetFactory.cpp b/Source/ActorInteractionPluginEditor/Private/Factories/InteractableComponentAssetFactory.cpp index 0c37298..bf6c325 100644 --- a/Source/ActorInteractionPluginEditor/Private/Factories/InteractableComponentAssetFactory.cpp +++ b/Source/ActorInteractionPluginEditor/Private/Factories/InteractableComponentAssetFactory.cpp @@ -10,7 +10,7 @@ #include "Kismet2/KismetEditorUtilities.h" #include "Engine/DataTable.h" -#define LOCTEXT_NAMESPACE "ActorInteraction" +#define LOCTEXT_NAMESPACE "InteractableComponentAssetFactory" UInteractableComponentAssetFactory::UInteractableComponentAssetFactory(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { diff --git a/Source/ActorInteractionPluginEditor/Public/ActorInteractionPluginEditor.h b/Source/ActorInteractionPluginEditor/Public/ActorInteractionPluginEditor.h index c8d6a52..85da3d8 100644 --- a/Source/ActorInteractionPluginEditor/Public/ActorInteractionPluginEditor.h +++ b/Source/ActorInteractionPluginEditor/Public/ActorInteractionPluginEditor.h @@ -46,6 +46,6 @@ class FActorInteractionPluginEditor : public IModuleInterface private: TSharedPtr PluginCommands; - + TArray RegisteredCustomClassLayouts; FHttpModule* Http; };