diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 99649f5a..5af83f69 100644 Binary files a/.vs/Switch_Toolbox/v15/.suo and b/.vs/Switch_Toolbox/v15/.suo differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide index c58ffce2..178ccd64 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm index 151bbc30..ec087d78 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index f1f28c64..4201ee47 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs index 45ed3b02..aabdea14 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs @@ -167,7 +167,7 @@ namespace Bfres.Structs var animBone = model.Skeleton.GetBone(bone.Text); if (animBone != null) - return model.Skeleton; + return model.Skeleton; } } } diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index 08b52675..4626fced 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll index 25ad8b22..eaf88e3c 100644 Binary files a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll and b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll differ diff --git a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb index 9b9dccb5..929ef26b 100644 Binary files a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb and b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb differ diff --git a/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.Designer.cs b/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.Designer.cs index c499ee9f..88910ff3 100644 --- a/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.Designer.cs +++ b/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.cs b/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.cs index bc83e680..c5326937 100644 --- a/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.cs +++ b/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.cs @@ -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(); } diff --git a/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.zip b/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.zip new file mode 100644 index 00000000..835f5fee Binary files /dev/null and b/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.zip differ diff --git a/Switch_Toolbox_Library/Forms/Editors/TimeLine.Designer.cs b/Switch_Toolbox_Library/Forms/Editors/TimeLine.Designer.cs new file mode 100644 index 00000000..67635181 --- /dev/null +++ b/Switch_Toolbox_Library/Forms/Editors/TimeLine.Designer.cs @@ -0,0 +1,37 @@ +namespace Switch_Toolbox.Library.Forms +{ + partial class TimeLine + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/Switch_Toolbox_Library/Forms/Editors/TimeLine.cs b/Switch_Toolbox_Library/Forms/Editors/TimeLine.cs new file mode 100644 index 00000000..d2a0b0e2 --- /dev/null +++ b/Switch_Toolbox_Library/Forms/Editors/TimeLine.cs @@ -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; + } + } + } +} diff --git a/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj b/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj index fd15eb92..22181aca 100644 --- a/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj +++ b/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj @@ -369,6 +369,12 @@ TextEditorForm.cs + + UserControl + + + TimeLine.cs + Form diff --git a/Toolbox/GUI/Credits.resx b/Toolbox/GUI/Credits.resx index 94553802..7ac5d9dc 100644 --- a/Toolbox/GUI/Credits.resx +++ b/Toolbox/GUI/Credits.resx @@ -121,7 +121,7 @@ - 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