mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Improved undo redo function and timelines
This commit is contained in:
parent
1af7f41d63
commit
e36ef6a368
372 changed files with 4086 additions and 211 deletions
|
@ -27,7 +27,7 @@ namespace RimWorldAnimationStudio
|
|||
public Transform animationTimelines;
|
||||
public Transform actorBodies;
|
||||
public Toggle stretchkeyframesToggle;
|
||||
|
||||
public InputField playBackSpeedField;
|
||||
|
||||
[Header("Prefabs")]
|
||||
public ActorBody actorBodyPrefab;
|
||||
|
@ -39,7 +39,8 @@ namespace RimWorldAnimationStudio
|
|||
private int cycleIndex = 0;
|
||||
private bool isDirty = true;
|
||||
private bool isTimelineDirty = true;
|
||||
|
||||
private float playBackSpeed = 1f;
|
||||
|
||||
public void MakeDirty()
|
||||
{ isDirty = true; }
|
||||
|
||||
|
@ -53,17 +54,17 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
// Dirty animation, reset
|
||||
if (Workspace.animationDef != null && isDirty)
|
||||
{ Initialize(); return; }
|
||||
{ Initialize(); }
|
||||
|
||||
// Update tick if animating
|
||||
if (isAnimating)
|
||||
{
|
||||
timeSinceLastUpdate += Time.deltaTime;
|
||||
|
||||
if (timeSinceLastUpdate < 1f / 60f)
|
||||
if (timeSinceLastUpdate < 1 / (playBackSpeed * 60f))
|
||||
{ return; }
|
||||
|
||||
timeSinceLastUpdate -= 1f / 60f;
|
||||
timeSinceLastUpdate -= 1 / (playBackSpeed * 60f);
|
||||
stageTick += 1;
|
||||
|
||||
if (stageTick > Workspace.StageWindowSize)
|
||||
|
@ -237,7 +238,7 @@ namespace RimWorldAnimationStudio
|
|||
Actor actor = new Actor();
|
||||
actor.MakeNew();
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Actor addition");
|
||||
}
|
||||
|
||||
public void RemoveActor()
|
||||
|
@ -254,7 +255,7 @@ namespace RimWorldAnimationStudio
|
|||
Workspace.animationDef.actors.RemoveAt(Workspace.actorID);
|
||||
Workspace.actorID = Workspace.actorID >= Workspace.animationDef.actors.Count ? Workspace.actorID = Workspace.animationDef.actors.Count - 1 : Workspace.actorID;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Actor deletion");
|
||||
}
|
||||
|
||||
public void AddPawnKeyframe()
|
||||
|
@ -294,14 +295,12 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
animationTimelines.GetComponentsInChildren<AnimationTimeline>()[Workspace.actorID].AddPawnKeyFrame(keyframe.keyframeID);
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Keyframe addition");
|
||||
}
|
||||
|
||||
public void RemovePawnKeyframe()
|
||||
{
|
||||
RemovePawnKeyframe(Workspace.actorID, Workspace.keyframeID);
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
}
|
||||
|
||||
public void RemovePawnKeyframe(int actorID, int keyframeID)
|
||||
|
@ -318,9 +317,9 @@ namespace RimWorldAnimationStudio
|
|||
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[actorID];
|
||||
clip.keyframes.Remove(keyframe);
|
||||
clip.BuildSimpleCurves();
|
||||
}
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Keyframe deletion");
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleAnimation()
|
||||
|
@ -351,8 +350,6 @@ namespace RimWorldAnimationStudio
|
|||
int.TryParse(animationClipTimeField.text, out int newStageTick);
|
||||
stageTick = Mathf.Clamp(newStageTick, 1, Workspace.StageWindowSize);
|
||||
stageTimelineSlider.value = stageTick;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
}
|
||||
|
||||
public void OnAnimationClipLengthFieldChange()
|
||||
|
@ -390,7 +387,7 @@ namespace RimWorldAnimationStudio
|
|||
animationClipLengthField.text = newStageWindowSize.ToString();
|
||||
Workspace.animationDef.animationStages[Workspace.stageID].stageWindowSize = newStageWindowSize;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Stage length");
|
||||
}
|
||||
|
||||
public void StretchKeyframes(int newStageWindowSize)
|
||||
|
@ -418,7 +415,7 @@ namespace RimWorldAnimationStudio
|
|||
if (int.TryParse(cyclesNormalField.text, out int cycles))
|
||||
{ Workspace.animationDef.animationStages[Workspace.stageID].playTimeTicks = cycles * Workspace.StageWindowSize; }
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Cycle count (normal)");
|
||||
}
|
||||
|
||||
public void OnCycleFastFieldChange()
|
||||
|
@ -428,7 +425,13 @@ namespace RimWorldAnimationStudio
|
|||
if (int.TryParse(cyclesFastField.text, out int cycles))
|
||||
{ Workspace.animationDef.animationStages[Workspace.stageID].playTimeTicksQuick = cycles * Workspace.StageWindowSize; }
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Cycle count (fast)");
|
||||
}
|
||||
|
||||
public void OnPlayBackSpeedChange()
|
||||
{
|
||||
if (float.TryParse(playBackSpeedField.text, out playBackSpeed))
|
||||
{ playBackSpeed = Mathf.Clamp(playBackSpeed, 0.01f, 4f); }
|
||||
}
|
||||
|
||||
private int lastactorCount = 0;
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace RimWorldAnimationStudio
|
|||
animationDef.Initialize();
|
||||
|
||||
Workspace.Instance.ClearHistory();
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("AnimationDef loaded");
|
||||
|
||||
AnimationController.Instance.MakeDirty();
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
AnimationStage stage = new AnimationStage();
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Stage addition");
|
||||
|
||||
return stage.MakeNew();
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
Workspace.animationDef.animationStages.Insert(Workspace.stageID + 1, stage);
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Stage clone");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -78,7 +78,9 @@ namespace RimWorldAnimationStudio
|
|||
Workspace.animationDef.animationStages[startIndex] = Workspace.animationDef.animationStages[startIndex + delta];
|
||||
Workspace.animationDef.animationStages[startIndex + delta] = stage;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.stageID = startIndex + delta;
|
||||
|
||||
Workspace.Instance.RecordEvent("Stage move");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -100,7 +102,7 @@ namespace RimWorldAnimationStudio
|
|||
Workspace.animationDef.animationStages.RemoveAt(Workspace.stageID);
|
||||
Workspace.stageID = Workspace.stageID >= Workspace.animationDef.animationStages.Count ? Workspace.stageID = Workspace.animationDef.animationStages.Count - 1 : Workspace.stageID;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
Workspace.Instance.RecordEvent("Stage deletion");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue