From fa8ecab21f0ddb613c7cbce0f7ef165252f678e2 Mon Sep 17 00:00:00 2001 From: Sch <3516520171@qq.com> Date: Thu, 24 Aug 2023 04:17:20 +0800 Subject: [PATCH] =?UTF-8?q?ctrls=E6=89=8B=E5=8A=A8=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 独立特效卡永久保存,拖拽进组和特效卡会复制特效卡,复制卡片与原本卡片共享,只有删除原本卡片复制卡片才会消失 --- .../Cut5/Interface/CutMainWidgetInterface.h | 1 + Source/Cut5/Widgets/DefineGlobal.h | 8 ++ Source/Cut5/Widgets/FX/SEffectCard.cpp | 33 ++++++- Source/Cut5/Widgets/FX/SEffectCardGroup.cpp | 33 ++++--- Source/Cut5/Widgets/FX/SEffectCardsPanel.cpp | 89 ++++++++++++++++--- Source/Cut5/Widgets/FX/SEffectCardsPanel.h | 4 + Source/Cut5/Widgets/SCutMainWindow.cpp | 46 ++++------ Source/Cut5/Widgets/SCutMainWindow.h | 1 + Source/Cut5/Widgets/STimelineClip.h | 5 +- 9 files changed, 161 insertions(+), 59 deletions(-) diff --git a/Source/Cut5/Interface/CutMainWidgetInterface.h b/Source/Cut5/Interface/CutMainWidgetInterface.h index 30b762c..db4b002 100644 --- a/Source/Cut5/Interface/CutMainWidgetInterface.h +++ b/Source/Cut5/Interface/CutMainWidgetInterface.h @@ -40,6 +40,7 @@ public: virtual void AddNewCard(FEffectCardProperty& CardProperty, FString GroupName) {}; virtual void OpenTimeline(const FString& TimelineName, bool NeedSaveBefore = false, bool ForceOpen = false) {}; + virtual void CloseTimeline() {}; virtual void OpenProject(const FString& Project) {}; virtual bool PreNewProject() { return false; }; virtual void ExportProject(const FString& ExportPath) {}; diff --git a/Source/Cut5/Widgets/DefineGlobal.h b/Source/Cut5/Widgets/DefineGlobal.h index 04b6a3e..9a021a4 100644 --- a/Source/Cut5/Widgets/DefineGlobal.h +++ b/Source/Cut5/Widgets/DefineGlobal.h @@ -646,6 +646,8 @@ struct CUT5_API FEffectCardProperty int32 ID = 0; TArray UsedCurtains; FStringWithGUID JumpStepCurtains; + + bool IsClone = false; friend FArchive& operator<<(FArchive& Ar, FEffectCardProperty& EffectCardProperty) { Ar << EffectCardProperty.Guid; @@ -654,8 +656,14 @@ struct CUT5_API FEffectCardProperty Ar << EffectCardProperty.ID; Ar << EffectCardProperty.UsedCurtains; Ar << EffectCardProperty.JumpStepCurtains; + Ar << EffectCardProperty.IsClone; return Ar; }; + + bool operator == (const FEffectCardProperty& Other) const + { + return Guid == Other.Guid; + } }; struct CUT5_API FEffectCardGroup diff --git a/Source/Cut5/Widgets/FX/SEffectCard.cpp b/Source/Cut5/Widgets/FX/SEffectCard.cpp index c53f6f3..01ecb22 100644 --- a/Source/Cut5/Widgets/FX/SEffectCard.cpp +++ b/Source/Cut5/Widgets/FX/SEffectCard.cpp @@ -19,7 +19,17 @@ BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION void SEffectCard::OnNameEdited(FString New, FString Old) { CardProperty->Name = New; - CardGroupPtr->CallRender(); + for (int32 i = 0; i < CardGroupPtr->EffectCardPanel->EffectCardGroups.Num(); i++) + { + for (int32 j = 0; j < CardGroupPtr->EffectCardPanel->EffectCardGroups[i].Cards.Num(); j++) + { + if (CardGroupPtr->EffectCardPanel->EffectCardGroups[i].Cards[j].Guid == CardProperty->Guid) + { + CardGroupPtr->EffectCardPanel->EffectCardGroups[i].Cards[j].Name = New; + } + } + } + CardGroupPtr->EffectCardPanel->CallRender(); } void SEffectCard::Construct(const FArguments& InArgs) @@ -57,8 +67,15 @@ void SEffectCard::Construct(const FArguments& InArgs) .ClickMethod(EButtonClickMethod::MouseDown) .OnClicked_Lambda([this]() { - - MainInterface->OpenTimeline(FUtils::SingleCardFullPath(CardProperty->Guid.ToString()), true); + if (CardProperty->bIsActive) + { + MainInterface->CloseTimeline(); + } + else + { + MainInterface->OpenTimeline(FUtils::SingleCardFullPath(CardProperty->Guid.ToString()), true); + } + PropertiesInterfaceGUID = CardProperty->Guid; MainInterface->CurrentSelectedPropertiesInterfaceGuid = CardProperty->Guid; MainInterface->UpdateProperties(this); @@ -165,7 +182,15 @@ void SEffectCard::ShowClosedButton(bool bShow) { MainInterface->OnSelectCard(CardProperty->Guid); } - CardGroupPtr->EffectCardPanel->RemoveCard(CardProperty->Guid); + if (CardProperty->IsClone) + { + CardGroupPtr->EffectCardPanel->RemoveCardInGroup(CardProperty->Guid, GroupProperty->Guid); + } + else + { + CardGroupPtr->EffectCardPanel->RemoveCard(CardProperty->Guid); + } + }), 1 ); diff --git a/Source/Cut5/Widgets/FX/SEffectCardGroup.cpp b/Source/Cut5/Widgets/FX/SEffectCardGroup.cpp index 4070ec2..48f173e 100644 --- a/Source/Cut5/Widgets/FX/SEffectCardGroup.cpp +++ b/Source/Cut5/Widgets/FX/SEffectCardGroup.cpp @@ -277,11 +277,8 @@ void SEffectCardGroup::Construct(const FArguments& InArgs) EffectCardGroup->UsedCurtains.Remove(*InItem.Get()); MainInterface->UpdateProperties(this); } - - }) ]; - }) [ SNew(STextBlock).Text_Lambda([this]() @@ -300,9 +297,7 @@ void SEffectCardGroup::Construct(const FArguments& InArgs) } }) ] - ] - ] ] ] @@ -391,7 +386,7 @@ void SEffectCardGroup::OnSelect() { if (EffectCardGroup->bIsDedicated == false) { - 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->Guid.ToString() + TEXT(".bin")); MainInterface->OpenTimeline(Name, true); MainInterface->CurrentSelectedPropertiesInterfaceGuid = EffectCardGroup->Guid; MainInterface->UpdateProperties(this); @@ -426,17 +421,26 @@ void SEffectCardGroup::CallRender() FEffectCardProperty NewCard; NewCard.Name = TEXT("未命名") + NewCard.Guid.ToString(); + + + int32 ID = 0; for (int32 i = 0; i < EffectCardPanel->EffectCardGroups.Num(); i++) { - for (int32 j = 0; j < EffectCardPanel->EffectCardGroups[i].Cards.Num(); j++) + if (EffectCardPanel->EffectCardGroups[i].bIsDedicated) { - ID++; + for (int32 j = 0; j < EffectCardPanel->EffectCardGroups[i].Cards.Num(); j++) + { + ID++; + } } ID++; } NewCard.ID = ID; + + + FUtils::CreateDefaultTimelineSave(FUtils::SingleCardFullPath(NewCard.Guid.ToString()), FTimelineInfo::ETimelineType::FX); { FSaveModifier SaveModifier(FUtils::SingleCardFullPath(NewCard.Guid.ToString())); @@ -444,7 +448,16 @@ void SEffectCardGroup::CallRender() SaveModifier.TimelineInfo.CurrentOpenType = FTimelineInfo::ETimelineType::FX; NewCard.TimelineInfo = SaveModifier.TimelineInfo; } - MainInterface->AddNewCard(NewCard, EffectCardGroup->GroupName); + MainInterface->AddNewCard(NewCard, TEXT("独立特效卡")); + + + if (!EffectCardGroup->bIsDedicated) + { + FEffectCardProperty NewCardForClone = NewCard; + NewCardForClone.IsClone = true; + MainInterface->AddNewCard(NewCardForClone, EffectCardGroup->GroupName); + } + return FReply::Handled(); }) ] @@ -554,7 +567,7 @@ FReply SEffectCardGroup::OnDrop(const FGeometry& MyGeometry, const FDragDropEven { return FReply::Handled(); } - EffectCardPanel->MoveCard(EffectCardDragDrop->CardGuid, EffectCardGroup->GroupName); + EffectCardPanel->DuplicateCard(EffectCardDragDrop->CardGuid, EffectCardGroup->Guid); } return SCompoundWidget::OnDrop(MyGeometry, DragDropEvent); } diff --git a/Source/Cut5/Widgets/FX/SEffectCardsPanel.cpp b/Source/Cut5/Widgets/FX/SEffectCardsPanel.cpp index 153e9ad..968394a 100644 --- a/Source/Cut5/Widgets/FX/SEffectCardsPanel.cpp +++ b/Source/Cut5/Widgets/FX/SEffectCardsPanel.cpp @@ -6,6 +6,7 @@ #include "SEffectCardGroup.h" #include "SlateOptMacros.h" #include "Cut5/Utils/Utils.h" +#include "Cut5/Widgets/SCutTimeline.h" #include "Widgets/Layout/SExpandableArea.h" #include "Widgets/Layout/SScrollBox.h" @@ -103,7 +104,9 @@ void SEffectCardsPanel::CallRender() .Text(FText::FromString("+")) .OnClicked_Lambda([this]() { - FEffectCardGroup* Group = AddNewGroup(TEXT("新建组") + FGuid::NewGuid().ToString()); + const FGuid NewGuid = FGuid::NewGuid(); + FEffectCardGroup* Group = AddNewGroup(TEXT("新建组") + NewGuid.ToString()); + Group->Guid = NewGuid; int32 ID = 0; for (int32 i = 0; i < EffectCardGroups.Num(); i++) { @@ -114,7 +117,8 @@ void SEffectCardsPanel::CallRender() ID++; } Group->ID = ID; - const FString NewPath = FPaths::Combine(FGlobalData::BasePath, FGlobalData::CurrentProjectName, TEXT("FX"), FGuid::NewGuid().ToString() + TEXT(".bin")); + + const FString NewPath = FPaths::Combine(FGlobalData::BasePath, FGlobalData::CurrentProjectName, TEXT("FX"), NewGuid.ToString() + TEXT(".bin")); FUtils::CreateDefaultTimelineSave(NewPath, FTimelineInfo::ETimelineType::FX); { FSaveModifier SaveModifier(NewPath); @@ -152,39 +156,64 @@ void SEffectCardsPanel::AddNewCard(FEffectCardProperty CardProperty, const FStri void SEffectCardsPanel::RemoveCard(const FGuid& GUID) { + const FGuid CopyGuid = GUID; // Search in all group to find GUID equal to the GUID. int32 j = 0; for (FEffectCardGroup& Group : EffectCardGroups) { - if (!Group.bIsDedicated && Group.Guid == GUID) + if (!Group.bIsDedicated && Group.Guid == CopyGuid) { if (Group.bIsActive == true) { - MainInterface->OpenTimeline(FUtils::MainSaveFullPath()); + MainInterface->OpenTimeline(FUtils::MainSaveFullPath(), true); } EffectCardGroups.RemoveAt(j); break; } - int32 i = 0; - for (FEffectCardProperty& Property : Group.Cards) + + for (int32 i = Group.Cards.Num() - 1; i >= 0; i--) { - if (Property.Guid == GUID) + if (Group.Cards[i].Guid == CopyGuid) { - if (Property.bIsActive == true) + if (Group.Cards[i].bIsActive == true) { - MainInterface->OpenTimeline(FUtils::MainSaveFullPath()); + MainInterface->OpenTimeline(FUtils::MainSaveFullPath(), true); } Group.Cards.RemoveAt(i); - break; } - i++; } j++; } CallRender(); } +void SEffectCardsPanel::RemoveCardInGroup(const FGuid& Guid, const FGuid& GroupGuid) +{ + for (FEffectCardGroup& Group : EffectCardGroups) + { + if (Group.Guid == GroupGuid) + { + int32 i = 0; + for (FEffectCardProperty& Property : Group.Cards) + { + if (Property.Guid == Guid) + { + if (Property.bIsActive == true) + { + MainInterface->OpenTimeline(FUtils::MainSaveFullPath()); + } + Group.Cards.RemoveAt(i); + break; + } + i++; + } + break; + } + } + CallRender(); +} + void SEffectCardsPanel::MoveCard(const FGuid& GUID, const FString& GroupName) { FEffectCardProperty CardProperty; @@ -211,6 +240,42 @@ void SEffectCardsPanel::MoveCard(const FGuid& GUID, const FString& GroupName) CallRender(); } +void SEffectCardsPanel::DuplicateCard(const FGuid& Guid, const FGuid& ToGroupGuid) +{ + for (int32 i = 0; i < EffectCardGroups.Num(); i++) + { + if (EffectCardGroups[i].bIsDedicated) + { + for (int32 j = 0; j < EffectCardGroups[i].Cards.Num(); j++) + { + if (Guid == EffectCardGroups[i].Cards[j].Guid) + { + FEffectCardProperty NewEffectCardProperty = EffectCardGroups[i].Cards[j]; + NewEffectCardProperty.IsClone = true; + for (int32 k = 0; k < EffectCardGroups.Num(); k++) + { + if (EffectCardGroups[k].Guid == ToGroupGuid) + { + if (EffectCardGroups[k].Cards.Contains(NewEffectCardProperty)) + { + return; + } + EffectCardGroups[k].Cards.Add(NewEffectCardProperty); + break; + } + } + break; + } + + + } + } + } + CallRender(); + + +} + FEffectCardGroup* SEffectCardsPanel::AddNewGroup(const FString& GroupName) { FEffectCardGroup NewGroup; @@ -253,7 +318,7 @@ void SEffectCardsPanel::SelectCard(const FGuid& Guid) { if (Guid == CurrentSelectedCardGuid) { - MainInterface->OpenTimeline(FUtils::MainSaveFullPath()); + MainInterface->CloseTimeline(); CurrentSelectedCardGuid.Invalidate(); DeselectedAll(); MainInterface->UpdateProperties(nullptr); diff --git a/Source/Cut5/Widgets/FX/SEffectCardsPanel.h b/Source/Cut5/Widgets/FX/SEffectCardsPanel.h index 0570d6c..07aa9c3 100644 --- a/Source/Cut5/Widgets/FX/SEffectCardsPanel.h +++ b/Source/Cut5/Widgets/FX/SEffectCardsPanel.h @@ -57,6 +57,9 @@ public: */ void RemoveCard(const FGuid& GUID); + + void RemoveCardInGroup(const FGuid& Guid, const FGuid& GroupGuid); + /** * @brief Move card from one group to another. * @param GUID Card GUID. @@ -64,6 +67,7 @@ public: */ void MoveCard(const FGuid& GUID, const FString& GroupName); + void DuplicateCard(const FGuid& Guid, const FGuid& ToGroupGuid); /** * @brief Add an group to the panel. diff --git a/Source/Cut5/Widgets/SCutMainWindow.cpp b/Source/Cut5/Widgets/SCutMainWindow.cpp index d9a110f..c751188 100644 --- a/Source/Cut5/Widgets/SCutMainWindow.cpp +++ b/Source/Cut5/Widgets/SCutMainWindow.cpp @@ -770,38 +770,18 @@ void SCutMainWindow::AddNewCard(FEffectCardProperty& CardProperty, FString Group void SCutMainWindow::OpenTimeline(const FString& TimelineName, bool NeedSaveBefore, bool ForceOpen) { - + CutTimeline->bNeedShowPanel = true; if (NeedSaveBefore) { - if (TimelineName != "") - { - if (CutTimeline->TimelineInfo.CurrentOpenFullPath.IsEmpty()) - { - CutTimeline->SaveTimeline(FUtils::MainSaveFullPath(), CutTimeline->TimelineInfo); - CutTimeline->TimelineInfo.CurrentOpenFullPath = FUtils::MainSaveFullPath(); - CutTimeline->bNeedShowPanel = false; - } - else - { - if (CutTimeline->TimelineInfo.CurrentOpenFullPath != FUtils::MainSaveFullPath()) - { - CutTimeline->SaveTimeline(CutTimeline->TimelineInfo.CurrentOpenFullPath, CutTimeline->TimelineInfo); - CutTimeline->bNeedShowPanel = true; - } - - else - { - if (!ForceOpen) - { - CutTimeline->SaveTimeline(FUtils::MainSaveFullPath(), CutTimeline->TimelineInfo); - CutTimeline->TimelineInfo.CurrentOpenFullPath = FUtils::MainSaveFullPath(); - CutTimeline->bNeedShowPanel = false; - } - - } - } - } + CutTimeline->SaveTimeline(CutTimeline->TimelineInfo.CurrentOpenFullPath, CutTimeline->TimelineInfo); + CutTimeline->TimelineInfo.CurrentOpenFullPath = TimelineName; } + // + // if (TimelineName == CutTimeline->TimelineInfo.CurrentOpenFullPath && !ForceOpen) + // { + // CloseTimeline(); + // return; + // } FTimelineInfo TimelineInfo; // 拿到TimelineName路径中的名字,也就是倒数第四位开始,去掉后缀 @@ -813,6 +793,14 @@ void SCutMainWindow::OpenTimeline(const FString& TimelineName, bool NeedSaveBefo } OnAddNewTrack(ETrackType::PlayerTrack); + +} + +void SCutMainWindow::CloseTimeline() +{ + CutTimeline->bNeedShowPanel = false; + CutTimeline->SaveTimeline(CutTimeline->TimelineInfo.CurrentOpenFullPath, CutTimeline->TimelineInfo); + CutTimeline->RenderGroup(); } void SCutMainWindow::OpenProject(const FString& Project) diff --git a/Source/Cut5/Widgets/SCutMainWindow.h b/Source/Cut5/Widgets/SCutMainWindow.h index 7832cd5..c72c409 100644 --- a/Source/Cut5/Widgets/SCutMainWindow.h +++ b/Source/Cut5/Widgets/SCutMainWindow.h @@ -70,6 +70,7 @@ public: // 不好 到时候改成 Group Widget 内部操作 virtual void AddNewCard(FEffectCardProperty& CardProperty, FString GroupName) override; virtual void OpenTimeline(const FString& TimelineName, bool NeedSaveBefore, bool ForceOpen = false) override; + virtual void CloseTimeline() override; virtual void OpenProject(const FString& Project) override; virtual void ExportProject(const FString& ExportPath) override; virtual void ImportProject(const FString& ImportPath) override; diff --git a/Source/Cut5/Widgets/STimelineClip.h b/Source/Cut5/Widgets/STimelineClip.h index 2f0fcd3..43bd92c 100644 --- a/Source/Cut5/Widgets/STimelineClip.h +++ b/Source/Cut5/Widgets/STimelineClip.h @@ -6,10 +6,7 @@ #include "DefineGlobal.h" #include "Cut5/Interface/CutMainWidgetInterface.h" #include "Widgets/SCompoundWidget.h" -#include -#include -#include -#include + #include "Cut5/Interface/SoundInterface.h"