Implement new cool features

* Implement walk booster (dash) as an option in settings menu
* Dash is smarter (can pre-animate)
* Implement smart walking (walk in diagonal when holding two arrow keys)
* Implement ping meter for all protocols
* Ping meter uses uses real ping packet for 9.6 and walk for others
This commit is contained in:
Eduardo Bart
2012-08-25 16:11:54 -03:00
parent 0763b266d5
commit 4bac36d3bc
15 changed files with 193 additions and 63 deletions

View File

@@ -15,6 +15,14 @@ function translateKeyCombo(keyCombo)
return keyComboDesc
end
local function getKeyCode(key)
for keyCode, keyDesc in pairs(KeyCodeDescs) do
if keyDesc:lower() == key:trim():lower() then
return keyCode
end
end
end
local function retranslateKeyComboDesc(keyComboDesc)
if keyComboDesc == nil then
error('Unable to translate key combo \'' .. keyComboDesc .. '\'')
@@ -140,6 +148,13 @@ function g_keyboard.getModifiers()
return g_window.getKeyboardModifiers()
end
function g_keyboard.isKeyPressed(key)
if type(key) == 'string' then
key = getKeyCode(key)
end
return g_window.isKeyPressed(key)
end
function g_keyboard.isCtrlPressed()
return bit32.band(g_window.getKeyboardModifiers(), KeyboardCtrlModifier) ~= 0
end