From 644106575ea27ede93fd1476207b081b23359103 Mon Sep 17 00:00:00 2001 From: offspring131313 Date: Mon, 16 May 2011 03:55:17 +0000 Subject: [PATCH] Refactored Movie folder. Added some functions, merged some functions, and added some comments regarding some questions I have about a few of the functions. --- BizHawk.MultiClient/movie/Movie.cs | 19 ++++++++++++------- BizHawk.MultiClient/movie/MovieHeader.cs | 10 +--------- BizHawk.MultiClient/movie/MovieLog.cs | 11 +++++++++-- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/BizHawk.MultiClient/movie/Movie.cs b/BizHawk.MultiClient/movie/Movie.cs index ad321e3868..c8fceed059 100644 --- a/BizHawk.MultiClient/movie/Movie.cs +++ b/BizHawk.MultiClient/movie/Movie.cs @@ -57,7 +57,7 @@ namespace BizHawk.MultiClient { MovieMode = MOVIEMODE.RECORD; Log.Clear(); - Header = new MovieHeader("BizHawk v1.0.0", MovieHeader.MovieVersion, Global.Emulator.SystemId, Global.Game.Name, "", 0); + Header = new MovieHeader(MainForm.EMUVERSION, MovieHeader.MovieVersion, Global.Emulator.SystemId, Global.Game.Name, "", 0); } public void StartPlayback() @@ -87,11 +87,16 @@ namespace BizHawk.MultiClient } //Movie editing tools may like to have something like this - public void AddMovieRecord(string record) + public void AddFrame(string record) { Log.AddFrame(record); } + public void AddFrameAt(string record, int frame) + { + Log.AddFrameAt(record, frame); + } + public void WriteMovie() { if (IsText) @@ -255,7 +260,7 @@ namespace BizHawk.MultiClient } else if (str[0] == '|') { - break; + break;//This right? } else { @@ -267,7 +272,7 @@ namespace BizHawk.MultiClient } return true; - } + }//Also this method is never called, can delete? What is purpose? private bool LoadBinary() { @@ -306,7 +311,7 @@ namespace BizHawk.MultiClient if (line == "[/Input]") break; if (line[0] == '|') Log.AddFrame(line); - } + }//can this be reduced to just if(line[0] == '|') Log.AddFrame(line) ?? } public void IncrementRerecordCount() @@ -333,7 +338,7 @@ namespace BizHawk.MultiClient public void SetHeaderLine(string key, string value) { - Header.SetHeaderLine(key, value); + Header.AddHeaderLine(key, value); } public string GetTime() @@ -367,7 +372,7 @@ namespace BizHawk.MultiClient } private double GetSeconds() - { + { //Should these be placed somewhere more accessible? Perhaps as a public dictionary object in MainForm? const double NES_PAL = 50.006977968268290849; const double NES_NTSC = (double)60.098813897440515532; const double PCE_PAL = 50.0; //TODO ? diff --git a/BizHawk.MultiClient/movie/MovieHeader.cs b/BizHawk.MultiClient/movie/MovieHeader.cs index 8928bff649..e8ac3b9550 100644 --- a/BizHawk.MultiClient/movie/MovieHeader.cs +++ b/BizHawk.MultiClient/movie/MovieHeader.cs @@ -53,10 +53,7 @@ namespace BizHawk.MultiClient /// public void AddHeaderLine(string key, string value) { - string temp = value; - - if (!HeaderParams.TryGetValue(key, out temp)) //TODO: does a failed attempt mess with value? - HeaderParams.Add(key, value); + HeaderParams.Add(key, value); } public void UpdateRerecordCount(int count) @@ -80,10 +77,5 @@ namespace BizHawk.MultiClient HeaderParams.TryGetValue(key, out value); return value; } - - public void SetHeaderLine(string key, string value) - { - HeaderParams[key] = value; - } } } diff --git a/BizHawk.MultiClient/movie/MovieLog.cs b/BizHawk.MultiClient/movie/MovieLog.cs index 32988a846a..1f4b651692 100644 --- a/BizHawk.MultiClient/movie/MovieLog.cs +++ b/BizHawk.MultiClient/movie/MovieLog.cs @@ -16,7 +16,8 @@ namespace BizHawk.MultiClient public MovieLog() { - + //Should this class initialize with an empty string to MovieRecords so that first frame is index 1? + //MovieRecords.Add(""); } public int Length() @@ -39,9 +40,15 @@ namespace BizHawk.MultiClient MovieRecords.Add(frame); } + public void AddFrameAt(string frame, int frameNum) + { + MovieRecords.Insert(frameNum, frame); + } + public void Truncate(int frame) { - //TODO + if (frame >= 0 && frame < Length()) + { MovieRecords.RemoveRange(frame,Length() - frame); } } public string GetFrame(int frameCount) //Frame count is 0 based here, should it be?