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:

![image](https://github.com/Aurorastation/Aurora.3/assets/1779662/25a027b1-f78b-434c-971e-acd27c98eb3c)

---------

Co-authored-by: Cody Brittain <cbrittain10@live.com>
This commit is contained in:
Cody Brittain
2024-05-22 09:09:12 +00:00
committed by GitHub
co-authored by Cody Brittain
parent ec421af722
commit 8ee205a7aa
9 changed files with 177 additions and 9 deletions
+8
View File
@@ -166,3 +166,11 @@
#define BLOB_COLOR_PULS "#b5ff5b"
#define RANDOM_RGB rgb(rand(0,255), rand(0,255), rand(0,255))
///Main colors for UI themes
#define COLOR_THEME_MIDNIGHT "#6086A0"
#define COLOR_THEME_PLASMAFIRE "#FFB200"
#define COLOR_THEME_RETRO "#24CA00"
#define COLOR_THEME_SLIMECORE "#4FB259"
#define COLOR_THEME_OPERATIVE "#B8221F"
#define COLOR_THEME_CLOCKWORK "#CFBA47"
@@ -7,3 +7,5 @@
///from base of obj/item/dropped(): (mob/user)
#define COMSIG_ITEM_DROPPED "item_drop"
///from base of obj/item/pickup(): (mob/user)
#define COMSIG_ITEM_PICKUP "item_pickup"
+8 -8
View File
@@ -47,14 +47,14 @@
#define CHAT_NOICONS 0x8000
#define CHAT_GHOSTLOOC 0x10000
// 0x1 is free.
// 0x2 is free.
#define PROGRESS_BARS 0x4
#define PARALLAX_IS_STATIC 0x8
#define FLOATING_MESSAGES 0x10
#define HOTKEY_DEFAULT 0x20
#define FULLSCREEN_MODE 0x40
#define ACCENT_TAG_TEXT 0x80
#define SEE_ITEM_OUTLINES 0x1
#define HIDE_ITEM_TOOLTIPS 0x2
#define PROGRESS_BARS 0x4
#define PARALLAX_IS_STATIC 0x8
#define FLOATING_MESSAGES 0x10
#define HOTKEY_DEFAULT 0x20
#define FULLSCREEN_MODE 0x40
#define ACCENT_TAG_TEXT 0x80
#define TOGGLES_DEFAULT (SOUND_ADMINHELP | SOUND_MIDI | SOUND_LOBBY | CHAT_OOC | CHAT_DEAD | CHAT_GHOSTEARS | CHAT_GHOSTSIGHT | CHAT_PRAYER | CHAT_RADIO | CHAT_ATTACKLOGS | CHAT_LOOC | CHAT_GHOSTLOOC)
+79
View File
@@ -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)
@@ -74,6 +74,8 @@
"<b>Ghost sight:</b> <a href='?src=\ref[src];toggle=[CHAT_GHOSTSIGHT]'><b>[(pref.toggles & CHAT_GHOSTSIGHT) ? "All Emotes" : "Nearest Creatures"]</b></a><br>",
"<b>Ghost radio:</b> <a href='?src=\ref[src];toggle=[CHAT_GHOSTRADIO]'><b>[(pref.toggles & CHAT_GHOSTRADIO) ? "All Chatter" : "Nearest Speakers"]</b></a><br>",
"<b>Observer LOOC:</b> <a href='?src=\ref[src];toggle=[CHAT_GHOSTLOOC]'><b>[(pref.toggles & CHAT_GHOSTLOOC) ? "Visible" : "Hidden"]</b></a><br>",
"<b>Item Outlines:</b> <a href='?src=\ref[src];paratoggle=[SEE_ITEM_OUTLINES]'><b>[(pref.toggles_secondary & SEE_ITEM_OUTLINES) ? "Visible" : "Hidden"]</b></a><br>",
"<b>Hide Item Tooltips:</b> <a href='?src=\ref[src];paratoggle=[HIDE_ITEM_TOOLTIPS]'><b>[(pref.toggles_secondary & HIDE_ITEM_TOOLTIPS) ? "Yes" : "No"]</b></a><br>",
"<b>Progress Bars:</b> <a href='?src=\ref[src];paratoggle=[PROGRESS_BARS]'><b>[(pref.toggles_secondary & PROGRESS_BARS) ? "Yes" : "No"]</b></a><br>",
"<b>Floating Messages:</b> <a href='?src=\ref[src];paratoggle=[FLOATING_MESSAGES]'><b>[(pref.toggles_secondary & FLOATING_MESSAGES) ? "Yes" : "No"]</b></a><br>",
"<b>Hotkey Mode Default:</b> <a href='?src=\ref[src];paratoggle=[HOTKEY_DEFAULT]'><b>[(pref.toggles_secondary & HOTKEY_DEFAULT) ? "On" : "Off"]</b></a><br>"
+1 -1
View File
@@ -163,7 +163,7 @@ var/list/preferences_datums = list()
var/metadata = ""
// SPAAAACE
var/toggles_secondary = PROGRESS_BARS | FLOATING_MESSAGES | HOTKEY_DEFAULT
var/toggles_secondary = SEE_ITEM_OUTLINES | PROGRESS_BARS | FLOATING_MESSAGES | HOTKEY_DEFAULT
var/clientfps = 100
var/floating_chat_color
var/speech_bubble_type = "default"
@@ -164,3 +164,21 @@
prefs.toggles_secondary ^= FLOATING_MESSAGES
prefs.save_preferences()
to_chat(src, SPAN_NOTICE("Floating messages are now [prefs.toggles_secondary & FLOATING_MESSAGES ? "enabled" : "disabled"]."))
/client/verb/toggle_item_outlines()
set name = "Toggle Item Outlines"
set desc = "Toggles outlines appearing on items in your inventory."
set category = "Preferences"
prefs.toggles_secondary ^= SEE_ITEM_OUTLINES
prefs.save_preferences()
to_chat(src, SPAN_NOTICE("Item outlines are now [prefs.toggles_secondary & SEE_ITEM_OUTLINES ? "enabled" : "disabled"]."))
/client/verb/toggle_item_tooltips()
set name = "Toggle Item Tooltips"
set desc = "Toggles tooltips appearing on items in your inventory."
set category = "Preferences"
prefs.toggles_secondary ^= HIDE_ITEM_TOOLTIPS
prefs.save_preferences()
to_chat(src, SPAN_NOTICE("Item outlines are now [prefs.toggles_secondary & HIDE_ITEM_TOOLTIPS ? "disabled" : "enabled"]."))