From 14bfd19814c25cfb21abea9898fe524e3b558d6f Mon Sep 17 00:00:00 2001 From: S34NW <12197162+S34NW@users.noreply.github.com> Date: Wed, 28 Jul 2021 17:04:48 +0100 Subject: [PATCH 1/6] Like tracing your hand but for items --- code/__DEFINES/colors.dm | 9 ++++ code/__DEFINES/preferences.dm | 5 +- code/game/objects/items.dm | 51 ++++++++++++++++++- .../objects/items/weapons/storage/storage.dm | 3 ++ .../client/preference/preferences_toggles.dm | 8 +++ 5 files changed, 73 insertions(+), 3 deletions(-) diff --git a/code/__DEFINES/colors.dm b/code/__DEFINES/colors.dm index fc67f448526..f399915e3e7 100644 --- a/code/__DEFINES/colors.dm +++ b/code/__DEFINES/colors.dm @@ -114,3 +114,12 @@ #define PIPE_COLOR_GREEN "#00ff00" #define PIPE_COLOR_YELLOW "#ffcc00" #define PIPE_COLOR_PURPLE "#5c1ec0" + +///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_GLASS "#75A4C4" +#define COLOR_THEME_CLOCKWORK "#CFBA47" diff --git a/code/__DEFINES/preferences.dm b/code/__DEFINES/preferences.dm index ba292ab65f6..a198421a2cb 100644 --- a/code/__DEFINES/preferences.dm +++ b/code/__DEFINES/preferences.dm @@ -56,10 +56,11 @@ #define PREFTOGGLE_2_REVERB_DISABLE 512 #define PREFTOGGLE_2_FORCE_WHITE_RUNECHAT 1024 #define PREFTOGGLE_2_SIMPLE_STAT_PANEL 2048 +#define PREFTOGGLE_2_SEE_ITEM_OUTLINES 4096 -#define TOGGLES_2_TOTAL 4095 // If you add or remove a preference toggle above, make sure you update this define with the total value of the toggles combined. +#define TOGGLES_2_TOTAL 8191 // If you add or remove a preference toggle above, make sure you update this define with the total value of the toggles combined. -#define TOGGLES_2_DEFAULT (PREFTOGGLE_2_FANCYUI|PREFTOGGLE_2_ITEMATTACK|PREFTOGGLE_2_WINDOWFLASHING|PREFTOGGLE_2_RUNECHAT|PREFTOGGLE_2_DEATHMESSAGE|PREFTOGGLE_2_EMOTE_BUBBLE) +#define TOGGLES_2_DEFAULT (PREFTOGGLE_2_FANCYUI|PREFTOGGLE_2_ITEMATTACK|PREFTOGGLE_2_WINDOWFLASHING|PREFTOGGLE_2_RUNECHAT|PREFTOGGLE_2_DEATHMESSAGE|PREFTOGGLE_2_EMOTE_BUBBLE|PREFTOGGLE_2_SEE_ITEM_OUTLINES) // Sanity checks #if TOGGLES_TOTAL > 16777215 diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 2d014e9e6c2..569270c5290 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -117,6 +117,10 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect var/in_inventory = FALSE //is this item equipped into an inventory slot or hand of a mob? var/tip_timer = 0 + /// item hover FX + var/in_storage = FALSE + var/outline_filter + /obj/item/New() ..() for(var/path in actions_types) @@ -418,10 +422,12 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect // 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) + in_inventory = 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_inventory = TRUE return /** @@ -691,14 +697,22 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect openToolTip(user, src, params, title = name, content = "[desc]", theme = "") /obj/item/MouseEntered(location, control, params) - if(in_inventory) + if(in_inventory || in_storage) var/timedelay = 8 var/user = usr tip_timer = addtimer(CALLBACK(src, .proc/openTip, location, control, params, user), timedelay, TIMER_STOPPABLE) + if(!QDELETED(src)) + var/mob/living/L = usr + if(usr.client.prefs.toggles2 & PREFTOGGLE_2_SEE_ITEM_OUTLINES) + if(istype(L) && L.incapacitated(ignore_lying = TRUE)) + apply_outline(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() //if the player's alive and well we send the command with no color set, so it uses the theme's color /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() /obj/item/MouseDrop_T(obj/item/I, mob/user) if(!user || user.incapacitated(ignore_lying = TRUE) || src == I) @@ -707,6 +721,41 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect if(loc && I.loc == loc && istype(loc, /obj/item/storage) && loc.Adjacent(user)) // Are we trying to swap two items in the storage? var/obj/item/storage/S = loc S.swap_items(src, I, user) + remove_outline() //get rid of the hover effect in case the mouse exit isn't called if someone drags and drops an item and somthing goes wrong + +/obj/item/proc/apply_outline(outline_color = null) + if(!(in_inventory || in_storage) || QDELETED(src) || isobserver(usr)) //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(usr.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 //just as garish as the rest of this theme + if("slimecore") + outline_color = COLOR_THEME_SLIMECORE + if("operative") + outline_color = COLOR_THEME_OPERATIVE + if("clockwork") + outline_color = COLOR_THEME_CLOCKWORK //if you want free gbp go fix the fact that clockwork's tooltip css is glass' + if("glass") + outline_color = COLOR_THEME_GLASS + 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 // Returns a numeric value for sorting items used as parts in machines, so they can be replaced by the rped /obj/item/proc/get_part_rating() diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index 9f145c5bbdb..7adb3b2a28f 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -59,6 +59,9 @@ populate_contents() + for(var/obj/item/L in return_inv()) //marks all items in storage as being such + L.in_storage = TRUE + boxes = new /obj/screen/storage() boxes.name = "storage" boxes.master = src diff --git a/code/modules/client/preference/preferences_toggles.dm b/code/modules/client/preference/preferences_toggles.dm index 2bb7b7529e2..6862b98fe1e 100644 --- a/code/modules/client/preference/preferences_toggles.dm +++ b/code/modules/client/preference/preferences_toggles.dm @@ -356,3 +356,11 @@ prefs.toggles2 ^= PREFTOGGLE_2_SIMPLE_STAT_PANEL prefs.save_preferences(src) to_chat(src, "You will [(prefs.toggles2 & PREFTOGGLE_2_SIMPLE_STAT_PANEL) ? "no longer" : "now"] get detailed information on the status panel.") + +/client/verb/toggle_item_outlines() + set name = "Toggle Item Outlines" + set category = "Preferences" + set desc = "Toggles seeing item outlines on hover." + prefs.toggles2 ^= PREFTOGGLE_2_SEE_ITEM_OUTLINES + prefs.save_preferences(src) + to_chat(usr, "You will [(prefs.toggles2 & PREFTOGGLE_2_SEE_ITEM_OUTLINES) ? "no longer" : "now"] see item outlines on hover.") From d37cbd1ad72e4205ccd5ee63c086577d66a541b5 Mon Sep 17 00:00:00 2001 From: S34N <12197162+S34NW@users.noreply.github.com> Date: Wed, 28 Jul 2021 17:15:13 +0100 Subject: [PATCH 2/6] Apply suggestions from code review --- code/game/objects/items.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 569270c5290..a9fb4e8fcc4 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -422,12 +422,12 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect // 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) - in_inventory = FALSE + 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_inventory = TRUE + in_storage = TRUE return /** From 43f5c2fa18de303034cfd664f2737838363a9ee4 Mon Sep 17 00:00:00 2001 From: S34NW <12197162+S34NW@users.noreply.github.com> Date: Wed, 28 Jul 2021 17:45:26 +0100 Subject: [PATCH 3/6] would help if i got these the right way around eh? --- code/modules/client/preference/preferences_toggles.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/client/preference/preferences_toggles.dm b/code/modules/client/preference/preferences_toggles.dm index 6862b98fe1e..21c81287a2b 100644 --- a/code/modules/client/preference/preferences_toggles.dm +++ b/code/modules/client/preference/preferences_toggles.dm @@ -363,4 +363,4 @@ set desc = "Toggles seeing item outlines on hover." prefs.toggles2 ^= PREFTOGGLE_2_SEE_ITEM_OUTLINES prefs.save_preferences(src) - to_chat(usr, "You will [(prefs.toggles2 & PREFTOGGLE_2_SEE_ITEM_OUTLINES) ? "no longer" : "now"] see item outlines on hover.") + to_chat(usr, "You will [(prefs.toggles2 & PREFTOGGLE_2_SEE_ITEM_OUTLINES) ? "now" : "no longer"] see item outlines on hover.") From 7a5e343c117ffe9fcf204d9f00dbf76a4a35c521 Mon Sep 17 00:00:00 2001 From: S34NW <12197162+S34NW@users.noreply.github.com> Date: Wed, 28 Jul 2021 19:26:43 +0100 Subject: [PATCH 4/6] code review --- code/game/objects/items.dm | 35 +++++++++++-------- .../objects/items/weapons/storage/storage.dm | 3 -- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index a9fb4e8fcc4..297753c372d 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -118,8 +118,8 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect var/tip_timer = 0 /// item hover FX - var/in_storage = FALSE - var/outline_filter + var/in_storage = FALSE //is this item inside a storage object? + var/outline_filter //holder var for the item outline filter, null when no outline filter on the item. /obj/item/New() ..() @@ -135,6 +135,11 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect if(!move_resist) determine_move_resist() +/obj/item/Initialize(mapload) + . = ..() + if(istype(loc, /obj/item/storage)) //marks all items in storage as being such + in_storage = TRUE + /obj/item/proc/determine_move_resist() switch(w_class) if(WEIGHT_CLASS_TINY) @@ -699,15 +704,17 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect /obj/item/MouseEntered(location, control, params) if(in_inventory || in_storage) var/timedelay = 8 - var/user = usr + var/mob/user = usr tip_timer = addtimer(CALLBACK(src, .proc/openTip, location, control, params, user), timedelay, TIMER_STOPPABLE) - if(!QDELETED(src)) - var/mob/living/L = usr - if(usr.client.prefs.toggles2 & PREFTOGGLE_2_SEE_ITEM_OUTLINES) - if(istype(L) && L.incapacitated(ignore_lying = TRUE)) - apply_outline(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() //if the player's alive and well we send the command with no color set, so it uses the theme's color + if(QDELETED(src)) + return + var/mob/living/L = user + if(!(user.client.prefs.toggles2 & PREFTOGGLE_2_SEE_ITEM_OUTLINES)) + return + if(istype(L) && L.incapacitated(ignore_lying = TRUE)) + 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/MouseExited() deltimer(tip_timer) //delete any in-progress timer if the mouse is moved off the item before it finishes @@ -723,10 +730,10 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect S.swap_items(src, I, user) remove_outline() //get rid of the hover effect in case the mouse exit isn't called if someone drags and drops an item and somthing goes wrong -/obj/item/proc/apply_outline(outline_color = null) - if(!(in_inventory || in_storage) || QDELETED(src) || isobserver(usr)) //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) +/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(usr.client.prefs.UI_style) + 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") @@ -749,7 +756,7 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect 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) + outline_filter = filter(type = "outline", size = 1, color = outline_color) filters += outline_filter /obj/item/proc/remove_outline() diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index 7adb3b2a28f..9f145c5bbdb 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -59,9 +59,6 @@ populate_contents() - for(var/obj/item/L in return_inv()) //marks all items in storage as being such - L.in_storage = TRUE - boxes = new /obj/screen/storage() boxes.name = "storage" boxes.master = src From a4ac662ae281a215bbabc31f5517d902e3d0eff7 Mon Sep 17 00:00:00 2001 From: S34N <12197162+S34NW@users.noreply.github.com> Date: Thu, 29 Jul 2021 08:11:05 +0100 Subject: [PATCH 5/6] Update code/game/objects/items.dm Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com> --- code/game/objects/items.dm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 297753c372d..b0f597d3a8a 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -117,9 +117,11 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect var/in_inventory = FALSE //is this item equipped into an inventory slot or hand of a mob? var/tip_timer = 0 - /// item hover FX - var/in_storage = FALSE //is this item inside a storage object? - var/outline_filter //holder var for the item outline filter, null when no outline filter on the item. + // 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/New() ..() From 4aa46f8bf313c337233bfff9bb282cf54e7b04f5 Mon Sep 17 00:00:00 2001 From: S34NW <12197162+S34NW@users.noreply.github.com> Date: Wed, 4 Aug 2021 08:49:29 +0100 Subject: [PATCH 6/6] stops outline flashing momentarily on dropping --- code/game/objects/items.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index b0f597d3a8a..1a6edd1dd45 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -121,7 +121,7 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect /// 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 + var/outline_filter /obj/item/New() ..() @@ -417,6 +417,7 @@ GLOBAL_DATUM_INIT(fire_overlay, /image, image("icon" = 'icons/goonstation/effect if((flags & NODROP) && !(initial(flags) & NODROP)) //Remove NODROP is dropped flags &= ~NODROP in_inventory = FALSE + remove_outline() SEND_SIGNAL(src, COMSIG_ITEM_DROPPED,user) if(!silent) playsound(src, drop_sound, DROP_SOUND_VOLUME, ignore_walls = FALSE)