diff --git a/code/__DEFINES/dcs/signals/atom/signals_atom.dm b/code/__DEFINES/dcs/signals/atom/signals_atom.dm index 7431c5593b17..cac9861d09cb 100644 --- a/code/__DEFINES/dcs/signals/atom/signals_atom.dm +++ b/code/__DEFINES/dcs/signals/atom/signals_atom.dm @@ -45,3 +45,9 @@ ///When the transform or an atom is varedited through vv topic. #define COMSIG_ATOM_VV_MODIFY_TRANSFORM "atom_vv_modify_transform" + +/// Called when an atom has something mouse dropped on it, from /client/MouseDrop: (atom/dropped_on) +#define COMSIG_ATOM_DROPPED_ON "atom_dropped_on" + +/// Called when an atom is mouse dropped on another atom, from /client/MouseDrop: (atom/dropped_onto) +#define COMSIG_ATOM_DROP_ON "atom_drop_on" diff --git a/code/_onclick/click_hold.dm b/code/_onclick/click_hold.dm index f65dd33c2eea..996f7ed2bf3b 100644 --- a/code/_onclick/click_hold.dm +++ b/code/_onclick/click_hold.dm @@ -94,3 +94,12 @@ // Add the hovered atom to the trace LAZYADD(mouse_trace_history, over_obj) + +/client/MouseDrop(datum/over_object, datum/src_location, over_location, src_control, over_control, params) + . = ..() + + if(src_location) + SEND_SIGNAL(src_location, COMSIG_ATOM_DROPPED_ON, over_object, src) + + if(over_object) + SEND_SIGNAL(over_object, COMSIG_ATOM_DROP_ON, src_location, src) diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 35b6073ee41b..b49bce4111f0 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -30,6 +30,10 @@ /atom/movable/screen/inventory var/slot_id //The indentifier for the slot. It has nothing to do with ID cards. +/atom/movable/screen/inventory/Initialize(mapload, ...) + . = ..() + + RegisterSignal(src, COMSIG_ATOM_DROPPED_ON, PROC_REF(handle_dropped_on)) /atom/movable/screen/close name = "close" @@ -325,6 +329,22 @@ return 1 return 0 +/atom/movable/screen/inventory/proc/handle_dropped_on(atom/dropped_on, atom/dropping, client/user) + SIGNAL_HANDLER + + if(slot_id != WEAR_L_HAND && slot_id != WEAR_R_HAND) + return + + if(!isstorage(dropping.loc)) + return + + if(!user.mob.Adjacent(dropping)) + return + + var/obj/item/storage/store = dropping.loc + store.remove_from_storage(dropping, get_turf(user.mob)) + user.mob.put_in_active_hand(dropping) + /atom/movable/screen/throw_catch name = "throw/catch" icon = 'icons/mob/hud/human_midnight.dmi'