u+d/l+r toggle implemented

This commit is contained in:
beirich 2011-06-10 04:14:21 +00:00
parent c4e37bf42c
commit 5a73fc03ad
2 changed files with 35 additions and 14 deletions

View File

@ -55,6 +55,16 @@ namespace BizHawk
return true; return true;
} }
public static string GetPrecedingString(this string str, string value)
{
int index = str.IndexOf(value);
if (index < 0)
return null;
if (index == 0)
return "";
return str.Substring(0, index);
}
public static bool In(this string str, params string[] options) public static bool In(this string str, params string[] options)
{ {
foreach (string opt in options) foreach (string opt in options)
@ -534,7 +544,6 @@ namespace BizHawk
string precision = "2"; string precision = "2";
return String.Format("{0:N" + precision + "}{1}", size, suffix); return String.Format("{0:N" + precision + "}{1}", size, suffix);
} }
} }
public unsafe class Serializer public unsafe class Serializer
@ -584,7 +593,7 @@ namespace BizHawk
else tr.ReadLine(); else tr.ReadLine();
} }
public unsafe void SyncEnum<T>(string name, ref T val) where T : struct public void SyncEnum<T>(string name, ref T val) where T : struct
{ {
if (typeof(T).BaseType != typeof(System.Enum)) if (typeof(T).BaseType != typeof(System.Enum))
throw new InvalidOperationException(); throw new InvalidOperationException();
@ -593,13 +602,13 @@ namespace BizHawk
else bw.Write(Convert.ToInt32(val)); else bw.Write(Convert.ToInt32(val));
} }
public unsafe void SyncEnumText<T>(string name, ref T val) where T : struct public void SyncEnumText<T>(string name, ref T val) where T : struct
{ {
if (IsReader) val = (T)Enum.Parse(typeof(T), tr.ReadLine().Split(' ')[1]); if (IsReader) val = (T)Enum.Parse(typeof(T), tr.ReadLine().Split(' ')[1]);
else tw.WriteLine("{0} {1}", name, val.ToString()); else tw.WriteLine("{0} {1}", name, val.ToString());
} }
unsafe void SyncBuffer(string name, int elemsize, int len, void* ptr) void SyncBuffer(string name, int elemsize, int len, void* ptr)
{ {
if (IsReader) if (IsReader)
{ {
@ -617,12 +626,12 @@ namespace BizHawk
} }
} }
public unsafe void Sync(string name, ref ByteBuffer byteBuf) public void Sync(string name, ref ByteBuffer byteBuf)
{ {
SyncBuffer(name, 1, byteBuf.len, byteBuf.ptr); SyncBuffer(name, 1, byteBuf.len, byteBuf.ptr);
} }
public unsafe void Sync(string name, ref IntBuffer byteBuf) public void Sync(string name, ref IntBuffer byteBuf)
{ {
SyncBuffer(name, 4, byteBuf.len, byteBuf.ptr); SyncBuffer(name, 4, byteBuf.len, byteBuf.ptr);
} }
@ -843,8 +852,6 @@ namespace BizHawk
void Write(ref bool val) { bw.Write(val); } void Write(ref bool val) { bw.Write(val); }
void ReadText(string name, ref bool val) { val = bool.Parse(tr.ReadLine().Split(' ')[1]); } void ReadText(string name, ref bool val) { val = bool.Parse(tr.ReadLine().Split(' ')[1]); }
void WriteText(string name, ref bool val) { tw.WriteLine("{0} {1}", name, val); } void WriteText(string name, ref bool val) { tw.WriteLine("{0} {1}", name, val); }
} }
@ -945,8 +952,6 @@ namespace BizHawk
/// </summary> /// </summary>
public IList<K> Keys { get { return new List<K>(dictionary.Keys); } } public IList<K> Keys { get { return new List<K>(dictionary.Keys); } }
public L this[K key] public L this[K key]
{ {
get get
@ -962,6 +967,4 @@ namespace BizHawk
} }
} }
} }
} }

View File

@ -75,7 +75,7 @@ namespace BizHawk.MultiClient
removeFromForcePressedButtons.Add(button); removeFromForcePressedButtons.Add(button);
return true; return true;
} }
if (unpressedButtons.Contains(button)) if (unpressedButtons.Contains(button))
{ {
if (IsPressedActually(button) == false) if (IsPressedActually(button) == false)
unpressedButtons.Remove(button); unpressedButtons.Remove(button);
@ -83,6 +83,24 @@ namespace BizHawk.MultiClient
return false; return false;
} }
if (Global.Config.AllowUD_LR == false)
{
string prefix;
if (button.Contains("Down"))
{
prefix = button.GetPrecedingString("Down");
if (IsPressed(prefix + "Up"))
return false;
}
if (button.Contains("Right"))
{
prefix = button.GetPrecedingString("Right");
if (IsPressed(prefix + "Left"))
return false;
}
}
return IsPressedActually(button); return IsPressedActually(button);
} }
@ -164,7 +182,7 @@ namespace BizHawk.MultiClient
if (type.Name == "PC Engine Controller") if (type.Name == "PC Engine Controller")
{ {
input.Append("."); //TODO: reset goes here input.Append("."); //TODO: reset goes here - the turbografx DOES NOT HAVE A RESET BUTTON. but I assume this is for pcejin movie file compatibility, which is a fools errand anyway......... I'll leave it for now, but marked for deletion
input.Append("|"); input.Append("|");
for (int player = 1; player < 6; player++) for (int player = 1; player < 6; player++)
{ {