From cb880bb359e12ead90c1757536d0d6732c27cf68 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 27 Oct 2020 10:09:25 +0100 Subject: [PATCH] [MIRROR] Adds layer switching with mouse wheel to the RPD. (#1491) * Adds layer switching with mouse wheel to the RPD. (#54458) Adds a signal that gets sent to items in currently active hand on mouse scroll and makes RPD listen to this and change the piping layer accordingly. * Adds layer switching with mouse wheel to the RPD. Co-authored-by: TheChosenEvilOne <34602646+TheChosenEvilOne@users.noreply.github.com> --- code/__DEFINES/dcs/signals.dm | 2 ++ code/_onclick/click.dm | 2 +- code/game/objects/items/RPD.dm | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 058062e9b60..a818bca682a 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -211,6 +211,8 @@ #define COMPONENT_NO_MOUSEDROP (1<<0) ///from base of atom/MouseDrop_T: (/atom/from, /mob/user) #define COMSIG_MOUSEDROPPED_ONTO "mousedropped_onto" +///from base of mob/MouseWheelOn(): (/atom, delta_x, delta_y, params) +#define COMSIG_MOUSE_SCROLL_ON "mousescroll_on" // /area signals diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index c7a26456c84..e5161a3300f 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -452,7 +452,7 @@ /// MouseWheelOn /mob/proc/MouseWheelOn(atom/A, delta_x, delta_y, params) - return + 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) diff --git a/code/game/objects/items/RPD.dm b/code/game/objects/items/RPD.dm index 97eb7fca55f..dfcf7b66a31 100644 --- a/code/game/objects/items/RPD.dm +++ b/code/game/objects/items/RPD.dm @@ -237,6 +237,18 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list( spark_system = null return ..() +/obj/item/pipe_dispenser/examine(mob/user) + . = ..() + . += "You can scroll your mouse wheel to change the piping layer." + +/obj/item/pipe_dispenser/equipped(mob/user, slot, initial) + . = ..() + RegisterSignal(user, COMSIG_MOUSE_SCROLL_ON, .proc/mouse_wheeled) + +/obj/item/pipe_dispenser/dropped(mob/user, silent) + UnregisterSignal(user, COMSIG_MOUSE_SCROLL_ON) + return ..() + /obj/item/pipe_dispenser/attack_self(mob/user) ui_interact(user) @@ -507,6 +519,19 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list( /obj/item/pipe_dispenser/proc/activate() playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) +/obj/item/pipe_dispenser/proc/mouse_wheeled(mob/source, atom/A, delta_x, delta_y, params) + SIGNAL_HANDLER + if(source.incapacitated(ignore_restraints = TRUE, ignore_stasis = TRUE)) + return + + if(delta_y > 0) + piping_layer = min(PIPING_LAYER_MAX, piping_layer + 1) + else if(delta_y < 0) + piping_layer = max(PIPING_LAYER_MIN, piping_layer - 1) + else + return + to_chat(source, "You set the layer to [piping_layer].") + #undef ATMOS_CATEGORY #undef DISPOSALS_CATEGORY #undef TRANSIT_CATEGORY