NES graphics config - pass in dependencies
This commit is contained in:
parent
827825bbf3
commit
16be999cbc
|
@ -1575,14 +1575,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void NESGraphicSettingsMenuItem_Click(object sender, EventArgs e)
|
private void NESGraphicSettingsMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (Emulator is NES)
|
if (Emulator is NES nes)
|
||||||
{
|
{
|
||||||
using var form = new NESGraphicsConfig();
|
using var form = new NESGraphicsConfig(this, nes.GetSettings());
|
||||||
form.ShowDialog(this);
|
form.ShowDialog(this);
|
||||||
}
|
}
|
||||||
else if (Emulator is SubNESHawk)
|
else if (Emulator is SubNESHawk sub)
|
||||||
{
|
{
|
||||||
using var form = new NESGraphicsConfig();
|
using var form = new NESGraphicsConfig(this, sub.GetSettings());
|
||||||
form.ShowDialog(this);
|
form.ShowDialog(this);
|
||||||
}
|
}
|
||||||
else if (Emulator is QuickNES)
|
else if (Emulator is QuickNES)
|
||||||
|
@ -1671,11 +1671,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void MovieSettingsMenuItem_Click(object sender, EventArgs e)
|
private void MovieSettingsMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using (var dlg = new NESSyncSettingsForm())
|
using var dlg = new NESSyncSettingsForm();
|
||||||
{
|
|
||||||
dlg.ShowDialog(this);
|
dlg.ShowDialog(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void BarcodeReaderMenuItem_Click(object sender, EventArgs e)
|
private void BarcodeReaderMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,29 +15,21 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// Allow selection of palette file from archive
|
// Allow selection of palette file from archive
|
||||||
// Hotkeys for BG & Sprite display toggle
|
// Hotkeys for BG & Sprite display toggle
|
||||||
// NTSC filter settings? Hue, Tint (This should probably be a client thing, not a nes specific thing?)
|
// NTSC filter settings? Hue, Tint (This should probably be a client thing, not a nes specific thing?)
|
||||||
private NES _nes;
|
private readonly MainForm _mainForm;
|
||||||
private SubNESHawk _subneshawk;
|
|
||||||
private NES.NESSettings _settings;
|
private NES.NESSettings _settings;
|
||||||
private Bitmap _bmp;
|
//private Bitmap _bmp;
|
||||||
|
|
||||||
public NESGraphicsConfig()
|
public NESGraphicsConfig(
|
||||||
|
MainForm mainForm,
|
||||||
|
NES.NESSettings settings)
|
||||||
{
|
{
|
||||||
|
_mainForm = mainForm;
|
||||||
|
_settings = settings;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NESGraphicsConfig_Load(object sender, EventArgs e)
|
private void NESGraphicsConfig_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (Global.Emulator is NES)
|
|
||||||
{
|
|
||||||
_nes = (NES)Global.Emulator;
|
|
||||||
_settings = _nes.GetSettings();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_subneshawk = (SubNESHawk)Global.Emulator;
|
|
||||||
_settings = _subneshawk.GetSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadStuff();
|
LoadStuff();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +76,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
int w = pictureBoxPalette.Size.Width;
|
int w = pictureBoxPalette.Size.Width;
|
||||||
int h = pictureBoxPalette.Size.Height;
|
int h = pictureBoxPalette.Size.Height;
|
||||||
|
|
||||||
_bmp = new Bitmap(w, h);
|
var bmp = new Bitmap(w, h);
|
||||||
for (int j = 0; j < h; j++)
|
for (int j = 0; j < h; j++)
|
||||||
{
|
{
|
||||||
int cy = j * 4 / h;
|
int cy = j * 4 / h;
|
||||||
|
@ -93,11 +85,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
int cx = i * 16 / w;
|
int cx = i * 16 / w;
|
||||||
int cindex = (cy * 16) + cx;
|
int cindex = (cy * 16) + cx;
|
||||||
Color col = Color.FromArgb(0xff, pal[cindex, 0], pal[cindex, 1], pal[cindex, 2]);
|
Color col = Color.FromArgb(0xff, pal[cindex, 0], pal[cindex, 1], pal[cindex, 2]);
|
||||||
_bmp.SetPixel(i, j, col);
|
bmp.SetPixel(i, j, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pictureBoxPalette.Image = _bmp;
|
pictureBoxPalette.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[,] ResolvePalette(bool showmsg = false)
|
private byte[,] ResolvePalette(bool showmsg = false)
|
||||||
|
@ -118,26 +110,23 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return _settings.Palette;
|
return _settings.Palette;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else // no filename: interpret this as "reset to default"
|
// no filename: interpret this as "reset to default"
|
||||||
{
|
|
||||||
if (showmsg)
|
if (showmsg)
|
||||||
{
|
{
|
||||||
GlobalWin.OSD.AddMessage("Standard Palette set");
|
GlobalWin.OSD.AddMessage("Standard Palette set");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (byte[,])Palettes.QuickNESPalette.Clone();
|
return (byte[,])Palettes.QuickNESPalette.Clone();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else // checkbox unchecked: we're reusing whatever palette was set
|
// checkbox unchecked: we're reusing whatever palette was set
|
||||||
{
|
|
||||||
return _settings.Palette;
|
return _settings.Palette;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void Ok_Click(object sender, EventArgs e)
|
private void Ok_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -157,15 +146,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_settings.BackgroundColor &= 0x00FFFFFF;
|
_settings.BackgroundColor &= 0x00FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Global.Emulator is NES)
|
_mainForm.PutCoreSettings(_settings);
|
||||||
{
|
|
||||||
_nes.PutSettings(_settings);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_subneshawk.PutSettings(_settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue