mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-24 21:40:55 +01:00
Add support for item tooltips and outlines (#19154)
This adds support for item tooltips and outlines, if the item in question is in an inventory and not in storage:  --------- Co-authored-by: Cody Brittain <cbrittain10@live.com>
This commit is contained in:
co-authored by
Cody Brittain
parent
ec421af722
commit
8ee205a7aa
@@ -238,6 +238,16 @@
|
||||
///Used to determine what this item can be changed into with a modkit
|
||||
var/list/convert_options
|
||||
|
||||
//Tooltip vars
|
||||
var/in_inventory = FALSE //is this item equipped into an inventory slot or hand of a mob?
|
||||
var/tip_timer = 0
|
||||
|
||||
// item hover FX
|
||||
/// Is this item inside a storage object?
|
||||
var/in_storage = FALSE
|
||||
/// Holder var for the item outline filter, null when no outline filter on the item.
|
||||
var/outline_filter
|
||||
|
||||
/obj/item/Initialize(mapload, ...)
|
||||
. = ..()
|
||||
if(islist(armor))
|
||||
@@ -481,6 +491,8 @@
|
||||
|
||||
SEND_SIGNAL(src, COMSIG_ITEM_DROPPED, user)
|
||||
|
||||
in_inventory = FALSE
|
||||
|
||||
if(user && (z_flags & ZMM_MANGLE_PLANES))
|
||||
addtimer(CALLBACK(user, /mob/proc/check_emissive_equipment), 0, TIMER_UNIQUE)
|
||||
|
||||
@@ -511,17 +523,21 @@
|
||||
/obj/item/proc/pickup(mob/user)
|
||||
pixel_x = 0
|
||||
pixel_y = 0
|
||||
SEND_SIGNAL(src, COMSIG_ITEM_PICKUP, user)
|
||||
if(item_flags & ITEM_FLAG_HELD_MAP_TEXT)
|
||||
addtimer(CALLBACK(src, PROC_REF(check_maptext)), 1) // invoke async does not work here
|
||||
in_inventory = TRUE
|
||||
do_pickup_animation(user)
|
||||
|
||||
// called when this item is removed from a storage item, which is passed on as S. The loc variable is already set to the new destination before this is called.
|
||||
/obj/item/proc/on_exit_storage(obj/item/storage/S as obj)
|
||||
do_drop_animation(S)
|
||||
in_storage = FALSE
|
||||
return
|
||||
|
||||
// called when this item is added into a storage item, which is passed on as S. The loc variable is already set to the storage item.
|
||||
/obj/item/proc/on_enter_storage(obj/item/storage/S as obj)
|
||||
in_storage = TRUE
|
||||
return
|
||||
|
||||
// called when "found" in pockets and storage items. Returns 1 if the search should end.
|
||||
@@ -538,6 +554,7 @@
|
||||
equip_slot = slot
|
||||
if(user.client) user.client.screen |= src
|
||||
if(user.pulling == src) user.stop_pulling()
|
||||
in_inventory = TRUE
|
||||
if(slot == slot_l_hand || slot == slot_r_hand)
|
||||
playsound(src, pickup_sound, PICKUP_SOUND_VOLUME)
|
||||
else if(slot_flags && slot)
|
||||
@@ -1171,6 +1188,7 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
|
||||
|
||||
/obj/item/throw_at()
|
||||
..()
|
||||
in_inventory = FALSE
|
||||
if(item_flags & ITEM_FLAG_HELD_MAP_TEXT)
|
||||
check_maptext()
|
||||
|
||||
@@ -1225,6 +1243,67 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
|
||||
/obj/item/proc/throw_fail_consequences(var/mob/living/carbon/C)
|
||||
return
|
||||
|
||||
/obj/item/proc/openTip(location, control, params, user)
|
||||
openToolTip(user, src, params, title = name, content = "[desc]", theme = "")
|
||||
|
||||
/obj/item/MouseEntered(location, control, params)
|
||||
. = ..()
|
||||
if(in_inventory || in_storage)
|
||||
var/mob/user = usr
|
||||
if(!(user.client.prefs.toggles_secondary & HIDE_ITEM_TOOLTIPS))
|
||||
tip_timer = addtimer(CALLBACK(src, PROC_REF(openTip), location, control, params, user), 8, TIMER_STOPPABLE)
|
||||
if(QDELETED(src))
|
||||
return
|
||||
if(!(user.client.prefs.toggles_secondary & SEE_ITEM_OUTLINES))
|
||||
return
|
||||
var/mob/living/L = user
|
||||
if(istype(L) && L.incapacitated())
|
||||
apply_outline(L, COLOR_RED_GRAY) //if they're dead or handcuffed, let's show the outline as red to indicate that they can't interact with that right now
|
||||
else
|
||||
apply_outline(L) //if the player's alive and well we send the command with no color set, so it uses the theme's color
|
||||
|
||||
/obj/item/MouseDrop(atom/over, src_location, over_location, src_control, over_control, params)
|
||||
. = ..()
|
||||
remove_outline()
|
||||
|
||||
/obj/item/MouseExited()
|
||||
deltimer(tip_timer) //delete any in-progress timer if the mouse is moved off the item before it finishes
|
||||
closeToolTip(usr)
|
||||
remove_outline()
|
||||
return ..()
|
||||
|
||||
/obj/item/proc/apply_outline(mob/user, outline_color = null)
|
||||
if(!(in_inventory || in_storage) || QDELETED(src) || isobserver(user)) //cancel if the item isn't in an inventory, is being deleted, or if the person hovering is a ghost (so that people spectating you don't randomly make your items glow)
|
||||
return
|
||||
var/theme = lowertext(user.client.prefs.UI_style)
|
||||
if(!outline_color) //if we weren't provided with a color, take the theme's color
|
||||
switch(theme) //yeah it kinda has to be this way
|
||||
if("midnight")
|
||||
outline_color = COLOR_THEME_MIDNIGHT
|
||||
if("plasmafire")
|
||||
outline_color = COLOR_THEME_PLASMAFIRE
|
||||
if("retro")
|
||||
outline_color = COLOR_THEME_RETRO
|
||||
if("slimecore")
|
||||
outline_color = COLOR_THEME_SLIMECORE
|
||||
if("operative")
|
||||
outline_color = COLOR_THEME_OPERATIVE
|
||||
if("clockwork")
|
||||
outline_color = COLOR_THEME_CLOCKWORK
|
||||
else //this should never happen, hopefully
|
||||
outline_color = COLOR_WHITE
|
||||
if(color)
|
||||
outline_color = COLOR_WHITE //if the item is recolored then the outline will be too, let's make the outline white so it becomes the same color instead of some ugly mix of the theme and the tint
|
||||
if(outline_filter)
|
||||
filters -= outline_filter
|
||||
outline_filter = filter(type = "outline", size = 1, color = outline_color)
|
||||
filters += outline_filter
|
||||
|
||||
/obj/item/proc/remove_outline()
|
||||
if(outline_filter)
|
||||
filters -= outline_filter
|
||||
outline_filter = null
|
||||
|
||||
/**
|
||||
* Determines if the item can be used to cut down wood (trees and the likes)
|
||||
*
|
||||
|
||||
@@ -203,6 +203,7 @@
|
||||
. += "It contains: [counting_english_list(contents)]"
|
||||
|
||||
/obj/item/storage/MouseDrop(obj/over_object)
|
||||
. = ..()
|
||||
if(!canremove)
|
||||
return
|
||||
if(!over_object || over_object == src)
|
||||
|
||||
Reference in New Issue
Block a user