整理结构

This commit is contained in:
Sch 2023-07-28 18:33:10 +08:00
parent 8b7be0ada0
commit 8cc79f33f0
13 changed files with 326 additions and 120 deletions

View File

@ -32,6 +32,7 @@ enum class ETrackType
{
VideoTrack,
AudioTrack,
AudioTrackR,
PlayerTrack,
AtomSphereLightTrack,
SpotLightTrack,
@ -157,9 +158,17 @@ struct CUT5_API FTimelinePropertyData
Name = InName;
Type = InType;
}
FTimelinePropertyData(FString InName, ETrackType InType, FString InIconPath)
{
Name = InName;
Type = InType;
IconPath = InIconPath;
}
FString Name = "";
ETrackType Type = ETrackType::VideoTrack;
FString IconPath = "";
FGuid Guid = FGuid::NewGuid();
AVFormatContext* Context = nullptr;

View File

@ -143,39 +143,6 @@ void SCustomInputPanel::Construct(const FArguments& InArgs)
.PropertyData(PropertyData)
];
// LoadAudio(OpenFileName[i]);
// URuntimeAudioImporterLibrary* AudioImporter = URuntimeAudioImporterLibrary::CreateRuntimeAudioImporter();
// AudioImporter->ImportAudioFromFile(OpenFileName[i], ERuntimeAudioFormat::Auto);
// AudioImporter->OnResultNoDynamic.AddLambda([&, OpenFileName, i](URuntimeAudioImporterLibrary* Importer,
// UImportedSoundWave* ImportedSoundWave, ERuntimeImportStatus Status)
// {
// switch (Status)
// {
// case ERuntimeImportStatus::SuccessfulImport:
// {
// GWorld->bAllowAudioPlayback = true;
//
// UGameplayStatics::PlaySound2D(GEngine->GetWorldContextFromPIEInstance(0)->World(), ImportedSoundWave);
// FTimelinePropertyData PropertyData;
// PropertyData.Name = OpenFileName[i];
// PropertyData.Type = ETrackType::AudioTrack;
// PropertyData.MoviePath = OpenFileName[i];
// PropertyData.Sound = ImportedSoundWave;
// PropertyData.MovieFrameLength = ImportedSoundWave->GetDuration() * FGlobalData::GlobalFPS;
//
// GridPanel->AddSlot(GridPanel->GetChildren()->Num() % 3, GridPanel->GetChildren()->Num() / 3)
// [
// SNew(SCustomInputResource)
// .PropertyData(PropertyData)
// ];
// }
// break;
// default:
// break;
// }
// });
return FReply::Handled();

View File

@ -18,6 +18,7 @@
#include "Cut5/Utils/Utils.h"
#include "Cut5/Xml/tinyxml2.h"
#include "FX/SEffectCardsPanel.h"
#include "StatePanel/SStatePanel.h"
#include "Widgets/Layout/SConstraintCanvas.h"
#include "Widgets/Layout/SScaleBox.h"
#include "Widgets/Layout/SWidgetSwitcher.h"
@ -29,8 +30,7 @@ BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SCutMainWindow::Construct(const FArguments& InArgs)
{
SAssignNew(CutTimeline, SCutTimeline).MainWidgetInterface(this);
SAssignNew(LightArrayPanel, SLightArrayPanel);
SAssignNew(VideoPlayer, SVideoPlayer);
SAssignNew(StatePanel, SStatePanel);
ChildSlot
[
SNew(SScaleBox)
@ -141,7 +141,7 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
SNew(SVerticalBox)
+ SVerticalBox::Slot()
[
VideoPlayer.ToSharedRef()
StatePanel.ToSharedRef()
]
]
@ -154,10 +154,7 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
[
SAssignNew(PlayerGroupsPanel1, SHorizontalBox)
]
+ SVerticalBox::Slot()
[
LightArrayPanel.ToSharedRef()
]
+ SVerticalBox::Slot()
[
SAssignNew(PlayerGroupsPanel2, SHorizontalBox)
@ -175,6 +172,7 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
]
]
+ SVerticalBox::Slot()
.SizeParam(FAuto())
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
@ -191,10 +189,10 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
FRunnableThread* Thread = FRunnableThread::Create(SoundThread, TEXT("SoundThread"));
OpenProject(FPaths::Combine(FPaths::ProjectSavedDir(), TEXT("DefaultProject")));
FString String;
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
DesktopPlatform->OpenDirectoryDialog(nullptr, TEXT("选择导出路径"), String, String);
ExportProject(String);
// FString String;
// IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
// DesktopPlatform->OpenDirectoryDialog(nullptr, TEXT("选择导出路径"), String, String);
// ExportProject(String);
}
void SCutMainWindow::Render()
@ -235,7 +233,7 @@ FReply SCutMainWindow::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent&
void SCutMainWindow::OnUpdateVideo(FGuid UUID, UTexture2D* Texture)
{
ICutMainWidgetInterface::OnUpdateVideo(UUID, Texture);
VideoPlayer->UpdateVideoData(UUID, Texture);
StatePanel->VideoPlayer->UpdateVideoData(UUID, Texture);
FColor* Colors = static_cast<FColor*>(Texture->GetPlatformData()->Mips[0].BulkData.Lock(LOCK_READ_WRITE));
@ -255,7 +253,7 @@ void SCutMainWindow::OnUpdateVideo(FGuid UUID, UTexture2D* Texture)
void SCutMainWindow::OnUpdateLightArray(const TArray<FColor>& LightArray)
{
ICutMainWidgetInterface::OnUpdateLightArray(LightArray);
LightArrayPanel->LightGridColors = LightArray;
StatePanel->LightArray->LightGridColors = LightArray;
}
void SCutMainWindow::OnUpdatePlayers(TSharedPtr<class IWidgetInterface> TrackBody, FColor PlayerColor)
@ -349,34 +347,119 @@ void SCutMainWindow::ExportProject(const FString& ExportPath)
Document.InsertFirstChild(RootElement);
tinyxml2::XMLElement* Standard = RootElement->InsertNewChildElement("Standard");
tinyxml2::XMLElement* File = Standard->InsertNewChildElement("File");
File->InsertNewText("Author");
File->InsertNewChildElement("Author")->InsertNewText("Sch");
// Device List
tinyxml2::XMLElement* DeviceList = RootElement->InsertNewChildElement("DeviceList");
tinyxml2::XMLElement* PlayerLightList = DeviceList->InsertNewChildElement("PlayerLightList");
tinyxml2::XMLElement* DMLightList = DeviceList->InsertNewChildElement("DMLightList");
tinyxml2::XMLElement* LightArrayList = DeviceList->InsertNewChildElement("GuangZhenList");
tinyxml2::XMLElement* RoundSpeakerList = DeviceList->InsertNewChildElement("RotationSpeakerList");
tinyxml2::XMLElement* ProjectorList = DeviceList->InsertNewChildElement("ProjectorList");
int32 ID = 0;
for (int32 i = 0; i < CutTimeline->TrackGroups.Num(); i++)
{
for (FTrackData& TrackData : CutTimeline->TrackGroups[i].TrackDataArray)
tinyxml2::XMLElement* PlayerLightList = DeviceList->InsertNewChildElement("PlayerLightList");
tinyxml2::XMLElement* DMLightList = DeviceList->InsertNewChildElement("DMLightList");
tinyxml2::XMLElement* LightArrayList = DeviceList->InsertNewChildElement("GuangZhenList");
tinyxml2::XMLElement* RoundSpeakerList = DeviceList->InsertNewChildElement("RotationSpeakerList");
tinyxml2::XMLElement* ProjectorList = DeviceList->InsertNewChildElement("ProjectorList");
int32 ID = 0;
for (int32 i = 0; i < CutTimeline->TrackGroups.Num(); i++)
{
switch (TrackData.TrackType)
for (FTrackData& TrackData : CutTimeline->TrackGroups[i].TrackDataArray)
{
switch (TrackData.TrackType)
{
case ETrackType::PlayerTrack:
tinyxml2::XMLElement* PlayerLight = PlayerLightList->InsertNewChildElement("PlayerLight");
PlayerLight->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(ID)));
ID++;
break;
{
tinyxml2::XMLElement* PlayerLight = PlayerLightList->InsertNewChildElement("PlayerLight");
PlayerLight->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(ID)));
PlayerLight->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.TrackName));
ID++;
}
break;
case ETrackType::AudioTrackR:
{
tinyxml2::XMLElement* RotationSpeaker = RoundSpeakerList->InsertNewChildElement("RotationSpeaker");
RotationSpeaker->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(ID)));
RotationSpeaker->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.TrackName));
ID++;
}
break;
case ETrackType::LightArrayTrack:
{
tinyxml2::XMLElement* LightArray = LightArrayList->InsertNewChildElement("GuangZhen");
LightArray->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(ID)));
LightArray->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.TrackName));
ID++;
}
break;
case ETrackType::ProjectorTrack:
{
tinyxml2::XMLElement* Projector = ProjectorList->InsertNewChildElement("Projector");
Projector->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(ID)));
Projector->InsertNewChildElement("RoleName")->InsertNewText(TCHAR_TO_UTF8(*TrackData.TrackName));
ID++;
}
break;
}
}
}
// Card List
ID = 0;
tinyxml2::XMLElement* CardList = RootElement->InsertNewChildElement("CardList");
for (int32 i = 0; i < EffectCardsPanel->EffectCardGroups.Num(); i ++)
{
for (int32 j = 0; j < EffectCardsPanel->EffectCardGroups[i].Cards.Num(); j++)
{
tinyxml2::XMLElement* Card = CardList->InsertNewChildElement("Card");
Card->InsertNewChildElement("ID")->InsertNewText(TCHAR_TO_UTF8(*FString::FromInt(ID)));
Card->InsertNewChildElement("Type")->InsertNewText(EffectCardsPanel->EffectCardGroups[0].bIsDedicated ? "0" : "1");
Card->InsertNewChildElement("Times");
Card->InsertNewChildElement("Step");
Card->InsertNewChildElement("SpecialEffectID");
Card->InsertNewChildElement("SerialNumberList");
}
}
// KeyBoard
tinyxml2::XMLElement* Keyboard = RootElement->InsertNewChildElement("KeyBoard");
}
// ProcessList
{
tinyxml2::XMLElement* ProcessList = RootElement->InsertNewChildElement("ProcessList");
tinyxml2::XMLElement* ProcessA = ProcessList->InsertNewChildElement("ProcessA");
tinyxml2::XMLElement* ProcessB = ProcessA->InsertNewChildElement("ProcessB");
{
tinyxml2::XMLElement* ProcessID = ProcessB->InsertNewChildElement("ID");
tinyxml2::XMLElement* AutoNext = ProcessB->InsertNewChildElement("AutoNext");
tinyxml2::XMLElement* TimeLength = ProcessB->InsertNewChildElement("TimeLength");
tinyxml2::XMLElement* SoundList = ProcessB->InsertNewChildElement("SoundList");
{
tinyxml2::XMLElement* Sound = SoundList->InsertNewChildElement("Sound");
tinyxml2::XMLElement* URL = Sound->InsertNewChildElement("URL");
tinyxml2::XMLElement* Loop = Sound->InsertNewChildElement("Loop");
tinyxml2::XMLElement* Mode = Sound->InsertNewChildElement("Mode");
tinyxml2::XMLElement* Round = Sound->InsertNewChildElement("Round");
tinyxml2::XMLElement* Timecode = Sound->InsertNewChildElement("Timecode");
tinyxml2::XMLElement* VolumeEventList = Sound->InsertNewChildElement("VolumeEventList");
{
tinyxml2::XMLElement* VolumeEvent = VolumeEventList->InsertNewChildElement("VolumeEvent");
tinyxml2::XMLElement* VolumeEventTimeCode = VolumeEvent->InsertNewChildElement("TimeCode");
tinyxml2::XMLElement* VolumeEventValue = VolumeEvent->InsertNewChildElement("Value");
}
}
}
}
TArray<uint8> Data {0};
FFileHelper::SaveArrayToFile(Data, *(ExportPath + "/" + FGlobalData::CurrentProjectName + "/" + FGlobalData::CurrentProjectName + TEXT(".bin")));
Document.SaveFile(TCHAR_TO_UTF8(*(ExportPath + "/" + FGlobalData::CurrentProjectName + "/" + FGlobalData::CurrentProjectName + TEXT(".xml"))));

View File

@ -8,9 +8,10 @@
#include "SCutTimeline.h"
#include "SLightArrayPanel.h"
#include "SPlayerLight.h"
#include "SVideoPlayer.h"
#include "StatePanel/SVideoPlayer.h"
#include "Cut5/Interface/CutMainWidgetInterface.h"
#include "Cut5/Interface/SoundInterface.h"
#include "StatePanel/SStatePanel.h"
#include "Widgets/SCompoundWidget.h"
/**
@ -29,8 +30,7 @@ public:
void Construct(const FArguments& InArgs);
TSharedPtr<SCutTimeline> CutTimeline;
TSharedPtr<SLightArrayPanel> LightArrayPanel;
TSharedPtr<SVideoPlayer> VideoPlayer;
TSharedPtr<SStatePanel> StatePanel;
TSharedPtr<SCurtainPanel> CurtainPanel;
TSharedPtr<SHorizontalBox> PlayerGroupsPanel1;
TSharedPtr<SHorizontalBox> PlayerGroupsPanel2;

View File

@ -62,6 +62,7 @@ void SCutTimeline::Construct(const FArguments& InArgs)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.SizeParam(FAuto())
[
// Tool bar
SNew(SHorizontalBox)
@ -167,57 +168,44 @@ void SCutTimeline::Construct(const FArguments& InArgs)
FGlobalData::CurrentTimeScroll = ChangedValue;
})
]
// + SVerticalBox::Slot()
// .SizeParam(FAuto())
// [
// SNew(SSlider)
// .Value(FMath::GetMappedRangeValueClamped(FVector2D(5, 15), FVector2D(0, 1), FGlobalData::DefaultTimeTickSpace))
// .OnValueChanged_Lambda([this](float ChangedValue)
// {
// FGlobalData::DefaultTimeTickSpace = FMath::GetMappedRangeValueClamped(FVector2D(0, 1), FVector2D(5, 15), ChangedValue);
// UpdateTimelineLength();
// })
// ]
+ SVerticalBox::Slot()
.SizeParam(FAuto())
]
]
+ SVerticalBox::Slot()
.SizeParam(FAuto())
[
// Down Tool Bar
SNew(SBox)
.HeightOverride(25)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
// Down Tool Bar
SNew(SBox)
.HeightOverride(25)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
SNew(SButton)
.OnClicked_Lambda([this]()
{
UpdateCursorPosition(GetCursorPosition() - 1);
return FReply::Handled();
})
]
+ SHorizontalBox::Slot()
[
SNew(SButton)
.OnClicked_Lambda([this]()
{
SetAutoPlay(!AutoPlaying);
return FReply::Handled();
})
]
+ SHorizontalBox::Slot()
[
SNew(SButton)
.OnClicked_Lambda([this]()
{
UpdateCursorPosition(GetCursorPosition() + 1);
return FReply::Handled();
})
]
]
SNew(SButton)
.OnClicked_Lambda([this]()
{
UpdateCursorPosition(GetCursorPosition() - 1);
return FReply::Handled();
})
]
+ SHorizontalBox::Slot()
[
SNew(SButton)
.OnClicked_Lambda([this]()
{
SetAutoPlay(!AutoPlaying);
return FReply::Handled();
})
]
+ SHorizontalBox::Slot()
[
SNew(SButton)
.OnClicked_Lambda([this]()
{
UpdateCursorPosition(GetCursorPosition() + 1);
return FReply::Handled();
})
]
]
]
];
@ -225,7 +213,7 @@ void SCutTimeline::Construct(const FArguments& InArgs)
FTrackData AudioDataL(TEXT("音频L"), ETrackType::AudioTrack);
AddNewTrackToGroup(TEXT("固定轨道"), AudioDataL);
FTrackData AudioDataR(TEXT("音频R"), ETrackType::AudioTrack);
FTrackData AudioDataR(TEXT("音频R"), ETrackType::AudioTrackR);
AddNewTrackToGroup(TEXT("固定轨道"), AudioDataR);
FTrackData ProjectorData(TEXT("投影仪"), ETrackType::ProjectorTrack);
AddNewTrackToGroup(TEXT("固定轨道"), ProjectorData);

View File

@ -4,6 +4,7 @@
#include "STimelineProperty.h"
#include "SlateOptMacros.h"
#include "Cut5/Utils/Utils.h"
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
@ -22,6 +23,7 @@ void STimelineProperty::Construct(const FArguments& InArgs)
+ SOverlay::Slot()
[
SNew(SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath(TimelinePropertyData.IconPath), {}))
]
+ SOverlay::Slot()
[

View File

@ -4,6 +4,7 @@
#include "STimelinePropertyPanel.h"
#include "SlateOptMacros.h"
#include "Cut5/Utils/Utils.h"
#include "Widgets/Input/SButton.h"
#include "Widgets/Layout/SGridPanel.h"
@ -63,9 +64,8 @@ void STimelinePropertyPanel::Construct(const FArguments& InArgs)
]
]
];
AddNewSelection(FTimelinePropertyData(TEXT("玩家"), ETrackType::PlayerTrack));
AddNewSelection(FTimelinePropertyData(TEXT("聚光灯"), ETrackType::SpotLightTrack));
AddNewSelection(FTimelinePropertyData(TEXT("氛围灯"), ETrackType::AtomSphereLightTrack));
AddNewSelection(FTimelinePropertyData(TEXT("聚光灯"), ETrackType::SpotLightTrack, TEXT("SpotLight.png")));
AddNewSelection(FTimelinePropertyData(TEXT("氛围灯"), ETrackType::AtomSphereLightTrack, TEXT("PlayerLight.png")));
}
void STimelinePropertyPanel::AddNewSelection(FTimelinePropertyData TimelinePropertyData)

View File

@ -309,7 +309,7 @@ void STrackBody::BreakClip(const FGuid& Guid)
FClipData NewClipData = TrackHead->TrackData.ClipData[i];
NewClipData.ClipGuid = FGuid::NewGuid();
const int32 CropFrameRight = TrackHead->TrackData.ClipData[i].GetClipRelativeEndFrame() - SelectedClipFrame;
const int32 CropFrameRight = TrackHead->TrackData.ClipData[i].GetClipRelativeEndFrame() - SelectedClipFrame - 1;
TrackHead->TrackData.ClipData[i].CropClip(FClipData::ECropMethod::FromBack, CropFrameRight);
NewClipData.CropClip(FClipData::ECropMethod::FromFront, SelectedClipFrame + 1);

View File

@ -53,6 +53,9 @@ void STrackHead::Construct(const FArguments& InArgs)
case ETrackType::AudioTrack:
ImagePath = FPaths::ProjectDir() + "/Resources/" + "Audio.png";
break;
case ETrackType::AudioTrackR:
ImagePath = FPaths::ProjectDir() + "/Resources/" + "Audio.png";
break;
case ETrackType::ProjectorTrack:
ImagePath = FPaths::ProjectDir() + "/Resources/" + "Projector.png";
break;

View File

@ -0,0 +1,120 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "SStatePanel.h"
#include "SlateOptMacros.h"
#include "SVideoPlayer.h"
#include "Cut5/Utils/Utils.h"
#include "Cut5/Widgets/SLightArrayPanel.h"
#include "Widgets/Layout/SScaleBox.h"
#include "Widgets/Layout/SSeparator.h"
#include "Widgets/Layout/SWidgetSwitcher.h"
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SStatePanel::Construct(const FArguments& InArgs)
{
SAssignNew(VideoPlayer, SVideoPlayer);
SAssignNew(LightArray, SLightArrayPanel);
ChildSlot
[
SNew(SBox)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
SNew(STextBlock)
.Text(FText::FromString(TEXT("预览")))
]
+ SHorizontalBox::Slot()
[
SNew(SButton)
.Text(FText::FromString(TEXT("编辑")))
]
]
]
+ SVerticalBox::Slot()
.SizeParam(FAuto())
[
SNew(SSeparator)
]
+ SVerticalBox::Slot()
.SizeParam(FAuto())
[
SNew(SBox)
.HeightOverride(125.0)
[
SAssignNew(PlayerList1, SHorizontalBox)
]
]
+ SVerticalBox::Slot()
[
SNew(SBox)
.MinDesiredHeight(500.0)
[
SNew(SOverlay)
+ SOverlay::Slot()
[
SAssignNew(ShowSwitcher, SWidgetSwitcher)
+ SWidgetSwitcher::Slot()
[
SAssignNew(MainShow, SBox)
[
VideoPlayer.ToSharedRef()
]
]
+ SWidgetSwitcher::Slot()
[
SNew(SBox)
[
LightArray.ToSharedRef()
]
]
]
+ SOverlay::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(100)
.HeightOverride(100)
[
SAssignNew(Projector, SImage)
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath(TEXT("Projector.png")), FVector2D(0, 0)))
]
]
+ SOverlay::Slot()
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(SBox)
.WidthOverride(100)
.HeightOverride(100)
[
SNew(SButton)
.OnClicked_Lambda([this]()
{
ShowSwitcher->SetActiveWidgetIndex(!bIsVideo);
bIsVideo = !bIsVideo;
return FReply::Handled();
})
]
]
]
]
]
];
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION

View File

@ -0,0 +1,34 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "SVideoPlayer.h"
#include "Cut5/Widgets/SLightArrayPanel.h"
#include "Widgets/SCompoundWidget.h"
/**
*
*/
class CUT5_API SStatePanel : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SStatePanel)
{
}
SLATE_END_ARGS()
/** Constructs this widget with InArgs */
void Construct(const FArguments& InArgs);
TSharedPtr<SHorizontalBox> PlayerList1;
TSharedPtr<SHorizontalBox> PlayerList2;
TSharedPtr<SVideoPlayer> VideoPlayer;
TSharedPtr<SLightArrayPanel> LightArray;
TSharedPtr<SWidgetSwitcher> ShowSwitcher;
TSharedPtr<SBox> MainShow;
TSharedPtr<SImage> Projector;
bool bIsVideo = true;
};