diff --git a/BizHawk.Client.Common/movie/import/Fm2Import.cs b/BizHawk.Client.Common/movie/import/Fm2Import.cs index 57be1836e2..d4cb3f9bee 100644 --- a/BizHawk.Client.Common/movie/import/Fm2Import.cs +++ b/BizHawk.Client.Common/movie/import/Fm2Import.cs @@ -2,6 +2,7 @@ using BizHawk.Common; using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Cores.Nintendo.NES; namespace BizHawk.Client.Common { @@ -14,8 +15,10 @@ namespace BizHawk.Client.Common var emulator = "FCEUX"; var platform = "NES"; // TODO: FDS? - Result.Movie.HeaderEntries[HeaderKeys.PLATFORM] = platform; + var syncSettings = new NES.NESSyncSettings(); + Result.Movie.HeaderEntries[HeaderKeys.PLATFORM] = platform; + using var sr = SourceFile.OpenText(); string line; @@ -110,6 +113,11 @@ namespace BizHawk.Client.Common if (fourscore) { // TODO: set controller config sync settings + syncSettings.Controls = new NESControlSettings + { + NesLeftPort = nameof(FourScore), + NesRightPort = nameof(FourScore) + }; } } else @@ -117,6 +125,8 @@ namespace BizHawk.Client.Common Result.Movie.Comments.Add(line); // Everything not explicitly defined is treated as a comment. } } + + Result.Movie.SyncSettingsJson = ToJson(syncSettings); } private static string ImportTextSubtitle(string line) diff --git a/BizHawk.Client.Common/movie/import/IMovieImport.cs b/BizHawk.Client.Common/movie/import/IMovieImport.cs index d49a8a81e6..752aa4c0a5 100644 --- a/BizHawk.Client.Common/movie/import/IMovieImport.cs +++ b/BizHawk.Client.Common/movie/import/IMovieImport.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using Newtonsoft.Json; namespace BizHawk.Client.Common { @@ -48,6 +49,20 @@ namespace BizHawk.Client.Common string str = line.Substring(x + 1, line.Length - x - 1); return str.Trim(); } + + protected static string ToJson(object syncSettings) + { + // Annoying kludge to force the json serializer to serialize the type name for "o" object. + // For just the "o" object to have type information, it must be cast to a superclass such + // that the TypeNameHandling.Auto decides to serialize the type as well as the object + // contents. As such, the object cast is NOT redundant + var jsonSettings = new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.Auto + }; + + return JsonConvert.SerializeObject(new { o = (object)syncSettings }, jsonSettings); + } } public class ImportResult diff --git a/BizHawk.Client.Common/movie/import/PJMImport.cs b/BizHawk.Client.Common/movie/import/PJMImport.cs index 8e2b20aede..4eb2a3a70a 100644 --- a/BizHawk.Client.Common/movie/import/PJMImport.cs +++ b/BizHawk.Client.Common/movie/import/PJMImport.cs @@ -1,8 +1,6 @@ using System; using System.IO; -using Newtonsoft.Json; - using BizHawk.Emulation.Cores.Sony.PSX; namespace BizHawk.Client.Common @@ -150,15 +148,7 @@ namespace BizHawk.Client.Common } }; - // Annoying kludge to force the json serializer to serialize the type name for "o" object. - // For just the "o" object to have type information, it must be cast to a superclass such - // that the TypeNameHandling.Auto decides to serialize the type as well as the object - // contents. As such, the object cast is NOT redundant - var jsonSettings = new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.Auto - }; - movie.SyncSettingsJson = JsonConvert.SerializeObject(new { o = (object)syncSettings }, jsonSettings); + movie.SyncSettingsJson = ToJson(syncSettings); info.FrameCount = br.ReadUInt32(); uint rerecordCount = br.ReadUInt32();