From 4d2dd19a5870f086d5fb683ca071b51b7ca85c01 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 26 Mar 2021 23:21:37 +0100 Subject: [PATCH] [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 --- code/game/objects/items/cards_ids.dm | 45 ++++++++++--------- code/modules/economy/account.dm | 4 +- .../mob/living/carbon/human/examine.dm | 4 -- .../tgui-panel/styles/goon/chat-dark.scss | 2 +- .../tgui-panel/styles/goon/chat-light.scss | 3 +- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/code/game/objects/items/cards_ids.dm b/code/game/objects/items/cards_ids.dm index 000e49220d4..5a532818419 100644 --- a/code/game/objects/items/cards_ids.dm +++ b/code/game/objects/items/cards_ids.dm @@ -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 diff --git a/code/modules/economy/account.dm b/code/modules/economy/account.dm index 9a43e0fc1c2..de954d828dd 100644 --- a/code/modules/economy/account.dm +++ b/code/modules/economy/account.dm @@ -103,8 +103,8 @@ return for(var/obj/A in bank_cards) var/icon_source = A - if(istype(A, /obj/item/card/id/advanced)) - var/obj/item/card/id/advanced/id_card = A + if(istype(A, /obj/item/card/id)) + var/obj/item/card/id/id_card = A icon_source = id_card.get_cached_flat_icon() var/mob/card_holder = recursive_loc_check(A, /mob) if(ismob(card_holder)) //If on a mob diff --git a/code/modules/mob/living/carbon/human/examine.dm b/code/modules/mob/living/carbon/human/examine.dm index 224f88f3201..f70a9f0f070 100644 --- a/code/modules/mob/living/carbon/human/examine.dm +++ b/code/modules/mob/living/carbon/human/examine.dm @@ -112,10 +112,6 @@ . += "[t_He] [t_is] wearing [wear_id.get_examine_string(user)]." . += wear_id.get_id_examine_strings(user) - //var/list/extended_id_examine = wear_id.get_id_examine_strings(user) - - //for(var/examine_string in extended_id_examine) - // . += examine_string //Status effects var/list/status_examines = status_effect_examines() diff --git a/tgui/packages/tgui-panel/styles/goon/chat-dark.scss b/tgui/packages/tgui-panel/styles/goon/chat-dark.scss index 3393be1d9f5..497bc790b04 100644 --- a/tgui/packages/tgui-panel/styles/goon/chat-dark.scss +++ b/tgui/packages/tgui-panel/styles/goon/chat-dark.scss @@ -783,7 +783,7 @@ em { } .bigicon { - font-size: 5em; + font-size: 2.5em; } .memo { diff --git a/tgui/packages/tgui-panel/styles/goon/chat-light.scss b/tgui/packages/tgui-panel/styles/goon/chat-light.scss index 92d82015452..386e8b92511 100644 --- a/tgui/packages/tgui-panel/styles/goon/chat-light.scss +++ b/tgui/packages/tgui-panel/styles/goon/chat-light.scss @@ -823,8 +823,7 @@ h1.alert, h2.alert { } .bigicon { - height: 4em; - width: auto; + font-size: 2.5em; } .memo {