diff --git a/InputDisplay/Config/Config.cs b/InputDisplay/Config/Config.cs index c029a28..b46684b 100644 --- a/InputDisplay/Config/Config.cs +++ b/InputDisplay/Config/Config.cs @@ -123,6 +123,6 @@ static public int Outline } } - static public int PlaybackSpeed { get; set; } = 60; + static public double PlaybackSpeed { get; set; } = 60/1.001; } } diff --git a/InputDisplay/Core/Animator.cs b/InputDisplay/Core/Animator.cs index bfe75a6..081720d 100644 --- a/InputDisplay/Core/Animator.cs +++ b/InputDisplay/Core/Animator.cs @@ -55,7 +55,7 @@ public void SwitchController(string controller) public bool Update() { - int roundedFrame = (int) Math.Floor(this.CurrentFrame); + int roundedFrame = (int)Math.Floor(this.CurrentFrame); //end of inputs reached if (roundedFrame >= this.GhostReader.TotalFrames) @@ -76,7 +76,6 @@ public bool Update() if (roundedFrame >= this.GhostReader.Trick_inputs[this.TrickIndex].endFrame) { this.TrickIndex += 1; - } (bool accelerator, bool drift, bool item) actions = this.GhostReader.Face_inputs[this.FaceIndex].values; @@ -85,7 +84,7 @@ public bool Update() this.Controller.Update(actions.accelerator, actions.drift, actions.item, coords, trick); - this.CurrentFrame += (double) Config.PlaybackSpeed / this.Fps; + this.CurrentFrame += Config.PlaybackSpeed / this.Fps; return true; } diff --git a/InputDisplay/Entities/Timer.cs b/InputDisplay/Entities/Timer.cs index 92f4296..fd888d0 100644 --- a/InputDisplay/Entities/Timer.cs +++ b/InputDisplay/Entities/Timer.cs @@ -25,9 +25,11 @@ public void Draw(ref Graphics g, double currentFrame) SolidBrush blackBrush = new SolidBrush(Color.Black); g.FillRectangle(blackBrush, new Rectangle(new Point(this.Coords.X, this.Coords.Y), this.Size)); - - int actualFrame = (int)Math.Floor(currentFrame) - 240; - double seconds = actualFrame * (1.0 / 60.0); + // TODO: with a timescale of 16.667ms the final time is quite far off the end time + // however having the correct timescale (1/(60.1.001)) also results in weird stuff + // Leaving it like this because when having the "correct" scale, time starts at -4.004 which seems weird + // Perhaps it'd be better to render the frame number instead + double seconds = ((currentFrame) - 240) * (1.0 / 60); SolidBrush whiteBrush = new SolidBrush(Color.White); g.DrawString(seconds.ToString("0.000", CultureInfo.CreateSpecificCulture("en-CA")), drawFont, whiteBrush, this.Coords.X, this.Coords.Y + 5, new StringFormat()); } diff --git a/InputDisplay/Forms/MainForm.cs b/InputDisplay/Forms/MainForm.cs index a8987d4..6d34bd5 100644 --- a/InputDisplay/Forms/MainForm.cs +++ b/InputDisplay/Forms/MainForm.cs @@ -20,14 +20,13 @@ public partial class MainForm : Form private CheatDetector CheatDetector; private bool GhostLoaded = false; private bool Animate = false; - - private Stopwatch stopWatch = new Stopwatch(); private AccurateTimer timer; public MainForm() { InitializeComponent(); VariableSetup(); + // Set the framerate of the animator to 62.5fps, this may seem weird but a frame lasts exactly 16ms this way this.Animator = new Animator(62.5, this.pictureBox1.ClientSize.Width, this.pictureBox1.ClientSize.Height); this.AllowDrop = true; this.DragEnter += new DragEventHandler(Form1_DragEnter); @@ -561,7 +560,7 @@ private void InitializeComponent() this.numericUpDown2.Size = new System.Drawing.Size(44, 20); this.numericUpDown2.TabIndex = 11; this.numericUpDown2.Value = new decimal(new int[] { - 60, + 100, 0, 0, 0}); @@ -959,10 +958,8 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e) private void TimerCallback() { - this.stopWatch.Stop(); this.AdvanceAnimator(); this.pictureBox1.Invalidate(); - this.stopWatch.Restart(); return; } diff --git a/InputDisplay/Forms/OptionTabs.cs b/InputDisplay/Forms/OptionTabs.cs index 9ce47cb..9229fef 100644 --- a/InputDisplay/Forms/OptionTabs.cs +++ b/InputDisplay/Forms/OptionTabs.cs @@ -61,7 +61,9 @@ private void NumericUpDown1_ValueChanged(object sender, EventArgs e) private void NumericUpDown2_ValueChanged(object sender, EventArgs e) { - Config.PlaybackSpeed = (int)this.numericUpDown2.Value; + // The original playback speed is 59.94(60/1.001) fps + // do this weird calculation to properly allow up to 3x speed + Config.PlaybackSpeed = 60 * ((double)this.numericUpDown2.Value / 1.001 / 100); } private void NumericUpDown4_ValueChanged(object sender, EventArgs e) diff --git a/InputDisplay/Forms/RecordForm.cs b/InputDisplay/Forms/RecordForm.cs index 12b16f8..a04d1ce 100644 --- a/InputDisplay/Forms/RecordForm.cs +++ b/InputDisplay/Forms/RecordForm.cs @@ -49,12 +49,15 @@ public RecordForm(MainForm mainForm, Animator animator, bool alhpaChannel, strin this.label2.Visible = false; this.progressBar1.Visible = false; - if (Config.PlaybackSpeed == 60) + Animator.Fps = (60 / 1.001); // Set the framerate of the animator to 59.94fps, this matches the framerate of the game + + if (Config.PlaybackSpeed == (60/1.001)) { this.PrepareRecording(); - } else + } + else { - this.label1.Text = String.Format("The current playback speed is set to {0} (regular speed is 60)\nAre you sure you want to continue?", Config.PlaybackSpeed); + this.label1.Text = String.Format("The current playback speed is set to {0} (regular speed is 100)\nAre you sure you want to continue?", Config.PlaybackSpeed); } } @@ -151,7 +154,7 @@ private void Render(object sender, DoWorkEventArgs e) // Prepare the animator and write all the frames to the temp directory this.Animator.Clear(); int frameNr = 0; - int totalFrames = (int)((double)Math.Ceiling((double)((60.0 / Config.PlaybackSpeed) * this.Animator.Fps)) * this.Animator.GetGhostInfo().Item4); + int totalFrames = (int)(Math.Ceiling((((60/1.001) / Config.PlaybackSpeed) * this.Animator.Fps)) * this.Animator.GetGhostInfo().Item4); while (this.Animator.Update()) { // Check for cancel request @@ -171,7 +174,7 @@ private void Render(object sender, DoWorkEventArgs e) Process proc = new Process(); proc.StartInfo.FileName = "ffmpeg\\ffmpeg"; this.FileName = String.Format("{0}.{1}", DateTime.Now.ToString("yy-MM-dd-hh-mm-ss"), this.FileFormat); - proc.StartInfo.Arguments = String.Format("-framerate 62.5 -i temp\\%d.png -vcodec {0} {1}", codec, this.FileName); + proc.StartInfo.Arguments = String.Format("-r \"60000/1001\" -i temp\\%d.png -vcodec {0} {1}", codec, this.FileName); proc.StartInfo.RedirectStandardError = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.CreateNoWindow = true;