NESGraphicsConfig - remove some more global usage
This commit is contained in:
parent
bab3dbca98
commit
5848cc5948
|
@ -1597,12 +1597,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (Emulator is NES nes)
|
||||
{
|
||||
using var form = new NESGraphicsConfig(this, nes.GetSettings().Clone());
|
||||
using var form = new NESGraphicsConfig(this, Config, nes.GetSettings().Clone());
|
||||
form.ShowDialog(this);
|
||||
}
|
||||
else if (Emulator is SubNESHawk sub)
|
||||
{
|
||||
using var form = new NESGraphicsConfig(this, sub.GetSettings().Clone());
|
||||
using var form = new NESGraphicsConfig(this, Config, sub.GetSettings().Clone());
|
||||
form.ShowDialog(this);
|
||||
}
|
||||
else if (Emulator is QuickNES quickNes)
|
||||
|
|
|
@ -5,7 +5,6 @@ using System.Windows.Forms;
|
|||
using BizHawk.Common;
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Cores.Nintendo.NES;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SubNESHawk;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -16,14 +15,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
// Hotkeys for BG & Sprite display toggle
|
||||
// NTSC filter settings? Hue, Tint (This should probably be a client thing, not a nes specific thing?)
|
||||
private readonly MainForm _mainForm;
|
||||
private readonly Config _config;
|
||||
private NES.NESSettings _settings;
|
||||
//private Bitmap _bmp;
|
||||
|
||||
public NESGraphicsConfig(
|
||||
MainForm mainForm,
|
||||
Config config,
|
||||
NES.NESSettings settings)
|
||||
{
|
||||
_mainForm = mainForm;
|
||||
_config = config;
|
||||
_settings = settings;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
@ -52,11 +54,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void BrowsePalette_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Palettes"].Path, "NES"),
|
||||
Filter = "Palette Files (.pal)|*.PAL|All Files (*.*)|*.*",
|
||||
RestoreDirectory = true
|
||||
};
|
||||
{
|
||||
InitialDirectory = PathManager.MakeAbsolutePath(_config.PathEntries["NES", "Palettes"].Path, "NES"),
|
||||
Filter = "Palette Files (.pal)|*.PAL|All Files (*.*)|*.*",
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
var result = ofd.ShowDialog();
|
||||
if (result != DialogResult.OK)
|
||||
|
@ -71,7 +73,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SetPaletteImage()
|
||||
{
|
||||
var pal = ResolvePalette(false);
|
||||
var pal = ResolvePalette();
|
||||
|
||||
int w = pictureBoxPalette.Size.Width;
|
||||
int h = pictureBoxPalette.Size.Height;
|
||||
|
@ -83,8 +85,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
for (int i = 0; i < w; i++)
|
||||
{
|
||||
int cx = i * 16 / w;
|
||||
int cindex = (cy * 16) + cx;
|
||||
Color col = Color.FromArgb(0xff, pal[cindex, 0], pal[cindex, 1], pal[cindex, 2]);
|
||||
int cIndex = (cy * 16) + cx;
|
||||
Color col = Color.FromArgb(0xff, pal[cIndex, 0], pal[cIndex, 1], pal[cIndex, 2]);
|
||||
bmp.SetPixel(i, j, col);
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +94,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
pictureBoxPalette.Image = bmp;
|
||||
}
|
||||
|
||||
private byte[,] ResolvePalette(bool showmsg = false)
|
||||
private byte[,] ResolvePalette(bool showMsg = false)
|
||||
{
|
||||
if (AutoLoadPalette.Checked) // checkbox checked: try to load palette from file
|
||||
{
|
||||
|
@ -103,9 +105,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (palette.Exists)
|
||||
{
|
||||
var data = Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name));
|
||||
if (showmsg)
|
||||
if (showMsg)
|
||||
{
|
||||
GlobalWin.OSD.AddMessage($"Palette file loaded: {palette.Name}");
|
||||
_mainForm.AddOnScreenMessage($"Palette file loaded: {palette.Name}");
|
||||
}
|
||||
|
||||
return data;
|
||||
|
@ -115,9 +117,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
// no filename: interpret this as "reset to default"
|
||||
if (showmsg)
|
||||
if (showMsg)
|
||||
{
|
||||
GlobalWin.OSD.AddMessage("Standard Palette set");
|
||||
_mainForm.AddOnScreenMessage("Standard Palette set");
|
||||
}
|
||||
|
||||
return (byte[,])Palettes.QuickNESPalette.Clone();
|
||||
|
|
Loading…
Reference in New Issue