mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-10 07:04:36 +00:00
More timeline fixes
This commit is contained in:
parent
9c439f099d
commit
3a10c4cf43
19 changed files with 173 additions and 75 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
|||
c33b69ea260fc3904ffe63aa4179e23192c4fb40
|
||||
ac1f8e64f6b51cf9f95182bfa050222cee02b540
|
||||
|
|
Binary file not shown.
Binary file not shown.
BIN
Switch_Toolbox_Library/Forms/Editors/AnimationPanel (2).zip
Normal file
BIN
Switch_Toolbox_Library/Forms/Editors/AnimationPanel (2).zip
Normal file
Binary file not shown.
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -15,50 +15,85 @@ namespace Switch_Toolbox.Library.Forms
|
|||
public TimeLine()
|
||||
{
|
||||
InitializeComponent();
|
||||
timer.Interval = 10;
|
||||
timer.Tick += Timer_Tick;
|
||||
}
|
||||
|
||||
public event EventHandler FrameChanged;
|
||||
|
||||
public int CurrentFrame
|
||||
{
|
||||
get { return currentFrame; }
|
||||
set
|
||||
{
|
||||
if (FollowCurrentFrame)
|
||||
{
|
||||
double delta = value - (frameRight + frameLeft) * 0.5;
|
||||
frameLeft += delta;
|
||||
frameRight += delta;
|
||||
private Timer timer = new Timer();
|
||||
|
||||
#region resolve collsions
|
||||
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 > frameCount)
|
||||
else if (frameRight > lastFrame)
|
||||
{
|
||||
frameLeft += frameCount - frameRight;
|
||||
frameRight = frameCount;
|
||||
frameLeft += lastFrame - frameRight;
|
||||
frameRight = lastFrame;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
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 => currentFrame;
|
||||
set
|
||||
{
|
||||
if (FollowCurrentFrame && !(Focused && MouseButtons == MouseButtons.Right))
|
||||
{
|
||||
double delta = value - (frameRight + frameLeft) * 0.5;
|
||||
frameLeft += delta;
|
||||
frameRight += delta;
|
||||
|
||||
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 max;
|
||||
if (frameRight < lastFrame)
|
||||
max = Math.Min(frameRight + step, lastFrame);
|
||||
else
|
||||
max = frameRight - step;
|
||||
|
||||
for (double frame = Math.Floor(frameLeft / step) * step; frame <= max; 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.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.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;
|
||||
Refresh();
|
||||
base.OnResize(e);
|
||||
}
|
||||
else if (frameRight > frameCount)
|
||||
{
|
||||
frameLeft += frameCount - frameRight;
|
||||
if (frameLeft < 0)
|
||||
frameLeft = 0;
|
||||
frameRight = frameCount;
|
||||
}
|
||||
}
|
||||
#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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
</Project>
|
Binary file not shown.
|
@ -205,8 +205,6 @@
|
|||
<ProjectReference Include="..\Switch_Toolbox_Library\Switch_Toolbox_Library.csproj">
|
||||
<Project>{96820047-2a39-4e5a-bfa4-e84fff5c66cf}</Project>
|
||||
<Name>Switch_Toolbox_Library</Name>
|
||||
<Private>False</Private>
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Updater\Updater.csproj">
|
||||
<Project>{d82a2c08-2a65-43af-bda6-a36cc27aa003}</Project>
|
||||
|
@ -354,9 +352,6 @@
|
|||
<Content Include="Lib\SFGraphics.Utils.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\Switch_Toolbox.Library.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\Syroot.BinaryData.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
Binary file not shown.
|
@ -1 +1 @@
|
|||
c475e10de89197fe91034aab1960dc610921d0f8
|
||||
747948e0929dd8935549f97d0e91eb2d59336ea8
|
||||
|
|
|
@ -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
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue