Expanded menus and bug fixes

This commit is contained in:
AbstractConcept 2022-10-15 01:00:47 -05:00
parent cc28ac4bd4
commit 721443592f
146 changed files with 5891 additions and 269 deletions

View file

@ -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)

View file

@ -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)