move DefaultControls class to its own file

This commit is contained in:
adelikat 2020-01-21 09:35:27 -06:00
parent e4827929b8
commit 86078addd4
4 changed files with 18 additions and 15 deletions

View File

@ -18,7 +18,7 @@ namespace BizHawk.Client.Common
{ {
if (AllTrollers.Count == 0 && AllTrollersAutoFire.Count == 0 && AllTrollersAnalog.Count == 0) if (AllTrollers.Count == 0 && AllTrollersAutoFire.Count == 0 && AllTrollersAnalog.Count == 0)
{ {
var cd = ConfigService.Load<ControlDefaults>(ControlDefaultPath); var cd = ConfigService.Load<DefaultControls>(ControlDefaultPath);
AllTrollers = cd.AllTrollers; AllTrollers = cd.AllTrollers;
AllTrollersAutoFire = cd.AllTrollersAutoFire; AllTrollersAutoFire = cd.AllTrollersAutoFire;
AllTrollersAnalog = cd.AllTrollersAnalog; AllTrollersAnalog = cd.AllTrollersAnalog;
@ -382,8 +382,6 @@ namespace BizHawk.Client.Common
public int Analog_LargeChange = 10; public int Analog_LargeChange = 10;
public int Analog_SmallChange = 1; public int Analog_SmallChange = 1;
// [ControllerType][ButtonName] => Physical Bind // [ControllerType][ButtonName] => Physical Bind
public Dictionary<string, Dictionary<string, string>> AllTrollers = new Dictionary<string, Dictionary<string, string>>(); 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 Dictionary<string, Dictionary<string, string>> AllTrollersAutoFire = new Dictionary<string, Dictionary<string, string>>();
@ -405,12 +403,4 @@ namespace BizHawk.Client.Common
public string LastWrittenFrom = VersionInfo.Mainversion; public string LastWrittenFrom = VersionInfo.Mainversion;
public string LastWrittenFromDetailed = VersionInfo.GetEmuVersion(); public string LastWrittenFromDetailed = VersionInfo.GetEmuVersion();
} }
// These are used in the defctrl.json or wherever
public 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 Dictionary<string, Dictionary<string, AnalogBind>> AllTrollersAnalog = new Dictionary<string, Dictionary<string, AnalogBind>>();
}
} }

View File

@ -0,0 +1,12 @@
using System.Collections.Generic;
namespace BizHawk.Client.Common
{
// Represents the defaults used in defctrl.json
public class DefaultControls
{
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 Dictionary<string, Dictionary<string, AnalogBind>> AllTrollersAnalog = new Dictionary<string, Dictionary<string, AnalogBind>>();
}
}

View File

@ -237,7 +237,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void LoadPanels(ControlDefaults cd) private void LoadPanels(DefaultControls cd)
{ {
LoadPanels(cd.AllTrollers, cd.AllTrollersAutoFire, cd.AllTrollersAnalog); LoadPanels(cd.AllTrollers, cd.AllTrollersAutoFire, cd.AllTrollersAnalog);
} }
@ -323,7 +323,7 @@ namespace BizHawk.Client.EmuHawk
ActOnControlCollection<AnalogBindPanel>(AnalogControlsTab, c => c.Save(_config.AllTrollersAnalog[_emulator.ControllerDefinition.Name])); ActOnControlCollection<AnalogBindPanel>(AnalogControlsTab, c => c.Save(_config.AllTrollersAnalog[_emulator.ControllerDefinition.Name]));
} }
private void SaveToDefaults(ControlDefaults cd) private void SaveToDefaults(DefaultControls cd)
{ {
ActOnControlCollection<ControllerConfigPanel>(NormalControlsTab, c => c.Save(cd.AllTrollers[_emulator.ControllerDefinition.Name])); ActOnControlCollection<ControllerConfigPanel>(NormalControlsTab, c => c.Save(cd.AllTrollers[_emulator.ControllerDefinition.Name]));
ActOnControlCollection<ControllerConfigPanel>(AutofireControlsTab, c => c.Save(cd.AllTrollersAutoFire[_emulator.ControllerDefinition.Name])); ActOnControlCollection<ControllerConfigPanel>(AutofireControlsTab, c => c.Save(cd.AllTrollersAutoFire[_emulator.ControllerDefinition.Name]));
@ -398,7 +398,7 @@ namespace BizHawk.Client.EmuHawk
// load panels directly from the default config. // load panels directly from the default config.
// this means that the changes are NOT committed. so "Cancel" works right and you // this means that the changes are NOT committed. so "Cancel" works right and you
// still have to hit OK at the end. // still have to hit OK at the end.
var cd = ConfigService.Load<ControlDefaults>(Config.ControlDefaultPath); var cd = ConfigService.Load<DefaultControls>(Config.ControlDefaultPath);
LoadPanels(cd); LoadPanels(cd);
tabControl1.SelectTab(wasTabbedMain); tabControl1.SelectTab(wasTabbedMain);
@ -431,7 +431,7 @@ namespace BizHawk.Client.EmuHawk
var result = MessageBox.Show(this, "OK to overwrite defaults for current control scheme?", "Save Defaults", MessageBoxButtons.YesNo); var result = MessageBox.Show(this, "OK to overwrite defaults for current control scheme?", "Save Defaults", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes) if (result == DialogResult.Yes)
{ {
var cd = ConfigService.Load<ControlDefaults>(Config.ControlDefaultPath); var cd = ConfigService.Load<DefaultControls>(Config.ControlDefaultPath);
cd.AllTrollers[_emulator.ControllerDefinition.Name] = new Dictionary<string, string>(); cd.AllTrollers[_emulator.ControllerDefinition.Name] = new Dictionary<string, string>();
cd.AllTrollersAutoFire[_emulator.ControllerDefinition.Name] = new Dictionary<string, string>(); cd.AllTrollersAutoFire[_emulator.ControllerDefinition.Name] = new Dictionary<string, string>();
cd.AllTrollersAnalog[_emulator.ControllerDefinition.Name] = new Dictionary<string, AnalogBind>(); cd.AllTrollersAnalog[_emulator.ControllerDefinition.Name] = new Dictionary<string, AnalogBind>();

View File

@ -229,6 +229,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Datarows/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Datarows/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Deadzone/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Deadzone/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=dearchive/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=dearchive/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=defctrl/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dega/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Dega/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=delaminated/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=delaminated/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dendy/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Dendy/@EntryIndexedValue">True</s:Boolean>