From 97ef68e64e4844402669ab2d31e434bd1c211afc Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Wed, 18 May 2011 01:49:20 +0000 Subject: [PATCH] Record movie dialog now allows user to type in name of file to record, and will auto fill in directory path if user does not. Play movie now uses the PreLoad function so length calculation is significantly faster --- .../BizHawk.MultiClient.csproj | 1 + BizHawk.MultiClient/PlayMovie.cs | 2 +- BizHawk.MultiClient/RecordMovie.cs | 19 +++++++++++++++++-- BizHawk.MultiClient/movie/Movie.cs | 16 ++++++++++------ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj index 15c8c47dec..e1caa1be66 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj @@ -148,6 +148,7 @@ Form + diff --git a/BizHawk.MultiClient/PlayMovie.cs b/BizHawk.MultiClient/PlayMovie.cs index d22601f90f..420f809cae 100644 --- a/BizHawk.MultiClient/PlayMovie.cs +++ b/BizHawk.MultiClient/PlayMovie.cs @@ -38,7 +38,7 @@ namespace BizHawk.MultiClient if (column == 2) //Game text = MovieList[index].GetGameName(); if (column == 3) //Time - text = MovieList[index].GetTime(); + text = MovieList[index].GetTime(true); } private void MovieView_QueryItemBkColor(int index, int column, ref Color color) diff --git a/BizHawk.MultiClient/RecordMovie.cs b/BizHawk.MultiClient/RecordMovie.cs index bdb7d11030..3292708a9d 100644 --- a/BizHawk.MultiClient/RecordMovie.cs +++ b/BizHawk.MultiClient/RecordMovie.cs @@ -13,6 +13,7 @@ namespace BizHawk.MultiClient public partial class RecordMovie : Form { //TODO: on OK check that the user actually selected a movie (text box != empty?) + //Allow relative paths in record textbox //Have an editiable listview for header info and any other settings, or appropriate widgets //Some header/settings that needs to be editable: // System ID @@ -21,6 +22,7 @@ namespace BizHawk.MultiClient // Some comments? // Platform specific bools like PAL vs NTSC or an FDS flag, etc + Movie MovieToRecord; public RecordMovie() @@ -28,8 +30,23 @@ namespace BizHawk.MultiClient InitializeComponent(); } + private string MakePath() + { + string path = RecordBox.Text; + int x = path.LastIndexOf('\\'); + if (path.LastIndexOf('\\') == -1) + { + path = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "") + RecordBox.Text; + return path; + } + else + return path; + } + private void OK_Click(object sender, EventArgs e) { + string path = MakePath(); + MovieToRecord = new Movie(RecordBox.Text, MOVIEMODE.RECORD); Global.MainForm.StartNewMovie(MovieToRecord, true); this.Close(); } @@ -52,8 +69,6 @@ namespace BizHawk.MultiClient Global.Sound.StartSound(); if (result == DialogResult.OK) { - var file = new FileInfo(sfd.FileName); - MovieToRecord = new Movie(sfd.FileName, MOVIEMODE.RECORD); RecordBox.Text = sfd.FileName; } } diff --git a/BizHawk.MultiClient/movie/Movie.cs b/BizHawk.MultiClient/movie/Movie.cs index 4f6447b592..31aaacb7ac 100644 --- a/BizHawk.MultiClient/movie/Movie.cs +++ b/BizHawk.MultiClient/movie/Movie.cs @@ -280,7 +280,7 @@ namespace BizHawk.MultiClient length -= line; int lines = (int)file.Length - length; this.Frames = lines / line; - break; //This right? + break; } else { @@ -365,10 +365,15 @@ namespace BizHawk.MultiClient Header.SetHeaderLine(key, value); } - public string GetTime() + public string GetTime(bool preLoad) { string time = ""; - double seconds = GetSeconds(); + + double seconds; + if (preLoad) + seconds = GetSeconds(Frames); + else + seconds = GetSeconds(Log.Length()); int hours = ((int)seconds) / 3600; int minutes = (((int)seconds) / 60) % 60; double sec = seconds % 60; @@ -395,7 +400,7 @@ namespace BizHawk.MultiClient return num.ToString(); } - private double GetSeconds() + private double GetSeconds(int frameCount) { //Should these be placed somewhere more accessible? Perhaps as a public dictionary object in MainForm? const double NES_PAL = 50.006977968268290849; const double NES_NTSC = (double)60.098813897440515532; @@ -407,8 +412,7 @@ namespace BizHawk.MultiClient const double LYNX = 59.8; const double WSWAN = (3072000.0 / (159 * 256)); double seconds = 0; - double frames = (double)Log.Length(); - + double frames = (double)frameCount; if (frames < 1) return seconds;