From db3174431765ca06a8f198ca244549c910e25616 Mon Sep 17 00:00:00 2001 From: Sch <3516520171@qq.com> Date: Thu, 3 Aug 2023 02:37:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=A1=E7=89=8C=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cut5/Interface/CutMainWidgetInterface.h | 1 + Source/Cut5/Utils/Utils.cpp | 3 +- .../DragDropOperator/DragDropOperator.cpp | 4 +- Source/Cut5/Widgets/FX/SEffectCard.cpp | 129 +++++++++++++----- Source/Cut5/Widgets/FX/SEffectCard.h | 10 ++ Source/Cut5/Widgets/FX/SEffectCardGroup.cpp | 49 +++++-- Source/Cut5/Widgets/FX/SEffectCardsPanel.cpp | 39 ++++-- Source/Cut5/Widgets/FX/SEffectCardsPanel.h | 2 + Source/Cut5/Widgets/MicroWidgets/STips.cpp | 16 ++- Source/Cut5/Widgets/SCutMainWindow.cpp | 21 ++- Source/Cut5/Widgets/SCutMainWindow.h | 2 +- Source/Cut5/Widgets/SCutTimeline.cpp | 6 +- Source/Cut5/Widgets/STimelineClip.cpp | 5 +- .../Cut5/Widgets/STimelinePropertyPanel.cpp | 24 +++- Source/Cut5/Widgets/STrackBody.cpp | 4 +- 15 files changed, 234 insertions(+), 81 deletions(-) diff --git a/Source/Cut5/Interface/CutMainWidgetInterface.h b/Source/Cut5/Interface/CutMainWidgetInterface.h index cf25e43..948efe6 100644 --- a/Source/Cut5/Interface/CutMainWidgetInterface.h +++ b/Source/Cut5/Interface/CutMainWidgetInterface.h @@ -43,4 +43,5 @@ public: virtual void OnSelectCard(const FGuid& SelectedCard) {}; + virtual void OnRemoveCard(const FGuid& SelectedCard) {}; }; diff --git a/Source/Cut5/Utils/Utils.cpp b/Source/Cut5/Utils/Utils.cpp index 2df88f0..bae1aba 100644 --- a/Source/Cut5/Utils/Utils.cpp +++ b/Source/Cut5/Utils/Utils.cpp @@ -72,7 +72,7 @@ void FUtils::CreateDefaultTimelineSave(const FString& SavedPath, const FTimeline { TArray SavedData; FFileHelper::LoadFileToArray(SavedData, *FPaths::Combine(FPaths::ProjectSavedDir(), Type == FTimelineInfo::ETimelineType::Main ? TEXT("Default.sav") : TEXT("DefaultFX.sav"))); - FFileHelper::SaveArrayToFile(SavedData, *FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName, SavedPath)); + FFileHelper::SaveArrayToFile(SavedData, *SavedPath); } FSaveModifier::FSaveModifier(const FString& FullSavedPath) @@ -80,6 +80,7 @@ FSaveModifier::FSaveModifier(const FString& FullSavedPath) this->FullSavedPath = FullSavedPath; TArray LoadData; + FFileHelper::LoadFileToArray(LoadData, *FullSavedPath); if (LoadData.Num() == 0) { diff --git a/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp b/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp index cf9e230..8ddea88 100644 --- a/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp +++ b/Source/Cut5/Widgets/DragDropOperator/DragDropOperator.cpp @@ -20,7 +20,7 @@ DragDropOperator* DragDropOperator::GetDragDropOperator() void DragDropOperator::OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) { const auto& DragDropOperation = static_cast(DragDropEvent.GetOperation().ToSharedRef().Get()); - // GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Green, FString::Printf(TEXT("%f"), DragDropEvent.GetScreenSpacePosition().X)); + TSharedPtr Body = StaticCastSharedPtr(DragDropOperation.OverrideWidget); if (DragDropOperation.DragDropType == FCutDragDropBase::EType::Clip2Clip) { @@ -165,7 +165,7 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& } TrackHead->TrackData.ClipData.Add(NewClipData); - // GEngine->AddOnScreenDebugMessage(-1, 10.0, FColor::Green, FString::Printf(TEXT("Track %d"), TrackHead->TrackData.ClipData.Num())); + } if (DragDropOperation.DragDropType == FCutDragDropBase::EType::Clip2Clip) { diff --git a/Source/Cut5/Widgets/FX/SEffectCard.cpp b/Source/Cut5/Widgets/FX/SEffectCard.cpp index 53d58f9..6e46dec 100644 --- a/Source/Cut5/Widgets/FX/SEffectCard.cpp +++ b/Source/Cut5/Widgets/FX/SEffectCard.cpp @@ -3,6 +3,7 @@ #include "SEffectCard.h" +#include "SEffectCardGroup.h" #include "SlateOptMacros.h" #include "Cut5/Utils/Utils.h" @@ -28,22 +29,29 @@ void SEffectCard::OnNameEdited(FString New, FString Old) } else { - + } + + CardGroupPtr->CallRender(); } void SEffectCard::Construct(const FArguments& InArgs) { CardProperty = InArgs._CardProperty; + CardGroupPtr = InArgs._CardGroupPtr; + GroupProperty = InArgs._GroupProperty; GroupName = InArgs._GroupName; MainInterface = InArgs._MainInterface; + + ChildSlot [ SNew(SBox) .WidthOverride(125.0f) .HeightOverride(125.0f) + .Padding(10.0f) [ - SNew(SOverlay) + SAssignNew(Overlay, SOverlay) // + SOverlay::Slot() // [ // SNew(SButton) @@ -52,51 +60,66 @@ void SEffectCard::Construct(const FArguments& InArgs) .VAlign(VAlign_Fill) .HAlign(HAlign_Fill) [ - SNew(SImage) - .Image(CardProperty->bIsActive ? FUtils::GetBrushFromImage(FUtils::GetResourcesPath("EffectCard.png"), FVector2D(125.0, 125.0)) : - FUtils::GetBrushFromImage(FUtils::GetResourcesPath("EffectCardUnSelected.png"), FVector2D(125.0, 125.0))) - .OnMouseButtonDown_Lambda([this](const FGeometry&, const FPointerEvent& PointerEvent) + SNew(SButton) + .HAlign(HAlign_Fill) + .VAlign(VAlign_Fill) + .OnClicked_Lambda([this]() { - MainInterface->OpenTimeline(FUtils::SingleCardFullPath(CardProperty->Name), true); - MainInterface->OnSelectCard(CardProperty->Guid); + if (GroupProperty->bIsDedicated) + { + MainInterface->OpenTimeline(FUtils::SingleCardFullPath(CardProperty->Name), true); + MainInterface->OnSelectCard(CardProperty->Guid); + } + else + { + if (GroupProperty->bIsDedicated == false) + { + const FString Name = FPaths::Combine(FGlobalData::BasePath, FGlobalData::CurrentProjectName, TEXT("FX"), GroupProperty->GroupName + TEXT(".bin")); + MainInterface->OpenTimeline(Name, true); + } + return FReply::Handled(); + } + return FReply::Handled(); }) ] + SOverlay::Slot() + [ + SNew(SImage) + .Image(CardProperty->bIsActive ? FUtils::GetBrushFromImage(FUtils::GetResourcesPath("EffectCard.png"), FVector2D(128.0, 128.0)) : + FUtils::GetBrushFromImage(FUtils::GetResourcesPath("EffectCardUnSelected.png"), FVector2D(128.0, 128.0))) + .Visibility(EVisibility::HitTestInvisible) + ] + + SOverlay::Slot() .VAlign(VAlign_Center) .HAlign(HAlign_Center) [ - SNew(SClickEditableText) - .InitTextPtr(&CardProperty->Name) - .OnEdited_Raw(this, &SEffectCard::OnNameEdited) - .CanEdit(!CardProperty->bIsActive) - .OnSingleClick_Lambda([this]() + SNew(SInlineEditableTextBlock) + .Text(FText::FromString(CardProperty->Name)) + .OnVerifyTextChanged_Lambda([this](const FText& NewText, FText& OutErrorMessage) { - + if (NewText.IsEmpty()) + { + OutErrorMessage = FText::FromString(TEXT("名称不能为空")); + return false; + } + for (FEffectCardProperty& CardProperty : GroupProperty->Cards) + { + if (CardProperty.Name == NewText.ToString() && CardProperty.Guid != this->CardProperty->Guid) + { + OutErrorMessage = FText::FromString(TEXT("名称已存在")); + return false; + } + } + return true; }) - ] - + SOverlay::Slot() - .VAlign(VAlign_Top) - .HAlign(HAlign_Right) - [ - SNew(SButton) - .Content() - [ - SNew(SImage) - .Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("close-circle-fill.png"), {})) - ] - .OnClicked_Lambda([]() + .OnTextCommitted_Lambda([this](const FText& NewText, ETextCommit::Type CommitType) { - GEngine->GameViewport->AddViewportWidgetContent( - SNew(STips) - .Title(TEXT("确定删除特效卡吗?")) - .SubTitle(TEXT("特效卡删除后不可恢复")), 1 - ); - - - return FReply::Handled(); + if (CommitType == ETextCommit::OnEnter) + { + OnNameEdited(NewText.ToString(), CardProperty->Name); + } }) - ] ] @@ -105,4 +128,40 @@ void SEffectCard::Construct(const FArguments& InArgs) } +void SEffectCard::ShowClosedButton(bool bShow) +{ + if (bShow) + { + ClosedButton = SNew(SButton) + .Content() + [ + SNew(SImage) + .Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("close-circle-fill.png"), {16, 16})) + ] + .OnClicked_Lambda([]() + { + GEngine->GameViewport->AddViewportWidgetContent( + SNew(STips) + .Title(TEXT("确定删除特效卡吗?")) + .SubTitle(TEXT("特效卡删除后不可恢复")), 1 + ); + + + return FReply::Handled(); + }); + Overlay->AddSlot() + .VAlign(VAlign_Top) + .HAlign(HAlign_Right) + [ + ClosedButton.ToSharedRef() + ]; + } + else + { + Overlay->RemoveSlot(ClosedButton.ToSharedRef()); + ClosedButton.Reset(); + } + +} + END_SLATE_FUNCTION_BUILD_OPTIMIZATION diff --git a/Source/Cut5/Widgets/FX/SEffectCard.h b/Source/Cut5/Widgets/FX/SEffectCard.h index b247487..782e3d2 100644 --- a/Source/Cut5/Widgets/FX/SEffectCard.h +++ b/Source/Cut5/Widgets/FX/SEffectCard.h @@ -18,12 +18,16 @@ public: { } SLATE_ARGUMENT(FEffectCardProperty*, CardProperty) + SLATE_ARGUMENT(FEffectCardGroup*, GroupProperty) + SLATE_ARGUMENT(class SEffectCardGroup*, CardGroupPtr) SLATE_ARGUMENT(FString, GroupName) SLATE_ARGUMENT(ICutMainWidgetInterface*, MainInterface) SLATE_END_ARGS() FEffectCardProperty* CardProperty; + FEffectCardGroup* GroupProperty; + class SEffectCardGroup* CardGroupPtr; FString GroupName; void OnNameEdited(FString New, FString Old); @@ -33,4 +37,10 @@ public: ICutMainWidgetInterface* MainInterface; + void ShowClosedButton(bool bShow); + + TSharedPtr Overlay; + + TSharedPtr ClosedButton; + }; diff --git a/Source/Cut5/Widgets/FX/SEffectCardGroup.cpp b/Source/Cut5/Widgets/FX/SEffectCardGroup.cpp index 319a6ca..5e4c7b9 100644 --- a/Source/Cut5/Widgets/FX/SEffectCardGroup.cpp +++ b/Source/Cut5/Widgets/FX/SEffectCardGroup.cpp @@ -10,6 +10,7 @@ #include "Widgets/Layout/SExpandableArea.h" #include "Widgets/Layout/SGridPanel.h" #include "Widgets/Layout/SScrollBox.h" +#include "Widgets/Text/SInlineEditableTextBlock.h" BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION @@ -32,6 +33,7 @@ void SEffectCardGroup::OnNameEdited(FString New, FString Old) { } + CallRender(); } void SEffectCardGroup::Construct(const FArguments& InArgs) @@ -55,19 +57,14 @@ void SEffectCardGroup::Construct(const FArguments& InArgs) }) .HeaderContent() [ - SNew(SClickEditableText) - .InitTextPtr(&EffectCardGroup->GroupName) - .CanEdit(EffectCardGroup->bCanEditName) - .IsNeedUpright(false) - .OnEdited_Raw(this, &SEffectCardGroup::OnNameEdited) + SNew(STextBlock) + .Text(EffectCardGroup->bIsDedicated ? FText::FromString(TEXT("独立特效卡")) : FText::FromString(TEXT("组合特效卡"))) ] .BodyContent() [ SNew(SBorder) .HAlign(HAlign_Fill) .VAlign(VAlign_Fill) - // .ColorAndOpacity(EffectCardGroup->bIsDedicated ? FLinearColor(0.5, 0.5, 0.5, 1) : - // EffectCardGroup->bIsActive ? FLinearColor(1, 0, 0, 1) : FLinearColor(0.5, 0.5, 0.5, 1)) [ SNew(SOverlay) + SOverlay::Slot() @@ -83,7 +80,7 @@ void SEffectCardGroup::Construct(const FArguments& InArgs) { if (EffectCardGroup->bIsDedicated == false) { - const FString Name = FPaths::Combine(FPaths::ProjectSavedDir() + 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); } return FReply::Handled(); @@ -93,12 +90,34 @@ void SEffectCardGroup::Construct(const FArguments& InArgs) ] + SOverlay::Slot() [ - SAssignNew(Contents, SScrollBox) - .Visibility(EVisibility::SelfHitTestInvisible) - + SScrollBox::Slot() + SNew(SVerticalBox) + + SVerticalBox::Slot() + .SizeParam(FAuto()) [ - SAssignNew(GridPanel, SGridPanel) + SNew(SInlineEditableTextBlock) + .Text(FText::FromString(EffectCardGroup->GroupName)) + .OnVerifyTextChanged_Lambda([](const FText& Text, FText& OutErrorMessage) + { + + return true; + }) + .OnTextCommitted_Lambda([this](const FText& Text, ETextCommit::Type CommitType) + { + OnNameEdited(Text.ToString(), TEXT("")); + + }) + .Visibility(EffectCardGroup->bIsDedicated ? EVisibility::Collapsed : EVisibility::Visible) ] + + SVerticalBox::Slot() + [ + SAssignNew(Contents, SScrollBox) + .Visibility(EVisibility::SelfHitTestInvisible) + + SScrollBox::Slot() + [ + SAssignNew(GridPanel, SGridPanel) + ] + ] + ] ] ] @@ -110,6 +129,7 @@ void SEffectCardGroup::Construct(const FArguments& InArgs) void SEffectCardGroup::CallRender() { + GridPanel->ClearChildren(); GridPanel->AddSlot(GridPanel->GetChildren()->Num() % 3, GridPanel->GetChildren()->Num() / 3) [ SNew(SBox) @@ -122,7 +142,7 @@ void SEffectCardGroup::CallRender() // 新建卡牌后 对卡牌进行个体保存。 FEffectCardProperty NewCard; NewCard.Name = TEXT("未命名") + NewCard.Guid.ToString(); - GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Cyan, *FUtils::SingleCardFullPath(NewCard.Name)); + FUtils::CreateDefaultTimelineSave(FUtils::SingleCardFullPath(NewCard.Name), FTimelineInfo::ETimelineType::FX); { FSaveModifier SaveModifier(FUtils::SingleCardFullPath(NewCard.Name)); @@ -133,6 +153,7 @@ void SEffectCardGroup::CallRender() MainInterface->AddNewCard(NewCard, EffectCardGroup->GroupName); return FReply::Handled(); }) + .ContentPadding(10.0) [ SNew(STextBlock) .Text(FText::FromString(TEXT("添加新特效卡"))) @@ -147,6 +168,8 @@ void SEffectCardGroup::CallRender() .CardProperty(&Property) .GroupName(EffectCardGroup->GroupName) .MainInterface(MainInterface) + .GroupProperty(EffectCardGroup) + .CardGroupPtr(this) ]; } diff --git a/Source/Cut5/Widgets/FX/SEffectCardsPanel.cpp b/Source/Cut5/Widgets/FX/SEffectCardsPanel.cpp index 9e640e8..0d130b6 100644 --- a/Source/Cut5/Widgets/FX/SEffectCardsPanel.cpp +++ b/Source/Cut5/Widgets/FX/SEffectCardsPanel.cpp @@ -74,7 +74,7 @@ void SEffectCardsPanel::CallRender() { FEffectCardGroup* Group = AddNewGroup(TEXT("新建组") + FGuid::NewGuid().ToString()); - const FString NewPath = FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName, TEXT("FX"), Group->GroupName + TEXT(".bin")); + const FString NewPath = FPaths::Combine(FGlobalData::BasePath, FGlobalData::CurrentProjectName, TEXT("FX"), Group->GroupName + TEXT(".bin")); FUtils::CreateDefaultTimelineSave(NewPath, FTimelineInfo::ETimelineType::FX); { FSaveModifier SaveModifier(NewPath); @@ -120,6 +120,10 @@ void SEffectCardsPanel::RemoveCard(const FGuid& GUID) { if (Property.Guid == GUID) { + if (Property.bIsActive == true) + { + MainInterface->OpenTimeline(FUtils::MainSaveFullPath()); + } Group.Cards.RemoveAt(i); break; } @@ -199,48 +203,55 @@ void SEffectCardsPanel::SelectCard(const FGuid& Guid) { MainInterface->OpenTimeline(FUtils::MainSaveFullPath()); CurrentSelectedCardGuid.Invalidate(); + DeselectedAll(); CallRender(); } else { + DeselectedAll(); + CurrentSelectedCardGuid = Guid; for (FEffectCardGroup& EffectCardGroup : EffectCardGroups) { if (EffectCardGroup.bIsDedicated) { for (FEffectCardProperty& Property : EffectCardGroup.Cards) { - Property.bIsActive = false; + if (Guid == Property.Guid) + { + Property.bIsActive = true; + } } } else { - EffectCardGroup.bIsActive = false; + if (EffectCardGroup.Guid == Guid) + { + EffectCardGroup.bIsActive = true; + } } } - CurrentSelectedCardGuid = Guid; + CallRender(); } + + +} + +void SEffectCardsPanel::DeselectedAll() +{ for (FEffectCardGroup& EffectCardGroup : EffectCardGroups) { if (EffectCardGroup.bIsDedicated) { for (FEffectCardProperty& Property : EffectCardGroup.Cards) { - if (Guid == Property.Guid) - { - Property.bIsActive = true; - } + Property.bIsActive = false; } } else { - if (EffectCardGroup.Guid == Guid) - { - EffectCardGroup.bIsActive = true; - } + EffectCardGroup.bIsActive = false; } } - CallRender(); - } void SEffectCardsPanel::SavePanel(const FString& Path) diff --git a/Source/Cut5/Widgets/FX/SEffectCardsPanel.h b/Source/Cut5/Widgets/FX/SEffectCardsPanel.h index c17c0f9..0570d6c 100644 --- a/Source/Cut5/Widgets/FX/SEffectCardsPanel.h +++ b/Source/Cut5/Widgets/FX/SEffectCardsPanel.h @@ -86,6 +86,8 @@ public: void SelectCard(const FGuid& Guid); + void DeselectedAll(); + FGuid CurrentSelectedCardGuid; void SavePanel(const FString& Path); diff --git a/Source/Cut5/Widgets/MicroWidgets/STips.cpp b/Source/Cut5/Widgets/MicroWidgets/STips.cpp index cef0bad..edef6b6 100644 --- a/Source/Cut5/Widgets/MicroWidgets/STips.cpp +++ b/Source/Cut5/Widgets/MicroWidgets/STips.cpp @@ -10,6 +10,8 @@ BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION void STips::Construct(const FArguments& InArgs) { + FTextBlockStyle NormalText = FAppStyle::GetWidgetStyle("NormalText"); + NormalText.SetFontSize(20); ChildSlot [ SNew(SOverlay) @@ -41,9 +43,10 @@ void STips::Construct(const FArguments& InArgs) [ SNew(STextBlock) .Text(FText::FromString(InArgs._Title)) + .TextStyle(&NormalText) ] + SVerticalBox::Slot() - .Padding(0, 40, 0, 0) + .Padding(0, 16, 0, 0) .HAlign(HAlign_Center) .VAlign(VAlign_Top) [ @@ -67,13 +70,15 @@ void STips::Construct(const FArguments& InArgs) SNew(SButton) .OnClicked_Lambda([this]() { - + GEngine->GameViewport->RemoveViewportWidgetContent(SharedThis(this)); return FReply::Handled(); }) .ButtonColorAndOpacity(FColor(0, 0,0 ,0)) [ SNew(SOverlay) + SOverlay::Slot() + .HAlign(HAlign_Center) + .VAlign(VAlign_Center) [ SNew(STextBlock) .Text(FText::FromString(TEXT("取消"))) @@ -93,25 +98,26 @@ void STips::Construct(const FArguments& InArgs) return FReply::Handled(); }) + .ButtonColorAndOpacity(FColor(0, 0,0 ,0)) [ SNew(SOverlay) + SOverlay::Slot() + .HAlign(HAlign_Center) + .VAlign(VAlign_Center) [ SNew(STextBlock) .Text(FText::FromString(TEXT("确定"))) .ColorAndOpacity(FSlateColor(FLinearColor(1.0f, 1.0f, 1.0f, 1.0f))) ] - ] ] - ] ] ] ] ] ]; - + } END_SLATE_FUNCTION_BUILD_OPTIMIZATION diff --git a/Source/Cut5/Widgets/SCutMainWindow.cpp b/Source/Cut5/Widgets/SCutMainWindow.cpp index ec0cf78..d435798 100644 --- a/Source/Cut5/Widgets/SCutMainWindow.cpp +++ b/Source/Cut5/Widgets/SCutMainWindow.cpp @@ -312,6 +312,11 @@ void SCutMainWindow::OpenTimeline(const FString& TimelineName, bool NeedSaveBefo { if (CutTimeline->TimelineInfo.CurrentOpenFullPath != FUtils::MainSaveFullPath()) CutTimeline->SaveTimeline(CutTimeline->TimelineInfo.CurrentOpenFullPath, CutTimeline->TimelineInfo); + else + { + CutTimeline->SaveTimeline(FUtils::MainSaveFullPath(), CutTimeline->TimelineInfo); + CutTimeline->TimelineInfo.CurrentOpenFullPath = FUtils::MainSaveFullPath(); + } } } } @@ -329,6 +334,8 @@ void SCutMainWindow::OpenTimeline(const FString& TimelineName, bool NeedSaveBefo void SCutMainWindow::OpenProject(const FString& Project) { + + TArray Data; FFileHelper::LoadFileToArray(Data, *Project); FMemoryReader Reader(Data); @@ -342,6 +349,10 @@ void SCutMainWindow::OpenProject(const FString& Project) FGlobalData::CurrentProjectName = FPaths::GetCleanFilename(Project); FTimelineInfo OpenedInfo; + + FGlobalData::BasePath = Project; + CutTimeline->TimelineInfo.CurrentOpenFullPath = FUtils::MainSaveFullPath(); + CutTimeline->LoadTimeline(FPaths::Combine(Project, FGlobalData::CurrentProjectName + TEXT(".bin")), OpenedInfo); @@ -511,7 +522,7 @@ void SCutMainWindow::ImportProject(const FString& ImportPath) void SCutMainWindow::NewProject(const FString& NewPath) { FGlobalData::BasePath = NewPath; - + CutTimeline->TimelineInfo.CurrentOpenFullPath = FUtils::MainSaveFullPath(); } void SCutMainWindow::OnSelectCard(const FGuid& SelectedCard) @@ -522,6 +533,14 @@ void SCutMainWindow::OnSelectCard(const FGuid& SelectedCard) } } +void SCutMainWindow::OnRemoveCard(const FGuid& SelectedCard) +{ + if (SelectedCard.IsValid()) + { + EffectCardsPanel->RemoveCard(SelectedCard); + } +} + FTimelinePropertyData* SCutMainWindow::GetResourcePropertyDataPtr(FGuid GUID) { diff --git a/Source/Cut5/Widgets/SCutMainWindow.h b/Source/Cut5/Widgets/SCutMainWindow.h index e8f7528..1a578dc 100644 --- a/Source/Cut5/Widgets/SCutMainWindow.h +++ b/Source/Cut5/Widgets/SCutMainWindow.h @@ -59,7 +59,7 @@ public: virtual void ImportProject(const FString& ImportPath) override; virtual void NewProject(const FString& NewPath) override; virtual void OnSelectCard(const FGuid& SelectedCard) override; - + virtual void OnRemoveCard(const FGuid& SelectedCard) override; virtual FTimelinePropertyData* GetResourcePropertyDataPtr(FGuid GUID) override; virtual FString GetGroupName(TSharedPtr WidgetInterface) override; }; diff --git a/Source/Cut5/Widgets/SCutTimeline.cpp b/Source/Cut5/Widgets/SCutTimeline.cpp index f5cdd4e..ea46f83 100644 --- a/Source/Cut5/Widgets/SCutTimeline.cpp +++ b/Source/Cut5/Widgets/SCutTimeline.cpp @@ -410,12 +410,14 @@ void SCutTimeline::SaveTimeline(const FString& SavedPath, FTimelineInfo Info) MemoryWriter << StaticCastSharedPtr(TrackGroupInstances[i].Head)->TrackData; } - FFileHelper::SaveArrayToFile(SavedData, *FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName, SavedPath)); + FString NewSavedPath = FPaths::ConvertRelativePathToFull(SavedPath); + + FFileHelper::SaveArrayToFile(SavedData, *NewSavedPath); } bool SCutTimeline::LoadTimeline(const FString& LoadPath, FTimelineInfo& Info) { - GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString::Printf(TEXT("LoadPath : %s"), *LoadPath)); + TArray LoadData; FPaths::ConvertRelativePathToFull(LoadPath); FFileHelper::LoadFileToArray(LoadData, *LoadPath); diff --git a/Source/Cut5/Widgets/STimelineClip.cpp b/Source/Cut5/Widgets/STimelineClip.cpp index a593f81..1030677 100644 --- a/Source/Cut5/Widgets/STimelineClip.cpp +++ b/Source/Cut5/Widgets/STimelineClip.cpp @@ -44,7 +44,7 @@ FReply STimelineClip::OnBorderMouseButtonDown(const FGeometry& Geometry, const F const FVector2D LocalPos = Geometry.AbsoluteToLocal(PointerEvent.GetScreenSpacePosition()); - // GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Blue, LocalPos.ToString()); + if (LocalPos.X <= 10) { const TSharedPtr Clip2ClipDragDropOperation = MakeShared(); @@ -126,7 +126,7 @@ void STimelineClip::Seek(int32 Frame) AVRational frame_rate = ClipData->ResourcePropertyDataPtr->Context->streams[ClipData->ResourcePropertyDataPtr->VideoStream]->avg_frame_rate; if (av_seek_frame(ClipData->ResourcePropertyDataPtr->Context, ClipData->ResourcePropertyDataPtr->VideoStream, Timestamp, AVSEEK_FLAG_BACKWARD) < 0) { - // GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Blue, TEXT("Seek Failed")); + }; } LastSeekFrame = SeekMovieFrame; @@ -166,7 +166,6 @@ void STimelineClip::Seek(int32 Frame) } av_packet_unref(Packet); - // GEngine->AddOnScreenDebugMessage(-1, 1.00f, FColor::Green, FString::FromInt(AllocatedFrame->best_effort_timestamp)); AVCodecContext* VideoCodecContext = ClipData->ResourcePropertyDataPtr->VideoCodecContext; diff --git a/Source/Cut5/Widgets/STimelinePropertyPanel.cpp b/Source/Cut5/Widgets/STimelinePropertyPanel.cpp index 7867200..7b14b49 100644 --- a/Source/Cut5/Widgets/STimelinePropertyPanel.cpp +++ b/Source/Cut5/Widgets/STimelinePropertyPanel.cpp @@ -44,8 +44,28 @@ void STimelinePropertyPanel::Construct(const FArguments& InArgs) ] + SOverlay::Slot() [ - SNew(STextBlock) - .Text(FText::FromString(TEXT("角色组"))) + SNew(SBox) + .WidthOverride(236) + .HeightOverride(76) + [ + SNew(SOverlay) + + SOverlay::Slot() + .VAlign(VAlign_Center) + .HAlign(HAlign_Center) + [ + SNew(SImage) + ] + + SOverlay::Slot() + .VAlign(VAlign_Bottom) + .HAlign(HAlign_Fill) + [ + SNew(STextBlock) + .Text(FText::FromString(TEXT("角色组"))) + .Justification(ETextJustify::Center) + ] + + ] + ] + SOverlay::Slot() .HAlign(HAlign_Fill) diff --git a/Source/Cut5/Widgets/STrackBody.cpp b/Source/Cut5/Widgets/STrackBody.cpp index 7458f54..0dd5b4c 100644 --- a/Source/Cut5/Widgets/STrackBody.cpp +++ b/Source/Cut5/Widgets/STrackBody.cpp @@ -81,7 +81,7 @@ void STrackBody::CallRender() TimelineClip.ToSharedRef() ]; SlateClips.Add(TimelineClip); - // GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("%f"), TempClipData.ClipEndTime - TempClipData.ClipStartTime)); + } } @@ -143,7 +143,7 @@ void STrackBody::BreakClip(const FGuid& Guid) NewClipData.CropClip(FClipData::ECropMethod::FromFront, SelectedClipFrame + 1); TrackHead->TrackData.ClipData.Add(NewClipData); - // GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Emerald, FString::Printf(TEXT("CropFrameLeft %d CropFrameRight %d"), SelectedClipFrame, CropFrameRight)); + } } CallRender();