mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-10 09:54:52 +00:00
138 lines
4.1 KiB
Plaintext
138 lines
4.1 KiB
Plaintext
/*
|
|
MouseDrop:
|
|
|
|
Called on the atom you're dragging. In a lot of circumstances we want to use the
|
|
recieving object instead, so that's the default action. This allows you to drag
|
|
almost anything into a trash can.
|
|
*/
|
|
/atom/MouseDrop(atom/over, src_location, over_location, src_control, over_control, params)
|
|
if(!usr || !over)
|
|
return
|
|
if(over == src)
|
|
return usr.client.Click(src, src_location, src_control, params)
|
|
if(!Adjacent(usr) || !over.Adjacent(usr))
|
|
return // should stop you from dragging through windows
|
|
|
|
over.MouseDrop_T(src,usr)
|
|
return
|
|
|
|
// recieve a mousedrop
|
|
/atom/proc/MouseDrop_T(atom/dropping, mob/user)
|
|
return
|
|
|
|
|
|
/client
|
|
var/list/atom/selected_target[2]
|
|
var/obj/item/active_mousedown_item = null
|
|
var/mouseParams = ""
|
|
var/mouseLocation = null
|
|
var/mouseObject = null
|
|
var/mouseControlObject = null
|
|
var/middragtime = 0
|
|
var/atom/middragatom
|
|
|
|
/client/MouseDown(object, location, control, params)
|
|
var/delay = mob.CanMobAutoclick(object, location, params)
|
|
if(delay)
|
|
selected_target[1] = object
|
|
selected_target[2] = params
|
|
while(selected_target[1])
|
|
Click(selected_target[1], location, control, selected_target[2])
|
|
sleep(delay)
|
|
active_mousedown_item = mob.canMobMousedown(object, location, params)
|
|
if(active_mousedown_item)
|
|
active_mousedown_item.onMouseDown(object, location, params, mob)
|
|
|
|
/client/MouseUp(object, location, control, params)
|
|
selected_target[1] = null
|
|
if(active_mousedown_item)
|
|
active_mousedown_item.onMouseUp(object, location, params, mob)
|
|
active_mousedown_item = null
|
|
|
|
/mob/proc/CanMobAutoclick(object, location, params)
|
|
|
|
/mob/living/carbon/CanMobAutoclick(atom/object, location, params)
|
|
if(!object.IsAutoclickable())
|
|
return
|
|
var/obj/item/h = get_active_held_item()
|
|
if(h)
|
|
. = h.CanItemAutoclick(object, location, params)
|
|
|
|
/mob/proc/canMobMousedown(object, location, params)
|
|
|
|
/mob/living/carbon/canMobMousedown(atom/object, location, params)
|
|
var/obj/item/H = get_active_held_item()
|
|
if(H)
|
|
. = H.canItemMouseDown(object, location, params)
|
|
|
|
/obj/item/proc/CanItemAutoclick(object, location, params)
|
|
|
|
/obj/item/proc/canItemMouseDown(object, location, params)
|
|
if(canMouseDown)
|
|
return src
|
|
|
|
/obj/item/proc/onMouseDown(object, location, params, mob)
|
|
return
|
|
|
|
/obj/item/proc/onMouseUp(object, location, params, mob)
|
|
return
|
|
|
|
/obj/item
|
|
var/canMouseDown = FALSE
|
|
|
|
/obj/item/gun
|
|
var/automatic = 0 //can gun use it, 0 is no, anything above 0 is the delay between clicks in ds
|
|
|
|
/obj/item/gun/CanItemAutoclick(object, location, params)
|
|
. = automatic
|
|
|
|
/atom/proc/IsAutoclickable()
|
|
. = 1
|
|
|
|
/obj/screen/IsAutoclickable()
|
|
. = 0
|
|
|
|
/obj/screen/click_catcher/IsAutoclickable()
|
|
. = 1
|
|
|
|
//Please don't roast me too hard
|
|
/client/MouseMove(object,location,control,params)
|
|
mouseParams = params
|
|
mouseLocation = location
|
|
mouseObject = object
|
|
mouseControlObject = control
|
|
if(mob && LAZYLEN(mob.mousemove_intercept_objects))
|
|
for(var/datum/D in mob.mousemove_intercept_objects)
|
|
D.onMouseMove(object, location, control, params)
|
|
|
|
/datum/proc/onMouseMove(object, location, control, params)
|
|
return
|
|
|
|
/client/MouseDrag(src_object,atom/over_object,src_location,over_location,src_control,over_control,params)
|
|
var/list/L = params2list(params)
|
|
if (L["middle"])
|
|
if (src_object && src_location != over_location)
|
|
middragtime = world.time
|
|
middragatom = src_object
|
|
else
|
|
middragtime = 0
|
|
middragatom = null
|
|
mouseParams = params
|
|
mouseLocation = over_location
|
|
mouseObject = over_object
|
|
mouseControlObject = over_control
|
|
if(selected_target[1] && over_object && over_object.IsAutoclickable())
|
|
selected_target[1] = over_object
|
|
selected_target[2] = params
|
|
if(active_mousedown_item)
|
|
active_mousedown_item.onMouseDrag(src_object, over_object, src_location, over_location, params, mob)
|
|
|
|
|
|
/obj/item/proc/onMouseDrag(src_object, over_object, src_location, over_location, params, mob)
|
|
return
|
|
|
|
/client/MouseDrop(src_object, over_object, src_location, over_location, src_control, over_control, params)
|
|
if (middragatom == src_object)
|
|
middragtime = 0
|
|
middragatom = null
|
|
..() |