remove a bit of hackish stuff in the new RomLoader by offloading mainform-appropriate work back to mainform

This commit is contained in:
goyuken 2014-01-01 21:24:58 +00:00
parent e7b34911b7
commit 8ed0265c9d
2 changed files with 11 additions and 31 deletions

View File

@ -58,7 +58,6 @@ namespace BizHawk.Client.Common
// TODO: reconsider the need for exposing these; // TODO: reconsider the need for exposing these;
public IEmulator LoadedEmulator { get; private set; } public IEmulator LoadedEmulator { get; private set; }
public CoreComm NextComm { get; private set; }
public GameInfo Game { get; private set; } public GameInfo Game { get; private set; }
public RomGame Rom { get; private set; } public RomGame Rom { get; private set; }
public string CanonicalFullPath { get; private set; } public string CanonicalFullPath { get; private set; }
@ -98,8 +97,6 @@ namespace BizHawk.Client.Common
public Func<HawkFile, int?> ChooseArchive { get; set; } public Func<HawkFile, int?> ChooseArchive { get; set; }
public Action<string> CoreCommMessageCallback { get; set; } // TODO: eww, do we have to do this?
private int? HandleArchive(HawkFile file) private int? HandleArchive(HawkFile file)
{ {
if (ChooseArchive != null) if (ChooseArchive != null)
@ -118,22 +115,7 @@ namespace BizHawk.Client.Common
} }
} }
// TODO I'm in mainform.cs and here, move me to a common place that both can call, static method on the config object? public bool LoadRom(string path, CoreComm nextComm)
private static void CommitCoreSettingsToConfig()
{
// save settings object
var t = Global.Emulator.GetType();
Global.Config.PutCoreSettings(Global.Emulator.GetSettings(), t);
// don't trample config with loaded-from-movie settings
if (!Global.MovieSession.Movie.IsActive)
{
Global.Config.PutCoreSyncSettings(Global.Emulator.GetSyncSettings(), t);
}
}
// TODO: the hasMovie hack should be obsoleted by the standardized movie sync setting saving/loading
public bool LoadRom(string path, bool hasmovie = false)
{ {
if (path == null) if (path == null)
{ {
@ -177,13 +159,6 @@ namespace BizHawk.Client.Common
IEmulator nextEmulator = null; IEmulator nextEmulator = null;
RomGame rom = null; RomGame rom = null;
GameInfo game = null; GameInfo game = null;
var nextComm = new CoreComm(CoreCommMessageCallback);
CoreFileProvider.SyncCoreCommInputSignals(nextComm);
// this also happens in CloseGame(). but it needs to happen here since if we're restarting with the same core,
// any settings changes that we made need to make it back to config before we try to instantiate that core with
// the new settings objects
CommitCoreSettingsToConfig();
try try
{ {
@ -438,7 +413,6 @@ namespace BizHawk.Client.Common
break; break;
case "N64": case "N64":
Global.Game = game;
nextEmulator = new N64(nextComm, game, rom.RomData, GetCoreSyncSettings<N64>()); nextEmulator = new N64(nextComm, game, rom.RomData, GetCoreSyncSettings<N64>());
break; break;
case "DEBUG": case "DEBUG":
@ -465,7 +439,6 @@ namespace BizHawk.Client.Common
Rom = rom; Rom = rom;
LoadedEmulator = nextEmulator; LoadedEmulator = nextEmulator;
NextComm = nextComm;
Game = game; Game = game;
CanonicalFullPath = file.CanonicalFullPath; CanonicalFullPath = file.CanonicalFullPath;
return true; return true;

View File

@ -2948,7 +2948,6 @@ namespace BizHawk.Client.EmuHawk
var loader = new RomLoader var loader = new RomLoader
{ {
ChooseArchive = LoadArhiveChooser, ChooseArchive = LoadArhiveChooser,
CoreCommMessageCallback = ShowMessageCoreComm
}; };
loader.OnLoadError += ShowLoadError; loader.OnLoadError += ShowLoadError;
@ -2956,7 +2955,15 @@ namespace BizHawk.Client.EmuHawk
loader.OnLoadSettings += CoreSettings; loader.OnLoadSettings += CoreSettings;
loader.OnLoadSyncSettings += CoreSyncSettings; loader.OnLoadSyncSettings += CoreSyncSettings;
var result = loader.LoadRom(path, hasmovie); // this also happens in CloseGame(). but it needs to happen here since if we're restarting with the same core,
// any settings changes that we made need to make it back to config before we try to instantiate that core with
// the new settings objects
CommitCoreSettingsToConfig();
var nextComm = new CoreComm(ShowMessageCoreComm);
CoreFileProvider.SyncCoreCommInputSignals(nextComm);
var result = loader.LoadRom(path, nextComm);
if (result) if (result)
{ {
@ -2971,7 +2978,7 @@ namespace BizHawk.Client.EmuHawk
CloseGame(); CloseGame();
Global.Emulator.Dispose(); Global.Emulator.Dispose();
Global.Emulator = loader.LoadedEmulator; Global.Emulator = loader.LoadedEmulator;
Global.CoreComm = loader.NextComm; Global.CoreComm = nextComm;
Global.Game = loader.Game; Global.Game = loader.Game;
CoreFileProvider.SyncCoreCommInputSignals(); CoreFileProvider.SyncCoreCommInputSignals();
InputManager.SyncControls(); InputManager.SyncControls();