分开设备与轨道保存

This commit is contained in:
Sch 2023-08-14 18:45:14 +08:00
parent 4aaeb4323a
commit f64c823cb4
8 changed files with 244 additions and 122 deletions

View File

@ -89,8 +89,17 @@ FSlateDynamicImageBrush* FUtils::GetBrushFromImage(const FString& ImageName, con
void FUtils::CreateDefaultTimelineSave(const FString& SavedPath, const FTimelineInfo::ETimelineType Type) void FUtils::CreateDefaultTimelineSave(const FString& SavedPath, const FTimelineInfo::ETimelineType Type)
{ {
TArray<uint8> SavedData; TArray<uint8> SavedData;
FFileHelper::LoadFileToArray(SavedData, *FPaths::Combine(FPaths::ProjectSavedDir(), Type == FTimelineInfo::ETimelineType::Main ? TEXT("Default.sav") : TEXT("DefaultFX.sav"))); FMemoryWriter MemoryWriter(SavedData);
FTimelineInfo Info = FTimelineInfo();
MemoryWriter << Info;
int32 ClipLength = 0;
TArray<FClipData> AllClips;
MemoryWriter << ClipLength;
MemoryWriter << AllClips;
FFileHelper::SaveArrayToFile(SavedData, *SavedPath); FFileHelper::SaveArrayToFile(SavedData, *SavedPath);
// FFileHelper::LoadFileToArray(SavedData, *FPaths::Combine(FPaths::ProjectSavedDir(), Type == FTimelineInfo::ETimelineType::Main ? TEXT("Default.sav") : TEXT("DefaultFX.sav")));
} }
TArray<FEncodeVideoInfo> FUtils::TrackEncodeVideo(const FTrackData& TrackData, const FString& ExportPath) TArray<FEncodeVideoInfo> FUtils::TrackEncodeVideo(const FTrackData& TrackData, const FString& ExportPath)
@ -475,7 +484,6 @@ FString FUtils::GetMsFromString(FString TimeString)
FSaveModifier::FSaveModifier(const FString& FullSavedPath) FSaveModifier::FSaveModifier(const FString& FullSavedPath)
{ {
this->FullSavedPath = FullSavedPath; this->FullSavedPath = FullSavedPath;
TArray<uint8> LoadData; TArray<uint8> LoadData;
@ -486,17 +494,8 @@ FSaveModifier::FSaveModifier(const FString& FullSavedPath)
} }
FMemoryReader MemoryReader(LoadData); FMemoryReader MemoryReader(LoadData);
MemoryReader << TimelineInfo; MemoryReader << TimelineInfo;
MemoryReader << GroupLength; MemoryReader << ClipDataLength;
GroupName.Init("", GroupLength); MemoryReader << ClipData;
for (int32 i = 0; i < GroupLength; i++)
{
MemoryReader << GroupName[i];
}
TrackData.Init(FTrackData(), GroupLength);
for (int32 i = 0; i < GroupLength; i++)
{
MemoryReader << TrackData[i];
}
} }
FSaveModifier::~FSaveModifier() FSaveModifier::~FSaveModifier()
@ -504,15 +503,8 @@ FSaveModifier::~FSaveModifier()
TArray<uint8> SavedData; TArray<uint8> SavedData;
FMemoryWriter MemoryWriter(SavedData); FMemoryWriter MemoryWriter(SavedData);
MemoryWriter << TimelineInfo; MemoryWriter << TimelineInfo;
MemoryWriter << GroupLength; MemoryWriter << ClipDataLength;
for (int32 i = 0; i < GroupLength; i++) MemoryWriter << ClipData;
{
MemoryWriter << GroupName[i];
}
for (int32 i = 0; i < GroupLength; i++)
{
MemoryWriter << TrackData[i];
}
if (bNewSavePath) if (bNewSavePath)
{ {
FFileHelper::SaveArrayToFile(SavedData, *NewSavePath); FFileHelper::SaveArrayToFile(SavedData, *NewSavePath);

View File

@ -84,9 +84,8 @@ public:
~FSaveModifier(); ~FSaveModifier();
FString FullSavedPath; FString FullSavedPath;
FTimelineInfo TimelineInfo; FTimelineInfo TimelineInfo;
int32 GroupLength = 0; int32 ClipDataLength;
TArray<FString> GroupName; TArray<FClipData> ClipData;
TArray<FTrackData> TrackData;
bool bNewSavePath = false; bool bNewSavePath = false;
FString NewSavePath = ""; FString NewSavePath = "";
}; };

View File

@ -84,8 +84,8 @@ enum class ETrackType
ProjectorTrack, ProjectorTrack,
LightArrayTrack, LightArrayTrack,
LightBarTrack, LightBarTrack,
CustomColorTrack, CustomColorTrack,
DefaultDevice,
None = 255, None = 255,
}; };
@ -101,15 +101,36 @@ enum class EPresetType
}; };
struct FClipData; struct FClipData;
struct FDeviceTrack
{
FDeviceTrack() {};
FDeviceTrack(const FString& Name, ETrackType Type)
{
DeviceName = Name;
DeviceType = Type;
};
FGuid Guid = FGuid::NewGuid();
FString DeviceName = "None";
ETrackType DeviceType = ETrackType::VideoTrack;
struct FDeviceTrackGroup* DeviceTrackGroup = nullptr;
friend FArchive& operator<<(FArchive& Ar, FDeviceTrack& DeviceTrack)
{
Ar << DeviceTrack.Guid;
Ar << DeviceTrack.DeviceName;
Ar << DeviceTrack.DeviceType;
return Ar;
};
};
struct CUT5_API FTrackData struct CUT5_API FTrackData
{ {
FTrackData() FTrackData() {};
{ FTrackData(const FString& Name, ETrackType Type, FDeviceTrack DeviceTrack)
};
FTrackData(const FString& Name, ETrackType Type)
{ {
TrackName = Name; TrackName = Name;
this->DeviceTrack = DeviceTrack;
TrackType = Type; TrackType = Type;
}; };
@ -120,6 +141,7 @@ struct CUT5_API FTrackData
Ar << TrackData.TrackType; Ar << TrackData.TrackType;
Ar << TrackData.TrackNum; Ar << TrackData.TrackNum;
Ar << TrackData.ClipData; Ar << TrackData.ClipData;
Ar << TrackData.DeviceTrack;
return Ar; return Ar;
}; };
@ -128,6 +150,7 @@ struct CUT5_API FTrackData
ETrackType TrackType = ETrackType::VideoTrack; ETrackType TrackType = ETrackType::VideoTrack;
FSlateBrush Brush; FSlateBrush Brush;
int32 TrackNum = 1; int32 TrackNum = 1;
FDeviceTrack DeviceTrack = FDeviceTrack("None", ETrackType::VideoTrack);
TArray<FClipData> ClipData; TArray<FClipData> ClipData;
}; };
struct CUT5_API FCursorData struct CUT5_API FCursorData
@ -165,6 +188,30 @@ struct CUT5_API FPresetsData
} }
}; };
struct FDeviceTrackGroup
{
FGuid Guid = FGuid::NewGuid();
FString GroupName = "None";
ETrackType GroupType = ETrackType::DefaultDevice;
TArray<FDeviceTrack> DeviceTracks;
bool bIsCollapse = false;
friend FArchive& operator<<(FArchive& Ar, FDeviceTrackGroup& DeviceTrackGroup)
{
Ar << DeviceTrackGroup.Guid;
Ar << DeviceTrackGroup.GroupName;
Ar << DeviceTrackGroup.GroupType;
Ar << DeviceTrackGroup.DeviceTracks;
Ar << DeviceTrackGroup.bIsCollapse;
return Ar;
};
};
struct CUT5_API FPresetsCustomData struct CUT5_API FPresetsCustomData
{ {
enum class EPresetCustomType enum class EPresetCustomType
@ -194,10 +241,15 @@ struct CUT5_API FPresetsCustomData
struct CUT5_API FClipData struct CUT5_API FClipData
{ {
FClipData(){};
FClipData(const FDeviceTrack& BindTrack)
{
BindTrackGuid = BindTrack.Guid;
}
friend FArchive& operator<<(FArchive& Ar, FClipData& ClipData) friend FArchive& operator<<(FArchive& Ar, FClipData& ClipData)
{ {
Ar << ClipData.ClipGuid; Ar << ClipData.ClipGuid;
Ar << ClipData.BindTrackGuid;
Ar << ClipData.ClipType; Ar << ClipData.ClipType;
Ar << ClipData.ClipStartFrame; Ar << ClipData.ClipStartFrame;
Ar << ClipData.ClipEndFrame; Ar << ClipData.ClipEndFrame;
@ -217,6 +269,7 @@ struct CUT5_API FClipData
}; };
FGuid ClipGuid; FGuid ClipGuid;
FGuid BindTrackGuid;
ETrackType ClipType; ETrackType ClipType;
UE_DEPRECATED(0.0, "Use int32 instead of float") UE_DEPRECATED(0.0, "Use int32 instead of float")
double ClipStartTime = 0; double ClipStartTime = 0;

View File

@ -169,7 +169,7 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
FClipData NewClipData; FClipData NewClipData(TrackHead->TrackData.DeviceTrack);
NewClipData.PresetType = PresetDragOperation->PresetData.PresetType; NewClipData.PresetType = PresetDragOperation->PresetData.PresetType;
NewClipData.ClipGuid = FGuid::NewGuid(); NewClipData.ClipGuid = FGuid::NewGuid();
NewClipData.ClipType = TrackHead->TrackData.TrackType; NewClipData.ClipType = TrackHead->TrackData.TrackType;
@ -223,7 +223,11 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
NewTrackData.TrackType = CutDragDropBase->TrackType; NewTrackData.TrackType = CutDragDropBase->TrackType;
NewTrackData.TrackName = CutDragDropBase->DeviceName; NewTrackData.TrackName = CutDragDropBase->DeviceName;
CutDragDropBase->MainInterface->GetCutTimeline()->AddNewTrackToGroup(TrackHead->GroupName, NewTrackData); FDeviceTrack NewDeviceTrack;
NewDeviceTrack.DeviceName = CutDragDropBase->DeviceName;
NewDeviceTrack.DeviceType = CutDragDropBase->TrackType;
CutDragDropBase->MainInterface->GetCutTimeline()->AddNewDeviceToGroup(TrackHead->GroupName, NewDeviceTrack);
CutDragDropBase->MainInterface->OnAddNewTrack(ETrackType::PlayerTrack); CutDragDropBase->MainInterface->OnAddNewTrack(ETrackType::PlayerTrack);
return; return;
} }
@ -238,7 +242,7 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
return; return;
FClipData NewClipData; FClipData NewClipData(TrackHead->TrackData.DeviceTrack);
NewClipData.ClipGuid = FGuid::NewGuid(); NewClipData.ClipGuid = FGuid::NewGuid();
ETrackType TrackType = TrackHead->TrackData.TrackType; ETrackType TrackType = TrackHead->TrackData.TrackType;
@ -308,7 +312,7 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
SCutMainWindow* MainWidget = static_cast<SCutMainWindow*>(TrackHead->MainWidgetInterface); SCutMainWindow* MainWidget = static_cast<SCutMainWindow*>(TrackHead->MainWidgetInterface);
if (!MainWidget->CutTimeline->GetTrackGroupByName(TEXT("视频附着"))) if (!MainWidget->CutTimeline->GetTrackGroupByName(TEXT("视频附着")))
{ {
MainWidget->CutTimeline->AddNewTrackToGroup(TEXT("视频附着"), FTrackData(TEXT("附着音频"), ETrackType::AudioTrack)); MainWidget->CutTimeline->AddNewTrackToGroup(TEXT("视频附着"), FTrackData(TEXT("附着音频"), ETrackType::AudioTrack, FDeviceTrack(TEXT("附着音频"), ETrackType::AudioTrack)));
} }
} }

View File

@ -664,6 +664,14 @@ void SCutMainWindow::OpenProject(const FString& Project)
// 记录所有组轨道链接 // 记录所有组轨道链接
int32 GroupTrackNum = 0;
Reader << GroupTrackNum;
for (int32 i = 0; i < GroupTrackNum; i++)
{
Reader << CutTimeline->DeviceTrackGroups[i];
CutTimeline->RenderGroup();
}
EffectCardsPanel->EffectCardGroups.Empty(); EffectCardsPanel->EffectCardGroups.Empty();
int32 GroupLength = 0; int32 GroupLength = 0;
@ -715,17 +723,17 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
tinyxml2::XMLElement* ProjectorList = DeviceList->InsertNewChildElement("ProjectorList"); tinyxml2::XMLElement* ProjectorList = DeviceList->InsertNewChildElement("ProjectorList");
int32 DeviceID = 0; int32 DeviceID = 0;
for (int32 i = 0; i < CutTimeline->TrackGroups.Num(); i++) for (FDeviceTrackGroup& DeviceTrackGroup : CutTimeline->DeviceTrackGroups)
{ {
for (FTrackData& TrackData : CutTimeline->TrackGroups[i].TrackDataArray) for (FDeviceTrack& TrackData : DeviceTrackGroup.DeviceTracks)
{ {
switch (TrackData.TrackType) switch (TrackData.DeviceType)
{ {
case ETrackType::PlayerTrack: case ETrackType::PlayerTrack:
{ {
tinyxml2::XMLElement* PlayerLight = PlayerLightList->InsertNewChildElement("PlayerLight"); tinyxml2::XMLElement* PlayerLight = PlayerLightList->InsertNewChildElement("PlayerLight");
PlayerLight->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(DeviceID))); PlayerLight->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(DeviceID)));
PlayerLight->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.TrackName)); PlayerLight->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.DeviceName));
DeviceID++; DeviceID++;
} }
break; break;
@ -733,7 +741,7 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
{ {
tinyxml2::XMLElement* RotationSpeaker = RoundSpeakerList->InsertNewChildElement("RotationSpeaker"); tinyxml2::XMLElement* RotationSpeaker = RoundSpeakerList->InsertNewChildElement("RotationSpeaker");
RotationSpeaker->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(DeviceID))); RotationSpeaker->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(DeviceID)));
RotationSpeaker->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.TrackName)); RotationSpeaker->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.DeviceName));
DeviceID++; DeviceID++;
} }
break; break;
@ -741,7 +749,7 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
{ {
tinyxml2::XMLElement* LightArray = LightArrayList->InsertNewChildElement("GuangZhen"); tinyxml2::XMLElement* LightArray = LightArrayList->InsertNewChildElement("GuangZhen");
LightArray->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(DeviceID))); LightArray->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(DeviceID)));
LightArray->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.TrackName)); LightArray->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.DeviceName));
DeviceID++; DeviceID++;
} }
break; break;
@ -749,7 +757,7 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
{ {
tinyxml2::XMLElement* Projector = ProjectorList->InsertNewChildElement("Projector"); tinyxml2::XMLElement* Projector = ProjectorList->InsertNewChildElement("Projector");
Projector->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(DeviceID))); Projector->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(DeviceID)));
Projector->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.TrackName)); Projector->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.DeviceName));
DeviceID++; DeviceID++;
} }
break; break;
@ -757,7 +765,7 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
{ {
tinyxml2::XMLElement* DMLight = DMLightList->InsertNewChildElement("DMLight"); tinyxml2::XMLElement* DMLight = DMLightList->InsertNewChildElement("DMLight");
DMLight->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(DeviceID))); DMLight->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(DeviceID)));
DMLight->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.TrackName)); DMLight->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.DeviceName));
DeviceID++; DeviceID++;
} }
default: default:
@ -880,6 +888,13 @@ void SCutMainWindow::SaveProject()
MemoryWriter << CurtainPanel->Groups[i]; MemoryWriter << CurtainPanel->Groups[i];
} }
int32 DeviceGroupLength = CutTimeline->DeviceTrackGroups.Num();
MemoryWriter << DeviceGroupLength;
for (int32 i = 0; i < DeviceGroupLength; i++)
{
MemoryWriter << CutTimeline->DeviceTrackGroups[i];
}
// 记录所有组轨道链接 // 记录所有组轨道链接
int32 GroupLength = EffectCardsPanel->EffectCardGroups.Num(); int32 GroupLength = EffectCardsPanel->EffectCardGroups.Num();

View File

@ -328,22 +328,24 @@ void SCutTimeline::Construct(const FArguments& InArgs)
]; ];
TrackHeadScrollBox->SetScrollBarVisibility(EVisibility::Hidden); TrackHeadScrollBox->SetScrollBarVisibility(EVisibility::Hidden);
TimelineInfo.CurrentOpenFullPath = FUtils::MainSaveFullPath(); TimelineInfo.CurrentOpenFullPath = FUtils::MainSaveFullPath();
// FTrackData AudioDataL(TEXT("音频L"), ETrackType::AudioTrack);
// AddNewTrackToGroup(TEXT("固定轨道"), AudioDataL);
// FTrackData AudioDataR(TEXT("音频R"), ETrackType::AudioTrackR); FDeviceTrack AudioDataL(TEXT("音频L"), ETrackType::AudioTrack);
// AddNewTrackToGroup(TEXT("固定轨道"), AudioDataR); AddNewDeviceToGroup(TEXT("固定轨道"), AudioDataL);
// FTrackData ProjectorData(TEXT("投影仪"), ETrackType::ProjectorTrack); FDeviceTrack AudioDataR(TEXT("音频R"), ETrackType::AudioTrackR);
// AddNewTrackToGroup(TEXT("固定轨道"), ProjectorData); AddNewDeviceToGroup(TEXT("固定轨道"), AudioDataR);
// FTrackData VideoData(TEXT("视频"), ETrackType::VideoTrack); FDeviceTrack ProjectorData(TEXT("投影仪"), ETrackType::ProjectorTrack);
// AddNewTrackToGroup(TEXT("固定轨道"), VideoData); AddNewDeviceToGroup(TEXT("固定轨道"), ProjectorData);
// FTrackData LightArrayData(TEXT("光阵"), ETrackType::LightArrayTrack); FDeviceTrack VideoData(TEXT("视频"), ETrackType::VideoTrack);
// AddNewTrackToGroup(TEXT("固定轨道"), LightArrayData); AddNewDeviceToGroup(TEXT("固定轨道"), VideoData);
// FTrackData LightBarData(TEXT("灯带"), ETrackType::LightBarTrack); FDeviceTrack LightArrayData(TEXT("光阵"), ETrackType::LightArrayTrack);
// AddNewTrackToGroup(TEXT("固定轨道"), LightBarData); AddNewDeviceToGroup(TEXT("固定轨道"), LightArrayData);
// FTrackData LightBarData2(TEXT("灯带2"), ETrackType::LightBarTrack); FDeviceTrack LightBarData(TEXT("灯带"), ETrackType::LightBarTrack);
// AddNewTrackToGroup(TEXT("固定轨道"), LightBarData2); AddNewDeviceToGroup(TEXT("固定轨道"), LightBarData);
// FTrackData SpotLightData(TEXT("聚光灯"), ETrackType::SpotLightTrack); FDeviceTrack LightBarData2(TEXT("灯带2"), ETrackType::LightBarTrack);
// AddNewTrackToGroup(TEXT("固定轨道"), SpotLightData); AddNewDeviceToGroup(TEXT("固定轨道"), LightBarData2);
FDeviceTrack SpotLightData(TEXT("聚光灯"), ETrackType::SpotLightTrack);
AddNewDeviceToGroup(TEXT("固定轨道"), SpotLightData);
} }
void SCutTimeline::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) void SCutTimeline::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
@ -396,27 +398,10 @@ void SCutTimeline::AddNewTrack(FTrackData TrackData, int32 TrackIndex, FString G
void SCutTimeline::AddNewTrackToGroup(FString GroupName, FTrackData TrackData, ETrackType GroupType) void SCutTimeline::AddNewTrackToGroup(FString GroupName, FTrackData TrackData, ETrackType GroupType)
{ {
bool bHasGroup = false;
for (FTrackGroup& Group : TrackGroups)
{
if (Group.GroupName == GroupName)
{
bHasGroup = true;
Group.TrackDataArray.Add(TrackData);
break;
}
}
if (bHasGroup == false)
{
// Add New Group
FTrackGroup NewGroup(GroupName);
NewGroup.TrackDataArray.Add(TrackData);
NewGroup.GroupType = GroupType;
TrackGroups.Add(NewGroup);
}
AddNewTrack(TrackData, 0, GroupName);
RenderGroup(); RenderGroup();
MainWidgetInterface->OnAddNewTrack(GroupType);
} }
@ -465,7 +450,7 @@ void SCutTimeline::RenderGroup()
for (int32 i = 0; i < TrackGroups.Num(); i++) for (int32 i = 0; i < DeviceTrackGroups.Num(); i++)
{ {
// Group Render // Group Render
TrackGroupScrollBox->AddSlot() TrackGroupScrollBox->AddSlot()
@ -473,7 +458,7 @@ void SCutTimeline::RenderGroup()
SNew(SBox) SNew(SBox)
.HAlign(HAlign_Fill) .HAlign(HAlign_Fill)
.VAlign(VAlign_Fill) .VAlign(VAlign_Fill)
.HeightOverride(FGlobalData::DefaultTrackHeight * (TrackGroups[i].GroupIsCollapsed ? 1 : TrackGroups[i].TrackDataArray.Num())) .HeightOverride(FGlobalData::DefaultTrackHeight * (DeviceTrackGroups[i].bIsCollapse ? 1 : DeviceTrackGroups[i].DeviceTracks.Num()))
.WidthOverride(24) .WidthOverride(24)
.Padding(8, 0, 0, 0) .Padding(8, 0, 0, 0)
[ [
@ -489,12 +474,12 @@ void SCutTimeline::RenderGroup()
[ [
SNew(SInlineEditableTextBlock) SNew(SInlineEditableTextBlock)
.Justification(ETextJustify::Center) .Justification(ETextJustify::Center)
.Text(FText::FromString(TrackGroups[i].GroupName)).WrapTextAt(1.0) .Text(FText::FromString(DeviceTrackGroups[i].GroupName)).WrapTextAt(1.0)
.ColorAndOpacity(FColor(0, 0, 0, 255)) .ColorAndOpacity(FColor(0, 0, 0, 255))
.Font(BlackHugeText.Font) .Font(BlackHugeText.Font)
.OnTextCommitted_Lambda([this, i](const FText& NewText, ETextCommit::Type CommitType) .OnTextCommitted_Lambda([this, i](const FText& NewText, ETextCommit::Type CommitType)
{ {
OnGroupNameEdited(NewText.ToString(), TrackGroups[i].GroupName); OnGroupNameEdited(NewText.ToString(), DeviceTrackGroups[i].GroupName);
}) })
] ]
+ SOverlay::Slot() + SOverlay::Slot()
@ -505,14 +490,14 @@ void SCutTimeline::RenderGroup()
SNew(SImage) SNew(SImage)
.OnMouseButtonDown_Lambda([this, i](const FGeometry& Geometry, const FPointerEvent& MouseEvent) .OnMouseButtonDown_Lambda([this, i](const FGeometry& Geometry, const FPointerEvent& MouseEvent)
{ {
if (TrackGroups[i].TrackDataArray.Num() > 1) if (DeviceTrackGroups[i].DeviceTracks.Num() > 1)
{ {
TrackGroups[i].GroupIsCollapsed = !TrackGroups[i].GroupIsCollapsed; DeviceTrackGroups[i].bIsCollapse = !DeviceTrackGroups[i].bIsCollapse;
RenderGroup(); RenderGroup();
} }
return FReply::Handled(); return FReply::Handled();
}) })
.Image(TrackGroups[i].GroupIsCollapsed ? FUtils::GetBrushFromImage(FUtils::GetResourcesPath(TEXT("Expaned.png")), {32, 16}) : FUtils::GetBrushFromImage(FUtils::GetResourcesPath(TEXT("Collapse.png")), {32, 16})) .Image(DeviceTrackGroups[i].bIsCollapse ? FUtils::GetBrushFromImage(FUtils::GetResourcesPath(TEXT("Expaned.png")), {32, 16}) : FUtils::GetBrushFromImage(FUtils::GetResourcesPath(TEXT("Collapse.png")), {32, 16}))
] ]
] ]
]; ];
@ -522,14 +507,14 @@ void SCutTimeline::RenderGroup()
FString LastGroupName; FString LastGroupName;
for (FSingleTrackGroupInstance SingleTrackGroupInstance : TrackGroupInstances) for (FSingleTrackGroupInstance SingleTrackGroupInstance : TrackGroupInstances)
{ {
if (LastGroupName != TrackGroups[i].GroupName) if (LastGroupName != DeviceTrackGroups[i].GroupName)
{ {
TrackIndex = 0; TrackIndex = 0;
} }
if (SingleTrackGroupInstance.GroupName == TrackGroups[i].GroupName) if (SingleTrackGroupInstance.GroupName == DeviceTrackGroups[i].GroupName)
{ {
LastGroupName = SingleTrackGroupInstance.GroupName; LastGroupName = SingleTrackGroupInstance.GroupName;
if (TrackGroups[i].GroupIsCollapsed == true && TrackIndex > 0) if (DeviceTrackGroups[i].bIsCollapse == true && TrackIndex > 0)
{ {
TrackIndex++; TrackIndex++;
continue; continue;
@ -561,17 +546,17 @@ void SCutTimeline::SaveTimeline(const FString& SavedPath, FTimelineInfo Info)
TArray<uint8> SavedData; TArray<uint8> SavedData;
FMemoryWriter MemoryWriter(SavedData); FMemoryWriter MemoryWriter(SavedData);
MemoryWriter << Info; MemoryWriter << Info;
int32 Length = TrackGroupInstances.Num();
MemoryWriter << Length; int32 ClipLength = 0;
for (FSingleTrackGroupInstance& SingleTrackGroupInstance : TrackGroupInstances) TArray<FClipData> AllClips;
{
MemoryWriter << SingleTrackGroupInstance.GroupName;
}
for (int32 i = 0; i < TrackGroupInstances.Num(); i++) for (int32 i = 0; i < TrackGroupInstances.Num(); i++)
{ {
MemoryWriter << StaticCastSharedPtr<STrackHead>(TrackGroupInstances[i].Head)->TrackData; ClipLength += StaticCastSharedPtr<STrackHead>(TrackGroupInstances[i].Head)->TrackData.ClipData.Num();
AllClips.Append(StaticCastSharedPtr<STrackHead>(TrackGroupInstances[i].Head)->TrackData.ClipData);
} }
MemoryWriter << ClipLength;
MemoryWriter << AllClips;
FString NewSavedPath = FPaths::ConvertRelativePathToFull(SavedPath); FString NewSavedPath = FPaths::ConvertRelativePathToFull(SavedPath);
FFileHelper::SaveArrayToFile(SavedData, *NewSavedPath); FFileHelper::SaveArrayToFile(SavedData, *NewSavedPath);
@ -589,30 +574,67 @@ bool SCutTimeline::LoadTimeline(const FString& LoadPath, FTimelineInfo& Info)
} }
FMemoryReader MemoryReader(LoadData); FMemoryReader MemoryReader(LoadData);
TrackGroupInstances.Empty();
TrackGroups.Empty(); TrackGroups.Empty();
for (int32 l = 0; l < TrackGroupInstances.Num(); l++)
{
StaticCastSharedPtr<STrackHead>(TrackGroupInstances[l].Head)->TrackData.ClipData.Empty();
}
RenderGroup(); RenderGroup();
MemoryReader << Info; MemoryReader << Info;
int32 Length = 0;
MemoryReader << Length; int32 ClipLength = 0;
TArray<FString> GroupName; MemoryReader << ClipLength;
GroupName.Init("", Length); TArray<FClipData> AllClips;
for (int32 i = 0; i < Length; i++) MemoryReader << AllClips;
for (int32 i = 0; i < AllClips.Num(); i++)
{ {
MemoryReader << GroupName[i]; AllClips[i].ResourcePropertyDataPtr = MainWidgetInterface->GetResourcePropertyDataPtr(AllClips[i].ResourcePropertyGuid);
} for (int32 j = 0; j < DeviceTrackGroups.Num(); j++)
for (int32 i = 0; i < Length; i++)
{
FTrackData TrackData;
MemoryReader << TrackData;
for (FClipData& ClipData : TrackData.ClipData)
{ {
ClipData.ResourcePropertyDataPtr = MainWidgetInterface->GetResourcePropertyDataPtr(ClipData.ResourcePropertyGuid); for (int32 k = 0; k < DeviceTrackGroups[j].DeviceTracks.Num(); k++)
{
if (AllClips[i].BindTrackGuid == DeviceTrackGroups[j].DeviceTracks[k].Guid)
{
for (int32 l = 0; l < TrackGroupInstances.Num(); l++)
{
if (StaticCastSharedPtr<STrackHead>(TrackGroupInstances[l].Head)->TrackData.DeviceTrack.Guid == DeviceTrackGroups[j].DeviceTracks[k].Guid)
{
StaticCastSharedPtr<STrackHead>(TrackGroupInstances[l].Head)->TrackData.ClipData.Add(AllClips[i]);
}
}
}
}
} }
AddNewTrackToGroup(GroupName[i], TrackData);
} }
RenderGroup();
// int32 Length = 0;
// MemoryReader << Length;
// TArray<FString> GroupName;
// GroupName.Init("", Length);
// for (int32 i = 0; i < Length; i++)
// {
// MemoryReader << GroupName[i];
// }
// for (int32 i = 0; i < Length; i++)
// {
// FTrackData TrackData;
// MemoryReader << TrackData;
// for (FClipData& ClipData : TrackData.ClipData)
// {
// ClipData.ResourcePropertyDataPtr = MainWidgetInterface->GetResourcePropertyDataPtr(ClipData.ResourcePropertyGuid);
// }
// AddNewTrackToGroup(GroupName[i], TrackData);
// }
return true; return true;
} }
@ -620,11 +642,11 @@ void SCutTimeline::RemoveTrack(const FGuid& TrackGuid)
{ {
for (int32 i = 0; i < TrackGroups.Num(); i++) for (int32 i = 0; i < TrackGroups.Num(); i++)
{ {
for (int32 j = TrackGroups[i].TrackDataArray.Num() - 1; j >= 0; --j) for (int32 j = DeviceTrackGroups.Num() - 1; j >= 0; --j)
{ {
if (TrackGroups[i].TrackDataArray[j].Guid == TrackGuid) if (DeviceTrackGroups[i].DeviceTracks[j].Guid == TrackGuid)
{ {
TrackGroups[i].TrackDataArray.RemoveAt(j); DeviceTrackGroups[i].DeviceTracks.RemoveAt(j);
break; break;
} }
} }
@ -659,5 +681,34 @@ FReply SCutTimeline::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& D
return SCompoundWidget::OnDrop(MyGeometry, DragDropEvent); return SCompoundWidget::OnDrop(MyGeometry, DragDropEvent);
} }
void SCutTimeline::AddNewDeviceToGroup(FString GroupName, FDeviceTrack DeviceTrack, ETrackType GroupTrack)
{
bool bIsFind = false;
for (FDeviceTrackGroup& DeviceTrackGroup : DeviceTrackGroups)
{
if (DeviceTrackGroup.GroupName == GroupName)
{
DeviceTrack.DeviceTrackGroup = &DeviceTrackGroup;
DeviceTrackGroup.DeviceTracks.Add(DeviceTrack);
bIsFind = true;
}
}
if (bIsFind != true)
{
FDeviceTrackGroup NewDeviceTrackGroup;
NewDeviceTrackGroup.DeviceTracks.Add(DeviceTrack);
NewDeviceTrackGroup.GroupName = GroupName;
NewDeviceTrackGroup.GroupType = GroupTrack;
DeviceTrackGroups.Add(NewDeviceTrackGroup);
DeviceTrack.DeviceTrackGroup = DeviceTrackGroups.GetData() + DeviceTrackGroups.Num() - 1;
}
FTrackData TrackData;
TrackData.TrackName = DeviceTrack.DeviceName;
TrackData.TrackType = DeviceTrack.DeviceType;
TrackData.DeviceTrack = DeviceTrack;
AddNewTrack(TrackData, 0, GroupName);
RenderGroup();
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -18,6 +18,7 @@
*/ */
struct FTrackGroup struct FTrackGroup
{ {
// TrackGroup Mean Device
FTrackGroup(FString InGroupName) FTrackGroup(FString InGroupName)
{ {
GroupName = InGroupName; GroupName = InGroupName;
@ -25,7 +26,7 @@ struct FTrackGroup
FString GroupName = ""; FString GroupName = "";
ETrackType GroupType = ETrackType::None; ETrackType GroupType = ETrackType::None;
bool GroupIsCollapsed = false; bool GroupIsCollapsed = false;
TArray<FTrackData> TrackDataArray;
}; };
struct FSingleTrackGroupInstance struct FSingleTrackGroupInstance
@ -112,4 +113,10 @@ public:
TSharedPtr<STextBlock> CurrentTimeData; TSharedPtr<STextBlock> CurrentTimeData;
TSharedPtr<STextBlock> MaxTimeData; TSharedPtr<STextBlock> MaxTimeData;
virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
TArray<FDeviceTrackGroup> DeviceTrackGroups;
void AddNewDeviceToGroup(FString GroupName, FDeviceTrack DeviceTrack, ETrackType GroupTrack = ETrackType::None);
}; };

View File

@ -54,24 +54,25 @@ void STimelinePropertyPanel::Construct(const FArguments& InArgs)
SNew(SButton) SNew(SButton)
.OnClicked_Lambda([this]() .OnClicked_Lambda([this]()
{ {
if (MainWindow->CutTimeline->TrackGroups.FindByPredicate([](const FTrackGroup& TrackGroup) if (MainWindow->CutTimeline->DeviceTrackGroups.FindByPredicate([](const FDeviceTrackGroup& TrackGroup)
{ {
return TrackGroup.GroupName == TEXT("未命名"); return TrackGroup.GroupName == TEXT("未命名");
})) }))
{ {
return FReply::Handled(); return FReply::Handled();
} }
const FTrackData PlayerData(TEXT("玩家"), ETrackType::AtomSphereLightTrack); const FTrackData PlayerData(TEXT("玩家"), ETrackType::AtomSphereLightTrack, FDeviceTrack(TEXT("玩家"), ETrackType::AtomSphereLightTrack));
// 遍历一下,检查出有多少个组里包含 角色组 三个字,然后按照当前得到的序号继续往后排序 // 遍历一下,检查出有多少个组里包含 角色组 三个字,然后按照当前得到的序号继续往后排序
int32 Index = 0; int32 Index = 0;
for (const FTrackGroup& TrackGroup : MainWindow->CutTimeline->TrackGroups) for (const FDeviceTrackGroup& TrackGroup : MainWindow->CutTimeline->DeviceTrackGroups)
{ {
if (TrackGroup.GroupName.Contains(TEXT("角色组"))) if (TrackGroup.GroupName.Contains(TEXT("角色组")))
{ {
Index++; Index++;
} }
} }
MainWindow->CutTimeline->AddNewTrackToGroup(TEXT("角色组") + FString::FromInt(Index), PlayerData, ETrackType::PlayerTrack); FDeviceTrack DeviceTrack(TEXT("玩家"), ETrackType::AtomSphereLightTrack);
MainWindow->CutTimeline->AddNewDeviceToGroup(TEXT("角色组") + FString::FromInt(Index), DeviceTrack, ETrackType::PlayerTrack);
return FReply::Handled(); return FReply::Handled();
}) })
] ]