Config: Reduced settings.xml size
This commit is contained in:
parent
0f5d65da7e
commit
bb18cf9a3f
3 changed files with 126 additions and 42 deletions
|
@ -28,14 +28,14 @@ namespace Mesen.GUI.Config
|
|||
public UInt32 LButton;
|
||||
public UInt32 RButton;
|
||||
|
||||
public UInt32[] PowerPadButtons = new UInt32[12];
|
||||
public UInt32[] FamilyBasicKeyboardButtons = new UInt32[72];
|
||||
public UInt32[] PartyTapButtons = new UInt32[6];
|
||||
public UInt32[] PachinkoButtons = new UInt32[2];
|
||||
public UInt32[] ExcitingBoxingButtons = new UInt32[8];
|
||||
public UInt32[] JissenMahjongButtons = new UInt32[21];
|
||||
public UInt32[] SuborKeyboardButtons = new UInt32[99];
|
||||
public UInt32[] BandaiMicrophoneButtons = new UInt32[3];
|
||||
[XmlElement("PowerPad")] public XmlIntArray PowerPadButtons = new UInt32[12];
|
||||
[XmlElement("FamilyBasic")] public XmlIntArray FamilyBasicKeyboardButtons = new UInt32[72];
|
||||
[XmlElement("PartyTap")] public XmlIntArray PartyTapButtons = new UInt32[6];
|
||||
[XmlElement("Pachinko")] public XmlIntArray PachinkoButtons = new UInt32[2];
|
||||
[XmlElement("ExcitingBoxing")] public XmlIntArray ExcitingBoxingButtons = new UInt32[8];
|
||||
[XmlElement("JissenMahjong")] public XmlIntArray JissenMahjongButtons = new UInt32[21];
|
||||
[XmlElement("SuborKeyboard")] public XmlIntArray SuborKeyboardButtons = new UInt32[99];
|
||||
[XmlElement("BandaiMicrophone")] public XmlIntArray BandaiMicrophoneButtons = new UInt32[3];
|
||||
|
||||
public KeyMappings()
|
||||
{
|
||||
|
@ -44,14 +44,14 @@ namespace Mesen.GUI.Config
|
|||
public KeyMappings Clone()
|
||||
{
|
||||
KeyMappings clone = (KeyMappings)this.MemberwiseClone();
|
||||
clone.PowerPadButtons = (UInt32[])this.PowerPadButtons.Clone();
|
||||
clone.FamilyBasicKeyboardButtons = (UInt32[])this.FamilyBasicKeyboardButtons.Clone();
|
||||
clone.PartyTapButtons = (UInt32[])this.PartyTapButtons.Clone();
|
||||
clone.PachinkoButtons = (UInt32[])this.PachinkoButtons.Clone();
|
||||
clone.ExcitingBoxingButtons = (UInt32[])this.ExcitingBoxingButtons.Clone();
|
||||
clone.JissenMahjongButtons = (UInt32[])this.JissenMahjongButtons.Clone();
|
||||
clone.SuborKeyboardButtons = (UInt32[])this.SuborKeyboardButtons.Clone();
|
||||
clone.BandaiMicrophoneButtons = (UInt32[])this.BandaiMicrophoneButtons.Clone();
|
||||
clone.PowerPadButtons = this.PowerPadButtons.Clone();
|
||||
clone.FamilyBasicKeyboardButtons = this.FamilyBasicKeyboardButtons.Clone();
|
||||
clone.PartyTapButtons = this.PartyTapButtons.Clone();
|
||||
clone.PachinkoButtons = this.PachinkoButtons.Clone();
|
||||
clone.ExcitingBoxingButtons = this.ExcitingBoxingButtons.Clone();
|
||||
clone.JissenMahjongButtons = this.JissenMahjongButtons.Clone();
|
||||
clone.SuborKeyboardButtons = this.SuborKeyboardButtons.Clone();
|
||||
clone.BandaiMicrophoneButtons = this.BandaiMicrophoneButtons.Clone();
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
@ -224,4 +224,88 @@ namespace Mesen.GUI.Config
|
|||
InteropEmu.SetMouseSensitivity(InteropEmu.MouseDevice.SuborMouse, (inputInfo.SuborMouse.Sensitivity + 1) / 2.0);
|
||||
}
|
||||
}
|
||||
|
||||
public class XmlIntArray
|
||||
{
|
||||
private List<UInt32> _values = new List<UInt32>();
|
||||
|
||||
public XmlIntArray() { }
|
||||
|
||||
public XmlIntArray(List<UInt32> values)
|
||||
{
|
||||
_values = new List<UInt32>(values);
|
||||
KeyCount = _values.Count;
|
||||
}
|
||||
|
||||
public XmlIntArray(UInt32[] values)
|
||||
{
|
||||
_values = new List<UInt32>(values);
|
||||
KeyCount = _values.Count;
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public List<UInt32> Values
|
||||
{
|
||||
get { return new List<UInt32>(_values); }
|
||||
}
|
||||
|
||||
public XmlIntArray Clone()
|
||||
{
|
||||
return new XmlIntArray(this.Values);
|
||||
}
|
||||
|
||||
public static implicit operator List<UInt32>(XmlIntArray x)
|
||||
{
|
||||
return new List<UInt32>(x.Values);
|
||||
}
|
||||
|
||||
public static implicit operator UInt32[](XmlIntArray x)
|
||||
{
|
||||
return x.Values.ToArray();
|
||||
}
|
||||
|
||||
public static implicit operator XmlIntArray(List<UInt32> values)
|
||||
{
|
||||
return new XmlIntArray(values);
|
||||
}
|
||||
|
||||
public static implicit operator XmlIntArray(UInt32[] values)
|
||||
{
|
||||
return new XmlIntArray(values);
|
||||
}
|
||||
|
||||
[XmlElement(Order = 0)]
|
||||
public int KeyCount;
|
||||
|
||||
[XmlElement("Values", Order = 1)]
|
||||
public string IntValues
|
||||
{
|
||||
get { return _values.Any(v => v > 0) ? string.Join(",", _values) : ""; }
|
||||
set
|
||||
{
|
||||
try {
|
||||
if(!string.IsNullOrWhiteSpace(value)) {
|
||||
List<UInt32> values = new List<UInt32>();
|
||||
foreach(string val in value.Split(',')) {
|
||||
values.Add(UInt32.Parse(val));
|
||||
}
|
||||
while(values.Count < KeyCount) {
|
||||
values.Add(0);
|
||||
}
|
||||
_values = values;
|
||||
} else {
|
||||
_values = new List<UInt32>(new UInt32[KeyCount]);
|
||||
}
|
||||
} catch {
|
||||
_values = new List<UInt32>(new UInt32[KeyCount]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 this[int index]
|
||||
{
|
||||
get { return _values[index]; }
|
||||
set { _values[index] = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -484,7 +484,7 @@ namespace Mesen.GUI.Forms.Config
|
|||
}
|
||||
break;
|
||||
case InteropEmu.ControllerType.PowerPad:
|
||||
foreach(UInt32 button in mappings.PowerPadButtons) {
|
||||
foreach(UInt32 button in mappings.PowerPadButtons.Values) {
|
||||
countMapping(i, button);
|
||||
}
|
||||
break;
|
||||
|
@ -497,27 +497,27 @@ namespace Mesen.GUI.Forms.Config
|
|||
foreach(KeyMappings mappings in inputInfo.Controllers[0].Keys) {
|
||||
switch(inputInfo.ExpansionPortDevice) {
|
||||
case InteropEmu.ExpansionPortDevice.ExcitingBoxing:
|
||||
foreach(UInt32 button in mappings.ExcitingBoxingButtons) {
|
||||
foreach(UInt32 button in mappings.ExcitingBoxingButtons.Values) {
|
||||
countMapping(4, button);
|
||||
}
|
||||
break;
|
||||
case InteropEmu.ExpansionPortDevice.FamilyTrainerMat:
|
||||
foreach(UInt32 button in mappings.PowerPadButtons) {
|
||||
foreach(UInt32 button in mappings.PowerPadButtons.Values) {
|
||||
countMapping(4, button);
|
||||
}
|
||||
break;
|
||||
case InteropEmu.ExpansionPortDevice.JissenMahjong:
|
||||
foreach(UInt32 button in mappings.JissenMahjongButtons) {
|
||||
foreach(UInt32 button in mappings.JissenMahjongButtons.Values) {
|
||||
countMapping(4, button);
|
||||
}
|
||||
break;
|
||||
case InteropEmu.ExpansionPortDevice.Pachinko:
|
||||
foreach(UInt32 button in mappings.PachinkoButtons) {
|
||||
foreach(UInt32 button in mappings.PachinkoButtons.Values) {
|
||||
countMapping(4, button);
|
||||
}
|
||||
break;
|
||||
case InteropEmu.ExpansionPortDevice.PartyTap:
|
||||
foreach(UInt32 button in mappings.PartyTapButtons) {
|
||||
foreach(UInt32 button in mappings.PartyTapButtons.Values) {
|
||||
countMapping(4, button);
|
||||
}
|
||||
break;
|
||||
|
@ -528,7 +528,7 @@ namespace Mesen.GUI.Forms.Config
|
|||
if(_hasCartridgeInput && btnSetupCartridge.Enabled) {
|
||||
//Bandai microphone
|
||||
foreach(KeyMappings mappings in inputInfo.Controllers[0].Keys) {
|
||||
foreach(UInt32 button in mappings.BandaiMicrophoneButtons) {
|
||||
foreach(UInt32 button in mappings.BandaiMicrophoneButtons.Values) {
|
||||
countMapping(5, button);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,25 +56,6 @@ namespace Mesen.GUI.Forms
|
|||
ConfigManager.Config.Cheats = ConfigManager.Config.Cheats.Where((cheat) => cheat.GameCrc != "00000000" && cheat.GameCrc.Length == 8).ToList();
|
||||
}
|
||||
|
||||
if(oldVersion <= new Version("0.9.3")) {
|
||||
//Version 0.9.3-
|
||||
//Set default keys for some of the new controller types
|
||||
KeyPresets presets = new KeyPresets();
|
||||
if(ConfigManager.Config.InputInfo.Controllers.Count > 0 && ConfigManager.Config.InputInfo.Controllers[0].Keys.Count > 0) {
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].ExcitingBoxingButtons = presets.ExcitingBoxing.ExcitingBoxingButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].FamilyBasicKeyboardButtons = presets.FamilyBasic.FamilyBasicKeyboardButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].JissenMahjongButtons = presets.JissenMahjong.JissenMahjongButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].PachinkoButtons = presets.Pachinko.PachinkoButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].PartyTapButtons = presets.PartyTap.PartyTapButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].PowerPadButtons = presets.PowerPad.PowerPadButtons;
|
||||
if(ConfigManager.Config.InputInfo.Controllers.Count > 1 && ConfigManager.Config.InputInfo.Controllers[1].Keys.Count > 0) {
|
||||
ConfigManager.Config.InputInfo.Controllers[1].Keys[0].PowerPadButtons = presets.PowerPad.PowerPadButtons;
|
||||
}
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].SuborKeyboardButtons = presets.SuborKeyboard.SuborKeyboardButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].BandaiMicrophoneButtons = presets.BandaiMicrophone.BandaiMicrophoneButtons;
|
||||
}
|
||||
}
|
||||
|
||||
if(oldVersion <= new Version("0.9.4")) {
|
||||
ShortcutKeyInfo oldLoadAutoSlot1 = ConfigManager.Config.PreferenceInfo.ShortcutKeys1.Where(o => o.Shortcut == EmulatorShortcut.LoadStateSlot8).FirstOrDefault();
|
||||
ShortcutKeyInfo oldLoadAutoSlot2 = ConfigManager.Config.PreferenceInfo.ShortcutKeys2.Where(o => o.Shortcut == EmulatorShortcut.LoadStateSlot8).FirstOrDefault();
|
||||
|
@ -92,6 +73,25 @@ namespace Mesen.GUI.Forms
|
|||
}
|
||||
}
|
||||
|
||||
if(oldVersion <= new Version("0.9.5")) {
|
||||
//Version 0.9.5-
|
||||
//Reset the default keys for the new controller types (to reduce settings.xml size)
|
||||
KeyPresets presets = new KeyPresets();
|
||||
if(ConfigManager.Config.InputInfo.Controllers.Count > 0 && ConfigManager.Config.InputInfo.Controllers[0].Keys.Count > 0) {
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].ExcitingBoxingButtons = presets.ExcitingBoxing.ExcitingBoxingButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].FamilyBasicKeyboardButtons = presets.FamilyBasic.FamilyBasicKeyboardButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].JissenMahjongButtons = presets.JissenMahjong.JissenMahjongButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].PachinkoButtons = presets.Pachinko.PachinkoButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].PartyTapButtons = presets.PartyTap.PartyTapButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].PowerPadButtons = presets.PowerPad.PowerPadButtons;
|
||||
if(ConfigManager.Config.InputInfo.Controllers.Count > 1 && ConfigManager.Config.InputInfo.Controllers[1].Keys.Count > 0) {
|
||||
ConfigManager.Config.InputInfo.Controllers[1].Keys[0].PowerPadButtons = presets.PowerPad.PowerPadButtons;
|
||||
}
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].SuborKeyboardButtons = presets.SuborKeyboard.SuborKeyboardButtons;
|
||||
ConfigManager.Config.InputInfo.Controllers[0].Keys[0].BandaiMicrophoneButtons = presets.BandaiMicrophone.BandaiMicrophoneButtons;
|
||||
}
|
||||
}
|
||||
|
||||
ConfigManager.Config.MesenVersion = InteropEmu.GetMesenVersion();
|
||||
ConfigManager.ApplyChanges();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue