PSX config dialogs - pass in dependencies

This commit is contained in:
adelikat 2019-12-16 17:21:49 -06:00
parent bdc8be2f6b
commit ea8ed79402
5 changed files with 50 additions and 31 deletions

View File

@ -29,6 +29,7 @@ using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; using BizHawk.Emulation.Cores.Computers.SinclairSpectrum;
using BizHawk.Emulation.Cores.Computers.AmstradCPC; using BizHawk.Emulation.Cores.Computers.AmstradCPC;
using BizHawk.Emulation.Cores.Intellivision; using BizHawk.Emulation.Cores.Intellivision;
using BizHawk.Emulation.Cores.Sony.PSX;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -2161,16 +2162,22 @@ namespace BizHawk.Client.EmuHawk
private void PSXControllerSettingsMenuItem_Click(object sender, EventArgs e) private void PSXControllerSettingsMenuItem_Click(object sender, EventArgs e)
{ {
using var form = new PSXControllerConfigNew(); if (Emulator is Octoshock psx)
form.ShowDialog(); {
using var form = new PSXControllerConfig(this, psx.GetSyncSettings().Clone());
form.ShowDialog();
}
} }
private void PSXOptionsMenuItem_Click(object sender, EventArgs e) private void PSXOptionsMenuItem_Click(object sender, EventArgs e)
{ {
var result = PSXOptions.DoSettingsDialog(this); if (Emulator is Octoshock psx)
if (result == DialogResult.OK)
{ {
FrameBufferResized(); var result = PSXOptions.DoSettingsDialog(this, psx);
if (result == DialogResult.OK)
{
FrameBufferResized();
}
} }
} }

View File

@ -1,6 +1,6 @@
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
partial class PSXControllerConfigNew partial class PSXControllerConfig
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -430,7 +430,7 @@
this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize; this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "PSXControllerConfigNew"; this.Name = "PSXControllerConfig";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Controller / Memcard Configuration"; this.Text = "Controller / Memcard Configuration";
this.Load += new System.EventHandler(this.PSXControllerConfigNew_Load); this.Load += new System.EventHandler(this.PSXControllerConfigNew_Load);

View File

@ -6,10 +6,17 @@ using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class PSXControllerConfigNew : Form public partial class PSXControllerConfig : Form
{ {
public PSXControllerConfigNew() private readonly MainForm _mainForm;
private readonly Octoshock.SyncSettings _syncSettings;
public PSXControllerConfig(
MainForm mainForm,
Octoshock.SyncSettings syncSettings)
{ {
_mainForm = mainForm;
_syncSettings = syncSettings;
InitializeComponent(); InitializeComponent();
} }
@ -26,9 +33,7 @@ namespace BizHawk.Client.EmuHawk
combo.SelectedIndex = 0; combo.SelectedIndex = 0;
} }
var psxSettings = ((Octoshock)Global.Emulator).GetSyncSettings(); GuiFromUserConfig(_syncSettings.FIOConfig);
GuiFromUserConfig(psxSettings.FIOConfig);
RefreshLabels(); RefreshLabels();
} }
@ -131,13 +136,10 @@ namespace BizHawk.Client.EmuHawk
private void BtnOk_Click(object sender, EventArgs e) private void BtnOk_Click(object sender, EventArgs e)
{ {
var psxSettings = ((Octoshock)Global.Emulator).GetSyncSettings(); _syncSettings.FIOConfig = UserConfigFromGui();
_mainForm.PutCoreSyncSettings(_syncSettings);
psxSettings.FIOConfig = UserConfigFromGui();
GlobalWin.MainForm.PutCoreSyncSettings(psxSettings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
} }

View File

@ -10,11 +10,17 @@ namespace BizHawk.Client.EmuHawk
public partial class PSXOptions : Form public partial class PSXOptions : Form
{ {
// backups of the labels for string replacing // backups of the labels for string replacing
private readonly string lblPixelPro_text, lblMednafen_text, lblTweakedMednafen_text; private readonly string _lblPixelProText, _lblMednafenText, _lblTweakedMednafenText;
private PSXOptions(Octoshock.Settings settings, Octoshock.SyncSettings syncSettings, OctoshockDll.eVidStandard vidStandard, Size currentVideoSize) private PSXOptions(
MainForm mainForm,
Octoshock.Settings settings,
Octoshock.SyncSettings syncSettings,
OctoshockDll.eVidStandard vidStandard,
Size currentVideoSize)
{ {
InitializeComponent(); InitializeComponent();
_mainForm = mainForm;
_settings = settings; _settings = settings;
_syncSettings = syncSettings; _syncSettings = syncSettings;
_previewVideoStandard = vidStandard; _previewVideoStandard = vidStandard;
@ -29,9 +35,9 @@ namespace BizHawk.Client.EmuHawk
lblPAL.Font = new Font(lblPAL.Font, FontStyle.Bold); lblPAL.Font = new Font(lblPAL.Font, FontStyle.Bold);
} }
lblPixelPro_text = lblPixelPro.Text; _lblPixelProText = lblPixelPro.Text;
lblMednafen_text = lblMednafen.Text; _lblMednafenText = lblMednafen.Text;
lblTweakedMednafen_text = lblTweakedMednafen.Text; _lblTweakedMednafenText = lblTweakedMednafen.Text;
rbPixelPro.Checked = _settings.ResolutionMode == Octoshock.eResolutionMode.PixelPro; rbPixelPro.Checked = _settings.ResolutionMode == Octoshock.eResolutionMode.PixelPro;
rbDebugMode.Checked = _settings.ResolutionMode == Octoshock.eResolutionMode.Debug; rbDebugMode.Checked = _settings.ResolutionMode == Octoshock.eResolutionMode.Debug;
@ -55,6 +61,7 @@ namespace BizHawk.Client.EmuHawk
} }
private Size _previewVideoSize; private Size _previewVideoSize;
private readonly MainForm _mainForm;
private readonly OctoshockDll.eVidStandard _previewVideoStandard; private readonly OctoshockDll.eVidStandard _previewVideoStandard;
private readonly Octoshock.Settings _settings; private readonly Octoshock.Settings _settings;
private readonly Octoshock.SyncSettings _syncSettings; private readonly Octoshock.SyncSettings _syncSettings;
@ -66,16 +73,15 @@ namespace BizHawk.Client.EmuHawk
MessageBox.Show("Finetuned Display Options will take effect if you OK from PSX Options"); MessageBox.Show("Finetuned Display Options will take effect if you OK from PSX Options");
} }
public static DialogResult DoSettingsDialog(IWin32Window owner) public static DialogResult DoSettingsDialog(MainForm mainForm, Octoshock psx)
{ {
var psx = (Octoshock)Global.Emulator;
var s = psx.GetSettings(); var s = psx.GetSettings();
var ss = psx.GetSyncSettings(); var ss = psx.GetSyncSettings();
var vid = psx.SystemVidStandard; var vid = psx.SystemVidStandard;
var size = psx.CurrentVideoSize; var size = psx.CurrentVideoSize;
using var dlg = new PSXOptions(s, ss, vid, size); using var dlg = new PSXOptions(mainForm, s, ss, vid, size);
var result = dlg.ShowDialog(owner); var result = dlg.ShowDialog(mainForm);
return result; return result;
} }
@ -116,8 +122,8 @@ namespace BizHawk.Client.EmuHawk
SyncSettingsFromGui(_settings, _syncSettings); SyncSettingsFromGui(_settings, _syncSettings);
_settings.Validate(); _settings.Validate();
GlobalWin.MainForm.PutCoreSettings(_settings); _mainForm.PutCoreSettings(_settings);
GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); _mainForm.PutCoreSyncSettings(_syncSettings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
@ -145,15 +151,15 @@ namespace BizHawk.Client.EmuHawk
temp.ResolutionMode = Octoshock.eResolutionMode.PixelPro; temp.ResolutionMode = Octoshock.eResolutionMode.PixelPro;
var ri = Octoshock.CalculateResolution(_previewVideoStandard, temp, w, h); var ri = Octoshock.CalculateResolution(_previewVideoStandard, temp, w, h);
lblPixelPro.Text = lblPixelPro_text.Replace("800x480", $"{ri.Resolution.Width}x{ri.Resolution.Height}"); lblPixelPro.Text = _lblPixelProText.Replace("800x480", $"{ri.Resolution.Width}x{ri.Resolution.Height}");
temp.ResolutionMode = Octoshock.eResolutionMode.Mednafen; temp.ResolutionMode = Octoshock.eResolutionMode.Mednafen;
ri = Octoshock.CalculateResolution(_previewVideoStandard, temp, w, h); ri = Octoshock.CalculateResolution(_previewVideoStandard, temp, w, h);
lblMednafen.Text = lblMednafen_text.Replace("320x240", $"{ri.Resolution.Width}x{ri.Resolution.Height}"); lblMednafen.Text = _lblMednafenText.Replace("320x240", $"{ri.Resolution.Width}x{ri.Resolution.Height}");
temp.ResolutionMode = Octoshock.eResolutionMode.TweakedMednafen; temp.ResolutionMode = Octoshock.eResolutionMode.TweakedMednafen;
ri = Octoshock.CalculateResolution(_previewVideoStandard, temp, w, h); ri = Octoshock.CalculateResolution(_previewVideoStandard, temp, w, h);
lblTweakedMednafen.Text = lblTweakedMednafen_text.Replace("400x300", $"{ri.Resolution.Width}x{ri.Resolution.Height}"); lblTweakedMednafen.Text = _lblTweakedMednafenText.Replace("400x300", $"{ri.Resolution.Width}x{ri.Resolution.Height}");
} }
private void DrawingArea_ValueChanged(object sender, EventArgs e) private void DrawingArea_ValueChanged(object sender, EventArgs e)

View File

@ -191,6 +191,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autosave/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Autosave/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=backcolor/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=backcolor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bezier/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Bezier/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=bilinear/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bizware/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Bizware/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=blitter/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=blitter/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bools/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Bools/@EntryIndexedValue">True</s:Boolean>
@ -216,6 +217,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Disasm/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Disasm/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Disassemblable/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Disassemblable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=disassembly/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=disassembly/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=disp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dontfire/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Dontfire/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ejin/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Ejin/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Endian/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Endian/@EntryIndexedValue">True</s:Boolean>
@ -226,6 +228,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=FCEU/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=FCEU/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ffmpeg/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=ffmpeg/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=filenames/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=filenames/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Finetuned/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=fname/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=fname/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=frameadvance/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=frameadvance/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FCEUX/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=FCEUX/@EntryIndexedValue">True</s:Boolean>
@ -265,6 +268,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=mainmemory/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=mainmemory/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mame/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=mame/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mednafen/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Mednafen/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mednafen_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=MOTW/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=MOTW/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Multidisk/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Multidisk/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=multilines/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=multilines/@EntryIndexedValue">True</s:Boolean>