Skip to content

Commit

Permalink
Merge branch '5.2_dev' into 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlicekdominik committed Sep 13, 2024
2 parents 3815089 + 2cb6bea commit 85e7c58
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 21 deletions.
Binary file modified Content/Example/BP_InteractionExample_Character.uasset
Binary file not shown.
Binary file modified Content/Example/BP_InteractionExample_NPC.uasset
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,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()
Expand Down Expand Up @@ -200,9 +186,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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "ToolMenus.h"
#include "AssetActions/InteractionSettingsConfig.h"
#include "DetailsPanel/MounteaInteractableBase_DetailsPanel.h"
#include "Helpers/MounteaInteractionSystemEditorLog.h"
#include "Interfaces/IHttpResponse.h"

Expand Down Expand Up @@ -138,6 +139,25 @@ void FActorInteractionPluginEditor::StartupModule()
);
}

// Register Custom Detail Panels
{
FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
{
TArray<FOnGetDetailCustomizationInstance> 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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<TWeakObjectPtr<UObject>> ObjectsBeingCustomized;
DetailBuilder.GetObjectsBeingCustomized(ObjectsBeingCustomized);

// Only support one object being customized
if (ObjectsBeingCustomized.Num() != 1) return;

const TWeakObjectPtr<UActorInteractableComponentBase> weakComponent = Cast<UActorInteractableComponentBase>(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
Original file line number Diff line number Diff line change
@@ -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<IDetailCustomization> MakeInstance() { return MakeShared<Self>(); }

// 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<SButton> DefaultsButton;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ class FActorInteractionPluginEditor : public IModuleInterface
private:

TSharedPtr<class FUICommandList> PluginCommands;

TArray<FName> RegisteredCustomClassLayouts;
FHttpModule* Http;
};

0 comments on commit 85e7c58

Please sign in to comment.