diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index ce19c5b9ad..b5e430a58f 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -1015,6 +1015,9 @@ namespace BizHawk.MultiClient var writer = new StreamWriter(path); Global.Emulator.SaveStateText(writer); + //TODO: logic surrounding the behavior of movie modes & settings + //TODO: refactor save/loadstate as functions to automatically include this behavior too + InputLog.DumpLogIntoSavestateText(writer); writer.Close(); Global.RenderPanel.AddMessage("Saved state: " + name); } @@ -1048,6 +1051,9 @@ namespace BizHawk.MultiClient var reader = new StreamReader(path); Global.Emulator.LoadStateText(reader); + //TODO: more logic regarding each movie mode + if (InputLog.GetMovieMode() == MOVIEMODE.RECORD) + InputLog.LoadLogFromSavestateText(reader); reader.Close(); Global.RenderPanel.AddMessage("Loaded state: " + name); } diff --git a/BizHawk.MultiClient/movie/Movie.cs b/BizHawk.MultiClient/movie/Movie.cs index 637d81d8aa..e18b48889a 100644 --- a/BizHawk.MultiClient/movie/Movie.cs +++ b/BizHawk.MultiClient/movie/Movie.cs @@ -186,5 +186,27 @@ namespace BizHawk.MultiClient { return Log.GetMovieLength(); } + + public void DumpLogIntoSavestateText(TextWriter writer) + { + writer.WriteLine("[Input]"); + for (int x = 0; x < Log.Length(); x++) + writer.WriteLine(Log.GetFrame(x)); + writer.WriteLine("[/Input]"); + } + + public void LoadLogFromSavestateText(TextReader reader) + { + Log.Clear(); + while (true) + { + string line = reader.ReadLine(); + if (line.Trim() == "") continue; + if (line == "[Input]") continue; + if (line == "[/Input]") break; + if (line[0] == '|') + Log.AddFrame(line); + } + } } } diff --git a/BizHawk.MultiClient/movie/MovieLog.cs b/BizHawk.MultiClient/movie/MovieLog.cs index e3cff4fc8f..32988a846a 100644 --- a/BizHawk.MultiClient/movie/MovieLog.cs +++ b/BizHawk.MultiClient/movie/MovieLog.cs @@ -19,6 +19,11 @@ namespace BizHawk.MultiClient } + public int Length() + { + return MovieRecords.Count; + } + public void Clear() { MovieRecords.Clear();