2013-07-14 01:48:05 +00:00
|
|
|
|
using System;
|
2013-11-09 01:29:29 +00:00
|
|
|
|
using System.Collections;
|
2013-07-14 01:48:05 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2013-11-04 01:39:19 +00:00
|
|
|
|
using BizHawk.Emulation.Common;
|
2013-10-25 00:57:23 +00:00
|
|
|
|
using BizHawk.Client.Common;
|
|
|
|
|
|
2013-11-03 03:54:37 +00:00
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
2013-07-14 01:48:05 +00:00
|
|
|
|
{
|
2013-10-06 20:45:04 +00:00
|
|
|
|
public partial class ControllerConfig : Form
|
2013-07-14 01:48:05 +00:00
|
|
|
|
{
|
2013-07-17 01:05:36 +00:00
|
|
|
|
static readonly Dictionary<string, Bitmap> ControllerImages = new Dictionary<string, Bitmap>();
|
2013-10-06 20:45:04 +00:00
|
|
|
|
static ControllerConfig()
|
2013-07-14 02:21:41 +00:00
|
|
|
|
{
|
|
|
|
|
ControllerImages.Add("NES Controller", Properties.Resources.NES_Controller);
|
2013-10-06 20:45:04 +00:00
|
|
|
|
ControllerImages.Add("SNES Controller", Properties.Resources.SNES_Controller);
|
|
|
|
|
ControllerImages.Add("Nintento 64 Controller", Properties.Resources.N64);
|
|
|
|
|
ControllerImages.Add("Gameboy Controller", Properties.Resources.GBController);
|
|
|
|
|
ControllerImages.Add("GBA Controller", Properties.Resources.GBA_Controller);
|
|
|
|
|
ControllerImages.Add("Dual Gameboy Controller", Properties.Resources.GBController);
|
|
|
|
|
|
|
|
|
|
ControllerImages.Add("SMS Controller", Properties.Resources.SMSController);
|
|
|
|
|
ControllerImages.Add("Genesis 3-Button Controller", Properties.Resources.GENController);
|
2013-12-17 01:46:23 +00:00
|
|
|
|
ControllerImages.Add("GPGX Genesis Controller", Properties.Resources.GENController);
|
2013-10-06 20:45:04 +00:00
|
|
|
|
ControllerImages.Add("Saturn Controller", Properties.Resources.SaturnController);
|
|
|
|
|
|
|
|
|
|
ControllerImages.Add("Intellivision Controller", Properties.Resources.IntVController);
|
|
|
|
|
ControllerImages.Add("ColecoVision Basic Controller", Properties.Resources.colecovisioncontroller);
|
|
|
|
|
ControllerImages.Add("Atari 2600 Basic Controller", Properties.Resources.atari_controller);
|
|
|
|
|
ControllerImages.Add("Atari 7800 ProLine Joystick Controller", Properties.Resources.A78Joystick);
|
|
|
|
|
|
|
|
|
|
ControllerImages.Add("PC Engine Controller", Properties.Resources.PCEngineController);
|
2013-07-14 02:21:41 +00:00
|
|
|
|
ControllerImages.Add("Commodore 64 Controller", Properties.Resources.C64Joystick);
|
2013-10-06 20:45:04 +00:00
|
|
|
|
ControllerImages.Add("TI83 Controller", Properties.Resources.TI83_Controller);
|
2013-07-29 20:02:15 +00:00
|
|
|
|
|
2013-10-06 20:45:04 +00:00
|
|
|
|
//ControllerImages.Add("PSP Controller", Properties.Resources); //TODO
|
2013-07-14 02:21:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-14 03:27:54 +00:00
|
|
|
|
const int MAXPLAYERS = 8;
|
|
|
|
|
|
2013-10-06 20:45:04 +00:00
|
|
|
|
private ControllerConfig()
|
2013-07-14 01:48:05 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-24 01:38:52 +00:00
|
|
|
|
delegate Control PanelCreator<T>(Dictionary<string, T> settings, List<string> buttons, Size size);
|
|
|
|
|
|
2013-11-09 01:29:29 +00:00
|
|
|
|
private Control CreateNormalPanel(Dictionary<string, string> settings, List<string> buttons, Size size)
|
2013-07-24 01:38:52 +00:00
|
|
|
|
{
|
2013-10-06 20:45:04 +00:00
|
|
|
|
var cp = new ControllerConfigPanel { Dock = DockStyle.Fill };
|
2013-07-28 21:54:42 +00:00
|
|
|
|
cp.LoadSettings(settings, checkBoxAutoTab.Checked, buttons, size.Width, size.Height);
|
2013-07-24 01:38:52 +00:00
|
|
|
|
return cp;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-28 01:33:38 +00:00
|
|
|
|
private static Control CreateAnalogPanel(Dictionary<string, Config.AnalogBind> settings, List<string> buttons, Size size)
|
2013-07-14 03:27:54 +00:00
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
return new AnalogBindPanel(settings, buttons) { Dock = DockStyle.Fill };
|
2013-07-24 01:38:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-28 01:33:38 +00:00
|
|
|
|
static void LoadToPanel<T>(Control dest, string controllerName, IEnumerable<string> controllerButtons, IDictionary<string, Dictionary<string, T>> settingsblock, T defaultvalue, PanelCreator<T> createpanel)
|
2013-07-24 01:38:52 +00:00
|
|
|
|
{
|
|
|
|
|
Dictionary<string, T> settings;
|
2013-11-28 01:33:38 +00:00
|
|
|
|
if (!settingsblock.TryGetValue(controllerName, out settings))
|
2013-07-14 03:27:54 +00:00
|
|
|
|
{
|
2013-07-24 01:38:52 +00:00
|
|
|
|
settings = new Dictionary<string, T>();
|
2013-11-28 01:33:38 +00:00
|
|
|
|
settingsblock[controllerName] = settings;
|
2013-07-14 03:27:54 +00:00
|
|
|
|
}
|
|
|
|
|
// check to make sure that the settings object has all of the appropriate boolbuttons
|
2013-11-28 01:33:38 +00:00
|
|
|
|
foreach (var button in controllerButtons)
|
2013-07-14 03:27:54 +00:00
|
|
|
|
{
|
|
|
|
|
if (!settings.Keys.Contains(button))
|
2013-07-24 01:38:52 +00:00
|
|
|
|
settings[button] = defaultvalue;
|
2013-07-14 03:27:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (settings.Keys.Count == 0)
|
2013-11-28 01:33:38 +00:00
|
|
|
|
{
|
2013-07-14 03:27:54 +00:00
|
|
|
|
return;
|
2013-11-28 01:33:38 +00:00
|
|
|
|
}
|
2013-07-14 01:48:05 +00:00
|
|
|
|
|
2013-07-14 03:27:54 +00:00
|
|
|
|
// split the list of all settings into buckets by player number
|
2013-11-28 01:33:38 +00:00
|
|
|
|
var buckets = new List<string>[MAXPLAYERS + 1];
|
2013-07-14 03:27:54 +00:00
|
|
|
|
for (int i = 0; i < buckets.Length; i++)
|
2013-11-28 01:33:38 +00:00
|
|
|
|
{
|
2013-07-14 03:27:54 +00:00
|
|
|
|
buckets[i] = new List<string>();
|
2013-11-28 01:33:38 +00:00
|
|
|
|
}
|
2013-07-14 03:27:54 +00:00
|
|
|
|
|
2013-11-28 01:33:38 +00:00
|
|
|
|
foreach (var button in settings.Keys)
|
2013-07-14 03:27:54 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 1; i <= MAXPLAYERS; i++)
|
|
|
|
|
{
|
|
|
|
|
if (button.StartsWith("P" + i))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (i > MAXPLAYERS) // couldn't find
|
|
|
|
|
i = 0;
|
|
|
|
|
buckets[i].Add(button);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (buckets[0].Count == settings.Keys.Count)
|
|
|
|
|
{
|
|
|
|
|
// everything went into bucket 0, so make no tabs at all
|
2013-07-24 01:38:52 +00:00
|
|
|
|
dest.Controls.Add(createpanel(settings, null, dest.Size));
|
2013-07-14 03:27:54 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// create multiple player tabs
|
2013-10-06 20:45:04 +00:00
|
|
|
|
var tt = new TabControl { Dock = DockStyle.Fill };
|
2013-07-14 03:27:54 +00:00
|
|
|
|
dest.Controls.Add(tt);
|
|
|
|
|
int pageidx = 0;
|
|
|
|
|
for (int i = 1; i <= MAXPLAYERS; i++)
|
|
|
|
|
{
|
|
|
|
|
if (buckets[i].Count > 0)
|
|
|
|
|
{
|
|
|
|
|
tt.TabPages.Add("Player " + i);
|
2013-07-24 01:38:52 +00:00
|
|
|
|
tt.TabPages[pageidx].Controls.Add(createpanel(settings, buckets[i], tt.Size));
|
2013-07-14 03:27:54 +00:00
|
|
|
|
pageidx++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (buckets[0].Count > 0)
|
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
tt.TabPages.Add(Global.Emulator.SystemId == "C64" ? "Keyboard" : "Console");
|
2013-07-24 01:38:52 +00:00
|
|
|
|
tt.TabPages[pageidx].Controls.Add(createpanel(settings, buckets[0], tt.Size));
|
2013-07-14 03:27:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-28 01:33:38 +00:00
|
|
|
|
private readonly ControllerDefinition _theDefinition;
|
2013-10-06 20:45:04 +00:00
|
|
|
|
|
|
|
|
|
public ControllerConfig(ControllerDefinition def)
|
2013-07-14 01:48:05 +00:00
|
|
|
|
: this()
|
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
_theDefinition = def;
|
2013-07-14 01:48:05 +00:00
|
|
|
|
SuspendLayout();
|
2013-07-31 02:43:06 +00:00
|
|
|
|
LoadPanels(Global.Config);
|
2013-07-14 01:48:05 +00:00
|
|
|
|
|
|
|
|
|
checkBoxUDLR.Checked = Global.Config.AllowUD_LR;
|
|
|
|
|
checkBoxAutoTab.Checked = Global.Config.InputConfigAutoTab;
|
2013-07-14 02:21:41 +00:00
|
|
|
|
|
|
|
|
|
SetControllerPicture(def.Name);
|
2013-07-31 20:34:20 +00:00
|
|
|
|
|
2013-11-10 02:32:47 +00:00
|
|
|
|
if (!VersionInfo.INTERIM)
|
|
|
|
|
{
|
2013-07-31 20:34:20 +00:00
|
|
|
|
buttonSaveDefaults.Hide();
|
2013-11-10 02:32:47 +00:00
|
|
|
|
}
|
2013-07-31 20:34:20 +00:00
|
|
|
|
|
2013-07-14 01:48:05 +00:00
|
|
|
|
ResumeLayout();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-28 01:33:38 +00:00
|
|
|
|
private void LoadPanels(IDictionary<string, Dictionary<string, string>> normal,
|
|
|
|
|
IDictionary<string, Dictionary<string, string>> autofire,
|
|
|
|
|
IDictionary<string, Dictionary<string, Config.AnalogBind>> analog)
|
2013-07-27 17:59:40 +00:00
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
LoadToPanel(tabPage1, _theDefinition.Name, _theDefinition.BoolButtons, normal, "", CreateNormalPanel);
|
|
|
|
|
LoadToPanel(tabPage2, _theDefinition.Name, _theDefinition.BoolButtons, autofire, "", CreateNormalPanel);
|
|
|
|
|
LoadToPanel(tabPage3, _theDefinition.Name, _theDefinition.FloatControls, analog, new Config.AnalogBind("", 1.0f, 0.1f), CreateAnalogPanel);
|
2013-07-27 18:44:51 +00:00
|
|
|
|
|
|
|
|
|
if (tabPage3.Controls.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
tabControl1.TabPages.Remove(tabPage3);
|
|
|
|
|
}
|
2013-07-27 17:59:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-31 02:43:06 +00:00
|
|
|
|
private void LoadPanels(ControlDefaults cd)
|
|
|
|
|
{
|
|
|
|
|
LoadPanels(cd.AllTrollers, cd.AllTrollersAutoFire, cd.AllTrollersAnalog);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-09 01:29:29 +00:00
|
|
|
|
private void LoadPanels(Config c)
|
2013-07-31 02:43:06 +00:00
|
|
|
|
{
|
|
|
|
|
LoadPanels(c.AllTrollers, c.AllTrollersAutoFire, c.AllTrollersAnalog);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-28 01:33:38 +00:00
|
|
|
|
void SetControllerPicture(string controlName)
|
2013-07-14 02:21:41 +00:00
|
|
|
|
{
|
|
|
|
|
Bitmap bmp;
|
2013-11-28 01:33:38 +00:00
|
|
|
|
if (!ControllerImages.TryGetValue(controlName, out bmp))
|
|
|
|
|
{
|
2013-07-14 02:21:41 +00:00
|
|
|
|
bmp = Properties.Resources.Help;
|
2013-11-28 01:33:38 +00:00
|
|
|
|
}
|
2013-07-14 02:21:41 +00:00
|
|
|
|
|
|
|
|
|
pictureBox1.Image = bmp;
|
|
|
|
|
pictureBox1.Size = bmp.Size;
|
|
|
|
|
tableLayoutPanel1.ColumnStyles[1].Width = bmp.Width;
|
2013-07-30 17:55:38 +00:00
|
|
|
|
|
2013-10-06 20:45:04 +00:00
|
|
|
|
//Uberhack
|
2013-11-28 01:33:38 +00:00
|
|
|
|
if (controlName == "Commodore 64 Controller")
|
2013-10-06 20:45:04 +00:00
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
var pictureBox2 = new PictureBox
|
2013-11-09 01:29:29 +00:00
|
|
|
|
{
|
|
|
|
|
Image = Properties.Resources.C64Keyboard,
|
|
|
|
|
Size = Properties.Resources.C64Keyboard.Size
|
|
|
|
|
};
|
2013-10-06 20:45:04 +00:00
|
|
|
|
tableLayoutPanel1.ColumnStyles[1].Width = Properties.Resources.C64Keyboard.Width;
|
|
|
|
|
pictureBox1.Height /= 2;
|
|
|
|
|
pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
|
|
|
pictureBox1.Dock = DockStyle.Top;
|
|
|
|
|
pictureBox2.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y + pictureBox1.Size.Height + 10);
|
|
|
|
|
tableLayoutPanel1.Controls.Add(pictureBox2, 1, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pictureBox2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
|
|
|
|
|
}
|
2013-07-14 02:21:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-14 03:27:54 +00:00
|
|
|
|
// lazy methods, but they're not called often and actually
|
|
|
|
|
// tracking all of the ControllerConfigPanels wouldn't be simpler
|
|
|
|
|
static void SetAutoTab(Control c, bool value)
|
|
|
|
|
{
|
|
|
|
|
if (c is ControllerConfigPanel)
|
2013-11-28 01:33:38 +00:00
|
|
|
|
{
|
2013-07-14 03:27:54 +00:00
|
|
|
|
(c as ControllerConfigPanel).SetAutoTab(value);
|
2013-11-28 01:33:38 +00:00
|
|
|
|
}
|
2013-07-24 02:14:25 +00:00
|
|
|
|
else if (c is AnalogBindPanel)
|
2013-08-10 01:17:06 +00:00
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
}
|
2013-07-14 03:27:54 +00:00
|
|
|
|
else if (c.HasChildren)
|
2013-11-28 01:33:38 +00:00
|
|
|
|
{
|
2013-07-14 03:27:54 +00:00
|
|
|
|
foreach (Control cc in c.Controls)
|
2013-11-28 01:33:38 +00:00
|
|
|
|
{
|
2013-07-14 03:27:54 +00:00
|
|
|
|
SetAutoTab(cc, value);
|
2013-11-28 01:33:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-07-14 03:27:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-31 02:43:06 +00:00
|
|
|
|
void Save()
|
2013-07-14 03:27:54 +00:00
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
ActOnControlCollection<ControllerConfigPanel>(tabPage1, c => c.Save(Global.Config.AllTrollers[_theDefinition.Name]));
|
|
|
|
|
ActOnControlCollection<ControllerConfigPanel>(tabPage2, c => c.Save(Global.Config.AllTrollersAutoFire[_theDefinition.Name]));
|
|
|
|
|
ActOnControlCollection<AnalogBindPanel>(tabPage3, c => c.Save(Global.Config.AllTrollersAnalog[_theDefinition.Name]));
|
2013-07-31 02:43:06 +00:00
|
|
|
|
}
|
2013-07-31 20:34:20 +00:00
|
|
|
|
void SaveToDefaults(ControlDefaults cd)
|
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
ActOnControlCollection<ControllerConfigPanel>(tabPage1, c => c.Save(cd.AllTrollers[_theDefinition.Name]));
|
|
|
|
|
ActOnControlCollection<ControllerConfigPanel>(tabPage2, c => c.Save(cd.AllTrollersAutoFire[_theDefinition.Name]));
|
|
|
|
|
ActOnControlCollection<AnalogBindPanel>(tabPage3, c => c.Save(cd.AllTrollersAnalog[_theDefinition.Name]));
|
2013-07-31 20:34:20 +00:00
|
|
|
|
}
|
2013-07-31 02:43:06 +00:00
|
|
|
|
|
|
|
|
|
static void ActOnControlCollection<T>(Control c, Action<T> proc)
|
|
|
|
|
where T : Control
|
|
|
|
|
{
|
|
|
|
|
if (c is T)
|
|
|
|
|
proc(c as T);
|
2013-07-14 03:27:54 +00:00
|
|
|
|
else if (c.HasChildren)
|
|
|
|
|
foreach (Control cc in c.Controls)
|
2013-07-31 02:43:06 +00:00
|
|
|
|
ActOnControlCollection(cc, proc);
|
2013-07-14 03:27:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-14 01:48:05 +00:00
|
|
|
|
private void checkBoxAutoTab_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-07-14 03:27:54 +00:00
|
|
|
|
SetAutoTab(this, checkBoxAutoTab.Checked);
|
2013-07-14 01:48:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2013-07-31 02:43:06 +00:00
|
|
|
|
Save();
|
2013-07-14 01:48:05 +00:00
|
|
|
|
|
2013-11-03 16:07:58 +00:00
|
|
|
|
GlobalWin.OSD.AddMessage("Controller settings saved");
|
2013-07-14 01:48:05 +00:00
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-11-03 16:07:58 +00:00
|
|
|
|
GlobalWin.OSD.AddMessage("Controller config aborted");
|
2013-07-14 01:48:05 +00:00
|
|
|
|
Close();
|
|
|
|
|
}
|
2013-07-14 20:38:23 +00:00
|
|
|
|
|
|
|
|
|
private void NewControllerConfig_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
Text = _theDefinition.Name + " Configuration";
|
2013-07-14 20:38:23 +00:00
|
|
|
|
}
|
2013-07-17 01:20:21 +00:00
|
|
|
|
|
2013-11-28 01:33:38 +00:00
|
|
|
|
private static TabControl GetTabControl(IEnumerable controls)
|
2013-10-06 20:45:04 +00:00
|
|
|
|
{
|
|
|
|
|
if (controls != null)
|
|
|
|
|
{
|
2013-11-09 01:29:29 +00:00
|
|
|
|
return controls
|
|
|
|
|
.OfType<TabControl>()
|
|
|
|
|
.Select(c => c)
|
|
|
|
|
.FirstOrDefault();
|
2013-10-06 20:45:04 +00:00
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2013-07-29 22:04:54 +00:00
|
|
|
|
|
2013-07-17 01:20:21 +00:00
|
|
|
|
private void buttonLoadDefaults_Click(object sender, EventArgs e)
|
2013-07-27 18:22:15 +00:00
|
|
|
|
{
|
2013-10-06 20:45:04 +00:00
|
|
|
|
tabControl1.SuspendLayout();
|
2013-07-29 22:04:54 +00:00
|
|
|
|
|
2013-11-28 01:33:38 +00:00
|
|
|
|
var wasTabbedMain = tabControl1.SelectedTab.Name;
|
|
|
|
|
var tb1 = GetTabControl(tabPage1.Controls);
|
|
|
|
|
var tb2 = GetTabControl(tabPage2.Controls);
|
|
|
|
|
var tb3 = GetTabControl(tabPage3.Controls);
|
2013-10-06 20:45:04 +00:00
|
|
|
|
int? wasTabbedPage1 = null;
|
|
|
|
|
int? wasTabbedPage2 = null;
|
|
|
|
|
int? wasTabbedPage3 = null;
|
2013-07-29 22:04:54 +00:00
|
|
|
|
|
2013-10-06 20:45:04 +00:00
|
|
|
|
if (tb1 != null && tb1.SelectedTab != null) { wasTabbedPage1 = tb1.SelectedIndex; }
|
|
|
|
|
if (tb2 != null && tb2.SelectedTab != null) { wasTabbedPage2 = tb2.SelectedIndex; }
|
2013-11-09 01:29:29 +00:00
|
|
|
|
if (tb3 != null && tb3.SelectedTab != null) { wasTabbedPage3 = tb3.SelectedIndex; }
|
2013-07-29 22:04:54 +00:00
|
|
|
|
|
2013-10-06 20:45:04 +00:00
|
|
|
|
tabPage1.Controls.Clear();
|
|
|
|
|
tabPage2.Controls.Clear();
|
|
|
|
|
tabPage3.Controls.Clear();
|
2013-07-31 02:43:06 +00:00
|
|
|
|
|
|
|
|
|
// load panels directly from the default config.
|
|
|
|
|
// this means that the changes are NOT committed. so "Cancel" works right and you
|
|
|
|
|
// still have to hit OK at the end.
|
2013-11-28 01:33:38 +00:00
|
|
|
|
var cd = new ControlDefaults();
|
2013-11-09 01:12:46 +00:00
|
|
|
|
cd = ConfigService.Load(Config.ControlDefaultPath, cd);
|
2013-07-31 02:43:06 +00:00
|
|
|
|
LoadPanels(cd);
|
2013-07-29 22:04:54 +00:00
|
|
|
|
|
2013-10-06 20:45:04 +00:00
|
|
|
|
tabControl1.SelectTab(wasTabbedMain);
|
|
|
|
|
|
|
|
|
|
if (wasTabbedPage1.HasValue)
|
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
var newTb1 = GetTabControl(tabPage1.Controls);
|
2013-10-06 20:45:04 +00:00
|
|
|
|
if (newTb1 != null)
|
|
|
|
|
{
|
|
|
|
|
newTb1.SelectTab(wasTabbedPage1.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wasTabbedPage2.HasValue)
|
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
var newTb2 = GetTabControl(tabPage2.Controls);
|
2013-10-06 20:45:04 +00:00
|
|
|
|
if (newTb2 != null)
|
|
|
|
|
{
|
|
|
|
|
newTb2.SelectTab(wasTabbedPage2.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wasTabbedPage3.HasValue)
|
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
var newTb3 = GetTabControl(tabPage3.Controls);
|
2013-10-06 20:45:04 +00:00
|
|
|
|
if (newTb3 != null)
|
|
|
|
|
{
|
|
|
|
|
newTb3.SelectTab(wasTabbedPage3.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tabControl1.ResumeLayout();
|
2013-07-27 18:22:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-31 20:34:20 +00:00
|
|
|
|
private void buttonSaveDefaults_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var result = MessageBox.Show(this, "OK to overwrite defaults for current control scheme?", "Save Defaults", MessageBoxButtons.YesNo);
|
|
|
|
|
if (result == DialogResult.Yes)
|
|
|
|
|
{
|
2013-11-28 01:33:38 +00:00
|
|
|
|
var cd = new ControlDefaults();
|
2013-11-09 01:12:46 +00:00
|
|
|
|
cd = ConfigService.Load(Config.ControlDefaultPath, cd);
|
2013-11-28 01:33:38 +00:00
|
|
|
|
cd.AllTrollers[_theDefinition.Name] = new Dictionary<string, string>();
|
|
|
|
|
cd.AllTrollersAutoFire[_theDefinition.Name] = new Dictionary<string, string>();
|
|
|
|
|
cd.AllTrollersAnalog[_theDefinition.Name] = new Dictionary<string, Config.AnalogBind>();
|
2013-07-31 20:34:20 +00:00
|
|
|
|
|
|
|
|
|
SaveToDefaults(cd);
|
|
|
|
|
|
2013-11-09 01:12:46 +00:00
|
|
|
|
ConfigService.Save(Config.ControlDefaultPath, cd);
|
2013-07-31 20:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-07-14 01:48:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|