Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion InputDisplay/Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ static public int Outline
}
}

static public int PlaybackSpeed { get; set; } = 60;
static public double PlaybackSpeed { get; set; } = 60/1.001;
}
}
5 changes: 2 additions & 3 deletions InputDisplay/Core/Animator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down
8 changes: 5 additions & 3 deletions InputDisplay/Entities/Timer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
7 changes: 2 additions & 5 deletions InputDisplay/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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});
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 3 additions & 1 deletion InputDisplay/Forms/OptionTabs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 8 additions & 5 deletions InputDisplay/Forms/RecordForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down