From 503af2db4daf781173d9f248c6a24d8acd6008ed Mon Sep 17 00:00:00 2001 From: varttist Date: Thu, 19 Nov 2026 21:32:29 +0300 Subject: [PATCH] `Item`: update rarity description display --- mods/CORE/Item/src/Item.lua | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/mods/CORE/Item/src/Item.lua b/mods/CORE/Item/src/Item.lua index a432998..7b5113d 100644 --- a/mods/CORE/Item/src/Item.lua +++ b/mods/CORE/Item/src/Item.lua @@ -19,7 +19,7 @@ local ItemFactory = Smc.requireItemFactory() local TITLE_RARITY_COLOR = true ---Shows rarity on a separate line. -local SHOW_RARITY = false +local SHOW_RARITY = true ---Determines whether common rarity will be shown in item descriptions or not. local SHOW_COMMON_RARITY = true @@ -59,25 +59,18 @@ local Item = Class:extend({ } }) -local DESC_PATTERNS = { - [1] = '{title}\n {desc}', - [2] = '{title}\n {desc}\n{rarity_title}' -} - ---Returns an item description pattern in accordance ---with global rarity display settings. ----@param rarity Item.Rarity ----@return string -local function getDescPattern(rarity) - if not SHOW_RARITY then - return DESC_PATTERNS[1] +---@param rarity Item.Rarity +---@param descColor ColorString +---@return string +local function getDescPattern(rarity, descColor) + if not SHOW_RARITY or (not SHOW_COMMON_RARITY and rarity == 'common') then + return '{title}\n {desc}' end - if not SHOW_COMMON_RARITY and rarity == 'common' then - return DESC_PATTERNS[1] - end - - return DESC_PATTERNS[2] + return '{title}\n {desc}\n\n '.. + coreColorize(descColor, coreTranslate('item', 'Rarity')..': ')..'{rarity_title}' end ---@param itemDef Item.ItemDefinition @@ -120,7 +113,7 @@ local function itemDefToLuantiDef(itemDef) s._description = description s._rarity_title = rarityTitle - local luantiDescription = smcConcatItemDescription(s, nil, getDescPattern(s._rarity)) + local luantiDescription = smcConcatItemDescription(s, nil, getDescPattern(s._rarity, s._description_color)) s.description = luantiDescription..ITEM_DESC_BACKGROUND_ESCAPE_SEQ local luantiDef = tableMerge(s, c, true) --[[@as ItemDefinition]]