Movie object cleanup, movie savestate handling cleanup, save GUID into movie savestates
This commit is contained in:
parent
60a4ea4426
commit
ce3bb25409
|
@ -109,5 +109,98 @@ namespace BizHawk.MultiClient
|
||||||
SetMainformMovieInfo();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1557,14 +1557,6 @@ namespace BizHawk.MultiClient
|
||||||
MakeScreenshot(String.Format(Global.Game.ScreenshotPrefix + ".{0:yyyy-MM-dd HH.mm.ss}.png", DateTime.Now));
|
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)
|
private void SaveState(string name)
|
||||||
{
|
{
|
||||||
string path = Global.Game.SaveStatePrefix + "." + name + ".State";
|
string path = Global.Game.SaveStatePrefix + "." + name + ".State";
|
||||||
|
@ -1604,89 +1596,6 @@ namespace BizHawk.MultiClient
|
||||||
UpdateStatusSlots();
|
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)
|
private void LoadStateFile(string path, string name)
|
||||||
{
|
{
|
||||||
var reader = new StreamReader(path);
|
var reader = new StreamReader(path);
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace BizHawk.MultiClient
|
||||||
if (column == 0) //File
|
if (column == 0) //File
|
||||||
text = Path.GetFileName(MovieList[index].Filename);
|
text = Path.GetFileName(MovieList[index].Filename);
|
||||||
if (column == 1) //System
|
if (column == 1) //System
|
||||||
text = MovieList[index].GetSysID();
|
text = MovieList[index].SysID();
|
||||||
if (column == 2) //Game
|
if (column == 2) //Game
|
||||||
text = MovieList[index].GetGameName();
|
text = MovieList[index].GetGameName();
|
||||||
if (column == 3) //Time
|
if (column == 3) //Time
|
||||||
|
|
|
@ -35,7 +35,8 @@ namespace BizHawk.MultiClient
|
||||||
IsText = true;
|
IsText = true;
|
||||||
Frames = 0;
|
Frames = 0;
|
||||||
StartsFromSavestate = false;
|
StartsFromSavestate = false;
|
||||||
Loaded = false;
|
if (filename.Length > 0)
|
||||||
|
Loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Movie()
|
public Movie()
|
||||||
|
@ -48,11 +49,16 @@ namespace BizHawk.MultiClient
|
||||||
Loaded = false;
|
Loaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetSysID()
|
public string SysID()
|
||||||
{
|
{
|
||||||
return Header.GetHeaderLine(MovieHeader.PLATFORM);
|
return Header.GetHeaderLine(MovieHeader.PLATFORM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GUID()
|
||||||
|
{
|
||||||
|
return Header.GetHeaderLine(MovieHeader.GUID);
|
||||||
|
}
|
||||||
|
|
||||||
public string GetGameName()
|
public string GetGameName()
|
||||||
{
|
{
|
||||||
return Header.GetHeaderLine(MovieHeader.GAMENAME);
|
return Header.GetHeaderLine(MovieHeader.GAMENAME);
|
||||||
|
@ -310,6 +316,8 @@ namespace BizHawk.MultiClient
|
||||||
public void DumpLogIntoSavestateText(TextWriter writer)
|
public void DumpLogIntoSavestateText(TextWriter writer)
|
||||||
{
|
{
|
||||||
writer.WriteLine("[Input]");
|
writer.WriteLine("[Input]");
|
||||||
|
string s = MovieHeader.GUID + " " + Header.GetHeaderLine(MovieHeader.GUID);
|
||||||
|
writer.WriteLine(s);
|
||||||
for (int x = 0; x < Log.Length(); x++)
|
for (int x = 0; x < Log.Length(); x++)
|
||||||
writer.WriteLine(Log.GetFrame(x));
|
writer.WriteLine(Log.GetFrame(x));
|
||||||
writer.WriteLine("[/Input]");
|
writer.WriteLine("[/Input]");
|
||||||
|
@ -571,8 +579,8 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private int CompareSysID(Movie Other)
|
private int CompareSysID(Movie Other)
|
||||||
{
|
{
|
||||||
string otherSysID = Other.GetSysID();
|
string otherSysID = Other.SysID();
|
||||||
string thisSysID = this.GetSysID();
|
string thisSysID = this.SysID();
|
||||||
|
|
||||||
if (thisSysID == null && otherSysID == null)
|
if (thisSysID == null && otherSysID == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -184,5 +184,17 @@ namespace BizHawk.MultiClient
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ReadHeader(StreamReader reader)
|
||||||
|
{
|
||||||
|
using (reader)
|
||||||
|
{
|
||||||
|
string str = "";
|
||||||
|
while ((str = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
AddHeaderFromLine(str);
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue