refactor CoreFileProvider instantiation, require ICoreFileProvider in CoreComm constructor and remove setter for CFP
This commit is contained in:
parent
8c7b0c6ff1
commit
3c519b0249
|
@ -83,11 +83,5 @@ namespace BizHawk.Client.Common
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// this should go away now
|
||||
public static void SyncCoreCommInputSignals(CoreComm target)
|
||||
{
|
||||
target.CoreFileProvider = new CoreFileProvider(target.ShowMessage, Global.FirmwareManager);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -82,7 +82,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
// its.. weird. don't ask.
|
||||
}
|
||||
|
||||
private CoreComm CreateCoreComm() => new CoreComm(ShowMessageCoreComm, NotifyCoreComm);
|
||||
private CoreComm CreateCoreComm()
|
||||
{
|
||||
var cfp = new CoreFileProvider(ShowMessageCoreComm, Global.FirmwareManager);
|
||||
return new CoreComm(ShowMessageCoreComm, NotifyCoreComm, cfp);
|
||||
}
|
||||
|
||||
public MainForm(string[] args)
|
||||
{
|
||||
|
@ -3613,7 +3617,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
//path = ioa_openrom.Path;
|
||||
}
|
||||
|
||||
CoreFileProvider.SyncCoreCommInputSignals(nextComm);
|
||||
var result = loader.LoadRom(path, nextComm, ioaRetro?.CorePath);
|
||||
|
||||
// we need to replace the path in the OpenAdvanced with the canonical one the user chose.
|
||||
|
@ -3639,7 +3642,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
string openAdvancedArgs = $"*{OpenAdvancedSerializer.Serialize(ioa)}";
|
||||
Emulator = loader.LoadedEmulator;
|
||||
Global.Game = loader.Game;
|
||||
CoreFileProvider.SyncCoreCommInputSignals(nextComm);
|
||||
InputManager.SyncControls();
|
||||
|
||||
if (oaOpenrom != null && Path.GetExtension(oaOpenrom.Path.Replace("|", "")).ToLowerInvariant() == ".xml" && !(Emulator is LibsnesCore))
|
||||
|
@ -3898,7 +3900,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
CloseGame(clearSram);
|
||||
var coreComm = CreateCoreComm();
|
||||
CoreFileProvider.SyncCoreCommInputSignals(coreComm);
|
||||
Emulator = new NullEmulator();
|
||||
Global.Game = GameInfo.NullInstance;
|
||||
|
||||
|
|
|
@ -76,8 +76,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
////LibRetroEmulator should be able to survive having this stub corecomm
|
||||
//NEW COMMENTS:
|
||||
//nope, we need to navigate to the dll path. this was a bad idea anyway. so many dlls get loaded, something to resolve them is needed
|
||||
var coreComm = new CoreComm(null, null);
|
||||
CoreFileProvider.SyncCoreCommInputSignals(coreComm);
|
||||
var cfp = new CoreFileProvider(s => { }, Global.FirmwareManager);
|
||||
var coreComm = new CoreComm(null, null, cfp);
|
||||
using var retro = new LibretroCore(coreComm, Global.Game, core);
|
||||
btnLibretroLaunchGame.Enabled = true;
|
||||
if (retro.Description.SupportsNoGame)
|
||||
|
|
|
@ -73,8 +73,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
_ldr = new RomLoader();
|
||||
_ldr.OnLoadError += OnLoadError;
|
||||
_ldr.ChooseArchive = ChooseArchive;
|
||||
_comm = new CoreComm(CommMessage, CommMessage);
|
||||
CoreFileProvider.SyncCoreCommInputSignals(_comm);
|
||||
var cfp = new CoreFileProvider(CommMessage, Global.FirmwareManager);
|
||||
_comm = new CoreComm(CommMessage, CommMessage, cfp);
|
||||
}
|
||||
|
||||
private void OnLoadError(object sender, RomLoader.RomErrorArgs e)
|
||||
|
|
|
@ -9,15 +9,19 @@ namespace BizHawk.Emulation.Common
|
|||
/// </summary>
|
||||
public class CoreComm
|
||||
{
|
||||
public CoreComm(Action<string> showMessage, Action<string> notifyMessage)
|
||||
public CoreComm(
|
||||
Action<string> showMessage,
|
||||
Action<string> notifyMessage,
|
||||
ICoreFileProvider coreFileProvider)
|
||||
{
|
||||
ShowMessage = showMessage;
|
||||
Notify = notifyMessage;
|
||||
CoreFileProvider = coreFileProvider;
|
||||
}
|
||||
|
||||
public CoreComm Clone() => (CoreComm)MemberwiseClone();
|
||||
|
||||
public ICoreFileProvider CoreFileProvider { get; set; }
|
||||
public ICoreFileProvider CoreFileProvider { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a message to show. reasonably annoying (dialog box), shouldn't be used most of the time
|
||||
|
|
Loading…
Reference in New Issue