Remove VirtKey and KeyName.
This commit is contained in:
@@ -91,7 +91,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public override bool HandleKeyPress(KeyInput e)
|
||||
{
|
||||
if (e.KeyName != Key || e.Event != KeyInputEvent.Down)
|
||||
if (KeycodeExts.DisplayString(e.Key) != Key || e.Event != KeyInputEvent.Down)
|
||||
return false;
|
||||
|
||||
if (!IsDisabled())
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
if (e.Event == KeyInputEvent.Up) return false;
|
||||
|
||||
if (e.KeyName == "return" || e.KeyName == "enter" )
|
||||
if (e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER)
|
||||
{
|
||||
if (composing)
|
||||
{
|
||||
@@ -79,14 +79,14 @@ namespace OpenRA.Widgets
|
||||
|
||||
if (composing)
|
||||
{
|
||||
if (e.KeyName == "escape")
|
||||
if (e.Key == Keycode.ESCAPE)
|
||||
{
|
||||
composing = false;
|
||||
content = "";
|
||||
YieldKeyboardFocus();
|
||||
return true;
|
||||
}
|
||||
else if (e.KeyName == "backspace")
|
||||
else if (e.Key == Keycode.BACKSPACE)
|
||||
{
|
||||
if (content.Length > 0)
|
||||
content = content.Remove(content.Length - 1);
|
||||
|
||||
@@ -110,16 +110,16 @@ namespace OpenRA.Widgets
|
||||
if (!HasKeyboardFocus)
|
||||
return false;
|
||||
|
||||
if ((e.KeyName == "return" || e.KeyName == "enter") && OnEnterKey())
|
||||
if ((e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER) && OnEnterKey())
|
||||
return true;
|
||||
|
||||
if (e.KeyName == "tab" && OnTabKey())
|
||||
if (e.Key == Keycode.TAB && OnTabKey())
|
||||
return true;
|
||||
|
||||
if (e.KeyName == "escape" && OnEscKey())
|
||||
if (e.Key == Keycode.ESCAPE && OnEscKey())
|
||||
return true;
|
||||
|
||||
if (e.KeyName == "left")
|
||||
if (e.Key == Keycode.LEFT)
|
||||
{
|
||||
if (CursorPosition > 0)
|
||||
CursorPosition--;
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.KeyName == "right")
|
||||
if (e.Key == Keycode.RIGHT)
|
||||
{
|
||||
if (CursorPosition <= Text.Length-1)
|
||||
CursorPosition++;
|
||||
@@ -135,19 +135,19 @@ namespace OpenRA.Widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.KeyName == "home")
|
||||
if (e.Key == Keycode.HOME)
|
||||
{
|
||||
CursorPosition = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.KeyName == "end")
|
||||
if (e.Key == Keycode.END)
|
||||
{
|
||||
CursorPosition = Text.Length;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.KeyName == "delete")
|
||||
if (e.Key == Keycode.DELETE)
|
||||
{
|
||||
if (CursorPosition < Text.Length)
|
||||
Text = Text.Remove(CursorPosition, 1);
|
||||
@@ -160,7 +160,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
public void TypeChar(KeyInput key)
|
||||
{
|
||||
if (key.KeyName == "backspace" && CursorPosition > 0)
|
||||
if (key.Key == Keycode.BACKSPACE && CursorPosition > 0)
|
||||
{
|
||||
CursorPosition--;
|
||||
Text = Text.Remove(CursorPosition, 1);
|
||||
|
||||
@@ -167,12 +167,12 @@ namespace OpenRA.Widgets
|
||||
|
||||
public override bool HandleKeyPress(KeyInput e)
|
||||
{
|
||||
switch (e.KeyName)
|
||||
switch (e.Key)
|
||||
{
|
||||
case "up": keyboardDirections = keyboardDirections.Set(ScrollDirection.Up, e.Event == KeyInputEvent.Down); return true;
|
||||
case "down": keyboardDirections = keyboardDirections.Set(ScrollDirection.Down, e.Event == KeyInputEvent.Down); return true;
|
||||
case "left": keyboardDirections = keyboardDirections.Set(ScrollDirection.Left, e.Event == KeyInputEvent.Down); return true;
|
||||
case "right": keyboardDirections = keyboardDirections.Set(ScrollDirection.Right, e.Event == KeyInputEvent.Down); return true;
|
||||
case Keycode.UP: keyboardDirections = keyboardDirections.Set(ScrollDirection.Up, e.Event == KeyInputEvent.Down); return true;
|
||||
case Keycode.DOWN: keyboardDirections = keyboardDirections.Set(ScrollDirection.Down, e.Event == KeyInputEvent.Down); return true;
|
||||
case Keycode.LEFT: keyboardDirections = keyboardDirections.Set(ScrollDirection.Left, e.Event == KeyInputEvent.Down); return true;
|
||||
case Keycode.RIGHT: keyboardDirections = keyboardDirections.Set(ScrollDirection.Right, e.Event == KeyInputEvent.Down); return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
if (e.Event == KeyInputEvent.Down)
|
||||
{
|
||||
if (e.KeyName == "escape")
|
||||
if (e.Key == Keycode.ESCAPE)
|
||||
{
|
||||
Stop();
|
||||
return true;
|
||||
|
||||
@@ -169,14 +169,15 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
if (e.Event == KeyInputEvent.Down)
|
||||
{
|
||||
if (e.KeyName.Length == 1 && char.IsDigit(e.KeyName[0]))
|
||||
if (e.Key >= Keycode.NUMBER_0 && e.Key <= Keycode.NUMBER_9)
|
||||
{
|
||||
world.Selection.DoControlGroup(world, worldRenderer, e.KeyName[0] - '0', e.Modifiers, e.MultiTapCount);
|
||||
var group = (int)e.Key - (int)Keycode.NUMBER_0;
|
||||
world.Selection.DoControlGroup(world, worldRenderer, group, e.Modifiers, e.MultiTapCount);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Disable pausing for spectators
|
||||
else if (e.KeyName == Game.Settings.Keys.PauseKey && world.LocalPlayer != null)
|
||||
else if (KeycodeExts.DisplayString(e.Key) == Game.Settings.Keys.PauseKey && world.LocalPlayer != null)
|
||||
world.SetPauseState(!world.Paused);
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user