Add new timeline by JuPaHe64

This commit is contained in:
KillzXGaming 2019-03-30 11:18:15 -04:00
parent 3d63151626
commit 2ee73e7857
15 changed files with 287 additions and 61 deletions

Binary file not shown.

View file

@ -167,7 +167,7 @@ namespace Bfres.Structs
var animBone = model.Skeleton.GetBone(bone.Text);
if (animBone != null)
return model.Skeleton;
return model.Skeleton;
}
}
}

View file

@ -34,8 +34,8 @@
this.totalFrame = new System.Windows.Forms.NumericUpDown();
this.currentFrameUpDown = new System.Windows.Forms.NumericUpDown();
this.animationPlayBtn = new System.Windows.Forms.Button();
this.animationTrackBar = new ColorSlider.ColorSlider();
this.stPanel1 = new Switch_Toolbox.Library.Forms.STPanel();
this.animationTrackBar = new Switch_Toolbox.Library.Forms.TimeLine();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.totalFrame)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.currentFrameUpDown)).BeginInit();
@ -120,45 +120,6 @@
this.animationPlayBtn.UseVisualStyleBackColor = false;
this.animationPlayBtn.Click += new System.EventHandler(this.animationPlayBtn_Click);
//
// animationTrackBar
//
this.animationTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.animationTrackBar.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.animationTrackBar.BarInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.animationTrackBar.BarPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.animationTrackBar.BarPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.animationTrackBar.BorderRoundRectSize = new System.Drawing.Size(8, 8);
this.animationTrackBar.ElapsedInnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.animationTrackBar.ElapsedPenColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.animationTrackBar.ElapsedPenColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.animationTrackBar.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F);
this.animationTrackBar.ForeColor = System.Drawing.Color.Silver;
this.animationTrackBar.LargeChange = ((uint)(5u));
this.animationTrackBar.Location = new System.Drawing.Point(0, 16);
this.animationTrackBar.MouseEffects = false;
this.animationTrackBar.Name = "animationTrackBar";
this.animationTrackBar.ScaleDivisions = 10;
this.animationTrackBar.ScaleSubDivisions = 5;
this.animationTrackBar.ShowDivisionsText = true;
this.animationTrackBar.ShowSmallScale = true;
this.animationTrackBar.Size = new System.Drawing.Size(631, 147);
this.animationTrackBar.SmallChange = ((uint)(0u));
this.animationTrackBar.TabIndex = 3;
this.animationTrackBar.Text = "colorSlider1";
this.animationTrackBar.ThumbInnerColor = System.Drawing.Color.Olive;
this.animationTrackBar.ThumbOuterColor = System.Drawing.Color.Olive;
this.animationTrackBar.ThumbPenColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.animationTrackBar.ThumbRoundRectSize = new System.Drawing.Size(1, 1);
this.animationTrackBar.ThumbSize = new System.Drawing.Size(5, 128);
this.animationTrackBar.TickAdd = 0F;
this.animationTrackBar.TickColor = System.Drawing.Color.Gray;
this.animationTrackBar.TickDivide = 1F;
this.animationTrackBar.Value = 0;
this.animationTrackBar.ValueChanged += new System.EventHandler(this.animationTrackBar_ValueChanged);
this.animationTrackBar.Scroll += new System.Windows.Forms.ScrollEventHandler(this.colorSlider1_Scroll);
//
// stPanel1
//
this.stPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@ -168,12 +129,24 @@
this.stPanel1.Size = new System.Drawing.Size(631, 16);
this.stPanel1.TabIndex = 5;
//
// animationTrackBar
//
this.animationTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.animationTrackBar.CurrentFrame = 0;
this.animationTrackBar.FrameCount = 1000;
this.animationTrackBar.Location = new System.Drawing.Point(0, 14);
this.animationTrackBar.Name = "animationTrackBar";
this.animationTrackBar.Size = new System.Drawing.Size(631, 149);
this.animationTrackBar.TabIndex = 6;
//
// AnimationPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.stPanel1);
this.Controls.Add(this.animationTrackBar);
this.Controls.Add(this.stPanel1);
this.Controls.Add(this.panel1);
this.Name = "AnimationPanel";
this.Size = new System.Drawing.Size(631, 194);
@ -190,8 +163,6 @@
}
#endregion
private ColorSlider.ColorSlider animationTrackBar;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button animationPlayBtn;
private System.Windows.Forms.Panel panel1;
@ -199,5 +170,6 @@
private System.Windows.Forms.NumericUpDown currentFrameUpDown;
private Forms.STPanel stPanel1;
private Forms.STCheckBox loopChkBox;
private Forms.TimeLine animationTrackBar;
}
}

View file

@ -76,9 +76,7 @@ namespace Switch_Toolbox.Library
totalFrame.Maximum = frameCount;
totalFrame.Value = frameCount;
currentFrameUpDown.Maximum = frameCount;
animationTrackBar.TickDivide = 1;
animationTrackBar.Maximum = frameCount;
animationTrackBar.Minimum = 0;
animationTrackBar.FrameCount = frameCount;
currentFrameUpDown.Value = 1;
currentFrameUpDown.Value = 0;
}
@ -111,7 +109,7 @@ namespace Switch_Toolbox.Library
animationTrackBar.BackColor = FormThemes.BaseTheme.FormBackColor;
animationTrackBar.ForeColor = FormThemes.BaseTheme.FormForeColor;
animationTrackBar.ThumbInnerColor = FormThemes.BaseTheme.TimelineThumbColor;
/* animationTrackBar.ThumbInnerColor = FormThemes.BaseTheme.TimelineThumbColor;
animationTrackBar.ThumbOuterColor = FormThemes.BaseTheme.TimelineThumbColor;
this.animationTrackBar.BarInnerColor = FormThemes.BaseTheme.FormBackColor;
@ -120,7 +118,7 @@ namespace Switch_Toolbox.Library
this.animationTrackBar.ElapsedInnerColor = FormThemes.BaseTheme.FormBackColor;
this.animationTrackBar.ElapsedPenColorBottom = FormThemes.BaseTheme.FormBackColor;
this.animationTrackBar.ElapsedPenColorTop = FormThemes.BaseTheme.FormBackColor;
*/
panel1.BackColor = FormThemes.BaseTheme.FormBackColor;
animationPlayBtn.BackColor = FormThemes.BaseTheme.FormBackColor;
button2.BackColor = FormThemes.BaseTheme.FormBackColor;
@ -180,7 +178,7 @@ namespace Switch_Toolbox.Library
private void AdvanceNextFrame()
{
if (animationTrackBar.Value == animationTrackBar.Maximum)
if (animationTrackBar.CurrentFrame == animationTrackBar.FrameCount)
{
if (IsLooping)
currentFrameUpDown.Value = 0;
@ -216,9 +214,8 @@ namespace Switch_Toolbox.Library
if (currentAnimation.Tag is Animation)
((Animation)currentAnimation.Tag).FrameCount = (int)totalFrame.Value;
currentAnimation.FrameCount = (int)totalFrame.Value;
animationTrackBar.Value = 0;
animationTrackBar.Maximum = currentAnimation.FrameCount;
animationTrackBar.Minimum = 0;
animationTrackBar.CurrentFrame = 0;
animationTrackBar.FrameCount = currentAnimation.FrameCount;
}
}
private void UpdateViewport()
@ -266,12 +263,12 @@ namespace Switch_Toolbox.Library
}
private void nextButton_Click(object sender, EventArgs e) {
if (animationTrackBar.Value < animationTrackBar.Maximum)
animationTrackBar.Value++;
if (animationTrackBar.CurrentFrame < animationTrackBar.FrameCount)
animationTrackBar.CurrentFrame++;
}
private void prevButton_Click(object sender, EventArgs e) {
if (animationTrackBar.Value > 0)
animationTrackBar.Value--;
if (animationTrackBar.CurrentFrame > 0)
animationTrackBar.CurrentFrame--;
}
private void animationTrackBar_Scroll(object sender, EventArgs e)
@ -281,9 +278,9 @@ namespace Switch_Toolbox.Library
private void animationTrackBar_ValueChanged(object sender, EventArgs e)
{
currentFrameUpDown.Value = animationTrackBar.Value;
currentFrameUpDown.Value = animationTrackBar.CurrentFrame;
UpdateViewport();
SetAnimationsToFrame(animationTrackBar.Value);
SetAnimationsToFrame(animationTrackBar.CurrentFrame);
if (!renderThreadIsUpdating || !IsPlaying)
UpdateViewport();
@ -355,7 +352,7 @@ namespace Switch_Toolbox.Library
if (currentFrameUpDown.Value > totalFrame.Value)
currentFrameUpDown.Value = totalFrame.Value;
animationTrackBar.Value = (int)currentFrameUpDown.Value;
animationTrackBar.CurrentFrame = (int)currentFrameUpDown.Value;
animationTrackBar.Refresh();
}

View file

@ -0,0 +1,37 @@
namespace Switch_Toolbox.Library.Forms
{
partial class TimeLine
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View file

@ -0,0 +1,214 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Switch_Toolbox.Library.Forms
{
public partial class TimeLine : UserControl
{
public TimeLine()
{
InitializeComponent();
}
public event EventHandler FrameChanged;
public int CurrentFrame
{
get => currentFrame;
set
{
if (FollowCurrentFrame)
{
double delta = value - (frameRight + frameLeft) * 0.5;
frameLeft += delta;
frameRight += delta;
#region resolve collsions
if (frameLeft < 0)
{
frameRight -= frameLeft;
frameLeft = 0;
}
else if (frameRight > frameCount)
{
frameLeft += frameCount - frameRight;
frameRight = frameCount;
}
#endregion
}
currentFrame = value;
Refresh();
}
}
public int FrameCount
{
get => frameCount;
set
{
frameCount = value;
if (value == 1)
{
frameLeft = 0;
frameRight = 1;
}
else
{
#region resolve collsions
if (frameLeft < 0)
{
frameRight -= frameLeft;
if (frameRight > frameCount)
frameRight = frameCount;
frameLeft = 0;
}
else if (frameRight > frameCount)
{
frameLeft += frameCount - frameRight;
if (frameLeft < 0)
frameLeft = 0;
frameRight = frameCount;
}
#endregion
}
Refresh();
}
}
public bool FollowCurrentFrame = true;
private int currentFrame = 0;
private int frameCount = 1000;
private double frameLeft = 0;
private double frameRight = 200;
private Point lastMousePos;
private static Brush brush1 = new SolidBrush(Color.FromArgb(255, 255, 20));
private static Brush brush2 = new SolidBrush(Color.FromArgb(20, 20, 20));
private static Brush brush3 = new SolidBrush(Color.FromArgb(50, 50, 50));
private static Brush brush4 = new SolidBrush(Color.FromArgb(90, 90, 90));
private static Pen pen1 = new Pen(new SolidBrush(Color.FromArgb(30, 30, 30)), 2);
private static Pen pen2 = new Pen(new SolidBrush(Color.FromArgb(100, 100, 20)), 2);
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
double currentFrameX = 20 + (currentFrame - frameLeft) * (Width - 40.0) / (frameRight - frameLeft);
e.Graphics.FillRectangle(brush2, new Rectangle(0, 0, Width, Height));
e.Graphics.FillRectangle(brush3, new Rectangle(0, 0, Width, TextRenderer.MeasureText("" + currentFrame, Font).Height));
double step = 50 * (frameRight - frameLeft) / Width;
if (step > 10)
step = Math.Round(step / 10.0) * 10;
else
{
step = Math.Round(Math.Max(1, step));
}
for (double frame = Math.Round(frameLeft / step) * step; frame <= frameRight; frame += step)
{
double frameX = 20 + (frame - frameLeft) * (Width - 40.0) / (frameRight - frameLeft);
e.Graphics.DrawLine(pen1, new Point((int)frameX, TextRenderer.MeasureText("" + frame, Font).Height), new Point((int)frameX, Height));
e.Graphics.DrawString("" + frame, Font, brush4, new Point((int)frameX - TextRenderer.MeasureText("" + frame, Font).Width / 2, 0));
}
e.Graphics.DrawLine(pen2, new Point((int)currentFrameX, TextRenderer.MeasureText("" + currentFrame, Font).Height), new Point((int)currentFrameX, Height));
e.Graphics.DrawString("" + currentFrame, Font, brush1, new Point((int)currentFrameX - TextRenderer.MeasureText("" + currentFrame, Font).Width / 2, 0));
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.Button == MouseButtons.Left)
{
currentFrame = Math.Min(Math.Max(0, (int)Math.Round(((e.Location.X - 20) * (frameRight - frameLeft) / (Width - 40.0) + frameLeft))), frameCount);
FrameChanged?.Invoke(this, new EventArgs());
Refresh();
}
else if (e.Button == MouseButtons.Right)
{
double delta = (e.Location.X - lastMousePos.X) * (frameRight - frameLeft) / (Width - 40.0);
frameLeft -= delta;
frameRight -= delta;
#region resolve collsions
if (frameLeft < 0)
{
frameRight -= frameLeft;
frameLeft = 0;
}
else if (frameRight > frameCount)
{
frameLeft += frameCount - frameRight;
frameRight = frameCount;
}
#endregion
Refresh();
}
lastMousePos = e.Location;
}
protected override void OnMouseWheel(MouseEventArgs e)
{
base.OnMouseWheel(e);
double delta = 1 + Math.Min(Math.Max(-0.5, -e.Delta * 0.00390625), 0.5);
double frameOrigin = Math.Min(Math.Max(0, ((e.Location.X - 20) * (frameRight - frameLeft) / (Width - 40.0) + frameLeft)), frameCount);
frameLeft = Math.Min(-1, (frameLeft - frameOrigin)) * delta + frameOrigin;
frameRight = Math.Max(1, (frameRight - frameOrigin)) * delta + frameOrigin;
#region resolve collsions
if (frameLeft < 0)
{
frameRight -= frameLeft;
if (frameRight > frameCount)
frameRight = frameCount;
frameLeft = 0;
}
else if (frameRight > frameCount)
{
frameLeft += frameCount - frameRight;
if (frameLeft < 0)
frameLeft = 0;
frameRight = frameCount;
}
#endregion
Refresh();
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}
}
}

View file

@ -369,6 +369,12 @@
<Compile Include="Forms\Editors\TextEditor\TextEditorForm.Designer.cs">
<DependentUpon>TextEditorForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Editors\TimeLine.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Forms\Editors\TimeLine.Designer.cs">
<DependentUpon>TimeLine.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Extensions\MDICustom.cs" />
<Compile Include="Forms\Editors\ObjectEditor.cs">
<SubType>Form</SubType>

View file

@ -121,7 +121,7 @@
<value>- Smash Forge Devs (SMG, Ploaj, jam1garner, smb123w64gb, etc) for some code ported over. Specifically animation stuff and some rendering.
- Assimp devs for their massive asset library!
- Wexos (helped figure out a few things, ie format list to assign each attribute)
- JuPaHe64 for the base 3D renderer.
- JuPaHe64 for the base 3D renderer and timeline control.
- Every File Explorer devs (Gericom) for Yaz0 stuff
- Exelix for Byaml, Sarc and KCL library
- Syroot for helpful IO extensions and libraies