ports TGMCs click hack for non-hotkey players ports classic keybinds from TGMC (#47670)

About The Pull Request

Ports tgstation/TerraGov-Marine-Corps#2977, overrides click proc to return focus back to chat bar using winsets also ports tgstation/TerraGov-Marine-Corps#1904 which has two sets of defaults for hotkey and classic mode
fixes #47672 fixes #47659

much credit to @Rohesie and the TGMC team for a bunch of these improvements
Why It's Good For The Game

lets the non-hotkey players walk and talk again
Changelog

cl
add: Custom keybinds will now check what style (classic / hotkey) you prefer when resetting if you use classic mode make sure to reset your keybinds to default!
add: multiple keybind support
tweak: non-hotkey mode keeps focus on chat
fix: pressing 4 as cyborg now properly cycles
fix: AI location hotkeys now work again
/cl
This commit is contained in:
Couls
2019-11-14 09:22:33 +13:00
committed by oranges
parent 3d7d69d1a6
commit 26a61a489c
20 changed files with 277 additions and 339 deletions
+16 -8
View File
@@ -35,6 +35,11 @@
message_admins("Client [ckey] just attempted to send an invalid keypress. Keymessage was over [MAX_KEYPRESS_COMMANDLENGTH] characters, autokicking due to likely abuse.")
QDEL_IN(src, 1)
return
//Focus Chat failsafe. Overrides movement checks to prevent WASD.
if(!prefs.hotkeys && length(_key) == 1 && _key != "Alt" && _key != "Ctrl" && _key != "Shift")
winset(src, null, "input.focus=true ; input.text=[url_encode(_key)]")
return
//offset by 1 because the buffer address is 0 indexed because the math was simpler
keys_held[current_key_address + 1] = _key
@@ -47,12 +52,15 @@
// Client-level keybindings are ones anyone should be able to do at any time
// Things like taking screenshots, hitting tab, and adminhelps.
var/AltMod = keys_held["Alt"] ? "Alt-" : ""
var/CtrlMod = keys_held["Ctrl"] ? "Ctrl-" : ""
var/ShiftMod = keys_held["Shift"] ? "Shift-" : ""
var/full_key = "[AltMod][CtrlMod][ShiftMod][_key]"
if(_key == "Alt" || _key == "Ctrl" || _key == "Shift") // only add modifiers if the key is not a modifier already
full_key = _key
var/AltMod = keys_held["Alt"] ? "Alt" : ""
var/CtrlMod = keys_held["Ctrl"] ? "Ctrl" : ""
var/ShiftMod = keys_held["Shift"] ? "Shift" : ""
var/full_key
switch(_key)
if("Alt", "Ctrl", "Shift")
full_key = "[AltMod][CtrlMod][ShiftMod]"
else
full_key = "[AltMod][CtrlMod][ShiftMod][_key]"
var/keycount = 0
for(var/kb_name in prefs.key_bindings[full_key])
keycount++
@@ -60,8 +68,8 @@
if(kb.down(src) && keycount >= MAX_COMMANDS_PER_KEY)
break
holder?.key_down(full_key, src)
mob.focus?.key_down(full_key, src)
holder?.key_down(_key, src)
mob.focus?.key_down(_key, src)
/client/verb/keyUp(_key as text)
set instant = TRUE
@@ -1,7 +0,0 @@
/mob/living/key_down(_key, client/user)
switch(_key)
if("B")
resist()
return
return ..()