diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 4203ac5e..722bf11d 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 66d27be3..3df71434 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 ec087d78..e43e0bb2 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 fc4250c8..56d536df 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/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Switch_FileFormatsMain/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 606f686a..93771bee 100644 Binary files a/Switch_FileFormatsMain/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/Switch_FileFormatsMain/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Switch_FileFormatsMain/obj/Debug/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache b/Switch_FileFormatsMain/obj/Debug/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache index 1d2c8b27..09d723dc 100644 --- a/Switch_FileFormatsMain/obj/Debug/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache +++ b/Switch_FileFormatsMain/obj/Debug/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -c33b69ea260fc3904ffe63aa4179e23192c4fb40 +ac1f8e64f6b51cf9f95182bfa050222cee02b540 diff --git a/Switch_FileFormatsMain/obj/Debug/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Debug/Switch_FileFormatsMain.csprojAssemblyReference.cache index b812ff8e..22f719a5 100644 Binary files a/Switch_FileFormatsMain/obj/Debug/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Debug/Switch_FileFormatsMain.csprojAssemblyReference.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index c51401fe..f9f469aa 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache differ diff --git a/Switch_Toolbox_Library/Forms/Editors/AnimationPanel (2).zip b/Switch_Toolbox_Library/Forms/Editors/AnimationPanel (2).zip new file mode 100644 index 00000000..a42c52c3 Binary files /dev/null and b/Switch_Toolbox_Library/Forms/Editors/AnimationPanel (2).zip differ diff --git a/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.cs b/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.cs index 25069cca..3c002122 100644 --- a/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.cs +++ b/Switch_Toolbox_Library/Forms/Editors/AnimationPanel.cs @@ -108,7 +108,7 @@ namespace Switch_Toolbox.Library animationTrackBar.BackColor = FormThemes.BaseTheme.FormBackColor; animationTrackBar.ForeColor = FormThemes.BaseTheme.FormForeColor; - animationTrackBar.FrameChanged += new EventHandler(animationTrackBar_ValueChanged); + // animationTrackBar.FrameChanged += new EventHandler(animationTrackBar_ValueChanged); /* animationTrackBar.ThumbInnerColor = FormThemes.BaseTheme.TimelineThumbColor; animationTrackBar.ThumbOuterColor = FormThemes.BaseTheme.TimelineThumbColor; @@ -138,12 +138,14 @@ namespace Switch_Toolbox.Library { AnimationPlayerState = PlayerState.Playing; UpdateAnimationUI(); + animationTrackBar.Play(); } private void Pause() { AnimationPlayerState = PlayerState.Stop; UpdateAnimationUI(); + animationTrackBar.Stop(); } private void Stop() @@ -280,15 +282,20 @@ namespace Switch_Toolbox.Library } - private void animationTrackBar_ValueChanged(object sender, EventArgs e) + private void animationTrackBar_ValueChanged() + { + + } + + private void OnFrameAdvanced() { - currentFrameUpDown.Value = animationTrackBar.CurrentFrame; UpdateViewport(); SetAnimationsToFrame(animationTrackBar.CurrentFrame); if (!renderThreadIsUpdating || !IsPlaying) UpdateViewport(); } + private void SetAnimationsToFrame(int frameNum) { if (currentAnimation == null) @@ -357,7 +364,7 @@ namespace Switch_Toolbox.Library currentFrameUpDown.Value = totalFrame.Value; animationTrackBar.CurrentFrame = (int)currentFrameUpDown.Value; - animationTrackBar.Refresh(); + OnFrameAdvanced(); } public void AnimationPanel_FormClosed() diff --git a/Switch_Toolbox_Library/Forms/Editors/TimeLine.Designer.cs b/Switch_Toolbox_Library/Forms/Editors/TimeLine.Designer.cs index 7c9029d1..aa479e04 100644 --- a/Switch_Toolbox_Library/Forms/Editors/TimeLine.Designer.cs +++ b/Switch_Toolbox_Library/Forms/Editors/TimeLine.Designer.cs @@ -35,7 +35,6 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Name = "TimeLine"; - this.Resize += new System.EventHandler(this.TimeLine_Resize); this.ResumeLayout(false); } diff --git a/Switch_Toolbox_Library/Forms/Editors/TimeLine.cs b/Switch_Toolbox_Library/Forms/Editors/TimeLine.cs index 8814276f..2079dd91 100644 --- a/Switch_Toolbox_Library/Forms/Editors/TimeLine.cs +++ b/Switch_Toolbox_Library/Forms/Editors/TimeLine.cs @@ -15,50 +15,85 @@ namespace Switch_Toolbox.Library.Forms public TimeLine() { InitializeComponent(); + timer.Interval = 10; + timer.Tick += Timer_Tick; } public event EventHandler FrameChanged; + private Timer timer = new Timer(); + + public bool Locked { get; private set; } = false; + + public void Play() + { + Locked = true; + } + + public void Stop() + { + Locked = false; + } + + private void ResolveCollision() + { + if (frameLeft < 0) + { + frameRight -= frameLeft; + frameLeft = 0; + } + else if (frameRight > lastFrame) + { + frameLeft += lastFrame - frameRight; + frameRight = lastFrame; + } + } + + private void ResolveFitting() + { + if (frameLeft < 0) + { + frameRight -= frameLeft; + if (frameRight > lastFrame) + frameRight = lastFrame; + frameLeft = 0; + } + else if (frameRight > lastFrame) + { + frameLeft += lastFrame - frameRight; + if (frameLeft < 0) + frameLeft = 0; + frameRight = lastFrame; + } + } + public int CurrentFrame { - get { return currentFrame; } + get => currentFrame; set { - if (FollowCurrentFrame) + if (FollowCurrentFrame && !(Focused && MouseButtons == MouseButtons.Right)) { 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 + ResolveCollision(); } currentFrame = value; - FrameChanged?.Invoke(this, new EventArgs()); - Refresh(); } } public int FrameCount { - get { return frameCount; } + get => lastFrame + 1; set { - frameCount = value; + lastFrame = value - 1; if (value == 1) { @@ -67,9 +102,12 @@ namespace Switch_Toolbox.Library.Forms } else { - ResolveCollision(); + ResolveFitting(); } + if (currentFrame > lastFrame) + currentFrame = lastFrame; + Refresh(); } } @@ -77,7 +115,7 @@ namespace Switch_Toolbox.Library.Forms public bool FollowCurrentFrame = true; private int currentFrame = 0; - private int frameCount = 1000; + private int lastFrame = 1000; private double frameLeft = 0; private double frameRight = 200; @@ -92,13 +130,15 @@ namespace Switch_Toolbox.Library.Forms 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); + private static Font font = new Font(new FontFamily("arial"), 10); + 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)); + e.Graphics.FillRectangle(brush3, new Rectangle(0, 0, Width, TextRenderer.MeasureText("" + currentFrame, font).Height)); double step = 50 * (frameRight - frameLeft) / Width; if (step > 10) @@ -108,84 +148,139 @@ namespace Switch_Toolbox.Library.Forms step = Math.Round(Math.Max(1, step)); } - for (double frame = Math.Round(frameLeft / step) * step; frame <= frameRight; frame += step) + if (lastFrame != 0) { - double frameX = 20 + (frame - frameLeft) * (Width - 40.0) / (frameRight - frameLeft); + double max; + if (frameRight < lastFrame) + max = Math.Min(frameRight + step, lastFrame); + else + max = frameRight - step; - e.Graphics.DrawLine(pen1, new Point((int)frameX, TextRenderer.MeasureText("" + frame, Font).Height), new Point((int)frameX, Height)); + for (double frame = Math.Floor(frameLeft / step) * step; frame <= max; frame += step) + { + double frameX = 20 + (frame - frameLeft) * (Width - 40.0) / (frameRight - frameLeft); - e.Graphics.DrawString("" + frame, Font, brush4, new Point((int)frameX - TextRenderer.MeasureText("" + frame, Font).Width / 2, 0)); + 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)); + if (frameRight == lastFrame) + { + //draw last frame regardless of the steps + double x = Width - 20; - e.Graphics.DrawString("" + currentFrame, Font, brush1, new Point((int)currentFrameX - TextRenderer.MeasureText("" + currentFrame, Font).Width / 2, 0)); + e.Graphics.DrawLine(pen1, new Point((int)x, TextRenderer.MeasureText("" + lastFrame, font).Height), new Point((int)x, Height)); + + e.Graphics.DrawString("" + lastFrame, font, brush4, new Point((int)x - TextRenderer.MeasureText("" + lastFrame, 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)); + } + + private void Timer_Tick(object sender, EventArgs e) + { + double step; + if (lastMousePos.X < 20) + { + step = (20 - lastMousePos.X) * (frameRight - frameLeft) / Width; + frameLeft -= step; + frameRight -= step; + + #region resolve collsions + if (frameLeft < 0) + { + frameRight -= frameLeft; + frameLeft = 0; + } + #endregion + } + else + { + step = (lastMousePos.X - Width + 20) * (frameRight - frameLeft) / Width; + frameLeft += step; + frameRight += step; + + #region resolve collsions + if (frameRight > lastFrame) + { + frameLeft += lastFrame - frameRight; + frameRight = lastFrame; + } + #endregion + } + + currentFrame = Math.Min(Math.Max(0, (int)Math.Round(((lastMousePos.X - 20) * (frameRight - frameLeft) / (Width - 40.0) + frameLeft))), lastFrame); + FrameChanged?.Invoke(this, new EventArgs()); + Refresh(); } protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); + if (lastFrame == 0) + return; + 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); + + timer.Enabled = (e.X < 20 || e.X > Width - 20); + Locked = true; + currentFrame = Math.Min(Math.Max(0, (int)Math.Round(((e.X - 20) * (frameRight - frameLeft) / (Width - 40.0) + frameLeft))), lastFrame); FrameChanged?.Invoke(this, new EventArgs()); - - double delta = e.Location.X * (frameRight - frameLeft) / (Width - 40.0); - frameLeft -= delta; - frameRight -= delta; - - ResolveCollision(); Refresh(); } else if (e.Button == MouseButtons.Right) { - double delta = (e.Location.X - lastMousePos.X) * (frameRight - frameLeft) / (Width - 40.0); + double delta = (e.X - lastMousePos.X) * (frameRight - frameLeft) / (Width - 40.0); frameLeft -= delta; frameRight -= delta; ResolveCollision(); + Refresh(); } lastMousePos = e.Location; } + protected override void OnMouseUp(MouseEventArgs e) + { + timer.Stop(); + Locked = false; + base.OnMouseUp(e); + } + protected override void OnMouseWheel(MouseEventArgs e) { base.OnMouseWheel(e); + if (lastFrame == 0) + return; + + if (frameRight - frameLeft <= 2 && e.Delta > 0) + return; 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); + double frameOrigin = Math.Min(Math.Max(0, ((e.X - 20) * (frameRight - frameLeft) / (Width - 40.0) + frameLeft)), lastFrame); frameLeft = Math.Min(-1, (frameLeft - frameOrigin)) * delta + frameOrigin; frameRight = Math.Max(1, (frameRight - frameOrigin)) * delta + frameOrigin; - ResolveCollision(); + ResolveFitting(); Refresh(); } - #region resolve collsions - private void ResolveCollision() + protected override void OnResize(EventArgs e) { - 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; - } + Refresh(); + base.OnResize(e); } - #endregion protected override CreateParams CreateParams { @@ -196,9 +291,5 @@ namespace Switch_Toolbox.Library.Forms return cp; } } - - private void TimeLine_Resize(object sender, EventArgs e) { - ResolveCollision(); - } } } diff --git a/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj.user b/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj.user new file mode 100644 index 00000000..f14b2a39 --- /dev/null +++ b/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj.user @@ -0,0 +1,6 @@ + + + + true + + \ No newline at end of file diff --git a/Toolbox/Lib/Switch_Toolbox.Library.dll b/Toolbox/Lib/Switch_Toolbox.Library.dll deleted file mode 100644 index 3637346c..00000000 Binary files a/Toolbox/Lib/Switch_Toolbox.Library.dll and /dev/null differ diff --git a/Toolbox/Toolbox.csproj b/Toolbox/Toolbox.csproj index 4d625cc5..b73337e3 100644 --- a/Toolbox/Toolbox.csproj +++ b/Toolbox/Toolbox.csproj @@ -205,8 +205,6 @@ {96820047-2a39-4e5a-bfa4-e84fff5c66cf} Switch_Toolbox_Library - False - False {d82a2c08-2a65-43af-bda6-a36cc27aa003} @@ -354,9 +352,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest diff --git a/Updater/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Updater/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 115017dc..52ac56c7 100644 Binary files a/Updater/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/Updater/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Updater/obj/Debug/Updater.csproj.CoreCompileInputs.cache b/Updater/obj/Debug/Updater.csproj.CoreCompileInputs.cache index dff7dfa7..addead93 100644 --- a/Updater/obj/Debug/Updater.csproj.CoreCompileInputs.cache +++ b/Updater/obj/Debug/Updater.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -c475e10de89197fe91034aab1960dc610921d0f8 +747948e0929dd8935549f97d0e91eb2d59336ea8 diff --git a/Updater/obj/Release/Updater.csproj.FileListAbsolute.txt b/Updater/obj/Release/Updater.csproj.FileListAbsolute.txt index 84c7b66f..d15f45b2 100644 --- a/Updater/obj/Release/Updater.csproj.FileListAbsolute.txt +++ b/Updater/obj/Release/Updater.csproj.FileListAbsolute.txt @@ -27,15 +27,15 @@ C:\Users\Nathan\Documents\GitHub\Switch_Toolbox\Switch-Toolbox-38ceb8d7163902ecb C:\Users\Nathan\Documents\GitHub\Switch_Toolbox\Switch-Toolbox-38ceb8d7163902ecb569774ab4db327a194d6f99\Updater\obj\Release\Updater.csproj.CopyComplete C:\Users\Nathan\Documents\GitHub\Switch_Toolbox\Switch-Toolbox-38ceb8d7163902ecb569774ab4db327a194d6f99\Updater\obj\Release\Updater.exe C:\Users\Nathan\Documents\GitHub\Switch_Toolbox\Switch-Toolbox-38ceb8d7163902ecb569774ab4db327a194d6f99\Updater\obj\Release\Updater.pdb -C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\obj\Release\Updater.csprojAssemblyReference.cache -C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\obj\Release\Updater.csproj.CoreCompileInputs.cache C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\bin\Release\Updater.exe.config C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\bin\Release\Updater.exe C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\bin\Release\Updater.pdb C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\bin\Release\Octokit.dll -C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\obj\Release\Updater.csproj.CopyComplete -C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\obj\Release\Updater.exe -C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\obj\Release\Updater.pdb C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Toolbox\bin\Release\Updater.exe.config C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Toolbox\bin\Release\Updater.exe C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Toolbox\bin\Release\Updater.pdb +C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\obj\Release\Updater.csprojAssemblyReference.cache +C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\obj\Release\Updater.csproj.CoreCompileInputs.cache +C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\obj\Release\Updater.csproj.CopyComplete +C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\obj\Release\Updater.exe +C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Updater\obj\Release\Updater.pdb diff --git a/Updater/obj/Release/Updater.csprojAssemblyReference.cache b/Updater/obj/Release/Updater.csprojAssemblyReference.cache index 3d3cb4a4..6ce8c9ef 100644 Binary files a/Updater/obj/Release/Updater.csprojAssemblyReference.cache and b/Updater/obj/Release/Updater.csprojAssemblyReference.cache differ