Skip to content

Commit

Permalink
Version Bump & Fixes & In-Editor Player Speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Panakotta00 committed Feb 1, 2022
1 parent f3ab8e2 commit 7912f0e
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 23 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.2",
"SemVersion": "0.2.1",
"SemVersion": "0.2.2",
"FriendlyName": "FicsIt-Cam",
"Description": "This mod allows you to create beautiful camera animations in-game.",
"Category": "Modding",
Expand Down
9 changes: 2 additions & 7 deletions Source/FicsItCam/UI/FICDragDrop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ FFICGraphDragDrop::FFICGraphDragDrop(TSharedRef<SFICGraphView> GraphView, FPoint
ValueStart = GraphView->LocalToValue(LocalPos.Y);
}

void FFICGraphDragDrop::Construct() {
bCreateNewWindow = true;
FDragDropOperation::Construct();
}

void FFICGraphDragDrop::OnDragged(const FDragDropEvent& DragDropEvent) {
FDragDropOperation::OnDragged(DragDropEvent);

Expand Down Expand Up @@ -72,13 +67,13 @@ TSharedPtr<SWidget> FFICGraphKeyframeDragDrop::GetDefaultDecorator() const {
.ColorAndOpacity( FLinearColor::Black )
.WrapTextAt_Static( &SToolTip::GetToolTipWrapWidth )
.Text_Lambda([this]() {
return FText::FromString(FString::Printf(TEXT("Frame: %lld\nValue: %f\n\nShift: Fixed Frame\nCTRL: Fixed Value"), KeyframeControl->GetFrame(), KeyframeControl->GetAttribute()->GetValueAsFloat(KeyframeControl->GetFrame())));
return FText::FromString(FString::Printf(TEXT("Frame: %lld\nValue: %i\n\nShift: Fixed Frame\nCTRL: Fixed Value"), KeyframeControl->GetFrame(), static_cast<int>(KeyframeControl->GetAttribute()->GetValueAsFloat(KeyframeControl->GetFrame()))));
})
];
}

FVector2D FFICGraphKeyframeDragDrop::GetDecoratorPosition() const {
return FFICGraphDragDrop::GetDecoratorPosition();
return FSlateApplication::Get().GetCursorPos() + FVector2D(20, 20);
}

void FFICGraphKeyframeDragDrop::OnDrop(bool bDropWasHandled, const FPointerEvent& MouseEvent) {
Expand Down
3 changes: 2 additions & 1 deletion Source/FicsItCam/UI/FICDragDrop.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class FFICGraphDragDrop : public FDragDropOperation {
FFICGraphDragDrop(TSharedRef<SFICGraphView> GraphView, FPointerEvent InitEvent);

// Begin FDragDropOperation
virtual void Construct() override;
virtual void OnDragged( const FDragDropEvent& DragDropEvent ) override;
// End FDragDropOperation
};
Expand All @@ -45,6 +44,8 @@ class FFICGraphKeyframeDragDrop : public FFICGraphDragDrop {

FFICGraphKeyframeDragDrop(TSharedRef<SFICGraphView> GraphView, TSharedRef<SFICKeyframeControl> KeyframeControl, FPointerEvent InitEvent) : FFICGraphDragDrop(GraphView, InitEvent), KeyframeControl(KeyframeControl) {
AttribBegin = KeyframeControl->GetAttribute()->GetAttribute()->Get();
FDragDropOperation::SetDecoratorVisibility(true);
bCreateNewWindow = false;
}

// Begin FDragDropOperation
Expand Down
5 changes: 3 additions & 2 deletions Source/FicsItCam/UI/FICEditorContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ void UFICEditorContext::HideEditor() {
IsEditorShown = false;
}

void UFICEditorContext::SetAnimPlayer(EFICAnimPlayerState InAnimPlayerState) {
void UFICEditorContext::SetAnimPlayer(EFICAnimPlayerState InAnimPlayerState, float InAnimPlayerFactor) {
AnimPlayerFactor = InAnimPlayerFactor;
if (AnimPlayerState != InAnimPlayerState) {
AnimPlayerState = InAnimPlayerState;
AnimPlayerDelta = 0;
Expand All @@ -95,7 +96,7 @@ UFICEditorContext::UFICEditorContext() :

void UFICEditorContext::Tick(float DeltaTime) {
if (Animation) {
AnimPlayerDelta += DeltaTime;
AnimPlayerDelta += DeltaTime * AnimPlayerFactor;
int32 FrameDelta = FMath::Floor(AnimPlayerDelta * Animation->FPS);
AnimPlayerDelta -= (float)FrameDelta / (float)Animation->FPS;
switch (AnimPlayerState) {
Expand Down
4 changes: 3 additions & 1 deletion Source/FicsItCam/UI/FICEditorContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class UFICEditorContext : public UObject, public FTickableGameObject {

EFICAnimPlayerState AnimPlayerState = FIC_PLAY_PAUSED;
float AnimPlayerDelta = 0.0f;
float AnimPlayerFactor = 1.0f;

public:
TFICEditorAttribute<FFICFloatAttribute> PosX;
Expand Down Expand Up @@ -99,6 +100,7 @@ class UFICEditorContext : public UObject, public FTickableGameObject {
void ShowEditor();
void HideEditor();

void SetAnimPlayer(EFICAnimPlayerState InAnimPlayerState);
void SetAnimPlayer(EFICAnimPlayerState InAnimPlayerState, float InAnimPlayerFactor);
EFICAnimPlayerState GetAnimPlayer() { return AnimPlayerState; }
float GetAnimPlayerFactor() { return AnimPlayerFactor; }
};
4 changes: 4 additions & 0 deletions Source/FicsItCam/UI/FICGraphView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ int32 SFICGraphView::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGe
int64 FrameStart = TimelineRangeBegin.Get();
int64 FrameEnd = TimelineRangeEnd.Get();
int64 Steps = 1;
int64 SafetyCounter = 0;
while (FMath::Abs(FrameEnd - FrameStart) / Steps > 30) Steps *= 10;
for (float x = FrameStart - FrameStart % Steps; x <= FrameEnd; x += Steps) {
if (SafetyCounter++ > 1000) break;
FSlateDrawElement::MakeLines(OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(), {FVector2D(FrameToLocal(x), 0), FVector2D(FrameToLocal(x), AllottedGeometry.GetLocalSize().Y)}, ESlateDrawEffect::None, GridColor, true, 1);
}
SafetyCounter = 0;
for (float y = 0; y <= AllottedGeometry.GetLocalSize().Y; y += Distance.Y) {
if (SafetyCounter++ > 1000) break;
FSlateDrawElement::MakeLines(OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(), {FVector2D(0, y + RenderOffset.Y), FVector2D(AllottedGeometry.GetLocalSize().X, y + RenderOffset.Y)}, ESlateDrawEffect::None, GridColor, true, 1);
}
FLinearColor FrameColor = FLinearColor(FColor::FromHex("666600"));
Expand Down
66 changes: 56 additions & 10 deletions Source/FicsItCam/UI/FICTimeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,43 @@ void SFICTimelinePanel::Construct(const FArguments& InArgs) {
.ColorAndOpacity(FColor::Black)
]
.ToolTipText_Lambda([this]() {
bool Ctrl = FSlateApplication::Get().GetModifierKeys().IsControlDown() && Context->GetAnimPlayer() != FIC_PLAY_PAUSED;
float Factor = Context->GetAnimPlayerFactor();
if (Context->GetAnimPlayer() == FIC_PLAY_BACKWARDS) {
return FText::FromString(TEXT("Pause Play"));
return FText::FromString(Ctrl ? FString::Printf(TEXT("Increate to %ix Reverse Play"), (int)Factor+1) : TEXT("Pause Play"));
} else {
return FText::FromString(TEXT("Play Reverse"));
return FText::FromString(Ctrl ? FString::Printf(TEXT("Decrease to %ix Play"), (int)Factor-1) : TEXT("Play Reverse"));
}
})
.IsChecked_Lambda([this]() {
return (Context->GetAnimPlayer() == FIC_PLAY_BACKWARDS) ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
})
.OnCheckStateChanged_Lambda([this](ECheckBoxState State) {
if (Context->GetAnimPlayer() == FIC_PLAY_BACKWARDS) {
Context->SetAnimPlayer(EFICAnimPlayerState::FIC_PLAY_PAUSED);
bool Ctrl = FSlateApplication::Get().GetModifierKeys().IsControlDown();
float Factor = Context->GetAnimPlayerFactor();
switch (Context->GetAnimPlayer()) {
case FIC_PLAY_PAUSED:
Context->SetAnimPlayer(EFICAnimPlayerState::FIC_PLAY_BACKWARDS, Factor = 1);
break;
case FIC_PLAY_FORWARDS:
if (Ctrl) {
Factor -= 1;
} else {
Factor = 0;
}
break;
case FIC_PLAY_BACKWARDS:
if (Ctrl) {
Factor += 1;
} else {
Factor = 0;
}
break;
}
if (FMath::Abs(Factor) < 0.1) {
Context->SetAnimPlayer(EFICAnimPlayerState::FIC_PLAY_PAUSED, 0);
} else {
Context->SetAnimPlayer(EFICAnimPlayerState::FIC_PLAY_BACKWARDS);
Context->SetAnimPlayer(Context->GetAnimPlayer(), Factor);
}
})
]
Expand Down Expand Up @@ -183,20 +206,43 @@ void SFICTimelinePanel::Construct(const FArguments& InArgs) {
.ColorAndOpacity(FColor::Black)
]
.ToolTipText_Lambda([this]() {
bool Ctrl = FSlateApplication::Get().GetModifierKeys().IsControlDown() && Context->GetAnimPlayer() != FIC_PLAY_PAUSED;
float Factor = Context->GetAnimPlayerFactor();
if (Context->GetAnimPlayer() == FIC_PLAY_FORWARDS) {
return FText::FromString(TEXT("Pause Play"));
return FText::FromString(Ctrl ? FString::Printf(TEXT("Increate to %ix Play"), (int)Factor+1) : TEXT("Pause Play"));
} else {
return FText::FromString(TEXT("Play"));
return FText::FromString(Ctrl ? FString::Printf(TEXT("Decrease to %ix Reverse Play"), (int)Factor+1) : TEXT("Play"));
}
})
.IsChecked_Lambda([this]() {
return (Context->GetAnimPlayer() == FIC_PLAY_FORWARDS) ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
})
.OnCheckStateChanged_Lambda([this](ECheckBoxState State) {
if (Context->GetAnimPlayer() == FIC_PLAY_FORWARDS) {
Context->SetAnimPlayer(EFICAnimPlayerState::FIC_PLAY_PAUSED);
bool Ctrl = FSlateApplication::Get().GetModifierKeys().IsControlDown();
float Factor = Context->GetAnimPlayerFactor();
switch (Context->GetAnimPlayer()) {
case FIC_PLAY_PAUSED:
Context->SetAnimPlayer(EFICAnimPlayerState::FIC_PLAY_FORWARDS, Factor = 1);
break;
case FIC_PLAY_BACKWARDS:
if (Ctrl) {
Factor -= 1;
} else {
Factor = 0;
}
break;
case FIC_PLAY_FORWARDS:
if (Ctrl) {
Factor += 1;
} else {
Factor = 0;
}
break;
}
if (FMath::Abs(Factor) < 0.1) {
Context->SetAnimPlayer(EFICAnimPlayerState::FIC_PLAY_PAUSED, 0);
} else {
Context->SetAnimPlayer(EFICAnimPlayerState::FIC_PLAY_FORWARDS);
Context->SetAnimPlayer(Context->GetAnimPlayer(), Factor);
}
})
]
Expand Down
3 changes: 2 additions & 1 deletion Source/FicsItCam/UI/FICTimelineScrubber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ int32 SFICTimelineScrubber::OnPaint(const FPaintArgs& Args, const FGeometry& All
int64 End = RangeEnd.Get();
int64 Increment = 10;
while ((End - Start) / Increment > 30) Increment *= 10;
Start += Increment - (Start % Increment);
Start += Increment - Start % Increment;
if (Start <= 0) Start -= Increment;
FLinearColor IncColor = IncrementColor.Get();
for (int64 i = Start; i <= End; i += Increment) {
float IX = RangePosToLocalPos(AllottedGeometry, i);
Expand Down

0 comments on commit 7912f0e

Please sign in to comment.