分开设备与轨道保存
This commit is contained in:
parent
4aaeb4323a
commit
f64c823cb4
@ -89,8 +89,17 @@ FSlateDynamicImageBrush* FUtils::GetBrushFromImage(const FString& ImageName, con
|
||||
void FUtils::CreateDefaultTimelineSave(const FString& SavedPath, const FTimelineInfo::ETimelineType Type)
|
||||
{
|
||||
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::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)
|
||||
@ -475,7 +484,6 @@ FString FUtils::GetMsFromString(FString TimeString)
|
||||
|
||||
FSaveModifier::FSaveModifier(const FString& FullSavedPath)
|
||||
{
|
||||
|
||||
this->FullSavedPath = FullSavedPath;
|
||||
TArray<uint8> LoadData;
|
||||
|
||||
@ -486,17 +494,8 @@ FSaveModifier::FSaveModifier(const FString& FullSavedPath)
|
||||
}
|
||||
FMemoryReader MemoryReader(LoadData);
|
||||
MemoryReader << TimelineInfo;
|
||||
MemoryReader << GroupLength;
|
||||
GroupName.Init("", GroupLength);
|
||||
for (int32 i = 0; i < GroupLength; i++)
|
||||
{
|
||||
MemoryReader << GroupName[i];
|
||||
}
|
||||
TrackData.Init(FTrackData(), GroupLength);
|
||||
for (int32 i = 0; i < GroupLength; i++)
|
||||
{
|
||||
MemoryReader << TrackData[i];
|
||||
}
|
||||
MemoryReader << ClipDataLength;
|
||||
MemoryReader << ClipData;
|
||||
}
|
||||
|
||||
FSaveModifier::~FSaveModifier()
|
||||
@ -504,15 +503,8 @@ FSaveModifier::~FSaveModifier()
|
||||
TArray<uint8> SavedData;
|
||||
FMemoryWriter MemoryWriter(SavedData);
|
||||
MemoryWriter << TimelineInfo;
|
||||
MemoryWriter << GroupLength;
|
||||
for (int32 i = 0; i < GroupLength; i++)
|
||||
{
|
||||
MemoryWriter << GroupName[i];
|
||||
}
|
||||
for (int32 i = 0; i < GroupLength; i++)
|
||||
{
|
||||
MemoryWriter << TrackData[i];
|
||||
}
|
||||
MemoryWriter << ClipDataLength;
|
||||
MemoryWriter << ClipData;
|
||||
if (bNewSavePath)
|
||||
{
|
||||
FFileHelper::SaveArrayToFile(SavedData, *NewSavePath);
|
||||
|
@ -84,9 +84,8 @@ public:
|
||||
~FSaveModifier();
|
||||
FString FullSavedPath;
|
||||
FTimelineInfo TimelineInfo;
|
||||
int32 GroupLength = 0;
|
||||
TArray<FString> GroupName;
|
||||
TArray<FTrackData> TrackData;
|
||||
int32 ClipDataLength;
|
||||
TArray<FClipData> ClipData;
|
||||
bool bNewSavePath = false;
|
||||
FString NewSavePath = "";
|
||||
};
|
||||
|
@ -84,8 +84,8 @@ enum class ETrackType
|
||||
ProjectorTrack,
|
||||
LightArrayTrack,
|
||||
LightBarTrack,
|
||||
|
||||
CustomColorTrack,
|
||||
DefaultDevice,
|
||||
None = 255,
|
||||
};
|
||||
|
||||
@ -101,15 +101,36 @@ enum class EPresetType
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
FTrackData()
|
||||
{
|
||||
|
||||
};
|
||||
FTrackData(const FString& Name, ETrackType Type)
|
||||
FTrackData() {};
|
||||
FTrackData(const FString& Name, ETrackType Type, FDeviceTrack DeviceTrack)
|
||||
{
|
||||
TrackName = Name;
|
||||
this->DeviceTrack = DeviceTrack;
|
||||
TrackType = Type;
|
||||
};
|
||||
|
||||
@ -120,6 +141,7 @@ struct CUT5_API FTrackData
|
||||
Ar << TrackData.TrackType;
|
||||
Ar << TrackData.TrackNum;
|
||||
Ar << TrackData.ClipData;
|
||||
Ar << TrackData.DeviceTrack;
|
||||
return Ar;
|
||||
};
|
||||
|
||||
@ -128,6 +150,7 @@ struct CUT5_API FTrackData
|
||||
ETrackType TrackType = ETrackType::VideoTrack;
|
||||
FSlateBrush Brush;
|
||||
int32 TrackNum = 1;
|
||||
FDeviceTrack DeviceTrack = FDeviceTrack("None", ETrackType::VideoTrack);
|
||||
TArray<FClipData> ClipData;
|
||||
};
|
||||
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
|
||||
{
|
||||
enum class EPresetCustomType
|
||||
@ -194,10 +241,15 @@ struct CUT5_API FPresetsCustomData
|
||||
|
||||
struct CUT5_API FClipData
|
||||
{
|
||||
|
||||
FClipData(){};
|
||||
FClipData(const FDeviceTrack& BindTrack)
|
||||
{
|
||||
BindTrackGuid = BindTrack.Guid;
|
||||
}
|
||||
friend FArchive& operator<<(FArchive& Ar, FClipData& ClipData)
|
||||
{
|
||||
Ar << ClipData.ClipGuid;
|
||||
Ar << ClipData.BindTrackGuid;
|
||||
Ar << ClipData.ClipType;
|
||||
Ar << ClipData.ClipStartFrame;
|
||||
Ar << ClipData.ClipEndFrame;
|
||||
@ -217,6 +269,7 @@ struct CUT5_API FClipData
|
||||
};
|
||||
|
||||
FGuid ClipGuid;
|
||||
FGuid BindTrackGuid;
|
||||
ETrackType ClipType;
|
||||
UE_DEPRECATED(0.0, "Use int32 instead of float")
|
||||
double ClipStartTime = 0;
|
||||
|
@ -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.ClipGuid = FGuid::NewGuid();
|
||||
NewClipData.ClipType = TrackHead->TrackData.TrackType;
|
||||
@ -223,7 +223,11 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
|
||||
NewTrackData.TrackType = CutDragDropBase->TrackType;
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@ -238,7 +242,7 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
|
||||
return;
|
||||
|
||||
|
||||
FClipData NewClipData;
|
||||
FClipData NewClipData(TrackHead->TrackData.DeviceTrack);
|
||||
NewClipData.ClipGuid = FGuid::NewGuid();
|
||||
|
||||
ETrackType TrackType = TrackHead->TrackData.TrackType;
|
||||
@ -308,7 +312,7 @@ void DragDropOperator::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
|
||||
SCutMainWindow* MainWidget = static_cast<SCutMainWindow*>(TrackHead->MainWidgetInterface);
|
||||
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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
int32 GroupLength = 0;
|
||||
@ -715,17 +723,17 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
|
||||
tinyxml2::XMLElement* ProjectorList = DeviceList->InsertNewChildElement("ProjectorList");
|
||||
|
||||
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:
|
||||
{
|
||||
tinyxml2::XMLElement* PlayerLight = PlayerLightList->InsertNewChildElement("PlayerLight");
|
||||
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++;
|
||||
}
|
||||
break;
|
||||
@ -733,7 +741,7 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
|
||||
{
|
||||
tinyxml2::XMLElement* RotationSpeaker = RoundSpeakerList->InsertNewChildElement("RotationSpeaker");
|
||||
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++;
|
||||
}
|
||||
break;
|
||||
@ -741,7 +749,7 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
|
||||
{
|
||||
tinyxml2::XMLElement* LightArray = LightArrayList->InsertNewChildElement("GuangZhen");
|
||||
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++;
|
||||
}
|
||||
break;
|
||||
@ -749,7 +757,7 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
|
||||
{
|
||||
tinyxml2::XMLElement* Projector = ProjectorList->InsertNewChildElement("Projector");
|
||||
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++;
|
||||
}
|
||||
break;
|
||||
@ -757,7 +765,7 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
|
||||
{
|
||||
tinyxml2::XMLElement* DMLight = DMLightList->InsertNewChildElement("DMLight");
|
||||
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++;
|
||||
}
|
||||
default:
|
||||
@ -880,6 +888,13 @@ void SCutMainWindow::SaveProject()
|
||||
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();
|
||||
|
@ -328,22 +328,24 @@ void SCutTimeline::Construct(const FArguments& InArgs)
|
||||
];
|
||||
TrackHeadScrollBox->SetScrollBarVisibility(EVisibility::Hidden);
|
||||
TimelineInfo.CurrentOpenFullPath = FUtils::MainSaveFullPath();
|
||||
// FTrackData AudioDataL(TEXT("音频L"), ETrackType::AudioTrack);
|
||||
// AddNewTrackToGroup(TEXT("固定轨道"), AudioDataL);
|
||||
// FTrackData AudioDataR(TEXT("音频R"), ETrackType::AudioTrackR);
|
||||
// AddNewTrackToGroup(TEXT("固定轨道"), AudioDataR);
|
||||
// FTrackData ProjectorData(TEXT("投影仪"), ETrackType::ProjectorTrack);
|
||||
// AddNewTrackToGroup(TEXT("固定轨道"), ProjectorData);
|
||||
// FTrackData VideoData(TEXT("视频"), ETrackType::VideoTrack);
|
||||
// AddNewTrackToGroup(TEXT("固定轨道"), VideoData);
|
||||
// FTrackData LightArrayData(TEXT("光阵"), ETrackType::LightArrayTrack);
|
||||
// AddNewTrackToGroup(TEXT("固定轨道"), LightArrayData);
|
||||
// FTrackData LightBarData(TEXT("灯带"), ETrackType::LightBarTrack);
|
||||
// AddNewTrackToGroup(TEXT("固定轨道"), LightBarData);
|
||||
// FTrackData LightBarData2(TEXT("灯带2"), ETrackType::LightBarTrack);
|
||||
// AddNewTrackToGroup(TEXT("固定轨道"), LightBarData2);
|
||||
// FTrackData SpotLightData(TEXT("聚光灯"), ETrackType::SpotLightTrack);
|
||||
// AddNewTrackToGroup(TEXT("固定轨道"), SpotLightData);
|
||||
|
||||
|
||||
FDeviceTrack AudioDataL(TEXT("音频L"), ETrackType::AudioTrack);
|
||||
AddNewDeviceToGroup(TEXT("固定轨道"), AudioDataL);
|
||||
FDeviceTrack AudioDataR(TEXT("音频R"), ETrackType::AudioTrackR);
|
||||
AddNewDeviceToGroup(TEXT("固定轨道"), AudioDataR);
|
||||
FDeviceTrack ProjectorData(TEXT("投影仪"), ETrackType::ProjectorTrack);
|
||||
AddNewDeviceToGroup(TEXT("固定轨道"), ProjectorData);
|
||||
FDeviceTrack VideoData(TEXT("视频"), ETrackType::VideoTrack);
|
||||
AddNewDeviceToGroup(TEXT("固定轨道"), VideoData);
|
||||
FDeviceTrack LightArrayData(TEXT("光阵"), ETrackType::LightArrayTrack);
|
||||
AddNewDeviceToGroup(TEXT("固定轨道"), LightArrayData);
|
||||
FDeviceTrack LightBarData(TEXT("灯带"), ETrackType::LightBarTrack);
|
||||
AddNewDeviceToGroup(TEXT("固定轨道"), LightBarData);
|
||||
FDeviceTrack LightBarData2(TEXT("灯带2"), ETrackType::LightBarTrack);
|
||||
AddNewDeviceToGroup(TEXT("固定轨道"), LightBarData2);
|
||||
FDeviceTrack SpotLightData(TEXT("聚光灯"), ETrackType::SpotLightTrack);
|
||||
AddNewDeviceToGroup(TEXT("固定轨道"), SpotLightData);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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();
|
||||
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
|
||||
TrackGroupScrollBox->AddSlot()
|
||||
@ -473,7 +458,7 @@ void SCutTimeline::RenderGroup()
|
||||
SNew(SBox)
|
||||
.HAlign(HAlign_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)
|
||||
.Padding(8, 0, 0, 0)
|
||||
[
|
||||
@ -489,12 +474,12 @@ void SCutTimeline::RenderGroup()
|
||||
[
|
||||
SNew(SInlineEditableTextBlock)
|
||||
.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))
|
||||
.Font(BlackHugeText.Font)
|
||||
.OnTextCommitted_Lambda([this, i](const FText& NewText, ETextCommit::Type CommitType)
|
||||
{
|
||||
OnGroupNameEdited(NewText.ToString(), TrackGroups[i].GroupName);
|
||||
OnGroupNameEdited(NewText.ToString(), DeviceTrackGroups[i].GroupName);
|
||||
})
|
||||
]
|
||||
+ SOverlay::Slot()
|
||||
@ -505,14 +490,14 @@ void SCutTimeline::RenderGroup()
|
||||
SNew(SImage)
|
||||
.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();
|
||||
}
|
||||
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;
|
||||
for (FSingleTrackGroupInstance SingleTrackGroupInstance : TrackGroupInstances)
|
||||
{
|
||||
if (LastGroupName != TrackGroups[i].GroupName)
|
||||
if (LastGroupName != DeviceTrackGroups[i].GroupName)
|
||||
{
|
||||
TrackIndex = 0;
|
||||
}
|
||||
if (SingleTrackGroupInstance.GroupName == TrackGroups[i].GroupName)
|
||||
if (SingleTrackGroupInstance.GroupName == DeviceTrackGroups[i].GroupName)
|
||||
{
|
||||
LastGroupName = SingleTrackGroupInstance.GroupName;
|
||||
if (TrackGroups[i].GroupIsCollapsed == true && TrackIndex > 0)
|
||||
if (DeviceTrackGroups[i].bIsCollapse == true && TrackIndex > 0)
|
||||
{
|
||||
TrackIndex++;
|
||||
continue;
|
||||
@ -561,17 +546,17 @@ void SCutTimeline::SaveTimeline(const FString& SavedPath, FTimelineInfo Info)
|
||||
TArray<uint8> SavedData;
|
||||
FMemoryWriter MemoryWriter(SavedData);
|
||||
MemoryWriter << Info;
|
||||
int32 Length = TrackGroupInstances.Num();
|
||||
MemoryWriter << Length;
|
||||
for (FSingleTrackGroupInstance& SingleTrackGroupInstance : TrackGroupInstances)
|
||||
{
|
||||
MemoryWriter << SingleTrackGroupInstance.GroupName;
|
||||
}
|
||||
|
||||
int32 ClipLength = 0;
|
||||
TArray<FClipData> AllClips;
|
||||
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);
|
||||
|
||||
FFileHelper::SaveArrayToFile(SavedData, *NewSavedPath);
|
||||
@ -589,30 +574,67 @@ bool SCutTimeline::LoadTimeline(const FString& LoadPath, FTimelineInfo& Info)
|
||||
}
|
||||
|
||||
FMemoryReader MemoryReader(LoadData);
|
||||
|
||||
TrackGroupInstances.Empty();
|
||||
|
||||
TrackGroups.Empty();
|
||||
for (int32 l = 0; l < TrackGroupInstances.Num(); l++)
|
||||
{
|
||||
|
||||
StaticCastSharedPtr<STrackHead>(TrackGroupInstances[l].Head)->TrackData.ClipData.Empty();
|
||||
|
||||
}
|
||||
RenderGroup();
|
||||
MemoryReader << Info;
|
||||
int32 Length = 0;
|
||||
MemoryReader << Length;
|
||||
TArray<FString> GroupName;
|
||||
GroupName.Init("", Length);
|
||||
for (int32 i = 0; i < Length; i++)
|
||||
|
||||
int32 ClipLength = 0;
|
||||
MemoryReader << ClipLength;
|
||||
TArray<FClipData> AllClips;
|
||||
MemoryReader << AllClips;
|
||||
for (int32 i = 0; i < AllClips.Num(); i++)
|
||||
{
|
||||
MemoryReader << GroupName[i];
|
||||
}
|
||||
for (int32 i = 0; i < Length; i++)
|
||||
{
|
||||
FTrackData TrackData;
|
||||
MemoryReader << TrackData;
|
||||
for (FClipData& ClipData : TrackData.ClipData)
|
||||
AllClips[i].ResourcePropertyDataPtr = MainWidgetInterface->GetResourcePropertyDataPtr(AllClips[i].ResourcePropertyGuid);
|
||||
for (int32 j = 0; j < DeviceTrackGroups.Num(); j++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -620,11 +642,11 @@ void SCutTimeline::RemoveTrack(const FGuid& TrackGuid)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -659,5 +681,34 @@ FReply SCutTimeline::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& D
|
||||
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
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
struct FTrackGroup
|
||||
{
|
||||
// TrackGroup Mean Device
|
||||
FTrackGroup(FString InGroupName)
|
||||
{
|
||||
GroupName = InGroupName;
|
||||
@ -25,7 +26,7 @@ struct FTrackGroup
|
||||
FString GroupName = "组";
|
||||
ETrackType GroupType = ETrackType::None;
|
||||
bool GroupIsCollapsed = false;
|
||||
TArray<FTrackData> TrackDataArray;
|
||||
|
||||
};
|
||||
|
||||
struct FSingleTrackGroupInstance
|
||||
@ -112,4 +113,10 @@ public:
|
||||
TSharedPtr<STextBlock> CurrentTimeData;
|
||||
TSharedPtr<STextBlock> MaxTimeData;
|
||||
virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
|
||||
|
||||
|
||||
TArray<FDeviceTrackGroup> DeviceTrackGroups;
|
||||
void AddNewDeviceToGroup(FString GroupName, FDeviceTrack DeviceTrack, ETrackType GroupTrack = ETrackType::None);
|
||||
};
|
||||
|
||||
|
||||
|
@ -54,24 +54,25 @@ void STimelinePropertyPanel::Construct(const FArguments& InArgs)
|
||||
SNew(SButton)
|
||||
.OnClicked_Lambda([this]()
|
||||
{
|
||||
if (MainWindow->CutTimeline->TrackGroups.FindByPredicate([](const FTrackGroup& TrackGroup)
|
||||
if (MainWindow->CutTimeline->DeviceTrackGroups.FindByPredicate([](const FDeviceTrackGroup& TrackGroup)
|
||||
{
|
||||
return TrackGroup.GroupName == TEXT("未命名");
|
||||
}))
|
||||
{
|
||||
return FReply::Handled();
|
||||
}
|
||||
const FTrackData PlayerData(TEXT("玩家"), ETrackType::AtomSphereLightTrack);
|
||||
const FTrackData PlayerData(TEXT("玩家"), ETrackType::AtomSphereLightTrack, FDeviceTrack(TEXT("玩家"), ETrackType::AtomSphereLightTrack));
|
||||
// 遍历一下,检查出有多少个组里包含 角色组 三个字,然后按照当前得到的序号继续往后排序
|
||||
int32 Index = 0;
|
||||
for (const FTrackGroup& TrackGroup : MainWindow->CutTimeline->TrackGroups)
|
||||
for (const FDeviceTrackGroup& TrackGroup : MainWindow->CutTimeline->DeviceTrackGroups)
|
||||
{
|
||||
if (TrackGroup.GroupName.Contains(TEXT("角色组")))
|
||||
{
|
||||
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();
|
||||
})
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user