Code cleanup on the input config dialog

This commit is contained in:
adelikat 2012-09-15 19:47:58 +00:00
parent ff0d5126f0
commit 4446ad07a7
1 changed files with 12 additions and 25 deletions

View File

@ -11,9 +11,6 @@ using System.Windows.Forms;
namespace BizHawk.MultiClient
{
//TODO:
//Remove AppendMapping and TruncateMapping functions
public partial class InputConfig : Form
{
int prevWidth;
@ -25,7 +22,7 @@ namespace BizHawk.MultiClient
{"AtariConsoleButtons", new string[2] { "Reset", "Select" } },
{"Gameboy", new string[8] { "Up", "Down", "Left", "Right", "A", "B", "Select", "Start" } },
{"NES", new string[8] { "Up", "Down", "Left", "Right", "A", "B", "Select", "Start" } },
{"SNES", new string[] { "Up", "Down", "Left", "Right", "A", "B", "X", "Y", "L", "R", "Select", "Start" } },
{"SNES", new string[] { "Up", "Down", "Left", "Right", "B", "A", "X", "Y", "L", "R", "Select", "Start" } },
{"PC Engine / SuperGrafx", new string[8] { "Up", "Down", "Left", "Right", "I", "II", "Run", "Select" } },
{"Sega Genesis", new string[8] { "Up", "Down", "Left", "Right", "A", "B", "C", "Start" } },
{"SMS / GG / SG-1000", new string[8] { "Up", "Down", "Left", "Right", "B1", "B2", "Pause", "Reset" } },
@ -81,16 +78,6 @@ namespace BizHawk.MultiClient
Input.Instance.EnableIgnoreModifiers = false;
}
private string AppendButtonMapping(string button, string oldmap)
{
//adelikat: Another relic, remove this
//int x = oldmap.LastIndexOf(',');
//if (x != -1)
// return oldmap.Substring(0, x + 2) + button;
//else
return button;
}
private void Do(string platform)
{
Label TempLabel;
@ -379,14 +366,14 @@ namespace BizHawk.MultiClient
Atari2600ConsoleButtonsTemplate o = (Atari2600ConsoleButtonsTemplate)controller[0];
FieldInfo buttonF = o.GetType().GetField(fieldName);
field = buttonF.GetValue(o);
buttonF.SetValue(o, AppendButtonMapping(TempBox.Text, (string)field));
buttonF.SetValue(o, TempBox.Text);
break;
case "Atari":
{
Atari2600ControllerTemplate obj = (Atari2600ControllerTemplate)controller[prev];
FieldInfo buttonField = obj.GetType().GetField(fieldName);
field = buttonField.GetValue(obj);
buttonField.SetValue(obj, AppendButtonMapping(TempBox.Text, (string)field));
buttonField.SetValue(obj, TempBox.Text);
break;
}
case "Gameboy":
@ -394,7 +381,7 @@ namespace BizHawk.MultiClient
GBControllerTemplate obj = (GBControllerTemplate)controller[prev];
FieldInfo buttonField = obj.GetType().GetField(fieldName);
field = buttonField.GetValue(obj);
buttonField.SetValue(obj, AppendButtonMapping(TempBox.Text, (string)field));
buttonField.SetValue(obj, TempBox.Text);
break;
}
case "NES":
@ -402,7 +389,7 @@ namespace BizHawk.MultiClient
NESControllerTemplate obj = (NESControllerTemplate)controller[prev];
FieldInfo buttonField = obj.GetType().GetField(fieldName);
field = buttonField.GetValue(obj);
buttonField.SetValue(obj, AppendButtonMapping(TempBox.Text, (string)field));
buttonField.SetValue(obj, TempBox.Text);
break;
}
case "SNES":
@ -410,7 +397,7 @@ namespace BizHawk.MultiClient
SNESControllerTemplate obj = (SNESControllerTemplate)controller[prev];
FieldInfo buttonField = obj.GetType().GetField(fieldName);
field = buttonField.GetValue(obj);
buttonField.SetValue(obj, AppendButtonMapping(TempBox.Text, (string)field));
buttonField.SetValue(obj, TempBox.Text);
break;
}
case "PC Engine / SuperGrafx":
@ -418,7 +405,7 @@ namespace BizHawk.MultiClient
PCEControllerTemplate obj = (PCEControllerTemplate)controller[prev];
FieldInfo buttonField = obj.GetType().GetField(fieldName);
field = buttonField.GetValue(obj);
buttonField.SetValue(obj, AppendButtonMapping(TempBox.Text, (string)field));
buttonField.SetValue(obj, TempBox.Text);
break;
}
case "Sega Genesis":
@ -426,7 +413,7 @@ namespace BizHawk.MultiClient
GenControllerTemplate obj = (GenControllerTemplate)controller[prev];
FieldInfo buttonField = obj.GetType().GetField(fieldName);
field = buttonField.GetValue(obj);
buttonField.SetValue(obj, AppendButtonMapping(TempBox.Text, (string)field));
buttonField.SetValue(obj, TempBox.Text);
break;
}
case "SMS / GG / SG-1000":
@ -436,12 +423,12 @@ namespace BizHawk.MultiClient
SMSControllerTemplate obj = (SMSControllerTemplate)controller[prev];
FieldInfo buttonField = obj.GetType().GetField(fieldName);
field = buttonField.GetValue(obj);
buttonField.SetValue(obj, AppendButtonMapping(TempBox.Text, (string)field));
buttonField.SetValue(obj, TempBox.Text);
}
else if (button == 6)
Global.Config.SmsPause = AppendButtonMapping(TempBox.Text, Global.Config.SmsPause);
Global.Config.SmsPause = TempBox.Text;
else
Global.Config.SmsReset = AppendButtonMapping(TempBox.Text, Global.Config.SmsReset);
Global.Config.SmsReset = TempBox.Text;
break;
}
case "TI-83":
@ -449,7 +436,7 @@ namespace BizHawk.MultiClient
TI83ControllerTemplate obj = (TI83ControllerTemplate)controller[prev];
FieldInfo buttonField = obj.GetType().GetField(TI83CONTROLS[button]);
field = buttonField.GetValue(obj);
buttonField.SetValue(obj, AppendButtonMapping(TempBox.Text, (string)field));
buttonField.SetValue(obj, TempBox.Text);
break;
}
}