Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Panakotta00 committed Aug 4, 2022
2 parents a52c98b + b3d1fb8 commit 0d27b3c
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion FicsItCam.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"FileVersion": 3,
"Version": 0,
"VersionName": "0.3",
"SemVersion": "0.3.1",
"SemVersion": "0.3.2",
"AcceptsAnyRemoteVersion": true,
"FriendlyName": "FicsIt-Cam",
"Description": "This mod allows you to create beautiful camera animations in-game.",
Expand Down
3 changes: 3 additions & 0 deletions Source/FicsItCam/Private/Data/Objects/FICParticleSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ TSharedRef<SWidget> UFICParticleSystem::CreateDetailsWidget(UFICEditorContext* I
}

void UFICParticleSystem::InitEditor(UFICEditorContext* Context) {
check(ParticleSystemActor == nullptr);
FVector Pos = Position.Get(Context->GetCurrentFrame());
FRotator Rot = Rotation.Get(Context->GetCurrentFrame());
ParticleSystemActor = GetWorld()->SpawnActor<AFICParticleSystemActor>(Pos, Rot);
Expand All @@ -93,11 +94,13 @@ void UFICParticleSystem::InitEditor(UFICEditorContext* Context) {
}

void UFICParticleSystem::ShutdownEditor(UFICEditorContext* Context) {
check(ParticleSystemActor != nullptr);
ParticleSystemActor->Destroy();
ParticleSystemActor = nullptr;
}

void UFICParticleSystem::EditorUpdate(UFICEditorContext* Context, TSharedRef<FFICEditorAttributeBase> Attribute) {
check(ParticleSystemActor != nullptr);
FVector Pos = FFICAttributePosition::FromEditorAttribute(Attribute->Get<FFICEditorAttributeGroup>("Position"));
FRotator Rot = FFICAttributeRotation::FromEditorAttribute(Attribute->Get<FFICEditorAttributeGroup>("Rotation"));
bool bActive = Attribute->Get<FFICEditorAttributeBool>("Active").GetActiveValue();
Expand Down
10 changes: 8 additions & 2 deletions Source/FicsItCam/Private/Editor/FICChangeList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ void FFICChange_ActiveFrame::UndoChange() {
}

void FFICChange_AddSceneObject::RedoChange() {
UObject* SceneObject = Context->FindSceneObject(SceneObjectName);
if (SceneObject) return;
UObject* CDO = SceneObjectClass->GetDefaultObject();
SceneObject = Cast<IFICSceneObject>(CDO)->CreateNewObject(AFICSubsystem::GetFICSubsystem(Context), Context->GetScene());
Cast<IFICSceneObject>(SceneObject)->SetSceneObjectName(SceneObjectName);
Context->AddSceneObject(SceneObject);
Context->SetSelectedSceneObject(SceneObject);
Cast<IFICSceneObject>(SceneObject)->GetRootAttribute().Set(Snapshot.ToSharedRef());
if (Snapshot) Cast<IFICSceneObject>(SceneObject)->GetRootAttribute().Set(Snapshot.ToSharedRef());
Snapshot.Reset();
}

void FFICChange_AddSceneObject::UndoChange() {
UObject* SceneObject = Context->FindSceneObject(SceneObjectName);
if (!SceneObject) return;
Snapshot = Cast<IFICSceneObject>(SceneObject)->GetRootAttribute().Get();
Context->RemoveSceneObject(SceneObject);
Expand All @@ -58,19 +61,22 @@ void FFICChange_AddSceneObject::UndoChange() {
FFICChange_RemoveSceneObject::FFICChange_RemoveSceneObject(UFICEditorContext* InContext, UObject* InSceneObject) :
Context(InContext),
SceneObjectClass(InSceneObject->GetClass()),
SceneObjectName(Cast<IFICSceneObject>(InSceneObject)->GetSceneObjectName()),
Snapshot(Cast<IFICSceneObject>(InSceneObject)->GetRootAttribute().Get()) {}

void FFICChange_RemoveSceneObject::RedoChange() {
UObject* SceneObject = Context->FindSceneObject(SceneObjectName);
if (!SceneObject) return;
Snapshot = Cast<IFICSceneObject>(SceneObject)->GetRootAttribute().Get();
Context->RemoveSceneObject(SceneObject);
SceneObject = nullptr;
}

void FFICChange_RemoveSceneObject::UndoChange() {
UObject* SceneObject = Context->FindSceneObject(SceneObjectName);
if (SceneObject) return;
UObject* CDO = SceneObjectClass->GetDefaultObject();
SceneObject = Cast<IFICSceneObject>(CDO)->CreateNewObject(AFICSubsystem::GetFICSubsystem(Context), Context->GetScene());
Cast<IFICSceneObject>(SceneObject)->SetSceneObjectName(SceneObjectName);
Cast<IFICSceneObject>(SceneObject)->GetRootAttribute().Set(Snapshot.ToSharedRef());
Snapshot.Reset();
Context->AddSceneObject(SceneObject);
Expand Down
9 changes: 9 additions & 0 deletions Source/FicsItCam/Private/Editor/FICEditorContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ void UFICEditorContext::MoveSceneObject(UObject* SceneObject, int Delta) {
SetSelectedSceneObject(SceneObject);
}

UObject* UFICEditorContext::FindSceneObject(FString SceneObjectName) const {
for (UObject* Object : Scene->GetSceneObjects()) {
if (Cast<IFICSceneObject>(Object)->GetSceneObjectName() == SceneObjectName) {
return Object;
}
}
return nullptr;
}

AFICScene* UFICEditorContext::GetScene() const {
return Scene;
}
Expand Down
1 change: 1 addition & 0 deletions Source/FicsItCam/Private/Editor/UI/FICEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ FMenuBarBuilder SFICEditor::CreateMenuBar() {
FMenuBarBuilder MenuBarBuilder(nullptr);
MenuBarBuilder.AddMenuEntry(LOCTEXT("Exit", "Exit"), LOCTEXT("ExitTT", "Closes and Exits the Editor"), FSlateIcon(), FExecuteAction::CreateLambda([this]() {
TabManager->SavePersistentLayout();
FSlateApplication::Get().ClearAllUserFocus();
AFICEditorSubsystem::GetFICEditorSubsystem(Context->GetScene()->GetWorld())->CloseEditor();
}));
MenuBarBuilder.AddPullDownMenu(LOCTEXT("View", "View"), LOCTEXT("ViewTT", "Views, Panels & Windows"), FNewMenuDelegate::CreateLambda([this](FMenuBuilder& MenuBuilder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void SFICSceneObjectOutliner::Construct(const FArguments& InArgs, UFICEditorCont
if (Event.GetKey() == EKeys::Delete) {
TArray<TSharedPtr<FFICSceneObjectReference>> Selected;
if (SceneObjectListWidget->GetSelectedItems(Selected) > 0) {
Context->ChangeList.PushChange(MakeShared<FFICChange_RemoveSceneObject>(Context, Selected[0]->SceneObject));
Context->RemoveSceneObject(Selected[0]->SceneObject);
}
return FReply::Handled();
Expand Down
4 changes: 2 additions & 2 deletions Source/FicsItCam/Private/Editor/UI/FICTimeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void SFICTimelinePanel::Construct(const FArguments& InArgs, UFICEditorContext* I
})
.MinValue(TNumericLimits<int64>::Min())
.OnValueCommitted_Lambda([this](int64 Value, ETextCommit::Type) {
Context->GetScene()->AnimationRange.Begin = Value;
Context->GetScene()->AnimationRange.SetBegin_Clamped(Value);
})
]
]
Expand Down Expand Up @@ -305,7 +305,7 @@ void SFICTimelinePanel::Construct(const FArguments& InArgs, UFICEditorContext* I
})
.MaxValue(TNumericLimits<int64>::Max())
.OnValueCommitted_Lambda([this](int64 Value, ETextCommit::Type) {
Context->GetScene()->AnimationRange.End = FMath::Clamp(Value, Context->GetScene()->AnimationRange.Begin+1, TNumericLimits<int64>::Max());
Context->GetScene()->AnimationRange.SetEnd_Clamped(Value);
})
]
]
Expand Down
8 changes: 8 additions & 0 deletions Source/FicsItCam/Public/Data/FICTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ struct FFICFrameRange {
return FFICFrameRange(Begin - Frame, End - Frame);
}

void SetBegin_Clamped(FICFrame InBegin, bool bInclusive = false) {
Begin = FMath::Min(InBegin, End - (bInclusive ? 0 : 1));
}

void SetEnd_Clamped(FICFrame InEnd, bool bInclusive = false) {
End = FMath::Max(InEnd, Begin + (bInclusive ? 0 : 1));
}

FFICFrameRangeIterator begin() const {
return FFICFrameRangeIterator(Begin);
}
Expand Down
7 changes: 4 additions & 3 deletions Source/FicsItCam/Public/Editor/FICChangeList.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "Data/Attributes/FICAttribute.h"
#include "Data/Objects/FICSceneObject.h"

class FFICChangeList;

Expand Down Expand Up @@ -95,10 +96,10 @@ struct FFICChange_Attribute : public FFICChange {
struct FFICChange_AddSceneObject : public FFICChange {
UFICEditorContext* Context;
UClass* SceneObjectClass;
UObject* SceneObject;
FString SceneObjectName;
TSharedPtr<FFICAttribute> Snapshot;

FFICChange_AddSceneObject(UFICEditorContext* InContext, UObject* InSceneObject) : Context(InContext), SceneObjectClass(InSceneObject->GetClass()), SceneObject(InSceneObject) {}
FFICChange_AddSceneObject(UFICEditorContext* InContext, UObject* InSceneObject) : Context(InContext), SceneObjectClass(InSceneObject->GetClass()), SceneObjectName(Cast<IFICSceneObject>(InSceneObject)->GetSceneObjectName()) {}

virtual void RedoChange() override;
virtual void UndoChange() override;
Expand All @@ -110,7 +111,7 @@ struct FFICChange_AddSceneObject : public FFICChange {

struct FFICChange_RemoveSceneObject : public FFICChange {
UFICEditorContext* Context;
UObject* SceneObject = nullptr;
FString SceneObjectName = "";
UClass* SceneObjectClass;
TSharedPtr<FFICAttribute> Snapshot;

Expand Down
1 change: 1 addition & 0 deletions Source/FicsItCam/Public/Editor/FICEditorContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class UFICEditorContext : public UObject, public FTickableGameObject {
void AddSceneObject(UObject* SceneObject);
void RemoveSceneObject(UObject* SceneObject);
void MoveSceneObject(UObject* SceneObject, int Delta);
UObject* FindSceneObject(FString SceneObjectName) const;

AFICScene* GetScene() const;
UFICCamera* GetCamera();
Expand Down

0 comments on commit 0d27b3c

Please sign in to comment.