Pass delegates instead of MainForm to OpenAdvancedChooser
This commit is contained in:
parent
4f4a875382
commit
c0aefd438a
|
@ -317,7 +317,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void OpenAdvancedMenuItem_Click(object sender, EventArgs e)
|
private void OpenAdvancedMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using var oac = new OpenAdvancedChooser(this, Config, Game);
|
using var oac = new OpenAdvancedChooser(Config, CreateCoreComm, Game, RunLibretroCoreChooser);
|
||||||
if (oac.ShowHawkDialog() == DialogResult.Cancel)
|
if (oac.ShowHawkDialog() == DialogResult.Cancel)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -23,19 +23,26 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public partial class OpenAdvancedChooser : Form
|
public partial class OpenAdvancedChooser : Form
|
||||||
{
|
{
|
||||||
private readonly MainForm _mainForm;
|
|
||||||
private readonly Config _config;
|
private readonly Config _config;
|
||||||
private readonly IGameInfo _game;
|
|
||||||
|
|
||||||
public AdvancedRomLoaderType Result;
|
private readonly Func<CoreComm> _createCoreComm;
|
||||||
public string SuggestedExtensionFilter;
|
|
||||||
private RetroDescription _currentDescription;
|
private RetroDescription _currentDescription;
|
||||||
|
|
||||||
public OpenAdvancedChooser(MainForm mainForm, Config config, IGameInfo game)
|
private readonly IGameInfo _game;
|
||||||
|
|
||||||
|
private readonly Func<bool> _libretroCoreChooserCallback;
|
||||||
|
|
||||||
|
public AdvancedRomLoaderType Result;
|
||||||
|
|
||||||
|
public string SuggestedExtensionFilter;
|
||||||
|
|
||||||
|
public OpenAdvancedChooser(Config config, Func<CoreComm> createCoreComm, IGameInfo game, Func<bool> libretroCoreChooserCallback)
|
||||||
{
|
{
|
||||||
_mainForm = mainForm;
|
|
||||||
_config = config;
|
_config = config;
|
||||||
|
_createCoreComm = createCoreComm;
|
||||||
_game = game;
|
_game = game;
|
||||||
|
_libretroCoreChooserCallback = libretroCoreChooserCallback;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
@ -50,8 +57,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void btnSetLibretroCore_Click(object sender, EventArgs e)
|
private void btnSetLibretroCore_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if(_mainForm.RunLibretroCoreChooser())
|
if (_libretroCoreChooserCallback()) RefreshLibretroCore(false);
|
||||||
RefreshLibretroCore(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshLibretroCore(bool bootstrap)
|
private void RefreshLibretroCore(bool bootstrap)
|
||||||
|
@ -72,7 +78,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// scan the current libretro core to see if it can be launched with NoGame,and other stuff
|
// scan the current libretro core to see if it can be launched with NoGame,and other stuff
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var coreComm = _mainForm.CreateCoreComm();
|
var coreComm = _createCoreComm();
|
||||||
using var retro = new LibretroCore(coreComm, _game, core);
|
using var retro = new LibretroCore(coreComm, _game, core);
|
||||||
btnLibretroLaunchGame.Enabled = true;
|
btnLibretroLaunchGame.Enabled = true;
|
||||||
if (retro.Description.SupportsNoGame)
|
if (retro.Description.SupportsNoGame)
|
||||||
|
|
Loading…
Reference in New Issue