记录一下属性面板

This commit is contained in:
Sch 2023-08-03 09:14:06 +08:00
parent 7927980d2f
commit 099040a36f
11 changed files with 134 additions and 22 deletions

View File

@ -47,4 +47,5 @@ public:
virtual void OnRemoveCard(const FGuid& SelectedCard) {}; virtual void OnRemoveCard(const FGuid& SelectedCard) {};
virtual void UpdateProperties(IPropertiesInterface* Interface) {}; virtual void UpdateProperties(IPropertiesInterface* Interface) {};
FGuid CurrentSelectedPropertiesInterfaceGuid;
}; };

View File

@ -26,4 +26,7 @@ public:
virtual FProperties* GetProperties() { return Properties; }; virtual FProperties* GetProperties() { return Properties; };
FProperties* Properties = nullptr; FProperties* Properties = nullptr;
virtual TSharedPtr<SWidget> GetPropertiesWidget() { return nullptr; };
FGuid PropertiesInterfaceGUID = FGuid::NewGuid();
}; };

View File

@ -38,14 +38,17 @@ void SCustomPanel::Construct(const FArguments& InArgs)
void SCustomPanel::UpdateProperties(IPropertiesInterface* Interface) void SCustomPanel::UpdateProperties(IPropertiesInterface* Interface)
{ {
CustomScroll->ClearChildren(); CustomScroll->ClearChildren();
for (FGeneralPropertyBase& Base : Interface->GetProperties()->Properties) if (Interface != nullptr)
{ {
CustomScroll->AddSlot() CustomScroll->AddSlot()
[ [
Base.BaseWidget.ToSharedRef() Interface->GetPropertiesWidget().ToSharedRef()
]; ];
} }
} }
END_SLATE_FUNCTION_BUILD_OPTIMIZATION END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -334,6 +334,7 @@ struct FGeneralPropertyBase
{ {
FString PropertyName; FString PropertyName;
TSharedPtr<SWidget> BaseWidget = nullptr; TSharedPtr<SWidget> BaseWidget = nullptr;
TSharedPtr<SEditableTextBox> EditableTextBox = nullptr;
FGeneralPropertyBase() FGeneralPropertyBase()
{ {
BaseWidget = SNew(SBox) BaseWidget = SNew(SBox)
@ -360,19 +361,29 @@ struct FCardNameProperty : public FGeneralPropertyBase
SNew(SHorizontalBox) SNew(SHorizontalBox)
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.SizeParam(FAuto()) .SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(62)
.HeightOverride(32)
[ [
SNew(STextBlock) SNew(STextBlock)
.Text(FText::FromString(Name)) .Text(FText::FromString(Name))
] ]
]
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.SizeParam(FAuto()) .SizeParam(FAuto())
[ [
SNew(SEditableTextBox) SNew(SBox)
.WidthOverride(136)
.HeightOverride(32)
[
SAssignNew(EditableTextBox, SEditableTextBox)
.OnTextCommitted_Lambda([CardNamePtr](const FText& InText, ETextCommit::Type InCommitType) .OnTextCommitted_Lambda([CardNamePtr](const FText& InText, ETextCommit::Type InCommitType)
{ {
*CardNamePtr = InText.ToString(); *CardNamePtr = InText.ToString();
}) })
] ]
]
]; ];
} }
}; };
@ -386,19 +397,30 @@ struct FNumProperty : public FGeneralPropertyBase
SNew(SHorizontalBox) SNew(SHorizontalBox)
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.SizeParam(FAuto()) .SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(62)
.HeightOverride(32)
[ [
SNew(STextBlock) SNew(STextBlock)
.Text(FText::FromString(Name)) .Text(FText::FromString(Name))
] ]
]
+ SHorizontalBox::Slot() + SHorizontalBox::Slot()
.SizeParam(FAuto()) .SizeParam(FAuto())
[ [
SNew(SEditableTextBox) SNew(SBox)
.WidthOverride(136)
.HeightOverride(32)
[
SAssignNew(EditableTextBox, SEditableTextBox)
.OnTextCommitted_Lambda([NumPtr](const FText& InText, ETextCommit::Type InCommitType) .OnTextCommitted_Lambda([NumPtr](const FText& InText, ETextCommit::Type InCommitType)
{ {
*NumPtr = FCString::Atoi(*InText.ToString()); *NumPtr = FCString::Atoi(*InText.ToString());
}) })
] ]
]
]; ];
} }
}; };

View File

@ -64,8 +64,11 @@ void SEffectCard::Construct(const FArguments& InArgs)
if (GroupProperty->bIsDedicated) if (GroupProperty->bIsDedicated)
{ {
MainInterface->OpenTimeline(FUtils::SingleCardFullPath(CardProperty->Name), true); MainInterface->OpenTimeline(FUtils::SingleCardFullPath(CardProperty->Name), true);
MainInterface->OnSelectCard(CardProperty->Guid); PropertiesInterfaceGUID = CardProperty->Guid;
MainInterface->CurrentSelectedPropertiesInterfaceGuid = CardProperty->Guid;
MainInterface->UpdateProperties(this); MainInterface->UpdateProperties(this);
MainInterface->OnSelectCard(CardProperty->Guid);
} }
else else
{ {
@ -73,6 +76,7 @@ void SEffectCard::Construct(const FArguments& InArgs)
{ {
const FString Name = FPaths::Combine(FGlobalData::BasePath, FGlobalData::CurrentProjectName, TEXT("FX"), GroupProperty->GroupName + TEXT(".bin")); const FString Name = FPaths::Combine(FGlobalData::BasePath, FGlobalData::CurrentProjectName, TEXT("FX"), GroupProperty->GroupName + TEXT(".bin"));
MainInterface->OpenTimeline(Name, true); MainInterface->OpenTimeline(Name, true);
MainInterface->OnSelectCard(GroupProperty->Guid);
} }
return FReply::Handled(); return FReply::Handled();
} }
@ -130,7 +134,51 @@ void SEffectCard::Construct(const FArguments& InArgs)
] ]
]; ];
PropertiesWidget = SNew(SBox).HeightOverride(32).WidthOverride(214)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(62)
.HeightOverride(32)
[
SNew(STextBlock)
.Text(FText::FromString(TEXT("名称")))
]
]
+ SHorizontalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
.WidthOverride(136)
.HeightOverride(32)
[
SNew(SEditableTextBox)
.Text(FText::FromString(CardProperty->Name))
.OnVerifyTextChanged_Lambda([this](const FText& InText, FText& OutErrorMessage)
{
TArray<FEffectCardProperty> Properties = GroupProperty->Cards;
for (FEffectCardProperty NewCardProperty : Properties)
{
if (NewCardProperty.Name == InText.ToString() && NewCardProperty.Guid != this->CardProperty->Guid)
{
OutErrorMessage = FText::FromString(TEXT("名称已存在"));
return false;
}
}
return true;
})
.OnTextCommitted_Lambda([this](const FText& InText, ETextCommit::Type InCommitType)
{
this->OnNameEdited(InText.ToString(), CardProperty->Name);
})
]
]
];
PropertiesInterfaceGUID = CardProperty->Guid;
} }
void SEffectCard::ShowClosedButton(bool bShow) void SEffectCard::ShowClosedButton(bool bShow)
@ -190,5 +238,10 @@ FProperties* SEffectCard::GetProperties()
return Properties; return Properties;
} }
TSharedPtr<SWidget> SEffectCard::GetPropertiesWidget()
{
return PropertiesWidget;
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -49,6 +49,8 @@ public:
virtual void OnMouseLeave(const FPointerEvent& MouseEvent) override; virtual void OnMouseLeave(const FPointerEvent& MouseEvent) override;
virtual FProperties* GetProperties() override; virtual FProperties* GetProperties() override;
virtual TSharedPtr<SWidget> GetPropertiesWidget() override;
TSharedPtr<SWidget> PropertiesWidget;
FString CardName; FString CardName;

View File

@ -65,6 +65,7 @@ void SEffectCardGroup::Construct(const FArguments& InArgs)
SNew(SBorder) SNew(SBorder)
.HAlign(HAlign_Fill) .HAlign(HAlign_Fill)
.VAlign(VAlign_Fill) .VAlign(VAlign_Fill)
.ColorAndOpacity(EffectCardGroup->bIsActive ? FLinearColor(0.1, 0.1, 0.3, 1) : FLinearColor(1.0, 1.0, 1.0, 1))
[ [
SNew(SOverlay) SNew(SOverlay)
+ SOverlay::Slot() + SOverlay::Slot()
@ -82,6 +83,7 @@ void SEffectCardGroup::Construct(const FArguments& InArgs)
{ {
const FString Name = FPaths::Combine(FGlobalData::BasePath, FGlobalData::CurrentProjectName, TEXT("FX"), EffectCardGroup->GroupName + TEXT(".bin")); const FString Name = FPaths::Combine(FGlobalData::BasePath, FGlobalData::CurrentProjectName, TEXT("FX"), EffectCardGroup->GroupName + TEXT(".bin"));
MainInterface->OpenTimeline(Name, true); MainInterface->OpenTimeline(Name, true);
MainInterface->OnSelectCard(EffectCardGroup->Guid);
} }
return FReply::Handled(); return FReply::Handled();
}) })
@ -129,6 +131,9 @@ void SEffectCardGroup::Construct(const FArguments& InArgs)
void SEffectCardGroup::CallRender() void SEffectCardGroup::CallRender()
{ {
// MainInterface->UpdateProperties(nullptr);
MainInterface->UpdateProperties(nullptr);
CardsInst.Empty();
GridPanel->ClearChildren(); GridPanel->ClearChildren();
GridPanel->AddSlot(GridPanel->GetChildren()->Num() % 3, GridPanel->GetChildren()->Num() / 3) GridPanel->AddSlot(GridPanel->GetChildren()->Num() % 3, GridPanel->GetChildren()->Num() / 3)
[ [
@ -160,19 +165,30 @@ void SEffectCardGroup::CallRender()
] ]
] ]
]; ];
for (FEffectCardProperty& Property : EffectCardGroup->Cards) for (FEffectCardProperty& Property : EffectCardGroup->Cards)
{ {
GridPanel->AddSlot(GridPanel->GetChildren()->Num() % 3, GridPanel->GetChildren()->Num() / 3) TSharedPtr<SEffectCard> NewCardInst =
[
SNew(SEffectCard) SNew(SEffectCard)
.CardProperty(&Property) .CardProperty(&Property)
.GroupName(EffectCardGroup->GroupName) .GroupName(EffectCardGroup->GroupName)
.MainInterface(MainInterface) .MainInterface(MainInterface)
.GroupProperty(EffectCardGroup) .GroupProperty(EffectCardGroup)
.CardGroupPtr(this) .CardGroupPtr(this);
GridPanel->AddSlot(GridPanel->GetChildren()->Num() % 3, GridPanel->GetChildren()->Num() / 3)
[
NewCardInst.ToSharedRef()
]; ];
if (MainInterface->CurrentSelectedPropertiesInterfaceGuid == Property.Guid)
{
MainInterface->UpdateProperties(NewCardInst.Get());
}
CardsInst.Add(NewCardInst);
} }
} }
END_SLATE_FUNCTION_BUILD_OPTIMIZATION END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -42,4 +42,6 @@ public:
* @brief All the effect cards slate instance in this group and formatted. * @brief All the effect cards slate instance in this group and formatted.
*/ */
TSharedPtr<SGridPanel> GridPanel; TSharedPtr<SGridPanel> GridPanel;
TArray<TSharedPtr<class SEffectCard>> CardsInst;
}; };

View File

@ -204,6 +204,7 @@ void SEffectCardsPanel::SelectCard(const FGuid& Guid)
MainInterface->OpenTimeline(FUtils::MainSaveFullPath()); MainInterface->OpenTimeline(FUtils::MainSaveFullPath());
CurrentSelectedCardGuid.Invalidate(); CurrentSelectedCardGuid.Invalidate();
DeselectedAll(); DeselectedAll();
MainInterface->UpdateProperties(nullptr);
CallRender(); CallRender();
} }
else else

View File

@ -33,6 +33,7 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
{ {
SAssignNew(CutTimeline, SCutTimeline).MainWidgetInterface(this); SAssignNew(CutTimeline, SCutTimeline).MainWidgetInterface(this);
SAssignNew(StatePanel, SStatePanel); SAssignNew(StatePanel, SStatePanel);
SAssignNew(CustomPanel, SCustomPanel);
ChildSlot ChildSlot
[ [
SNew(SScaleBox) SNew(SScaleBox)
@ -144,7 +145,7 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
SNew(SVerticalBox) SNew(SVerticalBox)
+ SVerticalBox::Slot() + SVerticalBox::Slot()
[ [
SAssignNew(CustomPanel, SCustomPanel) CustomPanel.ToSharedRef()
] ]
] ]
] ]
@ -578,6 +579,12 @@ FString SCutMainWindow::GetGroupName(TSharedPtr<IWidgetInterface> WidgetInterfac
void SCutMainWindow::UpdateProperties(IPropertiesInterface* Interface) void SCutMainWindow::UpdateProperties(IPropertiesInterface* Interface)
{ {
CustomPanel->UpdateProperties(Interface); CustomPanel->UpdateProperties(Interface);
if (Interface)
{
CurrentSelectedPropertiesInterfaceGuid = Interface->PropertiesInterfaceGUID;
}
} }

View File

@ -63,4 +63,6 @@ public:
virtual FTimelinePropertyData* GetResourcePropertyDataPtr(FGuid GUID) override; virtual FTimelinePropertyData* GetResourcePropertyDataPtr(FGuid GUID) override;
virtual FString GetGroupName(TSharedPtr<IWidgetInterface> WidgetInterface) override; virtual FString GetGroupName(TSharedPtr<IWidgetInterface> WidgetInterface) override;
virtual void UpdateProperties(IPropertiesInterface* Interface) override; virtual void UpdateProperties(IPropertiesInterface* Interface) override;
}; };