This commit is contained in:
Sch 2023-08-01 10:04:57 +08:00
parent f859840d7b
commit b8a2cbd287
12 changed files with 96 additions and 25 deletions

Binary file not shown.

View File

@ -26,16 +26,7 @@
</Projector>
</ProjectorList>
</DeviceList>
<CardList>
<Card>
<ID>0</ID>
<Type>0</Type>
<Times/>
<Step/>
<SpecialEffectID/>
<SerialNumberList/>
</Card>
</CardList>
<CardList/>
<KeyBoard/>
<ProcessList>
<ProcessA>

View File

@ -24,6 +24,7 @@ public:
inline static float CurrentTimeScroll = 0.0f;
inline static float GlobalFPS = 30.0f;
inline static FString CurrentProjectName = "DefaultProject";
inline static FString BasePath = "";
static int32 GetAlignOfTickSpace(double Align, bool bCeil = false)
{
return bCeil ? FMath::CeilToInt(Align / FGlobalData::DefaultTimeTickSpace) * FGlobalData::DefaultTimeTickSpace :

View File

@ -2,6 +2,7 @@
#include "Cut5/Utils/OpencvUtils.h"
#include "Cut5/Widgets/DefineGlobal.h"
#include "Cut5/Widgets/SCutMainWindow.h"
#include "Cut5/Widgets/STimelineClip.h"
#include "Cut5/Widgets/STrackBody.h"
@ -60,12 +61,14 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
if (ClipDragOperation.TimelinePropertyData->Type != TrackHead->TrackData.TrackType)
{
if ((ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::LightArrayTrack)
|| (ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::PlayerTrack))
|| (ClipDragOperation.TimelinePropertyData->Type == ETrackType::VideoTrack && TrackHead->TrackData.TrackType == ETrackType::PlayerTrack)
|| (ClipDragOperation.TimelinePropertyData->Type == ETrackType::AudioTrack && TrackHead->TrackData.TrackType == ETrackType::AudioTrackR))
{
}
else
{
return;
}
}
FClipData NewClipData;
@ -92,6 +95,15 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
NewClipData.PlayerName = TrackBody->MainWidgetInterface->GetGroupName(TrackHead);
NewClipData.PlayerLightData = FOpencvUtils::GetVideoSingleLightColor(ClipDragOperation.TimelinePropertyData->MoviePath);
}
if (TrackHead->TrackData.TrackType == ETrackType::VideoTrack)
{
SCutMainWindow* MainWidget = static_cast<SCutMainWindow*>(TrackHead->MainWidgetInterface);
if (!MainWidget->CutTimeline->GetTrackGroupByName(TEXT("视频附着")))
{
MainWidget->CutTimeline->AddNewTrackToGroup(TEXT("视频附着"), FTrackData(TEXT("附着音频"), ETrackType::AudioTrack));
}
}
}
else if (ClipDragOperation.TimelinePropertyData->Type == ETrackType::LightArrayTrack)
{

View File

@ -243,4 +243,41 @@ void SEffectCardsPanel::SelectCard(const FGuid& Guid)
}
void SEffectCardsPanel::SavePanel(const FString& Path)
{
TArray<uint8> Data;
FMemoryWriter MemoryWriter(Data);
int32 GroupLength = EffectCardGroups.Num();
MemoryWriter << GroupLength;
for (FEffectCardGroup& Group : EffectCardGroups)
{
for (FEffectCardProperty& Property : Group.Cards)
{
FString Target = Property.TimelineInfo.CurrentOpenFullPath;
FPaths::CollapseRelativeDirectories(Target);
IFileManager::Get().Move(*FPaths::Combine(Path, Target), *Property.TimelineInfo.CurrentOpenFullPath);
}
MemoryWriter << Group;
}
FFileHelper::SaveArrayToFile(Data, *Path);
}
void SEffectCardsPanel::LoadPanel(const FString& Path)
{
EffectCardGroups.Empty();
TArray<uint8> Data;
FFileHelper::LoadFileToArray(Data, *Path);
FMemoryReader MemoryReader(Data);
int32 GroupLength = 0;
MemoryReader << GroupLength;
for (int32 i = 0; i < GroupLength; i++)
{
FEffectCardGroup Group;
MemoryReader << Group;
EffectCardGroups.Add(Group);
}
CallRender();
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -87,5 +87,9 @@ public:
void SelectCard(const FGuid& Guid);
FGuid CurrentSelectedCardGuid;
void SavePanel(const FString& Path);
void LoadPanel(const FString& Path);
};

View File

@ -164,8 +164,8 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
SoundThread = new FSoundThread();
FRunnableThread* Thread = FRunnableThread::Create(SoundThread, TEXT("SoundThread"));
OpenProject(FPaths::Combine(FPaths::ProjectSavedDir(), TEXT("DefaultProject")));
// OpenProject(FPaths::Combine(FPaths::ProjectSavedDir(), TEXT("DefaultProject")));
ImportProject("");
}
@ -328,9 +328,22 @@ void SCutMainWindow::OpenTimeline(const FString& TimelineName, bool NeedSaveBefo
void SCutMainWindow::OpenProject(const FString& Project)
{
TArray<uint8> Data;
FFileHelper::LoadFileToArray(Data, *Project);
FMemoryReader Reader(Data);
FString CustomPanelInputPath = "";
Reader << CustomPanelInputPath;
CustomInputPanel->LoadPanel(CustomPanelInputPath);
FString FXPath = "";
Reader << FXPath;
EffectCardsPanel->LoadPanel(FXPath);
FGlobalData::CurrentProjectName = FPaths::GetCleanFilename(Project);
FTimelineInfo OpenedInfo;
CutTimeline->LoadTimeline(FPaths::Combine(Project, FGlobalData::CurrentProjectName + TEXT(".bin")), OpenedInfo);
}
void SCutMainWindow::ExportProject(const FString& ExportPath)
@ -338,14 +351,17 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
// Save Project Link
TArray<uint8> Data {0};
FMemoryWriter MemoryWriter(Data);
FString CustomInputPanelSavePath = ExportPath + "/" + FGlobalData::CurrentProjectName + "/Dataset/" + TEXT("CustomInputPanel.bin");
FString CustomInputPanelSavePath = ExportPath + "/" + FGlobalData::CurrentProjectName + "/Dataset/" + TEXT("CustomInputPanel.bin");
MemoryWriter << CustomInputPanelSavePath;
CustomInputPanel->SavePanel(CustomInputPanelSavePath);
FString FXPath = ExportPath + "/" + FGlobalData::CurrentProjectName + "/Dataset/" + TEXT("FX.bin");
MemoryWriter << FXPath;
EffectCardsPanel->SavePanel(FXPath);
FFileHelper::SaveArrayToFile(Data, *FPaths::Combine(ExportPath, *FGlobalData::CurrentProjectName, FGlobalData::CurrentProjectName + TEXT("_Link.cutlink")));
FFileHelper::SaveArrayToFile(Data, *(ExportPath + "/" + FGlobalData::CurrentProjectName + "/" + FGlobalData::CurrentProjectName + TEXT("_Link.cutlink")));
if (ExportPath.IsEmpty())
return;
tinyxml2::XMLDocument Document;
@ -422,6 +438,7 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
Card->InsertNewChildElement("Step");
Card->InsertNewChildElement("SpecialEffectID");
Card->InsertNewChildElement("SerialNumberList");
ID++;
}
}
@ -482,12 +499,7 @@ void SCutMainWindow::ImportProject(const FString& ImportPath)
IFileManager::Get().FindFiles(Files, *OutFolderNames, TEXT("cutlink"));
if (Files.Num() != 0)
{
TArray<uint8> Data;
FFileHelper::LoadFileToArray(Data, *(OutFolderNames + "/" + Files[0]));
FMemoryReader Reader(Data);
FString CustomPanelInputPath = "";
Reader << CustomPanelInputPath;
CustomInputPanel->LoadPanel(CustomPanelInputPath);
OpenProject(*(OutFolderNames + "/" + Files[0]));
}
}
}

View File

@ -409,6 +409,7 @@ void SCutTimeline::SaveTimeline(const FString& SavedPath, FTimelineInfo Info)
{
MemoryWriter << StaticCastSharedPtr<STrackHead>(TrackGroupInstances[i].Head)->TrackData;
}
FFileHelper::SaveArrayToFile(SavedData, *FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName, SavedPath));
}
@ -480,6 +481,17 @@ void SCutTimeline::RemoveTrack(const FGuid& TrackGuid)
MainWidgetInterface->OnRemoveTrack(TrackGuid);
}
FTrackGroup* SCutTimeline::GetTrackGroupByName(FString GroupName)
{
for (FTrackGroup& TrackGroup : TrackGroups)
{
if (TrackGroup.GroupName == GroupName)
{
return &TrackGroup;
}
}
return nullptr;
}
FReply SCutTimeline::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)

View File

@ -86,6 +86,8 @@ public:
void RemoveTrack(const FGuid& FGuid);
FTrackGroup* GetTrackGroupByName(FString GroupName);
ICutMainWidgetInterface* MainWidgetInterface;

View File

@ -84,7 +84,7 @@ void STrackHead::Construct(const FArguments& InArgs)
FReply STrackHead::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
CutTimeline->RemoveTrack(TrackData.Guid);
// CutTimeline->RemoveTrack(TrackData.Guid);
return FReply::Unhandled();
}