-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
128 additions
and
21 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...ctorInteractionPluginEditor/Private/DetailsPanel/MounteaInteractableBase_DetailsPanel.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
31 changes: 31 additions & 0 deletions
31
.../ActorInteractionPluginEditor/Private/DetailsPanel/MounteaInteractableBase_DetailsPanel.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters