Movie object cleanup, movie savestate handling cleanup, save GUID into movie savestates

This commit is contained in:
andres.delikat 2011-07-31 01:15:14 +00:00
parent 60a4ea4426
commit ce3bb25409
5 changed files with 118 additions and 96 deletions

View File

@ -109,5 +109,98 @@ namespace BizHawk.MultiClient
SetMainformMovieInfo();
}
}
private void HandleMovieLoadState(StreamReader reader)
{
//Note, some of the situations in these IF's may be identical and could be combined but I intentionally separated it out for clarity
if (UserMovie.Mode == MOVIEMODE.RECORD)
{
if (ReadOnly)
{
int x = UserMovie.CheckTimeLines(reader);
//if (x >= 0)
// MessageBox.Show("Savestate input log does not match the movie at frame " + (x+1).ToString() + "!", "Timeline error", MessageBoxButtons.OK); //TODO: replace with a not annoying message once savestate logic is running smoothly
//else
{
UserMovie.WriteMovie();
UserMovie.StartPlayback();
SetMainformMovieInfo();
Global.MovieMode = true;
}
}
else
{
Global.MovieMode = false;
UserMovie.LoadLogFromSavestateText(reader);
}
}
else if (UserMovie.Mode == MOVIEMODE.PLAY)
{
if (ReadOnly)
{
int x = UserMovie.CheckTimeLines(reader);
//if (x >= 0)
// MessageBox.Show("Savestate input log does not match the movie at frame " + (x+1).ToString() + "!", "Timeline error", MessageBoxButtons.OK); //TODO: replace with a not annoying message once savestate logic is running smoothly
}
else
{
//QUESTIONABLE - control whether the movie gets truncated here?
UserMovie.StartNewRecording(!Global.MovieSession.MultiTrack.IsActive);
SetMainformMovieInfo();
Global.MovieMode = false;
UserMovie.LoadLogFromSavestateText(reader);
}
}
else if (UserMovie.Mode == MOVIEMODE.FINISHED)
{
//TODO: have the input log kick in upon movie finished mode and stop upon movie resume
if (ReadOnly)
{
if (Global.Emulator.Frame > UserMovie.Length())
{
Global.MovieMode = false;
//Post movie savestate
//There is no movie data to load, and the movie will stay in movie finished mode
//So do nothing
}
else
{
int x = UserMovie.CheckTimeLines(reader);
UserMovie.StartPlayback();
SetMainformMovieInfo();
Global.MovieMode = true;
//if (x >= 0)
// MessageBox.Show("Savestate input log does not match the movie at frame " + (x+1).ToString() + "!", "Timeline error", MessageBoxButtons.OK); //TODO: replace with a not annoying message once savestate logic is running smoothly
}
}
else
{
if (Global.Emulator.Frame > UserMovie.Length())
{
Global.MovieMode = false;
//Post movie savestate
//There is no movie data to load, and the movie will stay in movie finished mode
//So do nothing
}
else
{
UserMovie.StartNewRecording();
Global.MovieMode = false;
SetMainformMovieInfo();
UserMovie.LoadLogFromSavestateText(reader);
}
}
}
}
private void HandleMovieSaveState(StreamWriter writer)
{
if (UserMovie.Mode != MOVIEMODE.INACTIVE)
{
UserMovie.DumpLogIntoSavestateText(writer);
}
}
}
}

View File

@ -1557,14 +1557,6 @@ namespace BizHawk.MultiClient
MakeScreenshot(String.Format(Global.Game.ScreenshotPrefix + ".{0:yyyy-MM-dd HH.mm.ss}.png", DateTime.Now));
}
private void HandleMovieSaveState(StreamWriter writer)
{
if (UserMovie.Mode != MOVIEMODE.INACTIVE)
{
UserMovie.DumpLogIntoSavestateText(writer);
}
}
private void SaveState(string name)
{
string path = Global.Game.SaveStatePrefix + "." + name + ".State";
@ -1604,89 +1596,6 @@ namespace BizHawk.MultiClient
UpdateStatusSlots();
}
private void HandleMovieLoadState(StreamReader reader)
{
//Note, some of the situations in these IF's may be identical and could be combined but I intentionally separated it out for clarity
if (UserMovie.Mode == MOVIEMODE.RECORD)
{
if (ReadOnly)
{
int x = UserMovie.CheckTimeLines(reader);
//if (x >= 0)
// MessageBox.Show("Savestate input log does not match the movie at frame " + (x+1).ToString() + "!", "Timeline error", MessageBoxButtons.OK); //TODO: replace with a not annoying message once savestate logic is running smoothly
//else
{
UserMovie.WriteMovie();
UserMovie.StartPlayback();
SetMainformMovieInfo();
Global.MovieMode = true;
}
}
else
{
Global.MovieMode = false;
UserMovie.LoadLogFromSavestateText(reader);
}
}
else if (UserMovie.Mode == MOVIEMODE.PLAY)
{
if (ReadOnly)
{
int x = UserMovie.CheckTimeLines(reader);
//if (x >= 0)
// MessageBox.Show("Savestate input log does not match the movie at frame " + (x+1).ToString() + "!", "Timeline error", MessageBoxButtons.OK); //TODO: replace with a not annoying message once savestate logic is running smoothly
}
else
{
//QUESTIONABLE - control whether the movie gets truncated here?
UserMovie.StartNewRecording(!Global.MovieSession.MultiTrack.IsActive);
SetMainformMovieInfo();
Global.MovieMode = false;
UserMovie.LoadLogFromSavestateText(reader);
}
}
else if (UserMovie.Mode == MOVIEMODE.FINISHED)
{
//TODO: have the input log kick in upon movie finished mode and stop upon movie resume
if (ReadOnly)
{
if (Global.Emulator.Frame > UserMovie.Length())
{
Global.MovieMode = false;
//Post movie savestate
//There is no movie data to load, and the movie will stay in movie finished mode
//So do nothing
}
else
{
int x = UserMovie.CheckTimeLines(reader);
UserMovie.StartPlayback();
SetMainformMovieInfo();
Global.MovieMode = true;
//if (x >= 0)
// MessageBox.Show("Savestate input log does not match the movie at frame " + (x+1).ToString() + "!", "Timeline error", MessageBoxButtons.OK); //TODO: replace with a not annoying message once savestate logic is running smoothly
}
}
else
{
if (Global.Emulator.Frame > UserMovie.Length())
{
Global.MovieMode = false;
//Post movie savestate
//There is no movie data to load, and the movie will stay in movie finished mode
//So do nothing
}
else
{
UserMovie.StartNewRecording();
Global.MovieMode = false;
SetMainformMovieInfo();
UserMovie.LoadLogFromSavestateText(reader);
}
}
}
}
private void LoadStateFile(string path, string name)
{
var reader = new StreamReader(path);

View File

@ -32,7 +32,7 @@ namespace BizHawk.MultiClient
if (column == 0) //File
text = Path.GetFileName(MovieList[index].Filename);
if (column == 1) //System
text = MovieList[index].GetSysID();
text = MovieList[index].SysID();
if (column == 2) //Game
text = MovieList[index].GetGameName();
if (column == 3) //Time

View File

@ -35,7 +35,8 @@ namespace BizHawk.MultiClient
IsText = true;
Frames = 0;
StartsFromSavestate = false;
Loaded = false;
if (filename.Length > 0)
Loaded = true;
}
public Movie()
@ -48,11 +49,16 @@ namespace BizHawk.MultiClient
Loaded = false;
}
public string GetSysID()
public string SysID()
{
return Header.GetHeaderLine(MovieHeader.PLATFORM);
}
public string GUID()
{
return Header.GetHeaderLine(MovieHeader.GUID);
}
public string GetGameName()
{
return Header.GetHeaderLine(MovieHeader.GAMENAME);
@ -310,6 +316,8 @@ namespace BizHawk.MultiClient
public void DumpLogIntoSavestateText(TextWriter writer)
{
writer.WriteLine("[Input]");
string s = MovieHeader.GUID + " " + Header.GetHeaderLine(MovieHeader.GUID);
writer.WriteLine(s);
for (int x = 0; x < Log.Length(); x++)
writer.WriteLine(Log.GetFrame(x));
writer.WriteLine("[/Input]");
@ -571,8 +579,8 @@ namespace BizHawk.MultiClient
private int CompareSysID(Movie Other)
{
string otherSysID = Other.GetSysID();
string thisSysID = this.GetSysID();
string otherSysID = Other.SysID();
string thisSysID = this.SysID();
if (thisSysID == null && otherSysID == null)
return 0;

View File

@ -184,5 +184,17 @@ namespace BizHawk.MultiClient
return true;
}
public void ReadHeader(StreamReader reader)
{
using (reader)
{
string str = "";
while ((str = reader.ReadLine()) != null)
{
AddHeaderFromLine(str);
}
reader.Close();
}
}
}
}