playernumber stuff: This is all medium whack
This commit is contained in:
parent
5406da7406
commit
cf608bfca9
|
@ -165,7 +165,8 @@ namespace BizHawk.Emulation.Common
|
||||||
List<string> list = new List<string>(FloatControls);
|
List<string> list = new List<string>(FloatControls);
|
||||||
list.AddRange(BoolButtons);
|
list.AddRange(BoolButtons);
|
||||||
|
|
||||||
List<string>[] ret = new List<string>[9];
|
// starts with console buttons, then each plasyer's buttons individually
|
||||||
|
List<string>[] ret = new List<string>[PlayerCount + 1];
|
||||||
for (int i = 0; i < ret.Length; i++)
|
for (int i = 0; i < ret.Length; i++)
|
||||||
{
|
{
|
||||||
ret[i] = new List<string>();
|
ret[i] = new List<string>();
|
||||||
|
@ -182,16 +183,18 @@ namespace BizHawk.Emulation.Common
|
||||||
|
|
||||||
public int PlayerNumber(string buttonName)
|
public int PlayerNumber(string buttonName)
|
||||||
{
|
{
|
||||||
int player = 0;
|
var match = PlayerRegex.Match(buttonName);
|
||||||
if (buttonName.Length > 3 && buttonName.StartsWith("P") && char.IsNumber(buttonName[1]))
|
if (match.Success)
|
||||||
{
|
{
|
||||||
player = buttonName[1] - '0';
|
return int.Parse(match.Groups[1].Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return player;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Regex PlayerRegex = new Regex("^P(\\d) ");
|
private static readonly Regex PlayerRegex = new Regex("^P(\\d+) ");
|
||||||
|
|
||||||
public int PlayerCount
|
public int PlayerCount
|
||||||
{
|
{
|
||||||
|
@ -199,9 +202,7 @@ namespace BizHawk.Emulation.Common
|
||||||
{
|
{
|
||||||
var allNames = FloatControls.Concat(BoolButtons).ToList();
|
var allNames = FloatControls.Concat(BoolButtons).ToList();
|
||||||
var player = allNames
|
var player = allNames
|
||||||
.Select(s => PlayerRegex.Match(s).Groups[1])
|
.Select(PlayerNumber)
|
||||||
.Where(group => group.Success)
|
|
||||||
.Select(group => group.Value[0] - '0')
|
|
||||||
.DefaultIfEmpty(0)
|
.DefaultIfEmpty(0)
|
||||||
.Max();
|
.Max();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue