N64 plugin config - pass dependencies in

This commit is contained in:
adelikat 2019-12-15 16:27:48 -06:00
parent 5ec3ac021e
commit 827825bbf3
2 changed files with 22 additions and 28 deletions

View File

@ -2272,7 +2272,23 @@ namespace BizHawk.Client.EmuHawk
private void N64PluginSettingsMenuItem_Click(object sender, EventArgs e)
{
using var form = new N64VideoPluginconfig();
// because mupen is a pile of garbage, this all needs to work even when N64 is not loaded
N64Settings settings;
N64SyncSettings syncSettings;
if (Global.Emulator is N64 n64)
{
settings = n64.GetSettings();
syncSettings = n64.GetSyncSettings();
}
else
{
settings = (N64Settings)Global.Config.GetCoreSettings<N64>()
?? new N64Settings();
syncSettings = (N64SyncSettings)Global.Config.GetCoreSyncSettings<N64>()
?? new N64SyncSettings();
}
using var form = new N64VideoPluginConfig(settings, syncSettings);
if (form.ShowDialog() == DialogResult.OK)
{
if (Emulator.IsNull())

View File

@ -36,34 +36,15 @@ namespace BizHawk.Client.EmuHawk
private bool _programmaticallyChangingPluginComboBox = false;
public N64VideoPluginConfig()
public N64VideoPluginConfig(
N64Settings settings,
N64SyncSettings syncSettings)
{
_s = settings;
_ss = syncSettings;
InitializeComponent();
}
// because mupen is a pile of garbage, this all needs to work even when N64 is not loaded
private static N64SyncSettings GetSyncSettings()
{
if (Global.Emulator is N64)
{
return ((N64)Global.Emulator).GetSyncSettings();
}
return (N64SyncSettings)Global.Config.GetCoreSyncSettings<N64>()
?? new N64SyncSettings();
}
private static N64Settings GetSettings()
{
if (Global.Emulator is N64)
{
return ((N64)Global.Emulator).GetSettings();
}
return (N64Settings)Global.Config.GetCoreSettings<N64>()
?? new N64Settings();
}
private static void PutSyncSettings(N64SyncSettings s)
{
if (Global.Emulator is N64)
@ -508,9 +489,6 @@ namespace BizHawk.Client.EmuHawk
private void N64VideoPluginConfig_Load(object sender, EventArgs e)
{
_s = GetSettings();
_ss = GetSyncSettings();
CoreTypeDropdown.PopulateFromEnum<N64SyncSettings.CoreType>(_ss.Core);
RspTypeDropdown.PopulateFromEnum<N64SyncSettings.RspType>(_ss.Rsp);