mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Ghost frames fix plus undo redo system
This commit is contained in:
parent
591b176924
commit
b0a965e0b2
163 changed files with 948 additions and 214 deletions
|
@ -43,12 +43,11 @@ namespace RimWorldAnimationStudio
|
|||
public void OnValueChanged()
|
||||
{
|
||||
keyframe.atTick = (int)value;
|
||||
|
||||
UpdateGhostFrames();
|
||||
|
||||
clip.BuildSimpleCurves();
|
||||
|
||||
AnimationController.Instance.stageTick = keyframe.atTick.Value;
|
||||
|
||||
timeline.InitiateUpdateOfGhostFrames();
|
||||
}
|
||||
|
||||
// Ghost sliders are non-interactable slider handle
|
||||
|
@ -57,27 +56,25 @@ namespace RimWorldAnimationStudio
|
|||
if (maxGhosts == 0)
|
||||
{ return; }
|
||||
|
||||
int nGhosts = GetGhostFramesRequired();
|
||||
int requiredGhosts = GetGhostFramesRequired();
|
||||
int currentGhostCount = ghostSliders.childCount;
|
||||
|
||||
for (int i = 0; i < Mathf.Max(nGhosts, ghostSliders.childCount); i++)
|
||||
for (int i = 0; i < Mathf.Max(requiredGhosts, currentGhostCount); i++)
|
||||
{
|
||||
if ((i - 1) * clip.duration + keyframe.atTick <= Workspace.StageWindowSize)
|
||||
{
|
||||
if (ghostSliders.childCount <= i)
|
||||
{ Instantiate(ghostSliderPrefab, ghostSliders); }
|
||||
int targetTick = (int)(i * clip.duration + keyframe.atTick);
|
||||
|
||||
GameObject ghostSliderObject = ghostSliders.GetChild(i).gameObject;
|
||||
ghostSliderObject.SetActive(true);
|
||||
if (ghostSliders.childCount <= i)
|
||||
{ Instantiate(ghostSliderPrefab, ghostSliders); }
|
||||
|
||||
Slider ghostSlider = ghostSliderObject.GetComponent<Slider>();
|
||||
ghostSlider.value = (int)((i + 1) * clip.duration + keyframe.atTick);
|
||||
GameObject ghostSliderObject = ghostSliders.GetChild(i).gameObject;
|
||||
ghostSliderObject.SetActive(i < requiredGhosts);
|
||||
|
||||
float mult = 1f - Mathf.Pow((float)i / maxGhosts, 2);
|
||||
ghostSlider.transform.FindDeepChild("Handle").GetComponent<Image>().color = new Color(0, 0.5f, 0.5f, 0.5f * mult);
|
||||
}
|
||||
|
||||
if (i >= nGhosts)
|
||||
{ transform.GetChild(i).gameObject.SetActive(false); }
|
||||
Slider ghostSlider = ghostSliderObject.GetComponent<Slider>();
|
||||
ghostSlider.maxValue = Workspace.StageWindowSize;
|
||||
ghostSlider.value = targetTick;
|
||||
|
||||
if (targetTick > ghostSlider.maxValue)
|
||||
{ ghostSlider.gameObject.SetActive(false); }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,9 +95,9 @@ namespace RimWorldAnimationStudio
|
|||
Workspace.keyframeID = keyframeID;
|
||||
|
||||
if (eventData.clickCount >= 2)
|
||||
{
|
||||
AnimationController.Instance.stageTick = keyframe.atTick.Value;
|
||||
}
|
||||
{ AnimationController.Instance.stageTick = keyframe.atTick.Value; }
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
|
@ -126,6 +123,8 @@ namespace RimWorldAnimationStudio
|
|||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
interactable = false;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue