From 0825c4181cc759c7911436e7ebc2a8bf4da3bef4 Mon Sep 17 00:00:00 2001 From: goyuken Date: Sun, 14 Jul 2013 01:48:05 +0000 Subject: [PATCH] multiclient: rework everything controller config related. there is still some transitional cruft and whatnot, so be patient. --- .../BizHawk.MultiClient.csproj | 12 ++ BizHawk.MultiClient/Config.cs | 96 +++++----- BizHawk.MultiClient/MainForm.MenuItems.cs | 3 +- BizHawk.MultiClient/MainForm.cs | 50 ++++- BizHawk.MultiClient/TI83tools/TI83KeyPad.cs | 4 + .../config/ControllerConfig.cs | 3 +- .../ControllerConfig/ControllerConfigPanel.cs | 12 +- .../NewControllerConfigPanel.cs | 57 ++++++ .../config/NewControllerConfig.Designer.cs | 173 ++++++++++++++++++ .../config/NewControllerConfig.cs | 95 ++++++++++ .../config/NewControllerConfig.resx | 120 ++++++++++++ 11 files changed, 569 insertions(+), 56 deletions(-) create mode 100644 BizHawk.MultiClient/config/ControllerConfig/NewControllerConfigPanel.cs create mode 100644 BizHawk.MultiClient/config/NewControllerConfig.Designer.cs create mode 100644 BizHawk.MultiClient/config/NewControllerConfig.cs create mode 100644 BizHawk.MultiClient/config/NewControllerConfig.resx diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj index 182969f497..1e5df0cc5d 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj @@ -178,6 +178,9 @@ ControllerConfigPanel.cs + + UserControl + Form @@ -193,6 +196,12 @@ MessageConfig.cs + + Form + + + NewControllerConfig.cs + Form @@ -572,6 +581,9 @@ GifAnimator.cs + + NewControllerConfig.cs + PathInfo.cs diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs index b4ef2d1ccd..7adf3d8292 100644 --- a/BizHawk.MultiClient/Config.cs +++ b/BizHawk.MultiClient/Config.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using System.Drawing; using System.Collections.Generic; @@ -8,6 +9,7 @@ namespace BizHawk.MultiClient { public Config() { + /* SMSController[0] = new SMSControllerTemplate(true); SMSController[1] = new SMSControllerTemplate(false); PCEController[0] = new PCEControllerTemplate(true); @@ -102,6 +104,7 @@ namespace BizHawk.MultiClient SNESConsoleButtons = new NESConsoleButtonTemplate(); SMSConsoleButtons = new SMSConsoleButtonTemplate(); GenesisConsoleButtons = new GenConsoleButtonTemplate(); + */ } // Directories @@ -843,6 +846,10 @@ namespace BizHawk.MultiClient public const int NESNoiseMax = 247; public const int NESDMCMax = 167; + // [ControllerType][ControllerName] => Bind + public Dictionary> AllTrollers = new Dictionary>(); + public Dictionary> AllTrollersAutoFire = new Dictionary>(); + // SMS / GameGear Settings public bool SmsEnableFM = true; public bool SmsAllowOverlock = false; @@ -851,66 +858,66 @@ namespace BizHawk.MultiClient public bool GGShowClippedRegions = false; public bool GGHighlightActiveDisplayRegion = false; - public SMSControllerTemplate[] SMSController = new SMSControllerTemplate[2]; - public SMSControllerTemplate[] SMSAutoController = new SMSControllerTemplate[2]; - public SMSConsoleButtonTemplate SMSConsoleButtons = new SMSConsoleButtonTemplate(); + //public SMSControllerTemplate[] SMSController = new SMSControllerTemplate[2]; + //public SMSControllerTemplate[] SMSAutoController = new SMSControllerTemplate[2]; + //public SMSConsoleButtonTemplate SMSConsoleButtons = new SMSConsoleButtonTemplate(); // PCEngine Settings public bool PceSpriteLimit = false; public bool PceEqualizeVolume = false; public bool PceArcadeCardRewindHack = true; - public PCEControllerTemplate[] PCEController = new PCEControllerTemplate[5]; - public PCEControllerTemplate[] PCEAutoController = new PCEControllerTemplate[5]; + //public PCEControllerTemplate[] PCEController = new PCEControllerTemplate[5]; + //public PCEControllerTemplate[] PCEAutoController = new PCEControllerTemplate[5]; // Genesis Settings - public GenControllerTemplate[] GenesisController = new GenControllerTemplate[1]; - public GenControllerTemplate[] GenesisAutoController = new GenControllerTemplate[1]; - public GenConsoleButtonTemplate GenesisConsoleButtons = new GenConsoleButtonTemplate(); + //public GenControllerTemplate[] GenesisController = new GenControllerTemplate[1]; + //public GenControllerTemplate[] GenesisAutoController = new GenControllerTemplate[1]; + //public GenConsoleButtonTemplate GenesisConsoleButtons = new GenConsoleButtonTemplate(); //Atari 2600 Settings - public SingleButtonJoyStickTemplate[] Atari2600Controller = new SingleButtonJoyStickTemplate[2]; - public SingleButtonJoyStickTemplate[] Atari2600AutoController = new SingleButtonJoyStickTemplate[2]; - public Atari2600ConsoleButtonsTemplate[] Atari2600ConsoleButtons = new Atari2600ConsoleButtonsTemplate[1]; + //public SingleButtonJoyStickTemplate[] Atari2600Controller = new SingleButtonJoyStickTemplate[2]; + //public SingleButtonJoyStickTemplate[] Atari2600AutoController = new SingleButtonJoyStickTemplate[2]; + //public Atari2600ConsoleButtonsTemplate[] Atari2600ConsoleButtons = new Atari2600ConsoleButtonsTemplate[1]; public bool Atari2600_BW = false; public bool Atari2600_LeftDifficulty = true; public bool Atari2600_RightDifficulty = true; //Atari 7800 Settings - public DoubleButtonJoyStickTemplate[] Atari7800Controller = new DoubleButtonJoyStickTemplate[2]; - public DoubleButtonJoyStickTemplate[] Atari7800AutoController = new DoubleButtonJoyStickTemplate[2]; - public Atari7800ConsoleButtonsTemplate[] Atari7800ConsoleButtons = new Atari7800ConsoleButtonsTemplate[1]; + //public DoubleButtonJoyStickTemplate[] Atari7800Controller = new DoubleButtonJoyStickTemplate[2]; + //public DoubleButtonJoyStickTemplate[] Atari7800AutoController = new DoubleButtonJoyStickTemplate[2]; + //public Atari7800ConsoleButtonsTemplate[] Atari7800ConsoleButtons = new Atari7800ConsoleButtonsTemplate[1]; //ColecoVision - public ColecoVisionControllerTemplate[] ColecoController = new ColecoVisionControllerTemplate[2]; - public ColecoVisionControllerTemplate[] ColecoAutoController = new ColecoVisionControllerTemplate[2]; + //public ColecoVisionControllerTemplate[] ColecoController = new ColecoVisionControllerTemplate[2]; + //public ColecoVisionControllerTemplate[] ColecoAutoController = new ColecoVisionControllerTemplate[2]; //Intellivision - public IntellivisionControllerTemplate[] IntellivisionController = new IntellivisionControllerTemplate[2]; - public IntellivisionControllerTemplate[] IntellivisionAutoController = new IntellivisionControllerTemplate[2]; + //public IntellivisionControllerTemplate[] IntellivisionController = new IntellivisionControllerTemplate[2]; + //public IntellivisionControllerTemplate[] IntellivisionAutoController = new IntellivisionControllerTemplate[2]; //NES settings - public NESControllerTemplate[] NESController = new NESControllerTemplate[4]; - public NESControllerTemplate[] NESAutoController = new NESControllerTemplate[4]; - public NESConsoleButtonTemplate NESConsoleButtons = new NESConsoleButtonTemplate(); + //public NESControllerTemplate[] NESController = new NESControllerTemplate[4]; + //public NESControllerTemplate[] NESAutoController = new NESControllerTemplate[4]; + //public NESConsoleButtonTemplate NESConsoleButtons = new NESConsoleButtonTemplate(); //SNES settings - public SNESControllerTemplate[] SNESController = new SNESControllerTemplate[4]; - public SNESControllerTemplate[] SNESAutoController = new SNESControllerTemplate[4]; - public NESConsoleButtonTemplate SNESConsoleButtons = new NESConsoleButtonTemplate(); + //public SNESControllerTemplate[] SNESController = new SNESControllerTemplate[4]; + //public SNESControllerTemplate[] SNESAutoController = new SNESControllerTemplate[4]; + //public NESConsoleButtonTemplate SNESConsoleButtons = new NESConsoleButtonTemplate(); public string SNESProfile = "Compatibility"; public bool SNESUseRingBuffer = true; public bool SNESAlwaysDoubleSize = false; - public N64ButtonsTemplate[] N64Controller = new N64ButtonsTemplate[4]; - public N64ButtonsTemplate[] N64AutoController = new N64ButtonsTemplate[4]; - public Standard2ButtonConsoleTemplate N64ConsoleButtons = new Standard2ButtonConsoleTemplate(); + //public N64ButtonsTemplate[] N64Controller = new N64ButtonsTemplate[4]; + //public N64ButtonsTemplate[] N64AutoController = new N64ButtonsTemplate[4]; + //public Standard2ButtonConsoleTemplate N64ConsoleButtons = new Standard2ButtonConsoleTemplate(); //TI 83 settings - public TI83ControllerTemplate[] TI83Controller = new TI83ControllerTemplate[1]; + //public TI83ControllerTemplate[] TI83Controller = new TI83ControllerTemplate[1]; //GB settings - public GBControllerTemplate[] GBController = new GBControllerTemplate[1]; - public GBControllerTemplate[] GBAutoController = new GBControllerTemplate[1]; + //public GBControllerTemplate[] GBController = new GBControllerTemplate[1]; + //public GBControllerTemplate[] GBAutoController = new GBControllerTemplate[1]; public bool GB_ForceDMG = false; public bool GB_GBACGB = false; public bool GB_MulticartCompat = false; @@ -919,23 +926,23 @@ namespace BizHawk.MultiClient public Emulation.Consoles.GB.GBColors.ColorType CGBColors = Emulation.Consoles.GB.GBColors.ColorType.gambatte; //Dual Gb - public DualGBControllerTemplate[] DualGBController = new DualGBControllerTemplate[1]; - public DualGBControllerTemplate[] AutoDualGBController = new DualGBControllerTemplate[1]; + //public DualGBControllerTemplate[] DualGBController = new DualGBControllerTemplate[1]; + //public DualGBControllerTemplate[] AutoDualGBController = new DualGBControllerTemplate[1]; //GBA settings - public GBAControllerTemplate[] GBAController = new GBAControllerTemplate[1]; - public GBAControllerTemplate[] GBAAutoController = new GBAControllerTemplate[1]; + //public GBAControllerTemplate[] GBAController = new GBAControllerTemplate[1]; + //public GBAControllerTemplate[] GBAAutoController = new GBAControllerTemplate[1]; //Saturn - public SaturnControllerTemplate[] SaturnController = new SaturnControllerTemplate[2]; - public SaturnControllerTemplate[] SaturnAutoController = new SaturnControllerTemplate[2]; - public SaturnConsoleButtonTemplate SaturnConsoleButtons = new SaturnConsoleButtonTemplate(); + //public SaturnControllerTemplate[] SaturnController = new SaturnControllerTemplate[2]; + //public SaturnControllerTemplate[] SaturnAutoController = new SaturnControllerTemplate[2]; + //public SaturnConsoleButtonTemplate SaturnConsoleButtons = new SaturnConsoleButtonTemplate(); //Commodore 64 Settings - public SingleButtonJoyStickTemplate[] C64Joysticks = new SingleButtonJoyStickTemplate[2]; - public SingleButtonJoyStickTemplate[] C64AutoJoysticks = new SingleButtonJoyStickTemplate[2]; - public C64KeyboardTemplate C64Keyboard = new C64KeyboardTemplate(); - public C64KeyboardTemplate C64AutofireKeyboard = new C64KeyboardTemplate(); + //public SingleButtonJoyStickTemplate[] C64Joysticks = new SingleButtonJoyStickTemplate[2]; + //public SingleButtonJoyStickTemplate[] C64AutoJoysticks = new SingleButtonJoyStickTemplate[2]; + //public C64KeyboardTemplate C64Keyboard = new C64KeyboardTemplate(); + //public C64KeyboardTemplate C64AutofireKeyboard = new C64KeyboardTemplate(); //GIF Animator Settings public int GifAnimatorNumFrames; @@ -975,6 +982,7 @@ namespace BizHawk.MultiClient public bool Atari2600_ShowPlayfield = true; } + /* public class NESConsoleButtonTemplate : iControllerConfigObject { public string Reset = ""; @@ -1949,12 +1957,12 @@ namespace BizHawk.MultiClient SIN = "Period"; //49 } } - + */ public interface iControllerConfigObject { void SetDefaults(); } - + public enum PLUGINTYPE { RICE, GLIDE }; diff --git a/BizHawk.MultiClient/MainForm.MenuItems.cs b/BizHawk.MultiClient/MainForm.MenuItems.cs index de6c6463b6..03317cdf4d 100644 --- a/BizHawk.MultiClient/MainForm.MenuItems.cs +++ b/BizHawk.MultiClient/MainForm.MenuItems.cs @@ -463,7 +463,8 @@ namespace BizHawk.MultiClient private void OpenControllerConfig() { - ControllerConfig c = new ControllerConfig(); + //ControllerConfig c = new ControllerConfig(); + config.NewControllerConfig c = new config.NewControllerConfig(Global.Emulator.ControllerDefinition); c.ShowDialog(); if (c.DialogResult == DialogResult.OK) { diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index edbbfa07a0..014a080d8a 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -804,7 +804,7 @@ namespace BizHawk.MultiClient Global.NullControls = new Controller(NullEmulator.NullController); Global.AutofireNullControls = new AutofireController(NullEmulator.NullController); - + /* var smsControls = new Controller(SMS.SmsController); smsControls.BindMulti("Reset", Global.Config.SMSConsoleButtons.Reset); smsControls.BindMulti("Pause", Global.Config.SMSConsoleButtons.Pause); @@ -905,7 +905,7 @@ namespace BizHawk.MultiClient Global.AutofireSNESControls = asnesControls; var nesControls = new Controller(NES.NESController); - for (int i = 0; i < 2 /*TODO*/; i++) + for (int i = 0; i < 2; i++) // TODO: more than 2 { nesControls.BindMulti("P" + (i + 1) + " Up", Global.Config.NESController[i].Up); nesControls.BindMulti("P" + (i + 1) + " Down", Global.Config.NESController[i].Down); @@ -927,7 +927,7 @@ namespace BizHawk.MultiClient var anesControls = new AutofireController(NES.NESController) {Autofire = true}; - for (int i = 0; i < 2 /*TODO*/; i++) + for (int i = 0; i < 2; i++) // TODO: more than 2 { anesControls.BindMulti("P" + (i + 1) + " Up", Global.Config.NESAutoController[i].Up); anesControls.BindMulti("P" + (i + 1) + " Down", Global.Config.NESAutoController[i].Down); @@ -1634,6 +1634,8 @@ namespace BizHawk.MultiClient N64AControls.BindMulti("P4 R", Global.Config.N64AutoController[3].R); Global.AutofireN64Controls = N64AControls; + + */ } private static void FormDragEnter(object sender, DragEventArgs e) @@ -1905,8 +1907,47 @@ namespace BizHawk.MultiClient } } + static Controller BindToDefinition(ControllerDefinition def, Dictionary> allbinds) + { + var ret = new Controller(def); + Dictionary binds; + if (allbinds.TryGetValue(def.Name, out binds)) + { + foreach (string cbutton in def.BoolButtons) + { + string bind; + if (binds.TryGetValue(cbutton, out bind)) + ret.BindMulti(cbutton, bind); + } + } + return ret; + } + // could merge these two methods... + static AutofireController BindToDefinitionAF(ControllerDefinition def, Dictionary> allbinds) + { + var ret = new AutofireController(def); + Dictionary binds; + if (allbinds.TryGetValue(def.Name, out binds)) + { + foreach (string cbutton in def.BoolButtons) + { + string bind; + if (binds.TryGetValue(cbutton, out bind)) + ret.BindMulti(cbutton, bind); + } + } + return ret; + } + + void SyncControls() { + var def = Global.Emulator.ControllerDefinition; + + Global.ActiveController = BindToDefinition(def, Global.Config.AllTrollers); + Global.AutoFireController = BindToDefinitionAF(def, Global.Config.AllTrollersAutoFire); + + /* if (Global.Game == null) return; switch (Global.Game.System) { @@ -1989,6 +2030,7 @@ namespace BizHawk.MultiClient Global.ActiveController = Global.NullControls; break; } + */ // allow propogating controls that are in the current controller definition but not in the prebaked one Global.ActiveController.ForceType(new ControllerDefinition(Global.Emulator.ControllerDefinition)); Global.ClickyVirtualPadController.Type = new ControllerDefinition(Global.Emulator.ControllerDefinition); @@ -2763,6 +2805,7 @@ namespace BizHawk.MultiClient //modals that need to capture input for binding purposes get input, of course if (ActiveForm is HotkeyWindow) return true; if (ActiveForm is ControllerConfig) return true; + if (ActiveForm is config.NewControllerConfig) return true; if (ActiveForm is TAStudio) return true; //if no form is active on this process, then the background input setting applies if (ActiveForm == null && Global.Config.AcceptBackgroundInput) return true; @@ -2881,7 +2924,6 @@ namespace BizHawk.MultiClient } } //foreach event - } private void ClearAutohold() diff --git a/BizHawk.MultiClient/TI83tools/TI83KeyPad.cs b/BizHawk.MultiClient/TI83tools/TI83KeyPad.cs index 2877f7203b..b8844c399e 100644 --- a/BizHawk.MultiClient/TI83tools/TI83KeyPad.cs +++ b/BizHawk.MultiClient/TI83tools/TI83KeyPad.cs @@ -26,6 +26,9 @@ namespace BizHawk.MultiClient private void SetToolTips() { //Set button hotkey mapping into tooltips + // TODO: REFIX this to work with the new controller system + // it isn't horribly difficult, but has to be done. + /* toolTip1.SetToolTip(ZERO, Global.Config.TI83Controller[0]._0); toolTip1.SetToolTip(ONE, Global.Config.TI83Controller[0]._1); toolTip1.SetToolTip(TWO, Global.Config.TI83Controller[0]._2); @@ -76,6 +79,7 @@ namespace BizHawk.MultiClient toolTip1.SetToolTip(DEL, Global.Config.TI83Controller[0].DEL); toolTip1.SetToolTip(COMMA, Global.Config.TI83Controller[0].COMMA); toolTip1.SetToolTip(SIN, Global.Config.TI83Controller[0].SIN); + */ } public void StopToolTips() diff --git a/BizHawk.MultiClient/config/ControllerConfig.cs b/BizHawk.MultiClient/config/ControllerConfig.cs index 6e739c5183..6896c6d222 100644 --- a/BizHawk.MultiClient/config/ControllerConfig.cs +++ b/BizHawk.MultiClient/config/ControllerConfig.cs @@ -14,6 +14,7 @@ namespace BizHawk.MultiClient private void ControllerConfig_Load(object sender, EventArgs e) { + /* AllowLR.Checked = Global.Config.AllowUD_LR; NESController1Panel.LoadSettings(Global.Config.NESController[0]); @@ -208,7 +209,7 @@ namespace BizHawk.MultiClient INTVAutofire2Panel.LabelWidth = 50; INTVAutofire2Panel.ColumnWidth = 170; INTVAutofire2Panel.LoadSettings(Global.Config.IntellivisionAutoController[1]); - + */ SetTabByPlatform(); if (!MainForm.INTERIM) diff --git a/BizHawk.MultiClient/config/ControllerConfig/ControllerConfigPanel.cs b/BizHawk.MultiClient/config/ControllerConfig/ControllerConfigPanel.cs index a8bc25140e..1da3ea2892 100644 --- a/BizHawk.MultiClient/config/ControllerConfig/ControllerConfigPanel.cs +++ b/BizHawk.MultiClient/config/ControllerConfig/ControllerConfigPanel.cs @@ -74,7 +74,7 @@ namespace BizHawk.MultiClient } } - public void Save() + virtual public void Save() { for (int button = 0; button < buttons.Count; button++) { @@ -83,7 +83,7 @@ namespace BizHawk.MultiClient } } - public void LoadSettings(iControllerConfigObject configobj) + virtual public void LoadSettings(iControllerConfigObject configobj) { ControllerConfigObject = configobj; @@ -92,7 +92,7 @@ namespace BizHawk.MultiClient SetWidgetStrings(); } - private void SetButtonList() + virtual protected void SetButtonList() { buttons.Clear(); MemberInfo[] members = ControllerConfigObject.GetType().GetMembers(); @@ -106,7 +106,7 @@ namespace BizHawk.MultiClient } } - private void SetWidgetStrings() + virtual protected void SetWidgetStrings() { for (int button = 0; button < buttons.Count; button++) { @@ -123,7 +123,7 @@ namespace BizHawk.MultiClient } } - private void Startup() + protected void Startup() { int x = InputMarginLeft; int y = MarginTop - Spacing; @@ -175,7 +175,7 @@ namespace BizHawk.MultiClient ClearAll(); } - private void restoreDefaultsToolStripMenuItem_Click(object sender, EventArgs e) + virtual protected void restoreDefaultsToolStripMenuItem_Click(object sender, EventArgs e) { ControllerConfigObject.SetDefaults(); SetWidgetStrings(); diff --git a/BizHawk.MultiClient/config/ControllerConfig/NewControllerConfigPanel.cs b/BizHawk.MultiClient/config/ControllerConfig/NewControllerConfigPanel.cs new file mode 100644 index 0000000000..d94f974d3d --- /dev/null +++ b/BizHawk.MultiClient/config/ControllerConfig/NewControllerConfigPanel.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.MultiClient.config.ControllerConfig +{ + class NewControllerConfigPanel : ControllerConfigPanel + { + Dictionary RealConfigObject; + + public override void Save() + { + for (int button = 0; button < buttons.Count; button++) + RealConfigObject[buttons[button]] = Inputs[button].Text; + } + + public void LoadSettings(Dictionary configobj) + { + RealConfigObject = configobj; + SetButtonList(); + Startup(); + SetWidgetStrings(); + } + + public override void LoadSettings(iControllerConfigObject configobj) + { + throw new InvalidOperationException(); + } + + protected override void SetButtonList() + { + buttons.Clear(); + foreach (string s in RealConfigObject.Keys) + buttons.Add(s); + } + + protected override void SetWidgetStrings() + { + for (int button = 0; button < buttons.Count; button++) + { + string s; + if (!RealConfigObject.TryGetValue(buttons[button], out s)) + s = ""; + Inputs[button].SetBindings(s); + } + } + + protected override void restoreDefaultsToolStripMenuItem_Click(object sender, EventArgs e) + { + // this is a TODO: we have no concept of default values in our config system at the moment + // so for the moment, "defaults" = "no binds at all" + RealConfigObject.Clear(); + SetWidgetStrings(); + } + } +} diff --git a/BizHawk.MultiClient/config/NewControllerConfig.Designer.cs b/BizHawk.MultiClient/config/NewControllerConfig.Designer.cs new file mode 100644 index 0000000000..04810fc56a --- /dev/null +++ b/BizHawk.MultiClient/config/NewControllerConfig.Designer.cs @@ -0,0 +1,173 @@ +namespace BizHawk.MultiClient.config +{ + partial class NewControllerConfig + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.label2 = new System.Windows.Forms.Label(); + this.checkBoxAutoTab = new System.Windows.Forms.CheckBox(); + this.checkBoxUDLR = new System.Windows.Forms.CheckBox(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.tabControl1.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(107, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Currently Configuring:"; + // + // tabControl1 + // + this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Location = new System.Drawing.Point(12, 25); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(840, 318); + this.tabControl1.TabIndex = 1; + // + // tabPage1 + // + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(832, 292); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "Normal Controls"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // tabPage2 + // + 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(832, 292); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "Autofire Controls"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(13, 457); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(140, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Escape clears a keybinding."; + // + // checkBoxAutoTab + // + this.checkBoxAutoTab.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkBoxAutoTab.AutoSize = true; + this.checkBoxAutoTab.Location = new System.Drawing.Point(260, 456); + this.checkBoxAutoTab.Name = "checkBoxAutoTab"; + this.checkBoxAutoTab.Size = new System.Drawing.Size(70, 17); + this.checkBoxAutoTab.TabIndex = 3; + this.checkBoxAutoTab.Text = "Auto Tab"; + this.checkBoxAutoTab.UseVisualStyleBackColor = true; + this.checkBoxAutoTab.CheckedChanged += new System.EventHandler(this.checkBoxAutoTab_CheckedChanged); + // + // checkBoxUDLR + // + this.checkBoxUDLR.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkBoxUDLR.AutoSize = true; + this.checkBoxUDLR.Location = new System.Drawing.Point(336, 456); + this.checkBoxUDLR.Name = "checkBoxUDLR"; + this.checkBoxUDLR.Size = new System.Drawing.Size(84, 17); + this.checkBoxUDLR.TabIndex = 4; + this.checkBoxUDLR.Text = "Allow UDLR"; + this.checkBoxUDLR.UseVisualStyleBackColor = true; + this.checkBoxUDLR.CheckedChanged += new System.EventHandler(this.checkBoxUDLR_CheckedChanged); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(696, 444); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 5; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.Location = new System.Drawing.Point(777, 444); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // NewControllerConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(864, 479); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.checkBoxUDLR); + this.Controls.Add(this.checkBoxAutoTab); + this.Controls.Add(this.label2); + this.Controls.Add(this.tabControl1); + this.Controls.Add(this.label1); + this.Name = "NewControllerConfig"; + this.Text = "NewControllerConfig"; + this.tabControl1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.CheckBox checkBoxAutoTab; + private System.Windows.Forms.CheckBox checkBoxUDLR; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + } +} \ No newline at end of file diff --git a/BizHawk.MultiClient/config/NewControllerConfig.cs b/BizHawk.MultiClient/config/NewControllerConfig.cs new file mode 100644 index 0000000000..bb455a5f23 --- /dev/null +++ b/BizHawk.MultiClient/config/NewControllerConfig.cs @@ -0,0 +1,95 @@ +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 BizHawk.MultiClient.config.ControllerConfig; + +namespace BizHawk.MultiClient.config +{ + public partial class NewControllerConfig : Form + { + private NewControllerConfig() + { + InitializeComponent(); + } + + NewControllerConfigPanel normcontrls; + NewControllerConfigPanel autofirecontrls; + + static void DoLoadSettings(NewControllerConfigPanel cp, ControllerDefinition def, Dictionary> settingsblock) + { + cp.Spacing = 24; + cp.InputSize = 100; + cp.LabelPadding = 5; + cp.ColumnWidth = 170; + cp.LabelWidth = 60; + + Dictionary settings; + if (!settingsblock.TryGetValue(def.Name, out settings)) + { + settings = new Dictionary(); + settingsblock[def.Name] = settings; + } + // check to make sure that the settings object has all of the appropriate boolbuttons + foreach (string button in def.BoolButtons) + { + if (!settings.Keys.Contains(button)) + settings[button] = ""; + } + cp.LoadSettings(settings); + } + + public NewControllerConfig(ControllerDefinition def) + : this() + { + SuspendLayout(); + normcontrls = new NewControllerConfigPanel(); + normcontrls.Dock = DockStyle.Fill; + tabPage1.Controls.Add(normcontrls); + DoLoadSettings(normcontrls, def, Global.Config.AllTrollers); + + autofirecontrls = new NewControllerConfigPanel(); + autofirecontrls.Dock = DockStyle.Fill; + tabPage2.Controls.Add(autofirecontrls); + DoLoadSettings(autofirecontrls, def, Global.Config.AllTrollersAutoFire); + + label1.Text = "Currently Configuring: " + def.Name; + checkBoxUDLR.Checked = Global.Config.AllowUD_LR; + checkBoxAutoTab.Checked = Global.Config.InputConfigAutoTab; + ResumeLayout(); + } + + private void checkBoxAutoTab_CheckedChanged(object sender, EventArgs e) + { + normcontrls.SetAutoTab(checkBoxAutoTab.Checked); + autofirecontrls.SetAutoTab(checkBoxAutoTab.Checked); + } + + private void checkBoxUDLR_CheckedChanged(object sender, EventArgs e) + { + } + + private void buttonOK_Click(object sender, EventArgs e) + { + Global.Config.AllowUD_LR = checkBoxUDLR.Checked; + Global.Config.InputConfigAutoTab = checkBoxAutoTab.Checked; + + normcontrls.Save(); + autofirecontrls.Save(); + + Global.OSD.AddMessage("Controller settings saved"); + DialogResult = DialogResult.OK; + Close(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + Global.OSD.AddMessage("Controller config aborted"); + Close(); + } + } +} diff --git a/BizHawk.MultiClient/config/NewControllerConfig.resx b/BizHawk.MultiClient/config/NewControllerConfig.resx new file mode 100644 index 0000000000..29dcb1b3a3 --- /dev/null +++ b/BizHawk.MultiClient/config/NewControllerConfig.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file