progress on fm2 importer rewrite (not wired up yet)

This commit is contained in:
adelikat 2019-11-09 15:22:32 -06:00
parent 7c9f2a2873
commit 0a63255244
3 changed files with 27 additions and 12 deletions

View File

@ -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)

View File

@ -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

View File

@ -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();