public override void OnAnimationChanged() { NW4RAnimationNode node = TargetAnimation; selectedAnimationToolStripMenuItem.Enabled = node != null; portToolStripMenuItem.Enabled = node is CHR0Node; mergeToolStripMenuItem.Enabled = node != null && Array.IndexOf(Mergeable, node.GetType()) >= 0; resizeToolStripMenuItem.Enabled = node != null && Array.IndexOf(Resizable, node.GetType()) >= 0; appendToolStripMenuItem.Enabled = node != null && Array.IndexOf(Appendable, node.GetType()) >= 0; int i = -1; bool hasKeys = node != null && !(node is SCN0Node) && (i = Array.IndexOf(Interpolated, node.GetType())) >= 0; string s = i == 0 ? SelectedBone != null ? SelectedBone.Name : "entry" : i == 1 ? TargetTexRef != null ? TargetTexRef.Name : "entry" : i == 2 ? shp0Editor.VertexSetDest != null ? shp0Editor.VertexSetDest.Name : "entry" : "entry"; averageboneStartendTangentsToolStripMenuItem.Enabled = hasKeys && s != "entry"; averageboneStartendTangentsToolStripMenuItem.Text = $"Average {s} start/end keyframes"; averageAllStartEndTangentsToolStripMenuItem.Enabled = node != null && Array.IndexOf(Interpolated, node.GetType()) >= 0; //syncStartendTangentsToolStripMenuItem.Enabled = node != null && Array.IndexOf(Interpolated, node.GetType()) >= 0; }
/// <summary> /// Updates controls when the target animation has changed. /// Does nothing if the type does not match the current target type. /// </summary> public void AnimChanged(NW4RAnimType type) { if (type != TargetAnimType && type != NW4RAnimType.None) { return; } UpdateEditor(); UpdateKeyframePanel(); NW4RAnimationNode node = GetAnimation(type); if (node == null) { _maxFrame = 0; EnableTransformEdit = true; _updating = true; PlaybackPanel.numFrameIndex.Maximum = _maxFrame; PlaybackPanel.numTotalFrames.Minimum = 0; PlaybackPanel.numTotalFrames.Value = 0; PlaybackPanel.btnPlay.Enabled = PlaybackPanel.numTotalFrames.Enabled = PlaybackPanel.numFrameIndex.Enabled = PlaybackPanel.btnLast.Enabled = PlaybackPanel.btnFirst.Enabled = PlaybackPanel.Enabled = false; _updating = false; GetFiles(NW4RAnimType.None); SetFrame(0); } else { int loopBias = node.Loop && Interpolated.Contains(node.GetType()) ? 1 : 0; _maxFrame = node.FrameCount; EnableTransformEdit = !_playing; _updating = true; PlaybackPanel.btnPlay.Enabled = PlaybackPanel.numFrameIndex.Enabled = PlaybackPanel.numTotalFrames.Enabled = PlaybackPanel.Enabled = true; PlaybackPanel.numTotalFrames.Minimum = loopBias + 1; PlaybackPanel.numTotalFrames.Value = (decimal)(_maxFrame + loopBias); PlaybackPanel.numFrameIndex.Maximum = (decimal)(_maxFrame + loopBias); _updating = false; GetFiles(TargetAnimType); SetFrame(1); } //UpdateModel(); //UpdatePropDisplay(); OnAnimationChanged(); }
public virtual void SetFrame(int index) { if (index < 0) { return; } NW4RAnimationNode node = TargetAnimation; int loopMax = _maxFrame + (node != null && node.Loop && Interpolated.Contains(node.GetType()) ? 1 : 0); if (index > loopMax) { return; } CurrentFrame = index; if (PlaybackPanel != null) { if (PlaybackPanel.InvokeRequired) { Action <int, int> d = new Action <int, int>(PlaybackPanel.UpdateInterface); this.Invoke(d, new object[] { _animFrame, loopMax }); } else { PlaybackPanel.UpdateInterface(_animFrame, loopMax); } } if (!_playing) { if (InterpolationEditor != null && InterpolationEditor.Visible) { InterpolationEditor.Frame = CurrentFrame; } if (KeyframePanel != null) { KeyframePanel.numFrame_ValueChanged(); } } }