Fix bogus handling of special keyboard characters everywhere else. Textfields now only accept valid characters, support right-delete.

This commit is contained in:
Paul Chote
2011-03-18 10:48:12 +13:00
parent 7d6d488176
commit eb69b697b1
9 changed files with 47 additions and 41 deletions

View File

@@ -154,7 +154,7 @@ namespace OpenRA.Mods.RA.Widgets
return true;
}
return DoBuildingHotkey(Char.ToLowerInvariant(e.KeyChar), world);
return DoBuildingHotkey(e.KeyName, world);
}
// TODO: BuildPaletteWidget doesn't support delegate methods for mouse input
@@ -499,12 +499,12 @@ namespace OpenRA.Mods.RA.Widgets
p.ToInt2(), Color.White);
}
bool DoBuildingHotkey(char c, World world)
bool DoBuildingHotkey(string key, World world)
{
if (!paletteOpen) return false;
if (CurrentQueue == null) return false;
var toBuild = CurrentQueue.BuildableItems().FirstOrDefault(b => b.Traits.Get<BuildableInfo>().Hotkey == c.ToString());
var toBuild = CurrentQueue.BuildableItems().FirstOrDefault(b => b.Traits.Get<BuildableInfo>().Hotkey == key);
if ( toBuild != null )
{

View File

@@ -12,10 +12,11 @@ namespace OpenRA.Mods.RA.Widgets
{
public World World { get { return OrderManager.world; } }
public char AttackMoveKey = 'a';
public char StopKey = 's';
public char ScatterKey = 'x';
public char DeployKey = 'f';
public string AttackMoveKey = "a";
public string StopKey = "s";
public string ScatterKey = "x";
public string DeployKey = "f";
public string BaseCycleKey = "backspace";
public readonly OrderManager OrderManager;
[ObjectCreator.UseCtor]
@@ -40,22 +41,22 @@ namespace OpenRA.Mods.RA.Widgets
{
if (e.Modifiers == Modifiers.None)
{
if (e.KeyChar == '\b' || e.KeyChar == (char)127)
if (e.KeyName == BaseCycleKey)
return CycleBases();
if (!World.Selection.Actors.Any())
return false;
if (e.KeyChar == AttackMoveKey)
if (e.KeyName == AttackMoveKey)
return PerformAttackMove();
if (e.KeyChar == StopKey)
if (e.KeyName == StopKey)
return PerformStop();
if (e.KeyChar == ScatterKey)
if (e.KeyName == ScatterKey)
return PerformScatter();
if (e.KeyChar == DeployKey)
if (e.KeyName == DeployKey)
return PerformDeploy();
}