diff --git a/code/__DEFINES/keybinding.dm b/code/__DEFINES/keybinding.dm new file mode 100644 index 00000000000..3259514bc22 --- /dev/null +++ b/code/__DEFINES/keybinding.dm @@ -0,0 +1,80 @@ +//Signals + +//General +#define COMSIG_KB_ACTIVATED (1<<0) +#define COMSIG_KB_EMOTE "keybinding_emote_down" + +//Admin +#define COMSIG_KB_ADMIN_ASAY_DOWN "keybinding_admin_asay_down" +#define COMSIG_KB_ADMIN_DSAY_DOWN "keybinding_admin_dsay_down" +#define COMSIG_KB_ADMIN_TOGGLEBUILDMODE_DOWN "keybinding_admin_togglebuildmode_down" +#define COMSIG_KB_ADMIN_AGHOST_DOWN "keybinding_admin_aghost_down" +#define COMSIG_KB_ADMIN_PLAYERPANELNEW_DOWN "keybinding_admin_playerpanelnew_down" +#define COMSIG_KB_ADMIN_STEALTHMODETOGGLE_DOWN "keybinding_admin_stealthmodetoggle_down" +#define COMSIG_KB_ADMIN_INVISIMINTOGGLE_DOWN "keybinding_admin_invisimintoggle_down" +#define COMSIG_KB_ADMIN_DEADMIN_DOWN "keybinding_admin_deadmin_down" +#define COMSIG_KB_ADMIN_READMIN_DOWN "keybinding_admin_readmin_down" + +//Carbon +#define COMSIG_KB_CARBON_HOLDRUNMOVEINTENT_DOWN "keybinding_carbon_holdrunmoveintent_down" +#define COMSIG_KB_CARBON_HOLDRUNMOVEINTENT_UP "keybinding_carbon_holdrunmoveintent_up" +#define COMSIG_KB_CARBON_TOGGLETHROWMODE_DOWN "keybinding_carbon_togglethrowmode_down" +#define COMSIG_KB_CARBON_SELECTHELPINTENT_DOWN "keybinding_carbon_selecthelpintent_down" +#define COMSIG_KB_CARBON_SELECTDISARMINTENT_DOWN "keybinding_carbon_selectdisarmintent_down" +#define COMSIG_KB_CARBON_SELECTGRABINTENT_DOWN "keybinding_carbon_selectgrabintent_down" +#define COMSIG_KB_CARBON_SELECTHARMINTENT_DOWN "keybinding_carbon_selectharmintent_down" +#define COMSIG_KB_CARBON_GIVEITEM_DOWN "keybinding_carbon_giveitem_down" + +//Client +#define COMSIG_KB_CLIENT_GETHELP_DOWN "keybinding_client_gethelp_down" +#define COMSIG_KB_CLIENT_SCREENSHOT_DOWN "keybinding_client_screenshot_down" +#define COMSIG_KB_CLIENT_MINIMALHUD_DOWN "keybinding_client_minimalhud_down" +#define COMSIG_KB_CLIENT_OOC_DOWN "keybinding_client_ooc_down" +#define COMSIG_KB_CLIENT_LOOC_DOWN "keybinding_client_looc_down" + +//Human +#define COMSIG_KB_HUMAN_QUICKEQUIP_DOWN "keybinding_human_quickequip_down" +#define COMSIG_KB_HUMAN_QUICKEQUIPBELT_DOWN "keybinding_human_quickequipbelt_down" +#define COMSIG_KB_HUMAN_BAGEQUIP_DOWN "keybinding_human_bagequip_down" +#define COMSIG_KB_HUMAN_EQUIPMENTSWAP_DOWN "keybinding_human_equipmentswap_down" +#define COMSIG_KB_HUMAN_SUITEQUIP_DOWN "keybinding_human_suitequip_down" + +//Living +#define COMSIG_KB_LIVING_RESIST_DOWN "keybinding_living_resist_down" +#define COMSIG_KB_LIVING_LOOKUP_DOWN "keybinding_living_lookup_down" +#define COMSIG_KB_LIVING_LOOKDOWN_DOWN "keybinding_living_lookdown_down" + +//Mob +#define COMSIG_KB_MOB_FACENORTH_DOWN "keybinding_mob_facenorth_down" +#define COMSIG_KB_MOB_FACEEAST_DOWN "keybinding_mob_faceeast_down" +#define COMSIG_KB_MOB_FACESOUTH_DOWN "keybinding_mob_facesouth_down" +#define COMSIG_KB_MOB_FACEWEST_DOWN "keybinding_mob_facewest_down" +#define COMSIG_KB_MOB_STOPPULLING_DOWN "keybinding_mob_stoppulling_down" +#define COMSIG_KB_MOB_CYCLEINTENTRIGHT_DOWN "keybinding_mob_cycleintentright_down" +#define COMSIG_KB_MOB_CYCLEINTENTLEFT_DOWN "keybinding_mob_cycleintentleft_down" +#define COMSIG_KB_MOB_SWAPHANDS_DOWN "keybinding_mob_swaphands_down" +#define COMSIG_KB_MOB_ACTIVATEINHAND_DOWN "keybinding_mob_activateinhand_down" +#define COMSIG_KB_MOB_DROPITEM_DOWN "keybinding_mob_dropitem_down" +#define COMSIG_KB_MOB_TOGGLEMOVEINTENT_DOWN "keybinding_mob_togglemoveintent_down" +#define COMSIG_KB_MOB_TOGGLEMOVEINTENTALT_DOWN "keybinding_mob_togglemoveintentalt_down" +#define COMSIG_KB_MOB_TARGETCYCLEHEAD_DOWN "keybinding_mob_targetcyclehead_down" +#define COMSIG_KB_MOB_TARGETRIGHTARM_DOWN "keybinding_mob_targetrightarm_down" +#define COMSIG_KB_MOB_TARGETBODYCHEST_DOWN "keybinding_mob_targetbodychest_down" +#define COMSIG_KB_MOB_TARGETLEFTARM_DOWN "keybinding_mob_targetleftarm_down" +#define COMSIG_KB_MOB_TARGETRIGHTLEG_DOWN "keybinding_mob_targetrightleg_down" +#define COMSIG_KB_MOB_TARGETBODYGROIN_DOWN "keybinding_mob_targetbodygroin_down" +#define COMSIG_KB_MOB_TARGETLEFTLEG_DOWN "keybinding_mob_targetleftleg_down" + +//Robot +#define COMSIG_KB_SILICON_TOGGLEMODULEONE_DOWN "keybinding_silicon_togglemoduleone_down" +#define COMSIG_KB_SILICON_TOGGLEMODULETWO_DOWN "keybinding_silicon_togglemoduletwo_down" +#define COMSIG_KB_SILICON_TOGGLEMODULETHREE_DOWN "keybinding_silicon_togglemodulethree_down" +#define COMSIG_KB_SILICON_CYCLEINTENT_DOWN "keybinding_silicon_cycleintent_down" +#define COMSIG_KB_SILICON_UNEQUIPMODULE_DOWN "keybinding_silicon_unequipmodule_down" + +//Movement +#define COMSIG_KB_MOVEMENT_NORTH_DOWN "keybinding_movement_north_down" +#define COMSIG_KB_MOVEMENT_SOUTH_DOWN "keybinding_movement_south_down" +#define COMSIG_KB_MOVEMENT_WEST_DOWN "keybinding_movement_west_down" +#define COMSIG_KB_MOVEMENT_EAST_DOWN "keybinding_movement_east_down" + diff --git a/code/_globalvars/lists/keybindings.dm b/code/_globalvars/lists/keybindings.dm index f760a88fbeb..8e4ce26f37b 100644 --- a/code/_globalvars/lists/keybindings.dm +++ b/code/_globalvars/lists/keybindings.dm @@ -2,7 +2,7 @@ /proc/init_keybindings() for(var/KB in subtypesof(/datum/keybinding)) var/datum/keybinding/keybinding = KB - if(!initial(keybinding.hotkey_keys)) + if(!initial(keybinding.keybind_signal) || !initial(keybinding.name)) continue add_keybinding(new keybinding) init_emote_keybinds() @@ -10,12 +10,12 @@ /// Adds an instanced keybinding to the global tracker /proc/add_keybinding(datum/keybinding/instance) GLOB.keybindings_by_name[instance.name] = instance - + // Classic if(LAZYLEN(instance.classic_keys)) for(var/bound_key in instance.classic_keys) LAZYADD(GLOB.classic_keybinding_list_by_key[bound_key], list(instance.name)) - + // Hotkey if(LAZYLEN(instance.hotkey_keys)) for(var/bound_key in instance.hotkey_keys) diff --git a/code/datums/keybinding/_keybindings.dm b/code/datums/keybinding/_keybindings.dm index 1d68e2d0373..dfcf492c180 100644 --- a/code/datums/keybinding/_keybindings.dm +++ b/code/datums/keybinding/_keybindings.dm @@ -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 diff --git a/code/datums/keybinding/admin.dm b/code/datums/keybinding/admin.dm index b63221e97a4..10d9722eaa8 100644 --- a/code/datums/keybinding/admin.dm +++ b/code/datums/keybinding/admin.dm @@ -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 diff --git a/code/datums/keybinding/carbon.dm b/code/datums/keybinding/carbon.dm index 2d9909760dc..abc3734aa1c 100644 --- a/code/datums/keybinding/carbon.dm +++ b/code/datums/keybinding/carbon.dm @@ -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 diff --git a/code/datums/keybinding/client.dm b/code/datums/keybinding/client.dm index b2ae7609cb5..e4b940c7f72 100644 --- a/code/datums/keybinding/client.dm +++ b/code/datums/keybinding/client.dm @@ -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 diff --git a/code/datums/keybinding/emote.dm b/code/datums/keybinding/emote.dm index 6099826819c..5d6e7895ed9 100644 --- a/code/datums/keybinding/emote.dm +++ b/code/datums/keybinding/emote.dm @@ -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) diff --git a/code/datums/keybinding/human.dm b/code/datums/keybinding/human.dm index 60ebff6afb6..41b698059bb 100644 --- a/code/datums/keybinding/human.dm +++ b/code/datums/keybinding/human.dm @@ -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 diff --git a/code/datums/keybinding/living.dm b/code/datums/keybinding/living.dm index d38f9c72c91..58d55ddc5cd 100644 --- a/code/datums/keybinding/living.dm +++ b/code/datums/keybinding/living.dm @@ -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 diff --git a/code/datums/keybinding/mob.dm b/code/datums/keybinding/mob.dm index f194c7fd2fe..cbb9d9cfe01 100644 --- a/code/datums/keybinding/mob.dm +++ b/code/datums/keybinding/mob.dm @@ -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, "You are not pulling anything.") @@ -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 diff --git a/code/datums/keybinding/movement.dm b/code/datums/keybinding/movement.dm index ca199b5eb4d..02d601e14fa 100644 --- a/code/datums/keybinding/movement.dm +++ b/code/datums/keybinding/movement.dm @@ -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 diff --git a/code/datums/keybinding/robot.dm b/code/datums/keybinding/robot.dm index b9f6ce83eb7..5076a5a1868 100644 --- a/code/datums/keybinding/robot.dm +++ b/code/datums/keybinding/robot.dm @@ -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 diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 5d7994f737c..8526225df1a 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -15,6 +15,7 @@ #include "card_mismatch.dm" #include "chain_pull_through_space.dm" #include "component_tests.dm" +#include "keybinding_init.dm" #include "outfit_sanity.dm" #include "plantgrowth_tests.dm" #include "reagent_id_typos.dm" diff --git a/code/modules/unit_tests/keybinding_init.dm b/code/modules/unit_tests/keybinding_init.dm new file mode 100644 index 00000000000..2bd2fdee1e2 --- /dev/null +++ b/code/modules/unit_tests/keybinding_init.dm @@ -0,0 +1,6 @@ +/datum/unit_test/keybinding_init/Run() + for(var/i in subtypesof(/datum/keybinding)) + var/datum/keybinding/KB = i + if(initial(KB.keybind_signal) || !initial(KB.name)) + continue + Fail("[KB.name] does not have a keybind signal defined.") diff --git a/tgstation.dme b/tgstation.dme index f416b29f1cf..678ef083b27 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -56,6 +56,7 @@ #include "code\__DEFINES\inventory.dm" #include "code\__DEFINES\is_helpers.dm" #include "code\__DEFINES\jobs.dm" +#include "code\__DEFINES\keybinding.dm" #include "code\__DEFINES\language.dm" #include "code\__DEFINES\layers.dm" #include "code\__DEFINES\lighting.dm"