diff --git a/code/__DEFINES/_click.dm b/code/__DEFINES/_click.dm new file mode 100644 index 00000000000..820f71d3668 --- /dev/null +++ b/code/__DEFINES/_click.dm @@ -0,0 +1,34 @@ +//Defines file for byond click related parameters +//this is mostly for ease of use and for finding all the things that use say RIGHT_CLICK rather then just searching "right" + + +//Mouse buttons pressed/held/released +#define RIGHT_CLICK "right" +#define MIDDLE_CLICK "middle" +#define LEFT_CLICK "left" + +//Keys held down during the mouse action +#define CTRL_CLICK "ctrl" +#define ALT_CLICK "alt" +#define SHIFT_CLICK "shift" + +//Cells involved if using a Grid control +#define DRAG_CELL "drag-cell" +#define DROP_CELL "drop-cell" + +//The button used for dragging (only sent for unrelated mouse up/down messages during a drag) +#define DRAG "drag" + +//If the mouse is over a link in maptext, or this event is related to clicking such a link +#define LINK "link" + +//Pixel coordinates relative to the icon's position on screen +#define VIS_X "vis-x" +#define VIS_Y "vis-y" + +//Pixel coordinates within the icon, in the icon's coordinate space +#define ICON_X "icon-x" +#define ICON_Y "icon-y" + +//Pixel coordinates in screen_loc format ("[tile_x]:[pixel_x],[tile_y]:[pixel_y]") +#define SCREEN_LOC "screen-loc" diff --git a/code/__HELPERS/mouse_control.dm b/code/__HELPERS/mouse_control.dm index 784496ed200..8896afb3ec6 100644 --- a/code/__HELPERS/mouse_control.dm +++ b/code/__HELPERS/mouse_control.dm @@ -1,7 +1,7 @@ /proc/mouse_angle_from_client(client/client) - var/list/mouse_control = params2list(client.mouseParams) - if(mouse_control["screen-loc"] && client) - var/list/screen_loc_params = splittext(mouse_control["screen-loc"], ",") + var/list/modifiers = params2list(client.mouseParams) + if(LAZYACCESS(modifiers, SCREEN_LOC) && client) + var/list/screen_loc_params = splittext(LAZYACCESS(modifiers, SCREEN_LOC), ",") var/list/screen_loc_X = splittext(screen_loc_params[1],":") var/list/screen_loc_Y = splittext(screen_loc_params[2],":") var/x = (text2num(screen_loc_X[1]) * 32 + text2num(screen_loc_X[2]) - 32) @@ -18,20 +18,20 @@ /proc/mouse_absolute_datum_map_position_from_client(client/client) if(!isloc(client.mob.loc)) return - var/list/mouse_control = params2list(client.mouseParams) + var/list/modifiers = params2list(client.mouseParams) var/atom/A = client.eye var/turf/T = get_turf(A) var/cx = T.x var/cy = T.y var/cz = T.z - if(mouse_control["screen-loc"]) + if(LAZYACCESS(modifiers, SCREEN_LOC)) var/x = 0 var/y = 0 var/z = 0 var/p_x = 0 var/p_y = 0 //Split screen-loc up into X+Pixel_X and Y+Pixel_Y - var/list/screen_loc_params = splittext(mouse_control["screen-loc"], ",") + var/list/screen_loc_params = splittext(LAZYACCESS(modifiers, SCREEN_LOC), ",") //Split X+Pixel_X up into list(X, Pixel_X) var/list/screen_loc_X = splittext(screen_loc_params[1],":") //Split Y+Pixel_Y up into list(Y, Pixel_Y) diff --git a/code/_onclick/ai.dm b/code/_onclick/ai.dm index d7f2085ae55..2aa2899bdbd 100644 --- a/code/_onclick/ai.dm +++ b/code/_onclick/ai.dm @@ -52,19 +52,19 @@ return var/list/modifiers = params2list(params) - if(modifiers["shift"] && modifiers["ctrl"]) - CtrlShiftClickOn(A) - return - if(modifiers["shift"]) + if(LAZYACCESS(modifiers, SHIFT_CLICK)) + if(LAZYACCESS(modifiers, CTRL_CLICK)) + CtrlShiftClickOn(A) + return ShiftClickOn(A) return - if(modifiers["alt"]) // alt and alt-gr (rightalt) + if(LAZYACCESS(modifiers, ALT_CLICK)) // alt and alt-gr (rightalt) AltClickOn(A) return - if(modifiers["ctrl"]) + if(LAZYACCESS(modifiers, CTRL_CLICK)) CtrlClickOn(A) return - if(modifiers["middle"]) + if(LAZYACCESS(modifiers, MIDDLE_CLICK)) MiddleClickOn(A, params) return diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index e06cfa5b42f..3dd56955317 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -79,22 +79,22 @@ return var/list/modifiers = params2list(params) - if(modifiers["shift"] && modifiers["middle"]) - ShiftMiddleClickOn(A) - return - if(modifiers["shift"] && modifiers["ctrl"]) - CtrlShiftClickOn(A) - return - if(modifiers["middle"]) - MiddleClickOn(A, params) - return - if(modifiers["shift"]) + if(LAZYACCESS(modifiers, SHIFT_CLICK)) + if(LAZYACCESS(modifiers, MIDDLE_CLICK)) + ShiftMiddleClickOn(A) + return + if(LAZYACCESS(modifiers, CTRL_CLICK)) + CtrlShiftClickOn(A) + return ShiftClickOn(A) return - if(modifiers["alt"]) // alt and alt-gr (rightalt) + if(LAZYACCESS(modifiers, MIDDLE_CLICK)) + MiddleClickOn(A, params) + return + if(LAZYACCESS(modifiers, ALT_CLICK)) // alt and alt-gr (rightalt) AltClickOn(A) return - if(modifiers["ctrl"]) + if(LAZYACCESS(modifiers, CTRL_CLICK)) CtrlClickOn(A) return @@ -110,7 +110,7 @@ if(next_move > world.time) // in the year 2000... return - if(!modifiers["catcher"] && A.IsObscured()) + if(!LAZYACCESS(modifiers, "catcher") && A.IsObscured()) return if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) @@ -155,7 +155,7 @@ UnarmedAttack(A,1,modifiers) else if(W) - if(modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) var/after_attack_secondary_result = W.afterattack_secondary(A, src, FALSE, params) if(after_attack_secondary_result == SECONDARY_ATTACK_CALL_NORMAL) @@ -449,11 +449,11 @@ /atom/movable/screen/click_catcher/Click(location, control, params) var/list/modifiers = params2list(params) - if(modifiers["middle"] && iscarbon(usr)) + if(LAZYACCESS(modifiers, MIDDLE_CLICK) && iscarbon(usr)) var/mob/living/carbon/C = usr C.swap_hand() else - var/turf/T = params2turf(modifiers["screen-loc"], get_turf(usr.client ? usr.client.eye : usr), usr.client) + var/turf/T = params2turf(LAZYACCESS(modifiers, SCREEN_LOC), get_turf(usr.client ? usr.client.eye : usr), usr.client) params += "&catcher=1" if(T) T.Click(location, control, params) @@ -464,8 +464,8 @@ SEND_SIGNAL(src, COMSIG_MOUSE_SCROLL_ON, A, delta_x, delta_y, params) /mob/dead/observer/MouseWheelOn(atom/A, delta_x, delta_y, params) - var/list/modifier = params2list(params) - if(modifier["shift"]) + var/list/modifiers = params2list(params) + if(LAZYACCESS(modifiers, SHIFT_CLICK)) var/view = 0 if(delta_y > 0) view = -1 diff --git a/code/_onclick/cyborg.dm b/code/_onclick/cyborg.dm index 4cf07b30258..04d1e7ffa93 100644 --- a/code/_onclick/cyborg.dm +++ b/code/_onclick/cyborg.dm @@ -18,22 +18,22 @@ return var/list/modifiers = params2list(params) - if(modifiers["shift"] && modifiers["ctrl"]) - CtrlShiftClickOn(A) - return - if(modifiers["shift"] && modifiers["middle"]) - ShiftMiddleClickOn(A) - return - if(modifiers["middle"]) - MiddleClickOn(A) - return - if(modifiers["shift"]) + if(LAZYACCESS(modifiers, SHIFT_CLICK)) + if(LAZYACCESS(modifiers, CTRL_CLICK)) + CtrlShiftClickOn(A) + return + if(LAZYACCESS(modifiers, MIDDLE_CLICK)) + ShiftMiddleClickOn(A) + return ShiftClickOn(A) return - if(modifiers["alt"]) // alt and alt-gr (rightalt) + if(LAZYACCESS(modifiers, MIDDLE_CLICK)) + MiddleClickOn(A, params) + return + if(LAZYACCESS(modifiers, ALT_CLICK)) // alt and alt-gr (rightalt) AltClickOn(A) return - if(modifiers["ctrl"]) + if(LAZYACCESS(modifiers, CTRL_CLICK)) CtrlClickOn(A) return diff --git a/code/_onclick/drag_drop.dm b/code/_onclick/drag_drop.dm index 26fd1d9ceab..8c6a6328790 100644 --- a/code/_onclick/drag_drop.dm +++ b/code/_onclick/drag_drop.dm @@ -87,8 +87,8 @@ return TRUE /client/MouseDrag(src_object,atom/over_object,src_location,over_location,src_control,over_control,params) - var/list/L = params2list(params) - if (L["middle"]) + var/list/modifiers = params2list(params) + if (LAZYACCESS(modifiers, MIDDLE_CLICK)) if (src_object && src_location != over_location) middragtime = world.time middragatom = src_object diff --git a/code/_onclick/hud/action_button.dm b/code/_onclick/hud/action_button.dm index 78cef8d4775..412375a77e6 100644 --- a/code/_onclick/hud/action_button.dm +++ b/code/_onclick/hud/action_button.dm @@ -43,14 +43,14 @@ return FALSE var/list/modifiers = params2list(params) - if(modifiers["shift"]) + if(LAZYACCESS(modifiers, SHIFT_CLICK)) if(locked) to_chat(usr, "Action button \"[name]\" is locked, unlock it first.") return TRUE moved = 0 usr.update_action_buttons() //redraw buttons that are no longer considered "moved" return TRUE - if(modifiers["ctrl"]) + if(LAZYACCESS(modifiers, CTRL_CLICK)) locked = !locked to_chat(usr, "Action button \"[name]\" [locked ? "" : "un"]locked.") if(id && usr.client) //try to (un)remember position @@ -95,20 +95,20 @@ return var/list/modifiers = params2list(params) - if(modifiers["shift"]) + if(LAZYACCESS(modifiers, SHIFT_CLICK)) if(locked) to_chat(usr, "Action button \"[name]\" is locked, unlock it first.") return TRUE moved = FALSE usr.update_action_buttons(TRUE) return TRUE - if(modifiers["ctrl"]) + if(LAZYACCESS(modifiers, CTRL_CLICK)) locked = !locked to_chat(usr, "Action button \"[name]\" [locked ? "" : "un"]locked.") if(id && usr.client) //try to (un)remember position usr.client.prefs.action_buttons_screen_locs["[name]_[id]"] = locked ? moved : null return TRUE - if(modifiers["alt"]) + if(LAZYACCESS(modifiers, ALT_CLICK)) for(var/V in usr.actions) var/datum/action/A = V var/atom/movable/screen/movable/action_button/B = A.button diff --git a/code/_onclick/hud/alert.dm b/code/_onclick/hud/alert.dm index cf92e5d61fe..860fa19cb23 100644 --- a/code/_onclick/hud/alert.dm +++ b/code/_onclick/hud/alert.dm @@ -726,8 +726,8 @@ so as to remain in compliance with the most up-to-date laws." /atom/movable/screen/alert/Click(location, control, params) if(!usr || !usr.client) return - var/paramslist = params2list(params) - if(paramslist["shift"]) // screen objects don't do the normal Click() stuff so we'll cheat + var/list/modifiers = params2list(params) + if(LAZYACCESS(modifiers, SHIFT_CLICK)) // screen objects don't do the normal Click() stuff so we'll cheat to_chat(usr, "[name] - [desc]") return if(usr != owner) diff --git a/code/_onclick/hud/movable_screen_objects.dm b/code/_onclick/hud/movable_screen_objects.dm index ddc67d4ca0a..4dfc76fb622 100644 --- a/code/_onclick/hud/movable_screen_objects.dm +++ b/code/_onclick/hud/movable_screen_objects.dm @@ -25,14 +25,14 @@ /atom/movable/screen/movable/MouseDrop(over_object, src_location, over_location, src_control, over_control, params) if(locked) //no! I am locked! begone! return - var/list/PM = params2list(params) + var/list/modifiers = params2list(params) //No screen-loc information? abort. - if(!PM || !PM["screen-loc"]) + if(LAZYACCESS(modifiers, SCREEN_LOC)) return //Split screen-loc up into X+Pixel_X and Y+Pixel_Y - var/list/screen_loc_params = splittext(PM["screen-loc"], ",") + var/list/screen_loc_params = splittext(LAZYACCESS(modifiers, SCREEN_LOC), ",") //Split X+Pixel_X up into list(X, Pixel_X) var/list/screen_loc_X = splittext(screen_loc_params[1],":") diff --git a/code/_onclick/hud/pai.dm b/code/_onclick/hud/pai.dm index bdb9ab05d68..b7c99aba687 100644 --- a/code/_onclick/hud/pai.dm +++ b/code/_onclick/hud/pai.dm @@ -89,7 +89,7 @@ var/mob/living/silicon/pai/pAI = usr var/list/modifiers = params2list(params) if(iscarbon(pAI.card.loc)) - if (modifiers["right"]) + if (LAZYACCESS(modifiers, RIGHT_CLICK)) pAI.hostscan.attack_secondary(pAI.card.loc, pAI) else pAI.hostscan.attack(pAI.card.loc, pAI) diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 4ea6b868989..8a5fd73b13c 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -490,9 +490,9 @@ if(isobserver(usr)) return - var/list/PL = params2list(params) - var/icon_x = text2num(PL["icon-x"]) - var/icon_y = text2num(PL["icon-y"]) + var/list/modifiers = params2list(params) + var/icon_x = text2num(LAZYACCESS(modifiers, ICON_X)) + var/icon_y = text2num(LAZYACCESS(modifiers, ICON_Y)) var/choice = get_zone_at(icon_x, icon_y) if (!choice) return 1 @@ -506,9 +506,9 @@ if(isobserver(usr)) return - var/list/PL = params2list(params) - var/icon_x = text2num(PL["icon-x"]) - var/icon_y = text2num(PL["icon-y"]) + var/list/modifiers = params2list(params) + var/icon_x = text2num(LAZYACCESS(modifiers, ICON_X)) + var/icon_y = text2num(LAZYACCESS(modifiers, ICON_Y)) var/choice = get_zone_at(icon_x, icon_y) if(hovering == choice) diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 42fcebddcc3..52e81c65c2d 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -8,7 +8,8 @@ * * [/obj/item/proc/afterattack]. The return value does not matter. */ /obj/item/proc/melee_attack_chain(mob/user, atom/target, params) - var/is_right_clicking = params2list(params)["right"] + + var/is_right_clicking = LAZYACCESS(params2list(params), RIGHT_CLICK) if(tool_behaviour && target.tool_act(user, src, tool_behaviour)) return TRUE diff --git a/code/_onclick/observer.dm b/code/_onclick/observer.dm index c01f75cb575..a3bf4c021f9 100644 --- a/code/_onclick/observer.dm +++ b/code/_onclick/observer.dm @@ -21,22 +21,22 @@ return var/list/modifiers = params2list(params) - if(modifiers["shift"] && modifiers["middle"]) - ShiftMiddleClickOn(A) - return - if(modifiers["shift"] && modifiers["ctrl"]) - CtrlShiftClickOn(A) - return - if(modifiers["middle"]) - MiddleClickOn(A) - return - if(modifiers["shift"]) + if(LAZYACCESS(modifiers, SHIFT_CLICK)) + if(LAZYACCESS(modifiers, MIDDLE_CLICK)) + ShiftMiddleClickOn(A) + return + if(LAZYACCESS(modifiers, CTRL_CLICK)) + CtrlShiftClickOn(A) + return ShiftClickOn(A) return - if(modifiers["alt"]) + if(LAZYACCESS(modifiers, MIDDLE_CLICK)) + MiddleClickOn(A, params) + return + if(LAZYACCESS(modifiers, ALT_CLICK)) AltClickNoInteract(src, A) return - if(modifiers["ctrl"]) + if(LAZYACCESS(modifiers, CTRL_CLICK)) CtrlClickOn(A) return diff --git a/code/_onclick/other_mobs.dm b/code/_onclick/other_mobs.dm index 8706508027e..a90805416b4 100644 --- a/code/_onclick/other_mobs.dm +++ b/code/_onclick/other_mobs.dm @@ -32,7 +32,7 @@ if(dna?.species?.spec_unarmedattack(src, A, modifiers)) //Because species like monkeys dont use attack hand return - if (modifiers["right"]) + if (LAZYACCESS(modifiers, RIGHT_CLICK)) var/secondary_result = A.attack_hand_secondary(src, modifiers) if (secondary_result == SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN || secondary_result == SECONDARY_ATTACK_CONTINUE_CHAIN) diff --git a/code/_onclick/overmind.dm b/code/_onclick/overmind.dm index 07907b94cee..d6b8994f82f 100644 --- a/code/_onclick/overmind.dm +++ b/code/_onclick/overmind.dm @@ -3,16 +3,16 @@ /mob/camera/blob/ClickOn(atom/A, params) //Expand blob var/list/modifiers = params2list(params) - if(modifiers["middle"]) - MiddleClickOn(A) + if(LAZYACCESS(modifiers, MIDDLE_CLICK)) + MiddleClickOn(A, params) return - if(modifiers["shift"]) + if(LAZYACCESS(modifiers, SHIFT_CLICK)) ShiftClickOn(A) return - if(modifiers["alt"]) + if(LAZYACCESS(modifiers, ALT_CLICK)) AltClickOn(A) return - if(modifiers["ctrl"]) + if(LAZYACCESS(modifiers, CTRL_CLICK)) CtrlClickOn(A) return var/turf/T = get_turf(A) diff --git a/code/datums/components/gunpoint.dm b/code/datums/components/gunpoint.dm index 45e2cd144b7..6c4c5d27005 100644 --- a/code/datums/components/gunpoint.dm +++ b/code/datums/components/gunpoint.dm @@ -88,7 +88,7 @@ /datum/component/gunpoint/proc/check_shove(mob/living/carbon/shooter, mob/shooter_again, mob/living/T, datum/martial_art/attacker_style, modifiers) SIGNAL_HANDLER - if(T != target || (modifiers && modifiers["right"])) + if(T != target || LAZYACCESS(modifiers, RIGHT_CLICK)) return shooter.visible_message("[shooter] bumps into [target] and fumbles [shooter.p_their()] aim!", \ "You bump into [target] and fumble your aim!", ignored_mobs = target) diff --git a/code/datums/components/riding/riding_mob.dm b/code/datums/components/riding/riding_mob.dm index 861b4cf39e8..25df6bfaf0b 100644 --- a/code/datums/components/riding/riding_mob.dm +++ b/code/datums/components/riding/riding_mob.dm @@ -182,7 +182,7 @@ /datum/component/riding/creature/human/proc/on_host_unarmed_melee(mob/living/carbon/human/human_parent, atom/target, proximity, modifiers) SIGNAL_HANDLER - if(modifiers && modifiers["right"] && (target in human_parent.buckled_mobs)) + if(LAZYACCESS(modifiers, RIGHT_CLICK) && (target in human_parent.buckled_mobs)) force_dismount(target) return COMPONENT_CANCEL_ATTACK_CHAIN diff --git a/code/datums/components/tackle.dm b/code/datums/components/tackle.dm index 9ceac3c7f6d..332ca967c10 100644 --- a/code/datums/components/tackle.dm +++ b/code/datums/components/tackle.dm @@ -100,7 +100,7 @@ user.face_atom(A) var/list/modifiers = params2list(params) - if(modifiers["alt"] || modifiers["shift"] || modifiers["ctrl"] || modifiers["middle"]) + if(LAZYACCESS(modifiers, ALT_CLICK) || LAZYACCESS(modifiers, SHIFT_CLICK) || LAZYACCESS(modifiers, CTRL_CLICK) || LAZYACCESS(modifiers, MIDDLE_CLICK)) return tackling = TRUE diff --git a/code/datums/martial/sleeping_carp.dm b/code/datums/martial/sleeping_carp.dm index 3d7a2357916..3d7de61e753 100644 --- a/code/datums/martial/sleeping_carp.dm +++ b/code/datums/martial/sleeping_carp.dm @@ -212,7 +212,7 @@ to_chat(user, "It would be dishonorable to attack a foe while they cannot retaliate.") return var/list/modifiers = params2list(params) - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) if(!wielded) return ..() if(!ishuman(target)) diff --git a/code/datums/mutations/hulk.dm b/code/datums/mutations/hulk.dm index 33510785dbd..763641cc18e 100644 --- a/code/datums/mutations/hulk.dm +++ b/code/datums/mutations/hulk.dm @@ -102,7 +102,7 @@ /// Basically, we only proceed if we're in throw mode with a tailed carbon in our grasp with at least a neck grab and we're not restrained in some way var/list/modifiers = params2list(params) - if(modifiers["alt"] || modifiers["shift"] || modifiers["ctrl"] || modifiers["middle"]) + if(LAZYACCESS(modifiers, ALT_CLICK) || LAZYACCESS(modifiers, SHIFT_CLICK) || LAZYACCESS(modifiers, CTRL_CLICK) || LAZYACCESS(modifiers, MIDDLE_CLICK)) return if(!user.in_throw_mode || user.get_active_held_item() || user.zone_selected != BODY_ZONE_PRECISE_GROIN) return diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 4bf4100f4ad..222bf7c751e 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -1829,11 +1829,11 @@ var/client/usr_client = usr.client var/list/paramslist = list() if(href_list["statpanel_item_shiftclick"]) - paramslist["shift"] = "1" + paramslist[SHIFT_CLICK] = "1" if(href_list["statpanel_item_ctrlclick"]) - paramslist["ctrl"] = "1" + paramslist[CTRL_CLICK] = "1" if(href_list["statpanel_item_altclick"]) - paramslist["alt"] = "1" + paramslist[ALT_CLICK] = "1" if(href_list["statpanel_item_click"]) // first of all make sure we valid var/mouseparams = list2params(paramslist) diff --git a/code/game/objects/items/crayons.dm b/code/game/objects/items/crayons.dm index 0f064ee187d..8753f5476af 100644 --- a/code/game/objects/items/crayons.dm +++ b/code/game/objects/items/crayons.dm @@ -352,13 +352,13 @@ else graf_rot = 0 - var/list/click_params = params2list(params) + var/list/modifiers = params2list(params) var/clickx var/clicky - if(click_params && click_params["icon-x"] && click_params["icon-y"]) - clickx = clamp(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2) - clicky = clamp(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2) + if(LAZYACCESS(modifiers, ICON_X) && LAZYACCESS(modifiers, ICON_Y)) + clickx = clamp(text2num(LAZYACCESS(modifiers, ICON_X)) - 16, -(world.icon_size/2), world.icon_size/2) + clicky = clamp(text2num(LAZYACCESS(modifiers, ICON_Y)) - 16, -(world.icon_size/2), world.icon_size/2) if(!instant) to_chat(user, "You start drawing a [temp] on the [target.name]...") diff --git a/code/game/objects/items/defib.dm b/code/game/objects/items/defib.dm index a4b44dd1d8c..06a15e9a50f 100644 --- a/code/game/objects/items/defib.dm +++ b/code/game/objects/items/defib.dm @@ -431,7 +431,7 @@ return var/list/modifiers = params2list(params) - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) do_disarm(M, user) return diff --git a/code/game/objects/items/devices/laserpointer.dm b/code/game/objects/items/devices/laserpointer.dm index 595e96dd37c..b2328f7901f 100644 --- a/code/game/objects/items/devices/laserpointer.dm +++ b/code/game/objects/items/devices/laserpointer.dm @@ -162,12 +162,12 @@ //laser pointer image icon_state = "pointer_[pointer_icon_state]" var/image/I = image('icons/obj/projectiles.dmi',targloc,pointer_icon_state,10) - var/list/click_params = params2list(params) - if(click_params) - if(click_params["icon-x"]) - I.pixel_x = (text2num(click_params["icon-x"]) - 16) - if(click_params["icon-y"]) - I.pixel_y = (text2num(click_params["icon-y"]) - 16) + var/list/modifiers = params2list(params) + if(modifiers) + if(LAZYACCESS(modifiers, ICON_X)) + I.pixel_x = (text2num(LAZYACCESS(modifiers, ICON_X)) - 16) + if(LAZYACCESS(modifiers, ICON_Y)) + I.pixel_y = (text2num(LAZYACCESS(modifiers, ICON_Y)) - 16) else I.pixel_x = target.pixel_x + rand(-5,5) I.pixel_y = target.pixel_y + rand(-5,5) diff --git a/code/game/objects/items/melee/misc.dm b/code/game/objects/items/melee/misc.dm index 26d162b59e0..f50a5bed0ea 100644 --- a/code/game/objects/items/melee/misc.dm +++ b/code/game/objects/items/melee/misc.dm @@ -290,7 +290,7 @@ return var/list/modifiers = params2list(params) - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) ..() return if(cooldown_check > world.time) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 50bf452b44a..647f95fe55e 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -193,7 +193,7 @@ return var/list/modifiers = params2list(params) - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) if(turned_on) if(attack_cooldown_check <= world.time) baton_effect(M, user, TRUE) //SKYRAT EDIT CHANGE - ORIGINAL: baton_effect(M, user) diff --git a/code/game/objects/items/tail_pin.dm b/code/game/objects/items/tail_pin.dm index 4e8729c5da2..3ace731b29a 100644 --- a/code/game/objects/items/tail_pin.dm +++ b/code/game/objects/items/tail_pin.dm @@ -35,9 +35,9 @@ return if(!user.transferItemToLoc(I, drop_location(), silent = FALSE)) return - var/list/click_params = params2list(params) - if(!click_params || !click_params["icon-x"] || !click_params["icon-y"]) + var/list/modifiers = params2list(params) + if(!LAZYACCESS(modifiers, ICON_X) || !LAZYACCESS(modifiers, ICON_Y)) return - I.pixel_x = clamp(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2) - I.pixel_y = clamp(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2) + I.pixel_x = clamp(text2num(LAZYACCESS(modifiers, ICON_X)) - 16, -(world.icon_size/2), world.icon_size/2) + I.pixel_y = clamp(text2num(LAZYACCESS(modifiers, ICON_Y)) - 16, -(world.icon_size/2), world.icon_size/2) return TRUE diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm index b6cf4cffc1d..a13f661b269 100644 --- a/code/game/objects/structures/tables_racks.dm +++ b/code/game/objects/structures/tables_racks.dm @@ -164,7 +164,7 @@ /obj/structure/table/attackby(obj/item/I, mob/living/user, params) var/list/modifiers = params2list(params) - if(!(flags_1 & NODECONSTRUCT_1) && modifiers && modifiers["right"]) + if(!(flags_1 & NODECONSTRUCT_1) && LAZYACCESS(modifiers, RIGHT_CLICK)) if(I.tool_behaviour == TOOL_SCREWDRIVER && deconstruction_ready) to_chat(user, "You start disassembling [src]...") if(I.use_tool(src, user, 20, volume=50)) @@ -215,13 +215,12 @@ if(!user.combat_mode && !(I.item_flags & ABSTRACT)) if(user.transferItemToLoc(I, drop_location(), silent = FALSE)) - var/list/click_params = params2list(params) //Center the icon where the user clicked. - if(!click_params || !click_params["icon-x"] || !click_params["icon-y"]) + if(!LAZYACCESS(modifiers, ICON_X) || !LAZYACCESS(modifiers, ICON_Y)) return //Clamp it so that the icon never moves more than 16 pixels in either direction (thus leaving the table turf) - I.pixel_x = clamp(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2) - I.pixel_y = clamp(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2) + I.pixel_x = clamp(text2num(LAZYACCESS(modifiers, ICON_X)) - 16, -(world.icon_size/2), world.icon_size/2) + I.pixel_y = clamp(text2num(LAZYACCESS(modifiers, ICON_Y)) - 16, -(world.icon_size/2), world.icon_size/2) AfterPutItemOnTable(I, user) return TRUE else @@ -511,7 +510,7 @@ /obj/structure/table/reinforced/attackby(obj/item/W, mob/living/user, params) var/list/modifiers = params2list(params) - if(W.tool_behaviour == TOOL_WELDER && modifiers && modifiers["right"]) + if(W.tool_behaviour == TOOL_WELDER && LAZYACCESS(modifiers, RIGHT_CLICK)) if(!W.tool_start_check(user, amount=0)) return @@ -633,7 +632,7 @@ /obj/structure/rack/attackby(obj/item/W, mob/living/user, params) var/list/modifiers = params2list(params) - if (W.tool_behaviour == TOOL_WRENCH && !(flags_1&NODECONSTRUCT_1) && modifiers && modifiers["right"]) + if (W.tool_behaviour == TOOL_WRENCH && !(flags_1&NODECONSTRUCT_1) && LAZYACCESS(modifiers, RIGHT_CLICK)) W.play_tool_sound(src) deconstruct(TRUE) return diff --git a/code/modules/antagonists/revenant/revenant_abilities.dm b/code/modules/antagonists/revenant/revenant_abilities.dm index e324944bec3..abb2d1f4b57 100644 --- a/code/modules/antagonists/revenant/revenant_abilities.dm +++ b/code/modules/antagonists/revenant/revenant_abilities.dm @@ -1,10 +1,10 @@ /mob/living/simple_animal/revenant/ClickOn(atom/A, params) //revenants can't interact with the world directly. var/list/modifiers = params2list(params) - if(modifiers["shift"]) + if(LAZYACCESS(modifiers, SHIFT_CLICK)) ShiftClickOn(A) return - if(modifiers["alt"]) + if(LAZYACCESS(modifiers, ALT_CLICK)) AltClickNoInteract(src, A) return diff --git a/code/modules/buildmode/bm_mode.dm b/code/modules/buildmode/bm_mode.dm index 5bd5f079fa4..12cc2c0c36c 100644 --- a/code/modules/buildmode/bm_mode.dm +++ b/code/modules/buildmode/bm_mode.dm @@ -70,10 +70,9 @@ cornerB = null /datum/buildmode_mode/proc/handle_click(client/c, params, object) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") + var/list/modifiers = params2list(params) if(use_corner_selection) - if(left_click) + if(LAZYACCESS(modifiers, LEFT_CLICK)) if(!cornerA) cornerA = select_tile(get_turf(object), AREASELECT_CORNERA) return diff --git a/code/modules/buildmode/buttons.dm b/code/modules/buildmode/buttons.dm index 5c5c0000d1b..28af8acce05 100644 --- a/code/modules/buildmode/buttons.dm +++ b/code/modules/buildmode/buttons.dm @@ -18,12 +18,12 @@ screen_loc = "NORTH,WEST" /atom/movable/screen/buildmode/mode/Click(location, control, params) - var/list/pa = params2list(params) - - if(pa.Find("left")) + var/list/modifiers = params2list(params) + if(LAZYACCESS(modifiers, LEFT_CLICK)) bd.toggle_modeswitch() - else if(pa.Find("right")) + else if(LAZYACCESS(modifiers, RIGHT_CLICK)) bd.mode.change_settings(usr.client) + update_icon() return 1 diff --git a/code/modules/buildmode/submodes/advanced.dm b/code/modules/buildmode/submodes/advanced.dm index d841ca26e34..4a0be94a878 100644 --- a/code/modules/buildmode/submodes/advanced.dm +++ b/code/modules/buildmode/submodes/advanced.dm @@ -30,10 +30,10 @@ return /datum/buildmode_mode/advanced/handle_click(client/c, params, obj/object) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") - var/right_click = pa.Find("right") - var/alt_click = pa.Find("alt") + var/list/modifiers = params2list(params) + var/left_click = LAZYACCESS(modifiers, LEFT_CLICK) + var/right_click = LAZYACCESS(modifiers, RIGHT_CLICK) + var/alt_click = LAZYACCESS(modifiers, ALT_CLICK) if(left_click && alt_click) if (istype(object, /turf) || istype(object, /obj) || istype(object, /mob)) diff --git a/code/modules/buildmode/submodes/area_edit.dm b/code/modules/buildmode/submodes/area_edit.dm index 19f536e0737..039f2897a88 100644 --- a/code/modules/buildmode/submodes/area_edit.dm +++ b/code/modules/buildmode/submodes/area_edit.dm @@ -43,11 +43,9 @@ areaimage.loc = storedarea // color our area /datum/buildmode_mode/area_edit/handle_click(client/c, params, object) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") - var/right_click = pa.Find("right") + var/list/modifiers = params2list(params) - if(left_click) + if(LAZYACCESS(modifiers, LEFT_CLICK)) if(!storedarea) to_chat(c, "Configure or select the area you want to paint first!") return @@ -55,7 +53,7 @@ if(get_area(T) != storedarea) log_admin("Build Mode: [key_name(c)] added [AREACOORD(T)] to [storedarea]") storedarea.contents.Add(T) - else if(right_click) + else if(LAZYACCESS(modifiers, RIGHT_CLICK)) var/turf/T = get_turf(object) storedarea = get_area(T) areaimage.loc = storedarea // color our area diff --git a/code/modules/buildmode/submodes/basic.dm b/code/modules/buildmode/submodes/basic.dm index 086d64eda86..59027b22a02 100644 --- a/code/modules/buildmode/submodes/basic.dm +++ b/code/modules/buildmode/submodes/basic.dm @@ -13,11 +13,12 @@ to_chat(c, "***********************************************************") /datum/buildmode_mode/basic/handle_click(client/c, params, obj/object) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") - var/right_click = pa.Find("right") - var/ctrl_click = pa.Find("ctrl") - var/alt_click = pa.Find("alt") + var/list/modifiers = params2list(params) + + var/left_click = LAZYACCESS(modifiers, LEFT_CLICK) + var/right_click = LAZYACCESS(modifiers, RIGHT_CLICK) + var/alt_click = LAZYACCESS(modifiers, ALT_CLICK) + var/ctrl_click = LAZYACCESS(modifiers, CTRL_CLICK) if(istype(object,/turf) && left_click && !alt_click && !ctrl_click) var/turf/T = object diff --git a/code/modules/buildmode/submodes/boom.dm b/code/modules/buildmode/submodes/boom.dm index 2b2bfe2239e..a8460956a0c 100644 --- a/code/modules/buildmode/submodes/boom.dm +++ b/code/modules/buildmode/submodes/boom.dm @@ -31,9 +31,8 @@ flames = -1 /datum/buildmode_mode/boom/handle_click(client/c, params, obj/object) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") + var/list/modifiers = params2list(params) - if(left_click) + if(LAZYACCESS(modifiers, LEFT_CLICK)) explosion(object, devastation, heavy, light, flash, FALSE, TRUE, flames) log_admin("Build Mode: [key_name(c)] caused an explosion(dev=[devastation], hvy=[heavy], lgt=[light], flash=[flash], flames=[flames]) at [AREACOORD(object)]") diff --git a/code/modules/buildmode/submodes/copy.dm b/code/modules/buildmode/submodes/copy.dm index 4aed8ac700d..7f189923b14 100644 --- a/code/modules/buildmode/submodes/copy.dm +++ b/code/modules/buildmode/submodes/copy.dm @@ -13,16 +13,14 @@ to_chat(c, "***********************************************************") /datum/buildmode_mode/copy/handle_click(client/c, params, obj/object) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") - var/right_click = pa.Find("right") + var/list/modifiers = params2list(params) - if(left_click) + if(LAZYACCESS(modifiers, LEFT_CLICK)) var/turf/T = get_turf(object) if(stored) DuplicateObject(stored, perfectcopy=1, sameloc=0,newloc=T) log_admin("Build Mode: [key_name(c)] copied [stored] to [AREACOORD(object)]") - else if(right_click) + else if(LAZYACCESS(modifiers, RIGHT_CLICK)) if(ismovable(object)) // No copying turfs for now. to_chat(c, "[object] set as template.") stored = object diff --git a/code/modules/buildmode/submodes/delete.dm b/code/modules/buildmode/submodes/delete.dm index ea2145a8dbd..92148de9d69 100644 --- a/code/modules/buildmode/submodes/delete.dm +++ b/code/modules/buildmode/submodes/delete.dm @@ -8,18 +8,16 @@ ***********************************************************") /datum/buildmode_mode/delete/handle_click(client/c, params, object) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") - var/right_click = pa.Find("right") + var/list/modifiers = params2list(params) - if(left_click) + if(LAZYACCESS(modifiers, LEFT_CLICK)) if(isturf(object)) var/turf/T = object T.ScrapeAway(flags = CHANGETURF_INHERIT_AIR) else if(isatom(object)) qdel(object) - if(right_click) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) if(check_rights(R_DEBUG|R_SERVER)) //Prevents buildmoded non-admins from breaking everything. if(isturf(object)) return diff --git a/code/modules/buildmode/submodes/fill.dm b/code/modules/buildmode/submodes/fill.dm index b7d87edef25..6d79fdc22d1 100644 --- a/code/modules/buildmode/submodes/fill.dm +++ b/code/modules/buildmode/submodes/fill.dm @@ -33,12 +33,10 @@ ..() /datum/buildmode_mode/fill/handle_selected_area(client/c, params) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") - var/alt_click = pa.Find("alt") - - if(left_click) //rectangular - if(alt_click) + var/list/modifiers = params2list(params) + + if(LAZYACCESS(modifiers, LEFT_CLICK)) //rectangular + if(LAZYACCESS(modifiers, ALT_CLICK)) var/list/deletion_area = block(get_turf(cornerA),get_turf(cornerB)) for(var/beep in deletion_area) var/turf/T = beep diff --git a/code/modules/buildmode/submodes/mapgen.dm b/code/modules/buildmode/submodes/mapgen.dm index 23f132c1d8a..60aad0f088d 100644 --- a/code/modules/buildmode/submodes/mapgen.dm +++ b/code/modules/buildmode/submodes/mapgen.dm @@ -31,9 +31,9 @@ ..() /datum/buildmode_mode/mapgen/handle_selected_area(client/c, params) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") - if(left_click) + var/list/modifiers = params2list(params) + + if(LAZYACCESS(modifiers, LEFT_CLICK)) var/datum/map_generator/G = new generator_path if(istype(G, /datum/map_generator/repair/reload_station_map)) if(GLOB.reloading_map) diff --git a/code/modules/buildmode/submodes/outfit.dm b/code/modules/buildmode/submodes/outfit.dm index 55ca0f4464d..f9f0f6edaec 100644 --- a/code/modules/buildmode/submodes/outfit.dm +++ b/code/modules/buildmode/submodes/outfit.dm @@ -21,15 +21,13 @@ dressuptime = c.robust_dress_shop() /datum/buildmode_mode/outfit/handle_click(client/c, params, object) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") - var/right_click = pa.Find("right") + var/list/modifiers = params2list(params) if(!ishuman(object)) return var/mob/living/carbon/human/dollie = object - if(left_click) + if(LAZYACCESS(modifiers, LEFT_CLICK)) if(isnull(dressuptime)) to_chat(c, "Pick an outfit first.") return @@ -39,6 +37,6 @@ if(dressuptime != "Naked") dollie.equipOutfit(dressuptime) - if(right_click) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) for (var/item in dollie.get_equipped_items(TRUE)) qdel(item) diff --git a/code/modules/buildmode/submodes/smite.dm b/code/modules/buildmode/submodes/smite.dm index 5f5050b41f3..7eefabf7f3b 100644 --- a/code/modules/buildmode/submodes/smite.dm +++ b/code/modules/buildmode/submodes/smite.dm @@ -21,13 +21,13 @@ return selected_smite = picking_smite -/datum/buildmode_mode/smite/handle_click(client/user, params_string, object) - var/list/params = params2list(params_string) +/datum/buildmode_mode/smite/handle_click(client/user, params, object) + var/list/modifiers = params2list(params) if (!check_rights(R_ADMIN | R_FUN)) return - if (!params.Find("left")) + if (!LAZYACCESS(modifiers, LEFT_CLICK)) return if (!isliving(object)) diff --git a/code/modules/buildmode/submodes/throwing.dm b/code/modules/buildmode/submodes/throwing.dm index 6d578c9c467..80a8d4cdbe4 100644 --- a/code/modules/buildmode/submodes/throwing.dm +++ b/code/modules/buildmode/submodes/throwing.dm @@ -14,16 +14,14 @@ to_chat(c, "***********************************************************") /datum/buildmode_mode/throwing/handle_click(client/c, params, obj/object) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") - var/right_click = pa.Find("right") + var/list/modifiers = params2list(params) - if(left_click) + if(LAZYACCESS(modifiers, LEFT_CLICK)) if(isturf(object)) return throw_atom = object to_chat(c, "Selected object '[throw_atom]'") - if(right_click) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) if(throw_atom) throw_atom.throw_at(object, 10, 1, c.mob) log_admin("Build Mode: [key_name(c)] threw [throw_atom] at [object] ([AREACOORD(object)])") diff --git a/code/modules/buildmode/submodes/variable_edit.dm b/code/modules/buildmode/submodes/variable_edit.dm index ac4c1ef66a2..8d5fea0f228 100644 --- a/code/modules/buildmode/submodes/variable_edit.dm +++ b/code/modules/buildmode/submodes/variable_edit.dm @@ -35,14 +35,12 @@ valueholder = temp_value["value"] /datum/buildmode_mode/varedit/handle_click(client/c, params, obj/object) - var/list/pa = params2list(params) - var/left_click = pa.Find("left") - var/right_click = pa.Find("right") + var/list/modifiers = params2list(params) if(isnull(varholder)) to_chat(c, "Choose a variable to modify first.") return - if(left_click) + if(LAZYACCESS(modifiers, LEFT_CLICK)) if(object.vars.Find(varholder)) if(object.vv_edit_var(varholder, valueholder) == FALSE) to_chat(c, "Your edit was rejected by the object.") @@ -50,7 +48,7 @@ log_admin("Build Mode: [key_name(c)] modified [object.name]'s [varholder] to [valueholder]") else to_chat(c, "[initial(object.name)] does not have a var called '[varholder]'") - if(right_click) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) if(object.vars.Find(varholder)) var/reset_value = initial(object.vars[varholder]) if(object.vv_edit_var(varholder, reset_value) == FALSE) diff --git a/code/modules/cargo/centcom_podlauncher.dm b/code/modules/cargo/centcom_podlauncher.dm index 0ee6de0d58d..beebdf4efc0 100644 --- a/code/modules/cargo/centcom_podlauncher.dm +++ b/code/modules/cargo/centcom_podlauncher.dm @@ -577,8 +577,10 @@ holder_mob?.update_mouse_pointer() //set the moues icons to null, then call update_moues_pointer() which resets them to the correct values based on what the mob is doing (in a mech, holding a spell, etc)() /datum/centcom_podlauncher/proc/InterceptClickOn(user,params,atom/target) //Click Intercept so we know where to send pods where the user clicks - var/list/pa = params2list(params) - var/left_click = pa.Find("left") + var/list/modifiers = params2list(params) + + var/left_click = LAZYACCESS(modifiers, LEFT_CLICK) + if (launcherActivated) //Clicking on UI elements shouldn't launch a pod if(istype(target,/atom/movable/screen)) diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 9d894b101c1..19b2443e471 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -835,13 +835,13 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( /client/Click(atom/object, atom/location, control, params) var/ab = FALSE - var/list/L = params2list(params) + var/list/modifiers = params2list(params) - var/dragged = L["drag"] - if(dragged && !L[dragged]) + var/dragged = LAZYACCESS(modifiers, DRAG) + if(dragged && !LAZYACCESS(modifiers, dragged)) //I don't know what's going on here, but I don't trust it return - if (object && object == middragatom && L["left"]) + if (object && object == middragatom && LAZYACCESS(modifiers, LEFT_CLICK)) ab = max(0, 5 SECONDS-(world.time-middragtime)*0.1) var/mcl = CONFIG_GET(number/minute_click_limit) diff --git a/code/modules/food_and_drinks/kitchen_machinery/griddle.dm b/code/modules/food_and_drinks/kitchen_machinery/griddle.dm index fab0183829c..cd5ed84f360 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/griddle.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/griddle.dm @@ -62,14 +62,14 @@ if(griddled_objects.len >= max_items) to_chat(user, "[src] can't fit more items!") return - var/list/click_params = params2list(params) + var/list/modifiers = params2list(params) //Center the icon where the user clicked. - if(!click_params || !click_params["icon-x"] || !click_params["icon-y"]) + if(!LAZYACCESS(modifiers, ICON_X) || !LAZYACCESS(modifiers, ICON_Y)) return if(user.transferItemToLoc(I, src, silent = FALSE)) //Clamp it so that the icon never moves more than 16 pixels in either direction (thus leaving the table turf) - I.pixel_x = clamp(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2) - I.pixel_y = clamp(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2) + I.pixel_x = clamp(text2num(LAZYACCESS(modifiers, ICON_X)) - 16, -(world.icon_size/2), world.icon_size/2) + I.pixel_y = clamp(text2num(LAZYACCESS(modifiers, ICON_Y)) - 16, -(world.icon_size/2), world.icon_size/2) to_chat(user, "You place [I] on [src].") AddToGrill(I, user) update_icon() diff --git a/code/modules/hydroponics/grown/towercap.dm b/code/modules/hydroponics/grown/towercap.dm index e91bf4cbb50..cb559ff1554 100644 --- a/code/modules/hydroponics/grown/towercap.dm +++ b/code/modules/hydroponics/grown/towercap.dm @@ -199,13 +199,13 @@ if(!user.combat_mode && !(W.item_flags & ABSTRACT)) if(user.temporarilyRemoveItemFromInventory(W)) W.forceMove(get_turf(src)) - var/list/click_params = params2list(params) + var/list/modifiers = params2list(params) //Center the icon where the user clicked. - if(!click_params || !click_params["icon-x"] || !click_params["icon-y"]) + if(!LAZYACCESS(modifiers, ICON_X) || !LAZYACCESS(modifiers, ICON_Y)) return //Clamp it so that the icon never moves more than 16 pixels in either direction (thus leaving the table turf) - W.pixel_x = W.base_pixel_x + clamp(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2) - W.pixel_y = W.base_pixel_y + clamp(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2) + W.pixel_x = W.base_pixel_x + clamp(text2num(LAZYACCESS(modifiers, ICON_X)) - 16, -(world.icon_size/2), world.icon_size/2) + W.pixel_y = W.base_pixel_y + clamp(text2num(LAZYACCESS(modifiers, ICON_Y)) - 16, -(world.icon_size/2), world.icon_size/2) else return ..() diff --git a/code/modules/mob/living/carbon/alien/alien_defense.dm b/code/modules/mob/living/carbon/alien/alien_defense.dm index a4893fd07d2..73d6a6a83e3 100644 --- a/code/modules/mob/living/carbon/alien/alien_defense.dm +++ b/code/modules/mob/living/carbon/alien/alien_defense.dm @@ -53,7 +53,7 @@ In all, this is a lot like the monkey code. /N return FALSE if(M.combat_mode) - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) M.do_attack_animation(src, ATTACK_EFFECT_DISARM) return TRUE M.do_attack_animation(src, ATTACK_EFFECT_PUNCH) diff --git a/code/modules/mob/living/carbon/alien/humanoid/humanoid_defense.dm b/code/modules/mob/living/carbon/alien/humanoid/humanoid_defense.dm index 2677c1a30d2..ef1912f2077 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/humanoid_defense.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/humanoid_defense.dm @@ -17,7 +17,7 @@ /mob/living/carbon/alien/humanoid/attack_hand(mob/living/carbon/human/M, modifiers) if(..()) if(M.combat_mode) - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) if (body_position == STANDING_UP) if (prob(5)) Unconscious(40) diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 56691d6952e..2e74ffdbba7 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -220,7 +220,7 @@ affecting = get_bodypart(BODY_ZONE_CHEST) - if(modifiers && modifiers["right"]) //Always drop item in hand, if no item, get stunned instead. + if(LAZYACCESS(modifiers, RIGHT_CLICK)) //Always drop item in hand, if no item, get stunned instead. var/obj/item/I = get_active_held_item() if(I && !(I.item_flags & ABSTRACT) && dropItemToGround(I)) playsound(loc, 'sound/weapons/slash.ogg', 25, TRUE, -1) @@ -270,7 +270,7 @@ if(!.) return - if(modifiers && modifiers["right"]) //Always drop item in hand, if no item, get stun instead. + if(LAZYACCESS(modifiers, RIGHT_CLICK)) //Always drop item in hand, if no item, get stun instead. var/obj/item/I = get_active_held_item() if(I && dropItemToGround(I)) playsound(loc, 'sound/weapons/slash.ogg', 25, TRUE, -1) diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 23ba488c384..dcde7d3e04f 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -1463,7 +1463,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) SEND_SIGNAL(M, COMSIG_MOB_ATTACK_HAND, M, H, attacker_style) - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) disarm(M, H, attacker_style) return // dont attack after if(M.combat_mode) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index fa3b0510577..d9e3090427b 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1983,7 +1983,7 @@ if (style) if (is_grab) attack_result = style.grab_act(src, target) - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) attack_result = style.disarm_act(src, target) if(combat_mode) if (HAS_TRAIT(src, TRAIT_PACIFISM)) diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 61d2ba77379..fcfc7ec55d6 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -264,7 +264,7 @@ if (M.apply_martial_art(src, modifiers)) return TRUE - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) if (M != src) M.disarm(src) return TRUE @@ -317,7 +317,7 @@ return FALSE /mob/living/attack_alien(mob/living/carbon/alien/humanoid/M, modifiers) - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) M.do_attack_animation(src, ATTACK_EFFECT_DISARM) return TRUE if(M.combat_mode) diff --git a/code/modules/mob/living/silicon/robot/robot_defense.dm b/code/modules/mob/living/silicon/robot/robot_defense.dm index 4f8bd4b14cc..f632dfcc94b 100644 --- a/code/modules/mob/living/silicon/robot/robot_defense.dm +++ b/code/modules/mob/living/silicon/robot/robot_defense.dm @@ -236,7 +236,7 @@ GLOBAL_LIST_INIT(blacklisted_borg_hats, typecacheof(list( //Hats that don't real return ..() /mob/living/silicon/robot/attack_alien(mob/living/carbon/alien/humanoid/M, modifiers) - if (modifiers && modifiers["right"]) + if (LAZYACCESS(modifiers, RIGHT_CLICK)) if(body_position == STANDING_UP) M.do_attack_animation(src, ATTACK_EFFECT_DISARM) var/obj/item/I = get_active_held_item() diff --git a/code/modules/mob/living/simple_animal/animal_defense.dm b/code/modules/mob/living/simple_animal/animal_defense.dm index 2f8a956040f..22e621d1fc5 100644 --- a/code/modules/mob/living/simple_animal/animal_defense.dm +++ b/code/modules/mob/living/simple_animal/animal_defense.dm @@ -5,7 +5,7 @@ if (..()) return TRUE - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) M.do_attack_animation(src, ATTACK_EFFECT_DISARM) playsound(src, 'sound/weapons/thudswoosh.ogg', 50, TRUE, -1) var/shove_dir = get_dir(M, src) @@ -80,7 +80,7 @@ /mob/living/simple_animal/attack_alien(mob/living/carbon/alien/humanoid/M, modifiers) if(..()) //if harm or disarm intent. - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) playsound(loc, 'sound/weapons/pierce.ogg', 25, TRUE, -1) visible_message("[M] [response_disarm_continuous] [name]!", \ "[M] [response_disarm_continuous] you!", null, COMBAT_MESSAGE_RANGE, M) diff --git a/code/modules/mob/living/simple_animal/bot/medbot.dm b/code/modules/mob/living/simple_animal/bot/medbot.dm index dbf2309ec95..f730d58baa6 100644 --- a/code/modules/mob/living/simple_animal/bot/medbot.dm +++ b/code/modules/mob/living/simple_animal/bot/medbot.dm @@ -454,7 +454,7 @@ to_chat(H, "You're already interacting with [src].") return - if(modifiers && modifiers["right"] && mode != BOT_TIPPED) + if(LAZYACCESS(modifiers, RIGHT_CLICK) && mode != BOT_TIPPED) H.visible_message("[H] begins tipping over [src].", "You begin tipping over [src]...") if(world.time > last_tipping_action_voice + 15 SECONDS) diff --git a/code/modules/mob/living/simple_animal/friendly/farm_animals.dm b/code/modules/mob/living/simple_animal/friendly/farm_animals.dm index a73b11b2b9f..2ddde08a1fa 100644 --- a/code/modules/mob/living/simple_animal/friendly/farm_animals.dm +++ b/code/modules/mob/living/simple_animal/friendly/farm_animals.dm @@ -179,7 +179,7 @@ udder.generateMilk() /mob/living/simple_animal/cow/attack_hand(mob/living/carbon/M, modifiers) - if(!stat && modifiers && modifiers["right"] && icon_state != icon_dead) + if(!stat && LAZYACCESS(modifiers, RIGHT_CLICK) && icon_state != icon_dead) M.visible_message("[M] tips over [src].", "You tip over [src].") to_chat(src, "You are tipped over by [M]!") diff --git a/code/modules/mob/living/simple_animal/slime/slime.dm b/code/modules/mob/living/simple_animal/slime/slime.dm index bfb4df5a364..84097d7a564 100644 --- a/code/modules/mob/living/simple_animal/slime/slime.dm +++ b/code/modules/mob/living/simple_animal/slime/slime.dm @@ -340,7 +340,7 @@ discipline_slime(M) else if(stat == DEAD && surgeries.len) - if(!M.combat_mode || (modifiers && modifiers["right"])) + if(!M.combat_mode || LAZYACCESS(modifiers, RIGHT_CLICK)) for(var/datum/surgery/S in surgeries) if(S.next_step(M, modifiers)) return 1 @@ -356,7 +356,7 @@ /mob/living/simple_animal/slime/attackby(obj/item/W, mob/living/user, params) if(stat == DEAD && surgeries.len) var/list/modifiers = params2list(params) - if(!user.combat_mode || (modifiers && modifiers["right"])) + if(!user.combat_mode || (LAZYACCESS(modifiers, RIGHT_CLICK))) for(var/datum/surgery/S in surgeries) if(S.next_step(user, modifiers)) return 1 diff --git a/code/modules/ninja/energy_katana.dm b/code/modules/ninja/energy_katana.dm index 84fd304c94a..fee30232fcc 100644 --- a/code/modules/ninja/energy_katana.dm +++ b/code/modules/ninja/energy_katana.dm @@ -42,9 +42,9 @@ /obj/item/energy_katana/afterattack(atom/target, mob/user, proximity_flag, click_parameters) . = ..() - var/list/params = params2list(click_parameters) + var/list/modifiers = params2list(click_parameters) - if(params["right"] && !target.density) + if(LAZYACCESS(modifiers, RIGHT_CLICK) && !target.density) jaunt.Teleport(user, target) /obj/item/energy_katana/pickup(mob/living/user) diff --git a/code/modules/paperwork/filingcabinet.dm b/code/modules/paperwork/filingcabinet.dm index 0bfaa1aef46..badc0e94ecd 100644 --- a/code/modules/paperwork/filingcabinet.dm +++ b/code/modules/paperwork/filingcabinet.dm @@ -47,7 +47,7 @@ /obj/structure/filingcabinet/attackby(obj/item/P, mob/living/user, params) var/list/modifiers = params2list(params) - if(P.tool_behaviour == TOOL_WRENCH && modifiers && modifiers["right"]) + if(P.tool_behaviour == TOOL_WRENCH && LAZYACCESS(modifiers, RIGHT_CLICK)) to_chat(user, "You begin to [anchored ? "unwrench" : "wrench"] [src].") if(P.use_tool(src, user, 20, volume=50)) to_chat(user, "You successfully [anchored ? "unwrench" : "wrench"] [src].") diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index d3d065d1bde..2b2c4a11623 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -811,7 +811,7 @@ var/charge_limit = ETHEREAL_CHARGE_DANGEROUS - APC_POWER_GAIN var/list/modifiers = params2list(params) if(H.combat_mode && E.drain_time < world.time) - if(modifiers && modifiers["right"]) //Disarm + if(LAZYACCESS(modifiers, RIGHT_CLICK)) //Disarm if(cell.charge == cell.maxcharge) to_chat(H, "The APC is full!") return diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 74fdb94997f..8eaa483ea62 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -857,17 +857,17 @@ qdel(src) /proc/calculate_projectile_angle_and_pixel_offsets(mob/user, params) - var/list/mouse_control = params2list(params) + var/list/modifiers = params2list(params) var/p_x = 0 var/p_y = 0 var/angle = 0 - if(mouse_control["icon-x"]) - p_x = text2num(mouse_control["icon-x"]) - if(mouse_control["icon-y"]) - p_y = text2num(mouse_control["icon-y"]) - if(mouse_control["screen-loc"]) + if(LAZYACCESS(modifiers, ICON_X)) + p_x = text2num(LAZYACCESS(modifiers, ICON_X)) + if(LAZYACCESS(modifiers, ICON_Y)) + p_y = text2num(LAZYACCESS(modifiers, ICON_Y)) + if(LAZYACCESS(modifiers, SCREEN_LOC)) //Split screen-loc up into X+Pixel_X and Y+Pixel_Y - var/list/screen_loc_params = splittext(mouse_control["screen-loc"], ",") + var/list/screen_loc_params = splittext(LAZYACCESS(modifiers, SCREEN_LOC), ",") //Split X+Pixel_X up into list(X, Pixel_X) var/list/screen_loc_X = splittext(screen_loc_params[1],":") diff --git a/code/modules/surgery/surgery.dm b/code/modules/surgery/surgery.dm index 5dcacc53252..f5c62165116 100644 --- a/code/modules/surgery/surgery.dm +++ b/code/modules/surgery/surgery.dm @@ -100,7 +100,7 @@ return TRUE var/try_to_fail = FALSE - if(modifiers && modifiers["right"]) + if(LAZYACCESS(modifiers, RIGHT_CLICK)) try_to_fail = TRUE var/datum/surgery_step/S = get_surgery_step() diff --git a/code/modules/unit_tests/combat.dm b/code/modules/unit_tests/combat.dm index ebe94c94106..1bff1c52159 100644 --- a/code/modules/unit_tests/combat.dm +++ b/code/modules/unit_tests/combat.dm @@ -6,7 +6,7 @@ ADD_TRAIT(puncher, TRAIT_PERFECT_ATTACKER, INNATE_TRAIT) puncher.set_combat_mode(TRUE) - victim.attack_hand(puncher, list("right" = FALSE)) + victim.attack_hand(puncher, list(RIGHT_CLICK = FALSE)) TEST_ASSERT(victim.getBruteLoss() > 0, "Victim took no brute damage after being punched") @@ -82,7 +82,7 @@ // First disarm, world should now look like: // Attacker --> Empty space --> Victim --> Wall - victim.attack_hand(attacker, list("right" = TRUE)) + victim.attack_hand(attacker, list(RIGHT_CLICK = TRUE)) TEST_ASSERT_EQUAL(victim.loc.x, run_loc_bottom_left.x + 2, "Victim wasn't moved back after being pushed") TEST_ASSERT(!victim.has_status_effect(STATUS_EFFECT_KNOCKDOWN), "Victim was knocked down despite not being against a wall") @@ -91,7 +91,7 @@ attacker.forceMove(get_step(attacker, EAST)) // Second disarm, victim was against wall and should be down - victim.attack_hand(attacker, list("right" = TRUE)) + victim.attack_hand(attacker, list(RIGHT_CLICK = TRUE)) TEST_ASSERT_EQUAL(victim.loc.x, run_loc_bottom_left.x + 2, "Victim was moved after being pushed against a wall") TEST_ASSERT(victim.has_status_effect(STATUS_EFFECT_KNOCKDOWN), "Victim was not knocked down after being pushed against a wall") diff --git a/code/modules/vehicles/mecha/_mecha.dm b/code/modules/vehicles/mecha/_mecha.dm index 481e6c3da72..a34ea3b1960 100644 --- a/code/modules/vehicles/mecha/_mecha.dm +++ b/code/modules/vehicles/mecha/_mecha.dm @@ -524,8 +524,8 @@ return if(is_currently_ejecting) return - var/list/mouse_control = params2list(params) - if(isAI(user) == !mouse_control["middle"])//BASICALLY if a human uses MMB, or an AI doesn't, then do nothing. + var/list/modifiers = params2list(params) + if(isAI(user) == !LAZYACCESS(modifiers, MIDDLE_CLICK))//BASICALLY if a human uses MMB, or an AI doesn't, then do nothing. return if(phasing) to_chat(occupants, "[icon2html(src, occupants)]Unable to interact with objects while phasing.") diff --git a/code/modules/vehicles/mecha/equipment/tools/work_tools.dm b/code/modules/vehicles/mecha/equipment/tools/work_tools.dm index 726547697e2..d3bb12bd6be 100644 --- a/code/modules/vehicles/mecha/equipment/tools/work_tools.dm +++ b/code/modules/vehicles/mecha/equipment/tools/work_tools.dm @@ -107,7 +107,7 @@ "[chassis] pushes you aside.") return ..() - /*else if(modifiers && modifiers["right"] && iscarbon(M))//meme clamp here + /*else if(LAZYACCESS(modifiers, RIGHT_CLICK) && iscarbon(M))//meme clamp here if(!killer_clamp) to_chat(source, "You longingly wish to tear [M]'s arms off.") return diff --git a/tgstation.dme b/tgstation.dme index 4e3105c215b..2ed120a162b 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -16,6 +16,7 @@ #include "_maps\_basemap.dm" #include "code\_compile_options.dm" #include "code\world.dm" +#include "code\__DEFINES\_click.dm" #include "code\__DEFINES\_globals.dm" #include "code\__DEFINES\_helpers.dm" #include "code\__DEFINES\_profile.dm"