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

This commit is contained in:
andres.delikat 2011-05-18 01:49:20 +00:00
parent 250f424629
commit 97ef68e64e
4 changed files with 29 additions and 9 deletions

View File

@ -148,6 +148,7 @@
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="movie\Movie.cs" /> <Compile Include="movie\Movie.cs" />
<Compile Include="movie\MovieConvert.cs" />
<Compile Include="movie\MovieHeader.cs" /> <Compile Include="movie\MovieHeader.cs" />
<Compile Include="movie\MovieLog.cs" /> <Compile Include="movie\MovieLog.cs" />
<Compile Include="MruStack.cs" /> <Compile Include="MruStack.cs" />

View File

@ -38,7 +38,7 @@ namespace BizHawk.MultiClient
if (column == 2) //Game if (column == 2) //Game
text = MovieList[index].GetGameName(); text = MovieList[index].GetGameName();
if (column == 3) //Time if (column == 3) //Time
text = MovieList[index].GetTime(); text = MovieList[index].GetTime(true);
} }
private void MovieView_QueryItemBkColor(int index, int column, ref Color color) private void MovieView_QueryItemBkColor(int index, int column, ref Color color)

View File

@ -13,6 +13,7 @@ namespace BizHawk.MultiClient
public partial class RecordMovie : Form public partial class RecordMovie : Form
{ {
//TODO: on OK check that the user actually selected a movie (text box != empty?) //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 //Have an editiable listview for header info and any other settings, or appropriate widgets
//Some header/settings that needs to be editable: //Some header/settings that needs to be editable:
// System ID // System ID
@ -21,6 +22,7 @@ namespace BizHawk.MultiClient
// Some comments? // Some comments?
// Platform specific bools like PAL vs NTSC or an FDS flag, etc // Platform specific bools like PAL vs NTSC or an FDS flag, etc
Movie MovieToRecord; Movie MovieToRecord;
public RecordMovie() public RecordMovie()
@ -28,8 +30,23 @@ namespace BizHawk.MultiClient
InitializeComponent(); 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) private void OK_Click(object sender, EventArgs e)
{ {
string path = MakePath();
MovieToRecord = new Movie(RecordBox.Text, MOVIEMODE.RECORD);
Global.MainForm.StartNewMovie(MovieToRecord, true); Global.MainForm.StartNewMovie(MovieToRecord, true);
this.Close(); this.Close();
} }
@ -52,8 +69,6 @@ namespace BizHawk.MultiClient
Global.Sound.StartSound(); Global.Sound.StartSound();
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
var file = new FileInfo(sfd.FileName);
MovieToRecord = new Movie(sfd.FileName, MOVIEMODE.RECORD);
RecordBox.Text = sfd.FileName; RecordBox.Text = sfd.FileName;
} }
} }

View File

@ -280,7 +280,7 @@ namespace BizHawk.MultiClient
length -= line; length -= line;
int lines = (int)file.Length - length; int lines = (int)file.Length - length;
this.Frames = lines / line; this.Frames = lines / line;
break; //This right? break;
} }
else else
{ {
@ -365,10 +365,15 @@ namespace BizHawk.MultiClient
Header.SetHeaderLine(key, value); Header.SetHeaderLine(key, value);
} }
public string GetTime() public string GetTime(bool preLoad)
{ {
string time = ""; string time = "";
double seconds = GetSeconds();
double seconds;
if (preLoad)
seconds = GetSeconds(Frames);
else
seconds = GetSeconds(Log.Length());
int hours = ((int)seconds) / 3600; int hours = ((int)seconds) / 3600;
int minutes = (((int)seconds) / 60) % 60; int minutes = (((int)seconds) / 60) % 60;
double sec = seconds % 60; double sec = seconds % 60;
@ -395,7 +400,7 @@ namespace BizHawk.MultiClient
return num.ToString(); 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? { //Should these be placed somewhere more accessible? Perhaps as a public dictionary object in MainForm?
const double NES_PAL = 50.006977968268290849; const double NES_PAL = 50.006977968268290849;
const double NES_NTSC = (double)60.098813897440515532; const double NES_NTSC = (double)60.098813897440515532;
@ -407,8 +412,7 @@ namespace BizHawk.MultiClient
const double LYNX = 59.8; const double LYNX = 59.8;
const double WSWAN = (3072000.0 / (159 * 256)); const double WSWAN = (3072000.0 / (159 * 256));
double seconds = 0; double seconds = 0;
double frames = (double)Log.Length(); double frames = (double)frameCount;
if (frames < 1) if (frames < 1)
return seconds; return seconds;