保存卡牌
This commit is contained in:
parent
0693f268e6
commit
ebcd744d23
BIN
Resources/BackGround.png
Normal file
BIN
Resources/BackGround.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 254 B |
@ -33,7 +33,8 @@ public:
|
||||
virtual void OnUpdateSound(uint8* Data, int32 Size) {};
|
||||
|
||||
virtual void AddNewCard(FEffectCardProperty& CardProperty, FString GroupName) {};
|
||||
|
||||
virtual void OpenTimeline(const FString& TimelineName, bool NeedSaveBefore = false) {};
|
||||
virtual void OpenProject(const FString& Project) {};
|
||||
virtual FString GetGroupName(TSharedPtr<class IWidgetInterface> WidgetInterface) { return FString(); };
|
||||
virtual FTimelinePropertyData* GetResourcePropertyDataPtr(FGuid GUID) { return nullptr; };
|
||||
};
|
||||
|
23
Source/Cut5/Interface/SaveInterface.cpp
Normal file
23
Source/Cut5/Interface/SaveInterface.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "SaveInterface.h"
|
||||
|
||||
#include "Cut5/Widgets/DefineGlobal.h"
|
||||
|
||||
|
||||
FString ISaveInterface::SetSavePath(TArray<FString> Paths)
|
||||
{
|
||||
FString Result = FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName);
|
||||
for (int32 i = 0; i < Paths.Num(); i++)
|
||||
{
|
||||
FPaths::Combine(Result, Paths[i]);
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
FString ISaveInterface::GetSavePath()
|
||||
{
|
||||
return SavePath;
|
||||
}
|
40
Source/Cut5/Interface/SaveInterface.h
Normal file
40
Source/Cut5/Interface/SaveInterface.h
Normal file
@ -0,0 +1,40 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "SaveInterface.generated.h"
|
||||
|
||||
// This class does not need to be modified.
|
||||
UINTERFACE()
|
||||
class USaveInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class CUT5_API ISaveInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* @brief Save Path modify by SetSavePath
|
||||
*/
|
||||
FString SavePath;
|
||||
public:
|
||||
/**
|
||||
* @brief Set Save Path to this
|
||||
* @param Paths Single word mean single path {"A", "B"} mean A/B
|
||||
* @return The path of the save file
|
||||
*/
|
||||
virtual FString SetSavePath(TArray<FString> Paths);
|
||||
|
||||
/**
|
||||
* @brief Get Save Path
|
||||
* @return The path of the save file
|
||||
*/
|
||||
virtual FString GetSavePath();
|
||||
};
|
@ -1,5 +1,7 @@
|
||||
#include "Utils.h"
|
||||
|
||||
#include "Cut5/Widgets/DefineGlobal.h"
|
||||
|
||||
FString FUtils::MakeStringUpright(const FString& String)
|
||||
{
|
||||
FString Result;
|
||||
@ -62,3 +64,51 @@ FSlateDynamicImageBrush* FUtils::GetBrushFromImage(const FString& ImageName, con
|
||||
|
||||
return Brush;
|
||||
}
|
||||
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")));
|
||||
FFileHelper::SaveArrayToFile(SavedData, *FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName, SavedPath));
|
||||
}
|
||||
|
||||
FSaveModifier::FSaveModifier(const FString& FullSavedPath)
|
||||
{
|
||||
|
||||
this->FullSavedPath = FullSavedPath;
|
||||
TArray<uint8> LoadData;
|
||||
FFileHelper::LoadFileToArray(LoadData, *FullSavedPath);
|
||||
if (LoadData.Num() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
FFileHelper::SaveArrayToFile(SavedData, *FullSavedPath);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "Cut5/Widgets/DefineGlobal.h"
|
||||
|
||||
class FUtils
|
||||
{
|
||||
@ -13,4 +14,37 @@ public:
|
||||
static FString GetResourcesPath(FString ResourcesName);
|
||||
static FSlateDynamicImageBrush* GetBrushFromImage(const FString& ImageName, const FVector2D Size);
|
||||
static TArray<FSlateDynamicImageBrush*> BrushPtr;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Create a default timeline save file.
|
||||
* @param SavedPath Where to save.
|
||||
* @param Type
|
||||
*/
|
||||
static void CreateDefaultTimelineSave(const FString& SavedPath, const FTimelineInfo::ETimelineType Type);
|
||||
|
||||
|
||||
static FString GroupFullPath(const FString& GroupName)
|
||||
{
|
||||
return FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName, TEXT("FX"), GroupName + TEXT(".bin"));
|
||||
};
|
||||
static FString SingleCardFullPath(const FString& CardName)
|
||||
{
|
||||
return FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName, TEXT("FX"), TEXT("SingleCard"), CardName + TEXT(".bin"));
|
||||
};
|
||||
static FString MainSaveFullPath()
|
||||
{
|
||||
return FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName, FGlobalData::CurrentProjectName + TEXT(".bin"));
|
||||
};
|
||||
};
|
||||
|
||||
class FSaveModifier
|
||||
{
|
||||
public:
|
||||
FSaveModifier(const FString& FullSavedPath);
|
||||
~FSaveModifier();
|
||||
FString FullSavedPath;
|
||||
FTimelineInfo TimelineInfo;
|
||||
int32 GroupLength = 0;
|
||||
TArray<FString> GroupName;
|
||||
TArray<FTrackData> TrackData;
|
||||
};
|
||||
|
@ -216,19 +216,41 @@ public:
|
||||
EDragType DragType;
|
||||
};
|
||||
|
||||
struct FTimelineInfo;
|
||||
struct CUT5_API FTimelineInfo
|
||||
{
|
||||
enum class ETimelineType
|
||||
{
|
||||
Main,
|
||||
FX,
|
||||
};
|
||||
FString CurrentOpenFullPath = "";
|
||||
FTimelineInfo::ETimelineType CurrentOpenType = ETimelineType::Main;
|
||||
|
||||
friend FArchive& operator<<(FArchive& Ar, FTimelineInfo& TimelineInfo)
|
||||
{
|
||||
Ar << TimelineInfo.CurrentOpenFullPath;
|
||||
Ar << TimelineInfo.CurrentOpenType;
|
||||
return Ar;
|
||||
};
|
||||
FString GetSavePath()
|
||||
{
|
||||
return CurrentOpenFullPath;
|
||||
}
|
||||
};
|
||||
|
||||
struct CUT5_API FEffectCardProperty
|
||||
{
|
||||
FEffectCardProperty() {};
|
||||
FGuid Guid = FGuid::NewGuid();
|
||||
FString Name = "";
|
||||
FString TimelineBinaryPath = "";
|
||||
FTimelineInfo TimelineInfo;
|
||||
|
||||
friend FArchive& operator<<(FArchive& Ar, FEffectCardProperty& EffectCardProperty)
|
||||
{
|
||||
Ar << EffectCardProperty.Guid;
|
||||
Ar << EffectCardProperty.Name;
|
||||
Ar << EffectCardProperty.TimelineBinaryPath;
|
||||
Ar << EffectCardProperty.TimelineInfo;
|
||||
return Ar;
|
||||
};
|
||||
};
|
||||
@ -238,12 +260,17 @@ struct CUT5_API FEffectCardGroup
|
||||
FString GroupName;
|
||||
TArray<FEffectCardProperty> Cards;
|
||||
bool bIsDedicated = false;
|
||||
|
||||
bool bCanEditName = false;
|
||||
bool bIsExpanded = true;
|
||||
|
||||
friend FArchive& operator<<(FArchive& Ar, FEffectCardGroup& EffectCard)
|
||||
{
|
||||
Ar << EffectCard.GroupName;
|
||||
Ar << EffectCard.Cards;
|
||||
Ar << EffectCard.bIsDedicated;
|
||||
Ar << EffectCard.bCanEditName;
|
||||
Ar << EffectCard.bIsExpanded;
|
||||
return Ar;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "SEffectCard.h"
|
||||
|
||||
#include "SlateOptMacros.h"
|
||||
|
||||
#include "Cut5/Utils/Utils.h"
|
||||
#include "Cut5/Widgets/MicroWidgets/SClickEditableText.h"
|
||||
|
||||
@ -11,14 +12,27 @@ BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
||||
|
||||
void SEffectCard::OnNameEdited(FString New, FString Old)
|
||||
{
|
||||
|
||||
CardProperty->Name = New;
|
||||
|
||||
CardProperty->Name = New;
|
||||
SetSavePath({TEXT("FX"), TEXT("SingleCard"), New + TEXT(".bin")});
|
||||
if (!IFileManager::Get().FileExists(*GetSavePath()))
|
||||
{
|
||||
TArray<uint8> BinaryData;
|
||||
FFileHelper::LoadFileToArray(BinaryData, *CardProperty->TimelineInfo.CurrentOpenFullPath);
|
||||
CardProperty->TimelineInfo.CurrentOpenFullPath = FUtils::SingleCardFullPath(CardProperty->Name);
|
||||
FFileHelper::SaveArrayToFile(BinaryData, *CardProperty->TimelineInfo.CurrentOpenFullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void SEffectCard::Construct(const FArguments& InArgs)
|
||||
{
|
||||
CardProperty = InArgs._CardProperty;
|
||||
GroupName = InArgs._GroupName;
|
||||
MainInterface = InArgs._MainInterface;
|
||||
SetSavePath({TEXT("FX"), TEXT("SingleCard"), CardProperty->Name + TEXT(".bin")});
|
||||
ChildSlot
|
||||
[
|
||||
SNew(SBox)
|
||||
@ -35,12 +49,22 @@ void SEffectCard::Construct(const FArguments& InArgs)
|
||||
SNew(SImage)
|
||||
.Visibility(EVisibility::HitTestInvisible)
|
||||
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("EffectCard.png"), FVector2D(125.0, 125.0)))
|
||||
.OnMouseButtonDown_Lambda([this](const FGeometry&, const FPointerEvent& PointerEvent)
|
||||
{
|
||||
MainInterface->OpenTimeline(FUtils::SingleCardFullPath(CardProperty->TimelineInfo.CurrentOpenFullPath), true);
|
||||
return FReply::Handled();
|
||||
})
|
||||
]
|
||||
+ SOverlay::Slot()
|
||||
[
|
||||
SNew(SClickEditableText)
|
||||
.InitTextPtr(&CardProperty->Name)
|
||||
.OnEdited_Raw(this, &SEffectCard::OnNameEdited)
|
||||
.CanEdit(true)
|
||||
.OnSingleClick_Lambda([this]()
|
||||
{
|
||||
MainInterface->OpenTimeline(FUtils::SingleCardFullPath(CardProperty->Name), true);
|
||||
})
|
||||
]
|
||||
]
|
||||
|
||||
|
@ -3,26 +3,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Cut5/Interface/SaveInterface.h"
|
||||
#include "Cut5/Interface/CutMainWidgetInterface.h"
|
||||
#include "Cut5/Widgets/DefineGlobal.h"
|
||||
#include "Widgets/SCompoundWidget.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class CUT5_API SEffectCard : public SCompoundWidget
|
||||
class CUT5_API SEffectCard : public SCompoundWidget, public ISaveInterface
|
||||
{
|
||||
public:
|
||||
SLATE_BEGIN_ARGS(SEffectCard)
|
||||
{
|
||||
}
|
||||
SLATE_ARGUMENT(FEffectCardProperty*, CardProperty)
|
||||
SLATE_ARGUMENT(FString, GroupName)
|
||||
SLATE_ARGUMENT(ICutMainWidgetInterface*, MainInterface)
|
||||
SLATE_END_ARGS()
|
||||
|
||||
|
||||
FEffectCardProperty* CardProperty;
|
||||
FString GroupName;
|
||||
|
||||
void OnNameEdited(FString New, FString Old);
|
||||
|
||||
/** Constructs this widget with InArgs */
|
||||
void Construct(const FArguments& InArgs);
|
||||
|
||||
ICutMainWidgetInterface* MainInterface;
|
||||
};
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include "SEffectCard.h"
|
||||
#include "SlateOptMacros.h"
|
||||
#include "Cut5/Utils/Utils.h"
|
||||
#include "Cut5/Widgets/MicroWidgets/SClickEditableText.h"
|
||||
#include "Widgets/Layout/SExpandableArea.h"
|
||||
#include "Widgets/Layout/SGridPanel.h"
|
||||
#include "Widgets/Layout/SScrollBox.h"
|
||||
@ -15,21 +17,65 @@ void SEffectCardGroup::Construct(const FArguments& InArgs)
|
||||
{
|
||||
EffectCardGroup = InArgs._EffectCardGroup;
|
||||
MainInterface = InArgs._MainInterface;
|
||||
|
||||
// 只考虑组别储存,不考虑组内卡片储存
|
||||
SetSavePath({TEXT("FX"), EffectCardGroup->GroupName + TEXT(".bin")});
|
||||
|
||||
ChildSlot
|
||||
[
|
||||
SNew(SBox)
|
||||
.WidthOverride(250.0f)
|
||||
.HeightOverride(250.0f)
|
||||
[
|
||||
SNew(SExpandableArea)
|
||||
.AreaTitle(FText::FromString(TEXT("独立特效")))
|
||||
.InitiallyCollapsed(!EffectCardGroup->bIsExpanded)
|
||||
.OnAreaExpansionChanged_Lambda([this](bool Changed)
|
||||
{
|
||||
EffectCardGroup->bIsExpanded = Changed;
|
||||
})
|
||||
.HeaderContent()
|
||||
[
|
||||
SNew(SClickEditableText)
|
||||
.InitTextPtr(&EffectCardGroup->GroupName)
|
||||
.CanEdit(EffectCardGroup->bCanEditName)
|
||||
.IsNeedUpright(false)
|
||||
]
|
||||
.BodyContent()
|
||||
[
|
||||
SAssignNew(Contents, SScrollBox)
|
||||
+ SScrollBox::Slot()
|
||||
SNew(SBorder)
|
||||
.HAlign(HAlign_Fill)
|
||||
.VAlign(VAlign_Fill)
|
||||
[
|
||||
SAssignNew(GridPanel, SGridPanel)
|
||||
|
||||
SNew(SOverlay)
|
||||
+ SOverlay::Slot()
|
||||
[
|
||||
SNew(SBox)
|
||||
.HAlign(HAlign_Fill)
|
||||
.VAlign(VAlign_Fill)
|
||||
.MaxDesiredWidth(1000)
|
||||
.MaxDesiredHeight(1000)
|
||||
[
|
||||
SNew(SImage)
|
||||
.OnMouseButtonDown_Lambda([this](const FGeometry&, const FPointerEvent& PointerEvent)
|
||||
{
|
||||
if (EffectCardGroup->bIsDedicated == false)
|
||||
{
|
||||
const FString Name = FPaths::Combine(FPaths::ProjectSavedDir() + FGlobalData::CurrentProjectName, TEXT("FX"), EffectCardGroup->GroupName + TEXT(".bin"));
|
||||
MainInterface->OpenTimeline(Name, true);
|
||||
}
|
||||
return FReply::Handled();
|
||||
})
|
||||
.Image(FUtils::GetBrushFromImage(FUtils::GetResourcesPath("BackGround.png"), FVector2D(0, 0)))
|
||||
]
|
||||
]
|
||||
+ SOverlay::Slot()
|
||||
[
|
||||
SAssignNew(Contents, SScrollBox)
|
||||
.Visibility(EVisibility::SelfHitTestInvisible)
|
||||
+ SScrollBox::Slot()
|
||||
[
|
||||
SAssignNew(GridPanel, SGridPanel)
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
@ -49,11 +95,17 @@ void SEffectCardGroup::CallRender()
|
||||
.VAlign(VAlign_Fill)
|
||||
.OnClicked_Lambda([this]()
|
||||
{
|
||||
// 新建卡牌后 对卡牌进行个体保存。
|
||||
FEffectCardProperty NewCard;
|
||||
NewCard.Name = TEXT("未命名");
|
||||
NewCard.TimelineBinaryPath = FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName, TEXT("FX"), EffectCardGroup->GroupName, TEXT("未命名.bin"));
|
||||
NewCard.Name = TEXT("未命名") + NewCard.Guid.ToString();
|
||||
FUtils::CreateDefaultTimelineSave(FUtils::SingleCardFullPath(NewCard.Name), FTimelineInfo::ETimelineType::FX);
|
||||
{
|
||||
FSaveModifier SaveModifier(FUtils::SingleCardFullPath(NewCard.Name));
|
||||
SaveModifier.TimelineInfo.CurrentOpenFullPath = FUtils::SingleCardFullPath(NewCard.Name);
|
||||
SaveModifier.TimelineInfo.CurrentOpenType = FTimelineInfo::ETimelineType::FX;
|
||||
NewCard.TimelineInfo = SaveModifier.TimelineInfo;
|
||||
}
|
||||
MainInterface->AddNewCard(NewCard, EffectCardGroup->GroupName);
|
||||
|
||||
return FReply::Handled();
|
||||
})
|
||||
[
|
||||
@ -68,6 +120,8 @@ void SEffectCardGroup::CallRender()
|
||||
[
|
||||
SNew(SEffectCard)
|
||||
.CardProperty(&Property)
|
||||
.GroupName(EffectCardGroup->GroupName)
|
||||
.MainInterface(MainInterface)
|
||||
];
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Cut5/Interface/CutMainWidgetInterface.h"
|
||||
#include "Cut5/Interface/SaveInterface.h"
|
||||
#include "Cut5/Widgets/DefineGlobal.h"
|
||||
#include "Widgets/SCompoundWidget.h"
|
||||
#include "Widgets/Layout/SGridPanel.h"
|
||||
@ -12,7 +13,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class CUT5_API SEffectCardGroup : public SCompoundWidget
|
||||
class CUT5_API SEffectCardGroup : public SCompoundWidget, public ISaveInterface
|
||||
{
|
||||
public:
|
||||
SLATE_BEGIN_ARGS(SEffectCardGroup)
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "SEffectCardGroup.h"
|
||||
#include "SlateOptMacros.h"
|
||||
#include "Cut5/Utils/Utils.h"
|
||||
#include "Widgets/Layout/SExpandableArea.h"
|
||||
#include "Widgets/Layout/SScrollBox.h"
|
||||
|
||||
@ -47,6 +48,31 @@ void SEffectCardsPanel::CallRender()
|
||||
.MainInterface(MainInterface)
|
||||
];
|
||||
}
|
||||
ScrollBox->AddSlot()
|
||||
[
|
||||
SNew(SBox)
|
||||
.HAlign(HAlign_Fill)
|
||||
.VAlign(VAlign_Fill)
|
||||
.WidthOverride(125 * 3)
|
||||
.HeightOverride(125.0)
|
||||
[
|
||||
SNew(SButton)
|
||||
.Text(FText::FromString("+"))
|
||||
.OnClicked_Lambda([this]()
|
||||
{
|
||||
FEffectCardGroup* Group = AddNewGroup(TEXT("新建组") + FGuid::NewGuid().ToString());
|
||||
|
||||
const FString NewPath = FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName, TEXT("FX"), Group->GroupName + TEXT(".bin"));
|
||||
FUtils::CreateDefaultTimelineSave(NewPath, FTimelineInfo::ETimelineType::FX);
|
||||
{
|
||||
FSaveModifier SaveModifier(NewPath);
|
||||
SaveModifier.TimelineInfo.CurrentOpenFullPath = NewPath;
|
||||
}
|
||||
return FReply::Handled();
|
||||
})
|
||||
]
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
void SEffectCardsPanel::AddNewCard(FEffectCardProperty CardProperty, const FString& GroupName)
|
||||
@ -61,6 +87,10 @@ void SEffectCardsPanel::AddNewCard(FEffectCardProperty CardProperty, const FStri
|
||||
{
|
||||
CardGroup = GetGroupFromName(GroupName);
|
||||
}
|
||||
if (!CardGroup)
|
||||
{
|
||||
CardGroup = AddNewGroup(GroupName);
|
||||
}
|
||||
|
||||
CardGroup->Cards.Add(CardProperty);
|
||||
CallRender();
|
||||
@ -111,6 +141,20 @@ void SEffectCardsPanel::MoveCard(const FGuid& GUID, const FString& GroupName)
|
||||
CallRender();
|
||||
}
|
||||
|
||||
FEffectCardGroup* SEffectCardsPanel::AddNewGroup(const FString& GroupName)
|
||||
{
|
||||
FEffectCardGroup NewGroup;
|
||||
NewGroup.GroupName = GroupName;
|
||||
NewGroup.bIsDedicated = false;
|
||||
NewGroup.bCanEditName = true;
|
||||
EffectCardGroups.Add(NewGroup);
|
||||
CallRender();
|
||||
return &EffectCardGroups.Last();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
FEffectCardGroup* SEffectCardsPanel::GetGroupFromName(const FString& Name)
|
||||
{
|
||||
for (FEffectCardGroup& Group : EffectCardGroups)
|
||||
|
@ -64,6 +64,13 @@ public:
|
||||
*/
|
||||
void MoveCard(const FGuid& GUID, const FString& GroupName);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add an group to the panel.
|
||||
* @param GroupName Group Name.
|
||||
*/
|
||||
FEffectCardGroup* AddNewGroup(const FString& GroupName);
|
||||
|
||||
/**
|
||||
* @brief Get Group Ptr from Group Name.
|
||||
* @param Name Group Name.
|
||||
@ -78,4 +85,3 @@ public:
|
||||
FEffectCardGroup* GetDedicatedGroupFromName();
|
||||
};
|
||||
|
||||
|
||||
|
@ -15,6 +15,8 @@ void SClickEditableText::Construct(const FArguments& InArgs)
|
||||
TextPtr = InArgs._InitTextPtr;
|
||||
OnEdited = InArgs._OnEdited;
|
||||
IsNeedUpright = InArgs._IsNeedUpright;
|
||||
CanEdit = InArgs._CanEdit;
|
||||
OnSingleClick = InArgs._OnSingleClick;
|
||||
ChildSlot
|
||||
[
|
||||
SNew(SVerticalBox)
|
||||
@ -30,9 +32,17 @@ void SClickEditableText::Construct(const FArguments& InArgs)
|
||||
SNew(SBorder)
|
||||
.OnMouseDoubleClick_Lambda([this](const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
||||
{
|
||||
CreateEditableBox();
|
||||
if (CanEdit)
|
||||
{
|
||||
CreateEditableBox();
|
||||
}
|
||||
return FReply::Handled();
|
||||
})
|
||||
.OnMouseButtonDown_Lambda([this](const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
||||
{
|
||||
OnSingleClick.ExecuteIfBound();
|
||||
return FReply::Handled();
|
||||
})
|
||||
]
|
||||
+ SOverlay::Slot()
|
||||
.HAlign(HAlign_Center)
|
||||
@ -61,19 +71,28 @@ void SClickEditableText::CreateEditableBox()
|
||||
return;
|
||||
}
|
||||
TextBlock->SetText(FText::FromString(IsNeedUpright ? FUtils::MakeStringUpright(InText.ToString()) : InText.ToString()));
|
||||
Overlay->RemoveSlot(EditableText.ToSharedRef());
|
||||
EditBox->SetVisibility(EVisibility::Hidden);
|
||||
Overlay->RemoveSlot(EditBox.ToSharedRef());
|
||||
if (!OnEdited.ExecuteIfBound(InText.ToString(), *TextPtr))
|
||||
{
|
||||
check(false)
|
||||
|
||||
};
|
||||
*TextPtr = InText.ToString();
|
||||
|
||||
});
|
||||
Overlay->AddSlot()
|
||||
.HAlign(HAlign_Fill)
|
||||
.VAlign(VAlign_Fill)
|
||||
.HAlign(HAlign_Center)
|
||||
.VAlign(VAlign_Center)
|
||||
[
|
||||
EditableText.ToSharedRef()
|
||||
SAssignNew(EditBox, SBox)
|
||||
.WidthOverride(100)
|
||||
.HeightOverride(30)
|
||||
.HAlign(HAlign_Fill)
|
||||
.VAlign(VAlign_Fill)
|
||||
[
|
||||
EditableText.ToSharedRef()
|
||||
]
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,14 @@ class CUT5_API SClickEditableText : public SCompoundWidget
|
||||
{
|
||||
public:
|
||||
DECLARE_DELEGATE_TwoParams(FOnEdited, FString, FString)
|
||||
DECLARE_DELEGATE(FOnSingleClick)
|
||||
SLATE_BEGIN_ARGS(SClickEditableText)
|
||||
{
|
||||
}
|
||||
SLATE_ARGUMENT(FString*, InitTextPtr)
|
||||
SLATE_ARGUMENT(bool, CanEdit)
|
||||
SLATE_EVENT(FOnEdited, OnEdited)
|
||||
SLATE_EVENT(FOnSingleClick, OnSingleClick)
|
||||
SLATE_ARGUMENT(bool, IsNeedUpright)
|
||||
SLATE_END_ARGS()
|
||||
|
||||
@ -27,8 +30,11 @@ public:
|
||||
TSharedPtr<STextBlock> TextBlock;
|
||||
TSharedPtr<SOverlay> Overlay;
|
||||
TSharedPtr<SEditableText> EditableText;
|
||||
TSharedPtr<SBox> EditBox;
|
||||
FOnEdited OnEdited;
|
||||
FOnSingleClick OnSingleClick;
|
||||
bool IsNeedUpright = true;
|
||||
bool CanEdit = true;
|
||||
FString* TextPtr;
|
||||
void CreateEditableBox();
|
||||
};
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "STimelinePropertyPanel.h"
|
||||
#include "STrackBody.h"
|
||||
#include "STrackHead.h"
|
||||
#include "Cut5/Utils/Utils.h"
|
||||
#include "FX/SEffectCardsPanel.h"
|
||||
#include "Widgets/Layout/SConstraintCanvas.h"
|
||||
#include "Widgets/Layout/SScaleBox.h"
|
||||
@ -57,7 +58,7 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
|
||||
SNew(SButton)
|
||||
.OnClicked_Lambda([this]()
|
||||
{
|
||||
CutTimeline->SaveTimeline("Test.sav");
|
||||
CutTimeline->SaveTimeline(FUtils::MainSaveFullPath(), CutTimeline->TimelineInfo);
|
||||
return FReply::Handled();
|
||||
})
|
||||
]
|
||||
@ -66,7 +67,9 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
|
||||
SNew(SButton)
|
||||
.OnClicked_Lambda([this]()
|
||||
{
|
||||
CutTimeline->LoadTimeline("Test.sav");
|
||||
FTimelineInfo TimelineInfo;
|
||||
OpenTimeline(FUtils::MainSaveFullPath(), true);
|
||||
// CutTimeline->LoadTimeline("Test.sav", TimelineInfo);
|
||||
return FReply::Handled();
|
||||
})
|
||||
]
|
||||
@ -112,6 +115,7 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
|
||||
]
|
||||
]
|
||||
+ SVerticalBox::Slot()
|
||||
.SizeParam(FStretch(1.0))
|
||||
[
|
||||
SAssignNew(PropertiesPanelSwitcher, SWidgetSwitcher)
|
||||
+ SWidgetSwitcher::Slot()
|
||||
@ -169,7 +173,7 @@ void SCutMainWindow::Construct(const FArguments& InArgs)
|
||||
|
||||
SoundThread = new FSoundThread();
|
||||
FRunnableThread* Thread = FRunnableThread::Create(SoundThread, TEXT("SoundThread"));
|
||||
|
||||
OpenProject(FPaths::Combine(FPaths::ProjectSavedDir(), TEXT("DefaultProject")));
|
||||
}
|
||||
|
||||
void SCutMainWindow::Render()
|
||||
@ -280,6 +284,42 @@ void SCutMainWindow::AddNewCard(FEffectCardProperty& CardProperty, FString Group
|
||||
EffectCardsPanel->AddNewCard(CardProperty, GroupName);
|
||||
}
|
||||
|
||||
void SCutMainWindow::OpenTimeline(const FString& TimelineName, bool NeedSaveBefore)
|
||||
{
|
||||
if (NeedSaveBefore)
|
||||
{
|
||||
if (TimelineName != "")
|
||||
{
|
||||
if (CutTimeline->TimelineInfo.CurrentOpenFullPath.IsEmpty())
|
||||
{
|
||||
CutTimeline->SaveTimeline(FUtils::MainSaveFullPath(), CutTimeline->TimelineInfo);
|
||||
CutTimeline->TimelineInfo.CurrentOpenFullPath = FUtils::MainSaveFullPath();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CutTimeline->TimelineInfo.CurrentOpenFullPath != FUtils::MainSaveFullPath())
|
||||
CutTimeline->SaveTimeline(CutTimeline->TimelineInfo.CurrentOpenFullPath, CutTimeline->TimelineInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
FTimelineInfo TimelineInfo;
|
||||
// 拿到TimelineName路径中的名字,也就是倒数第四位开始,去掉后缀
|
||||
|
||||
|
||||
if (CutTimeline->LoadTimeline(TimelineName, TimelineInfo))
|
||||
{
|
||||
CutTimeline->TimelineInfo = TimelineInfo;
|
||||
}
|
||||
}
|
||||
|
||||
void SCutMainWindow::OpenProject(const FString& Project)
|
||||
{
|
||||
FGlobalData::CurrentProjectName = FPaths::GetCleanFilename(Project);
|
||||
FTimelineInfo OpenedInfo;
|
||||
CutTimeline->LoadTimeline(FPaths::Combine(Project, FGlobalData::CurrentProjectName + TEXT(".bin")), OpenedInfo);
|
||||
}
|
||||
|
||||
|
||||
FTimelinePropertyData* SCutMainWindow::GetResourcePropertyDataPtr(FGuid GUID)
|
||||
{
|
||||
if (!GUID.IsValid())
|
||||
|
@ -53,6 +53,9 @@ public:
|
||||
virtual void OnUpdateSound(uint8* Data, int32 Size) override;
|
||||
// 不好 到时候改成 Group Widget 内部操作
|
||||
virtual void AddNewCard(FEffectCardProperty& CardProperty, FString GroupName) override;
|
||||
virtual void OpenTimeline(const FString& TimelineName, bool NeedSaveBefore) override;
|
||||
virtual void OpenProject(const FString& Project) override;
|
||||
|
||||
virtual FTimelinePropertyData* GetResourcePropertyDataPtr(FGuid GUID) override;
|
||||
virtual FString GetGroupName(TSharedPtr<IWidgetInterface> WidgetInterface) override;
|
||||
};
|
||||
|
@ -375,14 +375,13 @@ void SCutTimeline::RenderGroup()
|
||||
}
|
||||
}
|
||||
|
||||
void SCutTimeline::SaveTimeline(const FString& SavedPath)
|
||||
void SCutTimeline::SaveTimeline(const FString& SavedPath, FTimelineInfo Info)
|
||||
{
|
||||
SetAutoPlay(false);
|
||||
|
||||
|
||||
|
||||
TArray<uint8> SavedData;
|
||||
FMemoryWriter MemoryWriter(SavedData);
|
||||
MemoryWriter << Info;
|
||||
int32 Length = TrackGroupInstances.Num();
|
||||
MemoryWriter << Length;
|
||||
for (FSingleTrackGroupInstance& SingleTrackGroupInstance : TrackGroupInstances)
|
||||
@ -396,7 +395,7 @@ void SCutTimeline::SaveTimeline(const FString& SavedPath)
|
||||
FFileHelper::SaveArrayToFile(SavedData, *FPaths::Combine(FPaths::ProjectSavedDir(), FGlobalData::CurrentProjectName, SavedPath));
|
||||
}
|
||||
|
||||
void SCutTimeline::LoadTimeline(const FString& LoadPath)
|
||||
bool SCutTimeline::LoadTimeline(const FString& LoadPath, FTimelineInfo& Info)
|
||||
{
|
||||
TArray<uint8> LoadData;
|
||||
if (!FPaths::IsDrive(LoadPath))
|
||||
@ -409,7 +408,7 @@ void SCutTimeline::LoadTimeline(const FString& LoadPath)
|
||||
}
|
||||
if (LoadData.Num() == 0)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
FMemoryReader MemoryReader(LoadData);
|
||||
@ -417,7 +416,7 @@ void SCutTimeline::LoadTimeline(const FString& LoadPath)
|
||||
TrackGroupInstances.Empty();
|
||||
TrackGroups.Empty();
|
||||
RenderGroup();
|
||||
|
||||
MemoryReader << Info;
|
||||
int32 Length = 0;
|
||||
MemoryReader << Length;
|
||||
TArray<FString> GroupName;
|
||||
@ -437,7 +436,7 @@ void SCutTimeline::LoadTimeline(const FString& LoadPath)
|
||||
AddNewTrackToGroup(GroupName[i], TrackData);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SCutTimeline::RemoveTrack(const FGuid& TrackGuid)
|
||||
@ -464,6 +463,8 @@ void SCutTimeline::RemoveTrack(const FGuid& TrackGuid)
|
||||
MainWidgetInterface->OnRemoveTrack(TrackGuid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
FReply SCutTimeline::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
|
||||
{
|
||||
// Add new Track
|
||||
|
@ -71,19 +71,21 @@ public:
|
||||
* @brief Save Current Time line Track to File.
|
||||
* @param SavedPath Where to save.
|
||||
*/
|
||||
void SaveTimeline(const FString& SavedPath);
|
||||
void SaveTimeline(const FString& SavedPath, FTimelineInfo Info);
|
||||
|
||||
/**
|
||||
* @brief Load Time line Track from File.
|
||||
* @param LoadPath Where to load.
|
||||
*/
|
||||
void LoadTimeline(const FString& LoadPath);
|
||||
bool LoadTimeline(const FString& LoadPath, FTimelineInfo& Info);
|
||||
|
||||
/**
|
||||
* @brief Remove Track from Timeline by UUID.
|
||||
* @param FGuid Track UUID.
|
||||
*/
|
||||
void RemoveTrack(const FGuid& FGuid);
|
||||
|
||||
|
||||
|
||||
ICutMainWidgetInterface* MainWidgetInterface;
|
||||
|
||||
@ -97,6 +99,8 @@ public:
|
||||
|
||||
TArray<FSingleTrackGroupInstance> TrackGroupInstances;
|
||||
TArray<FTrackGroup> TrackGroups;
|
||||
|
||||
FTimelineInfo TimelineInfo;
|
||||
|
||||
virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user