Movies - final round of refactoring, also removed all code relating to the StopOnFrame variable. The fast foraward button on TAStudio now loses some functionality, but the code that did it needed an overhaul

This commit is contained in:
adelikat 2012-09-03 20:17:57 +00:00
parent 8f408737da
commit 1b20175a81
7 changed files with 27 additions and 69 deletions

View File

@ -32,7 +32,7 @@ namespace BizHawk.MultiClient
}
if (record)
{
Global.MovieSession.Movie.StartNewRecording();
Global.MovieSession.Movie.StartRecording();
ReadOnly = false;
}
else
@ -167,7 +167,7 @@ namespace BizHawk.MultiClient
{
return false; //GUID Error
}
Global.MovieSession.Movie.Record();
Global.MovieSession.Movie.SwitchToRecord();
SetMainformMovieInfo();
Global.MovieSession.Movie.LoadLogFromSavestateText(path);
}
@ -205,7 +205,7 @@ namespace BizHawk.MultiClient
}
else
{
Global.MovieSession.Movie.StartNewRecording();
Global.MovieSession.Movie.StartRecording();
SetMainformMovieInfo();
Global.MovieSession.Movie.LoadLogFromSavestateText(path);
}
@ -271,25 +271,6 @@ namespace BizHawk.MultiClient
//this has been wired to Global.MovieOutputHardpoint in RewireInputChain
Global.MovieSession.Movie.CommitFrame(Global.Emulator.Frame, Global.MovieOutputHardpoint);
}
//adelikat TODO: Scheduled for deletion: RestoreReadWriteOnStop, should just be a type of movie finished, we need a menu item for what to do when a movie finishes (closes, resumes recording, goes into finished mode)
//if (StopOnFrame != -1 && StopOnFrame == Global.Emulator.Frame + 1)
//{
// if (StopOnFrame == Global.MovieSession.Movie.LogLength())
// {
// Global.MovieSession.Movie.SetMovieFinished();
// }
// if (Global.MovieSession.Movie.TastudioOn == true)
// {
// PauseEmulator();
// StopOnFrame = -1;
// }
// if (RestoreReadWriteOnStop == true)
// {
// Global.MovieSession.Movie.Mode = MOVIEMODE.RECORD;
// RestoreReadWriteOnStop = false;
// }
//}
}
}
}

View File

@ -34,7 +34,6 @@ namespace BizHawk.MultiClient
public bool PressRewind = false;
public bool FastForward = false;
public bool TurboFastForward = false;
public int StopOnFrame = -1;
public bool RestoreReadWriteOnStop = false;
public bool UpdateFrame = false;
@ -225,7 +224,6 @@ namespace BizHawk.MultiClient
else
{
Movie m = new Movie(cmdMovie);
m.Play();
ReadOnly = true;
// if user is dumping and didnt supply dump length, make it as long as the loaded movie
if (autoDumpLength == 0)
@ -245,8 +243,6 @@ namespace BizHawk.MultiClient
else
{
Movie m = new Movie(Global.Config.RecentMovies.GetRecentFileByPosition(0));
m.Play();
ReadOnly = true;
StartNewMovie(m, false);
}
}
@ -505,9 +501,13 @@ namespace BizHawk.MultiClient
{
EmulatorPaused ^= true;
if (EmulatorPaused)
{
PauseStrip.Image = BizHawk.MultiClient.Properties.Resources.Pause;
}
else
{
PauseStrip.Image = BizHawk.MultiClient.Properties.Resources.Blank;
}
}
@ -519,7 +519,9 @@ namespace BizHawk.MultiClient
Global.Sound.StopSound();
DialogResult result = MessageBox.Show("Could not open " + rom + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (result == DialogResult.Yes)
{
Global.Config.RecentRoms.Remove(rom);
}
Global.Sound.StartSound();
}
}
@ -527,14 +529,15 @@ namespace BizHawk.MultiClient
private void LoadMoviesFromRecent(string movie)
{
Movie m = new Movie(movie);
m.Play();
if (!m.Loaded)
{
Global.Sound.StopSound();
DialogResult result = MessageBox.Show("Could not open " + movie + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (result == DialogResult.Yes)
{
Global.Config.RecentMovies.Remove(movie);
}
Global.Sound.StartSound();
}
else
@ -958,9 +961,13 @@ namespace BizHawk.MultiClient
string warningMsg = "";
Movie m = MovieImport.ImportFile(filePaths[0], out errorMsg, out warningMsg);
if (errorMsg.Length > 0)
{
MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
StartNewMovie(m, false);
}
Global.OSD.AddMessage(warningMsg);
}
else
@ -1888,7 +1895,7 @@ namespace BizHawk.MultiClient
//we don't want to capture input when rewinding, even in record mode
if (Global.MovieSession.Movie.IsRecording)
{
Global.MovieSession.Movie.Play();
Global.MovieSession.Movie.SwitchToPlay();
}
}
if (UpdateFrame == true)
@ -1896,7 +1903,7 @@ namespace BizHawk.MultiClient
runFrame = true;
if (Global.MovieSession.Movie.IsRecording)
{
Global.MovieSession.Movie.Play();
Global.MovieSession.Movie.SwitchToPlay();
}
}
@ -1992,7 +1999,7 @@ namespace BizHawk.MultiClient
UpdateToolsAfter();
if (ReturnToRecording)
{
Global.MovieSession.Movie.Record();
Global.MovieSession.Movie.SwitchToRecord();
}
PressRewind = false;
}
@ -2000,7 +2007,7 @@ namespace BizHawk.MultiClient
{
if (ReturnToRecording)
{
Global.MovieSession.Movie.Record();
Global.MovieSession.Movie.SwitchToRecord();
}
UpdateFrame = false;
}

View File

@ -58,7 +58,6 @@ namespace BizHawk.MultiClient
MovieToRecord = new Movie(path);
MovieToRecord.Record();
//Header
MovieToRecord.Header.SetHeaderLine(MovieHeader.AUTHOR, AuthorBox.Text);

View File

@ -216,12 +216,11 @@ namespace BizHawk.MultiClient
}
}
//TODO: merge this with record? or better distinguish between the two events
/// <summary>
/// Tells the movie to start recording from the beginning, this will clear sram, and the movie log
/// </summary>
/// <param name="truncate"></param>
public void StartNewRecording(bool truncate = true)
public void StartRecording(bool truncate = true)
{
Global.MainForm.ClearSaveRAM();
Mode = MOVIEMODE.RECORD;
@ -236,31 +235,26 @@ namespace BizHawk.MultiClient
}
}
//TODO: merge this with Play, play vs resume play?
public void StartPlayback()
{
Global.MainForm.ClearSaveRAM();
Mode = MOVIEMODE.PLAY;
Global.MainForm.StopOnFrame = Frames; //TODO: Get rid of this stuff
}
/// <summary>
/// Tells the movie to recording mode
/// </summary>
public void Record()
public void SwitchToRecord()
{
Mode = MOVIEMODE.RECORD;
}
//TODO: all the constructors for a movie that call this or record after, need to be rethought, what about clearing sram??
/// <summary>
/// Tells the movie to go into playback mode
/// </summary>
public void Play()
public void SwitchToPlay()
{
//TODO: determine if movie finished is correct here
//Also, consider the management of the read-only flag
//Really this hsouldn't be a method, it should be a consequence of other factors that should be managed
Mode = MOVIEMODE.PLAY;
}
@ -463,9 +457,8 @@ namespace BizHawk.MultiClient
if (frame <= Log.StateFirstIndex())
{
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Log.GetInitState())));
if (true == Global.MainForm.EmulatorPaused && 0 != frame)
if (Global.MainForm.EmulatorPaused == true && frame > 0)
{
Global.MainForm.StopOnFrame = frame;
Global.MainForm.UnpauseEmulator();
}
if (MOVIEMODE.RECORD == Mode)
@ -493,7 +486,6 @@ namespace BizHawk.MultiClient
}
else
{
Global.MainForm.StopOnFrame = frame;
Global.MainForm.UnpauseEmulator();
}
}

View File

@ -197,7 +197,6 @@ namespace BizHawk.MultiClient
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileInfo file = new FileInfo(path);
StreamReader sr = file.OpenText();
string emulator = "";
@ -348,7 +347,6 @@ namespace BizHawk.MultiClient
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 46 43 4D 1A "FCM\x1A"
@ -604,7 +602,6 @@ namespace BizHawk.MultiClient
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 46 4D 56 1A "FMV\x1A"
@ -735,7 +732,6 @@ namespace BizHawk.MultiClient
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 16-byte signature and format version: "Gens Movie TEST9"
@ -850,7 +846,6 @@ namespace BizHawk.MultiClient
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 8-byte "MDFNMOVI" signature
@ -974,7 +969,6 @@ namespace BizHawk.MultiClient
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 0000: 4-byte signature: "MMV\0"
@ -1090,7 +1084,6 @@ namespace BizHawk.MultiClient
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 4E 53 53 1A "NSS\x1A"
@ -1340,7 +1333,6 @@ namespace BizHawk.MultiClient
private static Movie ImportSMV143(BinaryReader r, string path)
{
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
uint GUID = r.ReadUInt32();
m.Header.SetHeaderLine(MovieHeader.GUID, GUID.ToString()); //TODO: format to hex string
m.Rerecords = (int)r.ReadUInt32();
@ -1396,7 +1388,6 @@ namespace BizHawk.MultiClient
private static Movie ImportSMV151(BinaryReader r, string path)
{
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
m.Header.Comments.Add(EMULATIONORIGIN + " Snes9x version 1.51");
m.Header.Comments.Add(MOVIEORIGIN + " .SMV");
return m;
@ -1405,7 +1396,6 @@ namespace BizHawk.MultiClient
private static Movie ImportSMV152(BinaryReader r, string path)
{
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
uint GUID = r.ReadUInt32();
m.Header.Comments.Add(EMULATIONORIGIN + " Snes9x version 1.52");
m.Header.Comments.Add(MOVIEORIGIN + " .SMV");
@ -1418,7 +1408,6 @@ namespace BizHawk.MultiClient
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 56 42 4D 1A "VBM\x1A"
@ -1645,7 +1634,6 @@ namespace BizHawk.MultiClient
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 12-byte signature: "VirtuaNES MV"

View File

@ -19,7 +19,6 @@
}
Global.MovieSession.Movie.StateCapturing = false;
Global.MainForm.StopOnFrame = Global.MovieSession.Movie.Frames; //TODO: remove this StopOnFrame stuff
base.Dispose(disposing);
}

View File

@ -185,7 +185,6 @@ namespace BizHawk.MultiClient
if (Global.MovieSession.Movie.IsActive)
{
Global.MovieSession.Movie.StateCapturing = true;
Global.MainForm.StopOnFrame = -1;
ReadOnlyCheckBox.Checked = Global.MainForm.ReadOnly;
}
else
@ -395,7 +394,7 @@ namespace BizHawk.MultiClient
if (Global.MovieSession.Movie.IsActive)
{
Global.MovieSession.Movie.Play();
Global.MovieSession.Movie.SwitchToPlay();
toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Currently Read-Only Mode");
}
}
@ -405,7 +404,7 @@ namespace BizHawk.MultiClient
ReadOnlyCheckBox.BackColor = Color.LightCoral;
if (Global.MovieSession.Movie.IsActive)
{
Global.MovieSession.Movie.Record();
Global.MovieSession.Movie.SwitchToRecord();
toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Currently Read+Write Mode");
}
}
@ -419,14 +418,7 @@ namespace BizHawk.MultiClient
private void FastForwardToEnd_Click(object sender, EventArgs e)
{
if (true == this.FastFowardToEnd.Checked)
{
Global.MainForm.StopOnFrame = -1;
}
else
{
Global.MainForm.StopOnFrame = Global.MovieSession.Movie.Frames;
}
//TODO: adelikat: I removed the stop on frame feature, so this will keep playing into movie finished mode, need to rebuild that functionality
this.FastFowardToEnd.Checked ^= true;
Global.MainForm.FastForward = this.FastFowardToEnd.Checked;