Pass delegates instead of MainForm to BatchRunner
This commit is contained in:
parent
c0aefd438a
commit
e4df38602b
|
@ -1371,7 +1371,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void BatchRunnerMenuItem_Click(object sender, EventArgs e)
|
private void BatchRunnerMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using var form = new BatchRun(this);
|
using var form = new BatchRun(CreateCoreComm);
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,17 +4,21 @@ using System.Windows.Forms;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
|
using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public partial class BatchRun : Form
|
public partial class BatchRun : Form
|
||||||
{
|
{
|
||||||
private Thread _thread;
|
private readonly Func<CoreComm> _createCoreComm;
|
||||||
private List<BatchRunner.Result> _mostRecentResults;
|
|
||||||
private MainForm _mainForm;
|
|
||||||
|
|
||||||
public BatchRun(MainForm mainForm)
|
private List<BatchRunner.Result> _mostRecentResults;
|
||||||
|
|
||||||
|
private Thread _thread;
|
||||||
|
|
||||||
|
public BatchRun(Func<CoreComm> createCoreComm)
|
||||||
{
|
{
|
||||||
this._mainForm = mainForm;
|
_createCoreComm = createCoreComm;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +87,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pp = (Tuple<int, List<string>>)o;
|
var pp = (Tuple<int, List<string>>)o;
|
||||||
BatchRunner br = new BatchRunner(_mainForm, pp.Item2, pp.Item1);
|
BatchRunner br = new BatchRunner(_createCoreComm(), pp.Item2, pp.Item1);
|
||||||
br.OnProgress += br_OnProgress;
|
br.OnProgress += br_OnProgress;
|
||||||
var results = br.Run();
|
var results = br.Run();
|
||||||
this.Invoke(() => { label3.Text = "Status: Finished!"; _mostRecentResults = results; });
|
this.Invoke(() => { label3.Text = "Status: Finished!"; _mostRecentResults = results; });
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BatchRunner(MainForm mainForm, IEnumerable<string> files, int numFrames)
|
public BatchRunner(CoreComm comm, IEnumerable<string> files, int numFrames)
|
||||||
{
|
{
|
||||||
_files = new List<string>(files);
|
_files = new List<string>(files);
|
||||||
_numFrames = numFrames;
|
_numFrames = numFrames;
|
||||||
|
@ -72,7 +72,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_ldr = new RomLoader(GlobalWin.Config, GlobalWin.FirmwareManager);
|
_ldr = new RomLoader(GlobalWin.Config, GlobalWin.FirmwareManager);
|
||||||
_ldr.OnLoadError += OnLoadError;
|
_ldr.OnLoadError += OnLoadError;
|
||||||
_ldr.ChooseArchive = ChooseArchive;
|
_ldr.ChooseArchive = ChooseArchive;
|
||||||
_comm = mainForm.CreateCoreComm();
|
_comm = comm;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLoadError(object sender, RomLoader.RomErrorArgs e)
|
private void OnLoadError(object sender, RomLoader.RomErrorArgs e)
|
||||||
|
|
Loading…
Reference in New Issue