My first BizHawk Commit! Better make it an epic one!

My little pony, apocalypse pony! http://www.youtube.com/watch?v=FIY41LrvMFQ
Oh yeah, started redo of input config.
This commit is contained in:
kylethomson 2011-02-19 20:31:32 +00:00
parent 1be99bcd68
commit 8ae5dc748f
4 changed files with 146 additions and 110 deletions

View File

@ -1,7 +1,13 @@
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public class Config public class Config
{ {
public Config()
{
SMSController[0] = new SMSControllerTemplate(1);
SMSController[1] = new SMSControllerTemplate(2);
}
// General Client Settings // General Client Settings
public int TargetZoomFactor = 2; public int TargetZoomFactor = 2;
public string LastRomPath = "."; public string LastRomPath = ".";
@ -63,24 +69,15 @@
public string SelectSlot8 = "8"; public string SelectSlot8 = "8";
public string SelectSlot9 = "9"; public string SelectSlot9 = "9";
// SMS / GameGear Settings // SMS / GameGear Settings
public bool SmsEnableFM = true; public bool SmsEnableFM = true;
public bool SmsAllowOverlock = false; public bool SmsAllowOverlock = false;
public bool SmsForceStereoSeparation = false; public bool SmsForceStereoSeparation = false;
public string SmsReset = "Tab";
public string SmsReset = "Reset, Tab";
public string SmsPause = "J1 B10, Space"; public string SmsPause = "J1 B10, Space";
public string SmsP1Up = "J1 Up, UpArrow"; public SMSControllerTemplate[] SMSController = new SMSControllerTemplate[2];
public string SmsP1Left = "J1 Left, LeftArrow";
public string SmsP1Right = "J1 Right, RightArrow";
public string SmsP1Down = "J1 Down, DownArrow";
public string SmsP1B1 = "J1 B1, Z";
public string SmsP1B2 = "J1 B2, X";
public string SmsP2Up = "J2 Up";
public string SmsP2Left = "J2 Left";
public string SmsP2Right = "J2 Right";
public string SmsP2Down = "J2 Down";
public string SmsP2B1 = "J2 B1";
public string SmsP2B2 = "J2 B2";
// PCEngine Settings // PCEngine Settings
public string PCEUp = "J1 Up, UpArrow"; public string PCEUp = "J1 Up, UpArrow";
@ -100,6 +97,25 @@
public string GenP1A = "J1 B1, Z"; public string GenP1A = "J1 B1, Z";
public string GenP1B = "J1 B2, X"; public string GenP1B = "J1 B2, X";
public string GenP1C = "J1 B9, C"; public string GenP1C = "J1 B9, C";
public string GenP1Start = "J1 B10, Return"; public string GenP1Start = "J1 B10, Return";
} }
public class SMSControllerTemplate
{
public string Up;
public string Down;
public string Left;
public string Right;
public string B1;
public string B2;
public SMSControllerTemplate(int i)
{
Up = string.Format("J{0} Up", i);
Down = string.Format("J{0} Down", i);
Left = string.Format("J{0} Left", i);
Right = string.Format("J{0} Right", i);
B1 = string.Format("J{0} B1", i);
B2 = string.Format("J{0} B2", i);
}
}
} }

View File

@ -184,20 +184,15 @@ namespace BizHawk.MultiClient
var smsControls = new Controller(SMS.SmsController); var smsControls = new Controller(SMS.SmsController);
smsControls.BindMulti("Reset", Global.Config.SmsReset); smsControls.BindMulti("Reset", Global.Config.SmsReset);
smsControls.BindMulti("Pause", Global.Config.SmsPause); smsControls.BindMulti("Pause", Global.Config.SmsPause);
for (int i = 0; i < 2; i++)
smsControls.BindMulti("P1 Up", Global.Config.SmsP1Up); {
smsControls.BindMulti("P1 Left", Global.Config.SmsP1Left); smsControls.BindMulti(string.Format("P{0} Up",i+1), Global.Config.SMSController[i].Up);
smsControls.BindMulti("P1 Right", Global.Config.SmsP1Right); smsControls.BindMulti(string.Format("P{0} Left", i + 1), Global.Config.SMSController[i].Left);
smsControls.BindMulti("P1 Down", Global.Config.SmsP1Down); smsControls.BindMulti(string.Format("P{0} Right", i + 1), Global.Config.SMSController[i].Right);
smsControls.BindMulti("P1 B1", Global.Config.SmsP1B1); smsControls.BindMulti(string.Format("P{0} Down", i + 1), Global.Config.SMSController[i].Down);
smsControls.BindMulti("P1 B2", Global.Config.SmsP1B2); smsControls.BindMulti(string.Format("P{0} B1", i + 1), Global.Config.SMSController[i].B1);
smsControls.BindMulti(string.Format("P{0} B2", i + 1), Global.Config.SMSController[i].B2);
smsControls.BindMulti("P2 Up", Global.Config.SmsP2Up); }
smsControls.BindMulti("P2 Left", Global.Config.SmsP2Left);
smsControls.BindMulti("P2 Right", Global.Config.SmsP2Right);
smsControls.BindMulti("P2 Down", Global.Config.SmsP2Down);
smsControls.BindMulti("P2 B1", Global.Config.SmsP2B1);
smsControls.BindMulti("P2 B2", Global.Config.SmsP2B2);
Global.SMSControls = smsControls; Global.SMSControls = smsControls;
var pceControls = new Controller(PCEngine.PCEngineController); var pceControls = new Controller(PCEngine.PCEngineController);

View File

@ -114,13 +114,11 @@
// //
this.ControllComboBox.FormattingEnabled = true; this.ControllComboBox.FormattingEnabled = true;
this.ControllComboBox.Items.AddRange(new object[] { this.ControllComboBox.Items.AddRange(new object[] {
"Joypad 1", "Joypad 1"});
"Joypad 2",
"Joypad 3",
"Joypad 4"});
this.ControllComboBox.Location = new System.Drawing.Point(6, 19); this.ControllComboBox.Location = new System.Drawing.Point(6, 19);
this.ControllComboBox.Name = "ControllComboBox"; this.ControllComboBox.Name = "ControllComboBox";
this.ControllComboBox.Size = new System.Drawing.Size(110, 21); this.ControllComboBox.Size = new System.Drawing.Size(110, 21);
this.ControllComboBox.SelectedIndexChanged += new System.EventHandler(ControllComboBox_SelectedIndexChanged);
this.ControllComboBox.TabIndex = 0; this.ControllComboBox.TabIndex = 0;
// //
// AllowLR // AllowLR

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
@ -12,81 +13,68 @@ namespace BizHawk.MultiClient
public partial class InputConfig : Form public partial class InputConfig : Form
{ {
const string ControllerStr = "Configure Controllers - "; const string ControllerStr = "Configure Controllers - ";
public static string[] SMSList = new string[] { "Up", "Down", "Left", "Right", "B1", "B2", "Pause", "Reset" };
public static string[] GenesisList = new string[] { "Up", "Down", "Left", "Right", "A", "B", "C", "Start", "X", "Y", "Z" };
private ArrayList Labels;
private ArrayList TextBoxes;
public InputConfig() public InputConfig()
{ {
InitializeComponent(); InitializeComponent();
Labels = new ArrayList();
TextBoxes = new ArrayList();
} }
private string TruncateButtonMapping(string button) private string TruncateButtonMapping(string button)
{ {
//all config button mappings have the name followed by a comma & space, then key mapping, remove up through the space //all config button mappings have the name followed by a comma & space, then key mapping, remove up through the space
int x = button.LastIndexOf(',') + 2; int x = button.LastIndexOf(',');
return button.Substring(x, button.Length - x); if (x != -1)
return button.Substring(x + 2, button.Length - (x + 2));
else
return "";
}
private string AppendButtonMapping(string button, string oldmap)
{
int x = oldmap.LastIndexOf(',');
if (x != -1)
return oldmap.Substring(0, x + 2) + button;
else
return oldmap + ", " + button;
} }
private void DoSMS() private void DoSMS()
{ {
Label TempLabel;
InputWidget TempTextBox;
this.Text = ControllerStr + "SMS / GG / SG-1000"; this.Text = ControllerStr + "SMS / GG / SG-1000";
ControllerImage.Image = BizHawk.MultiClient.Properties.Resources.SMSController; ControllerImage.Image = BizHawk.MultiClient.Properties.Resources.SMSController;
SystemComboBox.SelectedIndex = 0; this.SystemComboBox.SelectedIndex = 0;
int jpad = this.ControllComboBox.SelectedIndex;
Label UpLabel = new Label(); string[] ButtonMappings = new string[SMSList.Length];
UpLabel.Text = "Up"; ButtonMappings[0] = TruncateButtonMapping(Global.Config.SMSController[jpad].Up);
UpLabel.Location = new Point(8, 20); ButtonMappings[1] = TruncateButtonMapping(Global.Config.SMSController[jpad].Down);
TextBox Up = new TextBox(); ButtonMappings[2] = TruncateButtonMapping(Global.Config.SMSController[jpad].Left);
Up.Location = new Point(48, 20); ButtonMappings[3] = TruncateButtonMapping(Global.Config.SMSController[jpad].Right);
Up.Text = TruncateButtonMapping(Global.Config.SmsP1Up); ButtonMappings[4] = TruncateButtonMapping(Global.Config.SMSController[jpad].B1);
ButtonMappings[5] = TruncateButtonMapping(Global.Config.SMSController[jpad].B2);
ButtonMappings[6] = TruncateButtonMapping(Global.Config.SmsPause);
ButtonMappings[7] = TruncateButtonMapping(Global.Config.SmsReset);
Label DownLabel = new Label(); Labels.Clear();
DownLabel.Text = "Down"; for (int i = 0; i < SMSList.Length; i++)
DownLabel.Location = new Point(8, 44); {
TextBox Down = new TextBox(); TempLabel = new Label();
Down.Location = new Point(48, 44); TempLabel.Text = SMSList[i];
Down.Text = TruncateButtonMapping(Global.Config.SmsP1Down); TempLabel.Location = new Point(8, 20 + (i * 24));
Labels.Add(TempLabel);
Label LeftLabel = new Label(); TempTextBox = new InputWidget();
LeftLabel.Text = "Left"; TempTextBox.Location = new Point(48, 20 + (i * 24));
LeftLabel.Location = new Point(8, 68); TextBoxes.Add(TempTextBox);
TextBox Left = new TextBox(); TempTextBox.Text = ButtonMappings[i];
Left.Location = new Point(48, 68); ButtonsGroupBox.Controls.Add(TempTextBox);
Left.Text = TruncateButtonMapping(Global.Config.SmsP1Left); ButtonsGroupBox.Controls.Add(TempLabel);
}
Label RightLabel = new Label();
RightLabel.Text = "Right";
RightLabel.Location = new Point(8, 92);
TextBox Right = new TextBox();
Right.Location = new Point(48, 92);
Right.Text = TruncateButtonMapping(Global.Config.SmsP1Right);
Label IButtonLabel = new Label();
IButtonLabel.Text = "I";
IButtonLabel.Location = new Point(8, 140);
TextBox IButton = new TextBox();
IButton.Location = new Point(48, 140);
IButton.Text = TruncateButtonMapping(Global.Config.SmsP1B1);
Label IIButtonLabel = new Label();
IIButtonLabel.Text = "II";
IIButtonLabel.Location = new Point(8, 164);
TextBox IIButton = new TextBox();
IIButton.Location = new Point(48, 164);
IIButton.Text = TruncateButtonMapping(Global.Config.SmsP1B2);
ButtonsGroupBox.Controls.Add(Up);
ButtonsGroupBox.Controls.Add(UpLabel);
ButtonsGroupBox.Controls.Add(Down);
ButtonsGroupBox.Controls.Add(DownLabel);
ButtonsGroupBox.Controls.Add(Left);
ButtonsGroupBox.Controls.Add(LeftLabel);
ButtonsGroupBox.Controls.Add(Right);
ButtonsGroupBox.Controls.Add(RightLabel);
ButtonsGroupBox.Controls.Add(IButton);
ButtonsGroupBox.Controls.Add(IButtonLabel);
ButtonsGroupBox.Controls.Add(IIButton);
ButtonsGroupBox.Controls.Add(IIButtonLabel);
} }
private void DoPCE() private void DoPCE()
{ {
this.Text = ControllerStr + "PCEjin / SGX"; this.Text = ControllerStr + "PCEjin / SGX";
@ -111,9 +99,10 @@ namespace BizHawk.MultiClient
} }
private void InputConfig_Load(object sender, EventArgs e) private void InputConfig_Load(object sender, EventArgs e)
{ {
//Determine the System currently loaded, and set that one up first, if null emulator set, what is the default? //SystemComboBox = new ComboBox();
ControllComboBox.SelectedIndex = 0; //Determine the System currently loaded, and set that one up first, if null emulator set, what is the default?
/*
if (!(Global.Emulator is NullEmulator)) if (!(Global.Emulator is NullEmulator))
{ {
switch (Global.Game.System) switch (Global.Game.System)
@ -121,28 +110,37 @@ namespace BizHawk.MultiClient
case "SMS": case "SMS":
case "SG": case "SG":
case "GG": case "GG":
DoSMS(); joypads = 2;
break; break;
case "PCE": case "PCE":
case "SGX": case "SGX":
DoPCE(); joypads = 5;
break; break;
case "GEN": case "GEN":
DoGen(); joypads = 8;
break; break;
case "TI83": case "TI83":
DoTI83(); joypads = 1;
break; break;
case "GB": case "GB":
DoGameBoy(); joypads = 1;
break; break;
default: default:
DoSMS(); joypads = 2;
break; break;
} }
} }
else else
DoSMS(); {
joypads = 2;
}
ControllComboBox.Items.Clear();
for (int i = 0; i < joypads; i++)
{
ControllComboBox.Items.Add(string.Format("Joypad {0}", i + 1));
}
ControllComboBox.SelectedIndex = 0;*/
} }
private void OK_Click(object sender, EventArgs e) private void OK_Click(object sender, EventArgs e)
@ -157,24 +155,53 @@ namespace BizHawk.MultiClient
private void SystemComboBox_SelectedIndexChanged(object sender, EventArgs e) private void SystemComboBox_SelectedIndexChanged(object sender, EventArgs e)
{ {
switch (SystemComboBox.SelectedItem.ToString()) int joypads = 0;
switch (this.SystemComboBox.SelectedItem.ToString())
{ {
case "SMS / GG / SG-1000": case "SMS / GG / SG-1000":
DoSMS(); joypads = 2;
break; break;
case "PC Engine / SGX": case "PC Engine / SGX":
DoPCE(); joypads = 5;
break; break;
case "Gameboy": case "Gameboy":
DoGameBoy(); joypads = 1;
break; break;
case "Sega Genesis": case "Sega Genesis":
DoGen(); joypads = 8;
break; break;
case "TI-83": case "TI-83":
DoTI83(); joypads = 1;
break; break;
}
ControllComboBox.Items.Clear();
for (int i = 0; i < joypads; i++)
{
ControllComboBox.Items.Add(string.Format("Joypad {0}", i + 1));
}
ControllComboBox.SelectedIndex = 0;
}
private void ControllComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
switch (SystemComboBox.SelectedItem.ToString())
{
case "SMS / GG / SG-1000":
DoSMS();
break;
case "PC Engine / SGX":
DoPCE();
break;
case "Gameboy":
DoGameBoy();
break;
case "Sega Genesis":
DoGen();
break;
case "TI-83":
DoTI83();
break;
}
} }
} }
} }
}