Movies - round 1 of code cleanup (no functional changes)
This commit is contained in:
parent
eae73accf3
commit
27f4663125
|
@ -342,11 +342,11 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED)
|
if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED)
|
||||||
{
|
{
|
||||||
return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.LogLength().ToString() + " (Finished)";
|
return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.TotalFrames.ToString() + " (Finished)";
|
||||||
}
|
}
|
||||||
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY)
|
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY)
|
||||||
{
|
{
|
||||||
return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.LogLength().ToString();
|
return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.TotalFrames.ToString();
|
||||||
}
|
}
|
||||||
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD)
|
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD)
|
||||||
return Global.Emulator.Frame.ToString();
|
return Global.Emulator.Frame.ToString();
|
||||||
|
|
|
@ -1813,7 +1813,7 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
public int movie_length()
|
public int movie_length()
|
||||||
{
|
{
|
||||||
return Global.MovieSession.Movie.LogLength();
|
return Global.MovieSession.Movie.TotalFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string movie_filename()
|
public string movie_filename()
|
||||||
|
|
|
@ -242,8 +242,8 @@ namespace BizHawk.MultiClient
|
||||||
Global.MovieSession.Movie.CommitFrame(Global.Emulator.Frame, Global.MovieOutputHardpoint);
|
Global.MovieSession.Movie.CommitFrame(Global.Emulator.Frame, Global.MovieOutputHardpoint);
|
||||||
break;
|
break;
|
||||||
case MOVIEMODE.PLAY:
|
case MOVIEMODE.PLAY:
|
||||||
int x = Global.MovieSession.Movie.LogLength();
|
int x = Global.MovieSession.Movie.TotalFrames;
|
||||||
if (Global.Emulator.Frame >= Global.MovieSession.Movie.LogLength())
|
if (Global.Emulator.Frame >= Global.MovieSession.Movie.TotalFrames)
|
||||||
{
|
{
|
||||||
Global.MovieSession.Movie.SetMovieFinished();
|
Global.MovieSession.Movie.SetMovieFinished();
|
||||||
}
|
}
|
||||||
|
@ -255,8 +255,8 @@ namespace BizHawk.MultiClient
|
||||||
x++;
|
x++;
|
||||||
break;
|
break;
|
||||||
case MOVIEMODE.FINISHED:
|
case MOVIEMODE.FINISHED:
|
||||||
int xx = Global.MovieSession.Movie.LogLength();
|
int xx = Global.MovieSession.Movie.TotalFrames;
|
||||||
if (Global.Emulator.Frame < Global.MovieSession.Movie.LogLength()) //This scenario can happen from rewinding (suddenly we are back in the movie, so hook back up to the movie
|
if (Global.Emulator.Frame < Global.MovieSession.Movie.TotalFrames) //This scenario can happen from rewinding (suddenly we are back in the movie, so hook back up to the movie
|
||||||
{
|
{
|
||||||
Global.MovieSession.Movie.StartPlayback();
|
Global.MovieSession.Movie.StartPlayback();
|
||||||
Global.MovieSession.LatchInputFromLog();
|
Global.MovieSession.LatchInputFromLog();
|
||||||
|
|
|
@ -226,7 +226,7 @@ namespace BizHawk.MultiClient
|
||||||
ReadOnly = true;
|
ReadOnly = true;
|
||||||
// if user is dumping and didnt supply dump length, make it as long as the loaded movie
|
// if user is dumping and didnt supply dump length, make it as long as the loaded movie
|
||||||
if (autoDumpLength == 0)
|
if (autoDumpLength == 0)
|
||||||
autoDumpLength = m.LogLength();
|
autoDumpLength = m.TotalFrames;
|
||||||
StartNewMovie(m, false);
|
StartNewMovie(m, false);
|
||||||
Global.Config.RecentMovies.Add(cmdMovie);
|
Global.Config.RecentMovies.Add(cmdMovie);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,21 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
text = "";
|
text = "";
|
||||||
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].SysID();
|
{
|
||||||
|
text = MovieList[index].SysID;
|
||||||
|
}
|
||||||
if (column == 2) //Game
|
if (column == 2) //Game
|
||||||
text = MovieList[index].GetGameName();
|
{
|
||||||
|
text = MovieList[index].GameName;
|
||||||
|
}
|
||||||
if (column == 3) //Time
|
if (column == 3) //Time
|
||||||
|
{
|
||||||
text = MovieList[index].GetTime(true);
|
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)
|
||||||
|
@ -88,7 +96,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
Movie m = new Movie(file.FullName, MOVIEMODE.INACTIVE);
|
Movie m = new Movie(file.FullName, MOVIEMODE.INACTIVE);
|
||||||
m.LoadMovie(); //State files will have to load everything unfortunately
|
m.LoadMovie(); //State files will have to load everything unfortunately
|
||||||
if (m.LogLength() == 0)
|
if (m.TotalFrames == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("No input log detected in this savestate, aborting", "Can not load file", MessageBoxButtons.OK, MessageBoxIcon.Hand);
|
MessageBox.Show("No input log detected in this savestate, aborting", "Can not load file", MessageBoxButtons.OK, MessageBoxIcon.Hand);
|
||||||
return;
|
return;
|
||||||
|
@ -119,7 +127,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
Movie m = new Movie(file.CanonicalFullPath, MOVIEMODE.INACTIVE);
|
Movie m = new Movie(file.CanonicalFullPath, MOVIEMODE.INACTIVE);
|
||||||
m.LoadMovie(); //State files will have to load everything unfortunately
|
m.LoadMovie(); //State files will have to load everything unfortunately
|
||||||
if (m.LogLength() > 0)
|
if (m.TotalFrames > 0)
|
||||||
{
|
{
|
||||||
MovieList.Add(m);
|
MovieList.Add(m);
|
||||||
sortReverse = false;
|
sortReverse = false;
|
||||||
|
@ -201,7 +209,7 @@ namespace BizHawk.MultiClient
|
||||||
//Pull out matching names
|
//Pull out matching names
|
||||||
for (int x = 0; x < MovieList.Count; x++)
|
for (int x = 0; x < MovieList.Count; x++)
|
||||||
{
|
{
|
||||||
if (PathManager.FilesystemSafeName(Global.Game) == MovieList[x].GetGameName())
|
if (PathManager.FilesystemSafeName(Global.Game) == MovieList[x].GameName)
|
||||||
Indexes.Add(x);
|
Indexes.Add(x);
|
||||||
}
|
}
|
||||||
if (Indexes.Count == 0) return;
|
if (Indexes.Count == 0) return;
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
if (StartFromCombo.SelectedItem.ToString() == "Now")
|
if (StartFromCombo.SelectedItem.ToString() == "Now")
|
||||||
{
|
{
|
||||||
MovieToRecord.SetStartsFromSavestate(true);
|
MovieToRecord.FlagStartsFromSavestate();
|
||||||
var temppath = path + ".tmp";
|
var temppath = path + ".tmp";
|
||||||
var writer = new StreamWriter(temppath);
|
var writer = new StreamWriter(temppath);
|
||||||
Global.Emulator.SaveStateText(writer);
|
Global.Emulator.SaveStateText(writer);
|
||||||
|
|
|
@ -163,7 +163,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
for (int i = 0; i < frames; i++)
|
for (int i = 0; i < frames; i++)
|
||||||
{
|
{
|
||||||
if (RewindBuf.Count == 0 || (true == Global.MovieSession.Movie.Loaded && 0 == Global.MovieSession.Movie.LogLength()))
|
if (RewindBuf.Count == 0 || (true == Global.MovieSession.Movie.Loaded && 0 == Global.MovieSession.Movie.TotalFrames))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,34 +12,16 @@ namespace BizHawk.MultiClient
|
||||||
public enum MOVIEMODE { INACTIVE, PLAY, RECORD, FINISHED };
|
public enum MOVIEMODE { INACTIVE, PLAY, RECORD, FINISHED };
|
||||||
public class Movie
|
public class Movie
|
||||||
{
|
{
|
||||||
public MovieHeader Header = new MovieHeader();
|
#region Constructors
|
||||||
public SubtitleList Subtitles = new SubtitleList();
|
|
||||||
public bool MakeBackup = true; //make backup before altering movie
|
|
||||||
|
|
||||||
//Remove this once the memory mangement issues with save states for tastudio has been solved.
|
|
||||||
public bool TastudioOn = false;
|
|
||||||
|
|
||||||
public bool IsText { get; private set; }
|
|
||||||
public string Filename { get; private set; }
|
|
||||||
public MOVIEMODE Mode { get; set; }
|
|
||||||
public int Rerecords { get; private set; }
|
|
||||||
private int Frames;
|
|
||||||
public bool RerecordCounting { get; set; }
|
|
||||||
|
|
||||||
private MovieLog Log = new MovieLog();
|
|
||||||
private int lastLog;
|
|
||||||
|
|
||||||
public bool StartsFromSavestate { get; private set; }
|
|
||||||
public bool Loaded { get; private set; }
|
|
||||||
|
|
||||||
public Movie(string filename, MOVIEMODE m)
|
public Movie(string filename, MOVIEMODE m)
|
||||||
{
|
{
|
||||||
Mode = m;
|
Mode = m;
|
||||||
lastLog = 0;
|
lastlog = 0;
|
||||||
Rerecords = 0;
|
Rerecords = 0;
|
||||||
this.Filename = filename;
|
this.Filename = filename;
|
||||||
IsText = true;
|
IsText = true;
|
||||||
Frames = 0;
|
frames = 0;
|
||||||
RerecordCounting = true;
|
RerecordCounting = true;
|
||||||
StartsFromSavestate = false;
|
StartsFromSavestate = false;
|
||||||
if (filename.Length > 0)
|
if (filename.Length > 0)
|
||||||
|
@ -51,35 +33,87 @@ namespace BizHawk.MultiClient
|
||||||
Filename = "";
|
Filename = "";
|
||||||
Mode = MOVIEMODE.INACTIVE;
|
Mode = MOVIEMODE.INACTIVE;
|
||||||
IsText = true;
|
IsText = true;
|
||||||
Frames = 0;
|
frames = 0;
|
||||||
StartsFromSavestate = false;
|
StartsFromSavestate = false;
|
||||||
Loaded = false;
|
Loaded = false;
|
||||||
RerecordCounting = true;
|
RerecordCounting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SysID()
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public MovieHeader Header = new MovieHeader();
|
||||||
|
public SubtitleList Subtitles = new SubtitleList();
|
||||||
|
public bool MakeBackup = true; //make backup before altering movie
|
||||||
|
public bool TastudioOn = false; //Remove this once the memory mangement issues with save states for tastudio has been solved.
|
||||||
|
public bool IsText { get; private set; }
|
||||||
|
public string Filename { get; private set; }
|
||||||
|
public MOVIEMODE Mode { get; set; }
|
||||||
|
public int Rerecords { get; private set; }
|
||||||
|
public bool RerecordCounting { get; set; }
|
||||||
|
public bool StartsFromSavestate { get; private set; }
|
||||||
|
public bool Loaded { get; private set; }
|
||||||
|
|
||||||
|
public string SysID
|
||||||
{
|
{
|
||||||
return Header.GetHeaderLine(MovieHeader.PLATFORM);
|
get
|
||||||
|
{
|
||||||
|
return Header.GetHeaderLine(MovieHeader.PLATFORM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GUID()
|
public string GUID
|
||||||
{
|
{
|
||||||
return Header.GetHeaderLine(MovieHeader.GUID);
|
get
|
||||||
|
{
|
||||||
|
return Header.GetHeaderLine(MovieHeader.GUID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetGameName()
|
public string GameName
|
||||||
{
|
{
|
||||||
return Header.GetHeaderLine(MovieHeader.GAMENAME);
|
get
|
||||||
|
{
|
||||||
|
return Header.GetHeaderLine(MovieHeader.GAMENAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int LogLength()
|
public int TotalFrames
|
||||||
{
|
{
|
||||||
if (Loaded)
|
get
|
||||||
return Log.MovieLength();
|
{
|
||||||
else
|
if (Loaded)
|
||||||
return Frames;
|
{
|
||||||
|
return Log.MovieLength();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return frames;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int StateFirstIndex
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Log.StateFirstIndex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int StateLastIndex
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Log.StateLastIndex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
public void UpdateFileName(string filename)
|
public void UpdateFileName(string filename)
|
||||||
{
|
{
|
||||||
this.Filename = filename;
|
this.Filename = filename;
|
||||||
|
@ -88,7 +122,10 @@ namespace BizHawk.MultiClient
|
||||||
public void StopMovie()
|
public void StopMovie()
|
||||||
{
|
{
|
||||||
if (Mode == MOVIEMODE.RECORD)
|
if (Mode == MOVIEMODE.RECORD)
|
||||||
|
{
|
||||||
WriteMovie();
|
WriteMovie();
|
||||||
|
}
|
||||||
|
|
||||||
Mode = MOVIEMODE.INACTIVE;
|
Mode = MOVIEMODE.INACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,9 +191,9 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
public void DeleteFrame(int frame)
|
public void DeleteFrame(int frame)
|
||||||
{
|
{
|
||||||
if (frame <= StateLastIndex())
|
if (frame <= StateLastIndex)
|
||||||
{
|
{
|
||||||
if (frame <= StateFirstIndex())
|
if (frame <= StateFirstIndex)
|
||||||
{
|
{
|
||||||
RewindToFrame(0);
|
RewindToFrame(0);
|
||||||
}
|
}
|
||||||
|
@ -168,16 +205,6 @@ namespace BizHawk.MultiClient
|
||||||
Log.DeleteFrame(frame);
|
Log.DeleteFrame(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int StateFirstIndex()
|
|
||||||
{
|
|
||||||
return Log.StateFirstIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int StateLastIndex()
|
|
||||||
{
|
|
||||||
return Log.StateLastIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearSaveRAM()
|
public void ClearSaveRAM()
|
||||||
{
|
{
|
||||||
string x = PathManager.SaveRamPath(Global.Game);
|
string x = PathManager.SaveRamPath(Global.Game);
|
||||||
|
@ -203,7 +230,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
ClearSaveRAM();
|
ClearSaveRAM();
|
||||||
Mode = MOVIEMODE.PLAY;
|
Mode = MOVIEMODE.PLAY;
|
||||||
Global.MainForm.StopOnFrame = LogLength();
|
Global.MainForm.StopOnFrame = TotalFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResumeRecording()
|
public void ResumeRecording()
|
||||||
|
@ -231,7 +258,7 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
public string GetInputFrame(int frame)
|
public string GetInputFrame(int frame)
|
||||||
{
|
{
|
||||||
lastLog = frame;
|
lastlog = frame;
|
||||||
if (frame < Log.MovieLength())
|
if (frame < Log.MovieLength())
|
||||||
return Log.GetFrame(frame);
|
return Log.GetFrame(frame);
|
||||||
else
|
else
|
||||||
|
@ -291,92 +318,6 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WriteText(string file)
|
|
||||||
{
|
|
||||||
if (file.Length == 0) return; //Nothing to write
|
|
||||||
int length = Log.MovieLength();
|
|
||||||
|
|
||||||
using (StreamWriter sw = new StreamWriter(file))
|
|
||||||
{
|
|
||||||
Header.WriteText(sw);
|
|
||||||
Subtitles.WriteText(sw);
|
|
||||||
Log.WriteText(sw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WriteBinary(string file)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool LoadText()
|
|
||||||
{
|
|
||||||
var file = new FileInfo(Filename);
|
|
||||||
|
|
||||||
if (file.Exists == false)
|
|
||||||
{
|
|
||||||
Loaded = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Header.Clear();
|
|
||||||
Log.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
using (StreamReader sr = file.OpenText())
|
|
||||||
{
|
|
||||||
string str = "";
|
|
||||||
string rerecordStr = "";
|
|
||||||
|
|
||||||
while ((str = sr.ReadLine()) != null)
|
|
||||||
{
|
|
||||||
if (str == "")
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (str.Contains(MovieHeader.RERECORDS))
|
|
||||||
{
|
|
||||||
rerecordStr = ParseHeader(str, MovieHeader.RERECORDS);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Rerecords = int.Parse(rerecordStr);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Rerecords = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (str.Contains(MovieHeader.STARTSFROMSAVESTATE))
|
|
||||||
{
|
|
||||||
str = ParseHeader(str, MovieHeader.STARTSFROMSAVESTATE);
|
|
||||||
if (str == "1")
|
|
||||||
StartsFromSavestate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Header.AddHeaderFromLine(str))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (str.StartsWith("subtitle") || str.StartsWith("sub"))
|
|
||||||
{
|
|
||||||
Subtitles.AddSubtitle(str);
|
|
||||||
}
|
|
||||||
else if (str[0] == '|')
|
|
||||||
{
|
|
||||||
Log.AddFrame(str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Header.Comments.Add(str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loaded = true;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load Header information only for displaying file information in dialogs such as play movie
|
/// Load Header information only for displaying file information in dialogs such as play movie
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -412,7 +353,7 @@ namespace BizHawk.MultiClient
|
||||||
length++;
|
length++;
|
||||||
length++;
|
length++;
|
||||||
// Count the remaining frames and the current one.
|
// Count the remaining frames and the current one.
|
||||||
this.Frames = (frames.Length / length) + 1;
|
this.frames = (frames.Length / length) + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -424,11 +365,6 @@ namespace BizHawk.MultiClient
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool LoadBinary()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool LoadMovie()
|
public bool LoadMovie()
|
||||||
{
|
{
|
||||||
var file = new FileInfo(Filename);
|
var file = new FileInfo(Filename);
|
||||||
|
@ -561,7 +497,9 @@ namespace BizHawk.MultiClient
|
||||||
public void SetMovieFinished()
|
public void SetMovieFinished()
|
||||||
{
|
{
|
||||||
if (Mode == MOVIEMODE.PLAY)
|
if (Mode == MOVIEMODE.PLAY)
|
||||||
|
{
|
||||||
Mode = MOVIEMODE.FINISHED;
|
Mode = MOVIEMODE.FINISHED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetTime(bool preLoad)
|
public string GetTime(bool preLoad)
|
||||||
|
@ -570,102 +508,28 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
double seconds;
|
double seconds;
|
||||||
if (preLoad)
|
if (preLoad)
|
||||||
seconds = GetSeconds(Frames);
|
{
|
||||||
|
seconds = GetSeconds(frames);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
seconds = GetSeconds(Log.MovieLength());
|
seconds = GetSeconds(Log.MovieLength());
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
if (hours > 0)
|
if (hours > 0)
|
||||||
|
{
|
||||||
time += MakeDigits(hours) + ":";
|
time += MakeDigits(hours) + ":";
|
||||||
|
}
|
||||||
|
|
||||||
time += MakeDigits(minutes) + ":";
|
time += MakeDigits(minutes) + ":";
|
||||||
time += Math.Round((decimal)sec, 2).ToString();
|
time += Math.Round((decimal)sec, 2).ToString();
|
||||||
|
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string MakeDigits(decimal num)
|
|
||||||
{
|
|
||||||
return MakeDigits((int)num);
|
|
||||||
}
|
|
||||||
|
|
||||||
private string MakeDigits(int num)
|
|
||||||
{
|
|
||||||
if (num < 10)
|
|
||||||
return "0" + num.ToString();
|
|
||||||
else
|
|
||||||
return num.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private double GetSeconds(int frameCount)
|
|
||||||
{
|
|
||||||
const double NES_PAL = 50.006977968268290849;
|
|
||||||
const double NES_NTSC = (double)60.098813897440515532;
|
|
||||||
const double PCE = (7159090.90909090 / 455 / 263); //~59.826
|
|
||||||
const double SMS_NTSC = (3579545 / 262.0 / 228.0);
|
|
||||||
const double SMS_PAL = (3546893 / 313.0 / 228.0);
|
|
||||||
const double NGP = (6144000.0 / (515 * 198));
|
|
||||||
const double VBOY = (20000000 / (259 * 384 * 4)); //~50.273
|
|
||||||
const double LYNX = 59.8;
|
|
||||||
const double WSWAN = (3072000.0 / (159 * 256));
|
|
||||||
double seconds = 0;
|
|
||||||
double frames = (double)frameCount;
|
|
||||||
if (frames < 1)
|
|
||||||
return seconds;
|
|
||||||
|
|
||||||
bool pal = false; //TODO: pal flag
|
|
||||||
|
|
||||||
switch (Header.GetHeaderLine(MovieHeader.PLATFORM))
|
|
||||||
{
|
|
||||||
case "GG":
|
|
||||||
case "SG":
|
|
||||||
case "SMS":
|
|
||||||
if (pal)
|
|
||||||
return frames / SMS_PAL;
|
|
||||||
else
|
|
||||||
return frames / SMS_NTSC;
|
|
||||||
case "FDS":
|
|
||||||
case "NES":
|
|
||||||
case "SNES":
|
|
||||||
if (pal)
|
|
||||||
return frames / NES_PAL;
|
|
||||||
else
|
|
||||||
return frames / NES_NTSC;
|
|
||||||
case "PCE":
|
|
||||||
case "PCECD":
|
|
||||||
return frames / PCE;
|
|
||||||
|
|
||||||
//One Day!
|
|
||||||
case "VBOY":
|
|
||||||
return frames / VBOY;
|
|
||||||
case "NGP":
|
|
||||||
return frames / NGP;
|
|
||||||
case "LYNX":
|
|
||||||
return frames / LYNX;
|
|
||||||
case "WSWAN":
|
|
||||||
return frames / WSWAN;
|
|
||||||
//********
|
|
||||||
|
|
||||||
case "":
|
|
||||||
default:
|
|
||||||
if (pal)
|
|
||||||
return frames / 50.0;
|
|
||||||
else
|
|
||||||
return frames / 60.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsStateFromAMovie(StreamReader reader)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
if (reader.ReadLine().Contains("GUID"))
|
|
||||||
break;
|
|
||||||
if (reader.EndOfStream)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CheckTimeLines(string path, bool OnlyGUID)
|
public bool CheckTimeLines(string path, bool OnlyGUID)
|
||||||
{
|
{
|
||||||
//This function will compare the movie data to the savestate movie data to see if they match
|
//This function will compare the movie data to the savestate movie data to see if they match
|
||||||
|
@ -779,6 +643,217 @@ namespace BizHawk.MultiClient
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void FlagStartsFromSavestate()
|
||||||
|
{
|
||||||
|
StartsFromSavestate = true;
|
||||||
|
Header.AddHeaderLine(MovieHeader.STARTSFROMSAVESTATE, "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TruncateMovie(int frame)
|
||||||
|
{
|
||||||
|
Log.TruncateMovie(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Fields
|
||||||
|
|
||||||
|
private int frames; //Not a a reliable number, used for preloading (when no log has yet been loaded), this is only for quick stat compilation for dialogs such as play movie
|
||||||
|
private MovieLog Log = new MovieLog();
|
||||||
|
private int lastlog;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void WriteText(string file)
|
||||||
|
{
|
||||||
|
if (file.Length == 0) return; //Nothing to write
|
||||||
|
int length = Log.MovieLength();
|
||||||
|
|
||||||
|
using (StreamWriter sw = new StreamWriter(file))
|
||||||
|
{
|
||||||
|
Header.WriteText(sw);
|
||||||
|
Subtitles.WriteText(sw);
|
||||||
|
Log.WriteText(sw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WriteBinary(string file)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool LoadText()
|
||||||
|
{
|
||||||
|
var file = new FileInfo(Filename);
|
||||||
|
|
||||||
|
if (file.Exists == false)
|
||||||
|
{
|
||||||
|
Loaded = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Header.Clear();
|
||||||
|
Log.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
using (StreamReader sr = file.OpenText())
|
||||||
|
{
|
||||||
|
string str = "";
|
||||||
|
string rerecordStr = "";
|
||||||
|
|
||||||
|
while ((str = sr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
if (str == "")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str.Contains(MovieHeader.RERECORDS))
|
||||||
|
{
|
||||||
|
rerecordStr = ParseHeader(str, MovieHeader.RERECORDS);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Rerecords = int.Parse(rerecordStr);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Rerecords = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (str.Contains(MovieHeader.STARTSFROMSAVESTATE))
|
||||||
|
{
|
||||||
|
str = ParseHeader(str, MovieHeader.STARTSFROMSAVESTATE);
|
||||||
|
if (str == "1")
|
||||||
|
StartsFromSavestate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Header.AddHeaderFromLine(str))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (str.StartsWith("subtitle") || str.StartsWith("sub"))
|
||||||
|
{
|
||||||
|
Subtitles.AddSubtitle(str);
|
||||||
|
}
|
||||||
|
else if (str[0] == '|')
|
||||||
|
{
|
||||||
|
Log.AddFrame(str);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Header.Comments.Add(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loaded = true;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool LoadBinary()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string MakeDigits(decimal num)
|
||||||
|
{
|
||||||
|
return MakeDigits((int)num);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string MakeDigits(int num)
|
||||||
|
{
|
||||||
|
if (num < 10)
|
||||||
|
return "0" + num.ToString();
|
||||||
|
else
|
||||||
|
return num.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double GetSeconds(int frameCount)
|
||||||
|
{
|
||||||
|
const double NES_PAL = 50.006977968268290849;
|
||||||
|
const double NES_NTSC = (double)60.098813897440515532;
|
||||||
|
const double PCE = (7159090.90909090 / 455 / 263); //~59.826
|
||||||
|
const double SMS_NTSC = (3579545 / 262.0 / 228.0);
|
||||||
|
const double SMS_PAL = (3546893 / 313.0 / 228.0);
|
||||||
|
const double NGP = (6144000.0 / (515 * 198));
|
||||||
|
const double VBOY = (20000000 / (259 * 384 * 4)); //~50.273
|
||||||
|
const double LYNX = 59.8;
|
||||||
|
const double WSWAN = (3072000.0 / (159 * 256));
|
||||||
|
double seconds = 0;
|
||||||
|
double frames = (double)frameCount;
|
||||||
|
if (frames < 1)
|
||||||
|
return seconds;
|
||||||
|
|
||||||
|
bool pal = false; //TODO: pal flag
|
||||||
|
|
||||||
|
switch (Header.GetHeaderLine(MovieHeader.PLATFORM))
|
||||||
|
{
|
||||||
|
case "GG":
|
||||||
|
case "SG":
|
||||||
|
case "SMS":
|
||||||
|
if (pal)
|
||||||
|
return frames / SMS_PAL;
|
||||||
|
else
|
||||||
|
return frames / SMS_NTSC;
|
||||||
|
case "FDS":
|
||||||
|
case "NES":
|
||||||
|
case "SNES":
|
||||||
|
if (pal)
|
||||||
|
return frames / NES_PAL;
|
||||||
|
else
|
||||||
|
return frames / NES_NTSC;
|
||||||
|
case "PCE":
|
||||||
|
case "PCECD":
|
||||||
|
return frames / PCE;
|
||||||
|
|
||||||
|
//One Day!
|
||||||
|
case "VBOY":
|
||||||
|
return frames / VBOY;
|
||||||
|
case "NGP":
|
||||||
|
return frames / NGP;
|
||||||
|
case "LYNX":
|
||||||
|
return frames / LYNX;
|
||||||
|
case "WSWAN":
|
||||||
|
return frames / WSWAN;
|
||||||
|
//********
|
||||||
|
|
||||||
|
case "":
|
||||||
|
default:
|
||||||
|
if (pal)
|
||||||
|
return frames / 50.0;
|
||||||
|
else
|
||||||
|
return frames / 60.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsStateFromAMovie(StreamReader reader)
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (reader.ReadLine().Contains("GUID"))
|
||||||
|
break;
|
||||||
|
if (reader.EndOfStream)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ParseHeader(string line, string headerName)
|
||||||
|
{
|
||||||
|
string str;
|
||||||
|
int x = line.LastIndexOf(headerName) + headerName.Length;
|
||||||
|
str = line.Substring(x + 1, line.Length - x - 1);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ComparisonLogic
|
||||||
|
|
||||||
public int CompareTo(Movie Other, string parameter)
|
public int CompareTo(Movie Other, string parameter)
|
||||||
{
|
{
|
||||||
int compare = 0;
|
int compare = 0;
|
||||||
|
@ -851,8 +926,8 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private int CompareSysID(Movie Other)
|
private int CompareSysID(Movie Other)
|
||||||
{
|
{
|
||||||
string otherSysID = Other.SysID();
|
string otherSysID = Other.SysID;
|
||||||
string thisSysID = this.SysID();
|
string thisSysID = this.SysID;
|
||||||
|
|
||||||
if (thisSysID == null && otherSysID == null)
|
if (thisSysID == null && otherSysID == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -866,8 +941,8 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private int CompareGameName(Movie Other)
|
private int CompareGameName(Movie Other)
|
||||||
{
|
{
|
||||||
string otherGameName = Other.GetGameName();
|
string otherGameName = Other.GameName;
|
||||||
string thisGameName = this.GetGameName();
|
string thisGameName = this.GameName;
|
||||||
|
|
||||||
if (thisGameName == null && otherGameName == null)
|
if (thisGameName == null && otherGameName == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -881,8 +956,8 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private int CompareLength(Movie Other)
|
private int CompareLength(Movie Other)
|
||||||
{
|
{
|
||||||
int otherLength = Other.Frames;
|
int otherLength = Other.frames;
|
||||||
int thisLength = this.Frames;
|
int thisLength = this.frames;
|
||||||
|
|
||||||
if (thisLength < otherLength)
|
if (thisLength < otherLength)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -892,23 +967,6 @@ namespace BizHawk.MultiClient
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ParseHeader(string line, string headerName)
|
#endregion
|
||||||
{
|
|
||||||
string str;
|
|
||||||
int x = line.LastIndexOf(headerName) + headerName.Length;
|
|
||||||
str = line.Substring(x + 1, line.Length - x - 1);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetStartsFromSavestate(bool savestate)
|
|
||||||
{
|
|
||||||
StartsFromSavestate = true;
|
|
||||||
Header.AddHeaderLine(MovieHeader.STARTSFROMSAVESTATE, "1");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TruncateMovie(int frame)
|
|
||||||
{
|
|
||||||
Log.TruncateMovie(frame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -120,7 +120,7 @@ namespace BizHawk.MultiClient
|
||||||
case '1':
|
case '1':
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
if (m.LogLength() != 0)
|
if (m.TotalFrames != 0)
|
||||||
warningMsg = "hard reset";
|
warningMsg = "hard reset";
|
||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
Global.MovieSession.Movie.TastudioOn = false;
|
Global.MovieSession.Movie.TastudioOn = false;
|
||||||
Global.MovieSession.Movie.ClearStates();
|
Global.MovieSession.Movie.ClearStates();
|
||||||
|
|
||||||
Global.MainForm.StopOnFrame = Global.MovieSession.Movie.LogLength();
|
Global.MainForm.StopOnFrame = Global.MovieSession.Movie.TotalFrames;
|
||||||
|
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,9 +122,9 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private void TASView_QueryItemBkColor(int index, int column, ref Color color)
|
private void TASView_QueryItemBkColor(int index, int column, ref Color color)
|
||||||
{
|
{
|
||||||
if (0 == index && 0 == Global.MovieSession.Movie.StateFirstIndex())
|
if (0 == index && 0 == Global.MovieSession.Movie.StateFirstIndex)
|
||||||
color = Color.LightGreen; //special case for frame 0. Normally we need to go back an extra frame, but for frame 0 we can reload the rom.
|
color = Color.LightGreen; //special case for frame 0. Normally we need to go back an extra frame, but for frame 0 we can reload the rom.
|
||||||
if (index > Global.MovieSession.Movie.StateFirstIndex() && index <= Global.MovieSession.Movie.StateLastIndex())
|
if (index > Global.MovieSession.Movie.StateFirstIndex && index <= Global.MovieSession.Movie.StateLastIndex)
|
||||||
color = Color.LightGreen;
|
color = Color.LightGreen;
|
||||||
if ("" != Global.MovieSession.Movie.GetInputFrame(index) &&
|
if ("" != Global.MovieSession.Movie.GetInputFrame(index) &&
|
||||||
Global.COMMANDS[Global.MovieInputSourceAdapter.Type.Name].ContainsKey("Lag") &&
|
Global.COMMANDS[Global.MovieInputSourceAdapter.Type.Name].ContainsKey("Lag") &&
|
||||||
|
@ -141,7 +141,7 @@ namespace BizHawk.MultiClient
|
||||||
text = "";
|
text = "";
|
||||||
|
|
||||||
//If this is just for an actual frame and not just the list view cursor at the end
|
//If this is just for an actual frame and not just the list view cursor at the end
|
||||||
if (Global.MovieSession.Movie.LogLength() != index)
|
if (Global.MovieSession.Movie.TotalFrames != index)
|
||||||
{
|
{
|
||||||
if (column == 0)
|
if (column == 0)
|
||||||
text = String.Format("{0:#,##0}", index);
|
text = String.Format("{0:#,##0}", index);
|
||||||
|
@ -152,8 +152,8 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private void DisplayList()
|
private void DisplayList()
|
||||||
{
|
{
|
||||||
TASView.ItemCount = Global.MovieSession.Movie.LogLength();
|
TASView.ItemCount = Global.MovieSession.Movie.TotalFrames;
|
||||||
if (Global.MovieSession.Movie.LogLength() == Global.Emulator.Frame && Global.MovieSession.Movie.StateLastIndex() == Global.Emulator.Frame - 1)
|
if (Global.MovieSession.Movie.TotalFrames == Global.Emulator.Frame && Global.MovieSession.Movie.StateLastIndex == Global.Emulator.Frame - 1)
|
||||||
{
|
{
|
||||||
//If we're at the end of the movie add one to show the cursor as a blank frame
|
//If we're at the end of the movie add one to show the cursor as a blank frame
|
||||||
TASView.ItemCount++;
|
TASView.ItemCount++;
|
||||||
|
@ -360,7 +360,7 @@ namespace BizHawk.MultiClient
|
||||||
if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED || Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE)
|
if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED || Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE)
|
||||||
{
|
{
|
||||||
Global.MainForm.Rewind(1);
|
Global.MainForm.Rewind(1);
|
||||||
if (Global.Emulator.Frame <= Global.MovieSession.Movie.LogLength())
|
if (Global.Emulator.Frame <= Global.MovieSession.Movie.TotalFrames)
|
||||||
{
|
{
|
||||||
Global.MovieSession.Movie.StartPlayback();
|
Global.MovieSession.Movie.StartPlayback();
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,7 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Global.MainForm.StopOnFrame = Global.MovieSession.Movie.LogLength();
|
Global.MainForm.StopOnFrame = Global.MovieSession.Movie.TotalFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.FastFowardToEnd.Checked ^= true;
|
this.FastFowardToEnd.Checked ^= true;
|
||||||
|
|
Loading…
Reference in New Issue