conttroller config default schtufff

This commit is contained in:
goyuken 2013-07-17 01:20:21 +00:00
parent 2beebec8da
commit 5903cfbe48
4 changed files with 489 additions and 1 deletions

View File

@ -6,6 +6,11 @@ namespace BizHawk.MultiClient
{
public class Config
{
public Config()
{
config.NewControllerConfig.ConfigCheckAllControlDefaults(this);
}
// Directories
public bool UseRecentForROMs = false;
public string LastRomPath = ".";

View File

@ -39,6 +39,8 @@
this.buttonCancel = new System.Windows.Forms.Button();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.buttonLoadDefaults = new System.Windows.Forms.Button();
this.buttonSaveAllDefaults = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
@ -70,7 +72,7 @@
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(726, 381);
this.tabPage2.Size = new System.Drawing.Size(486, 438);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Autofire Controls";
this.tabPage2.UseVisualStyleBackColor = true;
@ -162,6 +164,26 @@
this.pictureBox1.TabIndex = 2;
this.pictureBox1.TabStop = false;
//
// buttonLoadDefaults
//
this.buttonLoadDefaults.Location = new System.Drawing.Point(615, 485);
this.buttonLoadDefaults.Name = "buttonLoadDefaults";
this.buttonLoadDefaults.Size = new System.Drawing.Size(75, 23);
this.buttonLoadDefaults.TabIndex = 8;
this.buttonLoadDefaults.Text = "Defaults";
this.buttonLoadDefaults.UseVisualStyleBackColor = true;
this.buttonLoadDefaults.Click += new System.EventHandler(this.buttonLoadDefaults_Click);
//
// buttonSaveAllDefaults
//
this.buttonSaveAllDefaults.Location = new System.Drawing.Point(534, 485);
this.buttonSaveAllDefaults.Name = "buttonSaveAllDefaults";
this.buttonSaveAllDefaults.Size = new System.Drawing.Size(75, 23);
this.buttonSaveAllDefaults.TabIndex = 9;
this.buttonSaveAllDefaults.Text = "Save All";
this.buttonSaveAllDefaults.UseVisualStyleBackColor = true;
this.buttonSaveAllDefaults.Click += new System.EventHandler(this.buttonSaveAllDefaults_Click);
//
// NewControllerConfig
//
this.AcceptButton = this.buttonOK;
@ -169,6 +191,8 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(864, 515);
this.Controls.Add(this.buttonSaveAllDefaults);
this.Controls.Add(this.buttonLoadDefaults);
this.Controls.Add(this.checkBoxUDLR);
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.buttonCancel);
@ -199,5 +223,7 @@
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button buttonLoadDefaults;
private System.Windows.Forms.Button buttonSaveAllDefaults;
}
}

View File

@ -30,10 +30,13 @@ namespace BizHawk.MultiClient.config
}
const int MAXPLAYERS = 8;
string ControllerType;
private NewControllerConfig()
{
InitializeComponent();
if (!MainForm.INTERIM)
buttonSaveAllDefaults.Hide();
}
static void LoadToPanel(Control dest, ControllerDefinition def, Dictionary<string, Dictionary<string, string>> settingsblock)
@ -111,6 +114,7 @@ namespace BizHawk.MultiClient.config
public NewControllerConfig(ControllerDefinition def)
: this()
{
ControllerType = def.Name;
SuspendLayout();
LoadToPanel(tabPage1, def, Global.Config.AllTrollers);
LoadToPanel(tabPage2, def, Global.Config.AllTrollersAutoFire);
@ -187,5 +191,64 @@ namespace BizHawk.MultiClient.config
{
}
private static string ControlDefaultPath
{
get { return PathManager.MakeProgramRelativePath("defctrl.json"); }
}
private void buttonLoadDefaults_Click(object sender, EventArgs e)
{
// this is not clever. i'm going to replace it with something more clever
var result = MessageBox.Show("OK to load control defaults for this controller?", "Bizhawk", MessageBoxButtons.YesNo);
if (result == System.Windows.Forms.DialogResult.Yes)
{
ControlDefaults cd = new ControlDefaults();
cd = ConfigService.Load(ControlDefaultPath, cd);
Dictionary<string, string> settings;
if (cd.AllTrollers.TryGetValue(ControllerType, out settings))
Global.Config.AllTrollers[ControllerType] = settings;
else
Global.Config.AllTrollers[ControllerType].Clear();
if (cd.AllTrollersAutoFire.TryGetValue(ControllerType, out settings))
Global.Config.AllTrollersAutoFire[ControllerType] = settings;
else
Global.Config.AllTrollersAutoFire[ControllerType].Clear();
Global.OSD.AddMessage("Default controls loaded");
DialogResult = System.Windows.Forms.DialogResult.OK;
Close();
}
}
private void buttonSaveAllDefaults_Click(object sender, EventArgs e)
{
var result = MessageBox.Show("OK to save defaults for ALL cores?", "Bizhawk", MessageBoxButtons.YesNo);
if (result == System.Windows.Forms.DialogResult.Yes)
{
ControlDefaults cd = new ControlDefaults();
cd.AllTrollers = Global.Config.AllTrollers;
cd.AllTrollersAutoFire = Global.Config.AllTrollersAutoFire;
ConfigService.Save(ControlDefaultPath, cd);
}
}
class ControlDefaults
{
public Dictionary<string, Dictionary<string, string>> AllTrollers = new Dictionary<string, Dictionary<string, string>>();
public Dictionary<string, Dictionary<string, string>> AllTrollersAutoFire = new Dictionary<string, Dictionary<string, string>>();
}
public static void ConfigCheckAllControlDefaults(Config c)
{
if (c.AllTrollers.Count == 0 && c.AllTrollersAutoFire.Count == 0)
{
ControlDefaults cd = new ControlDefaults();
cd = ConfigService.Load(ControlDefaultPath, cd);
c.AllTrollers = cd.AllTrollers;
c.AllTrollersAutoFire = cd.AllTrollersAutoFire;
}
}
}
}

View File

@ -0,0 +1,394 @@
{
"AllTrollers": {
"NES Controller": {
"P1 Up": "UpArrow",
"P1 Down": "DownArrow",
"P1 Left": "LeftArrow",
"P1 Right": "RightArrow",
"P1 Select": "Delete",
"P1 Start": "End",
"P1 B": "S",
"P1 A": "A",
"Reset": "",
"Power": "",
"P2 Up": "",
"P2 Down": "",
"P2 Left": "",
"P2 Right": "",
"P2 Select": "",
"P2 Start": "",
"P2 B": "",
"P2 A": ""
},
"Gameboy Controller": {
"Up": "UpArrow",
"Down": "DownArrow",
"Left": "LeftArrow",
"Right": "RightArrow",
"A": "A",
"B": "S",
"Select": "Delete",
"Start": "End",
"Power": ""
},
"Saturn Controller": {
"Power": "",
"Reset": "",
"P1 Up": "UpArrow",
"P1 Down": "DownArrow",
"P1 Left": "LeftArrow",
"P1 Right": "RightArrow",
"P1 Start": "End",
"P1 Z": "A",
"P1 Y": "S",
"P1 X": "D",
"P1 C": "Z",
"P1 B": "X",
"P1 A": "C",
"P1 L": "Q",
"P1 R": "W",
"P2 Up": "",
"P2 Down": "",
"P2 Left": "",
"P2 Right": "",
"P2 Start": "",
"P2 Z": "",
"P2 Y": "",
"P2 X": "",
"P2 C": "",
"P2 B": "",
"P2 A": "",
"P2 L": "",
"P2 R": ""
},
"Dual Gameboy Controller": {
"P1 Up": "",
"P1 Down": "",
"P1 Left": "",
"P1 Right": "",
"P1 A": "",
"P1 B": "",
"P1 Select": "",
"P1 Start": "",
"P1 Power": "",
"P2 Up": "",
"P2 Down": "",
"P2 Left": "",
"P2 Right": "",
"P2 A": "",
"P2 B": "",
"P2 Select": "",
"P2 Start": "",
"P2 Power": ""
},
"Null Controller": {},
"TI83 Controller": {
"0": "",
"1": "",
"2": "",
"3": "",
"4": "",
"5": "",
"6": "",
"7": "",
"8": "",
"9": "",
"DOT": "",
"ON": "",
"ENTER": "",
"DOWN": "",
"LEFT": "",
"UP": "",
"RIGHT": "",
"PLUS": "",
"MINUS": "",
"MULTIPLY": "",
"DIVIDE": "",
"CLEAR": "",
"EXP": "",
"DASH": "",
"PARACLOSE": "",
"TAN": "",
"VARS": "",
"PARAOPEN": "",
"COS": "",
"PRGM": "",
"STAT": "",
"COMMA": "",
"SIN": "",
"MATRIX": "",
"X": "",
"STO": "",
"LN": "",
"LOG": "",
"SQUARED": "",
"NEG1": "",
"MATH": "",
"ALPHA": "",
"GRAPH": "",
"TRACE": "",
"ZOOM": "",
"WINDOW": "",
"Y": "",
"2ND": "",
"MODE": "",
"DEL": ""
},
"Nintento 64 Controller": {
"P1 DPad R": "RightArrow",
"P1 DPad L": "LeftArrow",
"P1 DPad D": "DownArrow",
"P1 DPad U": "UpArrow",
"P1 Start": "End",
"P1 Z": "D",
"P1 B": "S",
"P1 A": "A",
"P1 C Right": "",
"P1 C Left": "",
"P1 C Down": "",
"P1 C Up": "",
"P1 R": "W",
"P1 L": "Q",
"P2 DPad R": "",
"P2 DPad L": "",
"P2 DPad D": "",
"P2 DPad U": "",
"P2 Start": "",
"P2 Z": "",
"P2 B": "",
"P2 A": "",
"P2 C Right": "",
"P2 C Left": "",
"P2 C Down": "",
"P2 C Up": "",
"P2 R": "",
"P2 L": "",
"P3 DPad R": "",
"P3 DPad L": "",
"P3 DPad D": "",
"P3 DPad U": "",
"P3 Start": "",
"P3 Z": "",
"P3 B": "",
"P3 A": "",
"P3 C Right": "",
"P3 C Left": "",
"P3 C Down": "",
"P3 C Up": "",
"P3 R": "",
"P3 L": "",
"P4 DPad R": "",
"P4 DPad L": "",
"P4 DPad D": "",
"P4 DPad U": "",
"P4 Start": "",
"P4 Z": "",
"P4 B": "",
"P4 A": "",
"P4 C Right": "",
"P4 C Left": "",
"P4 C Down": "",
"P4 C Up": "",
"P4 R": "",
"P4 L": "",
"Reset": "",
"Power": ""
}
},
"AllTrollersAutoFire": {
"NES Controller": {
"P1 Up": "",
"P1 Down": "",
"P1 Left": "",
"P1 Right": "",
"P1 Select": "",
"P1 Start": "",
"P1 B": "",
"P1 A": "",
"Reset": "",
"Power": "",
"P2 Up": "",
"P2 Down": "",
"P2 Left": "",
"P2 Right": "",
"P2 Select": "",
"P2 Start": "",
"P2 B": "",
"P2 A": ""
},
"Gameboy Controller": {
"Up": "",
"Down": "",
"Left": "",
"Right": "",
"A": "",
"B": "",
"Select": "",
"Start": "",
"Power": ""
},
"Saturn Controller": {
"Power": "",
"Reset": "",
"P1 Up": "",
"P1 Down": "",
"P1 Left": "",
"P1 Right": "",
"P1 Start": "",
"P1 Z": "",
"P1 Y": "",
"P1 X": "",
"P1 C": "",
"P1 B": "",
"P1 A": "",
"P1 L": "",
"P1 R": "",
"P2 Up": "",
"P2 Down": "",
"P2 Left": "",
"P2 Right": "",
"P2 Start": "",
"P2 Z": "",
"P2 Y": "",
"P2 X": "",
"P2 C": "",
"P2 B": "",
"P2 A": "",
"P2 L": "",
"P2 R": ""
},
"Dual Gameboy Controller": {
"P1 Up": "",
"P1 Down": "",
"P1 Left": "",
"P1 Right": "",
"P1 A": "",
"P1 B": "",
"P1 Select": "",
"P1 Start": "",
"P1 Power": "",
"P2 Up": "",
"P2 Down": "",
"P2 Left": "",
"P2 Right": "",
"P2 A": "",
"P2 B": "",
"P2 Select": "",
"P2 Start": "",
"P2 Power": ""
},
"Null Controller": {},
"TI83 Controller": {
"0": "",
"1": "",
"2": "",
"3": "",
"4": "",
"5": "",
"6": "",
"7": "",
"8": "",
"9": "",
"DOT": "",
"ON": "",
"ENTER": "",
"DOWN": "",
"LEFT": "",
"UP": "",
"RIGHT": "",
"PLUS": "",
"MINUS": "",
"MULTIPLY": "",
"DIVIDE": "",
"CLEAR": "",
"EXP": "",
"DASH": "",
"PARACLOSE": "",
"TAN": "",
"VARS": "",
"PARAOPEN": "",
"COS": "",
"PRGM": "",
"STAT": "",
"COMMA": "",
"SIN": "",
"MATRIX": "",
"X": "",
"STO": "",
"LN": "",
"LOG": "",
"SQUARED": "",
"NEG1": "",
"MATH": "",
"ALPHA": "",
"GRAPH": "",
"TRACE": "",
"ZOOM": "",
"WINDOW": "",
"Y": "",
"2ND": "",
"MODE": "",
"DEL": ""
},
"Nintento 64 Controller": {
"P1 DPad R": "",
"P1 DPad L": "",
"P1 DPad D": "",
"P1 DPad U": "",
"P1 Start": "",
"P1 Z": "",
"P1 B": "",
"P1 A": "",
"P1 C Right": "",
"P1 C Left": "",
"P1 C Down": "",
"P1 C Up": "",
"P1 R": "",
"P1 L": "",
"P2 DPad R": "",
"P2 DPad L": "",
"P2 DPad D": "",
"P2 DPad U": "",
"P2 Start": "",
"P2 Z": "",
"P2 B": "",
"P2 A": "",
"P2 C Right": "",
"P2 C Left": "",
"P2 C Down": "",
"P2 C Up": "",
"P2 R": "",
"P2 L": "",
"P3 DPad R": "",
"P3 DPad L": "",
"P3 DPad D": "",
"P3 DPad U": "",
"P3 Start": "",
"P3 Z": "",
"P3 B": "",
"P3 A": "",
"P3 C Right": "",
"P3 C Left": "",
"P3 C Down": "",
"P3 C Up": "",
"P3 R": "",
"P3 L": "",
"P4 DPad R": "",
"P4 DPad L": "",
"P4 DPad D": "",
"P4 DPad U": "",
"P4 Start": "",
"P4 Z": "",
"P4 B": "",
"P4 A": "",
"P4 C Right": "",
"P4 C Left": "",
"P4 C Down": "",
"P4 C Up": "",
"P4 R": "",
"P4 L": "",
"Reset": "",
"Power": ""
}
}
}