mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Expanded menus and bug fixes
This commit is contained in:
parent
cc28ac4bd4
commit
721443592f
146 changed files with 5891 additions and 269 deletions
|
@ -22,28 +22,22 @@ namespace RimWorldAnimationStudio
|
|||
this.actorID = actorID;
|
||||
|
||||
PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(actorID);
|
||||
clip.BuildSimpleCurves();
|
||||
|
||||
if (clip == null || clip.keyframes.NullOrEmpty())
|
||||
{
|
||||
clip = new PawnAnimationClip();
|
||||
clip.keyframes.Add(new PawnKeyframe());
|
||||
clip.BuildSimpleCurves();
|
||||
}
|
||||
foreach (KeyframeSlider slider in GetComponentsInChildren<KeyframeSlider>())
|
||||
{ RemovePawnKeyFrame(slider.keyframeID);}
|
||||
|
||||
foreach (PawnKeyframe keyframe in clip.keyframes)
|
||||
{
|
||||
KeyframeSlider keyframeSlider = Instantiate(keyframeSliderPrefab, transform);
|
||||
keyframeSlider.Initialize(this, actorID, keyframe.keyframeID);
|
||||
}
|
||||
{ AddPawnKeyFrame(keyframe.keyframeID); }
|
||||
|
||||
int keyframeCount = clip.keyframes.Count;
|
||||
/*int keyframeCount = clip.keyframes.Count;
|
||||
int childCount = GetComponentsInChildren<KeyframeSlider>().Count();
|
||||
|
||||
for (int i = 0; i < Mathf.Max(keyframeCount, childCount); i++)
|
||||
{
|
||||
// Add new keyframe sliders as required
|
||||
if (i >= childCount)
|
||||
{ Instantiate(keyframeSliderPrefab, transform); }
|
||||
{ AddPawnKeyFrame(clip.keyframes[i].keyframeID); }
|
||||
|
||||
// Get objects to update
|
||||
KeyframeSlider keyframeSlider = GetComponentsInChildren<KeyframeSlider>()[i];
|
||||
|
@ -54,8 +48,8 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
// Remove excess objects as required
|
||||
else
|
||||
{ Destroy(keyframeSlider.gameObject); }
|
||||
}
|
||||
{ RemovePawnKeyFrame(GetComponentsInChildren<KeyframeSlider>()[i].keyframeID); }
|
||||
}*/
|
||||
}
|
||||
|
||||
public void AddPawnKeyFrame(int keyframeID)
|
||||
|
|
|
@ -44,8 +44,6 @@ namespace RimWorldAnimationStudio
|
|||
maxValue = Workspace.StageWindowSize;
|
||||
value = keyframe.atTick.Value;
|
||||
|
||||
OnValueChanged();
|
||||
|
||||
onValueChanged.AddListener(delegate (float value) { OnValueChanged(); });
|
||||
}
|
||||
|
||||
|
@ -124,18 +122,22 @@ namespace RimWorldAnimationStudio
|
|||
// Link other slected keyframes to the movement of this one
|
||||
if (selectedKeyframes.NotNullOrEmpty())
|
||||
{
|
||||
pivotKeyframe = keyframe.atTick <= selectedKeyframes.Min(x => x.atTick) ?
|
||||
selectedKeyframes.FirstOrDefault(x => x.atTick >= selectedKeyframes.Max(y => y.atTick)) :
|
||||
selectedKeyframes.FirstOrDefault(x => x.atTick <= selectedKeyframes.Min(y => y.atTick));
|
||||
|
||||
foreach (PawnKeyframe selectedKeyframe in selectedKeyframes)
|
||||
{
|
||||
KeyframeSlider unlinkedSlider = selectedKeyframe.GetKeyframeSlider();
|
||||
|
||||
if (unlinkedSlider != null)
|
||||
{
|
||||
if (AnimationController.Instance.stretchKeyframesToggle.isOn && unlinkedSlider.keyframe.atTick == pivotKeyframe.atTick) continue;
|
||||
|
||||
unlinkedSlider.linkedSlider = this;
|
||||
unlinkedSlider.linkedOffset = unlinkedSlider.keyframe.atTick.Value - keyframe.atTick.Value;
|
||||
}
|
||||
}
|
||||
|
||||
pivotKeyframe = keyframe.atTick < selectedKeyframes[0].atTick ? selectedKeyframes.Last() : selectedKeyframes.First();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,13 +170,17 @@ namespace RimWorldAnimationStudio
|
|||
if (keyframe.atTick == Constants.minTick)
|
||||
{ value = Constants.minTick; return; }
|
||||
|
||||
foreach (Selectable otherSlider in Selectable.allSelectablesArray)
|
||||
foreach (Selectable linkedSlider in Selectable.allSelectablesArray)
|
||||
{
|
||||
if (otherSlider is KeyframeSlider)
|
||||
{ Debug.Log("unlinked keyframes"); (otherSlider as KeyframeSlider).linkedSlider = null; }
|
||||
if (linkedSlider is KeyframeSlider)
|
||||
{
|
||||
(linkedSlider as KeyframeSlider).linkedSlider = null;
|
||||
(linkedSlider as KeyframeSlider).pivotKeyframe = null;
|
||||
}
|
||||
}
|
||||
|
||||
interactable = false;
|
||||
|
||||
Workspace.Instance.RecordEvent("Keyframe move");
|
||||
}
|
||||
|
||||
|
@ -186,7 +192,7 @@ namespace RimWorldAnimationStudio
|
|||
if (Workspace.keyframeID.NullOrEmpty() || Workspace.keyframeID.Contains(keyframeID) == false)
|
||||
{ linkedSlider = null; }
|
||||
|
||||
else if (AnimationController.Instance.stretchKeyframesToggle.isOn && linkedSlider != null && linkedSlider.IsPivotKeyframe(keyframe) == false)
|
||||
else if (AnimationController.Instance.stretchKeyframesToggle.isOn && linkedSlider != null)
|
||||
{ value = Mathf.CeilToInt(linkedSlider.keyframe.atTick.Value + linkedOffset * linkedSlider.ScaledOffsetFromPivot()); }
|
||||
|
||||
else if (AnimationController.Instance.stretchKeyframesToggle.isOn == false && linkedSlider != null)
|
||||
|
|
|
@ -421,11 +421,14 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void PastePawnKeyframes()
|
||||
{
|
||||
MakeTimelineDirty();
|
||||
|
||||
int originalWindowSize = Workspace.StageWindowSize;
|
||||
|
||||
|
||||
List<int> actorsInvolved = Workspace.copiedKeyframes.Select(x => x.actorID)?.ToList();
|
||||
actorsInvolved = actorsInvolved?.Distinct()?.ToList();
|
||||
|
||||
foreach (int i in actorsInvolved) { Debug.Log("Actor: " + i); }
|
||||
|
||||
if (actorsInvolved.NullOrEmpty()) { Debug.Log("Cannot paste keyframes - there were no copied keyframes to paste"); return; }
|
||||
if (actorsInvolved.Count > 1 && actorsInvolved.Contains(Workspace.actorID) == false) { Debug.Log("Cannot paste keyframes - keyframes copied across multiple timelines can only be pasted back into these source timelines"); return; }
|
||||
|
||||
|
@ -458,7 +461,7 @@ namespace RimWorldAnimationStudio
|
|||
clonedKeyframe.atTick = tickToPasteAt;
|
||||
|
||||
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[targetActorID];
|
||||
PawnKeyframe nextKeyframe = clip.keyframes.FirstOrDefault(x => x.atTick > stageTick);
|
||||
PawnKeyframe nextKeyframe = clip.keyframes.FirstOrDefault(x => x.atTick > tickToPasteAt);
|
||||
|
||||
if (nextKeyframe != null)
|
||||
{ clip.keyframes.Insert(clip.keyframes.IndexOf(nextKeyframe), clonedKeyframe); }
|
||||
|
@ -467,10 +470,15 @@ namespace RimWorldAnimationStudio
|
|||
{ clip.keyframes.Add(clonedKeyframe); }
|
||||
|
||||
clip.BuildSimpleCurves();
|
||||
|
||||
animationTimelines.GetComponentsInChildren<AnimationTimeline>()[clonedKeyframe.actorID].AddPawnKeyFrame(clonedKeyframe.keyframeID);
|
||||
}
|
||||
|
||||
if (originalWindowSize != Workspace.StageWindowSize)
|
||||
{
|
||||
StretchKeyframes(originalWindowSize);
|
||||
ResizeStageWindowSize(originalWindowSize);
|
||||
}
|
||||
|
||||
Workspace.Instance.RecordEvent("Keyframe pasted");
|
||||
}
|
||||
|
||||
|
@ -567,6 +575,7 @@ namespace RimWorldAnimationStudio
|
|||
}
|
||||
|
||||
ResizeStageWindowSize(newStageWindowSize);
|
||||
Workspace.Instance.RecordEvent("Stage length");
|
||||
}
|
||||
|
||||
public void StretchKeyframes(int newStageWindowSize)
|
||||
|
@ -592,8 +601,6 @@ namespace RimWorldAnimationStudio
|
|||
Workspace.animationDef.animationStages[Workspace.stageID].stageWindowSize = newStageWindowSize;
|
||||
Workspace.animationDef.animationStages[Workspace.stageID].playTimeTicks = newStageWindowSize * int.Parse(cyclesNormalField.text);
|
||||
Workspace.animationDef.animationStages[Workspace.stageID].playTimeTicksQuick = newStageWindowSize * int.Parse(cyclesFastField.text);
|
||||
|
||||
Workspace.Instance.RecordEvent("Stage length");
|
||||
}
|
||||
|
||||
public void OnCycleNormalFieldChange()
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void ResetCamera()
|
||||
{
|
||||
cam.transform.position = new Vector3(-1, 0, -10);
|
||||
cam.transform.position = new Vector3(1, 0, -10);
|
||||
curZoom = zoom;
|
||||
|
||||
mouseDragActive = false;
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace RimWorldAnimationStudio
|
|||
public GameObject keyframeSelector;
|
||||
|
||||
private float lastUpdate = -1f;
|
||||
private float timeBetweenUpdates = 0.15f;
|
||||
private float largeStep = 0.1f;
|
||||
private float smallStep = 0.03f;
|
||||
|
||||
|
@ -24,7 +23,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public bool CanRepeatThisUpdate()
|
||||
{
|
||||
if (Time.unscaledTime > lastUpdate + timeBetweenUpdates)
|
||||
if (Time.unscaledTime > lastUpdate + Constants.actionRepeatSpeed)
|
||||
{
|
||||
lastUpdate = Time.unscaledTime;
|
||||
return true;
|
||||
|
@ -402,5 +401,22 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
Camera.main.GetComponent<CameraController>().ResetCamera();
|
||||
}
|
||||
|
||||
public void StretchKeyframesToggle()
|
||||
{
|
||||
AnimationController.Instance.stretchKeyframesToggle.isOn = !AnimationController.Instance.stretchKeyframesToggle.isOn;
|
||||
}
|
||||
|
||||
public void OpenProjectHome()
|
||||
{
|
||||
if (Uri.IsWellFormedUriString(Constants.projectHome, UriKind.RelativeOrAbsolute))
|
||||
{ Application.OpenURL(Constants.projectHome); }
|
||||
}
|
||||
|
||||
public void OpenProjectWiki()
|
||||
{
|
||||
if (Uri.IsWellFormedUriString(Constants.projectWiki, UriKind.RelativeOrAbsolute))
|
||||
{ Application.OpenURL(Constants.projectWiki); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,12 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public static class Constants
|
||||
{
|
||||
public static string currentVersion = "0.0.0";
|
||||
public static string projectHome = "https://gitgud.io/AbstractConcept/rimworld-animation-studio";
|
||||
public static string projectWiki = "https://gitgud.io/AbstractConcept/rimworld-animation-studio/-/wikis/home";
|
||||
|
||||
public static float actionRepeatSpeed = 0.250f;
|
||||
|
||||
public static int defaultAnimationClipLength = 600;
|
||||
public static int minTick = 1;
|
||||
public static int minAnimationClipLength = 2;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
@ -8,15 +9,27 @@ namespace RimWorldAnimationStudio
|
|||
public class RequiresAnimationDef : MonoBehaviour
|
||||
{
|
||||
private Button button;
|
||||
private List<Text> buttonText;
|
||||
private List<Color> buttonTextColor = new List<Color>();
|
||||
|
||||
public void Start()
|
||||
{
|
||||
button = GetComponent<Button>();
|
||||
buttonText = GetComponentsInChildren<Text>()?.ToList();
|
||||
|
||||
if (buttonText != null)
|
||||
{
|
||||
for (int i = 0; i < buttonText.Count; i++)
|
||||
{ buttonTextColor.Add(buttonText[i].color); }
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
button.interactable = Workspace.animationDef != null;
|
||||
|
||||
for (int i = 0; i < buttonText.Count; i++)
|
||||
{ buttonText[i].color = button.interactable ? buttonTextColor[i] : Constants.ColorMidGrey; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue