Rebindable Hotkeys (#12138)
* demodularize interface * keybindings * binds * prefs * loose ends * globals * changes * s * datum ref lists * ok * fixes * fixes * fix * ok * sigh * sigh * indicators * let's play the move code around game * let's play the i didn't comma my lists game * let's play the indent game * let's play hte spelling bee * let's fail the spelling bee * LET'S PLAY THe HOW HARd IS IT TO SPELL A PROC GAME * let's play the bugfix game * bugfixes * improvements * Update bindings_client.dm * pixel shift * A * wups
This commit is contained in:
@@ -33,55 +33,69 @@
|
||||
to_chat(src, "<span class='userdanger'>Invalid KeyDown detected! You have been disconnected from the server automatically.</span>")
|
||||
log_admin("Client [ckey] just attempted to send an invalid keypress. Keymessage was over [MAX_KEYPRESS_COMMANDLENGTH] characters, autokicking due to likely abuse.")
|
||||
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)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
if(_key == "Tab")
|
||||
ForceAllKeysUp() //groan, more hacky kevcode
|
||||
return
|
||||
|
||||
if(length(keys_held) > MAX_HELD_KEYS)
|
||||
keys_held.Cut(1,2)
|
||||
keys_held[_key] = TRUE
|
||||
var/movement = SSinput.movement_keys[_key]
|
||||
var/movement = movement_keys[_key]
|
||||
if(!(next_move_dir_sub & movement) && !keys_held["Ctrl"])
|
||||
next_move_dir_add |= movement
|
||||
|
||||
// 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
|
||||
switch(_key)
|
||||
if("F1")
|
||||
if(keys_held["Ctrl"] && keys_held["Shift"]) // Is this command ever used?
|
||||
winset(src, null, "command=.options")
|
||||
else
|
||||
get_adminhelp()
|
||||
return
|
||||
if("F2") // Screenshot. Hold shift to choose a name and location to save in
|
||||
winset(src, null, "command=.screenshot [!keys_held["shift"] ? "auto" : ""]")
|
||||
return
|
||||
if("F12") // Toggles minimal HUD
|
||||
mob.button_pressed_F12()
|
||||
return
|
||||
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++
|
||||
var/datum/keybinding/kb = GLOB.keybindings_by_name[kb_name]
|
||||
if(kb.can_use(src) && kb.down(src) && keycount >= MAX_COMMANDS_PER_KEY)
|
||||
break
|
||||
|
||||
if(holder)
|
||||
holder.key_down(_key, src)
|
||||
if(mob.focus)
|
||||
mob.focus.key_down(_key, src)
|
||||
holder?.key_down(_key, src)
|
||||
mob.focus?.key_down(_key, src)
|
||||
|
||||
/// Keyup's all keys held down.
|
||||
/client/proc/ForceAllKeysUp()
|
||||
// simulate a user releasing all keys except for the mod keys. groan. i hate this. thanks, byond. why aren't keyups able to be forced to fire on macro change aoaoaoao.
|
||||
// groan
|
||||
for(var/key in keys_held) // all of these won't be the 3 mod keys.
|
||||
if((key == "Ctrl") || (key == "Alt") || (key == "Shift"))
|
||||
continue
|
||||
keyUp("[key]")
|
||||
|
||||
/client/verb/keyUp(_key as text)
|
||||
set instant = TRUE
|
||||
set hidden = TRUE
|
||||
|
||||
keys_held -= _key
|
||||
var/movement = SSinput.movement_keys[_key]
|
||||
var/movement = movement_keys[_key]
|
||||
if(!(next_move_dir_add & movement))
|
||||
next_move_dir_sub |= movement
|
||||
|
||||
if(holder)
|
||||
holder.key_up(_key, src)
|
||||
if(mob.focus)
|
||||
mob.focus.key_up(_key, src)
|
||||
// We don't do full key for release, because for mod keys you
|
||||
// can hold different keys and releasing any should be handled by the key binding specifically
|
||||
for (var/kb_name in prefs.key_bindings[_key])
|
||||
var/datum/keybinding/kb = GLOB.keybindings_by_name[kb_name]
|
||||
if(kb.can_use(src) && kb.up(src))
|
||||
break
|
||||
holder?.key_up(_key, src)
|
||||
mob.focus?.key_up(_key, src)
|
||||
|
||||
// Called every game tick
|
||||
/client/keyLoop()
|
||||
if(holder)
|
||||
holder.keyLoop(src)
|
||||
if(mob.focus)
|
||||
mob.focus.keyLoop(src)
|
||||
holder?.keyLoop(src)
|
||||
mob.focus?.keyLoop(src)
|
||||
|
||||
Reference in New Issue
Block a user