mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 23:27:34 +01:00
[MIRROR] Crops the cached ID card icon so it is less obnoxious in tgui chat. (#4429)
* Crops the cached ID card icon so it is less obnoxious in tgui chat. (#57935) * Crops the cached ID card icon so it is less obnoxious in tgui chat. Co-authored-by: Timberpoes <silent_insomnia_pp@hotmail.co.uk>
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
/**
|
||||
* x1, y1, x2, y2 - Represents the bounding box for the ID card's non-transparent portion of its various icon_states.
|
||||
* Used to crop the ID card's transparency away when chaching the icon for better use in tgui chat.
|
||||
*/
|
||||
#define ID_ICON_BORDERS 1, 9, 32, 24
|
||||
|
||||
/* Cards
|
||||
* Contains:
|
||||
* DATA CARD
|
||||
@@ -74,6 +80,9 @@
|
||||
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, BIO = 0, RAD = 0, FIRE = 100, ACID = 100)
|
||||
resistance_flags = FIRE_PROOF | ACID_PROOF
|
||||
|
||||
/// Cached icon that has been built for this card. Intended for use in chat.
|
||||
var/icon/cached_flat_icon
|
||||
|
||||
/// How many magical mining Disney Dollars this card has for spending at the mining equipment vendors.
|
||||
var/mining_points = 0
|
||||
/// The name registered on the card (for example: Dr Bryan See)
|
||||
@@ -118,11 +127,22 @@
|
||||
|
||||
/obj/item/card/id/get_id_examine_strings(mob/user)
|
||||
. = ..()
|
||||
. += list("[icon2html(get_icon_source(), user, extra_classes = "bigicon")]")
|
||||
. += list("[icon2html(get_cached_flat_icon(), user, extra_classes = "bigicon")]")
|
||||
|
||||
/// Simple helper proc. Returns the source of the icon for this card. Advanced cards can override this to return their icon that has been cached due to using overlays.
|
||||
/obj/item/card/id/proc/get_icon_source()
|
||||
return src
|
||||
/obj/item/card/id/update_overlays()
|
||||
. = ..()
|
||||
|
||||
cached_flat_icon = null
|
||||
|
||||
/// If no cached_flat_icon exists, this proc creates it and crops it. This proc then returns the cached_flat_icon. Intended only for use displaying ID card icons in chat.
|
||||
/obj/item/card/id/proc/get_cached_flat_icon()
|
||||
if(!cached_flat_icon)
|
||||
cached_flat_icon = getFlatIcon(src)
|
||||
cached_flat_icon.Crop(ID_ICON_BORDERS)
|
||||
return cached_flat_icon
|
||||
|
||||
/obj/item/card/id/get_examine_string(mob/user, thats = FALSE)
|
||||
return "[icon2html(get_cached_flat_icon(), user)] [thats? "That's ":""][get_examine_name(user)]"
|
||||
|
||||
/**
|
||||
* Helper proc, checks whether the ID card can hold any given set of wildcards.
|
||||
@@ -688,8 +708,6 @@
|
||||
|
||||
/// An overlay icon state for when the card is assigned to a name. Usually manifests itself as a little scribble to the right of the job icon.
|
||||
var/assigned_icon_state = "assigned"
|
||||
/// Cached icon that has been built for this card.
|
||||
var/icon/cached_flat_icon
|
||||
|
||||
/// If this is set, will manually override the icon file for the trim. Intended for admins to VV edit and chameleon ID cards.
|
||||
var/trim_icon_override
|
||||
@@ -698,23 +716,9 @@
|
||||
/// If this is set, will manually override the trim's assignmment for SecHUDs. Intended for admins to VV edit and chameleon ID cards.
|
||||
var/trim_assignment_override
|
||||
|
||||
/obj/item/card/id/advanced/get_icon_source()
|
||||
return get_cached_flat_icon()
|
||||
|
||||
/// If no cached_flat_icon exists, this proc creates it. This proc then returns the cached_flat_icon.
|
||||
/obj/item/card/id/advanced/proc/get_cached_flat_icon()
|
||||
if(!cached_flat_icon)
|
||||
cached_flat_icon = getFlatIcon(src)
|
||||
return cached_flat_icon
|
||||
|
||||
/obj/item/card/id/advanced/get_examine_string(mob/user, thats = FALSE)
|
||||
return "[icon2html(get_cached_flat_icon(), user)] [thats? "That's ":""][get_examine_name(user)]" //displays all overlays in chat
|
||||
|
||||
/obj/item/card/id/advanced/update_overlays()
|
||||
. = ..()
|
||||
|
||||
cached_flat_icon = null
|
||||
|
||||
if(registered_name && registered_name != "Captain")
|
||||
. += mutable_appearance(icon, assigned_icon_state)
|
||||
|
||||
@@ -1204,3 +1208,4 @@
|
||||
desc = "A card used to identify members of the green team for CTF"
|
||||
icon_state = "ctf_green"
|
||||
|
||||
#undef ID_ICON_BORDERS
|
||||
|
||||
Reference in New Issue
Block a user