mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Extra keybinds
This commit is contained in:
parent
e210923733
commit
c3c0a05ac0
139 changed files with 586 additions and 233 deletions
|
@ -143,6 +143,7 @@ namespace RimWorldAnimationStudio
|
|||
{ continue; }
|
||||
|
||||
bool quiver = isAnimating && Workspace.Instance.GetCurrentOrPreviousKeyframe(actorID).quiver == true;
|
||||
bool requiresGenitals = actor.requiredGenitals.Any(x => x == "Penis") || Workspace.animationDef.actors[actorID].isFucking;
|
||||
|
||||
float clipPercent = (float)(stageTick % clip.duration) / clip.duration;
|
||||
if (stageTick == clip.duration) clipPercent = 1f;
|
||||
|
@ -184,7 +185,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
actorBody.bodyRenderer.sprite = alienRaceDef.GetBodyTypeGraphic((CardinalDirection)bodyFacing, bodyType);
|
||||
actorBody.headRenderer.sprite = alienRaceDef.isHumanoid ? alienRaceDef.GetHeadGraphic((CardinalDirection)headFacing) : null;
|
||||
actorBody.appendageRenderer.sprite = alienRaceDef.isHumanoid && bodyFacing != 0 ? Resources.Load<Sprite>("Textures/Humanlike/Appendages/Appendage" + bodyFacing) : null;
|
||||
actorBody.appendageRenderer.sprite = requiresGenitals && alienRaceDef.isHumanoid && bodyFacing != 0 ? Resources.Load<Sprite>("Textures/Humanlike/Appendages/Appendage" + bodyFacing) : null;
|
||||
|
||||
actorBody.bodyRenderer.gameObject.SetActive(actorBody.bodyRenderer.sprite != null);
|
||||
actorBody.headRenderer.gameObject.SetActive(actorBody.headRenderer.sprite != null);
|
||||
|
@ -352,7 +353,7 @@ namespace RimWorldAnimationStudio
|
|||
{ Debug.LogWarning("Cannot clone pawn keyframe - a keyframe already exists at this tick"); return; }
|
||||
|
||||
PawnKeyframe cloneFrame = keyframe.Copy();
|
||||
cloneFrame.GenerateKeyframeID();
|
||||
cloneFrame.GenerateKeyframeID(clipID);
|
||||
cloneFrame.atTick = stageTick;
|
||||
|
||||
PawnKeyframe nextKeyframe = clip.keyframes.FirstOrDefault(x => x.atTick > stageTick);
|
||||
|
@ -371,6 +372,48 @@ namespace RimWorldAnimationStudio
|
|||
Workspace.Instance.RecordEvent("Keyframe clone");
|
||||
}
|
||||
|
||||
public void CopyPawnKeyframes()
|
||||
{
|
||||
Workspace.copiedKeyframes.Clear();
|
||||
|
||||
List<PawnKeyframe> keyframesToClone = Workspace.Instance.GetPawnKeyframes(Workspace.keyframeID);
|
||||
|
||||
foreach (PawnKeyframe keyframe in keyframesToClone)
|
||||
{ Workspace.copiedKeyframes.Add(keyframe.Copy()); }
|
||||
}
|
||||
|
||||
public void PastePawnKeyframes()
|
||||
{
|
||||
foreach (PawnKeyframe keyframe in Workspace.copiedKeyframes)
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[keyframe.actorID];
|
||||
|
||||
if (Workspace.Instance.DoesPawnKeyframeExistAtTick(Workspace.stageID, keyframe.actorID, stageTick))
|
||||
{
|
||||
PawnKeyframe oldKeyframe = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[keyframe.actorID].keyframes.First(x => x.atTick == stageTick);
|
||||
|
||||
RemovePawnKeyframe(keyframe.actorID, oldKeyframe.keyframeID, true);
|
||||
}
|
||||
|
||||
keyframe.GenerateKeyframeID(keyframe.actorID);
|
||||
keyframe.atTick = stageTick;
|
||||
|
||||
PawnKeyframe nextKeyframe = clip.keyframes.FirstOrDefault(x => x.atTick > stageTick);
|
||||
|
||||
if (nextKeyframe != null)
|
||||
{ clip.keyframes.Insert(clip.keyframes.IndexOf(nextKeyframe), keyframe); }
|
||||
|
||||
else
|
||||
{ clip.keyframes.Add(keyframe); }
|
||||
|
||||
clip.BuildSimpleCurves();
|
||||
|
||||
animationTimelines.GetComponentsInChildren<AnimationTimeline>()[keyframe.actorID].AddPawnKeyFrame(keyframe.keyframeID);
|
||||
|
||||
clip.BuildSimpleCurves();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemovePawnKeyframe()
|
||||
{
|
||||
foreach (int keyframeID in Workspace.keyframeID)
|
||||
|
@ -380,17 +423,17 @@ namespace RimWorldAnimationStudio
|
|||
}
|
||||
}
|
||||
|
||||
public void RemovePawnKeyframe(int actorID, int keyframeID)
|
||||
public void RemovePawnKeyframe(int actorID, int keyframeID, bool force = false)
|
||||
{
|
||||
PawnKeyframe keyframe = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID);
|
||||
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[actorID];
|
||||
|
||||
if (keyframe == null || clip == null) return;
|
||||
|
||||
if (keyframe.atTick == 1)
|
||||
if (keyframe.atTick == 1 && force == false)
|
||||
{ Debug.LogWarning("Cannot delete key frame - the first key frame of an animation clip cannot be deleted"); return; }
|
||||
|
||||
if (clip.keyframes.Count <= 2)
|
||||
if (clip.keyframes.Count <= 2 && force == false)
|
||||
{ Debug.LogWarning("Cannot delete key frame - an animation clip must have two or more keyframes"); return; }
|
||||
|
||||
animationTimelines.GetComponentsInChildren<AnimationTimeline>()[actorID].RemovePawnKeyFrame(keyframe.keyframeID);
|
||||
|
|
|
@ -9,34 +9,220 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class InputManager : Singleton<InputManager>
|
||||
{
|
||||
private float lastUpdate = -1f;
|
||||
private float timeBetweenUpdates = 0.15f;
|
||||
private float largeStep = 0.1f;
|
||||
private float smallStep = 0.03f;
|
||||
|
||||
public bool CanUpdate()
|
||||
{
|
||||
if (Time.unscaledTime > lastUpdate + timeBetweenUpdates)
|
||||
{
|
||||
lastUpdate = Time.unscaledTime;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.Z))
|
||||
// Make new animation
|
||||
if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand)) && Input.GetKeyDown(KeyCode.N))
|
||||
{ ApplicationManager.Instance.TryToMakeNewAnimation(); }
|
||||
|
||||
// Save animation
|
||||
else if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand)) && Input.GetKeyDown(KeyCode.S))
|
||||
{ ApplicationManager.Instance.TryToSaveAnimation(); }
|
||||
|
||||
// Load animation
|
||||
else if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand)) && Input.GetKeyDown(KeyCode.L))
|
||||
{ ApplicationManager.Instance.TryToLoadAnimation(); }
|
||||
|
||||
// Exit if animationDef has not be loaded
|
||||
if (Workspace.animationDef == null) return;
|
||||
|
||||
// Play / pause
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{ AnimationController.Instance.ToggleAnimation(); }
|
||||
|
||||
// Move / switch actors
|
||||
else if (Input.GetKey(KeyCode.UpArrow) && CanUpdate())
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand))
|
||||
{
|
||||
Workspace.selectedBodyPart = null;
|
||||
Workspace.actorID = Mathf.Clamp(Workspace.actorID - 1, 0, Workspace.animationDef.actors.Count - 1);
|
||||
}
|
||||
|
||||
else if (Input.GetKey(KeyCode.LeftShift))
|
||||
{ ActorKeyframeCard.Instance.AdjustActor(Vector2.up * smallStep); }
|
||||
|
||||
else
|
||||
{ ActorKeyframeCard.Instance.AdjustActor(Vector2.up * largeStep); }
|
||||
}
|
||||
|
||||
else if (Input.GetKey(KeyCode.DownArrow) && CanUpdate())
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand))
|
||||
{
|
||||
Workspace.selectedBodyPart = null;
|
||||
Workspace.actorID = Mathf.Clamp(Workspace.actorID + 1, 0, Workspace.animationDef.actors.Count - 1);
|
||||
}
|
||||
|
||||
else if (Input.GetKey(KeyCode.LeftShift))
|
||||
{ ActorKeyframeCard.Instance.AdjustActor(Vector2.down * smallStep); }
|
||||
|
||||
else
|
||||
{ ActorKeyframeCard.Instance.AdjustActor(Vector2.down * largeStep); }
|
||||
}
|
||||
|
||||
else if (Input.GetKey(KeyCode.LeftArrow) && CanUpdate())
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{ ActorKeyframeCard.Instance.AdjustActor(Vector2.left * smallStep); }
|
||||
|
||||
else
|
||||
{ ActorKeyframeCard.Instance.AdjustActor(Vector2.left * largeStep); }
|
||||
}
|
||||
|
||||
else if (Input.GetKey(KeyCode.RightArrow) && CanUpdate())
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{ ActorKeyframeCard.Instance.AdjustActor(Vector2.right * smallStep); }
|
||||
|
||||
else
|
||||
{ ActorKeyframeCard.Instance.AdjustActor(Vector2.right * largeStep); }
|
||||
}
|
||||
|
||||
// Switch to actor panning
|
||||
else if (Input.GetKeyDown(KeyCode.Q))
|
||||
{ AnimationController.Instance.ToggleActorManipulationMode(0); }
|
||||
|
||||
// Switch to actor rotating
|
||||
else if (Input.GetKeyDown(KeyCode.W))
|
||||
{ AnimationController.Instance.ToggleActorManipulationMode(1); }
|
||||
|
||||
// SWitch to actor facing
|
||||
else if (Input.GetKeyDown(KeyCode.E))
|
||||
{ AnimationController.Instance.ToggleActorManipulationMode(2); }
|
||||
|
||||
// Switch between body parts
|
||||
else if (Input.GetKeyDown(KeyCode.Tab))
|
||||
{
|
||||
ActorBody actorBody = AnimationController.Instance.actorBodies.GetChild(Workspace.actorID).GetComponent<ActorBody>();
|
||||
List<ActorBodyPart> actorBodyParts = actorBody.GetComponentsInChildren<ActorBodyPart>().Where(x => x.gameObject.activeInHierarchy)?.ToList();
|
||||
|
||||
foreach(Transform c in actorBody.transform)
|
||||
{
|
||||
Debug.Log(c.gameObject + " " + c.gameObject.activeSelf);
|
||||
}
|
||||
|
||||
if (actorBodyParts.NullOrEmpty()) return;
|
||||
|
||||
if (Workspace.selectedBodyPart == null)
|
||||
{ actorBodyParts[0].Activate(); return; }
|
||||
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < actorBodyParts.Count; i++)
|
||||
{
|
||||
ActorBodyPart part = actorBodyParts[i];
|
||||
|
||||
if (part == Workspace.selectedBodyPart)
|
||||
{
|
||||
if (i < actorBodyParts.Count - 1)
|
||||
{ actorBodyParts[i + 1].Activate(); return; }
|
||||
|
||||
else
|
||||
{ actorBody.Activate(); return; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Move along time lines
|
||||
else if (Input.GetKey(KeyCode.PageUp) && CanUpdate())
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
PawnKeyframe keyframe = Workspace.Instance.GetPreviousKeyframe(Workspace.actorID);
|
||||
if (keyframe != null) AnimationController.Instance.stageTick = keyframe.atTick.Value;
|
||||
}
|
||||
|
||||
else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand))
|
||||
{ AnimationController.Instance.stageTick = 1; }
|
||||
|
||||
else
|
||||
{ AnimationController.Instance.stageTick = Mathf.Clamp(AnimationController.Instance.stageTick - 1, 1, Workspace.StageWindowSize); }
|
||||
}
|
||||
|
||||
else if (Input.GetKey(KeyCode.PageDown) && CanUpdate())
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
PawnKeyframe keyframe = Workspace.Instance.GetNextKeyframe(Workspace.actorID);
|
||||
if (keyframe != null) AnimationController.Instance.stageTick = keyframe.atTick.Value;
|
||||
}
|
||||
|
||||
else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand))
|
||||
{ AnimationController.Instance.stageTick = Workspace.StageWindowSize; }
|
||||
|
||||
else
|
||||
{ AnimationController.Instance.stageTick = Mathf.Clamp(AnimationController.Instance.stageTick + 1, 1, Workspace.StageWindowSize); }
|
||||
}
|
||||
|
||||
// Switch stages
|
||||
else if (Input.GetKeyDown(KeyCode.Home))
|
||||
{
|
||||
int prevStageID = Workspace.stageID;
|
||||
Workspace.stageID = Mathf.Clamp(Workspace.stageID - 1, 0, Workspace.animationDef.animationStages.Count - 1);
|
||||
|
||||
if (Workspace.stageID != prevStageID)
|
||||
{ Workspace.Instance.RecordEvent("Stage selected"); }
|
||||
}
|
||||
|
||||
else if (Input.GetKeyDown(KeyCode.End))
|
||||
{
|
||||
|
||||
int prevStageID = Workspace.stageID;
|
||||
Workspace.stageID = Mathf.Clamp(Workspace.stageID + 1, 0, Workspace.animationDef.animationStages.Count - 1);
|
||||
|
||||
if (Workspace.stageID != prevStageID)
|
||||
{ Workspace.Instance.RecordEvent("Stage selected"); }
|
||||
}
|
||||
|
||||
// Undo
|
||||
else 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(); }
|
||||
|
||||
// Redo
|
||||
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(); }
|
||||
// Copy keyframes
|
||||
else if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.C))
|
||||
{ AnimationController.Instance.CopyPawnKeyframes(); }
|
||||
|
||||
else if (Input.GetKey(KeyCode.LeftCommand) && Input.GetKeyDown(KeyCode.C))
|
||||
{ AnimationController.Instance.CopyPawnKeyframes(); }
|
||||
|
||||
// Paste keyframes
|
||||
else if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.V))
|
||||
{ AnimationController.Instance.PastePawnKeyframes(); }
|
||||
|
||||
else if (Input.GetKey(KeyCode.LeftCommand) && Input.GetKeyDown(KeyCode.X))
|
||||
{ AnimationController.Instance.PastePawnKeyframes(); }
|
||||
|
||||
// Delete keyframes
|
||||
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(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue