code cleanup of config dialog files

This commit is contained in:
adelikat 2019-12-15 15:57:46 -06:00
parent 8c5b13097a
commit f833d50f30
4 changed files with 16 additions and 18 deletions

View File

@ -25,7 +25,7 @@ namespace BizHawk.Client.EmuHawk
textBox1.Text = bind.Value; textBox1.Text = bind.Value;
} }
public string ButtonName { get; private set; } public string ButtonName { get; }
public Config.AnalogBind Bind => _bind; public Config.AnalogBind Bind => _bind;
private Config.AnalogBind _bind; private Config.AnalogBind _bind;
@ -33,12 +33,12 @@ namespace BizHawk.Client.EmuHawk
private void Timer1_Tick(object sender, EventArgs e) private void Timer1_Tick(object sender, EventArgs e)
{ {
string bindval = Input.Instance.GetNextFloatEvent(); string bindValue = Input.Instance.GetNextFloatEvent();
if (bindval != null) if (bindValue != null)
{ {
timer1.Stop(); timer1.Stop();
_listening = false; _listening = false;
_bind.Value = bindval; _bind.Value = bindValue;
textBox1.Text = Bind.Value; textBox1.Text = Bind.Value;
buttonBind.Text = "Bind!"; buttonBind.Text = "Bind!";
Input.Instance.StopListeningForFloatEvents(); Input.Instance.StopListeningForFloatEvents();

View File

@ -41,11 +41,11 @@ namespace BizHawk.Client.EmuHawk
/// <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;
saveto[abc.ButtonName] = abc.Bind; saveTo[abc.ButtonName] = abc.Bind;
} }
} }
} }

View File

@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
// this is a little messy right now because of remnants of the old config system // this is a little messy right now because of remnants of the old config system
@ -32,7 +30,7 @@ namespace BizHawk.Client.EmuHawk
private Size _panelSize = new Size(0, 0); private Size _panelSize = new Size(0, 0);
private bool _autotab; private bool _autoTab;
public ControllerConfigPanel() public ControllerConfigPanel()
{ {
@ -54,16 +52,16 @@ namespace BizHawk.Client.EmuHawk
/// <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 void LoadSettings(Dictionary<string, string> configobj, bool autotab, List<string> configbuttons = null, int? width = null, int? height = null) public void LoadSettings(Dictionary<string, string> config, bool autoTab, List<string> buttons = 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);
@ -73,8 +71,8 @@ namespace BizHawk.Client.EmuHawk
_panelSize = Size; _panelSize = Size;
} }
_realConfigObject = configobj; _realConfigObject = config;
_realConfigButtons = configbuttons; _realConfigButtons = buttons;
SetButtonList(); SetButtonList();
Startup(); Startup();
SetWidgetStrings(); SetWidgetStrings();
@ -94,8 +92,7 @@ namespace BizHawk.Client.EmuHawk
{ {
for (int button = 0; button < _buttons.Count; button++) for (int button = 0; button < _buttons.Count; button++)
{ {
string s; if (!_realConfigObject.TryGetValue(_buttons[button], out var s))
if (!_realConfigObject.TryGetValue(_buttons[button], out s))
{ {
s = ""; s = "";
} }
@ -122,7 +119,7 @@ namespace BizHawk.Client.EmuHawk
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 = _autotab AutoTab = _autoTab
}; };
iw.SetupTooltip(Tooltip, null); iw.SetupTooltip(Tooltip, null);

View File

@ -206,6 +206,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cpus/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Cpus/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=curr/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=curr/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Datarows/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Datarows/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Deadzone/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=dearchive/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=dearchive/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dega/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Dega/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=delaminated/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=delaminated/@EntryIndexedValue">True</s:Boolean>