movie: rework how sinksettings are saved/loaded
This commit is contained in:
parent
f69fd00458
commit
16a347565b
|
@ -63,5 +63,35 @@ namespace BizHawk.Client.Common
|
|||
Serializer.Serialize(w, config);
|
||||
}
|
||||
}
|
||||
|
||||
// movie 1.0 header stuff
|
||||
|
||||
private class TypeNameEncapsulator
|
||||
{
|
||||
public object o;
|
||||
}
|
||||
|
||||
public static object LoadWithType(string serialized)
|
||||
{
|
||||
using (TextReader tr = new StringReader(serialized))
|
||||
using (JsonTextReader jr = new JsonTextReader(tr))
|
||||
{
|
||||
TypeNameEncapsulator tne = (TypeNameEncapsulator)Serializer.Deserialize(jr, typeof(TypeNameEncapsulator));
|
||||
return tne.o;
|
||||
}
|
||||
}
|
||||
|
||||
public static string SaveWithType(object o)
|
||||
{
|
||||
using (StringWriter sw = new StringWriter())
|
||||
using (JsonTextWriter jw = new JsonTextWriter(sw) { Formatting = Formatting.None })
|
||||
{
|
||||
TypeNameEncapsulator tne = new TypeNameEncapsulator { o = o };
|
||||
Serializer.Serialize(jw, tne, typeof(TypeNameEncapsulator));
|
||||
sw.Flush();
|
||||
return sw.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,25 +49,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (Global.MovieSession.Movie.Header[HeaderKeys.CORE] == quicknesName)
|
||||
{
|
||||
Global.Config.NES_InQuickNES = true;
|
||||
|
||||
_syncSettingsHack = JsonConvert.DeserializeObject(
|
||||
Global.MovieSession.Movie.Header.SyncSettingsJson,
|
||||
typeof(QuickNES.QuickNESSyncSettings));
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.Config.NES_InQuickNES = false;
|
||||
|
||||
_syncSettingsHack = JsonConvert.DeserializeObject(
|
||||
Global.MovieSession.Movie.Header.SyncSettingsJson,
|
||||
typeof(NES.NESSyncSettings));
|
||||
}
|
||||
}
|
||||
|
||||
_syncSettingsHack = JsonConvert.DeserializeObject(
|
||||
Global.MovieSession.Movie.Header.SyncSettingsJson,
|
||||
Global.Emulator.GetSyncSettings().GetType());
|
||||
|
||||
string s = Global.MovieSession.Movie.Header.SyncSettingsJson;
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
_syncSettingsHack = ConfigService.LoadWithType(Global.MovieSession.Movie.Header.SyncSettingsJson);
|
||||
}
|
||||
LoadRom(GlobalWin.MainForm.CurrentlyOpenRom, true, !record);
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_movieToRecord.Header[HeaderKeys.PLATFORM] = Global.Game.System;
|
||||
|
||||
// Sync Settings, for movies 1.0, just dump a json blob into a header line
|
||||
_movieToRecord.Header[HeaderKeys.SYNCSETTINGS] = JsonConvert.SerializeObject(Global.Emulator.GetSyncSettings());
|
||||
_movieToRecord.Header[HeaderKeys.SYNCSETTINGS] = ConfigService.SaveWithType(Global.Emulator.GetSyncSettings());
|
||||
|
||||
if (Global.Game != null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue