Skip to content

Commit

Permalink
Cached badge icons
Browse files Browse the repository at this point in the history
  • Loading branch information
m-dzianishchyts committed Mar 11, 2024
1 parent b2e008f commit 3ae2c51
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modular_ss220/chat_badges/code/badges.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#define CHAT_BADGES_DMI 'modular_ss220/chat_badges/icons/chatbadges.dmi'

GLOBAL_LIST(badge_icons_cache)

/client/proc/get_ooc_badged_name()
var/donator_badge = get_donator_badge()
var/worker_badge = get_worker_badge()
var/icon/donator_badge_icon = donator_badge ? icon(CHAT_BADGES_DMI, donator_badge) : null
var/icon/worker_badge_icon = worker_badge ? icon(CHAT_BADGES_DMI, worker_badge) : null
var/icon/donator_badge_icon = donator_badge ? get_badge_icon_cached(donator_badge) : null
var/icon/worker_badge_icon = worker_badge ? get_badge_icon_cached(worker_badge) : null

return "[donator_badge_icon ? bicon(donator_badge_icon) : ""][worker_badge_icon ? bicon(worker_badge_icon) : ""][key]"

Expand Down Expand Up @@ -37,4 +39,8 @@
)
return rank_badge_map[holder?.rank]

/proc/get_badge_icon_cached(badge)
LAZYSET(GLOB.badge_icons_cache, badge, icon(CHAT_BADGES_DMI, badge))
return GLOB.badge_icons_cache[badge]

#undef CHAT_BADGES_DMI

0 comments on commit 3ae2c51

Please sign in to comment.