From a4c3ef7e3894b8be255b28c74caf6fe31bfab3dc Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 21 Mar 2010 20:47:06 +1300 Subject: [PATCH] fix shift-numkeys --- OpenRA.Game/Game.cs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index cd35c562c7..ee7dfe0a83 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -360,18 +360,36 @@ namespace OpenRA get { return LobbyInfo.Clients.FirstOrDefault(c => c.Index == orderManager.Connection.LocalClientId); } } + static Dictionary RemapKeys = new Dictionary + { + { '!', '1' }, + { '@', '2' }, + { '#', '3' }, + { '$', '4' }, + { '%', '5' }, + { '^', '6' }, + { '&', '7' }, + { '*', '8' }, + { '(', '9' }, + { ')', '0' }, + }; + public static void HandleKeyPress( KeyPressEventArgs e, Modifiers modifiers ) { int sync = Game.world.SyncHash(); if( e.KeyChar == '\r' ) Game.chat.Toggle(); - else if( Game.chat.isChatting ) - Game.chat.TypeChar( e.KeyChar ); + else if (Game.chat.isChatting) + Game.chat.TypeChar(e.KeyChar); else - if( e.KeyChar >= '0' && e.KeyChar <= '9' ) - Game.controller.selection.DoControlGroup( world, - e.KeyChar - '0', modifiers ); + { + var c = RemapKeys.ContainsKey(e.KeyChar) ? RemapKeys[e.KeyChar] : e.KeyChar; + + if (c >= '0' && c <= '9') + Game.controller.selection.DoControlGroup(world, + c - '0', modifiers); + } if( sync != Game.world.SyncHash() ) throw new InvalidOperationException( "Desync in OnKeyPress" );