Merge branch 'master' into waterbox2

This commit is contained in:
adelikat 2017-05-31 13:38:01 -05:00
commit 95353188c7
86 changed files with 1777 additions and 1767 deletions

View File

@ -274,6 +274,9 @@ sha1:CAAC1E829133851648BA7C7CD6EAA7D26A464999 Metal Fighter (Asia) (Unl) (Sache
sha1:B9902886D1739983B315B67B02133E44620E4381 Challenge of the Dragon (Asia) (PAL) (Unl) NES board=MAPPER147;PAD_V=0;PAD_H=1;system=NES-PAL sha1:B9902886D1739983B315B67B02133E44620E4381 Challenge of the Dragon (Asia) (PAL) (Unl) NES board=MAPPER147;PAD_V=0;PAD_H=1;system=NES-PAL
sha1:0CDE48DB89896946F0C2E78936EA290348994ED5 Pipemania (Australia) (HES) (Unl) NES board=MAPPER113;PRG=32;CHR=16;WRAM=0;VRAM=0 sha1:0CDE48DB89896946F0C2E78936EA290348994ED5 Pipemania (Australia) (HES) (Unl) NES board=MAPPER113;PRG=32;CHR=16;WRAM=0;VRAM=0
sha1:E843AB3D779D4F0BB1F933D6EE99DAA526EFBCF1 Gaiapolis (Asia) (Unl) NES board=UNIF_NES-TLROM;PRG=128;CHR=256;WRAM=0;VRAM=0 sha1:E843AB3D779D4F0BB1F933D6EE99DAA526EFBCF1 Gaiapolis (Asia) (Unl) NES board=UNIF_NES-TLROM;PRG=128;CHR=256;WRAM=0;VRAM=0
sha1:68ABE1E49C9E9CCEA978A48232432C252E5912C0 Dancing Blocks (Asia) (PAL) (Unl) NES board=MAPPER143;PAD_V=1;PAD_H=0;system=NES-PAL
sha1:B21CFE30197727C1C8E8DB6D28AD696A708F8FF5 Pyramid II (Asia) (PAL) (Unl) NES board=MAPPER146
sha1:7117413766ABC02F3BB767C2CE96065B6F3CBA85 Silent Assault (Asia) (PAL) (Unl) NES board=MAPPER146;PAD_V=0;PAD_H=1;system=NES-PAL
;;;;;;;;;;;;;;;;;;;----------------------------------------------------------------------- ;;;;;;;;;;;;;;;;;;;-----------------------------------------------------------------------
;;;;;;;;;;;;;;;;;;;----------------------------------------------------------------------- ;;;;;;;;;;;;;;;;;;;-----------------------------------------------------------------------

View File

@ -1324,7 +1324,7 @@ namespace BizHawk.Client.EmuHawk
{ {
Global.Config = ConfigService.Load<Config>(PathManager.DefaultIniPath); Global.Config = ConfigService.Load<Config>(PathManager.DefaultIniPath);
Global.Config.ResolveDefaults(); Global.Config.ResolveDefaults();
InitControls(); //rebind hotkeys InitControls(); // rebind hotkeys
GlobalWin.OSD.AddMessage("Config file loaded: " + PathManager.DefaultIniPath); GlobalWin.OSD.AddMessage("Config file loaded: " + PathManager.DefaultIniPath);
} }
@ -1343,7 +1343,7 @@ namespace BizHawk.Client.EmuHawk
{ {
Global.Config = ConfigService.Load<Config>(ofd.FileName); Global.Config = ConfigService.Load<Config>(ofd.FileName);
Global.Config.ResolveDefaults(); Global.Config.ResolveDefaults();
InitControls(); //rebind hotkeys InitControls(); // rebind hotkeys
GlobalWin.OSD.AddMessage("Config file loaded: " + ofd.FileName); GlobalWin.OSD.AddMessage("Config file loaded: " + ofd.FileName);
} }
} }
@ -1610,7 +1610,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Emulator is NES && ((NES)Emulator).IsVS) if (Emulator is NES && ((NES)Emulator).IsVS)
{ {
new NESVSSettings().ShowHawkDialog(); new NesVsSettings().ShowHawkDialog();
} }
} }
@ -1988,7 +1988,7 @@ namespace BizHawk.Client.EmuHawk
private void GBCoreSettingsMenuItem_Click(object sender, EventArgs e) private void GBCoreSettingsMenuItem_Click(object sender, EventArgs e)
{ {
config.GB.GBPrefs.DoGBPrefsDialog(this); GBPrefs.DoGBPrefsDialog(this);
} }
private void LoadGbInSgbMenuItem_Click(object sender, EventArgs e) private void LoadGbInSgbMenuItem_Click(object sender, EventArgs e)
@ -2294,7 +2294,7 @@ namespace BizHawk.Client.EmuHawk
private void DgbSettingsMenuItem_Click(object sender, EventArgs e) private void DgbSettingsMenuItem_Click(object sender, EventArgs e)
{ {
config.GB.DGBPrefs.DoDGBPrefsDialog(this); DGBPrefs.DoDGBPrefsDialog(this);
} }
#endregion #endregion
@ -2602,7 +2602,7 @@ namespace BizHawk.Client.EmuHawk
private void DisplayConfigMenuItem_Click(object sender, EventArgs e) private void DisplayConfigMenuItem_Click(object sender, EventArgs e)
{ {
var window = new config.DisplayConfigLite(); var window = new DisplayConfigLite();
var result = window.ShowDialog(); var result = window.ShowDialog();
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {

View File

@ -1,10 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
@ -51,7 +46,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public bool Radial public bool Radial
{ {
get get
@ -67,15 +61,9 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private int ScaledX private int ScaledX => MaxX / ScaleFactor;
{
get { return MaxX / ScaleFactor; }
}
private int ScaledY private int ScaledY => MaxY / ScaleFactor;
{
get { return MaxY / ScaleFactor; }
}
private Point TopLeft private Point TopLeft
{ {
@ -187,10 +175,7 @@ namespace BizHawk.Client.EmuHawk
private void Changed() private void Changed()
{ {
if (ChangeCallback != null) ChangeCallback?.Invoke();
{
ChangeCallback();
}
} }
} }
} }

View File

@ -1,17 +1,11 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class AnalogRangeConfigControl : UserControl public partial class AnalogRangeConfigControl : UserControl
{ {
private bool _supressChange = false; private bool _supressChange;
public AnalogRangeConfigControl() public AnalogRangeConfigControl()
{ {

View File

@ -74,8 +74,7 @@ namespace BizHawk.Client.EmuHawk
private Control CreateNormalPanel(Dictionary<string, string> settings, List<string> buttons, Size size) private Control CreateNormalPanel(Dictionary<string, string> settings, List<string> buttons, Size size)
{ {
var cp = new ControllerConfigPanel { Dock = DockStyle.Fill, AutoScroll = true }; var cp = new ControllerConfigPanel { Dock = DockStyle.Fill, AutoScroll = true, Tooltip = toolTip1 };
cp.Tooltip = toolTip1;
cp.LoadSettings(settings, checkBoxAutoTab.Checked, buttons, size.Width, size.Height); cp.LoadSettings(settings, checkBoxAutoTab.Checked, buttons, size.Width, size.Height);
return cp; return cp;
} }

View File

@ -71,7 +71,7 @@
this.trackBarSensitivity.SmallChange = 10; this.trackBarSensitivity.SmallChange = 10;
this.trackBarSensitivity.TabIndex = 2; this.trackBarSensitivity.TabIndex = 2;
this.trackBarSensitivity.TickFrequency = 10; this.trackBarSensitivity.TickFrequency = 10;
this.trackBarSensitivity.ValueChanged += new System.EventHandler(this.trackBarSensitivity_ValueChanged); this.trackBarSensitivity.ValueChanged += new System.EventHandler(this.TrackBarSensitivity_ValueChanged);
// //
// labelSensitivity // labelSensitivity
// //
@ -84,7 +84,7 @@
// //
// timer1 // timer1
// //
this.timer1.Tick += new System.EventHandler(this.timer1_Tick); this.timer1.Tick += new System.EventHandler(this.Timer1_Tick);
// //
// buttonBind // buttonBind
// //
@ -94,7 +94,7 @@
this.buttonBind.TabIndex = 4; this.buttonBind.TabIndex = 4;
this.buttonBind.Text = "Bind!"; this.buttonBind.Text = "Bind!";
this.buttonBind.UseVisualStyleBackColor = true; this.buttonBind.UseVisualStyleBackColor = true;
this.buttonBind.Click += new System.EventHandler(this.buttonBind_Click); this.buttonBind.Click += new System.EventHandler(this.ButtonBind_Click);
// //
// trackBarDeadzone // trackBarDeadzone
// //
@ -103,7 +103,7 @@
this.trackBarDeadzone.Size = new System.Drawing.Size(104, 45); this.trackBarDeadzone.Size = new System.Drawing.Size(104, 45);
this.trackBarDeadzone.TabIndex = 5; this.trackBarDeadzone.TabIndex = 5;
this.trackBarDeadzone.TickFrequency = 2; this.trackBarDeadzone.TickFrequency = 2;
this.trackBarDeadzone.ValueChanged += new System.EventHandler(this.trackBarDeadzone_ValueChanged); this.trackBarDeadzone.ValueChanged += new System.EventHandler(this.TrackBarDeadzone_ValueChanged);
// //
// labelDeadzone // labelDeadzone
// //
@ -122,7 +122,7 @@
this.buttonFlip.TabIndex = 7; this.buttonFlip.TabIndex = 7;
this.buttonFlip.Text = "Flip Axis"; this.buttonFlip.Text = "Flip Axis";
this.buttonFlip.UseVisualStyleBackColor = true; this.buttonFlip.UseVisualStyleBackColor = true;
this.buttonFlip.Click += new System.EventHandler(this.buttonFlip_Click); this.buttonFlip.Click += new System.EventHandler(this.ButtonFlip_Click);
// //
// buttonUnbind // buttonUnbind
// //

View File

@ -1,10 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -18,75 +12,77 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent(); InitializeComponent();
} }
public string ButtonName; public AnalogBindControl(string buttonName, Config.AnalogBind bind)
public Config.AnalogBind Bind;
bool listening = false;
public AnalogBindControl(string ButtonName, Config.AnalogBind Bind)
: this() : this()
{ {
this.Bind = Bind; _bind = bind;
this.ButtonName = ButtonName; ButtonName = buttonName;
labelButtonName.Text = ButtonName; labelButtonName.Text = buttonName;
trackBarSensitivity.Value = (int)(Bind.Mult * 10.0f); trackBarSensitivity.Value = (int)(bind.Mult * 10.0f);
trackBarDeadzone.Value = (int)(Bind.Deadzone * 20.0f); trackBarDeadzone.Value = (int)(bind.Deadzone * 20.0f);
trackBarSensitivity_ValueChanged(null, null); TrackBarSensitivity_ValueChanged(null, null);
trackBarDeadzone_ValueChanged(null, null); TrackBarDeadzone_ValueChanged(null, null);
textBox1.Text = Bind.Value; textBox1.Text = bind.Value;
} }
private void timer1_Tick(object sender, EventArgs e) public string ButtonName { get; private set; }
public Config.AnalogBind Bind => _bind;
private Config.AnalogBind _bind;
private bool _listening;
private void Timer1_Tick(object sender, EventArgs e)
{ {
string bindval = Input.Instance.GetNextFloatEvent(); string bindval = Input.Instance.GetNextFloatEvent();
if (bindval != null) if (bindval != null)
{ {
timer1.Stop(); timer1.Stop();
listening = false; _listening = false;
Bind.Value = bindval; _bind.Value = bindval;
textBox1.Text = Bind.Value; textBox1.Text = Bind.Value;
buttonBind.Text = "Bind!"; buttonBind.Text = "Bind!";
Input.Instance.StopListeningForFloatEvents(); Input.Instance.StopListeningForFloatEvents();
} }
} }
private void buttonBind_Click(object sender, EventArgs e) private void ButtonBind_Click(object sender, EventArgs e)
{ {
if (listening) if (_listening)
{ {
timer1.Stop(); timer1.Stop();
listening = false; _listening = false;
buttonBind.Text = "Bind!"; buttonBind.Text = "Bind!";
Input.Instance.StopListeningForFloatEvents(); Input.Instance.StopListeningForFloatEvents();
} }
else else
{ {
Input.Instance.StartListeningForFloatEvents(); Input.Instance.StartListeningForFloatEvents();
listening = true; _listening = true;
buttonBind.Text = "Cancel!"; buttonBind.Text = "Cancel!";
timer1.Start(); timer1.Start();
} }
} }
private void trackBarSensitivity_ValueChanged(object sender, EventArgs e) private void TrackBarSensitivity_ValueChanged(object sender, EventArgs e)
{ {
Bind.Mult = trackBarSensitivity.Value / 10.0f; _bind.Mult = trackBarSensitivity.Value / 10.0f;
labelSensitivity.Text = String.Format("Sensitivity: {0}", (Bind.Mult*100)) + "%"; labelSensitivity.Text = $"Sensitivity: {(Bind.Mult * 100)}" + "%";
} }
private void trackBarDeadzone_ValueChanged(object sender, EventArgs e) private void TrackBarDeadzone_ValueChanged(object sender, EventArgs e)
{ {
Bind.Deadzone = trackBarDeadzone.Value / 20.0f; _bind.Deadzone = trackBarDeadzone.Value / 20.0f;
labelDeadzone.Text = String.Format("Deadzone: {0}", (Bind.Deadzone*100)) + "%"; labelDeadzone.Text = $"Deadzone: {(Bind.Deadzone * 100)}" + "%";
} }
private void buttonFlip_Click(object sender, EventArgs e) private void ButtonFlip_Click(object sender, EventArgs e)
{ {
trackBarSensitivity.Value *= -1; trackBarSensitivity.Value *= -1;
} }
public void Unbind_Click(object sender, EventArgs e) public void Unbind_Click(object sender, EventArgs e)
{ {
Bind.Value = ""; _bind.Value = "";
textBox1.Text = ""; textBox1.Text = "";
} }
} }

View File

@ -1,7 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing; using System.Drawing;
@ -9,40 +6,42 @@ using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
class AnalogBindPanel : UserControl public class AnalogBindPanel : UserControl
{ {
Dictionary<string, Config.AnalogBind> RealConfigObject; private readonly Dictionary<string, Config.AnalogBind> _realConfigObject;
public AnalogBindPanel(Dictionary<string, Config.AnalogBind> RealConfigObject, List<string> RealConfigButtons = null) public AnalogBindPanel(Dictionary<string, Config.AnalogBind> realConfigObject, List<string> realConfigButtons = null)
:base()
{ {
this.RealConfigObject = RealConfigObject; _realConfigObject = realConfigObject;
LoadSettings(realConfigButtons ?? (IEnumerable<string>)realConfigObject.Keys);
LoadSettings(RealConfigButtons ?? (IEnumerable<string>)RealConfigObject.Keys);
} }
void LoadSettings(IEnumerable<string> ButtonList) private void LoadSettings(IEnumerable<string> buttonList)
{ {
SuspendLayout(); SuspendLayout();
int x = 4; int x = 4;
int y = 4; int y = 4;
foreach (string ButtonName in ButtonList) foreach (string buttonName in buttonList)
{ {
var ctrl = new AnalogBindControl(ButtonName, RealConfigObject[ButtonName]); var ctrl = new AnalogBindControl(buttonName, _realConfigObject[buttonName])
ctrl.Location = new Point(x, y); {
Location = new Point(x, y)
};
y += ctrl.Height + 4; y += ctrl.Height + 4;
Controls.Add(ctrl); Controls.Add(ctrl);
} }
ResumeLayout(); ResumeLayout();
} }
/// <summary> /// <summary>
/// save to config /// save to config
/// </summary> /// </summary>
/// <param name="SaveConfigObject">if non-null, save to possibly different config object than originally initialized from</param> /// <param name="saveConfigObject">if non-null, save to possibly different config object than originally initialized from</param>
public void Save(Dictionary<string, Config.AnalogBind> SaveConfigObject = null) public void Save(Dictionary<string, Config.AnalogBind> saveConfigObject = null)
{ {
var saveto = SaveConfigObject ?? RealConfigObject; var saveto = saveConfigObject ?? _realConfigObject;
foreach (Control c in Controls) foreach (Control c in Controls)
{ {
var abc = (AnalogBindControl)c; var abc = (AnalogBindControl)c;

View File

@ -46,7 +46,7 @@
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem"; this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
this.clearToolStripMenuItem.Size = new System.Drawing.Size(99, 22); this.clearToolStripMenuItem.Size = new System.Drawing.Size(99, 22);
this.clearToolStripMenuItem.Text = "&Clear"; this.clearToolStripMenuItem.Text = "&Clear";
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click); this.clearToolStripMenuItem.Click += new System.EventHandler(this.ClearToolStripMenuItem_Click);
// //
// ControllerConfigPanel // ControllerConfigPanel
// //

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -12,29 +11,29 @@ namespace BizHawk.Client.EmuHawk
public partial class ControllerConfigPanel : UserControl public partial class ControllerConfigPanel : UserControl
{ {
// the dictionary that results are saved to // the dictionary that results are saved to
Dictionary<string, string> RealConfigObject; private Dictionary<string, string> _realConfigObject;
// if nonnull, the list of keys to use. used to have the config panel operate on a smaller list than the whole dictionary; // if nonnull, the list of keys to use. used to have the config panel operate on a smaller list than the whole dictionary;
// for instance, to show only a single player // for instance, to show only a single player
List<string> RealConfigButtons; private List<string> _realConfigButtons;
public List<string> buttons = new List<string>(); private readonly List<string> _buttons = new List<string>();
public int InputMarginLeft = UIHelper.ScaleX(0); private readonly int _inputMarginLeft = UIHelper.ScaleX(0);
public int LabelPadding = UIHelper.ScaleX(5); private readonly int _labelPadding = UIHelper.ScaleX(5);
private readonly int _marginTop = UIHelper.ScaleY(0);
private readonly int _spacing = UIHelper.ScaleY(24);
private readonly int _inputSize = UIHelper.ScaleX(170);
private readonly int _columnWidth = UIHelper.ScaleX(280);
public int MarginTop = UIHelper.ScaleY(0); public ToolTip Tooltip { get; set; }
public int Spacing = UIHelper.ScaleY(24);
public int InputSize = UIHelper.ScaleX(170);
public int ColumnWidth = UIHelper.ScaleX(280);
public int LabelWidth = UIHelper.ScaleX(60);
public ToolTip Tooltip; private readonly List<InputCompositeWidget> _inputs = new List<InputCompositeWidget>();
protected List<InputCompositeWidget> Inputs = new List<InputCompositeWidget>();
protected List<Label> Labels = new List<Label>();
private Size _panelSize = new Size(0, 0); private Size _panelSize = new Size(0, 0);
private bool _autotab;
public ControllerConfigPanel() public ControllerConfigPanel()
{ {
InitializeComponent(); InitializeComponent();
@ -42,29 +41,29 @@ namespace BizHawk.Client.EmuHawk
private void ControllerConfigPanel_Load(object sender, EventArgs e) private void ControllerConfigPanel_Load(object sender, EventArgs e)
{ {
} }
public void ClearAll() private void ClearAll()
{ {
Inputs.ForEach(x => x.Clear()); _inputs.ForEach(x => x.Clear());
} }
/// <summary> /// <summary>
/// save to config /// save to config
/// </summary> /// </summary>
/// <param name="SaveConfigObject">if non-null, save to possibly different config object than originally initialized from</param> /// <param name="saveConfigObject">if non-null, save to possibly different config object than originally initialized from</param>
public void Save(Dictionary<string, string>SaveConfigObject = null) public void Save(Dictionary<string, string> saveConfigObject = null)
{ {
var saveto = SaveConfigObject ?? RealConfigObject; var saveto = saveConfigObject ?? _realConfigObject;
for (int button = 0; button < buttons.Count; button++) for (int button = 0; button < _buttons.Count; button++)
saveto[buttons[button]] = Inputs[button].Bindings; {
saveto[_buttons[button]] = _inputs[button].Bindings;
}
} }
public bool Autotab = false;
public void LoadSettings(Dictionary<string, string> configobj, bool autotab, List<string> configbuttons = null, int? width = null, int? height = null) public void LoadSettings(Dictionary<string, string> configobj, bool autotab, List<string> configbuttons = null, int? width = null, int? height = null)
{ {
Autotab = autotab; _autotab = autotab;
if (width.HasValue && height.HasValue) if (width.HasValue && height.HasValue)
{ {
_panelSize = new Size(width.Value, height.Value); _panelSize = new Size(width.Value, height.Value);
@ -74,78 +73,82 @@ namespace BizHawk.Client.EmuHawk
_panelSize = Size; _panelSize = Size;
} }
RealConfigObject = configobj; _realConfigObject = configobj;
RealConfigButtons = configbuttons; _realConfigButtons = configbuttons;
SetButtonList(); SetButtonList();
Startup(); Startup();
SetWidgetStrings(); SetWidgetStrings();
} }
protected void SetButtonList() private void SetButtonList()
{ {
buttons.Clear(); _buttons.Clear();
IEnumerable<string> bl = RealConfigButtons ?? (IEnumerable<string>)RealConfigObject.Keys; IEnumerable<string> bl = _realConfigButtons ?? (IEnumerable<string>)_realConfigObject.Keys;
foreach (string s in bl) foreach (string s in bl)
buttons.Add(s);
}
protected void SetWidgetStrings()
{
for (int button = 0; button < buttons.Count; button++)
{ {
string s; _buttons.Add(s);
if (!RealConfigObject.TryGetValue(buttons[button], out s))
s = "";
Inputs[button].Bindings = s;
} }
} }
protected void Startup() private void SetWidgetStrings()
{ {
int x = InputMarginLeft; for (int button = 0; button < _buttons.Count; button++)
int y = MarginTop - Spacing;
for (int i = 0; i < buttons.Count; i++)
{ {
y += Spacing; string s;
if (y > (_panelSize.Height - UIHelper.ScaleY(62))) if (!_realConfigObject.TryGetValue(_buttons[button], out s))
{ {
y = MarginTop; s = "";
x += ColumnWidth;
} }
InputCompositeWidget iw = new InputCompositeWidget _inputs[button].Bindings = s;
}
}
private void Startup()
{
int x = _inputMarginLeft;
int y = _marginTop - _spacing;
for (int i = 0; i < _buttons.Count; i++)
{
y += _spacing;
if (y > (_panelSize.Height - UIHelper.ScaleY(62)))
{
y = _marginTop;
x += _columnWidth;
}
var iw = new InputCompositeWidget
{ {
Location = new Point(x, y), Location = new Point(x, y),
Size = new Size(InputSize, UIHelper.ScaleY(23)), Size = new Size(_inputSize, UIHelper.ScaleY(23)),
TabIndex = i, TabIndex = i,
AutoTab = this.Autotab AutoTab = _autotab
}; };
iw.SetupTooltip(Tooltip, null); iw.SetupTooltip(Tooltip, null);
iw.BringToFront(); iw.BringToFront();
Controls.Add(iw); Controls.Add(iw);
Inputs.Add(iw); _inputs.Add(iw);
Label label = new Label var label = new Label
{ {
Location = new Point(x + InputSize + LabelPadding, y + UIHelper.ScaleY(3)), Location = new Point(x + _inputSize + _labelPadding, y + UIHelper.ScaleY(3)),
Size = new Size(UIHelper.ScaleX(100), UIHelper.ScaleY(15)), Size = new Size(UIHelper.ScaleX(100), UIHelper.ScaleY(15)),
Text = buttons[i].Replace('_', ' ').Trim(), Text = _buttons[i].Replace('_', ' ').Trim(),
}; };
//Tooltip.SetToolTip(label, null); //??? not supported yet ////Tooltip.SetToolTip(label, null); //??? not supported yet
Controls.Add(label); Controls.Add(label);
Labels.Add(label);
} }
} }
public void SetAutoTab(bool value) public void SetAutoTab(bool value)
{ {
Inputs.ForEach(x => x.AutoTab = value); _inputs.ForEach(x => x.AutoTab = value);
} }
private void clearToolStripMenuItem_Click(object sender, EventArgs e) private void ClearToolStripMenuItem_Click(object sender, EventArgs e)
{ {
ClearAll(); ClearAll();
} }

View File

@ -1,4 +1,4 @@
namespace BizHawk.Client.EmuHawk.config namespace BizHawk.Client.EmuHawk
{ {
partial class DisplayConfig partial class DisplayConfig
{ {

View File

@ -1,13 +1,6 @@
using System; using System.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk.config namespace BizHawk.Client.EmuHawk
{ {
public partial class DisplayConfig : Form public partial class DisplayConfig : Form
{ {

View File

@ -1,4 +1,4 @@
namespace BizHawk.Client.EmuHawk.config namespace BizHawk.Client.EmuHawk
{ {
partial class DisplayConfigLite partial class DisplayConfigLite
{ {

View File

@ -1,16 +1,10 @@
using System; using System;
using System.IO; using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Client.Common; using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk.config namespace BizHawk.Client.EmuHawk
{ {
public partial class DisplayConfigLite : Form public partial class DisplayConfigLite : Form
{ {

View File

@ -1,10 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -24,7 +20,7 @@ namespace BizHawk.Client.EmuHawk
int count = 0; int count = 0;
foreach (var kvp in Global.Config.PreferredPlatformsForExtensions) foreach (var kvp in Global.Config.PreferredPlatformsForExtensions)
{ {
FileExtensionPreferencesPicker picker = new FileExtensionPreferencesPicker var picker = new FileExtensionPreferencesPicker
{ {
FileExtension = kvp.Key, FileExtension = kvp.Key,
OriginalPreference = kvp.Value, OriginalPreference = kvp.Value,
@ -38,7 +34,6 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
foreach (var picker in PrefPanel.Controls.OfType<FileExtensionPreferencesPicker>()) foreach (var picker in PrefPanel.Controls.OfType<FileExtensionPreferencesPicker>())
{ {
Global.Config.PreferredPlatformsForExtensions[picker.FileExtension] = picker.CurrentlySelectedSystemId; Global.Config.PreferredPlatformsForExtensions[picker.FileExtension] = picker.CurrentlySelectedSystemId;

View File

@ -1,10 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
@ -17,10 +13,10 @@ namespace BizHawk.Client.EmuHawk
public FileExtensionPreferencesPicker() public FileExtensionPreferencesPicker()
{ {
InitializeComponent(); InitializeComponent();
AvailableSystems = new SystemLookup().AllSystems.ToList(); _availableSystems = new SystemLookup().AllSystems.ToList();
} }
private readonly List<SystemLookup.SystemInfo> AvailableSystems; private readonly List<SystemLookup.SystemInfo> _availableSystems;
public string FileExtension { get; set; } public string FileExtension { get; set; }
public string OriginalPreference { get; set; } public string OriginalPreference { get; set; }
@ -31,8 +27,8 @@ namespace BizHawk.Client.EmuHawk
{ {
if (PlatformDropdown.SelectedIndex > 0) if (PlatformDropdown.SelectedIndex > 0)
{ {
return AvailableSystems return _availableSystems
.FirstOrDefault(x => x.SystemId == PlatformDropdown.SelectedItem.ToString()).FullName; .First(x => x.SystemId == PlatformDropdown.SelectedItem.ToString()).FullName;
} }
return ""; return "";
@ -42,25 +38,12 @@ namespace BizHawk.Client.EmuHawk
private void PopulatePlatforms() private void PopulatePlatforms()
{ {
PlatformDropdown.Items.Add("Ask me on load"); PlatformDropdown.Items.Add("Ask me on load");
foreach (var platform in AvailableSystems) foreach (var platform in _availableSystems)
{ {
PlatformDropdown.Items.Add(platform.FullName); PlatformDropdown.Items.Add(platform.FullName);
} }
} }
private IEnumerable<string> DropdownSystemIds
{
get
{
var dispVals = PlatformDropdown.Items.OfType<string>();
foreach (var val in dispVals)
{
yield return AvailableSystems.FirstOrDefault(x => x.FullName == val).SystemId ?? "";
}
}
}
private void FileExtensionPreferencesPicker_Load(object sender, EventArgs e) private void FileExtensionPreferencesPicker_Load(object sender, EventArgs e)
{ {
PopulatePlatforms(); PopulatePlatforms();
@ -68,7 +51,7 @@ namespace BizHawk.Client.EmuHawk
var selectedSystemId = Global.Config.PreferredPlatformsForExtensions[FileExtension]; var selectedSystemId = Global.Config.PreferredPlatformsForExtensions[FileExtension];
if (!string.IsNullOrEmpty(selectedSystemId)) if (!string.IsNullOrEmpty(selectedSystemId))
{ {
var selectedSystem = AvailableSystems.FirstOrDefault(s => s.SystemId == selectedSystemId); var selectedSystem = _availableSystems.FirstOrDefault(s => s.SystemId == selectedSystemId);
var selectedItem = PlatformDropdown.Items var selectedItem = PlatformDropdown.Items
.OfType<string>() .OfType<string>()

View File

@ -2,11 +2,9 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Common; using BizHawk.Common;
@ -14,42 +12,41 @@ using BizHawk.Client.Common;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Client.EmuHawk.WinFormExtensions; using BizHawk.Client.EmuHawk.WinFormExtensions;
//notes: eventually, we intend to have a "firmware acquisition interface" exposed to the emulator cores. // notes: eventually, we intend to have a "firmware acquisition interface" exposed to the emulator cores.
//it will be implemented by emuhawk, and use firmware keys to fetch the firmware content. // it will be implemented by emuhawk, and use firmware keys to fetch the firmware content.
//however, for now, the cores are using strings from the config class. so we have the `configMember` which is // however, for now, the cores are using strings from the config class. so we have the `configMember` which is
//used by reflection to set the configuration for firmwares which were found // used by reflection to set the configuration for firmwares which were found
//TODO - we may eventually need to add a progress dialog for this. we should have one for other reasons. // TODO - we may eventually need to add a progress dialog for this. we should have one for other reasons.
//I started making one in Bizhawk.Util as QuickProgressPopup but ran out of time // I started making one in Bizhawk.Util as QuickProgressPopup but ran out of time
//IDEA: show current path in tooltip (esp. for custom resolved) // IDEA: show current path in tooltip (esp. for custom resolved)
//IDEA: prepop set customization to dir of current custom // IDEA: prepop set customization to dir of current custom
//TODO - display some kind if [!] if you have a user-specified file which is known but defined as incompatible by the firmware DB
// TODO - display some kind if [!] if you have a user-specified file which is known but defined as incompatible by the firmware DB
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class FirmwaresConfig : Form public partial class FirmwaresConfig : Form
{ {
//friendlier names than the system Ids // friendlier names than the system Ids
public static readonly Dictionary<string, string> SystemGroupNames = new Dictionary<string, string>() private static readonly Dictionary<string, string> SystemGroupNames = new Dictionary<string, string>
{ {
{ "NES", "NES" }, { "NES", "NES" },
{ "SNES", "SNES" }, { "SNES", "SNES" },
{ "PCECD", "PCE-CD" }, { "PCECD", "PCE-CD" },
{ "SAT", "Saturn" }, { "SAT", "Saturn" },
{ "A78", "Atari 7800" }, { "A78", "Atari 7800" },
{ "Coleco", "Colecovision" }, { "Coleco", "Colecovision" },
{ "GBA", "GBA" }, { "GBA", "GBA" },
{ "TI83", "TI-83" }, { "TI83", "TI-83" },
{ "INTV", "Intellivision" }, { "INTV", "Intellivision" },
{ "C64", "C64" }, { "C64", "C64" },
{ "GEN", "Genesis" }, { "GEN", "Genesis" },
{ "SMS", "Sega Master System" }, { "SMS", "Sega Master System" },
{ "PSX", "Sony PlayStation" }, { "PSX", "Sony PlayStation" },
{ "Lynx", "Atari Lynx" }, { "Lynx", "Atari Lynx" },
{ "AppleII", "Apple II" } { "AppleII", "Apple II" }
}; };
public string TargetSystem = null; public string TargetSystem = null;
@ -57,9 +54,9 @@ namespace BizHawk.Client.EmuHawk
private const int idMissing = 1; private const int idMissing = 1;
private const int idOk = 2; private const int idOk = 2;
Font fixedFont, boldFont, boldFixedFont; private Font fixedFont, boldFont, boldFixedFont;
class ListViewSorter : IComparer private class ListViewSorter : IComparer
{ {
public FirmwaresConfig dialog; public FirmwaresConfig dialog;
public int column; public int column;
@ -77,14 +74,14 @@ namespace BizHawk.Client.EmuHawk
} }
} }
string currSelectorDir; private string currSelectorDir;
ListViewSorter listviewSorter; private readonly ListViewSorter listviewSorter;
public FirmwaresConfig(bool retryLoadRom = false, string reloadRomPath = null) public FirmwaresConfig(bool retryLoadRom = false, string reloadRomPath = null)
{ {
InitializeComponent(); InitializeComponent();
//prep imagelist for listview with 3 item states for {idUnsure, idMissing, idOk} // prep imagelist for listview with 3 item states for {idUnsure, idMissing, idOk}
imageList1.Images.AddRange(new[] { Properties.Resources.RetroQuestion, Properties.Resources.ExclamationRed, Properties.Resources.GreenCheck }); imageList1.Images.AddRange(new[] { Properties.Resources.RetroQuestion, Properties.Resources.ExclamationRed, Properties.Resources.GreenCheck });
listviewSorter = new ListViewSorter(this, -1); listviewSorter = new ListViewSorter(this, -1);
@ -108,7 +105,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
//makes sure that the specified SystemId is selected in the list (and that all the firmwares for it are visible) // makes sure that the specified SystemId is selected in the list (and that all the firmwares for it are visible)
private void WarpToSystemId(string sysid) private void WarpToSystemId(string sysid)
{ {
bool selectedFirst = false; bool selectedFirst = false;
@ -125,12 +122,12 @@ namespace BizHawk.Client.EmuHawk
private void FirmwaresConfig_Load(object sender, EventArgs e) private void FirmwaresConfig_Load(object sender, EventArgs e)
{ {
//we'll use this font for displaying the hash, so they dont look all jagged in a long list // we'll use this font for displaying the hash, so they dont look all jagged in a long list
fixedFont = new Font(new FontFamily("Courier New"), 8); fixedFont = new Font(new FontFamily("Courier New"), 8);
boldFont = new Font(lvFirmwares.Font, FontStyle.Bold); boldFont = new Font(lvFirmwares.Font, FontStyle.Bold);
boldFixedFont = new Font(fixedFont, FontStyle.Bold); boldFixedFont = new Font(fixedFont, FontStyle.Bold);
//populate listview from firmware DB // populate listview from firmware DB
var groups = new Dictionary<string, ListViewGroup>(); var groups = new Dictionary<string, ListViewGroup>();
foreach (var fr in FirmwareDatabase.FirmwareRecords) foreach (var fr in FirmwareDatabase.FirmwareRecords)
{ {
@ -142,15 +139,15 @@ namespace BizHawk.Client.EmuHawk
lvi.SubItems.Add(fr.SystemId); lvi.SubItems.Add(fr.SystemId);
lvi.SubItems.Add(fr.FirmwareId); lvi.SubItems.Add(fr.FirmwareId);
lvi.SubItems.Add(fr.Descr); lvi.SubItems.Add(fr.Descr);
lvi.SubItems.Add(""); //resolved with lvi.SubItems.Add(""); // resolved with
lvi.SubItems.Add(""); //location lvi.SubItems.Add(""); // location
lvi.SubItems.Add(""); //size lvi.SubItems.Add(""); // size
lvi.SubItems.Add(""); //hash lvi.SubItems.Add(""); // hash
lvi.SubItems[6].Font = fixedFont; //would be used for hash and size lvi.SubItems[6].Font = fixedFont; // would be used for hash and size
lvi.SubItems[7].Font = fixedFont; //would be used for hash and size lvi.SubItems[7].Font = fixedFont; // would be used for hash and size
lvFirmwares.Items.Add(lvi); lvFirmwares.Items.Add(lvi);
//build the groups in the listview as we go: // build the groups in the listview as we go:
if (!groups.ContainsKey(fr.SystemId)) if (!groups.ContainsKey(fr.SystemId))
{ {
string name; string name;
@ -163,7 +160,7 @@ namespace BizHawk.Client.EmuHawk
lvi.Group = groups[fr.SystemId]; lvi.Group = groups[fr.SystemId];
} }
//now that we have some items in the listview, we can size some columns to sensible widths // now that we have some items in the listview, we can size some columns to sensible widths
lvFirmwares.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.ColumnContent); lvFirmwares.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.ColumnContent);
lvFirmwares.AutoResizeColumn(2, ColumnHeaderAutoResizeStyle.ColumnContent); lvFirmwares.AutoResizeColumn(2, ColumnHeaderAutoResizeStyle.ColumnContent);
lvFirmwares.AutoResizeColumn(3, ColumnHeaderAutoResizeStyle.ColumnContent); lvFirmwares.AutoResizeColumn(3, ColumnHeaderAutoResizeStyle.ColumnContent);
@ -198,7 +195,7 @@ namespace BizHawk.Client.EmuHawk
private void tbbGroup_Click(object sender, EventArgs e) private void tbbGroup_Click(object sender, EventArgs e)
{ {
//toggle the grouping state // toggle the grouping state
lvFirmwares.ShowGroups = !lvFirmwares.ShowGroups; lvFirmwares.ShowGroups = !lvFirmwares.ShowGroups;
} }
@ -217,18 +214,18 @@ namespace BizHawk.Client.EmuHawk
private void tbbScan_Click(object sender, EventArgs e) private void tbbScan_Click(object sender, EventArgs e)
{ {
//user-initiated scan // user-initiated scan
DoScan(); DoScan();
} }
FirmwareManager Manager { get { return Global.FirmwareManager; } } private FirmwareManager Manager => Global.FirmwareManager;
private void DoScan() private void DoScan()
{ {
lvFirmwares.BeginUpdate(); lvFirmwares.BeginUpdate();
Manager.DoScanAndResolve(); Manager.DoScanAndResolve();
//for each type of firmware, try resolving and record the result // for each type of firmware, try resolving and record the result
foreach (ListViewItem lvi in lvFirmwares.Items) foreach (ListViewItem lvi in lvFirmwares.Items)
{ {
var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord; var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord;
@ -243,15 +240,15 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
//lazy substring extraction. really should do a better job // lazy substring extraction. really should do a better job
var basePath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null) + Path.DirectorySeparatorChar; var basePath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null) + Path.DirectorySeparatorChar;
var path = ri.FilePath.Replace(basePath, ""); var path = ri.FilePath.Replace(basePath, "");
//bolden the item if the user has specified a path for it // bolden the item if the user has specified a path for it
bool bolden = ri.UserSpecified; bool bolden = ri.UserSpecified;
//set columns based on whether it was a known file // set columns based on whether it was a known file
if (ri.KnownFirmwareFile == null) if (ri.KnownFirmwareFile == null)
{ {
lvi.ImageIndex = idUnsure; lvi.ImageIndex = idUnsure;
@ -265,7 +262,7 @@ namespace BizHawk.Client.EmuHawk
lvi.SubItems[4].Text = ri.KnownFirmwareFile.Description; lvi.SubItems[4].Text = ri.KnownFirmwareFile.Description;
} }
//bolden the item if necessary // bolden the item if necessary
if (bolden) if (bolden)
{ {
foreach (ListViewItem.ListViewSubItem lvsi in lvi.SubItems) lvsi.Font = boldFont; foreach (ListViewItem.ListViewSubItem lvsi in lvi.SubItems) lvsi.Font = boldFont;
@ -277,14 +274,14 @@ namespace BizHawk.Client.EmuHawk
lvi.SubItems[6].Font = fixedFont; lvi.SubItems[6].Font = fixedFont;
} }
//if the user specified a file but its missing, mark it as such // if the user specified a file but its missing, mark it as such
if (ri.Missing) if (ri.Missing)
{ {
lvi.ImageIndex = idMissing; lvi.ImageIndex = idMissing;
lvi.ToolTipText = "Missing!"; lvi.ToolTipText = "Missing!";
} }
//if the user specified a known firmware file but its for some other firmware, it was probably a mistake. mark it as suspicious // if the user specified a known firmware file but its for some other firmware, it was probably a mistake. mark it as suspicious
if (ri.KnownMismatching) if (ri.KnownMismatching)
lvi.ImageIndex = idUnsure; lvi.ImageIndex = idUnsure;
@ -303,7 +300,9 @@ namespace BizHawk.Client.EmuHawk
private void tbbOrganize_Click(object sender, EventArgs e) private void tbbOrganize_Click(object sender, EventArgs e)
{ {
if (MessageBox.Show(this, "This is going to move/rename every automatically-selected firmware file under your configured firmwares directory to match our recommended organizational scheme (which is not super great right now). Proceed?", "Firmwares Organization Confirm", MessageBoxButtons.OKCancel) == DialogResult.Cancel) if (MessageBox.Show(this, "This is going to move/rename every automatically-selected firmware file under your configured firmwares directory to match our recommended organizational scheme (which is not super great right now). Proceed?", "Firmwares Organization Confirm", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
return; {
return;
}
Manager.DoScanAndResolve(); Manager.DoScanAndResolve();
@ -323,8 +322,8 @@ namespace BizHawk.Client.EmuHawk
} }
catch catch
{ {
//sometimes moves fail. especially in newer versions of windows with explorers more fragile than your great-grandma. // sometimes moves fail. especially in newer versions of windows with explorers more fragile than your great-grandma.
//I am embarassed that I know that. about windows, not your great-grandma. // I am embarassed that I know that. about windows, not your great-grandma.
} }
} }
@ -360,10 +359,10 @@ namespace BizHawk.Client.EmuHawk
if (ofd.ShowDialog() == DialogResult.OK) if (ofd.ShowDialog() == DialogResult.OK)
{ {
//remember the location we selected this firmware from, maybe there are others // remember the location we selected this firmware from, maybe there are others
currSelectorDir = Path.GetDirectoryName(ofd.FileName); currSelectorDir = Path.GetDirectoryName(ofd.FileName);
//for each selected item, set the user choice (even though multiple selection for this operation is no longer allowed) // for each selected item, set the user choice (even though multiple selection for this operation is no longer allowed)
foreach (ListViewItem lvi in lvFirmwares.SelectedItems) foreach (ListViewItem lvi in lvFirmwares.SelectedItems)
{ {
var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord; var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord;
@ -377,7 +376,7 @@ namespace BizHawk.Client.EmuHawk
private void tsmiClearCustomization_Click(object sender, EventArgs e) private void tsmiClearCustomization_Click(object sender, EventArgs e)
{ {
//for each selected item, clear the user choice // for each selected item, clear the user choice
foreach (ListViewItem lvi in lvFirmwares.SelectedItems) foreach (ListViewItem lvi in lvFirmwares.SelectedItems)
{ {
var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord; var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord;
@ -390,16 +389,22 @@ namespace BizHawk.Client.EmuHawk
private void tsmiInfo_Click(object sender, EventArgs e) private void tsmiInfo_Click(object sender, EventArgs e)
{ {
var lvi = lvFirmwares.SelectedItems[0]; var lvi = lvFirmwares.SelectedItems[0];
var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord; var fr = (FirmwareDatabase.FirmwareRecord)lvi.Tag;
//get all options for this firmware (in order) // get all options for this firmware (in order)
var options = var options =
from fo in FirmwareDatabase.FirmwareOptions from fo in FirmwareDatabase.FirmwareOptions
where fo.SystemId == fr.SystemId && fo.FirmwareId == fr.FirmwareId where fo.SystemId == fr.SystemId && fo.FirmwareId == fr.FirmwareId
select fo; select fo;
FirmwaresConfigInfo fciDialog = new FirmwaresConfigInfo(); FirmwaresConfigInfo fciDialog = new FirmwaresConfigInfo
fciDialog.lblFirmware.Text = string.Format("{0} : {1} ({2})", fr.SystemId, fr.FirmwareId, fr.Descr); {
lblFirmware =
{
Text = $"{fr.SystemId} : {fr.FirmwareId} ({fr.Descr})"
}
};
foreach (var o in options) foreach (var o in options)
{ {
ListViewItem olvi = new ListViewItem(); ListViewItem olvi = new ListViewItem();
@ -417,15 +422,15 @@ namespace BizHawk.Client.EmuHawk
if (o.Status == FirmwareDatabase.FirmwareOptionStatus.Bad) if (o.Status == FirmwareDatabase.FirmwareOptionStatus.Bad)
olvi.ImageIndex = FirmwaresConfigInfo.idBad; olvi.ImageIndex = FirmwaresConfigInfo.idBad;
olvi.SubItems[0].Text = ff.Size.ToString(); olvi.SubItems[0].Text = ff.Size.ToString();
olvi.SubItems[0].Font = this.Font; //why doesnt this work? olvi.SubItems[0].Font = this.Font; // why doesnt this work?
olvi.SubItems[1].Text = "sha1:" + o.Hash; olvi.SubItems[1].Text = "sha1:" + o.Hash;
olvi.SubItems[1].Font = fixedFont; olvi.SubItems[1].Font = fixedFont;
olvi.SubItems[2].Text = ff.RecommendedName; olvi.SubItems[2].Text = ff.RecommendedName;
olvi.SubItems[2].Font = this.Font; //why doesnt this work? olvi.SubItems[2].Font = this.Font; // why doesnt this work?
olvi.SubItems[3].Text = ff.Description; olvi.SubItems[3].Text = ff.Description;
olvi.SubItems[3].Font = this.Font; //why doesnt this work? olvi.SubItems[3].Font = this.Font; // why doesnt this work?
olvi.SubItems[4].Text = ff.Info; olvi.SubItems[4].Text = ff.Info;
olvi.SubItems[4].Font = this.Font; //why doesnt this work? olvi.SubItems[4].Font = this.Font; // why doesnt this work?
fciDialog.lvOptions.Items.Add(olvi); fciDialog.lvOptions.Items.Add(olvi);
} }
@ -439,7 +444,7 @@ namespace BizHawk.Client.EmuHawk
private void lvFirmwaresContextMenuStrip_Opening(object sender, CancelEventArgs e) private void lvFirmwaresContextMenuStrip_Opening(object sender, CancelEventArgs e)
{ {
//hide menu items that arent appropriate for multi-select // hide menu items that arent appropriate for multi-select
tsmiSetCustomization.Visible = lvFirmwares.SelectedItems.Count == 1; tsmiSetCustomization.Visible = lvFirmwares.SelectedItems.Count == 1;
tsmiInfo.Visible = lvFirmwares.SelectedItems.Count == 1; tsmiInfo.Visible = lvFirmwares.SelectedItems.Count == 1;
} }
@ -456,21 +461,24 @@ namespace BizHawk.Client.EmuHawk
MessageBox.Show("C-C-C-Combo Breaker!", "Nice try, but"); MessageBox.Show("C-C-C-Combo Breaker!", "Nice try, but");
return; return;
} }
new PathConfig().ShowDialog(this); new PathConfig().ShowDialog(this);
RefreshBasePath(); RefreshBasePath();
} }
void RefreshBasePath() private void RefreshBasePath()
{ {
string oldBasePath = currSelectorDir; string oldBasePath = currSelectorDir;
linkBasePath.Text = currSelectorDir = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null); linkBasePath.Text = currSelectorDir = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null);
if (oldBasePath != currSelectorDir) if (oldBasePath != currSelectorDir)
{
DoScan(); DoScan();
}
} }
private void tbbImport_Click(object sender, EventArgs e) private void tbbImport_Click(object sender, EventArgs e)
{ {
using(var ofd = new OpenFileDialog()) using (var ofd = new OpenFileDialog())
{ {
ofd.Multiselect = true; ofd.Multiselect = true;
if (ofd.ShowDialog() != DialogResult.OK) if (ofd.ShowDialog() != DialogResult.OK)
@ -515,7 +523,11 @@ namespace BizHawk.Client.EmuHawk
} }
catch catch
{ {
if (errors != "") errors += "\n"; if (errors != "")
{
errors += "\n";
}
errors += f; errors += f;
return false; return false;
} }
@ -532,7 +544,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (hf.IsArchive) if (hf.IsArchive)
{ {
//blech. the worst extraction code in the universe. // blech. the worst extraction code in the universe.
string extractpath = Path.GetTempFileName() + ".dir"; string extractpath = Path.GetTempFileName() + ".dir";
DirectoryInfo di = Directory.CreateDirectory(extractpath); DirectoryInfo di = Directory.CreateDirectory(extractpath);
@ -588,10 +600,7 @@ namespace BizHawk.Client.EmuHawk
private void lvFirmwares_DragEnter(object sender, DragEventArgs e) private void lvFirmwares_DragEnter(object sender, DragEventArgs e)
{ {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
} }
private void lvFirmwares_DragDrop(object sender, DragEventArgs e) private void lvFirmwares_DragDrop(object sender, DragEventArgs e)
@ -602,5 +611,5 @@ namespace BizHawk.Client.EmuHawk
RunImportJob(files); RunImportJob(files);
} }
} }
} //class FirmwaresConfig } // class FirmwaresConfig
} }

View File

@ -67,8 +67,8 @@
this.lvOptions.TabIndex = 0; this.lvOptions.TabIndex = 0;
this.lvOptions.UseCompatibleStateImageBehavior = false; this.lvOptions.UseCompatibleStateImageBehavior = false;
this.lvOptions.View = System.Windows.Forms.View.Details; this.lvOptions.View = System.Windows.Forms.View.Details;
this.lvOptions.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvOptions_KeyDown); this.lvOptions.KeyDown += new System.Windows.Forms.KeyEventHandler(this.LvOptions_KeyDown);
this.lvOptions.MouseClick += new System.Windows.Forms.MouseEventHandler(this.lvOptions_MouseClick); this.lvOptions.MouseClick += new System.Windows.Forms.MouseEventHandler(this.LvOptions_MouseClick);
// //
// colHash // colHash
// //
@ -179,7 +179,7 @@
this.tsmiOptionsCopy.Name = "tsmiOptionsCopy"; this.tsmiOptionsCopy.Name = "tsmiOptionsCopy";
this.tsmiOptionsCopy.Size = new System.Drawing.Size(99, 22); this.tsmiOptionsCopy.Size = new System.Drawing.Size(99, 22);
this.tsmiOptionsCopy.Text = "&Copy"; this.tsmiOptionsCopy.Text = "&Copy";
this.tsmiOptionsCopy.Click += new System.EventHandler(this.tsmiOptionsCopy_Click); this.tsmiOptionsCopy.Click += new System.EventHandler(this.TsmiOptionsCopy_Click);
// //
// colSize // colSize
// //

View File

@ -3,15 +3,13 @@ using System.Windows.Forms;
using BizHawk.Client.EmuHawk.WinFormExtensions; using BizHawk.Client.EmuHawk.WinFormExtensions;
//todo - display details on the current resolution status // todo - display details on the current resolution status
//todo - check(mark) the one thats selected // todo - check(mark) the one thats selected
//todo - turn top info into textboxes i guess, labels suck // todo - turn top info into textboxes i guess, labels suck
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class FirmwaresConfigInfo : Form public partial class FirmwaresConfigInfo : Form
{ {
public const int idIdeal = 0; public const int idIdeal = 0;
public const int idAcceptable = 1; public const int idAcceptable = 1;
public const int idUnacceptable = 2; public const int idUnacceptable = 2;
@ -21,11 +19,11 @@ namespace BizHawk.Client.EmuHawk
{ {
InitializeComponent(); InitializeComponent();
//prep imagelist for listview with 4 item states for (ideal, acceptable, unacceptable, bad) // prep imagelist for listview with 4 item states for (ideal, acceptable, unacceptable, bad)
imageList1.Images.AddRange(new[] { Properties.Resources.GreenCheck, Properties.Resources.Freeze, Properties.Resources.thumbsdown, Properties.Resources.ExclamationRed }); imageList1.Images.AddRange(new[] { Properties.Resources.GreenCheck, Properties.Resources.Freeze, Properties.Resources.thumbsdown, Properties.Resources.ExclamationRed });
} }
private void lvOptions_KeyDown(object sender, KeyEventArgs e) private void LvOptions_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift) if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift)
{ {
@ -33,21 +31,23 @@ namespace BizHawk.Client.EmuHawk
} }
} }
void PerformListCopy() private void PerformListCopy()
{ {
var str = lvOptions.CopyItemsAsText(); var str = lvOptions.CopyItemsAsText();
if (str.Length > 0) Clipboard.SetDataObject(str); if (str.Length > 0) Clipboard.SetDataObject(str);
} }
private void tsmiOptionsCopy_Click(object sender, EventArgs e) private void TsmiOptionsCopy_Click(object sender, EventArgs e)
{ {
PerformListCopy(); PerformListCopy();
} }
private void lvOptions_MouseClick(object sender, MouseEventArgs e) private void LvOptions_MouseClick(object sender, MouseEventArgs e)
{ {
if (e.Button == MouseButtons.Right && lvOptions.GetItemAt(e.X, e.Y) != null) if (e.Button == MouseButtons.Right && lvOptions.GetItemAt(e.X, e.Y) != null)
{
lvmiOptionsContextMenuStrip.Show(lvOptions, e.Location); lvmiOptionsContextMenuStrip.Show(lvOptions, e.Location);
}
} }
} }
} }

View File

@ -11,19 +11,18 @@ using BizHawk.Client.EmuHawk.WinFormExtensions;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class BmpView : Control public class BmpView : Control
{ {
[Browsable(false)] [Browsable(false)]
public Bitmap bmp { get; private set; } public Bitmap BMP { get; private set; }
bool scaled; private bool _scaled;
public BmpView() public BmpView()
{ {
if (Process.GetCurrentProcess().ProcessName == "devenv") if (Process.GetCurrentProcess().ProcessName == "devenv")
{ {
// in the designer // in the designer
//this.BackColor = Color.Black;
SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true);
} }
else else
@ -33,29 +32,29 @@ namespace BizHawk.Client.EmuHawk
SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.Opaque, true);
this.BackColor = Color.Transparent; BackColor = Color.Transparent;
this.Paint += new PaintEventHandler(BmpView_Paint); Paint += BmpView_Paint;
this.SizeChanged += new EventHandler(BmpView_SizeChanged); SizeChanged += BmpView_SizeChanged;
ChangeBitmapSize(1, 1); ChangeBitmapSize(1, 1);
} }
} }
void BmpView_SizeChanged(object sender, EventArgs e) private void BmpView_SizeChanged(object sender, EventArgs e)
{ {
scaled = !(bmp.Width == Width && bmp.Height == Height); _scaled = !(BMP.Width == Width && BMP.Height == Height);
} }
void BmpView_Paint(object sender, PaintEventArgs e) private void BmpView_Paint(object sender, PaintEventArgs e)
{ {
if (scaled) if (_scaled)
{ {
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
e.Graphics.DrawImage(bmp, 0, 0, Width, Height); e.Graphics.DrawImage(BMP, 0, 0, Width, Height);
} }
else else
{ {
e.Graphics.DrawImageUnscaled(bmp, 0, 0); e.Graphics.DrawImageUnscaled(BMP, 0, 0);
} }
} }
@ -66,22 +65,26 @@ namespace BizHawk.Client.EmuHawk
public void ChangeBitmapSize(int w, int h) public void ChangeBitmapSize(int w, int h)
{ {
if (bmp != null) if (BMP != null)
{ {
if (w == bmp.Width && h == bmp.Height) if (w == BMP.Width && h == BMP.Height)
{
return; return;
bmp.Dispose(); }
BMP.Dispose();
} }
bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
BMP = new Bitmap(w, h, PixelFormat.Format32bppArgb);
BmpView_SizeChanged(null, null); BmpView_SizeChanged(null, null);
Refresh(); Refresh();
} }
public void Clear() public void Clear()
{ {
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); var lockdata = BMP.LockBits(new Rectangle(0, 0, BMP.Width, BMP.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
Win32.MemSet(lockdata.Scan0, 0xff, (uint)(lockdata.Height * lockdata.Stride)); Win32.MemSet(lockdata.Scan0, 0xff, (uint)(lockdata.Height * lockdata.Stride));
bmp.UnlockBits(lockdata); BMP.UnlockBits(lockdata);
Refresh(); Refresh();
} }
@ -113,7 +116,7 @@ namespace BizHawk.Client.EmuHawk
} }
var file = new FileInfo(sfd.FileName); var file = new FileInfo(sfd.FileName);
var b = this.bmp; var b = BMP;
ImageFormat i; ImageFormat i;
string extension = file.Extension.ToUpper(); string extension = file.Extension.ToUpper();

View File

@ -69,7 +69,7 @@
this.radioButton6.TabStop = true; this.radioButton6.TabStop = true;
this.radioButton6.Text = "GBA"; this.radioButton6.Text = "GBA";
this.radioButton6.UseVisualStyleBackColor = true; this.radioButton6.UseVisualStyleBackColor = true;
this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); this.radioButton6.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
// //
// radioButton5 // radioButton5
// //
@ -81,7 +81,7 @@
this.radioButton5.TabStop = true; this.radioButton5.TabStop = true;
this.radioButton5.Text = "VBA Accurate (Old)"; this.radioButton5.Text = "VBA Accurate (Old)";
this.radioButton5.UseVisualStyleBackColor = true; this.radioButton5.UseVisualStyleBackColor = true;
this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); this.radioButton5.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
// //
// radioButton3 // radioButton3
// //
@ -93,7 +93,7 @@
this.radioButton3.TabStop = true; this.radioButton3.TabStop = true;
this.radioButton3.Text = "VBA Vivid"; this.radioButton3.Text = "VBA Vivid";
this.radioButton3.UseVisualStyleBackColor = true; this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); this.radioButton3.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
// //
// radioButton4 // radioButton4
// //
@ -105,7 +105,7 @@
this.radioButton4.TabStop = true; this.radioButton4.TabStop = true;
this.radioButton4.Text = "VBA Accurate"; this.radioButton4.Text = "VBA Accurate";
this.radioButton4.UseVisualStyleBackColor = true; this.radioButton4.UseVisualStyleBackColor = true;
this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); this.radioButton4.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
// //
// radioButton2 // radioButton2
// //
@ -117,7 +117,7 @@
this.radioButton2.TabStop = true; this.radioButton2.TabStop = true;
this.radioButton2.Text = "Vivid"; this.radioButton2.Text = "Vivid";
this.radioButton2.UseVisualStyleBackColor = true; this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); this.radioButton2.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
// //
// radioButton1 // radioButton1
// //
@ -129,7 +129,7 @@
this.radioButton1.TabStop = true; this.radioButton1.TabStop = true;
this.radioButton1.Text = "Gambatte"; this.radioButton1.Text = "Gambatte";
this.radioButton1.UseVisualStyleBackColor = true; this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); this.radioButton1.CheckedChanged += new System.EventHandler(this.RadioButton1_CheckedChanged);
// //
// groupBox2 // groupBox2
// //
@ -187,7 +187,6 @@
this.Name = "CGBColorChooserForm"; this.Name = "CGBColorChooserForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Game Boy Color Palette Config"; this.Text = "Game Boy Color Palette Config";
this.Load += new System.EventHandler(this.CGBColorChooserForm_Load);
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout(); this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false); this.groupBox2.ResumeLayout(false);

View File

@ -2,40 +2,51 @@
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Nintendo.Gameboy;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class CGBColorChooserForm : Form public partial class CGBColorChooserForm : Form
{ {
CGBColorChooserForm() private CGBColorChooserForm()
{ {
InitializeComponent(); InitializeComponent();
bmpView1.ChangeBitmapSize(new Size(256, 128)); bmpView1.ChangeBitmapSize(new Size(256, 128));
} }
void LoadType(Gameboy.GambatteSettings s) private GBColors.ColorType _type;
private void LoadType(Gameboy.GambatteSettings s)
{ {
type = s.CGBColors; _type = s.CGBColors;
switch (type) switch (_type)
{ {
case GBColors.ColorType.gambatte: radioButton1.Checked = true; break; case GBColors.ColorType.gambatte:
case GBColors.ColorType.vivid: radioButton2.Checked = true; break; radioButton1.Checked = true;
case GBColors.ColorType.vbavivid: radioButton3.Checked = true; break; break;
case GBColors.ColorType.vbagbnew: radioButton4.Checked = true; break; case GBColors.ColorType.vivid:
case GBColors.ColorType.vbabgbold: radioButton5.Checked = true; break; radioButton2.Checked = true;
case GBColors.ColorType.gba: radioButton6.Checked = true; break; break;
case GBColors.ColorType.vbavivid:
radioButton3.Checked = true;
break;
case GBColors.ColorType.vbagbnew:
radioButton4.Checked = true;
break;
case GBColors.ColorType.vbabgbold:
radioButton5.Checked = true;
break;
case GBColors.ColorType.gba:
radioButton6.Checked = true;
break;
} }
} }
GBColors.ColorType type; private unsafe void RefreshType()
unsafe void RefreshType()
{ {
var lockdata = bmpView1.bmp.LockBits(new Rectangle(0, 0, 256, 128), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmpView1.BMP.LockBits(new Rectangle(0, 0, 256, 128), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int[] lut = GBColors.GetLut(type); int[] lut = GBColors.GetLut(_type);
int* dest = (int*)lockdata.Scan0; int* dest = (int*)lockdata.Scan0;
@ -45,35 +56,56 @@ namespace BizHawk.Client.EmuHawk
{ {
int r = i % 32; int r = i % 32;
int g = j % 32; int g = j % 32;
int b = i / 32 * 4 + j / 32; int b = (i / 32 * 4) + (j / 32);
int color = lut[r | g << 5 | b << 10]; int color = lut[r | g << 5 | b << 10];
*dest++ = color; *dest++ = color;
} }
dest -= 256; dest -= 256;
dest += lockdata.Stride / sizeof(int); dest += lockdata.Stride / sizeof(int);
} }
bmpView1.bmp.UnlockBits(lockdata); bmpView1.BMP.UnlockBits(lockdata);
bmpView1.Refresh(); bmpView1.Refresh();
} }
private void radioButton1_CheckedChanged(object sender, EventArgs e) private void RadioButton1_CheckedChanged(object sender, EventArgs e)
{ {
if (sender == radioButton1) if (sender == radioButton1)
type = GBColors.ColorType.gambatte; {
_type = GBColors.ColorType.gambatte;
}
if (sender == radioButton2) if (sender == radioButton2)
type = GBColors.ColorType.vivid; {
_type = GBColors.ColorType.vivid;
}
if (sender == radioButton3) if (sender == radioButton3)
type = GBColors.ColorType.vbavivid; {
_type = GBColors.ColorType.vbavivid;
}
if (sender == radioButton4) if (sender == radioButton4)
type = GBColors.ColorType.vbagbnew; {
_type = GBColors.ColorType.vbagbnew;
}
if (sender == radioButton5) if (sender == radioButton5)
type = GBColors.ColorType.vbabgbold; {
_type = GBColors.ColorType.vbabgbold;
}
if (sender == radioButton6) if (sender == radioButton6)
type = GBColors.ColorType.gba; {
var radio_button = sender as RadioButton; _type = GBColors.ColorType.gba;
if (radio_button != null && radio_button.Checked) }
var radioButton = sender as RadioButton;
if (radioButton != null && radioButton.Checked)
{
RefreshType(); RefreshType();
}
} }
public static void DoCGBColorChoserFormDialog(IWin32Window parent, Gameboy.GambatteSettings s) public static void DoCGBColorChoserFormDialog(IWin32Window parent, Gameboy.GambatteSettings s)
@ -81,33 +113,12 @@ namespace BizHawk.Client.EmuHawk
using (var dlg = new CGBColorChooserForm()) using (var dlg = new CGBColorChooserForm())
{ {
dlg.LoadType(s); dlg.LoadType(s);
var result = dlg.ShowDialog(parent);
if (result == DialogResult.OK)
s.CGBColors = dlg.type;
}
}
public static void DoCGBColorChooserFormDialog(IWin32Window parent)
{
using (var dlg = new CGBColorChooserForm())
{
var gb = Global.Emulator as Gameboy;
dlg.LoadType(gb.GetSettings());
var result = dlg.ShowDialog(parent); var result = dlg.ShowDialog(parent);
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
var s = gb.GetSettings(); s.CGBColors = dlg._type;
s.CGBColors = dlg.type;
gb.PutSettings(s);
} }
} }
} }
private void CGBColorChooserForm_Load(object sender, EventArgs e)
{
}
} }
} }

View File

@ -62,7 +62,7 @@
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(40, 32); this.panel1.Size = new System.Drawing.Size(40, 32);
this.panel1.TabIndex = 0; this.panel1.TabIndex = 0;
this.panel1.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel1.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// panel2 // panel2
// //
@ -71,7 +71,7 @@
this.panel2.Name = "panel2"; this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(40, 32); this.panel2.Size = new System.Drawing.Size(40, 32);
this.panel2.TabIndex = 1; this.panel2.TabIndex = 1;
this.panel2.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel2.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// panel3 // panel3
// //
@ -80,7 +80,7 @@
this.panel3.Name = "panel3"; this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(40, 32); this.panel3.Size = new System.Drawing.Size(40, 32);
this.panel3.TabIndex = 2; this.panel3.TabIndex = 2;
this.panel3.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel3.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// panel4 // panel4
// //
@ -89,7 +89,7 @@
this.panel4.Name = "panel4"; this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(40, 32); this.panel4.Size = new System.Drawing.Size(40, 32);
this.panel4.TabIndex = 3; this.panel4.TabIndex = 3;
this.panel4.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel4.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// panel5 // panel5
// //
@ -98,7 +98,7 @@
this.panel5.Name = "panel5"; this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(40, 32); this.panel5.Size = new System.Drawing.Size(40, 32);
this.panel5.TabIndex = 4; this.panel5.TabIndex = 4;
this.panel5.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel5.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// panel6 // panel6
// //
@ -107,7 +107,7 @@
this.panel6.Name = "panel6"; this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(40, 32); this.panel6.Size = new System.Drawing.Size(40, 32);
this.panel6.TabIndex = 5; this.panel6.TabIndex = 5;
this.panel6.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel6.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// panel7 // panel7
// //
@ -116,7 +116,7 @@
this.panel7.Name = "panel7"; this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(40, 32); this.panel7.Size = new System.Drawing.Size(40, 32);
this.panel7.TabIndex = 6; this.panel7.TabIndex = 6;
this.panel7.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel7.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// panel8 // panel8
// //
@ -125,7 +125,7 @@
this.panel8.Name = "panel8"; this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(40, 32); this.panel8.Size = new System.Drawing.Size(40, 32);
this.panel8.TabIndex = 7; this.panel8.TabIndex = 7;
this.panel8.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel8.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// panel9 // panel9
// //
@ -134,7 +134,7 @@
this.panel9.Name = "panel9"; this.panel9.Name = "panel9";
this.panel9.Size = new System.Drawing.Size(40, 32); this.panel9.Size = new System.Drawing.Size(40, 32);
this.panel9.TabIndex = 8; this.panel9.TabIndex = 8;
this.panel9.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel9.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// panel10 // panel10
// //
@ -143,7 +143,7 @@
this.panel10.Name = "panel10"; this.panel10.Name = "panel10";
this.panel10.Size = new System.Drawing.Size(40, 32); this.panel10.Size = new System.Drawing.Size(40, 32);
this.panel10.TabIndex = 9; this.panel10.TabIndex = 9;
this.panel10.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel10.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// panel11 // panel11
// //
@ -152,7 +152,7 @@
this.panel11.Name = "panel11"; this.panel11.Name = "panel11";
this.panel11.Size = new System.Drawing.Size(40, 32); this.panel11.Size = new System.Drawing.Size(40, 32);
this.panel11.TabIndex = 10; this.panel11.TabIndex = 10;
this.panel11.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel11.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// panel12 // panel12
// //
@ -161,7 +161,7 @@
this.panel12.Name = "panel12"; this.panel12.Name = "panel12";
this.panel12.Size = new System.Drawing.Size(40, 32); this.panel12.Size = new System.Drawing.Size(40, 32);
this.panel12.TabIndex = 11; this.panel12.TabIndex = 11;
this.panel12.DoubleClick += new System.EventHandler(this.panel12_DoubleClick); this.panel12.DoubleClick += new System.EventHandler(this.Panel12_DoubleClick);
// //
// label1 // label1
// //
@ -200,7 +200,7 @@
this.OK.TabIndex = 22; this.OK.TabIndex = 22;
this.OK.Text = "&OK"; this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true; this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click); this.OK.Click += new System.EventHandler(this.Ok_Click);
// //
// Cancel // Cancel
// //
@ -221,7 +221,7 @@
this.buttonInterpolateBG.TabIndex = 25; this.buttonInterpolateBG.TabIndex = 25;
this.buttonInterpolateBG.Text = "Interpolate"; this.buttonInterpolateBG.Text = "Interpolate";
this.buttonInterpolateBG.UseVisualStyleBackColor = true; this.buttonInterpolateBG.UseVisualStyleBackColor = true;
this.buttonInterpolateBG.Click += new System.EventHandler(this.button3_Click); this.buttonInterpolateBG.Click += new System.EventHandler(this.Button3_Click);
// //
// buttonInterpolateSP1 // buttonInterpolateSP1
// //
@ -231,7 +231,7 @@
this.buttonInterpolateSP1.TabIndex = 26; this.buttonInterpolateSP1.TabIndex = 26;
this.buttonInterpolateSP1.Text = "Interpolate"; this.buttonInterpolateSP1.Text = "Interpolate";
this.buttonInterpolateSP1.UseVisualStyleBackColor = true; this.buttonInterpolateSP1.UseVisualStyleBackColor = true;
this.buttonInterpolateSP1.Click += new System.EventHandler(this.button4_Click); this.buttonInterpolateSP1.Click += new System.EventHandler(this.Button4_Click);
// //
// buttonInterpolateSP2 // buttonInterpolateSP2
// //
@ -241,7 +241,7 @@
this.buttonInterpolateSP2.TabIndex = 27; this.buttonInterpolateSP2.TabIndex = 27;
this.buttonInterpolateSP2.Text = "Interpolate"; this.buttonInterpolateSP2.Text = "Interpolate";
this.buttonInterpolateSP2.UseVisualStyleBackColor = true; this.buttonInterpolateSP2.UseVisualStyleBackColor = true;
this.buttonInterpolateSP2.Click += new System.EventHandler(this.button5_Click); this.buttonInterpolateSP2.Click += new System.EventHandler(this.Button5_Click);
// //
// buttonLoad // buttonLoad
// //
@ -251,7 +251,7 @@
this.buttonLoad.TabIndex = 28; this.buttonLoad.TabIndex = 28;
this.buttonLoad.Text = "&Load..."; this.buttonLoad.Text = "&Load...";
this.buttonLoad.UseVisualStyleBackColor = true; this.buttonLoad.UseVisualStyleBackColor = true;
this.buttonLoad.Click += new System.EventHandler(this.button6_Click); this.buttonLoad.Click += new System.EventHandler(this.Button6_Click);
// //
// buttonSave // buttonSave
// //
@ -261,7 +261,7 @@
this.buttonSave.TabIndex = 29; this.buttonSave.TabIndex = 29;
this.buttonSave.Text = "&Save..."; this.buttonSave.Text = "&Save...";
this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.button7_Click); this.buttonSave.Click += new System.EventHandler(this.Button7_Click);
// //
// DefaultButton // DefaultButton
// //
@ -320,7 +320,6 @@
this.Name = "ColorChooserForm"; this.Name = "ColorChooserForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Game Boy Palette Config"; this.Text = "Game Boy Palette Config";
this.Load += new System.EventHandler(this.ColorChooserForm_Load);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.ColorChooserForm_DragDrop); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.ColorChooserForm_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.ColorChooserForm_DragEnter); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.ColorChooserForm_DragEnter);
this.ResumeLayout(false); this.ResumeLayout(false);

View File

@ -11,27 +11,23 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class ColorChooserForm : Form public partial class ColorChooserForm : Form
{ {
ColorChooserForm() private ColorChooserForm()
{ {
InitializeComponent(); InitializeComponent();
} }
private readonly Color[] colors = new Color[12]; private readonly Color[] _colors = new Color[12];
/// <summary> // gambatte's default dmg colors
/// gambatte's default dmg colors private static readonly int[] DefaultCGBColors =
/// </summary>
static readonly int[] DefaultCGBColors =
{ {
0x00ffffff, 0x00aaaaaa, 0x00555555, 0x00000000, 0x00ffffff, 0x00aaaaaa, 0x00555555, 0x00000000,
0x00ffffff, 0x00aaaaaa, 0x00555555, 0x00000000, 0x00ffffff, 0x00aaaaaa, 0x00555555, 0x00000000,
0x00ffffff, 0x00aaaaaa, 0x00555555, 0x00000000 0x00ffffff, 0x00aaaaaa, 0x00555555, 0x00000000
}; };
/// <summary> // bsnes's default dmg colors with slight tweaking
/// bsnes's default dmg colors with slight tweaking private static readonly int[] DefaultDMGColors =
/// </summary>
static readonly int[] DefaultDMGColors =
{ {
10798341, 8956165, 1922333, 337157, 10798341, 8956165, 1922333, 337157,
10798341, 8956165, 1922333, 337157, 10798341, 8956165, 1922333, 337157,
@ -40,83 +36,84 @@ namespace BizHawk.Client.EmuHawk
private void RefreshAllBackdrops() private void RefreshAllBackdrops()
{ {
panel1.BackColor = colors[0]; panel1.BackColor = _colors[0];
panel2.BackColor = colors[1]; panel2.BackColor = _colors[1];
panel3.BackColor = colors[2]; panel3.BackColor = _colors[2];
panel4.BackColor = colors[3]; panel4.BackColor = _colors[3];
panel5.BackColor = colors[4]; panel5.BackColor = _colors[4];
panel6.BackColor = colors[5]; panel6.BackColor = _colors[5];
panel7.BackColor = colors[6]; panel7.BackColor = _colors[6];
panel8.BackColor = colors[7]; panel8.BackColor = _colors[7];
panel9.BackColor = colors[8]; panel9.BackColor = _colors[8];
panel10.BackColor = colors[9]; panel10.BackColor = _colors[9];
panel11.BackColor = colors[10]; panel11.BackColor = _colors[10];
panel12.BackColor = colors[11]; panel12.BackColor = _colors[11];
} }
Color betweencolor(Color left, Color right, double pos) private Color Betweencolor(Color left, Color right, double pos)
{ {
int R = (int)(right.R * pos + left.R * (1.0 - pos) + 0.5); int r = (int)(right.R * pos + left.R * (1.0 - pos) + 0.5);
int G = (int)(right.G * pos + left.G * (1.0 - pos) + 0.5); int g = (int)(right.G * pos + left.G * (1.0 - pos) + 0.5);
int B = (int)(right.B * pos + left.B * (1.0 - pos) + 0.5); int b = (int)(right.B * pos + left.B * (1.0 - pos) + 0.5);
int A = (int)(right.A * pos + left.A * (1.0 - pos) + 0.5); int a = (int)(right.A * pos + left.A * (1.0 - pos) + 0.5);
return Color.FromArgb(A, R, G, B); return Color.FromArgb(a, r, g, b);
} }
void interpolate_colors(int firstindex, int lastindex) private void InterpolateColors(int firstindex, int lastindex)
{ {
for (int i = firstindex + 1; i < lastindex; i++) for (int i = firstindex + 1; i < lastindex; i++)
{ {
double pos = (i - firstindex) / (double)(lastindex - firstindex); double pos = (i - firstindex) / (double)(lastindex - firstindex);
colors[i] = betweencolor(colors[firstindex], colors[lastindex], pos); _colors[i] = Betweencolor(_colors[firstindex], _colors[lastindex], pos);
} }
RefreshAllBackdrops(); RefreshAllBackdrops();
} }
private void button3_Click(object sender, EventArgs e) private void Button3_Click(object sender, EventArgs e)
{ {
interpolate_colors(0, 3); InterpolateColors(0, 3);
} }
private void button4_Click(object sender, EventArgs e) private void Button4_Click(object sender, EventArgs e)
{ {
interpolate_colors(4, 7); InterpolateColors(4, 7);
} }
private void button5_Click(object sender, EventArgs e) private void Button5_Click(object sender, EventArgs e)
{ {
interpolate_colors(8, 11); InterpolateColors(8, 11);
} }
private void panel12_DoubleClick(object _sender, EventArgs e) private void Panel12_DoubleClick(object sender, EventArgs e)
{ {
Panel sender = (Panel)_sender; Panel psender = (Panel)sender;
int i; int i;
if (sender == panel1) if (psender == panel1)
i = 0; i = 0;
else if (sender == panel2) else if (psender == panel2)
i = 1; i = 1;
else if (sender == panel3) else if (psender == panel3)
i = 2; i = 2;
else if (sender == panel4) else if (psender == panel4)
i = 3; i = 3;
else if (sender == panel5) else if (psender == panel5)
i = 4; i = 4;
else if (sender == panel6) else if (psender == panel6)
i = 5; i = 5;
else if (sender == panel7) else if (psender == panel7)
i = 6; i = 6;
else if (sender == panel8) else if (psender == panel8)
i = 7; i = 7;
else if (sender == panel9) else if (psender == panel9)
i = 8; i = 8;
else if (sender == panel10) else if (psender == panel10)
i = 9; i = 9;
else if (sender == panel11) else if (psender == panel11)
i = 10; i = 10;
else if (sender == panel12) else if (psender == panel12)
i = 11; i = 11;
else else
return; // i = -1; return; // i = -1;
@ -125,14 +122,16 @@ namespace BizHawk.Client.EmuHawk
{ {
dlg.AllowFullOpen = true; dlg.AllowFullOpen = true;
dlg.AnyColor = true; dlg.AnyColor = true;
dlg.Color = colors[i]; dlg.Color = _colors[i];
// custom colors are ints, not Color structs? // custom colors are ints, not Color structs?
// and they don't work right unless the alpha bits are set to 0 // and they don't work right unless the alpha bits are set to 0
// and the rgb order is switched // and the rgb order is switched
int[] customs = new int[12]; int[] customs = new int[12];
for (int j = 0; j < customs.Length; j++) for (int j = 0; j < customs.Length; j++)
customs[j] = colors[j].R | colors[j].G << 8 | colors[j].B << 16; {
customs[j] = _colors[j].R | _colors[j].G << 8 | _colors[j].B << 16;
}
dlg.CustomColors = customs; dlg.CustomColors = customs;
dlg.FullOpen = true; dlg.FullOpen = true;
@ -141,19 +140,17 @@ namespace BizHawk.Client.EmuHawk
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
if (colors[i] != dlg.Color) if (_colors[i] != dlg.Color)
{ {
colors[i] = dlg.Color; _colors[i] = dlg.Color;
sender.BackColor = colors[i]; psender.BackColor = _colors[i];
} }
} }
} }
} }
/// <summary> // ini keys for gambatte palette file
/// ini keys for gambatte palette file private static readonly string[] Paletteinikeys =
/// </summary>
private static readonly string[] paletteinikeys =
{ {
"Background0", "Background0",
"Background1", "Background1",
@ -172,18 +169,20 @@ namespace BizHawk.Client.EmuHawk
/// <summary> /// <summary>
/// load gambatte-style .pal file /// load gambatte-style .pal file
/// </summary> /// </summary>
/// <param name="f"></param>
/// <returns>null on failure</returns> /// <returns>null on failure</returns>
public static int[] LoadPalFile(TextReader f) public static int[] LoadPalFile(TextReader f)
{ {
Dictionary<string, int> lines = new Dictionary<string, int>(); var lines = new Dictionary<string, int>();
string line; string line;
while ((line = f.ReadLine()) != null) while ((line = f.ReadLine()) != null)
{ {
int i = line.IndexOf('='); int i = line.IndexOf('=');
if (i < 0) if (i < 0)
{
continue; continue;
}
try try
{ {
lines.Add(line.Substring(0, i), int.Parse(line.Substring(i + 1))); lines.Add(line.Substring(0, i), int.Parse(line.Substring(i + 1)));
@ -197,44 +196,49 @@ namespace BizHawk.Client.EmuHawk
try try
{ {
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
ret[i] = lines[paletteinikeys[i]]; {
ret[i] = lines[Paletteinikeys[i]];
}
} }
catch (KeyNotFoundException) catch (KeyNotFoundException)
{ {
return null; return null;
} }
return ret; return ret;
} }
/// <summary> // save gambatte-style palette file
/// save gambatte-style palette file private static void SavePalFile(TextWriter f, int[] colors)
/// </summary>
/// <param name="f"></param>
/// <param name="colors"></param>
public static void SavePalFile(TextWriter f, int[] colors)
{ {
f.WriteLine("[General]"); f.WriteLine("[General]");
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
f.WriteLine(String.Format("{0}={1}", paletteinikeys[i], colors[i])); {
f.WriteLine($"{Paletteinikeys[i]}={colors[i]}");
}
} }
void SetAllColors(int[] _colors) private void SetAllColors(int[] colors)
{ {
// fix alpha to 255 in created color objects, else problems // fix alpha to 255 in created color objects, else problems
for (int i = 0; i < colors.Length; i++) for (int i = 0; i < _colors.Length; i++)
{ {
colors[i] = Color.FromArgb(255, Color.FromArgb(_colors[i])); _colors[i] = Color.FromArgb(255, Color.FromArgb(colors[i]));
} }
RefreshAllBackdrops(); RefreshAllBackdrops();
} }
static void DoColorChooserFormDialog(IWin32Window parent, Gameboy.GambatteSettings s, bool fromemu) private static void DoColorChooserFormDialog(IWin32Window parent, Gameboy.GambatteSettings s, bool fromemu)
{ {
using (var dlg = new ColorChooserForm()) using (var dlg = new ColorChooserForm())
{ {
var gb = Global.Emulator as Gameboy; var gb = Global.Emulator as Gameboy;
if (fromemu) if (fromemu)
{
s = gb.GetSettings(); s = gb.GetSettings();
}
dlg.SetAllColors(s.GBPalette); dlg.SetAllColors(s.GBPalette);
var result = dlg.ShowDialog(parent); var result = dlg.ShowDialog(parent);
@ -242,34 +246,35 @@ namespace BizHawk.Client.EmuHawk
{ {
int[] colorints = new int[12]; int[] colorints = new int[12];
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
colorints[i] = dlg.colors[i].ToArgb(); {
colorints[i] = dlg._colors[i].ToArgb();
}
s.GBPalette = colorints; s.GBPalette = colorints;
if (fromemu) if (fromemu)
{
gb.PutSettings(s); gb.PutSettings(s);
}
} }
} }
} }
public static void DoColorChooserFormDialog(IWin32Window parent)
{
DoColorChooserFormDialog(parent, null, true);
}
public static void DoColorChooserFormDialog(IWin32Window parent, Gameboy.GambatteSettings s) public static void DoColorChooserFormDialog(IWin32Window parent, Gameboy.GambatteSettings s)
{ {
DoColorChooserFormDialog(parent, s, false); DoColorChooserFormDialog(parent, s, false);
} }
void LoadColorFile(string filename, bool alert) private void LoadColorFile(string filename, bool alert)
{ {
try try
{ {
using (StreamReader f = new StreamReader(filename)) using (var f = new StreamReader(filename))
{ {
int[] newcolors = LoadPalFile(f); int[] newcolors = LoadPalFile(f);
if (newcolors == null) if (newcolors == null)
{
throw new Exception(); throw new Exception();
}
SetAllColors(newcolors); SetAllColors(newcolors);
} }
@ -277,20 +282,25 @@ namespace BizHawk.Client.EmuHawk
catch catch
{ {
if (alert) if (alert)
{
MessageBox.Show(this, "Error loading .pal file!"); MessageBox.Show(this, "Error loading .pal file!");
}
} }
} }
void SaveColorFile(string filename) private void SaveColorFile(string filename)
{ {
try try
{ {
using (StreamWriter f = new StreamWriter(filename)) using (var f = new StreamWriter(filename))
{ {
int[] savecolors = new int[12]; int[] savecolors = new int[12];
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{
// clear alpha because gambatte color files don't usually contain it // clear alpha because gambatte color files don't usually contain it
savecolors[i] = colors[i].ToArgb() & 0xffffff; savecolors[i] = _colors[i].ToArgb() & 0xffffff;
}
SavePalFile(f, savecolors); SavePalFile(f, savecolors);
} }
} }
@ -300,7 +310,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void button6_Click(object sender, EventArgs e) private void Button6_Click(object sender, EventArgs e)
{ {
using (var ofd = new OpenFileDialog()) using (var ofd = new OpenFileDialog())
{ {
@ -310,7 +320,9 @@ namespace BizHawk.Client.EmuHawk
var result = ofd.ShowDialog(this); var result = ofd.ShowDialog(this);
if (result == DialogResult.OK) if (result == DialogResult.OK)
{
LoadColorFile(ofd.FileName, true); LoadColorFile(ofd.FileName, true);
}
} }
} }
@ -318,23 +330,25 @@ namespace BizHawk.Client.EmuHawk
{ {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) if (e.Data.GetDataPresent(DataFormats.FileDrop))
{ {
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); var files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files.Length > 1) if (files.Length > 1)
{
return; return;
}
LoadColorFile(files[0], true); LoadColorFile(files[0], true);
} }
} }
private void ColorChooserForm_DragEnter(object sender, DragEventArgs e) private void ColorChooserForm_DragEnter(object sender, DragEventArgs e)
{ {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop)
e.Effect = DragDropEffects.Move; ? DragDropEffects.Move
else : DragDropEffects.None;
e.Effect = DragDropEffects.None;
} }
private void button7_Click(object sender, EventArgs e) private void Button7_Click(object sender, EventArgs e)
{ {
using (var sfd = new SaveFileDialog()) using (var sfd = new SaveFileDialog())
{ {
@ -345,11 +359,13 @@ namespace BizHawk.Client.EmuHawk
sfd.RestoreDirectory = true; sfd.RestoreDirectory = true;
var result = sfd.ShowDialog(this); var result = sfd.ShowDialog(this);
if (result == DialogResult.OK) if (result == DialogResult.OK)
{
SaveColorFile(sfd.FileName); SaveColorFile(sfd.FileName);
}
} }
} }
private void OK_Click(object sender, EventArgs e) private void Ok_Click(object sender, EventArgs e)
{ {
} }
@ -362,10 +378,5 @@ namespace BizHawk.Client.EmuHawk
{ {
SetAllColors(DefaultCGBColors); SetAllColors(DefaultCGBColors);
} }
private void ColorChooserForm_Load(object sender, EventArgs e)
{
}
} }
} }

View File

@ -1,4 +1,4 @@
namespace BizHawk.Client.EmuHawk.config.GB namespace BizHawk.Client.EmuHawk
{ {
partial class DGBPrefs partial class DGBPrefs
{ {
@ -31,9 +31,9 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DGBPrefs)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DGBPrefs));
this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage1 = new System.Windows.Forms.TabPage();
this.gbPrefControl1 = new BizHawk.Client.EmuHawk.config.GB.GBPrefControl(); this.gbPrefControl1 = new GBPrefControl();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage();
this.gbPrefControl2 = new BizHawk.Client.EmuHawk.config.GB.GBPrefControl(); this.gbPrefControl2 = new GBPrefControl();
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button(); this.buttonOK = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();

View File

@ -1,30 +1,24 @@
using System; using System.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Client.Common; using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk.config.GB namespace BizHawk.Client.EmuHawk
{ {
public partial class DGBPrefs : Form public partial class DGBPrefs : Form
{ {
DGBPrefs() private DGBPrefs()
{ {
InitializeComponent(); InitializeComponent();
} }
void PutSettings(GambatteLink.GambatteLinkSettings s, GambatteLink.GambatteLinkSyncSettings ss) private void PutSettings(GambatteLink.GambatteLinkSettings s, GambatteLink.GambatteLinkSyncSettings ss)
{ {
gbPrefControl1.PutSettings(s.L, ss.L); gbPrefControl1.PutSettings(s.L, ss.L);
gbPrefControl2.PutSettings(s.R, ss.R); gbPrefControl2.PutSettings(s.R, ss.R);
} }
void GetSettings(out GambatteLink.GambatteLinkSettings s, out GambatteLink.GambatteLinkSyncSettings ss) private void GetSettings(out GambatteLink.GambatteLinkSettings s, out GambatteLink.GambatteLinkSyncSettings ss)
{ {
Gameboy.GambatteSettings sl; Gameboy.GambatteSettings sl;
Gameboy.GambatteSyncSettings ssl; Gameboy.GambatteSyncSettings ssl;
@ -37,13 +31,7 @@ namespace BizHawk.Client.EmuHawk.config.GB
ss = new GambatteLink.GambatteLinkSyncSettings(ssl, ssr); ss = new GambatteLink.GambatteLinkSyncSettings(ssl, ssr);
} }
private bool SyncSettingsChanged private bool SyncSettingsChanged => gbPrefControl1.SyncSettingsChanged || gbPrefControl2.SyncSettingsChanged;
{
get
{
return gbPrefControl1.SyncSettingsChanged || gbPrefControl2.SyncSettingsChanged;
}
}
public static void DoDGBPrefsDialog(IWin32Window owner) public static void DoDGBPrefsDialog(IWin32Window owner)
{ {
@ -64,7 +52,9 @@ namespace BizHawk.Client.EmuHawk.config.GB
dlg.GetSettings(out s, out ss); dlg.GetSettings(out s, out ss);
gambatte.PutSettings(s); gambatte.PutSettings(s);
if (dlg.SyncSettingsChanged) if (dlg.SyncSettingsChanged)
{
GlobalWin.MainForm.PutCoreSyncSettings(ss); GlobalWin.MainForm.PutCoreSyncSettings(ss);
}
} }
} }
} }

View File

@ -1,4 +1,4 @@
namespace BizHawk.Client.EmuHawk.config.GB namespace BizHawk.Client.EmuHawk
{ {
partial class GBPrefControl partial class GBPrefControl
{ {
@ -48,7 +48,7 @@
this.propertyGrid1.Size = new System.Drawing.Size(338, 279); this.propertyGrid1.Size = new System.Drawing.Size(338, 279);
this.propertyGrid1.TabIndex = 0; this.propertyGrid1.TabIndex = 0;
this.propertyGrid1.ToolbarVisible = false; this.propertyGrid1.ToolbarVisible = false;
this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid1_PropertyValueChanged); this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.PropertyGrid1_PropertyValueChanged);
// //
// buttonDefaults // buttonDefaults
// //
@ -59,7 +59,7 @@
this.buttonDefaults.TabIndex = 1; this.buttonDefaults.TabIndex = 1;
this.buttonDefaults.Text = "Defaults"; this.buttonDefaults.Text = "Defaults";
this.buttonDefaults.UseVisualStyleBackColor = true; this.buttonDefaults.UseVisualStyleBackColor = true;
this.buttonDefaults.Click += new System.EventHandler(this.buttonDefaults_Click); this.buttonDefaults.Click += new System.EventHandler(this.ButtonDefaults_Click);
// //
// buttonPalette // buttonPalette
// //
@ -70,7 +70,7 @@
this.buttonPalette.TabIndex = 2; this.buttonPalette.TabIndex = 2;
this.buttonPalette.Text = "Palette..."; this.buttonPalette.Text = "Palette...";
this.buttonPalette.UseVisualStyleBackColor = true; this.buttonPalette.UseVisualStyleBackColor = true;
this.buttonPalette.Click += new System.EventHandler(this.buttonPalette_Click); this.buttonPalette.Click += new System.EventHandler(this.ButtonPalette_Click);
// //
// checkBoxMuted // checkBoxMuted
// //
@ -82,7 +82,7 @@
this.checkBoxMuted.TabIndex = 3; this.checkBoxMuted.TabIndex = 3;
this.checkBoxMuted.Text = "Mute"; this.checkBoxMuted.Text = "Mute";
this.checkBoxMuted.UseVisualStyleBackColor = true; this.checkBoxMuted.UseVisualStyleBackColor = true;
this.checkBoxMuted.CheckedChanged += new System.EventHandler(this.checkBoxMuted_CheckedChanged); this.checkBoxMuted.CheckedChanged += new System.EventHandler(this.CheckBoxMuted_CheckedChanged);
// //
// cbDisplayBG // cbDisplayBG
// //
@ -94,7 +94,7 @@
this.cbDisplayBG.TabIndex = 4; this.cbDisplayBG.TabIndex = 4;
this.cbDisplayBG.Text = "BG"; this.cbDisplayBG.Text = "BG";
this.cbDisplayBG.UseVisualStyleBackColor = true; this.cbDisplayBG.UseVisualStyleBackColor = true;
this.cbDisplayBG.CheckedChanged += new System.EventHandler(this.cbDisplayBG_CheckedChanged); this.cbDisplayBG.CheckedChanged += new System.EventHandler(this.CbDisplayBG_CheckedChanged);
// //
// cbDisplayOBJ // cbDisplayOBJ
// //
@ -106,7 +106,7 @@
this.cbDisplayOBJ.TabIndex = 5; this.cbDisplayOBJ.TabIndex = 5;
this.cbDisplayOBJ.Text = "OBJ"; this.cbDisplayOBJ.Text = "OBJ";
this.cbDisplayOBJ.UseVisualStyleBackColor = true; this.cbDisplayOBJ.UseVisualStyleBackColor = true;
this.cbDisplayOBJ.CheckedChanged += new System.EventHandler(this.cbDisplayOBJ_CheckedChanged); this.cbDisplayOBJ.CheckedChanged += new System.EventHandler(this.CbDisplayOBJ_CheckedChanged);
// //
// cbDisplayWIN // cbDisplayWIN
// //
@ -118,7 +118,7 @@
this.cbDisplayWIN.TabIndex = 6; this.cbDisplayWIN.TabIndex = 6;
this.cbDisplayWIN.Text = "WIN"; this.cbDisplayWIN.Text = "WIN";
this.cbDisplayWIN.UseVisualStyleBackColor = true; this.cbDisplayWIN.UseVisualStyleBackColor = true;
this.cbDisplayWIN.CheckedChanged += new System.EventHandler(this.cbDisplayWIN_CheckedChanged); this.cbDisplayWIN.CheckedChanged += new System.EventHandler(this.CbDisplayWin_CheckedChanged);
// //
// GBPrefControl // GBPrefControl
// //

View File

@ -1,16 +1,11 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Client.Common; using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk.config.GB namespace BizHawk.Client.EmuHawk
{ {
public partial class GBPrefControl : UserControl public partial class GBPrefControl : UserControl
{ {
@ -21,68 +16,75 @@ namespace BizHawk.Client.EmuHawk.config.GB
[Browsable(false)] [Browsable(false)]
public bool ColorGameBoy { get; set; } public bool ColorGameBoy { get; set; }
[Browsable(false)] [Browsable(false)]
public bool SyncSettingsChanged { get; private set; } public bool SyncSettingsChanged { get; private set; }
Gameboy.GambatteSettings s; private Gameboy.GambatteSettings _s;
Gameboy.GambatteSyncSettings ss; private Gameboy.GambatteSyncSettings _ss;
public void PutSettings(Gameboy.GambatteSettings s, Gameboy.GambatteSyncSettings ss) public void PutSettings(Gameboy.GambatteSettings s, Gameboy.GambatteSyncSettings ss)
{ {
this.s = s ?? new Gameboy.GambatteSettings(); _s = s ?? new Gameboy.GambatteSettings();
this.ss = ss ?? new Gameboy.GambatteSyncSettings(); _ss = ss ?? new Gameboy.GambatteSyncSettings();
propertyGrid1.SelectedObject = this.ss; propertyGrid1.SelectedObject = _ss;
propertyGrid1.Enabled = !Global.MovieSession.Movie.IsActive; propertyGrid1.Enabled = !Global.MovieSession.Movie.IsActive;
checkBoxMuted.Checked = this.s.Muted; checkBoxMuted.Checked = _s.Muted;
cbDisplayBG.Checked = this.s.DisplayBG; cbDisplayBG.Checked = _s.DisplayBG;
cbDisplayOBJ.Checked = this.s.DisplayOBJ; cbDisplayOBJ.Checked = _s.DisplayOBJ;
cbDisplayWIN.Checked = this.s.DisplayWindow; cbDisplayWIN.Checked = _s.DisplayWindow;
} }
public void GetSettings(out Gameboy.GambatteSettings s, out Gameboy.GambatteSyncSettings ss) public void GetSettings(out Gameboy.GambatteSettings s, out Gameboy.GambatteSyncSettings ss)
{ {
s = this.s; s = _s;
ss = this.ss; ss = _ss;
} }
private void buttonDefaults_Click(object sender, EventArgs e) private void ButtonDefaults_Click(object sender, EventArgs e)
{ {
PutSettings(null, Global.MovieSession.Movie.IsActive ? ss : null); PutSettings(null, Global.MovieSession.Movie.IsActive ? _ss : null);
if (!Global.MovieSession.Movie.IsActive) if (!Global.MovieSession.Movie.IsActive)
{
SyncSettingsChanged = true; SyncSettingsChanged = true;
}
} }
private void buttonPalette_Click(object sender, EventArgs e) private void ButtonPalette_Click(object sender, EventArgs e)
{ {
if (ColorGameBoy) if (ColorGameBoy)
CGBColorChooserForm.DoCGBColorChoserFormDialog(this.ParentForm, s); {
CGBColorChooserForm.DoCGBColorChoserFormDialog(ParentForm, _s);
}
else else
ColorChooserForm.DoColorChooserFormDialog(this.ParentForm, s); {
ColorChooserForm.DoColorChooserFormDialog(ParentForm, _s);
}
} }
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) private void PropertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{ {
SyncSettingsChanged = true; SyncSettingsChanged = true;
} }
private void checkBoxMuted_CheckedChanged(object sender, EventArgs e) private void CheckBoxMuted_CheckedChanged(object sender, EventArgs e)
{ {
s.Muted = (sender as CheckBox).Checked; _s.Muted = ((CheckBox)sender).Checked;
} }
private void cbDisplayBG_CheckedChanged(object sender, EventArgs e) private void CbDisplayBG_CheckedChanged(object sender, EventArgs e)
{ {
s.DisplayBG = (sender as CheckBox).Checked; _s.DisplayBG = ((CheckBox)sender).Checked;
} }
private void cbDisplayOBJ_CheckedChanged(object sender, EventArgs e) private void CbDisplayOBJ_CheckedChanged(object sender, EventArgs e)
{ {
s.DisplayOBJ = (sender as CheckBox).Checked; _s.DisplayOBJ = ((CheckBox)sender).Checked;
} }
private void cbDisplayWIN_CheckedChanged(object sender, EventArgs e) private void CbDisplayWin_CheckedChanged(object sender, EventArgs e)
{ {
s.DisplayWindow = (sender as CheckBox).Checked; _s.DisplayWindow = ((CheckBox)sender).Checked;
} }
} }
} }

View File

@ -1,4 +1,4 @@
namespace BizHawk.Client.EmuHawk.config.GB namespace BizHawk.Client.EmuHawk
{ {
partial class GBPrefs partial class GBPrefs
{ {
@ -31,7 +31,7 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GBPrefs)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GBPrefs));
this.buttonOK = new System.Windows.Forms.Button(); this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.gbPrefControl1 = new BizHawk.Client.EmuHawk.config.GB.GBPrefControl(); this.gbPrefControl1 = new GBPrefControl();
this.SuspendLayout(); this.SuspendLayout();
// //
// buttonOK // buttonOK

View File

@ -1,26 +1,20 @@
using System; using System.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Client.Common; using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk.config.GB namespace BizHawk.Client.EmuHawk
{ {
public partial class GBPrefs : Form public partial class GBPrefs : Form
{ {
public GBPrefs() private GBPrefs()
{ {
InitializeComponent(); InitializeComponent();
} }
public static void DoGBPrefsDialog(IWin32Window owner) public static void DoGBPrefsDialog(IWin32Window owner)
{ {
var gb = ((Gameboy)Global.Emulator); var gb = (Gameboy)Global.Emulator;
var s = gb.GetSettings(); var s = gb.GetSettings();
var ss = gb.GetSyncSettings(); var ss = gb.GetSyncSettings();
@ -33,7 +27,9 @@ namespace BizHawk.Client.EmuHawk.config.GB
dlg.gbPrefControl1.GetSettings(out s, out ss); dlg.gbPrefControl1.GetSettings(out s, out ss);
gb.PutSettings(s); gb.PutSettings(s);
if (dlg.gbPrefControl1.SyncSettingsChanged) if (dlg.gbPrefControl1.SyncSettingsChanged)
{
GlobalWin.MainForm.PutCoreSyncSettings(ss); GlobalWin.MainForm.PutCoreSyncSettings(ss);
}
} }
} }
} }

View File

@ -1,10 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;

View File

@ -187,21 +187,21 @@
this.clearAllToolStripMenuItem.Name = "clearAllToolStripMenuItem"; this.clearAllToolStripMenuItem.Name = "clearAllToolStripMenuItem";
this.clearAllToolStripMenuItem.Size = new System.Drawing.Size(167, 22); this.clearAllToolStripMenuItem.Size = new System.Drawing.Size(167, 22);
this.clearAllToolStripMenuItem.Text = "Clear All"; this.clearAllToolStripMenuItem.Text = "Clear All";
this.clearAllToolStripMenuItem.Click += new System.EventHandler(this.clearAllToolStripMenuItem_Click); this.clearAllToolStripMenuItem.Click += new System.EventHandler(this.ClearAllToolStripMenuItem_Click);
// //
// clearCurrentTabToolStripMenuItem // clearCurrentTabToolStripMenuItem
// //
this.clearCurrentTabToolStripMenuItem.Name = "clearCurrentTabToolStripMenuItem"; this.clearCurrentTabToolStripMenuItem.Name = "clearCurrentTabToolStripMenuItem";
this.clearCurrentTabToolStripMenuItem.Size = new System.Drawing.Size(167, 22); this.clearCurrentTabToolStripMenuItem.Size = new System.Drawing.Size(167, 22);
this.clearCurrentTabToolStripMenuItem.Text = "Clear Current Tab"; this.clearCurrentTabToolStripMenuItem.Text = "Clear Current Tab";
this.clearCurrentTabToolStripMenuItem.Click += new System.EventHandler(this.clearCurrentTabToolStripMenuItem_Click); this.clearCurrentTabToolStripMenuItem.Click += new System.EventHandler(this.ClearCurrentTabToolStripMenuItem_Click);
// //
// restoreDefaultsToolStripMenuItem // restoreDefaultsToolStripMenuItem
// //
this.restoreDefaultsToolStripMenuItem.Name = "restoreDefaultsToolStripMenuItem"; this.restoreDefaultsToolStripMenuItem.Name = "restoreDefaultsToolStripMenuItem";
this.restoreDefaultsToolStripMenuItem.Size = new System.Drawing.Size(167, 22); this.restoreDefaultsToolStripMenuItem.Size = new System.Drawing.Size(167, 22);
this.restoreDefaultsToolStripMenuItem.Text = "Restore Defaults"; this.restoreDefaultsToolStripMenuItem.Text = "Restore Defaults";
this.restoreDefaultsToolStripMenuItem.Click += new System.EventHandler(this.restoreDefaultsToolStripMenuItem_Click); this.restoreDefaultsToolStripMenuItem.Click += new System.EventHandler(this.RestoreDefaultsToolStripMenuItem_Click);
// //
// toolStripSeparator1 // toolStripSeparator1
// //

View File

@ -100,10 +100,10 @@ namespace BizHawk.Client.EmuHawk
{ {
HotkeyTabControl.TabPages.Clear(); HotkeyTabControl.TabPages.Clear();
//Buckets // Buckets
var Tabs = Global.Config.HotkeyBindings.Select(x => x.TabGroup).Distinct().ToList(); var tabs = Global.Config.HotkeyBindings.Select(x => x.TabGroup).Distinct().ToList();
foreach (var tab in Tabs) foreach (var tab in tabs)
{ {
var _y = UIHelper.ScaleY(14); var _y = UIHelper.ScaleY(14);
var _x = UIHelper.ScaleX(6); var _x = UIHelper.ScaleX(6);
@ -167,7 +167,10 @@ namespace BizHawk.Client.EmuHawk
foreach (var w in InputWidgets) foreach (var w in InputWidgets)
{ {
var b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == w.WidgetName); var b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == w.WidgetName);
if (b != null) w.Bindings = b.DefaultBinding; if (b != null)
{
w.Bindings = b.DefaultBinding;
}
} }
} }
@ -216,19 +219,19 @@ namespace BizHawk.Client.EmuHawk
private void SearchBox_KeyDown(object sender, KeyEventArgs e) private void SearchBox_KeyDown(object sender, KeyEventArgs e)
{ {
//Tab or Enter // Tab or Enter
if (!e.Control && !e.Alt && !e.Shift && if (!e.Control && !e.Alt && !e.Shift &&
(e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab)) (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab))
{ {
var b = Global.Config.HotkeyBindings.FirstOrDefault(x => string.Compare(x.DisplayName,SearchBox.Text,true)==0); var b = Global.Config.HotkeyBindings.FirstOrDefault(x => string.Compare(x.DisplayName, SearchBox.Text, true) == 0);
//Found // Found
if (b != null) if (b != null)
{ {
var w = InputWidgets.FirstOrDefault(x => x.WidgetName == b.DisplayName); var w = InputWidgets.FirstOrDefault(x => x.WidgetName == b.DisplayName);
if (w != null) if (w != null)
{ {
HotkeyTabControl.SelectTab((w.Parent as TabPage)); HotkeyTabControl.SelectTab((TabPage)w.Parent);
Input.Instance.BindUnpress(e.KeyCode); Input.Instance.BindUnpress(e.KeyCode);
w.Focus(); w.Focus();
} }
@ -238,17 +241,17 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void clearAllToolStripMenuItem_Click(object sender, EventArgs e) private void ClearAllToolStripMenuItem_Click(object sender, EventArgs e)
{ {
ClearAll(true); ClearAll(true);
} }
private void clearCurrentTabToolStripMenuItem_Click(object sender, EventArgs e) private void ClearCurrentTabToolStripMenuItem_Click(object sender, EventArgs e)
{ {
ClearAll(false); ClearAll(false);
} }
private void restoreDefaultsToolStripMenuItem_Click(object sender, EventArgs e) private void RestoreDefaultsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Defaults(); Defaults();
} }

View File

@ -19,7 +19,7 @@
} }
base.Dispose(disposing); base.Dispose(disposing);
DropdownMenu.Dispose(); _dropdownMenu.Dispose();
} }
#region Component Designer generated code #region Component Designer generated code
@ -46,7 +46,7 @@
this.btnSpecial.Size = new System.Drawing.Size(20, 20); this.btnSpecial.Size = new System.Drawing.Size(20, 20);
this.btnSpecial.TabIndex = 2; this.btnSpecial.TabIndex = 2;
this.btnSpecial.UseVisualStyleBackColor = true; this.btnSpecial.UseVisualStyleBackColor = true;
this.btnSpecial.Click += new System.EventHandler(this.btnSpecial_Click); this.btnSpecial.Click += new System.EventHandler(this.BtnSpecial_Click);
// //
// tableLayoutPanel1 // tableLayoutPanel1
// //

View File

@ -1,10 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
@ -15,25 +9,24 @@ namespace BizHawk.Client.EmuHawk
{ {
InitializeComponent(); InitializeComponent();
DropdownMenu = new ContextMenuStrip(); _dropdownMenu = new ContextMenuStrip();
DropdownMenu.ItemClicked += new ToolStripItemClickedEventHandler(DropdownMenu_ItemClicked); _dropdownMenu.ItemClicked += DropdownMenu_ItemClicked;
DropdownMenu.PreviewKeyDown += new PreviewKeyDownEventHandler(DropdownMenu_PreviewKeyDown); _dropdownMenu.PreviewKeyDown += DropdownMenu_PreviewKeyDown;
foreach (var spec in InputWidget.SpecialBindings) foreach (var spec in InputWidget.SpecialBindings)
{ {
var tsi = new ToolStripMenuItem(spec.BindingName); var tsi = new ToolStripMenuItem(spec.BindingName) { ToolTipText = spec.TooltipText };
tsi.ToolTipText = spec.TooltipText; _dropdownMenu.Items.Add(tsi);
DropdownMenu.Items.Add(tsi);
} }
btnSpecial.ContextMenuStrip = DropdownMenu; btnSpecial.ContextMenuStrip = _dropdownMenu;
widget.CompositeWidget = this; widget.CompositeWidget = this;
} }
static readonly string WidgetTooltipText = "* Escape clears a key mapping\r\n* Disable Auto Tab to multiply bind"; private static readonly string WidgetTooltipText = "* Escape clears a key mapping\r\n* Disable Auto Tab to multiply bind";
ToolTip _tooltip; private ToolTip _tooltip;
string _bindingTooltipText; private string _bindingTooltipText;
public void SetupTooltip(ToolTip tip, string bindingText) public void SetupTooltip(ToolTip tip, string bindingText)
{ {
@ -47,16 +40,21 @@ namespace BizHawk.Client.EmuHawk
{ {
string widgetText = "Current Binding: " + widget.Text; string widgetText = "Current Binding: " + widget.Text;
if (_bindingTooltipText != null) if (_bindingTooltipText != null)
{
widgetText = widgetText + "\r\n---\r\n" + _bindingTooltipText; widgetText = widgetText + "\r\n---\r\n" + _bindingTooltipText;
}
widgetText = widgetText + "\r\n---\r\n" + WidgetTooltipText; widgetText = widgetText + "\r\n---\r\n" + WidgetTooltipText;
_tooltip.SetToolTip(widget, widgetText); _tooltip.SetToolTip(widget, widgetText);
} }
void DropdownMenu_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) private void DropdownMenu_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{ {
//suppress handling of ALT keys, so that we can receive them as binding modifiers // suppress handling of ALT keys, so that we can receive them as binding modifiers
if (e.KeyCode == Keys.Menu) if (e.KeyCode == Keys.Menu)
{
e.IsInputKey = true; e.IsInputKey = true;
}
} }
public void TabNext() public void TabNext()
@ -64,7 +62,7 @@ namespace BizHawk.Client.EmuHawk
Parent.SelectNextControl(btnSpecial, true, true, true, true); Parent.SelectNextControl(btnSpecial, true, true, true, true);
} }
ContextMenuStrip DropdownMenu; private readonly ContextMenuStrip _dropdownMenu;
public bool AutoTab { get { return widget.AutoTab; } set { widget.AutoTab = value; } } public bool AutoTab { get { return widget.AutoTab; } set { widget.AutoTab = value; } }
public string WidgetName { get { return widget.WidgetName; } set { widget.WidgetName = value; } } public string WidgetName { get { return widget.WidgetName; } set { widget.WidgetName = value; } }
@ -76,23 +74,31 @@ namespace BizHawk.Client.EmuHawk
widget.ClearAll(); widget.ClearAll();
} }
private void btnSpecial_Click(object sender, EventArgs e) private void BtnSpecial_Click(object sender, EventArgs e)
{ {
DropdownMenu.Show(Control.MousePosition); _dropdownMenu.Show(MousePosition);
} }
void DropdownMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) private void DropdownMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{ {
Input.ModifierKey mods = new Input.ModifierKey(); Input.ModifierKey mods = new Input.ModifierKey();
if ((Control.ModifierKeys & Keys.Shift) != 0)
mods |= Input.ModifierKey.Shift;
if ((Control.ModifierKeys & Keys.Control) != 0)
mods |= Input.ModifierKey.Control;
if ((Control.ModifierKeys & Keys.Alt) != 0)
mods |= Input.ModifierKey.Alt;
Input.LogicalButton lb = new Input.LogicalButton(e.ClickedItem.Text,mods); if ((ModifierKeys & Keys.Shift) != 0)
{
mods |= Input.ModifierKey.Shift;
}
if ((ModifierKeys & Keys.Control) != 0)
{
mods |= Input.ModifierKey.Control;
}
if ((ModifierKeys & Keys.Alt) != 0)
{
mods |= Input.ModifierKey.Alt;
}
var lb = new Input.LogicalButton(e.ClickedItem.Text, mods);
widget.SetBinding(lb.ToString()); widget.SetBinding(lb.ToString());
} }

View File

@ -15,27 +15,27 @@ namespace BizHawk.Client.EmuHawk
private string _wasPressed = ""; private string _wasPressed = "";
public InputCompositeWidget CompositeWidget; public InputCompositeWidget CompositeWidget { get; set; }
public class SpecialBindingInfo public class SpecialBindingInfo
{ {
public string BindingName; public string BindingName { get; set; }
public string TooltipText; public string TooltipText { get; set; }
} }
/// <summary> /// <summary>
/// These bindings get ignored by the widget and can only be entered by SetBinding() via the contextmenu from the InputCompositeWidget /// These bindings get ignored by the widget and can only be entered by SetBinding() via the context menu from the InputCompositeWidget
/// </summary> /// </summary>
public static readonly SpecialBindingInfo[] SpecialBindings = { public static readonly SpecialBindingInfo[] SpecialBindings =
new SpecialBindingInfo { BindingName = "Escape", TooltipText = "Binds the Escape key" }, {
new SpecialBindingInfo { BindingName = "WMouse L", TooltipText = "Binds the left mouse button"}, new SpecialBindingInfo { BindingName = "Escape", TooltipText = "Binds the Escape key" },
new SpecialBindingInfo { BindingName = "WMouse M", TooltipText = "Binds the middle mouse button"}, new SpecialBindingInfo { BindingName = "WMouse L", TooltipText = "Binds the left mouse button" },
new SpecialBindingInfo { BindingName = "WMouse R", TooltipText = "Binds the right mouse button"}, new SpecialBindingInfo { BindingName = "WMouse M", TooltipText = "Binds the middle mouse button" },
new SpecialBindingInfo { BindingName = "WMouse 1", TooltipText = "Binds the mouse auxiliary button 1" }, new SpecialBindingInfo { BindingName = "WMouse R", TooltipText = "Binds the right mouse button" },
new SpecialBindingInfo { BindingName = "WMouse 2", TooltipText = "Binds the mouse auxiliary button 2" }, new SpecialBindingInfo { BindingName = "WMouse 1", TooltipText = "Binds the mouse auxiliary button 1" },
new SpecialBindingInfo { BindingName = "WMouse 2", TooltipText = "Binds the mouse auxiliary button 2" }
}; };
public InputWidget() public InputWidget()
{ {
ContextMenu = new ContextMenu(); ContextMenu = new ContextMenu();
@ -45,7 +45,6 @@ namespace BizHawk.Client.EmuHawk
Cursor = Cursors.Arrow; Cursor = Cursors.Arrow;
} }
public bool AutoTab { get; set; } public bool AutoTab { get; set; }
public string WidgetName { get; set; } public string WidgetName { get; set; }
@ -106,7 +105,7 @@ namespace BizHawk.Client.EmuHawk
ReadKeys(); ReadKeys();
} }
public void EraseMappings() private void EraseMappings()
{ {
ClearBindings(); ClearBindings();
Text = ""; Text = "";
@ -136,9 +135,8 @@ namespace BizHawk.Client.EmuHawk
if (bindingStr != null) if (bindingStr != null)
{ {
// has special meaning for the binding UI system (clear it).
//has special meaning for the binding UI system (clear it). // you can set it through the special bindings dropdown menu
//you can set it through the special bindings dropdown menu
if (bindingStr == "Escape") if (bindingStr == "Escape")
{ {
EraseMappings(); EraseMappings();
@ -146,16 +144,20 @@ namespace BizHawk.Client.EmuHawk
return; return;
} }
//seriously, we refuse to allow you to bind this to anything else. // seriously, we refuse to allow you to bind this to anything else.
if (bindingStr == "Alt+F4") if (bindingStr == "Alt+F4")
{ {
return; return;
} }
//ignore special bindings // ignore special bindings
foreach(var spec in SpecialBindings) foreach (var spec in SpecialBindings)
if(spec.BindingName == bindingStr) {
if (spec.BindingName == bindingStr)
{
return; return;
}
}
if (!IsDuplicate(bindingStr)) if (!IsDuplicate(bindingStr))
{ {

View File

@ -98,7 +98,7 @@
this.OK.TabIndex = 1; this.OK.TabIndex = 1;
this.OK.Text = "&OK"; this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true; this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click); this.OK.Click += new System.EventHandler(this.Ok_Click);
// //
// MessageTypeBox // MessageTypeBox
// //

View File

@ -55,7 +55,7 @@ namespace BizHawk.Client.EmuHawk
private void MessageConfig_Load(object sender, EventArgs e) private void MessageConfig_Load(object sender, EventArgs e)
{ {
SetMaxXY(); SetMaxXy();
MessageColorDialog.Color = Color.FromArgb(_messageColor); MessageColorDialog.Color = Color.FromArgb(_messageColor);
AlertColorDialog.Color = Color.FromArgb(_alertColor); AlertColorDialog.Color = Color.FromArgb(_alertColor);
LInputColorDialog.Color = Color.FromArgb(_lastInputColor); LInputColorDialog.Color = Color.FromArgb(_lastInputColor);
@ -65,7 +65,7 @@ namespace BizHawk.Client.EmuHawk
StackMessagesCheckbox.Checked = Global.Config.StackOSDMessages; StackMessagesCheckbox.Checked = Global.Config.StackOSDMessages;
} }
private void SetMaxXY() private void SetMaxXy()
{ {
var video = Global.Emulator.AsVideoProvider(); // TODO: this is objectively wrong, these are core agnostic settings, why is the current core used here? Also this will crash on a core without a video provider var video = Global.Emulator.AsVideoProvider(); // TODO: this is objectively wrong, these are core agnostic settings, why is the current core used here? Also this will crash on a core without a video provider
XNumeric.Maximum = video.BufferWidth - 12; XNumeric.Maximum = video.BufferWidth - 12;
@ -81,19 +81,19 @@ namespace BizHawk.Client.EmuHawk
{ {
_messageColor = MessageColorDialog.Color.ToArgb(); _messageColor = MessageColorDialog.Color.ToArgb();
ColorPanel.BackColor = MessageColorDialog.Color; ColorPanel.BackColor = MessageColorDialog.Color;
ColorText.Text = String.Format("{0:X8}", _messageColor); ColorText.Text = $"{_messageColor:X8}";
_alertColor = AlertColorDialog.Color.ToArgb(); _alertColor = AlertColorDialog.Color.ToArgb();
AlertColorPanel.BackColor = AlertColorDialog.Color; AlertColorPanel.BackColor = AlertColorDialog.Color;
AlertColorText.Text = String.Format("{0:X8}", _alertColor); AlertColorText.Text = $"{_alertColor:X8}";
_lastInputColor = LInputColorDialog.Color.ToArgb(); _lastInputColor = LInputColorDialog.Color.ToArgb();
LInputColorPanel.BackColor = LInputColorDialog.Color; LInputColorPanel.BackColor = LInputColorDialog.Color;
LInputText.Text = String.Format("{0:X8}", _lastInputColor); LInputText.Text = $"{_lastInputColor:X8}";
_movieInput = MovieInputColorDialog.Color.ToArgb(); _movieInput = MovieInputColorDialog.Color.ToArgb();
MovieInputColor.BackColor = MovieInputColorDialog.Color; MovieInputColor.BackColor = MovieInputColorDialog.Color;
MovieInputText.Text = String.Format("{0:X8}", _movieInput); MovieInputText.Text = $"{_movieInput:X8}";
} }
private void SetAnchorRadio(int anchor) private void SetAnchorRadio(int anchor)
@ -102,13 +102,17 @@ namespace BizHawk.Client.EmuHawk
{ {
default: default:
case 0: case 0:
TL.Checked = true; break; TL.Checked = true;
break;
case 1: case 1:
TR.Checked = true; break; TR.Checked = true;
break;
case 2: case 2:
BL.Checked = true; break; BL.Checked = true;
break;
case 3: case 3:
BR.Checked = true; break; BR.Checked = true;
break;
} }
} }
@ -230,7 +234,7 @@ namespace BizHawk.Client.EmuHawk
Global.Config.StackOSDMessages = StackMessagesCheckbox.Checked; Global.Config.StackOSDMessages = StackMessagesCheckbox.Checked;
} }
private void OK_Click(object sender, EventArgs e) private void Ok_Click(object sender, EventArgs e)
{ {
SaveSettings(); SaveSettings();
GlobalWin.OSD.AddMessage("Message settings saved"); GlobalWin.OSD.AddMessage("Message settings saved");
@ -324,10 +328,9 @@ namespace BizHawk.Client.EmuHawk
if (mx > XNumeric.Maximum) mx = (int)XNumeric.Maximum; if (mx > XNumeric.Maximum) mx = (int)XNumeric.Maximum;
if (my > YNumeric.Maximum) my = (int)YNumeric.Maximum; if (my > YNumeric.Maximum) my = (int)YNumeric.Maximum;
if (TL.Checked) if (TL.Checked)
{ {
//Do nothing // Do nothing
} }
else if (TR.Checked) else if (TR.Checked)
{ {
@ -488,7 +491,7 @@ namespace BizHawk.Client.EmuHawk
LInputColorDialog.Color = Color.FromArgb(_lastInputColor); LInputColorDialog.Color = Color.FromArgb(_lastInputColor);
MovieInputColorDialog.Color = Color.FromArgb(_movieInput); MovieInputColorDialog.Color = Color.FromArgb(_movieInput);
SetMaxXY(); SetMaxXy();
SetColorBox(); SetColorBox();
SetPositionInfo(); SetPositionInfo();
@ -541,6 +544,7 @@ namespace BizHawk.Client.EmuHawk
{ {
SetAnchorValue(0); SetAnchorValue(0);
} }
PositionPanel.Refresh(); PositionPanel.Refresh();
} }
@ -550,6 +554,7 @@ namespace BizHawk.Client.EmuHawk
{ {
SetAnchorValue(1); SetAnchorValue(1);
} }
PositionPanel.Refresh(); PositionPanel.Refresh();
} }

View File

@ -75,7 +75,6 @@
this.Controls.Add(this.EnabledCheckbox); this.Controls.Add(this.EnabledCheckbox);
this.Name = "N64ControllerSettingControl"; this.Name = "N64ControllerSettingControl";
this.Size = new System.Drawing.Size(290, 22); this.Size = new System.Drawing.Size(290, 22);
this.Load += new System.EventHandler(this.N64ControllerSettingControl_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@ -1,13 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Common;
using BizHawk.Common.ReflectionExtensions; using BizHawk.Common.ReflectionExtensions;
using BizHawk.Emulation.Cores.Nintendo.N64; using BizHawk.Emulation.Cores.Nintendo.N64;
@ -25,17 +19,13 @@ namespace BizHawk.Client.EmuHawk
ControllerNameLabel.Text = "Controller " + ControllerNumber; ControllerNameLabel.Text = "Controller " + ControllerNumber;
} }
private void N64ControllerSettingControl_Load(object sender, EventArgs e)
{
}
public int ControllerNumber public int ControllerNumber
{ {
get get
{ {
return _controllerNumber; return _controllerNumber;
} }
set set
{ {
_controllerNumber = value; _controllerNumber = value;

View File

@ -1,10 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Cores.Nintendo.N64; using BizHawk.Emulation.Cores.Nintendo.N64;

View File

@ -905,7 +905,7 @@
this.RiceAnisotropicFiltering_TB.Size = new System.Drawing.Size(121, 25); this.RiceAnisotropicFiltering_TB.Size = new System.Drawing.Size(121, 25);
this.RiceAnisotropicFiltering_TB.TabIndex = 13; this.RiceAnisotropicFiltering_TB.TabIndex = 13;
this.toolTip1.SetToolTip(this.RiceAnisotropicFiltering_TB, resources.GetString("RiceAnisotropicFiltering_TB.ToolTip")); this.toolTip1.SetToolTip(this.RiceAnisotropicFiltering_TB, resources.GetString("RiceAnisotropicFiltering_TB.ToolTip"));
this.RiceAnisotropicFiltering_TB.Scroll += new System.EventHandler(this.RiceAnisotropicFiltering_TB_Scroll_1); this.RiceAnisotropicFiltering_TB.Scroll += new System.EventHandler(this.RiceAnisotropicFiltering_Tb_Scroll_1);
// //
// label6 // label6
// //
@ -1839,7 +1839,7 @@
this.RiceUseDefaultHacks_CB.TabIndex = 1; this.RiceUseDefaultHacks_CB.TabIndex = 1;
this.RiceUseDefaultHacks_CB.Text = "Use defaults for current game"; this.RiceUseDefaultHacks_CB.Text = "Use defaults for current game";
this.RiceUseDefaultHacks_CB.UseVisualStyleBackColor = true; this.RiceUseDefaultHacks_CB.UseVisualStyleBackColor = true;
this.RiceUseDefaultHacks_CB.CheckedChanged += new System.EventHandler(this.RiceUseDefaultHacks_CB_CheckedChanged); this.RiceUseDefaultHacks_CB.CheckedChanged += new System.EventHandler(this.RiceUseDefaultHacks_Cb_CheckedChanged);
// //
// Glide64TabPage // Glide64TabPage
// //
@ -4548,7 +4548,7 @@
this.SaveButton.TabIndex = 100; this.SaveButton.TabIndex = 100;
this.SaveButton.Text = "Save"; this.SaveButton.Text = "Save";
this.SaveButton.UseVisualStyleBackColor = true; this.SaveButton.UseVisualStyleBackColor = true;
this.SaveButton.Click += new System.EventHandler(this.button1_Click); this.SaveButton.Click += new System.EventHandler(this.Button1_Click);
// //
// CancelBT // CancelBT
// //
@ -4560,7 +4560,7 @@
this.CancelBT.TabIndex = 105; this.CancelBT.TabIndex = 105;
this.CancelBT.Text = "Cancel"; this.CancelBT.Text = "Cancel";
this.CancelBT.UseVisualStyleBackColor = true; this.CancelBT.UseVisualStyleBackColor = true;
this.CancelBT.Click += new System.EventHandler(this.CancelBT_Click); this.CancelBT.Click += new System.EventHandler(this.CancelBtn_Click);
// //
// toolTip1 // toolTip1
// //

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Common;
using BizHawk.Common.StringExtensions; using BizHawk.Common.StringExtensions;
using BizHawk.Common.ReflectionExtensions; using BizHawk.Common.ReflectionExtensions;
using BizHawk.Emulation.Cores.Nintendo.N64; using BizHawk.Emulation.Cores.Nintendo.N64;
@ -14,8 +11,8 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class NewN64PluginSettings : Form public partial class NewN64PluginSettings : Form
{ {
N64Settings s; private N64Settings _s;
N64SyncSettings ss; private N64SyncSettings _ss;
public NewN64PluginSettings() public NewN64PluginSettings()
{ {
@ -32,36 +29,36 @@ namespace BizHawk.Client.EmuHawk
{ {
if (VideoResolutionComboBox.Text != "Custom") if (VideoResolutionComboBox.Text != "Custom")
{ {
var video_settings = VideoResolutionComboBox.SelectedItem.ToString(); var videoSettings = VideoResolutionComboBox.SelectedItem.ToString();
var strArr = video_settings.Split('x'); var strArr = videoSettings.Split('x');
s.VideoSizeX = int.Parse(strArr[0].Trim()); _s.VideoSizeX = int.Parse(strArr[0].Trim());
s.VideoSizeY = int.Parse(strArr[1].Trim()); _s.VideoSizeY = int.Parse(strArr[1].Trim());
} }
else else
{ {
s.VideoSizeX = _s.VideoSizeX =
VideoResolutionXTextBox.Text.IsUnsigned() ? VideoResolutionXTextBox.Text.IsUnsigned() ?
int.Parse(VideoResolutionXTextBox.Text) : 320; int.Parse(VideoResolutionXTextBox.Text) : 320;
s.VideoSizeY = _s.VideoSizeY =
VideoResolutionYTextBox.Text.IsUnsigned() ? VideoResolutionYTextBox.Text.IsUnsigned() ?
int.Parse(VideoResolutionYTextBox.Text) : 240; int.Parse(VideoResolutionYTextBox.Text) : 240;
} }
ss.Core = CoreTypeDropdown.SelectedItem _ss.Core = CoreTypeDropdown.SelectedItem
.ToString() .ToString()
.GetEnumFromDescription<N64SyncSettings.CoreType>(); .GetEnumFromDescription<N64SyncSettings.CoreType>();
ss.Rsp = RspTypeDropdown.SelectedItem _ss.Rsp = RspTypeDropdown.SelectedItem
.ToString() .ToString()
.GetEnumFromDescription<N64SyncSettings.RspType>(); .GetEnumFromDescription<N64SyncSettings.RspType>();
ss.VideoPlugin = PluginComboBox.SelectedItem _ss.VideoPlugin = PluginComboBox.SelectedItem
.ToString() .ToString()
.GetEnumFromDescription<PluginType>(); .GetEnumFromDescription<PluginType>();
PutSettings(s); PutSettings(_s);
PutSyncSettings(ss); PutSyncSettings(_ss);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
@ -69,21 +66,21 @@ namespace BizHawk.Client.EmuHawk
private void NewN64PluginSettings_Load(object sender, EventArgs e) private void NewN64PluginSettings_Load(object sender, EventArgs e)
{ {
s = GetSettings(); _s = GetSettings();
ss = GetSyncSettings(); _ss = GetSyncSettings();
CoreTypeDropdown.PopulateFromEnum<N64SyncSettings.CoreType>(ss.Core); CoreTypeDropdown.PopulateFromEnum<N64SyncSettings.CoreType>(_ss.Core);
RspTypeDropdown.PopulateFromEnum<N64SyncSettings.RspType>(ss.Rsp); RspTypeDropdown.PopulateFromEnum<N64SyncSettings.RspType>(_ss.Rsp);
PluginComboBox.PopulateFromEnum<PluginType>(ss.VideoPlugin); PluginComboBox.PopulateFromEnum<PluginType>(_ss.VideoPlugin);
VideoResolutionXTextBox.Text = s.VideoSizeX.ToString(); VideoResolutionXTextBox.Text = _s.VideoSizeX.ToString();
VideoResolutionYTextBox.Text = s.VideoSizeY.ToString(); VideoResolutionYTextBox.Text = _s.VideoSizeY.ToString();
var video_setting = s.VideoSizeX var videoSetting = _s.VideoSizeX
+ " x " + " x "
+ s.VideoSizeY; + _s.VideoSizeY;
var index = VideoResolutionComboBox.Items.IndexOf(video_setting); var index = VideoResolutionComboBox.Items.IndexOf(videoSetting);
if (index >= 0) if (index >= 0)
{ {
VideoResolutionComboBox.SelectedIndex = index; VideoResolutionComboBox.SelectedIndex = index;
@ -94,10 +91,10 @@ namespace BizHawk.Client.EmuHawk
ShowCustomVideoResolutionControls(); ShowCustomVideoResolutionControls();
} }
RicePropertyGrid.SelectedObject = ss.RicePlugin; RicePropertyGrid.SelectedObject = _ss.RicePlugin;
Glidemk2PropertyGrid.SelectedObject = ss.Glide64mk2Plugin; Glidemk2PropertyGrid.SelectedObject = _ss.Glide64mk2Plugin;
GlidePropertyGrid.SelectedObject = ss.GlidePlugin; GlidePropertyGrid.SelectedObject = _ss.GlidePlugin;
JaboPropertyGrid.SelectedObject = ss.JaboPlugin; JaboPropertyGrid.SelectedObject = _ss.JaboPlugin;
} }
#region Setting Get/Set #region Setting Get/Set
@ -159,8 +156,8 @@ namespace BizHawk.Client.EmuHawk
else else
{ {
HideCustomVideoResolutionControls(); HideCustomVideoResolutionControls();
var new_resolution = VideoResolutionComboBox.SelectedItem.ToString(); var newResolution = VideoResolutionComboBox.SelectedItem.ToString();
var strArr = new_resolution.Split('x'); var strArr = newResolution.Split('x');
VideoResolutionXTextBox.Text = strArr[0].Trim(); VideoResolutionXTextBox.Text = strArr[0].Trim();
VideoResolutionYTextBox.Text = strArr[1].Trim(); VideoResolutionYTextBox.Text = strArr[1].Trim();
} }

View File

@ -1,7 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data; using System.Data;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
@ -9,29 +6,32 @@ namespace BizHawk.Client.EmuHawk
public class DataTableDictionaryBind<TKey, TValue> public class DataTableDictionaryBind<TKey, TValue>
{ {
public DataTable Table { get; private set; } public DataTable Table { get; private set; }
public IDictionary<TKey, TValue> Dictionary { get; private set; }
private IDictionary<TKey, TValue> Dictionary { get; }
public bool WasModified { get; private set; } public bool WasModified { get; private set; }
public DataTableDictionaryBind(IDictionary<TKey, TValue> Dictionary) public DataTableDictionaryBind(IDictionary<TKey, TValue> dictionary)
{ {
this.Dictionary = Dictionary; Dictionary = dictionary;
CreateTable(); CreateTable();
} }
void CreateTable() private void CreateTable()
{ {
Table = new DataTable(); Table = new DataTable();
Table.Columns.Add("Key", typeof(TKey)); Table.Columns.Add("Key", typeof(TKey));
Table.Columns.Add("Value", typeof(TValue)); Table.Columns.Add("Value", typeof(TValue));
foreach (var kvp in Dictionary) foreach (var kvp in Dictionary)
{
Table.Rows.Add(kvp.Key, kvp.Value); Table.Rows.Add(kvp.Key, kvp.Value);
}
Table.RowChanged += new DataRowChangeEventHandler(Table_RowChanged); Table.RowChanged += Table_RowChanged;
WasModified = false; WasModified = false;
} }
void Table_RowChanged(object sender, DataRowChangeEventArgs e) private void Table_RowChanged(object sender, DataRowChangeEventArgs e)
{ {
var key = (TKey)e.Row[0]; var key = (TKey)e.Row[0];
var value = (TValue)e.Row[1]; var value = (TValue)e.Row[1];

View File

@ -81,7 +81,7 @@
this.OK.TabIndex = 70; this.OK.TabIndex = 70;
this.OK.Text = "&OK"; this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true; this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click); this.OK.Click += new System.EventHandler(this.Ok_Click);
// //
// Cancel // Cancel
// //
@ -252,7 +252,7 @@
this.btnAreaFull.TabIndex = 40; this.btnAreaFull.TabIndex = 40;
this.btnAreaFull.Text = "Full [0,239]"; this.btnAreaFull.Text = "Full [0,239]";
this.btnAreaFull.UseVisualStyleBackColor = true; this.btnAreaFull.UseVisualStyleBackColor = true;
this.btnAreaFull.Click += new System.EventHandler(this.btnAreaFull_Click); this.btnAreaFull.Click += new System.EventHandler(this.BtnAreaFull_Click);
// //
// btnAreaStandard // btnAreaStandard
// //
@ -262,7 +262,7 @@
this.btnAreaStandard.TabIndex = 35; this.btnAreaStandard.TabIndex = 35;
this.btnAreaStandard.Text = "Standard [8,231]"; this.btnAreaStandard.Text = "Standard [8,231]";
this.btnAreaStandard.UseVisualStyleBackColor = true; this.btnAreaStandard.UseVisualStyleBackColor = true;
this.btnAreaStandard.Click += new System.EventHandler(this.btnAreaStandard_Click); this.btnAreaStandard.Click += new System.EventHandler(this.BtnAreaStandard_Click);
// //
// label4 // label4
// //

View File

@ -14,10 +14,9 @@ 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 NES nes; private NES.NESSettings _settings;
private NES.NESSettings settings; private Bitmap _bmp;
Bitmap bmp;
public NESGraphicsConfig() public NESGraphicsConfig()
{ {
@ -26,23 +25,23 @@ namespace BizHawk.Client.EmuHawk
private void NESGraphicsConfig_Load(object sender, EventArgs e) private void NESGraphicsConfig_Load(object sender, EventArgs e)
{ {
nes = Global.Emulator as NES; _nes = (NES)Global.Emulator;
settings = (NES.NESSettings)nes.GetSettings(); _settings = _nes.GetSettings();
LoadStuff(); LoadStuff();
} }
private void LoadStuff() private void LoadStuff()
{ {
NTSC_FirstLineNumeric.Value = settings.NTSC_TopLine; NTSC_FirstLineNumeric.Value = _settings.NTSC_TopLine;
NTSC_LastLineNumeric.Value = settings.NTSC_BottomLine; NTSC_LastLineNumeric.Value = _settings.NTSC_BottomLine;
PAL_FirstLineNumeric.Value = settings.PAL_TopLine; PAL_FirstLineNumeric.Value = _settings.PAL_TopLine;
PAL_LastLineNumeric.Value = settings.PAL_BottomLine; PAL_LastLineNumeric.Value = _settings.PAL_BottomLine;
AllowMoreSprites.Checked = settings.AllowMoreThanEightSprites; AllowMoreSprites.Checked = _settings.AllowMoreThanEightSprites;
ClipLeftAndRightCheckBox.Checked = settings.ClipLeftAndRight; ClipLeftAndRightCheckBox.Checked = _settings.ClipLeftAndRight;
DispSprites.Checked = settings.DispSprites; DispSprites.Checked = _settings.DispSprites;
DispBackground.Checked = settings.DispBackground; DispBackground.Checked = _settings.DispBackground;
BGColorDialog.Color = Color.FromArgb(unchecked(settings.BackgroundColor | (int)0xFF000000)); BGColorDialog.Color = Color.FromArgb(unchecked(_settings.BackgroundColor | (int)0xFF000000));
checkUseBackdropColor.Checked = (settings.BackgroundColor & 0xFF000000) != 0; checkUseBackdropColor.Checked = (_settings.BackgroundColor & 0xFF000000) != 0;
SetColorBox(); SetColorBox();
SetPaletteImage(); SetPaletteImage();
} }
@ -74,19 +73,20 @@ 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); _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;
for (int i = 0; i < w; i++) for (int i = 0; i < w; i++)
{ {
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)
@ -95,56 +95,65 @@ namespace BizHawk.Client.EmuHawk
{ {
if (PalettePath.Text.Length > 0) if (PalettePath.Text.Length > 0)
{ {
HawkFile palette = new HawkFile(PalettePath.Text); var palette = new HawkFile(PalettePath.Text);
if (palette != null && palette.Exists) if (palette.Exists)
{ {
var data = Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name)); var data = Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name));
if (showmsg) GlobalWin.OSD.AddMessage("Palette file loaded: " + palette.Name); if (showmsg)
{
GlobalWin.OSD.AddMessage("Palette file loaded: " + palette.Name);
}
return data; return data;
} }
else else
{ {
return settings.Palette; return _settings.Palette;
} }
} }
else // no filename: interpret this as "reset to default" else // no filename: interpret this as "reset to default"
{ {
if (showmsg) GlobalWin.OSD.AddMessage("Standard Palette set"); if (showmsg)
{
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 else // 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)
{ {
settings.Palette = ResolvePalette(true); _settings.Palette = ResolvePalette(true);
settings.NTSC_TopLine = (int)NTSC_FirstLineNumeric.Value; _settings.NTSC_TopLine = (int)NTSC_FirstLineNumeric.Value;
settings.NTSC_BottomLine = (int)NTSC_LastLineNumeric.Value; _settings.NTSC_BottomLine = (int)NTSC_LastLineNumeric.Value;
settings.PAL_TopLine = (int)PAL_FirstLineNumeric.Value; _settings.PAL_TopLine = (int)PAL_FirstLineNumeric.Value;
settings.PAL_BottomLine = (int)PAL_LastLineNumeric.Value; _settings.PAL_BottomLine = (int)PAL_LastLineNumeric.Value;
settings.AllowMoreThanEightSprites = AllowMoreSprites.Checked; _settings.AllowMoreThanEightSprites = AllowMoreSprites.Checked;
settings.ClipLeftAndRight = ClipLeftAndRightCheckBox.Checked; _settings.ClipLeftAndRight = ClipLeftAndRightCheckBox.Checked;
settings.DispSprites = DispSprites.Checked; _settings.DispSprites = DispSprites.Checked;
settings.DispBackground = DispBackground.Checked; _settings.DispBackground = DispBackground.Checked;
settings.BackgroundColor = BGColorDialog.Color.ToArgb(); _settings.BackgroundColor = BGColorDialog.Color.ToArgb();
if (!checkUseBackdropColor.Checked) if (!checkUseBackdropColor.Checked)
settings.BackgroundColor &= 0x00FFFFFF; {
_settings.BackgroundColor &= 0x00FFFFFF;
}
nes.PutSettings(settings); _nes.PutSettings(_settings);
Close(); Close();
} }
private void SetColorBox() private void SetColorBox()
{ {
int color = BGColorDialog.Color.ToArgb(); int color = BGColorDialog.Color.ToArgb();
BackGroundColorNumber.Text = String.Format("{0:X8}", color).Substring(2,6); BackGroundColorNumber.Text = $"{color:X8}".Substring(2, 6);
BackgroundColorPanel.BackColor = BGColorDialog.Color; BackgroundColorPanel.BackColor = BGColorDialog.Color;
} }
@ -161,13 +170,13 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void btnAreaStandard_Click(object sender, EventArgs e) private void BtnAreaStandard_Click(object sender, EventArgs e)
{ {
NTSC_FirstLineNumeric.Value = 8; NTSC_FirstLineNumeric.Value = 8;
NTSC_LastLineNumeric.Value = 231; NTSC_LastLineNumeric.Value = 231;
} }
private void btnAreaFull_Click(object sender, EventArgs e) private void BtnAreaFull_Click(object sender, EventArgs e)
{ {
NTSC_FirstLineNumeric.Value = 0; NTSC_FirstLineNumeric.Value = 0;
NTSC_LastLineNumeric.Value = 239; NTSC_LastLineNumeric.Value = 239;
@ -180,7 +189,7 @@ namespace BizHawk.Client.EmuHawk
private void RestoreDefaultsButton_Click(object sender, EventArgs e) private void RestoreDefaultsButton_Click(object sender, EventArgs e)
{ {
settings = new NES.NESSettings(); _settings = new NES.NESSettings();
LoadStuff(); LoadStuff();
} }

View File

@ -61,7 +61,7 @@
this.OK.TabIndex = 0; this.OK.TabIndex = 0;
this.OK.Text = "&OK"; this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true; this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click); this.OK.Click += new System.EventHandler(this.Ok_Click);
// //
// Cancel // Cancel
// //
@ -81,7 +81,7 @@
this.trackBar1.Name = "trackBar1"; this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(104, 45); this.trackBar1.Size = new System.Drawing.Size(104, 45);
this.trackBar1.TabIndex = 2; this.trackBar1.TabIndex = 2;
this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged); this.trackBar1.ValueChanged += new System.EventHandler(this.TrackBar1_ValueChanged);
// //
// trackBar2 // trackBar2
// //
@ -89,7 +89,7 @@
this.trackBar2.Name = "trackBar2"; this.trackBar2.Name = "trackBar2";
this.trackBar2.Size = new System.Drawing.Size(104, 45); this.trackBar2.Size = new System.Drawing.Size(104, 45);
this.trackBar2.TabIndex = 3; this.trackBar2.TabIndex = 3;
this.trackBar2.ValueChanged += new System.EventHandler(this.trackBar2_ValueChanged); this.trackBar2.ValueChanged += new System.EventHandler(this.TrackBar2_ValueChanged);
// //
// trackBar3 // trackBar3
// //
@ -97,7 +97,7 @@
this.trackBar3.Name = "trackBar3"; this.trackBar3.Name = "trackBar3";
this.trackBar3.Size = new System.Drawing.Size(104, 45); this.trackBar3.Size = new System.Drawing.Size(104, 45);
this.trackBar3.TabIndex = 4; this.trackBar3.TabIndex = 4;
this.trackBar3.ValueChanged += new System.EventHandler(this.trackBar3_ValueChanged); this.trackBar3.ValueChanged += new System.EventHandler(this.TrackBar3_ValueChanged);
// //
// trackBar4 // trackBar4
// //
@ -105,7 +105,7 @@
this.trackBar4.Name = "trackBar4"; this.trackBar4.Name = "trackBar4";
this.trackBar4.Size = new System.Drawing.Size(104, 45); this.trackBar4.Size = new System.Drawing.Size(104, 45);
this.trackBar4.TabIndex = 5; this.trackBar4.TabIndex = 5;
this.trackBar4.ValueChanged += new System.EventHandler(this.trackBar4_ValueChanged); this.trackBar4.ValueChanged += new System.EventHandler(this.TrackBar4_ValueChanged);
// //
// trackBar5 // trackBar5
// //
@ -113,7 +113,7 @@
this.trackBar5.Name = "trackBar5"; this.trackBar5.Name = "trackBar5";
this.trackBar5.Size = new System.Drawing.Size(104, 45); this.trackBar5.Size = new System.Drawing.Size(104, 45);
this.trackBar5.TabIndex = 6; this.trackBar5.TabIndex = 6;
this.trackBar5.ValueChanged += new System.EventHandler(this.trackBar5_ValueChanged); this.trackBar5.ValueChanged += new System.EventHandler(this.TrackBar5_ValueChanged);
// //
// label1 // label1
// //

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Nintendo.NES; using BizHawk.Emulation.Cores.Nintendo.NES;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
@ -10,13 +9,14 @@ namespace BizHawk.Client.EmuHawk
public partial class NESSoundConfig : Form, IToolForm public partial class NESSoundConfig : Form, IToolForm
{ {
[RequiredService] [RequiredService]
private NES _nes { get; set; } private NES NES { get; set; }
private NES.NESSettings _oldSettings; private NES.NESSettings _oldSettings;
private NES.NESSettings _settings; private NES.NESSettings _settings;
public bool AskSaveChanges() { return true; } public bool AskSaveChanges() { return true; }
public bool UpdateBefore { get { return false; } } public bool UpdateBefore => false;
public void UpdateValues() public void UpdateValues()
{ {
} }
@ -35,6 +35,7 @@ namespace BizHawk.Client.EmuHawk
public NESSoundConfig() public NESSoundConfig()
{ {
InitializeComponent(); InitializeComponent();
// get baseline maxes from a default config object // get baseline maxes from a default config object
var d = new NES.NESSettings(); var d = new NES.NESSettings();
trackBar1.Maximum = d.Square1; trackBar1.Maximum = d.Square1;
@ -46,7 +47,7 @@ namespace BizHawk.Client.EmuHawk
private void NESSoundConfig_Load(object sender, EventArgs e) private void NESSoundConfig_Load(object sender, EventArgs e)
{ {
_oldSettings = _nes.GetSettings(); _oldSettings = NES.GetSettings();
_settings = _oldSettings.Clone(); _settings = _oldSettings.Clone();
trackBar1.Value = _settings.Square1; trackBar1.Value = _settings.Square1;
@ -56,7 +57,7 @@ namespace BizHawk.Client.EmuHawk
trackBar5.Value = _settings.DMC; trackBar5.Value = _settings.DMC;
} }
private void OK_Click(object sender, EventArgs e) private void Ok_Click(object sender, EventArgs e)
{ {
Close(); Close();
} }
@ -64,43 +65,43 @@ namespace BizHawk.Client.EmuHawk
private void Cancel_Click(object sender, EventArgs e) private void Cancel_Click(object sender, EventArgs e)
{ {
// restore previous value // restore previous value
_nes.PutSettings(_oldSettings); NES.PutSettings(_oldSettings);
Close(); Close();
} }
private void trackBar1_ValueChanged(object sender, EventArgs e) private void TrackBar1_ValueChanged(object sender, EventArgs e)
{ {
label6.Text = trackBar1.Value.ToString(); label6.Text = trackBar1.Value.ToString();
_settings.Square1 = trackBar1.Value; _settings.Square1 = trackBar1.Value;
_nes.PutSettings(_settings); NES.PutSettings(_settings);
} }
private void trackBar2_ValueChanged(object sender, EventArgs e) private void TrackBar2_ValueChanged(object sender, EventArgs e)
{ {
label7.Text = trackBar2.Value.ToString(); label7.Text = trackBar2.Value.ToString();
_settings.Square2 = trackBar2.Value; _settings.Square2 = trackBar2.Value;
_nes.PutSettings(_settings); NES.PutSettings(_settings);
} }
private void trackBar3_ValueChanged(object sender, EventArgs e) private void TrackBar3_ValueChanged(object sender, EventArgs e)
{ {
label8.Text = trackBar3.Value.ToString(); label8.Text = trackBar3.Value.ToString();
_settings.Triangle = trackBar3.Value; _settings.Triangle = trackBar3.Value;
_nes.PutSettings(_settings); NES.PutSettings(_settings);
} }
private void trackBar4_ValueChanged(object sender, EventArgs e) private void TrackBar4_ValueChanged(object sender, EventArgs e)
{ {
label9.Text = trackBar4.Value.ToString(); label9.Text = trackBar4.Value.ToString();
_settings.Noise = trackBar4.Value; _settings.Noise = trackBar4.Value;
_nes.PutSettings(_settings); NES.PutSettings(_settings);
} }
private void trackBar5_ValueChanged(object sender, EventArgs e) private void TrackBar5_ValueChanged(object sender, EventArgs e)
{ {
label10.Text = trackBar5.Value.ToString(); label10.Text = trackBar5.Value.ToString();
_settings.DMC = trackBar5.Value; _settings.DMC = trackBar5.Value;
_nes.PutSettings(_settings); NES.PutSettings(_settings);
} }
} }
} }

View File

@ -1,32 +1,30 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Nintendo.NES; using BizHawk.Emulation.Cores.Nintendo.NES;
using BizHawk.Common.NumberExtensions; using BizHawk.Common.NumberExtensions;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class NESSyncSettingsForm : Form public partial class NESSyncSettingsForm : Form
{ {
DataTableDictionaryBind<string, string> DTDB; private readonly DataTableDictionaryBind<string, string> _dataTableDictionary;
NES.NESSyncSettings SyncSettings; private readonly NES.NESSyncSettings _syncSettings;
public NESSyncSettingsForm() public NESSyncSettingsForm()
{ {
InitializeComponent(); InitializeComponent();
SyncSettings = ((NES)Global.Emulator).GetSyncSettings(); _syncSettings = ((NES)Global.Emulator).GetSyncSettings();
if ((Global.Emulator as NES).HasMapperProperties) if (((NES)Global.Emulator).HasMapperProperties)
{ {
_dataTableDictionary = new DataTableDictionaryBind<string, string>(_syncSettings.BoardProperties);
DTDB = new DataTableDictionaryBind<string, string>(SyncSettings.BoardProperties); dataGridView1.DataSource = _dataTableDictionary.Table;
dataGridView1.DataSource = DTDB.Table;
InfoLabel.Visible = false; InfoLabel.Visible = false;
} }
else else
@ -38,12 +36,12 @@ namespace BizHawk.Client.EmuHawk
} }
RegionComboBox.Items.AddRange(Enum.GetNames(typeof(NES.NESSyncSettings.Region))); RegionComboBox.Items.AddRange(Enum.GetNames(typeof(NES.NESSyncSettings.Region)));
RegionComboBox.SelectedItem = Enum.GetName(typeof(NES.NESSyncSettings.Region), SyncSettings.RegionOverride); RegionComboBox.SelectedItem = Enum.GetName(typeof(NES.NESSyncSettings.Region), _syncSettings.RegionOverride);
if (SyncSettings.InitialWRamStatePattern != null && SyncSettings.InitialWRamStatePattern.Any()) if (_syncSettings.InitialWRamStatePattern != null && _syncSettings.InitialWRamStatePattern.Any())
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
foreach (var b in SyncSettings.InitialWRamStatePattern) foreach (var b in _syncSettings.InitialWRamStatePattern)
{ {
sb.Append(b.ToHexString(2)); sb.Append(b.ToHexString(2));
} }
@ -60,35 +58,34 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
var old = _syncSettings.RegionOverride;
var old = SyncSettings.RegionOverride; _syncSettings.RegionOverride = (NES.NESSyncSettings.Region)
SyncSettings.RegionOverride = (NES.NESSyncSettings.Region)
Enum.Parse( Enum.Parse(
typeof(NES.NESSyncSettings.Region), typeof(NES.NESSyncSettings.Region),
(string)RegionComboBox.SelectedItem); (string)RegionComboBox.SelectedItem);
List<byte> oldRam = SyncSettings.InitialWRamStatePattern != null ? SyncSettings.InitialWRamStatePattern.ToList() : new List<byte>(); List<byte> oldRam = _syncSettings.InitialWRamStatePattern?.ToList() ?? new List<byte>();
if (!string.IsNullOrWhiteSpace(RamPatternOverrideBox.Text)) if (!string.IsNullOrWhiteSpace(RamPatternOverrideBox.Text))
{ {
SyncSettings.InitialWRamStatePattern = Enumerable.Range(0, RamPatternOverrideBox.Text.Length) _syncSettings.InitialWRamStatePattern = Enumerable.Range(0, RamPatternOverrideBox.Text.Length)
.Where(x => x % 2 == 0) .Where(x => x % 2 == 0)
.Select(x => Convert.ToByte(RamPatternOverrideBox.Text.Substring(x, 2), 16)) .Select(x => Convert.ToByte(RamPatternOverrideBox.Text.Substring(x, 2), 16))
.ToList(); .ToList();
} }
else else
{ {
SyncSettings.InitialWRamStatePattern = null; _syncSettings.InitialWRamStatePattern = null;
} }
bool changed = (DTDB != null && DTDB.WasModified) || bool changed = (_dataTableDictionary != null && _dataTableDictionary.WasModified) ||
old != SyncSettings.RegionOverride || old != _syncSettings.RegionOverride ||
!(oldRam.SequenceEqual(SyncSettings.InitialWRamStatePattern ?? new List<byte>())); !(oldRam.SequenceEqual(_syncSettings.InitialWRamStatePattern ?? new List<byte>()));
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
if (changed) if (changed)
{ {
GlobalWin.MainForm.PutCoreSyncSettings(SyncSettings); GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings);
} }
} }

View File

@ -1,6 +1,6 @@
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
partial class NESVSSettings partial class NesVsSettings
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -161,11 +161,11 @@
this.Controls.Add(this.Dipswitch1CheckBox); this.Controls.Add(this.Dipswitch1CheckBox);
this.Controls.Add(this.CancelBtn); this.Controls.Add(this.CancelBtn);
this.Controls.Add(this.OkBtn); this.Controls.Add(this.OkBtn);
this.Name = "NESVSSettings"; this.Name = "NesVsSettings";
this.ShowIcon = false; this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "NES VS Settings"; this.Text = "NES VS Settings";
this.Load += new System.EventHandler(this.NESVSSettings_Load); this.Load += new System.EventHandler(this.NesVsSettings_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@ -6,19 +6,19 @@ using BizHawk.Emulation.Cores.Nintendo.NES;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class NESVSSettings : Form public partial class NesVsSettings : Form
{ {
private NES.NESSyncSettings _settings; private NES.NESSyncSettings _settings;
private NES _nes; private NES _nes;
public NESVSSettings() public NesVsSettings()
{ {
InitializeComponent(); InitializeComponent();
} }
private void NESVSSettings_Load(object sender, EventArgs e) private void NesVsSettings_Load(object sender, EventArgs e)
{ {
_nes = Global.Emulator as NES; _nes = (NES)Global.Emulator;
_settings = _nes.GetSyncSettings(); _settings = _nes.GetSyncSettings();
Dipswitch1CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_1; Dipswitch1CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_1;

View File

@ -72,7 +72,7 @@
this.checkBoxFamicom.TabIndex = 4; this.checkBoxFamicom.TabIndex = 4;
this.checkBoxFamicom.Text = "Famicom"; this.checkBoxFamicom.Text = "Famicom";
this.checkBoxFamicom.UseVisualStyleBackColor = true; this.checkBoxFamicom.UseVisualStyleBackColor = true;
this.checkBoxFamicom.CheckedChanged += new System.EventHandler(this.checkBoxFamicom_CheckedChanged); this.checkBoxFamicom.CheckedChanged += new System.EventHandler(this.CheckBoxFamicom_CheckedChanged);
// //
// label5 // label5
// //
@ -149,7 +149,6 @@
this.Name = "NesControllerSettings"; this.Name = "NesControllerSettings";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "NES Controller Settings"; this.Text = "NES Controller Settings";
this.Load += new System.EventHandler(this.NesControllerSettings_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@ -1,10 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -14,30 +9,25 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class NesControllerSettings : Form public partial class NesControllerSettings : Form
{ {
NES.NESSyncSettings SyncSettings; private readonly NES.NESSyncSettings _syncSettings;
public NesControllerSettings() public NesControllerSettings()
{ {
InitializeComponent(); InitializeComponent();
SyncSettings = ((NES)Global.Emulator).GetSyncSettings(); _syncSettings = ((NES)Global.Emulator).GetSyncSettings();
// TODO: use combobox extension and add descriptions to enum values // TODO: use combobox extension and add descriptions to enum values
comboBoxFamicom.Items.AddRange(NESControlSettings.GetFamicomExpansionValues().ToArray()); comboBoxFamicom.Items.AddRange(NESControlSettings.GetFamicomExpansionValues().ToArray());
comboBoxNESL.Items.AddRange(NESControlSettings.GetNesPortValues().ToArray()); comboBoxNESL.Items.AddRange(NESControlSettings.GetNesPortValues().ToArray());
comboBoxNESR.Items.AddRange(NESControlSettings.GetNesPortValues().ToArray()); comboBoxNESR.Items.AddRange(NESControlSettings.GetNesPortValues().ToArray());
comboBoxFamicom.SelectedItem = SyncSettings.Controls.FamicomExpPort; comboBoxFamicom.SelectedItem = _syncSettings.Controls.FamicomExpPort;
comboBoxNESL.SelectedItem = SyncSettings.Controls.NesLeftPort; comboBoxNESL.SelectedItem = _syncSettings.Controls.NesLeftPort;
comboBoxNESR.SelectedItem = SyncSettings.Controls.NesRightPort; comboBoxNESR.SelectedItem = _syncSettings.Controls.NesRightPort;
checkBoxFamicom.Checked = SyncSettings.Controls.Famicom; checkBoxFamicom.Checked = _syncSettings.Controls.Famicom;
} }
private void NesControllerSettings_Load(object sender, EventArgs e) private void CheckBoxFamicom_CheckedChanged(object sender, EventArgs e)
{
}
private void checkBoxFamicom_CheckedChanged(object sender, EventArgs e)
{ {
comboBoxFamicom.Enabled = checkBoxFamicom.Checked; comboBoxFamicom.Enabled = checkBoxFamicom.Checked;
comboBoxNESL.Enabled = !checkBoxFamicom.Checked; comboBoxNESL.Enabled = !checkBoxFamicom.Checked;
@ -54,16 +44,13 @@ namespace BizHawk.Client.EmuHawk
NesRightPort = (string)comboBoxNESR.SelectedItem NesRightPort = (string)comboBoxNESR.SelectedItem
}; };
bool changed = NESControlSettings.NeedsReboot(ctrls, SyncSettings.Controls); bool changed = NESControlSettings.NeedsReboot(ctrls, _syncSettings.Controls);
SyncSettings.Controls = ctrls; _syncSettings.Controls = ctrls;
if (changed) if (changed)
{ {
GlobalWin.MainForm.PutCoreSyncSettings(SyncSettings); GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings);
// redundant -- MainForm.PutCoreSyncSettings() flags reboot when it is needed
// GlobalWin.MainForm.FlagNeedsReboot();
// GlobalWin.OSD.AddMessage("Controller settings saved but a core reboot is required");
} }
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;

View File

@ -82,7 +82,7 @@
this.buttonOK.TabIndex = 2; this.buttonOK.TabIndex = 2;
this.buttonOK.Text = "OK"; this.buttonOK.Text = "OK";
this.buttonOK.UseVisualStyleBackColor = true; this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); this.buttonOK.Click += new System.EventHandler(this.ButtonOk_Click);
// //
// buttonCancel // buttonCancel
// //
@ -104,7 +104,7 @@
this.buttonPal.TabIndex = 4; this.buttonPal.TabIndex = 4;
this.buttonPal.Text = "Browse..."; this.buttonPal.Text = "Browse...";
this.buttonPal.UseVisualStyleBackColor = true; this.buttonPal.UseVisualStyleBackColor = true;
this.buttonPal.Click += new System.EventHandler(this.buttonPal_Click); this.buttonPal.Click += new System.EventHandler(this.ButtonPal_Click);
// //
// buttonPalReset // buttonPalReset
// //
@ -115,7 +115,7 @@
this.buttonPalReset.TabIndex = 5; this.buttonPalReset.TabIndex = 5;
this.buttonPalReset.Text = "Reset to QuickNES Default"; this.buttonPalReset.Text = "Reset to QuickNES Default";
this.buttonPalReset.UseVisualStyleBackColor = true; this.buttonPalReset.UseVisualStyleBackColor = true;
this.buttonPalReset.Click += new System.EventHandler(this.buttonPalReset_Click); this.buttonPalReset.Click += new System.EventHandler(this.ButtonPalReset_Click);
// //
// label1 // label1
// //

View File

@ -1,12 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Cores.Nintendo.NES;
using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES; using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Common; using BizHawk.Common;
@ -15,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class QuickNesConfig : Form public partial class QuickNesConfig : Form
{ {
private QuickNES.QuickNESSettings Settings; private QuickNES.QuickNESSettings _settings;
public QuickNesConfig() public QuickNesConfig()
{ {
@ -24,17 +19,17 @@ namespace BizHawk.Client.EmuHawk
private void QuickNesConfig_Load(object sender, EventArgs e) private void QuickNesConfig_Load(object sender, EventArgs e)
{ {
Settings = ((QuickNES)Global.Emulator).GetSettings(); _settings = ((QuickNES)Global.Emulator).GetSettings();
propertyGrid1.SelectedObject = Settings; propertyGrid1.SelectedObject = _settings;
SetPaletteImage(); SetPaletteImage();
} }
void SetPaletteImage() private void SetPaletteImage()
{ {
int w = pictureBox1.Size.Width; int w = pictureBox1.Size.Width;
int h = pictureBox1.Size.Height; int h = pictureBox1.Size.Height;
var bmp = new Bitmap(w, h); var bmp = new Bitmap(w, h);
var pal = Settings.Palette; var pal = _settings.Palette;
for (int j = 0; j < h; j++) for (int j = 0; j < h; j++)
{ {
@ -46,15 +41,21 @@ namespace BizHawk.Client.EmuHawk
int cx = ix / 7; int cx = ix / 7;
if (iy % 3 == 2) if (iy % 3 == 2)
{ {
cx += 64 * (ix % 7 + 1); cx += 64 * ((ix % 7) + 1);
} }
int cindex = cy * 16 + cx;
Color col = Color.FromArgb(0xff, pal[cindex * 3], pal[cindex * 3 + 1], pal[cindex * 3 + 2]); int cindex = (cy * 16) + cx;
Color col = Color.FromArgb(
0xff,
pal[cindex * 3],
pal[(cindex * 3) + 1],
pal[(cindex * 3) + 2]);
bmp.SetPixel(i, j, col); bmp.SetPixel(i, j, col);
} }
} }
if (pictureBox1.Image != null) pictureBox1.Image.Dispose(); pictureBox1.Image?.Dispose();
pictureBox1.Image = bmp; pictureBox1.Image = bmp;
} }
@ -67,12 +68,11 @@ namespace BizHawk.Client.EmuHawk
pictureBox1.Image.Dispose(); pictureBox1.Image.Dispose();
pictureBox1.Image = null; pictureBox1.Image = null;
} }
} }
private void buttonPal_Click(object sender, EventArgs e) private void ButtonPal_Click(object sender, EventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog var ofd = new OpenFileDialog
{ {
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Palettes"].Path, "NES"), InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Palettes"].Path, "NES"),
Filter = "Palette Files (.pal)|*.PAL|All Files (*.*)|*.*", Filter = "Palette Files (.pal)|*.PAL|All Files (*.*)|*.*",
@ -84,26 +84,27 @@ namespace BizHawk.Client.EmuHawk
{ {
return; return;
} }
HawkFile palette = new HawkFile(ofd.FileName);
if (palette != null && palette.Exists) var palette = new HawkFile(ofd.FileName);
if (palette.Exists)
{ {
var data = Emulation.Cores.Nintendo.NES.Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name)); var data = Emulation.Cores.Nintendo.NES.Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name));
Settings.SetNesHawkPalette(data); _settings.SetNesHawkPalette(data);
SetPaletteImage(); SetPaletteImage();
} }
} }
private void buttonOK_Click(object sender, EventArgs e) private void ButtonOk_Click(object sender, EventArgs e)
{ {
GlobalWin.MainForm.PutCoreSettings(Settings); GlobalWin.MainForm.PutCoreSettings(_settings);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
private void buttonPalReset_Click(object sender, EventArgs e) private void ButtonPalReset_Click(object sender, EventArgs e)
{ {
Settings.SetDefaultColors(); _settings.SetDefaultColors();
SetPaletteImage(); SetPaletteImage();
} }
} }

View File

@ -1,15 +1,10 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Cores.PCEngine; using BizHawk.Emulation.Cores.PCEngine;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -48,7 +43,8 @@ namespace BizHawk.Client.EmuHawk
.OfType<CheckBox>() .OfType<CheckBox>()
.OrderBy(c => c.Name) .OrderBy(c => c.Name)
.ToList() .ToList()
.ForEach(c => { .ForEach(c =>
{
var index = int.Parse(c.Name.Replace("Controller", "")); var index = int.Parse(c.Name.Replace("Controller", ""));
pceSettings.Controllers[index].IsConnected = c.Checked; pceSettings.Controllers[index].IsConnected = c.Checked;
}); });

View File

@ -48,7 +48,7 @@
this.OK.TabIndex = 4; this.OK.TabIndex = 4;
this.OK.Text = "&OK"; this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true; this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click); this.OK.Click += new System.EventHandler(this.Ok_Click);
// //
// Cancel // Cancel
// //

View File

@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
DispBG2.Checked = s.ShowBG2; DispBG2.Checked = s.ShowBG2;
} }
private void OK_Click(object sender, EventArgs e) private void Ok_Click(object sender, EventArgs e)
{ {
var pce = (PCEngine)Global.Emulator; var pce = (PCEngine)Global.Emulator;
PCEngine.PCESettings s = pce.GetSettings(); PCEngine.PCESettings s = pce.GetSettings();

View File

@ -74,7 +74,7 @@
this.cbMultitap_1.TabIndex = 0; this.cbMultitap_1.TabIndex = 0;
this.cbMultitap_1.Text = "Multitap"; this.cbMultitap_1.Text = "Multitap";
this.cbMultitap_1.UseVisualStyleBackColor = true; this.cbMultitap_1.UseVisualStyleBackColor = true;
this.cbMultitap_1.CheckedChanged += new System.EventHandler(this.cb_changed); this.cbMultitap_1.CheckedChanged += new System.EventHandler(this.Cb_Changed);
// //
// groupBox1 // groupBox1
// //
@ -187,7 +187,7 @@
this.combo_1_4.Name = "combo_1_4"; this.combo_1_4.Name = "combo_1_4";
this.combo_1_4.Size = new System.Drawing.Size(121, 21); this.combo_1_4.Size = new System.Drawing.Size(121, 21);
this.combo_1_4.TabIndex = 5; this.combo_1_4.TabIndex = 5;
this.combo_1_4.SelectedIndexChanged += new System.EventHandler(this.combo_SelectedIndexChanged); this.combo_1_4.SelectedIndexChanged += new System.EventHandler(this.Combo_SelectedIndexChanged);
// //
// combo_1_3 // combo_1_3
// //
@ -197,7 +197,7 @@
this.combo_1_3.Name = "combo_1_3"; this.combo_1_3.Name = "combo_1_3";
this.combo_1_3.Size = new System.Drawing.Size(121, 21); this.combo_1_3.Size = new System.Drawing.Size(121, 21);
this.combo_1_3.TabIndex = 4; this.combo_1_3.TabIndex = 4;
this.combo_1_3.SelectedIndexChanged += new System.EventHandler(this.combo_SelectedIndexChanged); this.combo_1_3.SelectedIndexChanged += new System.EventHandler(this.Combo_SelectedIndexChanged);
// //
// combo_1_2 // combo_1_2
// //
@ -207,7 +207,7 @@
this.combo_1_2.Name = "combo_1_2"; this.combo_1_2.Name = "combo_1_2";
this.combo_1_2.Size = new System.Drawing.Size(121, 21); this.combo_1_2.Size = new System.Drawing.Size(121, 21);
this.combo_1_2.TabIndex = 3; this.combo_1_2.TabIndex = 3;
this.combo_1_2.SelectedIndexChanged += new System.EventHandler(this.combo_SelectedIndexChanged); this.combo_1_2.SelectedIndexChanged += new System.EventHandler(this.Combo_SelectedIndexChanged);
// //
// combo_1_1 // combo_1_1
// //
@ -217,7 +217,7 @@
this.combo_1_1.Name = "combo_1_1"; this.combo_1_1.Name = "combo_1_1";
this.combo_1_1.Size = new System.Drawing.Size(121, 21); this.combo_1_1.Size = new System.Drawing.Size(121, 21);
this.combo_1_1.TabIndex = 2; this.combo_1_1.TabIndex = 2;
this.combo_1_1.SelectedIndexChanged += new System.EventHandler(this.combo_SelectedIndexChanged); this.combo_1_1.SelectedIndexChanged += new System.EventHandler(this.Combo_SelectedIndexChanged);
// //
// cbMemcard_1 // cbMemcard_1
// //
@ -228,7 +228,7 @@
this.cbMemcard_1.TabIndex = 1; this.cbMemcard_1.TabIndex = 1;
this.cbMemcard_1.Text = "Memcard"; this.cbMemcard_1.Text = "Memcard";
this.cbMemcard_1.UseVisualStyleBackColor = true; this.cbMemcard_1.UseVisualStyleBackColor = true;
this.cbMemcard_1.CheckedChanged += new System.EventHandler(this.cb_changed); this.cbMemcard_1.CheckedChanged += new System.EventHandler(this.Cb_Changed);
// //
// btnOK // btnOK
// //
@ -239,7 +239,7 @@
this.btnOK.TabIndex = 2; this.btnOK.TabIndex = 2;
this.btnOK.Text = "OK"; this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true; this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click); this.btnOK.Click += new System.EventHandler(this.BtnOk_Click);
// //
// btnCancel // btnCancel
// //
@ -362,7 +362,7 @@
this.combo_2_4.Name = "combo_2_4"; this.combo_2_4.Name = "combo_2_4";
this.combo_2_4.Size = new System.Drawing.Size(121, 21); this.combo_2_4.Size = new System.Drawing.Size(121, 21);
this.combo_2_4.TabIndex = 5; this.combo_2_4.TabIndex = 5;
this.combo_2_4.SelectedIndexChanged += new System.EventHandler(this.combo_SelectedIndexChanged); this.combo_2_4.SelectedIndexChanged += new System.EventHandler(this.Combo_SelectedIndexChanged);
// //
// combo_2_3 // combo_2_3
// //
@ -372,7 +372,7 @@
this.combo_2_3.Name = "combo_2_3"; this.combo_2_3.Name = "combo_2_3";
this.combo_2_3.Size = new System.Drawing.Size(121, 21); this.combo_2_3.Size = new System.Drawing.Size(121, 21);
this.combo_2_3.TabIndex = 4; this.combo_2_3.TabIndex = 4;
this.combo_2_3.SelectedIndexChanged += new System.EventHandler(this.combo_SelectedIndexChanged); this.combo_2_3.SelectedIndexChanged += new System.EventHandler(this.Combo_SelectedIndexChanged);
// //
// combo_2_2 // combo_2_2
// //
@ -382,7 +382,7 @@
this.combo_2_2.Name = "combo_2_2"; this.combo_2_2.Name = "combo_2_2";
this.combo_2_2.Size = new System.Drawing.Size(121, 21); this.combo_2_2.Size = new System.Drawing.Size(121, 21);
this.combo_2_2.TabIndex = 3; this.combo_2_2.TabIndex = 3;
this.combo_2_2.SelectedIndexChanged += new System.EventHandler(this.combo_SelectedIndexChanged); this.combo_2_2.SelectedIndexChanged += new System.EventHandler(this.Combo_SelectedIndexChanged);
// //
// combo_2_1 // combo_2_1
// //
@ -392,7 +392,7 @@
this.combo_2_1.Name = "combo_2_1"; this.combo_2_1.Name = "combo_2_1";
this.combo_2_1.Size = new System.Drawing.Size(121, 21); this.combo_2_1.Size = new System.Drawing.Size(121, 21);
this.combo_2_1.TabIndex = 2; this.combo_2_1.TabIndex = 2;
this.combo_2_1.SelectedIndexChanged += new System.EventHandler(this.combo_SelectedIndexChanged); this.combo_2_1.SelectedIndexChanged += new System.EventHandler(this.Combo_SelectedIndexChanged);
// //
// cbMemcard_2 // cbMemcard_2
// //
@ -403,7 +403,7 @@
this.cbMemcard_2.TabIndex = 1; this.cbMemcard_2.TabIndex = 1;
this.cbMemcard_2.Text = "Memcard"; this.cbMemcard_2.Text = "Memcard";
this.cbMemcard_2.UseVisualStyleBackColor = true; this.cbMemcard_2.UseVisualStyleBackColor = true;
this.cbMemcard_2.CheckedChanged += new System.EventHandler(this.cb_changed); this.cbMemcard_2.CheckedChanged += new System.EventHandler(this.Cb_Changed);
// //
// cbMultitap_2 // cbMultitap_2
// //
@ -414,7 +414,7 @@
this.cbMultitap_2.TabIndex = 0; this.cbMultitap_2.TabIndex = 0;
this.cbMultitap_2.Text = "Multitap"; this.cbMultitap_2.Text = "Multitap";
this.cbMultitap_2.UseVisualStyleBackColor = true; this.cbMultitap_2.UseVisualStyleBackColor = true;
this.cbMultitap_2.CheckedChanged += new System.EventHandler(this.cb_changed); this.cbMultitap_2.CheckedChanged += new System.EventHandler(this.Cb_Changed);
// //
// PSXControllerConfigNew // PSXControllerConfigNew
// //

View File

@ -15,8 +15,8 @@ namespace BizHawk.Client.EmuHawk
private void PSXControllerConfigNew_Load(object sender, EventArgs e) private void PSXControllerConfigNew_Load(object sender, EventArgs e)
{ {
//populate combo boxes // populate combo boxes
foreach(var combo in new[]{combo_1_1,combo_1_2,combo_1_3,combo_1_4,combo_2_1,combo_2_2,combo_2_3,combo_2_4}) foreach (var combo in new[] { combo_1_1, combo_1_2, combo_1_3, combo_1_4, combo_2_1, combo_2_2, combo_2_3, combo_2_4 })
{ {
combo.Items.Add("-Nothing-"); combo.Items.Add("-Nothing-");
combo.Items.Add("Gamepad"); combo.Items.Add("Gamepad");
@ -32,7 +32,7 @@ namespace BizHawk.Client.EmuHawk
RefreshLabels(); RefreshLabels();
} }
void GuiFromUserConfig(OctoshockFIOConfigUser user) private void GuiFromUserConfig(OctoshockFIOConfigUser user)
{ {
cbMemcard_1.Checked = user.Memcards[0]; cbMemcard_1.Checked = user.Memcards[0];
cbMemcard_2.Checked = user.Memcards[1]; cbMemcard_2.Checked = user.Memcards[1];
@ -51,15 +51,13 @@ namespace BizHawk.Client.EmuHawk
} }
} }
OctoshockFIOConfigUser UserConfigFromGui() private OctoshockFIOConfigUser UserConfigFromGui()
{ {
var uc = new OctoshockFIOConfigUser(); var uc = new OctoshockFIOConfigUser
{
uc.Memcards[0] = cbMemcard_1.Checked; Memcards = { [0] = cbMemcard_1.Checked, [1] = cbMemcard_2.Checked },
uc.Memcards[1] = cbMemcard_2.Checked; Multitaps = { [0] = cbMultitap_1.Checked, [1] = cbMultitap_2.Checked }
};
uc.Multitaps[0] = cbMultitap_1.Checked;
uc.Multitaps[1] = cbMultitap_2.Checked;
var combos = new[] { combo_1_1, combo_1_2, combo_1_3, combo_1_4, combo_2_1, combo_2_2, combo_2_3, combo_2_4 }; var combos = new[] { combo_1_1, combo_1_2, combo_1_3, combo_1_4, combo_2_1, combo_2_2, combo_2_3, combo_2_4 };
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
@ -75,7 +73,7 @@ namespace BizHawk.Client.EmuHawk
return uc; return uc;
} }
void RefreshLabels() private void RefreshLabels()
{ {
var uc = UserConfigFromGui(); var uc = UserConfigFromGui();
@ -103,33 +101,35 @@ namespace BizHawk.Client.EmuHawk
lbl_p_2_3.Visible = b2; lbl_p_2_3.Visible = b2;
lbl_p_2_4.Visible = b2; lbl_p_2_4.Visible = b2;
var LC = uc.ToLogical(); var lc = uc.ToLogical();
var p_labels = new[] { lbl_p_1_1,lbl_p_1_2,lbl_p_1_3,lbl_p_1_4,lbl_p_2_1,lbl_p_2_2,lbl_p_2_3,lbl_p_2_4}; var pLabels = new[] { lbl_p_1_1, lbl_p_1_2, lbl_p_1_3, lbl_p_1_4, lbl_p_2_1, lbl_p_2_2, lbl_p_2_3, lbl_p_2_4 };
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
var lbl = p_labels[i]; var lbl = pLabels[i];
if (LC.PlayerAssignments[i] == -1) if (lc.PlayerAssignments[i] == -1)
{
lbl.Visible = false; lbl.Visible = false;
}
else else
{ {
lbl.Text = "P" + LC.PlayerAssignments[i]; lbl.Text = "P" + lc.PlayerAssignments[i];
lbl.Visible = true; lbl.Visible = true;
} }
} }
} }
private void cb_changed(object sender, EventArgs e) private void Cb_Changed(object sender, EventArgs e)
{ {
RefreshLabels(); RefreshLabels();
} }
private void combo_SelectedIndexChanged(object sender, EventArgs e) private void Combo_SelectedIndexChanged(object sender, EventArgs e)
{ {
RefreshLabels(); RefreshLabels();
} }
private void btnOK_Click(object sender, EventArgs e) private void BtnOk_Click(object sender, EventArgs e)
{ {
var psxSettings = ((Octoshock)Global.Emulator).GetSyncSettings(); var psxSettings = ((Octoshock)Global.Emulator).GetSyncSettings();

View File

@ -53,7 +53,7 @@
this.btnHash.TabIndex = 1; this.btnHash.TabIndex = 1;
this.btnHash.Text = "Hash"; this.btnHash.Text = "Hash";
this.btnHash.UseVisualStyleBackColor = true; this.btnHash.UseVisualStyleBackColor = true;
this.btnHash.Click += new System.EventHandler(this.btnHash_Click); this.btnHash.Click += new System.EventHandler(this.BtnHash_Click);
// //
// txtHashes // txtHashes
// //

View File

@ -1,10 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -20,18 +14,18 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent(); InitializeComponent();
} }
private void btnHash_Click(object sender, EventArgs e) private void BtnHash_Click(object sender, EventArgs e)
{ {
txtHashes.Text = ""; txtHashes.Text = "";
btnHash.Enabled = false; btnHash.Enabled = false;
try try
{ {
var psx = ((Octoshock)Global.Emulator); var psx = (Octoshock)Global.Emulator;
foreach (var disc in psx.Discs) foreach (var disc in psx.Discs)
{ {
DiscHasher hasher = new DiscHasher(disc); DiscHasher hasher = new DiscHasher(disc);
uint hash = hasher.Calculate_PSX_RedumpHash(); uint hash = hasher.Calculate_PSX_RedumpHash();
txtHashes.Text += string.Format("{0:X8} {1}\r\n", hash, disc.Name); txtHashes.Text += $"{hash:X8} {disc.Name}\r\n";
} }
} }
finally finally

View File

@ -98,7 +98,7 @@
this.btnOk.TabIndex = 2; this.btnOk.TabIndex = 2;
this.btnOk.Text = "OK"; this.btnOk.Text = "OK";
this.btnOk.UseVisualStyleBackColor = true; this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click); this.btnOk.Click += new System.EventHandler(this.BtnOk_Click);
// //
// groupBox1 // groupBox1
// //
@ -128,7 +128,7 @@
this.linkLabel1.TabIndex = 29; this.linkLabel1.TabIndex = 29;
this.linkLabel1.TabStop = true; this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "About Me"; this.linkLabel1.Text = "About Me";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel1_LinkClicked);
// //
// lblTweakedMednafen // lblTweakedMednafen
// //
@ -179,7 +179,7 @@
this.btnNiceDisplayConfig.TabIndex = 24; this.btnNiceDisplayConfig.TabIndex = 24;
this.btnNiceDisplayConfig.Text = "Change My Display Options"; this.btnNiceDisplayConfig.Text = "Change My Display Options";
this.btnNiceDisplayConfig.UseVisualStyleBackColor = true; this.btnNiceDisplayConfig.UseVisualStyleBackColor = true;
this.btnNiceDisplayConfig.Click += new System.EventHandler(this.btnNiceDisplayConfig_Click); this.btnNiceDisplayConfig.Click += new System.EventHandler(this.BtnNiceDisplayConfig_Click);
// //
// lblMednafen // lblMednafen
// //
@ -263,7 +263,7 @@
this.rbClipNone.Text = "None"; this.rbClipNone.Text = "None";
this.toolTip1.SetToolTip(this.rbClipNone, resources.GetString("rbClipNone.ToolTip")); this.toolTip1.SetToolTip(this.rbClipNone, resources.GetString("rbClipNone.ToolTip"));
this.rbClipNone.UseVisualStyleBackColor = true; this.rbClipNone.UseVisualStyleBackColor = true;
this.rbClipNone.CheckedChanged += new System.EventHandler(this.rbClipNone_CheckedChanged); this.rbClipNone.CheckedChanged += new System.EventHandler(this.RbClipNone_CheckedChanged);
// //
// rbClipToFramebuffer // rbClipToFramebuffer
// //
@ -278,7 +278,7 @@
"s framebuffer.\r\nHorizontal letterbox bars may be re-added in Mednafen-style reso" + "s framebuffer.\r\nHorizontal letterbox bars may be re-added in Mednafen-style reso" +
"lution modes to maintain correct AR."); "lution modes to maintain correct AR.");
this.rbClipToFramebuffer.UseVisualStyleBackColor = true; this.rbClipToFramebuffer.UseVisualStyleBackColor = true;
this.rbClipToFramebuffer.CheckedChanged += new System.EventHandler(this.rbClipToFramebuffer_CheckedChanged); this.rbClipToFramebuffer.CheckedChanged += new System.EventHandler(this.RbClipToFramebuffer_CheckedChanged);
// //
// rbClipBasic // rbClipBasic
// //
@ -291,7 +291,7 @@
this.rbClipBasic.Text = "Basic Clipping"; this.rbClipBasic.Text = "Basic Clipping";
this.toolTip1.SetToolTip(this.rbClipBasic, "A mednafen option -- appears to be 5.5% horizontally"); this.toolTip1.SetToolTip(this.rbClipBasic, "A mednafen option -- appears to be 5.5% horizontally");
this.rbClipBasic.UseVisualStyleBackColor = true; this.rbClipBasic.UseVisualStyleBackColor = true;
this.rbClipBasic.CheckedChanged += new System.EventHandler(this.rbClipHorizontal_CheckedChanged); this.rbClipBasic.CheckedChanged += new System.EventHandler(this.RbClipHorizontal_CheckedChanged);
// //
// lblPAL // lblPAL
// //
@ -350,7 +350,7 @@
this.btnAreaFull.TabIndex = 40; this.btnAreaFull.TabIndex = 40;
this.btnAreaFull.Text = "Full [0,239] and [0,287]"; this.btnAreaFull.Text = "Full [0,239] and [0,287]";
this.btnAreaFull.UseVisualStyleBackColor = true; this.btnAreaFull.UseVisualStyleBackColor = true;
this.btnAreaFull.Click += new System.EventHandler(this.btnAreaFull_Click); this.btnAreaFull.Click += new System.EventHandler(this.BtnAreaFull_Click);
// //
// label4 // label4
// //

View File

@ -1,10 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Cores.Sony.PSX; using BizHawk.Emulation.Cores.Sony.PSX;
@ -14,10 +9,10 @@ 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
string lblPixelPro_text, lblMednafen_text, lblTweakedMednafen_text; private readonly string lblPixelPro_text, lblMednafen_text, lblTweakedMednafen_text;
public PSXOptions(Octoshock.Settings settings, Octoshock.SyncSettings syncSettings, OctoshockDll.eVidStandard vidStandard, Size currentVideoSize) private PSXOptions(Octoshock.Settings settings, Octoshock.SyncSettings syncSettings, OctoshockDll.eVidStandard vidStandard, Size currentVideoSize)
{ {
InitializeComponent(); InitializeComponent();
_settings = settings; _settings = settings;
@ -26,8 +21,13 @@ namespace BizHawk.Client.EmuHawk
_previewVideoSize = currentVideoSize; _previewVideoSize = currentVideoSize;
if (_previewVideoStandard == OctoshockDll.eVidStandard.NTSC) if (_previewVideoStandard == OctoshockDll.eVidStandard.NTSC)
lblNTSC.Font = new System.Drawing.Font(lblNTSC.Font, FontStyle.Bold); {
else lblPAL.Font = new System.Drawing.Font(lblPAL.Font, FontStyle.Bold); lblNTSC.Font = new Font(lblNTSC.Font, FontStyle.Bold);
}
else
{
lblPAL.Font = new Font(lblPAL.Font, FontStyle.Bold);
}
lblPixelPro_text = lblPixelPro.Text; lblPixelPro_text = lblPixelPro.Text;
lblMednafen_text = lblMednafen.Text; lblMednafen_text = lblMednafen.Text;
@ -54,13 +54,13 @@ namespace BizHawk.Client.EmuHawk
PAL_LastLineNumeric.Value = _settings.ScanlineEnd_PAL; PAL_LastLineNumeric.Value = _settings.ScanlineEnd_PAL;
} }
Size _previewVideoSize; private Size _previewVideoSize;
OctoshockDll.eVidStandard _previewVideoStandard; private readonly OctoshockDll.eVidStandard _previewVideoStandard;
Octoshock.Settings _settings; private readonly Octoshock.Settings _settings;
Octoshock.SyncSettings _syncSettings; private readonly Octoshock.SyncSettings _syncSettings;
bool _dispSettingsSet = false; private bool _dispSettingsSet;
private void btnNiceDisplayConfig_Click(object sender, EventArgs e) private void BtnNiceDisplayConfig_Click(object sender, EventArgs e)
{ {
_dispSettingsSet = true; _dispSettingsSet = true;
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");
@ -68,18 +68,18 @@ namespace BizHawk.Client.EmuHawk
public static DialogResult DoSettingsDialog(IWin32Window owner) public static DialogResult DoSettingsDialog(IWin32Window owner)
{ {
var psx = ((Octoshock)Global.Emulator); 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;
var dlg = new PSXOptions(s,ss,vid,size); var dlg = new PSXOptions(s, ss, vid, size);
var result = dlg.ShowDialog(owner); var result = dlg.ShowDialog(owner);
return result; return result;
} }
void SyncSettingsFromGui(Octoshock.Settings settings, Octoshock.SyncSettings syncSettings) private void SyncSettingsFromGui(Octoshock.Settings settings, Octoshock.SyncSettings syncSettings)
{ {
if (rbPixelPro.Checked) settings.ResolutionMode = Octoshock.eResolutionMode.PixelPro; if (rbPixelPro.Checked) settings.ResolutionMode = Octoshock.eResolutionMode.PixelPro;
if (rbDebugMode.Checked) settings.ResolutionMode = Octoshock.eResolutionMode.Debug; if (rbDebugMode.Checked) settings.ResolutionMode = Octoshock.eResolutionMode.Debug;
@ -90,9 +90,9 @@ namespace BizHawk.Client.EmuHawk
if (rbClipBasic.Checked) settings.HorizontalClipping = Octoshock.eHorizontalClipping.Basic; if (rbClipBasic.Checked) settings.HorizontalClipping = Octoshock.eHorizontalClipping.Basic;
if (rbClipToFramebuffer.Checked) settings.HorizontalClipping = Octoshock.eHorizontalClipping.Framebuffer; if (rbClipToFramebuffer.Checked) settings.HorizontalClipping = Octoshock.eHorizontalClipping.Framebuffer;
if(rbWeave.Checked) _settings.DeinterlaceMode = Octoshock.eDeinterlaceMode.Weave; if (rbWeave.Checked) _settings.DeinterlaceMode = Octoshock.eDeinterlaceMode.Weave;
if(rbBob.Checked) _settings.DeinterlaceMode = Octoshock.eDeinterlaceMode.Bob; if (rbBob.Checked) _settings.DeinterlaceMode = Octoshock.eDeinterlaceMode.Bob;
if(rbBobOffset.Checked) _settings.DeinterlaceMode = Octoshock.eDeinterlaceMode.BobOffset; if (rbBobOffset.Checked) _settings.DeinterlaceMode = Octoshock.eDeinterlaceMode.BobOffset;
settings.ScanlineStart_NTSC = (int)NTSC_FirstLineNumeric.Value; settings.ScanlineStart_NTSC = (int)NTSC_FirstLineNumeric.Value;
settings.ScanlineEnd_NTSC = (int)NTSC_LastLineNumeric.Value; settings.ScanlineEnd_NTSC = (int)NTSC_LastLineNumeric.Value;
@ -104,14 +104,14 @@ namespace BizHawk.Client.EmuHawk
syncSettings.EnableLEC = cbLEC.Checked; syncSettings.EnableLEC = cbLEC.Checked;
} }
private void btnOk_Click(object sender, EventArgs e) private void BtnOk_Click(object sender, EventArgs e)
{ {
if (_dispSettingsSet) if (_dispSettingsSet)
{ {
Global.Config.DispManagerAR = Config.EDispManagerAR.System; Global.Config.DispManagerAR = Config.EDispManagerAR.System;
Global.Config.DispFixAspectRatio = true; Global.Config.DispFixAspectRatio = true;
Global.Config.DispFixScaleInteger = false; Global.Config.DispFixScaleInteger = false;
Global.Config.DispFinalFilter = 1; //bilinear, I hope Global.Config.DispFinalFilter = 1; // bilinear, I hope
} }
SyncSettingsFromGui(_settings, _syncSettings); SyncSettingsFromGui(_settings, _syncSettings);
@ -123,7 +123,7 @@ namespace BizHawk.Client.EmuHawk
Close(); Close();
} }
private void btnAreaFull_Click(object sender, EventArgs e) private void BtnAreaFull_Click(object sender, EventArgs e)
{ {
NTSC_FirstLineNumeric.Value = 0; NTSC_FirstLineNumeric.Value = 0;
NTSC_LastLineNumeric.Value = 239; NTSC_LastLineNumeric.Value = 239;
@ -132,28 +132,28 @@ namespace BizHawk.Client.EmuHawk
SyncLabels(); SyncLabels();
} }
void SyncLabels() private void SyncLabels()
{ {
var temp = _settings.Clone(); var temp = _settings.Clone();
var syncTemp = _syncSettings.Clone(); var syncTemp = _syncSettings.Clone();
SyncSettingsFromGui(temp, syncTemp); SyncSettingsFromGui(temp, syncTemp);
_settings.Validate(); _settings.Validate();
//actually, I think this is irrelevant. But it's nice in case we want to do some kind of a more detailed simulation later // actually, I think this is irrelevant. But it's nice in case we want to do some kind of a more detailed simulation later
int w = _previewVideoSize.Width; int w = _previewVideoSize.Width;
int h = _previewVideoSize.Height; int h = _previewVideoSize.Height;
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", string.Format("{0}x{1}", ri.Resolution.Width, ri.Resolution.Height)); ; lblPixelPro.Text = lblPixelPro_text.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", string.Format("{0}x{1}", ri.Resolution.Width, ri.Resolution.Height)); lblMednafen.Text = lblMednafen_text.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", string.Format("{0}x{1}", ri.Resolution.Width, ri.Resolution.Height)); lblTweakedMednafen.Text = lblTweakedMednafen_text.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)
@ -161,23 +161,22 @@ namespace BizHawk.Client.EmuHawk
SyncLabels(); SyncLabels();
} }
private void RbClipHorizontal_CheckedChanged(object sender, EventArgs e)
private void rbClipHorizontal_CheckedChanged(object sender, EventArgs e)
{ {
SyncLabels(); SyncLabels();
} }
private void rbClipToFramebuffer_CheckedChanged(object sender, EventArgs e) private void RbClipToFramebuffer_CheckedChanged(object sender, EventArgs e)
{ {
SyncLabels(); SyncLabels();
} }
private void rbClipNone_CheckedChanged(object sender, EventArgs e) private void RbClipNone_CheckedChanged(object sender, EventArgs e)
{ {
SyncLabels(); SyncLabels();
} }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{ {
MessageBox.Show(@"These options control BizHawk's Display Options to make it act quite a lot like Mednafen: MessageBox.Show(@"These options control BizHawk's Display Options to make it act quite a lot like Mednafen:
@ -191,7 +190,5 @@ But: 1. we think we improved on it a tiny bit with the tweaked mode
And: 2. It's not suitable for detailed scrutinizing of graphics And: 2. It's not suitable for detailed scrutinizing of graphics
"); ");
} }
} }
} }

View File

@ -114,7 +114,7 @@
this.RecentForROMs.TabIndex = 207; this.RecentForROMs.TabIndex = 207;
this.RecentForROMs.Text = "Always use recent path for ROMs"; this.RecentForROMs.Text = "Always use recent path for ROMs";
this.RecentForROMs.UseVisualStyleBackColor = true; this.RecentForROMs.UseVisualStyleBackColor = true;
this.RecentForROMs.CheckedChanged += new System.EventHandler(this.RecentForROMs_CheckedChanged); this.RecentForROMs.CheckedChanged += new System.EventHandler(this.RecentForRoms_CheckedChanged);
// //
// DefaultsBtn // DefaultsBtn
// //

View File

@ -13,7 +13,6 @@ namespace BizHawk.Client.EmuHawk
{ {
// All path text boxes should do some kind of error checking // All path text boxes should do some kind of error checking
// Config path under base, config will default to %exe% // Config path under base, config will default to %exe%
private void LockDownCores() private void LockDownCores()
{ {
if (VersionInfo.DeveloperBuild) if (VersionInfo.DeveloperBuild)
@ -26,23 +25,17 @@ namespace BizHawk.Client.EmuHawk
foreach (var core in coresToHide) foreach (var core in coresToHide)
{ {
PathTabControl.TabPages.Remove( PathTabControl.TabPages.Remove(
PathTabControl.TabPages().FirstOrDefault(x => x.Name == core) ?? new TabPage()); PathTabControl.TabPages().FirstOrDefault(tp => tp.Name == core) ?? new TabPage());
} }
} }
private static AutoCompleteStringCollection AutoCompleteOptions private static AutoCompleteStringCollection AutoCompleteOptions => new AutoCompleteStringCollection
{ {
get "%recent%",
{ "%exe%",
return new AutoCompleteStringCollection ".\\",
{ "..\\",
"%recent%", };
"%exe%",
".\\",
"..\\",
};
}
}
public PathConfig() public PathConfig()
{ {
@ -71,11 +64,11 @@ namespace BizHawk.Client.EmuHawk
{ {
var global = PathTabControl.TabPages var global = PathTabControl.TabPages
.OfType<TabPage>() .OfType<TabPage>()
.First(x => x.Name.ToUpper().Contains("GLOBAL")); .First(tp => tp.Name.ToUpper().Contains("GLOBAL"));
return PathTabControl.TabPages return PathTabControl.TabPages
.OfType<TabPage>() .OfType<TabPage>()
.FirstOrDefault(x => x.Name.ToUpper().StartsWith(name.ToUpper())) .FirstOrDefault(tp => tp.Name.ToUpper().StartsWith(name.ToUpper()))
?? global; ?? global;
} }
@ -85,17 +78,20 @@ namespace BizHawk.Client.EmuHawk
PathTabControl.TabPages.Clear(); PathTabControl.TabPages.Clear();
// Separate by system // Separate by system
var systems = Global.Config.PathEntries.Select(x => x.SystemDisplayName).Distinct().ToList(); var systems = Global.Config.PathEntries
.Select(s => s.SystemDisplayName)
.Distinct()
.ToList();
systems.Sort(); systems.Sort();
// Hacky way to put global first // Hacky way to put global first
var global = systems.FirstOrDefault(x => x == "Global"); var global = systems.FirstOrDefault(s => s == "Global");
systems.Remove(global); systems.Remove(global);
systems.Insert(0, global); systems.Insert(0, global);
var tabPages = new List<TabPage>(systems.Count); var tabPages = new List<TabPage>(systems.Count);
int _x = UIHelper.ScaleX(6); int x = UIHelper.ScaleX(6);
int textboxWidth = UIHelper.ScaleX(70); int textboxWidth = UIHelper.ScaleX(70);
int padding = UIHelper.ScaleX(5); int padding = UIHelper.ScaleX(5);
int buttonWidth = UIHelper.ScaleX(26); int buttonWidth = UIHelper.ScaleX(26);
@ -106,7 +102,7 @@ namespace BizHawk.Client.EmuHawk
foreach (var systemDisplayName in systems) foreach (var systemDisplayName in systems)
{ {
var systemId = Global.Config.PathEntries.FirstOrDefault(x => x.SystemDisplayName == systemDisplayName).System; var systemId = Global.Config.PathEntries.First(p => p.SystemDisplayName == systemDisplayName).System;
var t = new TabPage var t = new TabPage
{ {
Text = systemDisplayName, Text = systemDisplayName,
@ -114,15 +110,19 @@ namespace BizHawk.Client.EmuHawk
Width = UIHelper.ScaleX(200), // Initial Left/Width of child controls are based on this size. Width = UIHelper.ScaleX(200), // Initial Left/Width of child controls are based on this size.
AutoScroll = true AutoScroll = true
}; };
var paths = pathCollection.Where(x => x.System == systemId).OrderBy(x => x.Ordinal).ThenBy(x => x.Type).ToList(); var paths = pathCollection
.Where(p => p.System == systemId)
.OrderBy(p => p.Ordinal)
.ThenBy(p => p.Type)
.ToList();
var _y = UIHelper.ScaleY(14); var y = UIHelper.ScaleY(14);
foreach (var path in paths) foreach (var path in paths)
{ {
var box = new TextBox var box = new TextBox
{ {
Text = path.Path, Text = path.Path,
Location = new Point(_x, _y), Location = new Point(x, y),
Width = textboxWidth, Width = textboxWidth,
Name = path.Type, Name = path.Type,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right, Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
@ -136,7 +136,7 @@ namespace BizHawk.Client.EmuHawk
{ {
Text = "", Text = "",
Image = Properties.Resources.OpenFile, Image = Properties.Resources.OpenFile,
Location = new Point(widgetOffset, _y + buttonOffsetY), Location = new Point(widgetOffset, y + buttonOffsetY),
Size = new Size(buttonWidth, buttonHeight), Size = new Size(buttonWidth, buttonHeight),
Name = path.Type, Name = path.Type,
Anchor = AnchorStyles.Top | AnchorStyles.Right, Anchor = AnchorStyles.Top | AnchorStyles.Right,
@ -160,7 +160,7 @@ namespace BizHawk.Client.EmuHawk
Name = "Global", Name = "Global",
Text = "", Text = "",
Image = Properties.Resources.Help, Image = Properties.Resources.Help,
Location = new Point(UIHelper.ScaleX(115), _y + buttonOffsetY), Location = new Point(UIHelper.ScaleX(115), y + buttonOffsetY),
Size = new Size(buttonWidth, buttonHeight), Size = new Size(buttonWidth, buttonHeight),
Anchor = AnchorStyles.Top | AnchorStyles.Right Anchor = AnchorStyles.Top | AnchorStyles.Right
}; };
@ -181,9 +181,9 @@ namespace BizHawk.Client.EmuHawk
} }
var label = new Label var label = new Label
{ {
Text = path.Type, Text = path.Type,
Location = new Point(widgetOffset + buttonWidth + padding + infoPadding, _y + UIHelper.ScaleY(4)), Location = new Point(widgetOffset + buttonWidth + padding + infoPadding, y + UIHelper.ScaleY(4)),
Size = new Size(UIHelper.ScaleX(100), UIHelper.ScaleY(15)), Size = new Size(UIHelper.ScaleX(100), UIHelper.ScaleY(15)),
Name = path.Type, Name = path.Type,
Anchor = AnchorStyles.Top | AnchorStyles.Right, Anchor = AnchorStyles.Top | AnchorStyles.Right,
@ -193,7 +193,7 @@ namespace BizHawk.Client.EmuHawk
t.Controls.Add(btn); t.Controls.Add(btn);
t.Controls.Add(box); t.Controls.Add(box);
_y += rowHeight; y += rowHeight;
} }
var sys = systemDisplayName; var sys = systemDisplayName;
@ -235,7 +235,7 @@ namespace BizHawk.Client.EmuHawk
foreach (var t in AllPathBoxes) foreach (var t in AllPathBoxes)
{ {
var pathEntry = Global.Config.PathEntries.FirstOrDefault(x => x.System == t.Parent.Name && x.Type == t.Name); var pathEntry = Global.Config.PathEntries.First(p => p.System == t.Parent.Name && p.Type == t.Name);
pathEntry.Path = t.Text; pathEntry.Path = t.Text;
} }
} }
@ -243,7 +243,7 @@ namespace BizHawk.Client.EmuHawk
private void DoRomToggle() private void DoRomToggle()
{ {
AllPathControls AllPathControls
.Where(x => x.Name == "ROM") .Where(c => c.Name == "ROM")
.ToList() .ToList()
.ForEach(control => control.Enabled = !RecentForROMs.Checked); .ForEach(control => control.Enabled = !RecentForROMs.Checked);
} }
@ -284,7 +284,7 @@ namespace BizHawk.Client.EmuHawk
LockDownCores(); LockDownCores();
} }
private void RecentForROMs_CheckedChanged(object sender, EventArgs e) private void RecentForRoms_CheckedChanged(object sender, EventArgs e)
{ {
DoRomToggle(); DoRomToggle();
} }

View File

@ -96,27 +96,27 @@ namespace BizHawk.Client.EmuHawk
snesSettings.Profile = "Performance"; snesSettings.Profile = "Performance";
PutSyncSettings<LibsnesCore>(snesSettings); PutSyncSettings<LibsnesCore>(snesSettings);
//Saturn // Saturn
var saturnSettings = GetSyncSettings<Yabause, Yabause.SaturnSyncSettings>(); var saturnSettings = GetSyncSettings<Yabause, Yabause.SaturnSyncSettings>();
saturnSettings.SkipBios = false; saturnSettings.SkipBios = false;
PutSyncSettings<Yabause>(saturnSettings); PutSyncSettings<Yabause>(saturnSettings);
//Genesis // Genesis
var genesisSettings = GetSyncSettings<GPGX, GPGX.GPGXSyncSettings>(); var genesisSettings = GetSyncSettings<GPGX, GPGX.GPGXSyncSettings>();
genesisSettings.Region = LibGPGX.Region.Autodetect; genesisSettings.Region = LibGPGX.Region.Autodetect;
PutSyncSettings<GPGX>(genesisSettings); PutSyncSettings<GPGX>(genesisSettings);
//SMS // SMS
var smsSettings = GetSyncSettings<SMS, SMS.SMSSyncSettings>(); var smsSettings = GetSyncSettings<SMS, SMS.SMSSyncSettings>();
smsSettings.UseBIOS = false; smsSettings.UseBIOS = false;
PutSyncSettings<SMS>(smsSettings); PutSyncSettings<SMS>(smsSettings);
//Coleco // Coleco
var colecoSettings = GetSyncSettings<ColecoVision, ColecoVision.ColecoSyncSettings>(); var colecoSettings = GetSyncSettings<ColecoVision, ColecoVision.ColecoSyncSettings>();
colecoSettings.SkipBiosIntro = false; colecoSettings.SkipBiosIntro = false;
PutSyncSettings<ColecoVision>(colecoSettings); PutSyncSettings<ColecoVision>(colecoSettings);
//A2600 // A2600
var a2600Settings = GetSyncSettings<Atari2600, Atari2600.A2600SyncSettings>(); var a2600Settings = GetSyncSettings<Atari2600, Atari2600.A2600SyncSettings>();
a2600Settings.FastScBios = true; a2600Settings.FastScBios = true;
a2600Settings.LeftDifficulty = false; a2600Settings.LeftDifficulty = false;
@ -302,15 +302,19 @@ namespace BizHawk.Client.EmuHawk
} }
else if (Global.Config.SelectedProfile == Config.ClientProfile.Custom) else if (Global.Config.SelectedProfile == Config.ClientProfile.Custom)
{ {
//Disabled for now // Disabled for now
//DisplayProfileSettingBoxes(true); ////DisplayProfileSettingBoxes(true);
} }
bool oldUpdateAutoCheckEnabled = Global.Config.Update_AutoCheckEnabled; bool oldUpdateAutoCheckEnabled = Global.Config.Update_AutoCheckEnabled;
Global.Config.Update_AutoCheckEnabled = AutoCheckForUpdates.Checked; Global.Config.Update_AutoCheckEnabled = AutoCheckForUpdates.Checked;
if (Global.Config.Update_AutoCheckEnabled != oldUpdateAutoCheckEnabled) if (Global.Config.Update_AutoCheckEnabled != oldUpdateAutoCheckEnabled)
{ {
if (!Global.Config.Update_AutoCheckEnabled) UpdateChecker.ResetHistory(); if (!Global.Config.Update_AutoCheckEnabled)
{
UpdateChecker.ResetHistory();
}
UpdateChecker.BeginCheck(); // Call even if auto checking is disabled to trigger event (it won't actually check) UpdateChecker.BeginCheck(); // Call even if auto checking is disabled to trigger event (it won't actually check)
} }
@ -351,10 +355,12 @@ namespace BizHawk.Client.EmuHawk
{ {
ProfileDialogHelpTexBox.Text = "Save Screenshot with Savestates: \r\n * Required for TASing \r\n * Not Recommended for \r\n Longplays or Casual Gaming"; ProfileDialogHelpTexBox.Text = "Save Screenshot with Savestates: \r\n * Required for TASing \r\n * Not Recommended for \r\n Longplays or Casual Gaming";
} }
private void SaveLargeScreenshotStatesCheckBox_MouseHover(object sender, EventArgs e) private void SaveLargeScreenshotStatesCheckBox_MouseHover(object sender, EventArgs e)
{ {
ProfileDialogHelpTexBox.Text = "Save Large Screenshot With States: \r\n * Required for TASing \r\n * Not Recommended for \r\n Longplays or Casual Gaming"; ProfileDialogHelpTexBox.Text = "Save Large Screenshot With States: \r\n * Required for TASing \r\n * Not Recommended for \r\n Longplays or Casual Gaming";
} }
private void AllowUDLRCheckBox_MouseHover(object sender, EventArgs e) private void AllowUDLRCheckBox_MouseHover(object sender, EventArgs e)
{ {
ProfileDialogHelpTexBox.Text = "All Up+Down or Left+Right: \r\n * Useful for TASing \r\n * Unchecked for Casual Gaming \r\n * Unknown for longplays"; ProfileDialogHelpTexBox.Text = "All Up+Down or Left+Right: \r\n * Useful for TASing \r\n * Unchecked for Casual Gaming \r\n * Unknown for longplays";
@ -365,11 +371,12 @@ namespace BizHawk.Client.EmuHawk
where TEmulator : IEmulator where TEmulator : IEmulator
{ {
// should we complain if we get a successful object from the config file, but it is the wrong type? // should we complain if we get a successful object from the config file, but it is the wrong type?
object fromcore = null; object fromcore = null;
var settable = new SettingsAdapter(Global.Emulator); var settable = new SettingsAdapter(Global.Emulator);
if (settable.HasSyncSettings) if (settable.HasSyncSettings)
{
fromcore = settable.GetSyncSettings(); fromcore = settable.GetSyncSettings();
}
return fromcore as TSetting return fromcore as TSetting
?? Global.Config.GetCoreSyncSettings<TEmulator>() as TSetting ?? Global.Config.GetCoreSyncSettings<TEmulator>() as TSetting
@ -381,11 +388,12 @@ namespace BizHawk.Client.EmuHawk
where TEmulator : IEmulator where TEmulator : IEmulator
{ {
// should we complain if we get a successful object from the config file, but it is the wrong type? // should we complain if we get a successful object from the config file, but it is the wrong type?
object fromcore = null; object fromcore = null;
var settable = new SettingsAdapter(Global.Emulator); var settable = new SettingsAdapter(Global.Emulator);
if (settable.HasSettings) if (settable.HasSettings)
{
fromcore = settable.GetSettings(); fromcore = settable.GetSettings();
}
return fromcore as TSetting return fromcore as TSetting
?? Global.Config.GetCoreSettings<TEmulator>() as TSetting ?? Global.Config.GetCoreSettings<TEmulator>() as TSetting

View File

@ -131,7 +131,7 @@
this.OK.TabIndex = 0; this.OK.TabIndex = 0;
this.OK.Text = "&OK"; this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true; this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click); this.OK.Click += new System.EventHandler(this.Ok_Click);
// //
// Cancel // Cancel
// //
@ -814,7 +814,7 @@
this.btnResetCompression.TabIndex = 23; this.btnResetCompression.TabIndex = 23;
this.toolTip1.SetToolTip(this.btnResetCompression, "Reset to default"); this.toolTip1.SetToolTip(this.btnResetCompression, "Reset to default");
this.btnResetCompression.UseVisualStyleBackColor = true; this.btnResetCompression.UseVisualStyleBackColor = true;
this.btnResetCompression.Click += new System.EventHandler(this.btnResetCompression_Click); this.btnResetCompression.Click += new System.EventHandler(this.BtnResetCompression_Click);
// //
// trackBarCompression // trackBarCompression
// //
@ -826,7 +826,7 @@
this.trackBarCompression.TabIndex = 20; this.trackBarCompression.TabIndex = 20;
this.toolTip1.SetToolTip(this.trackBarCompression, "0 = None; 9 = Maximum"); this.toolTip1.SetToolTip(this.trackBarCompression, "0 = None; 9 = Maximum");
this.trackBarCompression.Value = 1; this.trackBarCompression.Value = 1;
this.trackBarCompression.ValueChanged += new System.EventHandler(this.trackBarCompression_ValueChanged); this.trackBarCompression.ValueChanged += new System.EventHandler(this.TrackBarCompression_ValueChanged);
// //
// nudCompression // nudCompression
// //
@ -844,7 +844,7 @@
0, 0,
0, 0,
0}); 0});
this.nudCompression.ValueChanged += new System.EventHandler(this.nudCompression_ValueChanged); this.nudCompression.ValueChanged += new System.EventHandler(this.NudCompression_ValueChanged);
// //
// groupBox7 // groupBox7
// //

View File

@ -12,7 +12,7 @@ namespace BizHawk.Client.EmuHawk
private long _stateSize; private long _stateSize;
private int _mediumStateSize; private int _mediumStateSize;
private int _largeStateSize; private int _largeStateSize;
private int _stateSizeCategory = 1; //1 = small, 2 = med, 3 = larg //TODO: enum private int _stateSizeCategory = 1; // 1 = small, 2 = med, 3 = larg //TODO: enum
public RewindConfig() public RewindConfig()
{ {
@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Global.Rewinder.HasBuffer) if (Global.Rewinder.HasBuffer)
{ {
FullnessLabel.Text = String.Format("{0:0.00}", Global.Rewinder.FullnessRatio * 100) + "%"; FullnessLabel.Text = $"{Global.Rewinder.FullnessRatio * 100:0.00}" + "%";
RewindFramesUsedLabel.Text = Global.Rewinder.Count.ToString(); RewindFramesUsedLabel.Text = Global.Rewinder.Count.ToString();
} }
else else
@ -57,13 +57,13 @@ namespace BizHawk.Client.EmuHawk
SetStateSize(); SetStateSize();
var medium_state_size_kb = Global.Config.Rewind_MediumStateSize / 1024; var mediumStateSizeKb = Global.Config.Rewind_MediumStateSize / 1024;
var large_state_size_kb = Global.Config.Rewind_LargeStateSize / 1024; var largeStateSizeKb = Global.Config.Rewind_LargeStateSize / 1024;
MediumStateTrackbar.Value = medium_state_size_kb; MediumStateTrackbar.Value = mediumStateSizeKb;
MediumStateUpDown.Value = medium_state_size_kb; MediumStateUpDown.Value = mediumStateSizeKb;
LargeStateTrackbar.Value = large_state_size_kb; LargeStateTrackbar.Value = largeStateSizeKb;
LargeStateUpDown.Value = large_state_size_kb; LargeStateUpDown.Value = largeStateSizeKb;
nudCompression.Value = Global.Config.SaveStateCompressionLevelNormal; nudCompression.Value = Global.Config.SaveStateCompressionLevelNormal;
@ -87,19 +87,17 @@ namespace BizHawk.Client.EmuHawk
ScreenshotInStatesCheckbox.Checked; ScreenshotInStatesCheckbox.Checked;
} }
string FormatKB(long n) private string FormatKB(long n)
{ {
double num = n / 1024.0; double num = n / 1024.0;
if (num >= 1024) if (num >= 1024)
{ {
num /= 1024.0; num /= 1024.0;
return String.Format("{0:0.00}", num) + " MB"; return $"{num:0.00}" + " MB";
}
else
{
return String.Format("{0:0.00}", num) + " KB";
} }
return $"{num:0.00}" + " KB";
} }
private void SetStateSize() private void SetStateSize()
@ -147,12 +145,16 @@ namespace BizHawk.Client.EmuHawk
private void PutRewindSetting<T>(ref T setting, T value) where T : IEquatable<T> private void PutRewindSetting<T>(ref T setting, T value) where T : IEquatable<T>
{ {
if (setting.Equals(value)) return; if (setting.Equals(value))
{
return;
}
setting = value; setting = value;
TriggerRewindSettingsReload = true; TriggerRewindSettingsReload = true;
} }
private void OK_Click(object sender, EventArgs e) private void Ok_Click(object sender, EventArgs e)
{ {
// These settings are used by DoRewindSettings, which we'll only call if anything actually changed (i.e. preserve rewind history if possible) // These settings are used by DoRewindSettings, which we'll only call if anything actually changed (i.e. preserve rewind history if possible)
PutRewindSetting(ref Global.Config.RewindEnabledSmall, SmallStateEnabledBox.Checked); PutRewindSetting(ref Global.Config.RewindEnabledSmall, SmallStateEnabledBox.Checked);
@ -240,12 +242,13 @@ namespace BizHawk.Client.EmuHawk
private void MediumStateTrackbar_ValueChanged(object sender, EventArgs e) private void MediumStateTrackbar_ValueChanged(object sender, EventArgs e)
{ {
MediumStateUpDown.Value = (sender as TrackBar).Value; MediumStateUpDown.Value = ((TrackBar)sender).Value;
if (MediumStateUpDown.Value > LargeStateUpDown.Value) if (MediumStateUpDown.Value > LargeStateUpDown.Value)
{ {
LargeStateUpDown.Value = MediumStateUpDown.Value; LargeStateUpDown.Value = MediumStateUpDown.Value;
LargeStateTrackbar.Value = (int)MediumStateUpDown.Value; LargeStateTrackbar.Value = (int)MediumStateUpDown.Value;
} }
_mediumStateSize = MediumStateTrackbar.Value * 1024; _mediumStateSize = MediumStateTrackbar.Value * 1024;
_largeStateSize = LargeStateTrackbar.Value * 1024; _largeStateSize = LargeStateTrackbar.Value * 1024;
SetStateSize(); SetStateSize();
@ -253,12 +256,13 @@ namespace BizHawk.Client.EmuHawk
private void MediumStateUpDown_ValueChanged(object sender, EventArgs e) private void MediumStateUpDown_ValueChanged(object sender, EventArgs e)
{ {
MediumStateTrackbar.Value = (int)(sender as NumericUpDown).Value; MediumStateTrackbar.Value = (int)((NumericUpDown)sender).Value;
if (MediumStateUpDown.Value > LargeStateUpDown.Value) if (MediumStateUpDown.Value > LargeStateUpDown.Value)
{ {
LargeStateUpDown.Value = MediumStateUpDown.Value; LargeStateUpDown.Value = MediumStateUpDown.Value;
LargeStateTrackbar.Value = (int)MediumStateUpDown.Value; LargeStateTrackbar.Value = (int)MediumStateUpDown.Value;
} }
_mediumStateSize = MediumStateTrackbar.Value * 1024; _mediumStateSize = MediumStateTrackbar.Value * 1024;
_largeStateSize = LargeStateTrackbar.Value * 1024; _largeStateSize = LargeStateTrackbar.Value * 1024;
SetStateSize(); SetStateSize();
@ -273,8 +277,9 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
LargeStateUpDown.Value = (sender as TrackBar).Value; LargeStateUpDown.Value = ((TrackBar)sender).Value;
} }
_mediumStateSize = MediumStateTrackbar.Value * 1024; _mediumStateSize = MediumStateTrackbar.Value * 1024;
_largeStateSize = LargeStateTrackbar.Value * 1024; _largeStateSize = LargeStateTrackbar.Value * 1024;
SetStateSize(); SetStateSize();
@ -289,8 +294,9 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
LargeStateTrackbar.Value = (int)(sender as NumericUpDown).Value; LargeStateTrackbar.Value = (int)((NumericUpDown)sender).Value;
} }
_mediumStateSize = MediumStateTrackbar.Value * 1024; _mediumStateSize = MediumStateTrackbar.Value * 1024;
_largeStateSize = LargeStateTrackbar.Value * 1024; _largeStateSize = LargeStateTrackbar.Value * 1024;
SetStateSize(); SetStateSize();
@ -298,48 +304,48 @@ namespace BizHawk.Client.EmuHawk
private void CalculateEstimates() private void CalculateEstimates()
{ {
long avg_state_size; long avgStateSize;
if (UseDeltaCompression.Checked || _stateSize == 0) if (UseDeltaCompression.Checked || _stateSize == 0)
{ {
if (Global.Rewinder.Count > 0) if (Global.Rewinder.Count > 0)
{ {
avg_state_size = Global.Rewinder.Size / Global.Rewinder.Count; avgStateSize = Global.Rewinder.Size / Global.Rewinder.Count;
} }
else else
{ {
avg_state_size = _stateSize; avgStateSize = _stateSize;
} }
} }
else else
{ {
avg_state_size = _stateSize; avgStateSize = _stateSize;
} }
var buffer_size = (long)(BufferSizeUpDown.Value); var bufferSize = (long)BufferSizeUpDown.Value;
buffer_size *= 1024 * 1024; bufferSize *= 1024 * 1024;
var est_frames = buffer_size / avg_state_size; var estFrames = bufferSize / avgStateSize;
long est_frequency = 0; long estFrequency = 0;
switch (_stateSizeCategory) switch (_stateSizeCategory)
{ {
case 1: case 1:
est_frequency = (long)SmallSavestateNumeric.Value; estFrequency = (long)SmallSavestateNumeric.Value;
break; break;
case 2: case 2:
est_frequency = (long)MediumSavestateNumeric.Value; estFrequency = (long)MediumSavestateNumeric.Value;
break; break;
case 3: case 3:
est_frequency = (long)LargeSavestateNumeric.Value; estFrequency = (long)LargeSavestateNumeric.Value;
break; break;
} }
long est_total_frames = est_frames * est_frequency;
double minutes = est_total_frames / 60 / 60;
AverageStoredStateSizeLabel.Text = FormatKB(avg_state_size); long estTotalFrames = estFrames * estFrequency;
ApproxFramesLabel.Text = String.Format("{0:n0}", est_frames) + " frames"; double minutes = estTotalFrames / 60 / 60;
EstTimeLabel.Text = String.Format("{0:n}", minutes) + " minutes";
AverageStoredStateSizeLabel.Text = FormatKB(avgStateSize);
ApproxFramesLabel.Text = $"{estFrames:n0}" + " frames";
EstTimeLabel.Text = $"{minutes:n}" + " minutes";
} }
private void BufferSizeUpDown_ValueChanged(object sender, EventArgs e) private void BufferSizeUpDown_ValueChanged(object sender, EventArgs e)
@ -367,18 +373,18 @@ namespace BizHawk.Client.EmuHawk
CalculateEstimates(); CalculateEstimates();
} }
private void nudCompression_ValueChanged(object sender, EventArgs e) private void NudCompression_ValueChanged(object sender, EventArgs e)
{ {
trackBarCompression.Value = (int)(sender as NumericUpDown).Value; trackBarCompression.Value = (int)((NumericUpDown)sender).Value;
} }
private void trackBarCompression_ValueChanged(object sender, EventArgs e) private void TrackBarCompression_ValueChanged(object sender, EventArgs e)
{ {
//TODO - make a UserControl which is trackbar and NUD combined // TODO - make a UserControl which is trackbar and NUD combined
nudCompression.Value = (sender as TrackBar).Value; nudCompression.Value = ((TrackBar)sender).Value;
} }
private void btnResetCompression_Click(object sender, EventArgs e) private void BtnResetCompression_Click(object sender, EventArgs e)
{ {
nudCompression.Value = Config.DefaultSaveStateCompressionLevelNormal; nudCompression.Value = Config.DefaultSaveStateCompressionLevelNormal;
} }

View File

@ -45,7 +45,7 @@
this.OK.TabIndex = 0; this.OK.TabIndex = 0;
this.OK.Text = "&OK"; this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true; this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click); this.OK.Click += new System.EventHandler(this.Ok_Click);
// //
// Cancel // Cancel
// //

View File

@ -8,7 +8,6 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class SMSGraphicsConfig : Form public partial class SMSGraphicsConfig : Form
{ {
public SMSGraphicsConfig() public SMSGraphicsConfig()
{ {
InitializeComponent(); InitializeComponent();
@ -21,7 +20,7 @@ namespace BizHawk.Client.EmuHawk
DispBG.Checked = s.DispBG; DispBG.Checked = s.DispBG;
} }
private void OK_Click(object sender, EventArgs e) private void Ok_Click(object sender, EventArgs e)
{ {
var s = ((SMS)Global.Emulator).GetSettings(); var s = ((SMS)Global.Emulator).GetSettings();
s.DispOBJ = DispOBJ.Checked; s.DispOBJ = DispOBJ.Checked;

View File

@ -10,7 +10,7 @@ namespace BizHawk.Client.EmuHawk
public partial class SNESControllerSettings : Form public partial class SNESControllerSettings : Form
{ {
private LibsnesCore.SnesSyncSettings _syncSettings; private LibsnesCore.SnesSyncSettings _syncSettings;
private bool _supressDropdownChangeEvents = false; private bool _supressDropdownChangeEvents;
public SNESControllerSettings() public SNESControllerSettings()
{ {

View File

@ -51,7 +51,7 @@
this.btnOk.TabIndex = 0; this.btnOk.TabIndex = 0;
this.btnOk.Text = "OK"; this.btnOk.Text = "OK";
this.btnOk.UseVisualStyleBackColor = true; this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler(this.btnOk_Click); this.btnOk.Click += new System.EventHandler(this.BtnOk_Click);
// //
// btnCancel // btnCancel
// //
@ -63,7 +63,7 @@
this.btnCancel.TabIndex = 1; this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "Cancel"; this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); this.btnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
// //
// rbCompatibility // rbCompatibility
// //
@ -108,7 +108,7 @@
this.rbAccuracy.TabStop = true; this.rbAccuracy.TabStop = true;
this.rbAccuracy.Text = "Accuracy (only to fix bugs in Compatibility!)"; this.rbAccuracy.Text = "Accuracy (only to fix bugs in Compatibility!)";
this.rbAccuracy.UseVisualStyleBackColor = true; this.rbAccuracy.UseVisualStyleBackColor = true;
this.rbAccuracy.CheckedChanged += new System.EventHandler(this.rbAccuracy_CheckedChanged); this.rbAccuracy.CheckedChanged += new System.EventHandler(this.RbAccuracy_CheckedChanged);
// //
// rbPerformance // rbPerformance
// //
@ -130,7 +130,7 @@
this.cbDoubleSize.TabIndex = 6; this.cbDoubleSize.TabIndex = 6;
this.cbDoubleSize.Text = "Always Double-Size Framebuffer"; this.cbDoubleSize.Text = "Always Double-Size Framebuffer";
this.cbDoubleSize.UseVisualStyleBackColor = true; this.cbDoubleSize.UseVisualStyleBackColor = true;
this.cbDoubleSize.CheckedChanged += new System.EventHandler(this.cbDoubleSize_CheckedChanged); this.cbDoubleSize.CheckedChanged += new System.EventHandler(this.CbDoubleSize_CheckedChanged);
// //
// lblDoubleSize // lblDoubleSize
// //
@ -151,7 +151,7 @@
this.cbForceDeterminism.TabIndex = 8; this.cbForceDeterminism.TabIndex = 8;
this.cbForceDeterminism.Text = "Force Determinism"; this.cbForceDeterminism.Text = "Force Determinism";
this.cbForceDeterminism.UseVisualStyleBackColor = true; this.cbForceDeterminism.UseVisualStyleBackColor = true;
this.cbForceDeterminism.CheckedChanged += new System.EventHandler(this.cbForceDeterminism_CheckedChanged); this.cbForceDeterminism.CheckedChanged += new System.EventHandler(this.CbForceDeterminism_CheckedChanged);
// //
// label3 // label3
// //

View File

@ -7,13 +7,13 @@ namespace BizHawk.Client.EmuHawk
{ {
public partial class SNESOptions : Form public partial class SNESOptions : Form
{ {
public SNESOptions() private SNESOptions()
{ {
InitializeComponent(); InitializeComponent();
} }
bool SuppressDoubleSize; private bool _suppressDoubleSize;
bool UserDoubleSizeOption; private bool _userDoubleSizeOption;
public static void DoSettingsDialog(IWin32Window owner) public static void DoSettingsDialog(IWin32Window owner)
{ {
@ -42,31 +42,51 @@ namespace BizHawk.Client.EmuHawk
rbAccuracy.Visible = VersionInfo.DeveloperBuild; rbAccuracy.Visible = VersionInfo.DeveloperBuild;
} }
public string Profile private string Profile
{ {
get get
{ {
if (rbCompatibility.Checked) return "Compatibility"; if (rbCompatibility.Checked)
else if (rbPerformance.Checked) return "Performance"; {
else if (rbAccuracy.Checked) return "Accuracy"; return "Compatibility";
else throw new InvalidOperationException(); }
if (rbPerformance.Checked)
{
return "Performance";
}
if (rbAccuracy.Checked)
{
return "Accuracy";
}
throw new InvalidOperationException();
} }
set set
{ {
rbCompatibility.Checked = (value == "Compatibility"); rbCompatibility.Checked = value == "Compatibility";
rbPerformance.Checked = (value == "Performance"); rbPerformance.Checked = value == "Performance";
rbAccuracy.Checked = (value == "Accuracy"); rbAccuracy.Checked = value == "Accuracy";
} }
} }
public bool AlwaysDoubleSize private bool AlwaysDoubleSize
{ {
get { return UserDoubleSizeOption; } get
set { UserDoubleSizeOption = value; RefreshDoubleSizeOption(); } {
return _userDoubleSizeOption;
}
set
{
_userDoubleSizeOption = value;
RefreshDoubleSizeOption();
}
} }
public bool ForceDeterminism private bool ForceDeterminism
{ {
get { return cbForceDeterminism.Checked; } get { return cbForceDeterminism.Checked; }
set { cbForceDeterminism.Checked = value; } set { cbForceDeterminism.Checked = value; }
@ -74,38 +94,39 @@ namespace BizHawk.Client.EmuHawk
void RefreshDoubleSizeOption() void RefreshDoubleSizeOption()
{ {
SuppressDoubleSize = true; _suppressDoubleSize = true;
if (cbDoubleSize.Enabled) cbDoubleSize.Checked = !cbDoubleSize.Enabled || _userDoubleSizeOption;
cbDoubleSize.Checked = UserDoubleSizeOption; _suppressDoubleSize = false;
else cbDoubleSize.Checked = true;
SuppressDoubleSize = false;
} }
private void rbAccuracy_CheckedChanged(object sender, EventArgs e) private void RbAccuracy_CheckedChanged(object sender, EventArgs e)
{ {
cbDoubleSize.Enabled = !rbAccuracy.Checked; cbDoubleSize.Enabled = !rbAccuracy.Checked;
lblDoubleSize.ForeColor = cbDoubleSize.Enabled ? System.Drawing.SystemColors.ControlText : System.Drawing.SystemColors.GrayText; lblDoubleSize.ForeColor = cbDoubleSize.Enabled ? System.Drawing.SystemColors.ControlText : System.Drawing.SystemColors.GrayText;
RefreshDoubleSizeOption(); RefreshDoubleSizeOption();
} }
private void cbDoubleSize_CheckedChanged(object sender, EventArgs e) private void CbDoubleSize_CheckedChanged(object sender, EventArgs e)
{ {
if (SuppressDoubleSize) return; if (_suppressDoubleSize)
UserDoubleSizeOption = cbDoubleSize.Checked; {
return;
}
_userDoubleSizeOption = cbDoubleSize.Checked;
} }
private void cbForceDeterminism_CheckedChanged(object sender, EventArgs e) private void CbForceDeterminism_CheckedChanged(object sender, EventArgs e)
{ {
} }
private void btnOk_Click(object sender, EventArgs e) private void BtnOk_Click(object sender, EventArgs e)
{ {
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
private void btnCancel_Click(object sender, EventArgs e) private void BtnCancel_Click(object sender, EventArgs e)
{ {
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();

View File

@ -81,7 +81,7 @@
this.OK.TabIndex = 0; this.OK.TabIndex = 0;
this.OK.Text = "&OK"; this.OK.Text = "&OK";
this.OK.UseVisualStyleBackColor = true; this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.OK_Click); this.OK.Click += new System.EventHandler(this.Ok_Click);
// //
// cbEnableNormal // cbEnableNormal
// //
@ -143,7 +143,7 @@
this.tbRWFF.Size = new System.Drawing.Size(42, 164); this.tbRWFF.Size = new System.Drawing.Size(42, 164);
this.tbRWFF.TabIndex = 13; this.tbRWFF.TabIndex = 13;
this.tbRWFF.TickFrequency = 10; this.tbRWFF.TickFrequency = 10;
this.tbRWFF.Scroll += new System.EventHandler(this.tbRWFF_Scroll); this.tbRWFF.Scroll += new System.EventHandler(this.TbRwff_Scroll);
// //
// label2 // label2
// //
@ -175,7 +175,7 @@
this.tbNormal.Size = new System.Drawing.Size(42, 164); this.tbNormal.Size = new System.Drawing.Size(42, 164);
this.tbNormal.TabIndex = 0; this.tbNormal.TabIndex = 0;
this.tbNormal.TickFrequency = 10; this.tbNormal.TickFrequency = 10;
this.tbNormal.Scroll += new System.EventHandler(this.trackBar1_Scroll); this.tbNormal.Scroll += new System.EventHandler(this.TrackBar1_Scroll);
// //
// nudNormal // nudNormal
// //

View File

@ -41,7 +41,7 @@ namespace BizHawk.Client.EmuHawk
_programmaticallyChangingValue = false; _programmaticallyChangingValue = false;
} }
private void OK_Click(object sender, EventArgs e) private void Ok_Click(object sender, EventArgs e)
{ {
if (rbOutputMethodDirectSound.Checked && (int)BufferSizeNumeric.Value < 60) if (rbOutputMethodDirectSound.Checked && (int)BufferSizeNumeric.Value < 60)
{ {
@ -62,12 +62,13 @@ namespace BizHawk.Client.EmuHawk
Global.Config.SoundVolumeRWFF = tbRWFF.Value; Global.Config.SoundVolumeRWFF = tbRWFF.Value;
Global.Config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? "<default>"; Global.Config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? "<default>";
GlobalWin.Sound.StopSound(); GlobalWin.Sound.StopSound();
if (Global.Config.SoundOutputMethod != oldOutputMethod || if (Global.Config.SoundOutputMethod != oldOutputMethod
Global.Config.SoundDevice != oldDevice) || Global.Config.SoundDevice != oldDevice)
{ {
GlobalWin.Sound.Dispose(); GlobalWin.Sound.Dispose();
GlobalWin.Sound = new Sound(GlobalWin.MainForm.Handle); GlobalWin.Sound = new Sound(GlobalWin.MainForm.Handle);
} }
GlobalWin.Sound.StartSound(); GlobalWin.Sound.StartSound();
GlobalWin.OSD.AddMessage("Sound settings saved"); GlobalWin.OSD.AddMessage("Sound settings saved");
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
@ -102,16 +103,20 @@ namespace BizHawk.Client.EmuHawk
private void OutputMethodRadioButtons_CheckedChanged(object sender, EventArgs e) private void OutputMethodRadioButtons_CheckedChanged(object sender, EventArgs e)
{ {
if (!((RadioButton)sender).Checked) return; if (!((RadioButton)sender).Checked)
{
return;
}
PopulateDeviceList(); PopulateDeviceList();
} }
private void trackBar1_Scroll(object sender, EventArgs e) private void TrackBar1_Scroll(object sender, EventArgs e)
{ {
nudNormal.Value = tbNormal.Value; nudNormal.Value = tbNormal.Value;
} }
private void tbRWFF_Scroll(object sender, EventArgs e) private void TbRwff_Scroll(object sender, EventArgs e)
{ {
nudRWFF.Value = tbRWFF.Value; nudRWFF.Value = tbRWFF.Value;
} }
@ -122,7 +127,9 @@ namespace BizHawk.Client.EmuHawk
// If the user is changing the volume, automatically turn on/off sound accordingly // If the user is changing the volume, automatically turn on/off sound accordingly
if (!_programmaticallyChangingValue) if (!_programmaticallyChangingValue)
{
cbEnableNormal.Checked = tbNormal.Value != 0; cbEnableNormal.Checked = tbNormal.Value != 0;
}
} }
private void UpdateSoundDialog() private void UpdateSoundDialog()
@ -131,11 +138,9 @@ namespace BizHawk.Client.EmuHawk
grpSoundVol.Enabled = cbEnableMaster.Checked; grpSoundVol.Enabled = cbEnableMaster.Checked;
} }
private void UpdateSoundDialog(object sender, EventArgs e) private void UpdateSoundDialog(object sender, EventArgs e)
{ {
UpdateSoundDialog(); UpdateSoundDialog();
} }
} }
} }

View File

@ -1,10 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
@ -59,7 +54,7 @@ namespace BizHawk.Client.EmuHawk
AllowFullOpen = true, AllowFullOpen = true,
AnyColor = true, AnyColor = true,
Color = BackgroundPanel.BackColor, Color = BackgroundPanel.BackColor,
CustomColors = new int[] { customColor } CustomColors = new[] { customColor }
}; };
if (dlg.ShowDialog() == DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
@ -80,7 +75,7 @@ namespace BizHawk.Client.EmuHawk
AllowFullOpen = true, AllowFullOpen = true,
AnyColor = true, AnyColor = true,
Color = ForeGroundPanel.BackColor, Color = ForeGroundPanel.BackColor,
CustomColors = new int[] { customColor } CustomColors = new[] { customColor }
}; };
if (dlg.ShowDialog() == DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)

View File

@ -378,14 +378,14 @@ namespace BizHawk.Client.EmuHawk
if (!_cgb) if (!_cgb)
{ {
DrawBGDMG( DrawBGDMG(
bmpViewBG.bmp, bmpViewBG.BMP,
_vram + (lcdc.Bit(3) ? 0x1c00 : 0x1800), _vram + (lcdc.Bit(3) ? 0x1c00 : 0x1800),
_vram + (lcdc.Bit(4) ? 0x0000 : 0x1000), _vram + (lcdc.Bit(4) ? 0x0000 : 0x1000),
!lcdc.Bit(4), !lcdc.Bit(4),
_bgpal); _bgpal);
DrawBGDMG( DrawBGDMG(
bmpViewWin.bmp, bmpViewWin.BMP,
_vram + (lcdc.Bit(6) ? 0x1c00 : 0x1800), _vram + (lcdc.Bit(6) ? 0x1c00 : 0x1800),
_vram + 0x1000, // force win to second tile bank??? _vram + 0x1000, // force win to second tile bank???
true, true,
@ -394,14 +394,14 @@ namespace BizHawk.Client.EmuHawk
else else
{ {
DrawBGCGB( DrawBGCGB(
bmpViewBG.bmp, bmpViewBG.BMP,
_vram + (lcdc.Bit(3) ? 0x1c00 : 0x1800), _vram + (lcdc.Bit(3) ? 0x1c00 : 0x1800),
_vram + (lcdc.Bit(4) ? 0x0000 : 0x1000), _vram + (lcdc.Bit(4) ? 0x0000 : 0x1000),
!lcdc.Bit(4), !lcdc.Bit(4),
_bgpal); _bgpal);
DrawBGCGB( DrawBGCGB(
bmpViewWin.bmp, bmpViewWin.BMP,
_vram + (lcdc.Bit(6) ? 0x1c00 : 0x1800), _vram + (lcdc.Bit(6) ? 0x1c00 : 0x1800),
_vram + 0x1000, // force win to second tile bank??? _vram + 0x1000, // force win to second tile bank???
true, true,
@ -413,11 +413,11 @@ namespace BizHawk.Client.EmuHawk
// tile display // tile display
// TODO: user selects palette to use, instead of fixed palette 0 // TODO: user selects palette to use, instead of fixed palette 0
// or possibly "smart" where, if a tile is in use, it's drawn with one of the palettes actually being used with it? // or possibly "smart" where, if a tile is in use, it's drawn with one of the palettes actually being used with it?
DrawTiles(bmpViewTiles1.bmp, _vram, tilespal); DrawTiles(bmpViewTiles1.BMP, _vram, tilespal);
bmpViewTiles1.Refresh(); bmpViewTiles1.Refresh();
if (_cgb) if (_cgb)
{ {
DrawTiles(bmpViewTiles2.bmp, _vram + 0x2000, tilespal); DrawTiles(bmpViewTiles2.BMP, _vram + 0x2000, tilespal);
bmpViewTiles2.Refresh(); bmpViewTiles2.Refresh();
} }
@ -430,8 +430,8 @@ namespace BizHawk.Client.EmuHawk
bmpViewSPPal.ChangeBitmapSize(8, 4); bmpViewSPPal.ChangeBitmapSize(8, 4);
if (bmpViewSPPal.Width != 128) if (bmpViewSPPal.Width != 128)
bmpViewSPPal.Width = 128; bmpViewSPPal.Width = 128;
DrawPal(bmpViewBGPal.bmp, _bgpal, 8); DrawPal(bmpViewBGPal.BMP, _bgpal, 8);
DrawPal(bmpViewSPPal.bmp, _sppal, 8); DrawPal(bmpViewSPPal.BMP, _sppal, 8);
} }
else else
{ {
@ -441,8 +441,8 @@ namespace BizHawk.Client.EmuHawk
bmpViewSPPal.ChangeBitmapSize(2, 4); bmpViewSPPal.ChangeBitmapSize(2, 4);
if (bmpViewSPPal.Width != 32) if (bmpViewSPPal.Width != 32)
bmpViewSPPal.Width = 32; bmpViewSPPal.Width = 32;
DrawPal(bmpViewBGPal.bmp, _bgpal, 1); DrawPal(bmpViewBGPal.BMP, _bgpal, 1);
DrawPal(bmpViewSPPal.bmp, _sppal, 2); DrawPal(bmpViewSPPal.BMP, _sppal, 2);
} }
bmpViewBGPal.Refresh(); bmpViewBGPal.Refresh();
bmpViewSPPal.Refresh(); bmpViewSPPal.Refresh();
@ -460,7 +460,7 @@ namespace BizHawk.Client.EmuHawk
if (bmpViewOAM.Height != 8) if (bmpViewOAM.Height != 8)
bmpViewOAM.Height = 8; bmpViewOAM.Height = 8;
} }
DrawOam(bmpViewOAM.bmp, _oam, _vram, _sppal, lcdc.Bit(2), _cgb); DrawOam(bmpViewOAM.BMP, _oam, _vram, _sppal, lcdc.Bit(2), _cgb);
bmpViewOAM.Refresh(); bmpViewOAM.Refresh();
// try to run the current mouseover, to refresh if the mouse is being held over a pane while the emulator runs // try to run the current mouseover, to refresh if the mouse is being held over a pane while the emulator runs
@ -586,7 +586,7 @@ namespace BizHawk.Client.EmuHawk
_freezeLabel = groupBoxDetails.Text; _freezeLabel = groupBoxDetails.Text;
if (_freezeBmp != null) if (_freezeBmp != null)
_freezeBmp.Dispose(); _freezeBmp.Dispose();
_freezeBmp = (Bitmap)bmpViewDetails.bmp.Clone(); _freezeBmp = (Bitmap)bmpViewDetails.BMP.Clone();
_freezeDetails = labelDetails.Text; _freezeDetails = labelDetails.Text;
} }
@ -595,7 +595,7 @@ namespace BizHawk.Client.EmuHawk
groupBoxDetails.Text = _freezeLabel; groupBoxDetails.Text = _freezeLabel;
bmpViewDetails.Height = _freezeBmp.Height * 8; bmpViewDetails.Height = _freezeBmp.Height * 8;
bmpViewDetails.ChangeBitmapSize(_freezeBmp.Size); bmpViewDetails.ChangeBitmapSize(_freezeBmp.Size);
using (var g = Graphics.FromImage(bmpViewDetails.bmp)) using (var g = Graphics.FromImage(bmpViewDetails.BMP))
g.DrawImageUnscaled(_freezeBmp, 0, 0); g.DrawImageUnscaled(_freezeBmp, 0, 0);
labelDetails.Text = _freezeDetails; labelDetails.Text = _freezeDetails;
bmpViewDetails.Refresh(); bmpViewDetails.Refresh();
@ -605,9 +605,9 @@ namespace BizHawk.Client.EmuHawk
{ {
groupBoxMemory.Text = groupBoxDetails.Text; groupBoxMemory.Text = groupBoxDetails.Text;
bmpViewMemory.Size = bmpViewDetails.Size; bmpViewMemory.Size = bmpViewDetails.Size;
bmpViewMemory.ChangeBitmapSize(bmpViewDetails.bmp.Size); bmpViewMemory.ChangeBitmapSize(bmpViewDetails.BMP.Size);
using (var g = Graphics.FromImage(bmpViewMemory.bmp)) using (var g = Graphics.FromImage(bmpViewMemory.BMP))
g.DrawImageUnscaled(bmpViewDetails.bmp, 0, 0); g.DrawImageUnscaled(bmpViewDetails.BMP, 0, 0);
labelMemory.Text = labelDetails.Text; labelMemory.Text = labelDetails.Text;
bmpViewMemory.Refresh(); bmpViewMemory.Refresh();
} }
@ -627,7 +627,7 @@ namespace BizHawk.Client.EmuHawk
sb.AppendLine(string.Format("Color {0}", y)); sb.AppendLine(string.Format("Color {0}", y));
sb.AppendLine(string.Format("(R,G,B) = ({0},{1},{2})", color >> 16 & 255, color >> 8 & 255, color & 255)); sb.AppendLine(string.Format("(R,G,B) = ({0},{1},{2})", color >> 16 & 255, color >> 8 & 255, color & 255));
var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, 10), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, 10), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0; int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int); int pitch = lockdata.Stride / sizeof(int);
@ -643,7 +643,7 @@ namespace BizHawk.Client.EmuHawk
dest -= 8; dest -= 8;
dest += pitch; dest += pitch;
} }
bmpViewDetails.bmp.UnlockBits(lockdata); bmpViewDetails.BMP.UnlockBits(lockdata);
labelDetails.Text = sb.ToString(); labelDetails.Text = sb.ToString();
bmpViewDetails.Refresh(); bmpViewDetails.Refresh();
} }
@ -664,9 +664,9 @@ namespace BizHawk.Client.EmuHawk
else else
sb.AppendLine(string.Format("Tile #{0} @{1:x4}", tileindex, tileoffs + 0x8000)); sb.AppendLine(string.Format("Tile #{0} @{1:x4}", tileindex, tileoffs + 0x8000));
var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
DrawTile((byte*)_vram + tileoffs + (secondbank ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)tilespal); DrawTile((byte*)_vram + tileoffs + (secondbank ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)tilespal);
bmpViewDetails.bmp.UnlockBits(lockdata); bmpViewDetails.BMP.UnlockBits(lockdata);
labelDetails.Text = sb.ToString(); labelDetails.Text = sb.ToString();
bmpViewDetails.Refresh(); bmpViewDetails.Refresh();
} }
@ -688,7 +688,7 @@ namespace BizHawk.Client.EmuHawk
if (tileindex < 128) if (tileindex < 128)
tileindex += 256; // compute all if from 0x8000 base tileindex += 256; // compute all if from 0x8000 base
int tileoffs = tileindex * 16; int tileoffs = tileindex * 16;
var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
if (!_cgb) if (!_cgb)
{ {
sb.AppendLine(string.Format("{0} Map ({1},{2}) @{3:x4}", win ? "Win" : "BG", x, y, mapoffs + 0x8000)); sb.AppendLine(string.Format("{0} Map ({1},{2}) @{3:x4}", win ? "Win" : "BG", x, y, mapoffs + 0x8000));
@ -705,7 +705,7 @@ namespace BizHawk.Client.EmuHawk
sb.AppendLine(string.Format(" Flags {0}{1}{2}", tileext.Bit(5) ? 'H' : ' ', tileext.Bit(6) ? 'V' : ' ', tileext.Bit(7) ? 'P' : ' ')); sb.AppendLine(string.Format(" Flags {0}{1}{2}", tileext.Bit(5) ? 'H' : ' ', tileext.Bit(6) ? 'V' : ' ', tileext.Bit(7) ? 'P' : ' '));
DrawTileHv((byte*)_vram + tileoffs + (tileext.Bit(3) ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)_bgpal + 4 * (tileext & 7), tileext.Bit(5), tileext.Bit(6)); DrawTileHv((byte*)_vram + tileoffs + (tileext.Bit(3) ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)_bgpal + 4 * (tileext & 7), tileext.Bit(5), tileext.Bit(6));
} }
bmpViewDetails.bmp.UnlockBits(lockdata); bmpViewDetails.BMP.UnlockBits(lockdata);
labelDetails.Text = sb.ToString(); labelDetails.Text = sb.ToString();
bmpViewDetails.Refresh(); bmpViewDetails.Refresh();
} }
@ -716,8 +716,8 @@ namespace BizHawk.Client.EmuHawk
x /= 8; x /= 8;
y /= 8; y /= 8;
bmpViewDetails.ChangeBitmapSize(8, tall ? 16 : 8); bmpViewDetails.ChangeBitmapSize(8, tall ? 16 : 8);
if (bmpViewDetails.Height != bmpViewDetails.bmp.Height * 8) if (bmpViewDetails.Height != bmpViewDetails.BMP.Height * 8)
bmpViewDetails.Height = bmpViewDetails.bmp.Height * 8; bmpViewDetails.Height = bmpViewDetails.BMP.Height * 8;
var sb = new StringBuilder(); var sb = new StringBuilder();
byte* oament = (byte*)_oam + 4 * x; byte* oament = (byte*)_oam + 4 * x;
@ -732,7 +732,7 @@ namespace BizHawk.Client.EmuHawk
int tileoffs = tilenum * 16; int tileoffs = tilenum * 16;
sb.AppendLine(string.Format("Sprite #{0} @{1:x4}", x, 4 * x + 0xfe00)); sb.AppendLine(string.Format("Sprite #{0} @{1:x4}", x, 4 * x + 0xfe00));
sb.AppendLine(string.Format(" (x,y) = ({0},{1})", sx, sy)); sb.AppendLine(string.Format(" (x,y) = ({0},{1})", sx, sy));
var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, tall ? 16 : 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, tall ? 16 : 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
if (_cgb) if (_cgb)
{ {
sb.AppendLine(string.Format(" Tile #{0} @{2}:{1:x4}", y == 1 ? tilenum ^ 1 : tilenum, tileoffs + 0x8000, flags.Bit(3) ? 1 : 0)); sb.AppendLine(string.Format(" Tile #{0} @{2}:{1:x4}", y == 1 ? tilenum ^ 1 : tilenum, tileoffs + 0x8000, flags.Bit(3) ? 1 : 0));
@ -750,7 +750,7 @@ namespace BizHawk.Client.EmuHawk
DrawTileHv((byte*)_vram + (tileoffs ^ 16), (int*)(lockdata.Scan0 + lockdata.Stride * 8), lockdata.Stride / sizeof(int), (int*)_sppal + 4 * (flags.Bit(4) ? 4 : 0), hflip, vflip); DrawTileHv((byte*)_vram + (tileoffs ^ 16), (int*)(lockdata.Scan0 + lockdata.Stride * 8), lockdata.Stride / sizeof(int), (int*)_sppal + 4 * (flags.Bit(4) ? 4 : 0), hflip, vflip);
} }
sb.AppendLine(string.Format(" Flags {0}{1}{2}", hflip ? 'H' : ' ', vflip ? 'V' : ' ', flags.Bit(7) ? 'P' : ' ')); sb.AppendLine(string.Format(" Flags {0}{1}{2}", hflip ? 'H' : ' ', vflip ? 'V' : ' ', flags.Bit(7) ? 'P' : ' '));
bmpViewDetails.bmp.UnlockBits(lockdata); bmpViewDetails.BMP.UnlockBits(lockdata);
labelDetails.Text = sb.ToString(); labelDetails.Text = sb.ToString();
bmpViewDetails.Refresh(); bmpViewDetails.Refresh();
} }
@ -909,7 +909,7 @@ namespace BizHawk.Client.EmuHawk
if (found is BmpView) if (found is BmpView)
{ {
var bv = found as BmpView; var bv = found as BmpView;
Clipboard.SetImage(bv.bmp); Clipboard.SetImage(bv.BMP);
labelClipboard.Text = found.Text + " copied to clipboard."; labelClipboard.Text = found.Text + " copied to clipboard.";
_messagetimer.Stop(); _messagetimer.Stop();
_messagetimer.Start(); _messagetimer.Start();

View File

@ -170,7 +170,7 @@ namespace BizHawk.Client.EmuHawk
case 2: mbv.ChangeAllSizes(256, 512); break; case 2: mbv.ChangeAllSizes(256, 512); break;
case 3: mbv.ChangeAllSizes(512, 512); break; case 3: mbv.ChangeAllSizes(512, 512); break;
} }
Bitmap bmp = mbv.BmpView.bmp; Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0; int* pixels = (int*)lockdata.Scan0;
@ -229,7 +229,7 @@ namespace BizHawk.Client.EmuHawk
case 2: mbv.ChangeAllSizes(512, 512); break; case 2: mbv.ChangeAllSizes(512, 512); break;
case 3: mbv.ChangeAllSizes(1024, 1024); break; case 3: mbv.ChangeAllSizes(1024, 1024); break;
} }
Bitmap bmp = mbv.BmpView.bmp; Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0; int* pixels = (int*)lockdata.Scan0;
@ -257,7 +257,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawM3BG(MobileBmpView mbv) unsafe void DrawM3BG(MobileBmpView mbv)
{ {
mbv.ChangeAllSizes(240, 160); mbv.ChangeAllSizes(240, 160);
Bitmap bmp = mbv.BmpView.bmp; Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0; int* pixels = (int*)lockdata.Scan0;
@ -280,7 +280,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawM4BG(MobileBmpView mbv, bool secondframe) unsafe void DrawM4BG(MobileBmpView mbv, bool secondframe)
{ {
mbv.ChangeAllSizes(240, 160); mbv.ChangeAllSizes(240, 160);
Bitmap bmp = mbv.BmpView.bmp; Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0; int* pixels = (int*)lockdata.Scan0;
@ -304,7 +304,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawM5BG(MobileBmpView mbv, bool secondframe) unsafe void DrawM5BG(MobileBmpView mbv, bool secondframe)
{ {
mbv.ChangeAllSizes(160, 128); mbv.ChangeAllSizes(160, 128);
Bitmap bmp = mbv.BmpView.bmp; Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0; int* pixels = (int*)lockdata.Scan0;
@ -406,7 +406,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawSprites(MobileBmpView mbv) unsafe void DrawSprites(MobileBmpView mbv)
{ {
mbv.BmpView.ChangeBitmapSize(1024, 512); mbv.BmpView.ChangeBitmapSize(1024, 512);
Bitmap bmp = mbv.BmpView.bmp; Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
// Clear() // Clear()
Win32.MemSet(lockdata.Scan0, 0xff, (uint)(lockdata.Height * lockdata.Stride)); Win32.MemSet(lockdata.Scan0, 0xff, (uint)(lockdata.Height * lockdata.Stride));
@ -439,7 +439,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawPalette(MobileBmpView mbv, bool sprite) unsafe void DrawPalette(MobileBmpView mbv, bool sprite)
{ {
mbv.BmpView.ChangeBitmapSize(16, 16); mbv.BmpView.ChangeBitmapSize(16, 16);
Bitmap bmp = mbv.BmpView.bmp; Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0; int* pixels = (int*)lockdata.Scan0;
@ -489,7 +489,7 @@ namespace BizHawk.Client.EmuHawk
int th = tophalfonly ? 16 : 32; int th = tophalfonly ? 16 : 32;
mbv.BmpView.ChangeBitmapSize(tw * 8, 256); mbv.BmpView.ChangeBitmapSize(tw * 8, 256);
Bitmap bmp = mbv.BmpView.bmp; Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0; int* pixels = (int*)lockdata.Scan0;
@ -516,7 +516,7 @@ namespace BizHawk.Client.EmuHawk
int th = 32; int th = 32;
mbv.BmpView.ChangeBitmapSize(tw * 8, th * 8); mbv.BmpView.ChangeBitmapSize(tw * 8, th * 8);
Bitmap bmp = mbv.BmpView.bmp; Bitmap bmp = mbv.BmpView.BMP;
var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int* pixels = (int*)lockdata.Scan0; int* pixels = (int*)lockdata.Scan0;
@ -837,7 +837,7 @@ namespace BizHawk.Client.EmuHawk
if (found is BmpView) if (found is BmpView)
{ {
Clipboard.SetImage((found as BmpView).bmp); Clipboard.SetImage((found as BmpView).BMP);
labelClipboard.Text = found.Text + " copied to clipboard."; labelClipboard.Text = found.Text + " copied to clipboard.";
timerMessage.Stop(); timerMessage.Stop();
timerMessage.Start(); timerMessage.Start();

View File

@ -62,7 +62,7 @@ namespace BizHawk.Client.EmuHawk
bv.Size = pixsize; bv.Size = pixsize;
bv.ChangeBitmapSize(pixsize); bv.ChangeBitmapSize(pixsize);
var lockdata = bv.bmp.LockBits(new Rectangle(Point.Empty, pixsize), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); var lockdata = bv.BMP.LockBits(new Rectangle(Point.Empty, pixsize), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int pitch = lockdata.Stride / sizeof(int); int pitch = lockdata.Stride / sizeof(int);
int* dest = (int*)lockdata.Scan0; int* dest = (int*)lockdata.Scan0;
@ -79,13 +79,13 @@ namespace BizHawk.Client.EmuHawk
dest -= 8 * tilew; dest -= 8 * tilew;
dest += 8 * pitch; dest += 8 * pitch;
} }
bv.bmp.UnlockBits(lockdata); bv.BMP.UnlockBits(lockdata);
bv.Refresh(); bv.Refresh();
} }
unsafe void DrawPalettes(int* pal) unsafe void DrawPalettes(int* pal)
{ {
var lockdata = bmpViewPal.bmp.LockBits(new Rectangle(0, 0, 16, 4), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); var lockdata = bmpViewPal.BMP.LockBits(new Rectangle(0, 0, 16, 4), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int pitch = lockdata.Stride / sizeof(int); int pitch = lockdata.Stride / sizeof(int);
int* dest = (int*)lockdata.Scan0; int* dest = (int*)lockdata.Scan0;
@ -95,13 +95,13 @@ namespace BizHawk.Client.EmuHawk
*dest++ = *pal++; *dest++ = *pal++;
dest += pitch - 16; dest += pitch - 16;
} }
bmpViewPal.bmp.UnlockBits(lockdata); bmpViewPal.BMP.UnlockBits(lockdata);
bmpViewPal.Refresh(); bmpViewPal.Refresh();
} }
unsafe void DrawTiles() unsafe void DrawTiles()
{ {
var lockdata = bmpViewTiles.bmp.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); var lockdata = bmpViewTiles.BMP.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int pitch = lockdata.Stride / sizeof(int); int pitch = lockdata.Stride / sizeof(int);
int* dest = (int*)lockdata.Scan0; int* dest = (int*)lockdata.Scan0;
byte* src = (byte*)View.PatternCache; byte* src = (byte*)View.PatternCache;
@ -117,7 +117,7 @@ namespace BizHawk.Client.EmuHawk
if ((tile & 63) == 0) if ((tile & 63) == 0)
dest += 8 * pitch - 512; dest += 8 * pitch - 512;
} }
bmpViewTiles.bmp.UnlockBits(lockdata); bmpViewTiles.BMP.UnlockBits(lockdata);
bmpViewTiles.Refresh(); bmpViewTiles.Refresh();
} }
@ -189,7 +189,7 @@ namespace BizHawk.Client.EmuHawk
if (found is BmpView) if (found is BmpView)
{ {
var bv = found as BmpView; var bv = found as BmpView;
Clipboard.SetImage(bv.bmp); Clipboard.SetImage(bv.BMP);
} }
} }
} }

View File

@ -76,7 +76,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawSprites() unsafe void DrawSprites()
{ {
var lockdata = bmpViewSP.bmp.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); var lockdata = bmpViewSP.BMP.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0; int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int); int pitch = lockdata.Stride / sizeof(int);
@ -92,12 +92,12 @@ namespace BizHawk.Client.EmuHawk
Draw16x16(src + srcaddr, dest + destaddr, pitch, pal); Draw16x16(src + srcaddr, dest + destaddr, pitch, pal);
} }
} }
bmpViewSP.bmp.UnlockBits(lockdata); bmpViewSP.BMP.UnlockBits(lockdata);
} }
unsafe void DrawBacks() unsafe void DrawBacks()
{ {
var lockdata = bmpViewBG.bmp.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); var lockdata = bmpViewBG.BMP.LockBits(new Rectangle(0, 0, 512, 256), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0; int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int); int pitch = lockdata.Stride / sizeof(int);
@ -113,15 +113,15 @@ namespace BizHawk.Client.EmuHawk
Draw8x8(src + srcaddr, dest + destaddr, pitch, pal); Draw8x8(src + srcaddr, dest + destaddr, pitch, pal);
} }
} }
bmpViewBG.bmp.UnlockBits(lockdata); bmpViewBG.BMP.UnlockBits(lockdata);
} }
unsafe void DrawPalettes() unsafe void DrawPalettes()
{ {
fixed (int* pal = vce.Palette) fixed (int* pal = vce.Palette)
{ {
DrawPalette(bmpViewBGPal.bmp, pal); DrawPalette(bmpViewBGPal.BMP, pal);
DrawPalette(bmpViewSPPal.bmp, pal + 256); DrawPalette(bmpViewSPPal.BMP, pal + 256);
} }
} }
@ -211,7 +211,7 @@ namespace BizHawk.Client.EmuHawk
if (found is BmpView) if (found is BmpView)
{ {
var bv = found as BmpView; var bv = found as BmpView;
Clipboard.SetImage(bv.bmp); Clipboard.SetImage(bv.BMP);
} }
} }
} }

View File

@ -65,7 +65,7 @@ namespace BizHawk.Client.EmuHawk
unsafe void DrawTiles(int *pal) unsafe void DrawTiles(int *pal)
{ {
var lockdata = bmpViewTiles.bmp.LockBits(new Rectangle(0, 0, 256, 128), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); var lockdata = bmpViewTiles.BMP.LockBits(new Rectangle(0, 0, 256, 128), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0; int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int); int pitch = lockdata.Stride / sizeof(int);
@ -80,7 +80,7 @@ namespace BizHawk.Client.EmuHawk
Draw8x8(src + srcaddr, dest + destaddr, pitch, pal); Draw8x8(src + srcaddr, dest + destaddr, pitch, pal);
} }
} }
bmpViewTiles.bmp.UnlockBits(lockdata); bmpViewTiles.BMP.UnlockBits(lockdata);
bmpViewTiles.Refresh(); bmpViewTiles.Refresh();
} }
@ -88,13 +88,13 @@ namespace BizHawk.Client.EmuHawk
{ {
int bgheight = vdp.FrameHeight == 192 ? 224 : 256; int bgheight = vdp.FrameHeight == 192 ? 224 : 256;
int maxtile = bgheight * 4; int maxtile = bgheight * 4;
if (bgheight != bmpViewBG.bmp.Height) if (bgheight != bmpViewBG.BMP.Height)
{ {
bmpViewBG.Height = bgheight; bmpViewBG.Height = bgheight;
bmpViewBG.ChangeBitmapSize(256, bgheight); bmpViewBG.ChangeBitmapSize(256, bgheight);
} }
var lockdata = bmpViewBG.bmp.LockBits(new Rectangle(0, 0, 256, bgheight), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); var lockdata = bmpViewBG.BMP.LockBits(new Rectangle(0, 0, 256, bgheight), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0; int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int); int pitch = lockdata.Stride / sizeof(int);
@ -116,13 +116,13 @@ namespace BizHawk.Client.EmuHawk
Draw8x8hv(src + srcaddr, dest + destaddr, pitch, tpal, hflip, vflip); Draw8x8hv(src + srcaddr, dest + destaddr, pitch, tpal, hflip, vflip);
} }
} }
bmpViewBG.bmp.UnlockBits(lockdata); bmpViewBG.BMP.UnlockBits(lockdata);
bmpViewBG.Refresh(); bmpViewBG.Refresh();
} }
unsafe void DrawPal(int* pal) unsafe void DrawPal(int* pal)
{ {
var lockdata = bmpViewPalette.bmp.LockBits(new Rectangle(0, 0, 16, 2), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); var lockdata = bmpViewPalette.BMP.LockBits(new Rectangle(0, 0, 16, 2), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
int* dest = (int*)lockdata.Scan0; int* dest = (int*)lockdata.Scan0;
int pitch = lockdata.Stride / sizeof(int); int pitch = lockdata.Stride / sizeof(int);
@ -135,7 +135,7 @@ namespace BizHawk.Client.EmuHawk
dest -= 16; dest -= 16;
dest += pitch; dest += pitch;
} }
bmpViewPalette.bmp.UnlockBits(lockdata); bmpViewPalette.BMP.UnlockBits(lockdata);
bmpViewPalette.Refresh(); bmpViewPalette.Refresh();
} }
@ -204,7 +204,7 @@ namespace BizHawk.Client.EmuHawk
if (found is BmpView) if (found is BmpView)
{ {
var bv = found as BmpView; var bv = found as BmpView;
Clipboard.SetImage(bv.bmp); Clipboard.SetImage(bv.BMP);
} }
} }
} }

View File

@ -286,6 +286,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
ram[0x701] = 0xFF; ram[0x701] = 0xFF;
} }
if (cart.DB_GameInfo.Hash == "68ABE1E49C9E9CCEA978A48232432C252E5912C0") // Dancing Blocks
{
ram[0xEC] = 0;
ram[0xED] = 0;
}
} }
} }

View File

@ -226,7 +226,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
// "If PPUADDR is not less then 8 when rendering starts, the first 8 fights in OAM and written to from // "If PPUADDR is not less then 8 when rendering starts, the first 8 fights in OAM and written to from
// the current location off PPUADDR" // the current location off PPUADDR"
if (sl == 0 && PPUON && reg_2003 >= 8) if (sl == 0 && PPUON && reg_2003 >= 8 && region==Region.NTSC)
{ {
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {

View File

@ -55,6 +55,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CRC/@EntryIndexedValue">CRC</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CRC/@EntryIndexedValue">CRC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DB/@EntryIndexedValue">DB</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DB/@EntryIndexedValue">DB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DC/@EntryIndexedValue">DC</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DC/@EntryIndexedValue">DC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DGB/@EntryIndexedValue">DGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DMG/@EntryIndexedValue">DMG</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DMG/@EntryIndexedValue">DMG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GB/@EntryIndexedValue">GB</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GB/@EntryIndexedValue">GB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GBA/@EntryIndexedValue">GBA</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GBA/@EntryIndexedValue">GBA</s:String>