mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Basic keybinds plus multi key selection
This commit is contained in:
parent
518a912ef1
commit
842c954455
89 changed files with 977 additions and 164 deletions
|
@ -132,10 +132,10 @@ namespace RimWorldAnimationStudio
|
|||
for (int actorID = 0; actorID < _actorBodies.Count; actorID++)
|
||||
{
|
||||
if (Workspace.stageID >= Workspace.animationDef?.animationStages.Count)
|
||||
{ Debug.Log("Waiting for animation stage data to initialize..."); return; }
|
||||
{ /*Debug.Log("Waiting for animation stage data to initialize...");*/ return; }
|
||||
|
||||
if (actorID >= Workspace.animationDef?.animationStages[Workspace.stageID]?.animationClips.Count)
|
||||
{ Debug.Log("Waiting for animation clip data to initialize..."); return; }
|
||||
{ /*Debug.Log("Waiting for animation clip data to initialize...");*/ return; }
|
||||
|
||||
Actor actor = Workspace.animationDef.actors[actorID];
|
||||
PawnAnimationClip clip = Workspace.animationDef?.animationStages[Workspace.stageID]?.animationClips[actorID];
|
||||
|
@ -340,39 +340,45 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void ClonePawnKeyframe()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.Instance.GetCurrentPawnAnimationClip();
|
||||
List<PawnKeyframe> keyframes = clip?.keyframes;
|
||||
PawnKeyframe keyframe = Workspace.Instance.GetPawnKeyframe(Workspace.actorID, Workspace.keyframeID);
|
||||
List<PawnKeyframe> keyframesToClone = Workspace.Instance.GetPawnKeyframes(Workspace.keyframeID);
|
||||
|
||||
if (clip == null || keyframes == null)
|
||||
{ Debug.LogWarning("Cannot clone pawn keyframe - the AnimationDef is invalid"); return; }
|
||||
foreach (PawnKeyframe keyframe in keyframesToClone)
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.Instance.GetAnimationClipThatOwnsKeyframe(keyframe.keyframeID, out int clipID);
|
||||
|
||||
if (keyframes.FirstOrDefault(x => x.atTick == stageTick) != null)
|
||||
{ Debug.LogWarning("Cannot clone pawn keyframe - a keyframe already exists at this tick"); return; }
|
||||
if (clip == null)
|
||||
{ Debug.LogWarning("Cannot clone pawn keyframe - no clip owns this keyframe"); continue; }
|
||||
|
||||
if (keyframe == null)
|
||||
{ Debug.LogWarning("Cannot clone pawn keyframe - no keyframe has been selected for cloning"); return; }
|
||||
if (clip.keyframes.FirstOrDefault(x => x.atTick == stageTick) != null)
|
||||
{ Debug.LogWarning("Cannot clone pawn keyframe - a keyframe already exists at this tick"); return; }
|
||||
|
||||
PawnKeyframe cloneFrame = keyframe.Copy();
|
||||
cloneFrame.GenerateKeyframeID();
|
||||
cloneFrame.atTick = stageTick;
|
||||
PawnKeyframe cloneFrame = keyframe.Copy();
|
||||
cloneFrame.GenerateKeyframeID();
|
||||
cloneFrame.atTick = stageTick;
|
||||
|
||||
PawnKeyframe nextKeyframe = keyframes.FirstOrDefault(x => x.atTick > stageTick);
|
||||
PawnKeyframe nextKeyframe = clip.keyframes.FirstOrDefault(x => x.atTick > stageTick);
|
||||
|
||||
if (nextKeyframe != null)
|
||||
{ keyframes.Insert(keyframes.IndexOf(nextKeyframe), cloneFrame); }
|
||||
if (nextKeyframe != null)
|
||||
{ clip.keyframes.Insert(clip.keyframes.IndexOf(nextKeyframe), cloneFrame); }
|
||||
|
||||
else
|
||||
{ keyframes.Add(cloneFrame); }
|
||||
else
|
||||
{ clip.keyframes.Add(cloneFrame); }
|
||||
|
||||
clip.BuildSimpleCurves();
|
||||
clip.BuildSimpleCurves();
|
||||
|
||||
animationTimelines.GetComponentsInChildren<AnimationTimeline>()[Workspace.actorID].AddPawnKeyFrame(cloneFrame.keyframeID);
|
||||
animationTimelines.GetComponentsInChildren<AnimationTimeline>()[clipID].AddPawnKeyFrame(cloneFrame.keyframeID);
|
||||
}
|
||||
|
||||
Workspace.Instance.RecordEvent("Keyframe clone");
|
||||
}
|
||||
|
||||
public void RemovePawnKeyframe()
|
||||
{
|
||||
RemovePawnKeyframe(Workspace.actorID, Workspace.keyframeID);
|
||||
foreach (int keyframeID in Workspace.keyframeID)
|
||||
{
|
||||
if (Workspace.Instance.GetAnimationClipThatOwnsKeyframe(keyframeID, out int clipID) != null)
|
||||
{ RemovePawnKeyframe(clipID, keyframeID); }
|
||||
}
|
||||
}
|
||||
|
||||
public void RemovePawnKeyframe(int actorID, int keyframeID)
|
||||
|
@ -388,7 +394,7 @@ namespace RimWorldAnimationStudio
|
|||
if (clip.keyframes.Count <= 2)
|
||||
{ Debug.LogWarning("Cannot delete key frame - an animation clip must have two or more keyframes"); return; }
|
||||
|
||||
animationTimelines.GetComponentsInChildren<AnimationTimeline>()[Workspace.actorID].RemovePawnKeyFrame(keyframe.keyframeID);
|
||||
animationTimelines.GetComponentsInChildren<AnimationTimeline>()[actorID].RemovePawnKeyFrame(keyframe.keyframeID);
|
||||
|
||||
clip.keyframes.Remove(keyframe);
|
||||
clip.BuildSimpleCurves();
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace RimWorldAnimationStudio
|
|||
public class ApplicationManager : Singleton<ApplicationManager>
|
||||
{
|
||||
public DialogBox exitDialog;
|
||||
public DialogBox newAnimationDialog;
|
||||
public SelectAnimationDialog selectAnimationDialog;
|
||||
|
||||
public void Start()
|
||||
|
@ -74,7 +75,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
}
|
||||
|
||||
public void TrySaveAnimation()
|
||||
public void TryToSaveAnimation()
|
||||
{
|
||||
if (Workspace.animationDef == null)
|
||||
{ return; }
|
||||
|
@ -121,6 +122,14 @@ namespace RimWorldAnimationStudio
|
|||
}
|
||||
}
|
||||
|
||||
public void TryToMakeNewAnimation()
|
||||
{
|
||||
if (Workspace.animationDef == null)
|
||||
{ NewAnimation(); return; }
|
||||
|
||||
newAnimationDialog.Pop();
|
||||
}
|
||||
|
||||
public void NewAnimation()
|
||||
{
|
||||
var path = Path.Combine(Application.streamingAssetsPath, "AnimationDefs/newAnimationDef.xml");
|
||||
|
|
42
Assets/Scripts/Managers/InputManager.cs
Normal file
42
Assets/Scripts/Managers/InputManager.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class InputManager : Singleton<InputManager>
|
||||
{
|
||||
public void Update()
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.Z))
|
||||
{ Workspace.Instance.Undo(); }
|
||||
|
||||
else if (Input.GetKey(KeyCode.LeftCommand) && Input.GetKeyDown(KeyCode.Z))
|
||||
{ Workspace.Instance.Undo(); }
|
||||
|
||||
else if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.Y))
|
||||
{ Workspace.Instance.Redo(); }
|
||||
|
||||
else if (Input.GetKey(KeyCode.LeftCommand) && Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.Z))
|
||||
{ Workspace.Instance.Redo(); }
|
||||
|
||||
else if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand)) && Input.GetKeyDown(KeyCode.C))
|
||||
{ AnimationController.Instance.ClonePawnKeyframe(); }
|
||||
|
||||
else if (Input.GetKey(KeyCode.Backspace) || Input.GetKey(KeyCode.Delete))
|
||||
{ AnimationController.Instance.RemovePawnKeyframe(); }
|
||||
|
||||
else if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand)) && Input.GetKeyDown(KeyCode.N))
|
||||
{ ApplicationManager.Instance.TryToMakeNewAnimation(); }
|
||||
|
||||
else if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand)) && Input.GetKeyDown(KeyCode.S))
|
||||
{ ApplicationManager.Instance.TryToSaveAnimation(); }
|
||||
|
||||
else if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand)) && Input.GetKeyDown(KeyCode.L))
|
||||
{ ApplicationManager.Instance.TryToLoadAnimation(); }
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Managers/InputManager.cs.meta
Normal file
11
Assets/Scripts/Managers/InputManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 120c040fa90da65478716f3ccda1248f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue