fix shift-numkeys

This commit is contained in:
Chris Forbes
2010-03-21 20:47:06 +13:00
parent 8207ca1105
commit a4c3ef7e38

View File

@@ -360,6 +360,20 @@ namespace OpenRA
get { return LobbyInfo.Clients.FirstOrDefault(c => c.Index == orderManager.Connection.LocalClientId); } get { return LobbyInfo.Clients.FirstOrDefault(c => c.Index == orderManager.Connection.LocalClientId); }
} }
static Dictionary<char, char> RemapKeys = new Dictionary<char, char>
{
{ '!', '1' },
{ '@', '2' },
{ '#', '3' },
{ '$', '4' },
{ '%', '5' },
{ '^', '6' },
{ '&', '7' },
{ '*', '8' },
{ '(', '9' },
{ ')', '0' },
};
public static void HandleKeyPress( KeyPressEventArgs e, Modifiers modifiers ) public static void HandleKeyPress( KeyPressEventArgs e, Modifiers modifiers )
{ {
int sync = Game.world.SyncHash(); int sync = Game.world.SyncHash();
@@ -369,9 +383,13 @@ namespace OpenRA
else if (Game.chat.isChatting) else if (Game.chat.isChatting)
Game.chat.TypeChar(e.KeyChar); Game.chat.TypeChar(e.KeyChar);
else else
if( e.KeyChar >= '0' && e.KeyChar <= '9' ) {
var c = RemapKeys.ContainsKey(e.KeyChar) ? RemapKeys[e.KeyChar] : e.KeyChar;
if (c >= '0' && c <= '9')
Game.controller.selection.DoControlGroup(world, Game.controller.selection.DoControlGroup(world,
e.KeyChar - '0', modifiers ); c - '0', modifiers);
}
if( sync != Game.world.SyncHash() ) if( sync != Game.world.SyncHash() )
throw new InvalidOperationException( "Desync in OnKeyPress" ); throw new InvalidOperationException( "Desync in OnKeyPress" );