keybind signal support, ported from TGMC (#52219)

* keybind signal support, ported from TGMC

* Thank you linter

* remove unused and extra defines

* move signal defines up and fix emote keybind runtimes

* Apply suggestions

* Update keybinding.dm

* Missed this one in the upstream merge

* Ignore keybindings without names

* back to the OG

* Update living.dm

* Update living.dm

* got it

* trailing newline

* Update code/datums/keybinding/living.dm

Co-authored-by: Rohesie <rohesie@gmail.com>

Co-authored-by: Rohesie <rohesie@gmail.com>
This commit is contained in:
Couls
2020-07-22 16:51:52 -04:00
committed by SkyratBot
parent 41c6428ca6
commit dc5840dc4e
15 changed files with 298 additions and 6 deletions
+4 -1
View File
@@ -9,13 +9,16 @@
var/keybind_signal
/datum/keybinding/New()
if(!keybind_signal)
CRASH("Keybind [src] called unredefined down() without a keybind_signal.")
// Default keys to the master "hotkey_keys"
if(LAZYLEN(hotkey_keys) && !LAZYLEN(classic_keys))
classic_keys = hotkey_keys.Copy()
/datum/keybinding/proc/down(client/user)
return FALSE
SHOULD_CALL_PARENT(TRUE)
return SEND_SIGNAL(user.mob, keybind_signal) & COMSIG_KB_ACTIVATED
/datum/keybinding/proc/up(client/user)
return FALSE
+36
View File
@@ -10,8 +10,12 @@
name = "admin_say"
full_name = "Admin say"
description = "Talk with other admins."
keybind_signal = COMSIG_KB_ADMIN_ASAY_DOWN
/datum/keybinding/admin/admin_say/down(client/user)
. = ..()
if(.)
return
user.get_admin_say()
return TRUE
@@ -20,8 +24,12 @@
name = "admin_ghost"
full_name = "Aghost"
description = "Go ghost"
keybind_signal = COMSIG_KB_ADMIN_AGHOST_DOWN
/datum/keybinding/admin/admin_ghost/down(client/user)
. = ..()
if(.)
return
user.admin_ghost()
return TRUE
@@ -30,8 +38,12 @@
name = "player_panel_new"
full_name = "Player Panel New"
description = "Opens up the new player panel"
keybind_signal = COMSIG_KB_ADMIN_PLAYERPANELNEW_DOWN
/datum/keybinding/admin/player_panel_new/down(client/user)
. = ..()
if(.)
return
user.holder.player_panel_new()
return TRUE
@@ -40,8 +52,12 @@
name = "toggle_buildmode_self"
full_name = "Toggle Buildmode Self"
description = "Toggles buildmode"
keybind_signal = COMSIG_KB_ADMIN_TOGGLEBUILDMODE_DOWN
/datum/keybinding/admin/toggle_buildmode_self/down(client/user)
. = ..()
if(.)
return
user.togglebuildmodeself()
return TRUE
@@ -50,8 +66,12 @@
name = "stealth_mode"
full_name = "Stealth mode"
description = "Enters stealth mode"
keybind_signal = COMSIG_KB_ADMIN_STEALTHMODETOGGLE_DOWN
/datum/keybinding/admin/stealthmode/down(client/user)
. = ..()
if(.)
return
user.stealth()
return TRUE
@@ -60,8 +80,12 @@
name = "invisimin"
full_name = "Admin invisibility"
description = "Toggles ghost-like invisibility (Don't abuse this)"
keybind_signal = COMSIG_KB_ADMIN_INVISIMINTOGGLE_DOWN
/datum/keybinding/admin/invisimin/down(client/user)
. = ..()
if(.)
return
user.invisimin()
return TRUE
@@ -70,8 +94,12 @@
name = "dsay"
full_name = "deadsay"
description = "Allows you to send a message to dead chat"
keybind_signal = COMSIG_KB_ADMIN_DSAY_DOWN
/datum/keybinding/admin/deadsay/down(client/user)
. = ..()
if(.)
return
user.get_dead_say()
return TRUE
@@ -80,8 +108,12 @@
name = "deadmin"
full_name = "Deadmin"
description = "Shed your admin powers"
keybind_signal = COMSIG_KB_ADMIN_DEADMIN_DOWN
/datum/keybinding/admin/deadmin/down(client/user)
. = ..()
if(.)
return
user.deadmin()
return TRUE
@@ -90,7 +122,11 @@
name = "readmin"
full_name = "Readmin"
description = "Regain your admin powers"
keybind_signal = COMSIG_KB_ADMIN_READMIN_DOWN
/datum/keybinding/admin/readmin/down(client/user)
. = ..()
if(.)
return
user.readmin()
return TRUE
+24
View File
@@ -11,8 +11,12 @@
full_name = "Toggle throw mode"
description = "Toggle throwing the current item or not."
category = CATEGORY_CARBON
keybind_signal = COMSIG_KB_CARBON_TOGGLETHROWMODE_DOWN
/datum/keybinding/carbon/toggle_throw_mode/down(client/user)
. = ..()
if(.)
return
var/mob/living/carbon/C = user.mob
C.toggle_throw_mode()
return TRUE
@@ -24,8 +28,12 @@
full_name = "Select help intent"
description = ""
category = CATEGORY_CARBON
keybind_signal = COMSIG_KB_CARBON_SELECTHELPINTENT_DOWN
/datum/keybinding/carbon/select_help_intent/down(client/user)
. = ..()
if(.)
return
user.mob?.a_intent_change(INTENT_HELP)
return TRUE
@@ -36,8 +44,12 @@
full_name = "Select disarm intent"
description = ""
category = CATEGORY_CARBON
keybind_signal = COMSIG_KB_CARBON_SELECTDISARMINTENT_DOWN
/datum/keybinding/carbon/select_disarm_intent/down(client/user)
. = ..()
if(.)
return
user.mob?.a_intent_change(INTENT_DISARM)
return TRUE
@@ -48,8 +60,12 @@
full_name = "Select grab intent"
description = ""
category = CATEGORY_CARBON
keybind_signal = COMSIG_KB_CARBON_SELECTGRABINTENT_DOWN
/datum/keybinding/carbon/select_grab_intent/down(client/user)
. = ..()
if(.)
return
user.mob?.a_intent_change(INTENT_GRAB)
return TRUE
@@ -60,8 +76,12 @@
full_name = "Select harm intent"
description = ""
category = CATEGORY_CARBON
keybind_signal = COMSIG_KB_CARBON_SELECTHARMINTENT_DOWN
/datum/keybinding/carbon/select_harm_intent/down(client/user)
. = ..()
if(.)
return
user.mob?.a_intent_change(INTENT_HARM)
return TRUE
@@ -70,8 +90,12 @@
name = "Give_Item"
full_name = "Give item"
description = "Give the item you're currently holding"
keybind_signal = COMSIG_KB_CARBON_GIVEITEM_DOWN
/datum/keybinding/carbon/give/down(client/user)
. = ..()
if(.)
return
var/mob/living/carbon/C = user.mob
C.give()
return TRUE
+13 -1
View File
@@ -8,8 +8,12 @@
name = "admin_help"
full_name = "Admin Help"
description = "Ask an admin for help."
keybind_signal = COMSIG_KB_CLIENT_GETHELP_DOWN
/datum/keybinding/client/admin_help/down(client/user)
. = ..()
if(.)
return
user.get_adminhelp()
return TRUE
@@ -19,8 +23,12 @@
name = "screenshot"
full_name = "Screenshot"
description = "Take a screenshot."
keybind_signal = COMSIG_KB_CLIENT_SCREENSHOT_DOWN
/datum/keybinding/client/screenshot/down(client/user)
. = ..()
if(.)
return
winset(user, null, "command=.screenshot [!user.keys_held["shift"] ? "auto" : ""]")
return TRUE
@@ -29,7 +37,11 @@
name = "minimal_hud"
full_name = "Minimal HUD"
description = "Hide most HUD features"
keybind_signal = COMSIG_KB_CLIENT_MINIMALHUD_DOWN
/datum/keybinding/client/minimal_hud/down(client/user)
. = ..()
if(.)
return
user.mob.button_pressed_F12()
return TRUE
return TRUE
+3
View File
@@ -1,6 +1,7 @@
/datum/keybinding/emote
category = CATEGORY_EMOTE
weight = WEIGHT_EMOTE
keybind_signal = COMSIG_KB_EMOTE
var/emote_key
/datum/keybinding/emote/proc/link_to_emote(datum/emote/faketype)
@@ -12,4 +13,6 @@
/datum/keybinding/emote/down(client/user)
. = ..()
if(.)
return
return user.mob.emote(emote_key, intentional=TRUE)
+14
View File
@@ -10,8 +10,12 @@
name = "quick_equip"
full_name = "Quick equip"
description = "Quickly puts an item in the best slot available"
keybind_signal = COMSIG_KB_HUMAN_QUICKEQUIP_DOWN
/datum/keybinding/human/quick_equip/down(client/user)
. = ..()
if(.)
return
var/mob/living/carbon/human/H = user.mob
H.quick_equip()
return TRUE
@@ -25,8 +29,12 @@
var/slot_type = ITEM_SLOT_BELT
///what we should call slot_type in messages (including failure messages)
var/slot_item_name = "belt"
keybind_signal = COMSIG_KB_HUMAN_QUICKEQUIPBELT_DOWN
/datum/keybinding/human/quick_equip_belt/down(client/user)
. = ..()
if(.)
return
var/mob/living/carbon/human/H = user.mob
H.smart_equip_targeted(slot_type, slot_item_name)
return TRUE
@@ -38,6 +46,7 @@
description = "Put held thing in backpack or take out most recent thing from backpack"
slot_type = ITEM_SLOT_BACK
slot_item_name = "backpack"
keybind_signal = COMSIG_KB_HUMAN_BAGEQUIP_DOWN
/datum/keybinding/human/quick_equip_belt/quick_equip_suit_storage
hotkey_keys = list("ShiftQ")
@@ -46,14 +55,19 @@
description = "Put held thing in suit storage slot item or take out most recent thing from suit storage slot item"
slot_type = ITEM_SLOT_SUITSTORE
slot_item_name = "suit storage slot item"
keybind_signal = COMSIG_KB_HUMAN_SUITEQUIP_DOWN
/datum/keybinding/human/equipment_swap
hotkey_keys = list("V")
name = "equipment_swap"
full_name = "Equipment Swap"
description = "Equip the currently held item by swapping it out with the already equipped item after a small delay"
keybind_signal = COMSIG_KB_HUMAN_EQUIPMENTSWAP_DOWN
/datum/keybinding/human/equipment_swap/down(client/user)
. = ..()
if(.)
return
var/mob/living/carbon/human/H = user.mob
H.equipment_swap()
return TRUE
+12
View File
@@ -10,8 +10,12 @@
name = "resist"
full_name = "Resist"
description = "Break free of your current state. Handcuffed? on fire? Resist!"
keybind_signal = COMSIG_KB_LIVING_RESIST_DOWN
/datum/keybinding/living/resist/down(client/user)
. = ..()
if(.)
return
var/mob/living/L = user.mob
L.resist()
return TRUE
@@ -21,8 +25,12 @@
name = "look up"
full_name = "Look Up"
description = "Look up at the next z-level. Only works if directly below open space."
keybind_signal = COMSIG_KB_LIVING_LOOKUP_DOWN
/datum/keybinding/living/look_up/down(client/user)
. = ..()
if(.)
return
var/mob/living/L = user.mob
L.look_up()
return TRUE
@@ -37,8 +45,12 @@
name = "look down"
full_name = "Look Down"
description = "Look down at the previous z-level. Only works if directly above open space."
keybind_signal = COMSIG_KB_LIVING_LOOKDOWN_DOWN
/datum/keybinding/living/look_down/down(client/user)
. = ..()
if(.)
return
var/mob/living/L = user.mob
L.look_down()
return TRUE
+77 -1
View File
@@ -8,8 +8,12 @@
name = "face_north"
full_name = "Face North"
description = ""
keybind_signal = COMSIG_KB_MOB_FACENORTH_DOWN
/datum/keybinding/mob/face_north/down(client/user)
. = ..()
if(.)
return
var/mob/M = user.mob
M.northface()
return TRUE
@@ -20,8 +24,12 @@
name = "face_east"
full_name = "Face East"
description = ""
keybind_signal = COMSIG_KB_MOB_FACEEAST_DOWN
/datum/keybinding/mob/face_east/down(client/user)
. = ..()
if(.)
return
var/mob/M = user.mob
M.eastface()
return TRUE
@@ -32,8 +40,12 @@
name = "face_south"
full_name = "Face South"
description = ""
keybind_signal = COMSIG_KB_MOB_FACESOUTH_DOWN
/datum/keybinding/mob/face_south/down(client/user)
. = ..()
if(.)
return
var/mob/M = user.mob
M.southface()
return TRUE
@@ -43,8 +55,12 @@
name = "face_west"
full_name = "Face West"
description = ""
keybind_signal = COMSIG_KB_MOB_FACEWEST_DOWN
/datum/keybinding/mob/face_west/down(client/user)
. = ..()
if(.)
return
var/mob/M = user.mob
M.westface()
return TRUE
@@ -54,8 +70,12 @@
name = "stop_pulling"
full_name = "Stop pulling"
description = ""
keybind_signal = COMSIG_KB_MOB_STOPPULLING_DOWN
/datum/keybinding/mob/stop_pulling/down(client/user)
. = ..()
if(.)
return
var/mob/M = user.mob
if(!M.pulling)
to_chat(user, "<span class='notice'>You are not pulling anything.</span>")
@@ -68,8 +88,12 @@
name = "cycle_intent_right"
full_name = "cycle intent right"
description = ""
keybind_signal = COMSIG_KB_MOB_CYCLEINTENTRIGHT_DOWN
/datum/keybinding/mob/cycle_intent_right/down(client/user)
. = ..()
if(.)
return
var/mob/M = user.mob
M.a_intent_change(INTENT_HOTKEY_RIGHT)
return TRUE
@@ -79,8 +103,12 @@
name = "cycle_intent_left"
full_name = "cycle intent left"
description = ""
keybind_signal = COMSIG_KB_MOB_CYCLEINTENTLEFT_DOWN
/datum/keybinding/mob/cycle_intent_left/down(client/user)
. = ..()
if(.)
return
var/mob/M = user.mob
M.a_intent_change(INTENT_HOTKEY_LEFT)
return TRUE
@@ -90,19 +118,27 @@
name = "swap_hands"
full_name = "Swap hands"
description = ""
keybind_signal = COMSIG_KB_MOB_SWAPHANDS_DOWN
/datum/keybinding/mob/swap_hands/down(client/user)
. = ..()
if(.)
return
var/mob/M = user.mob
M.swap_hand()
return TRUE
/datum/keybinding/mob/activate_inhand
hotkey_keys = list("Z", "Southeast") // PAGEDOWN
hotkey_keys = list("Z", "Southeast") // Southeast = PAGEDOWN
name = "activate_inhand"
full_name = "Activate in-hand"
description = "Uses whatever item you have inhand"
keybind_signal = COMSIG_KB_MOB_ACTIVATEINHAND_DOWN
/datum/keybinding/mob/activate_inhand/down(client/user)
. = ..()
if(.)
return
var/mob/M = user.mob
M.mode()
return TRUE
@@ -112,8 +148,12 @@
name = "drop_item"
full_name = "Drop Item"
description = ""
keybind_signal = COMSIG_KB_MOB_DROPITEM_DOWN
/datum/keybinding/mob/drop_item/down(client/user)
. = ..()
if(.)
return
if(iscyborg(user.mob)) //cyborgs can't drop items
return FALSE
var/mob/M = user.mob
@@ -129,8 +169,12 @@
name = "toggle_move_intent"
full_name = "Hold to toggle move intent"
description = "Held down to cycle to the other move intent, release to cycle back"
keybind_signal = COMSIG_KB_MOB_TOGGLEMOVEINTENT_DOWN
/datum/keybinding/mob/toggle_move_intent/down(client/user)
. = ..()
if(.)
return
var/mob/M = user.mob
M.toggle_move_intent()
return TRUE
@@ -145,8 +189,12 @@
name = "toggle_move_intent_alt"
full_name = "press to cycle move intent"
description = "Pressing this cycle to the opposite move intent, does not cycle back"
keybind_signal = COMSIG_KB_MOB_TOGGLEMOVEINTENTALT_DOWN
/datum/keybinding/mob/toggle_move_intent_alternative/down(client/user)
. = ..()
if(.)
return
var/mob/M = user.mob
M.toggle_move_intent()
return TRUE
@@ -156,8 +204,12 @@
name = "target_head_cycle"
full_name = "Target: Cycle head"
description = ""
keybind_signal = COMSIG_KB_MOB_TARGETCYCLEHEAD_DOWN
/datum/keybinding/mob/target_head_cycle/down(client/user)
. = ..()
if(.)
return
user.body_toggle_head()
return TRUE
@@ -166,8 +218,12 @@
name = "target_r_arm"
full_name = "Target: right arm"
description = ""
keybind_signal = COMSIG_KB_MOB_TARGETRIGHTARM_DOWN
/datum/keybinding/mob/target_r_arm/down(client/user)
. = ..()
if(.)
return
user.body_r_arm()
return TRUE
@@ -176,8 +232,12 @@
name = "target_body_chest"
full_name = "Target: Body"
description = ""
keybind_signal = COMSIG_KB_MOB_TARGETBODYCHEST_DOWN
/datum/keybinding/mob/target_body_chest/down(client/user)
. = ..()
if(.)
return
user.body_chest()
return TRUE
@@ -186,8 +246,12 @@
name = "target_left_arm"
full_name = "Target: left arm"
description = ""
keybind_signal = COMSIG_KB_MOB_TARGETLEFTARM_DOWN
/datum/keybinding/mob/target_left_arm/down(client/user)
. = ..()
if(.)
return
user.body_l_arm()
return TRUE
@@ -196,8 +260,12 @@
name = "target_right_leg"
full_name = "Target: Right leg"
description = ""
keybind_signal = COMSIG_KB_MOB_TARGETRIGHTLEG_DOWN
/datum/keybinding/mob/target_right_leg/down(client/user)
. = ..()
if(.)
return
user.body_r_leg()
return TRUE
@@ -206,8 +274,12 @@
name = "target_body_groin"
full_name = "Target: Groin"
description = ""
keybind_signal = COMSIG_KB_MOB_TARGETBODYGROIN_DOWN
/datum/keybinding/mob/target_body_groin/down(client/user)
. = ..()
if(.)
return
user.body_groin()
return TRUE
@@ -216,7 +288,11 @@
name = "target_left_leg"
full_name = "Target: left leg"
description = ""
keybind_signal = COMSIG_KB_MOB_TARGETLEFTLEG_DOWN
/datum/keybinding/mob/target_left_leg/down(client/user)
. = ..()
if(.)
return
user.body_l_leg()
return TRUE
+4
View File
@@ -7,21 +7,25 @@
name = "North"
full_name = "Move North"
description = "Moves your character north"
keybind_signal = COMSIG_KB_MOVEMENT_NORTH_DOWN
/datum/keybinding/movement/south
hotkey_keys = list("S", "South")
name = "South"
full_name = "Move South"
description = "Moves your character south"
keybind_signal = COMSIG_KB_MOVEMENT_SOUTH_DOWN
/datum/keybinding/movement/west
hotkey_keys = list("A", "West")
name = "West"
full_name = "Move West"
description = "Moves your character left"
keybind_signal = COMSIG_KB_MOVEMENT_WEST_DOWN
/datum/keybinding/movement/east
hotkey_keys = list("D", "East")
name = "East"
full_name = "Move East"
description = "Moves your character east"
keybind_signal = COMSIG_KB_MOVEMENT_EAST_DOWN
+20
View File
@@ -10,8 +10,12 @@
name = "module_one"
full_name = "Toggle module 1"
description = "Equips or unequips the first module"
keybind_signal = COMSIG_KB_SILICON_TOGGLEMODULEONE_DOWN
/datum/keybinding/robot/moduleone/down(client/user)
. = ..()
if(.)
return
var/mob/living/silicon/robot/R = user.mob
R.toggle_module(1)
return TRUE
@@ -21,8 +25,12 @@
name = "module_two"
full_name = "Toggle module 2"
description = "Equips or unequips the second module"
keybind_signal = COMSIG_KB_SILICON_TOGGLEMODULETWO_DOWN
/datum/keybinding/robot/moduletwo/down(client/user)
. = ..()
if(.)
return
var/mob/living/silicon/robot/R = user.mob
R.toggle_module(2)
return TRUE
@@ -32,8 +40,12 @@
name = "module_three"
full_name = "Toggle module 3"
description = "Equips or unequips the third module"
keybind_signal = COMSIG_KB_SILICON_TOGGLEMODULETHREE_DOWN
/datum/keybinding/robot/modulethree/down(client/user)
. = ..()
if(.)
return
var/mob/living/silicon/robot/R = user.mob
R.toggle_module(3)
return TRUE
@@ -43,8 +55,12 @@
name = "cycle_intent"
full_name = "Cycle intent left"
description = "Cycles the intent left"
keybind_signal = COMSIG_KB_SILICON_CYCLEINTENT_DOWN
/datum/keybinding/robot/intent_cycle/down(client/user)
. = ..()
if(.)
return
var/mob/living/silicon/robot/R = user.mob
R.a_intent_change(INTENT_HOTKEY_LEFT)
return TRUE
@@ -54,8 +70,12 @@
name = "unequip_module"
full_name = "Unequip module"
description = "Unequips the active module"
keybind_signal = COMSIG_KB_SILICON_UNEQUIPMODULE_DOWN
/datum/keybinding/robot/unequip_module/down(client/user)
. = ..()
if(.)
return
var/mob/living/silicon/robot/R = user.mob
R.uneq_active()
return TRUE