Skip to content

Commit

Permalink
Using ctrl + your quick MOD button now opens module selector on your …
Browse files Browse the repository at this point in the history
…mouse position (tgstation#84879)

## About The Pull Request

Title. Ctrl + middle by default, can be ctrl + alt + LMB if changed in
prefs. Both are unused and default to ctrl/alt click behavior
respectively.

## Why It's Good For The Game
A quick way to change modules. You *can* bind your module wheel to a
hotkey but that still opens it on your sprite, making it harder to
quickly swap modules in combat/danger.
## Changelog
:cl:
qol: Using ctrl + your quick MOD button now opens module selector on
your mouse position
/:cl:
  • Loading branch information
SmArtKar authored Jul 12, 2024
1 parent 1e80a72 commit bb696fc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions code/modules/mod/mod_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,15 @@
SEND_SIGNAL(src, COMSIG_MOD_WEARER_SET, wearer)
RegisterSignal(wearer, COMSIG_ATOM_EXITED, PROC_REF(on_exit))
RegisterSignal(wearer, COMSIG_SPECIES_GAIN, PROC_REF(on_species_gain))
RegisterSignal(wearer, COMSIG_MOB_CLICKON, PROC_REF(click_on))
update_charge_alert()
for(var/obj/item/mod/module/module as anything in modules)
module.on_equip()

/obj/item/mod/control/proc/unset_wearer()
for(var/obj/item/mod/module/module as anything in modules)
module.on_unequip()
UnregisterSignal(wearer, list(COMSIG_ATOM_EXITED, COMSIG_SPECIES_GAIN))
UnregisterSignal(wearer, list(COMSIG_ATOM_EXITED, COMSIG_SPECIES_GAIN, COMSIG_MOB_CLICKON))
SEND_SIGNAL(src, COMSIG_MOD_WEARER_UNSET, wearer)
wearer.update_spacesuit_hud_icon("0")
wearer = null
Expand Down Expand Up @@ -506,7 +507,14 @@
forceMove(drop_location())
return

/obj/item/mod/control/proc/quick_module(mob/user)
/obj/item/mod/control/proc/click_on(mob/source, atom/A, list/modifiers)
SIGNAL_HANDLER

if (LAZYACCESS(modifiers, CTRL_CLICK) && LAZYACCESS(modifiers, source.client?.prefs.read_preference(/datum/preference/choiced/mod_select) || MIDDLE_CLICK))
INVOKE_ASYNC(src, PROC_REF(quick_module), source, get_turf(A))
return COMSIG_MOB_CANCEL_CLICKON

/obj/item/mod/control/proc/quick_module(mob/user, anchor_override = null)
if(!length(modules))
return
var/list/display_names = list()
Expand All @@ -528,7 +536,9 @@
var/radial_anchor = src
if(istype(user.loc, /obj/effect/dummy/phased_mob))
radial_anchor = get_turf(user.loc) //they're phased out via some module, anchor the radial on the turf so it may still display
var/pick = show_radial_menu(user, radial_anchor, items, custom_check = FALSE, require_near = TRUE, tooltips = TRUE)
if (!isnull(anchor_override))
radial_anchor = anchor_override
var/pick = show_radial_menu(user, radial_anchor, items, custom_check = FALSE, require_near = isnull(anchor_override), tooltips = TRUE)
if(!pick)
return
var/module_reference = display_names[pick]
Expand Down

0 comments on commit bb696fc

Please sign in to comment.