Item: update rarity description display
This commit is contained in:
@@ -19,7 +19,7 @@ local ItemFactory = Smc.requireItemFactory()
|
|||||||
local TITLE_RARITY_COLOR = true
|
local TITLE_RARITY_COLOR = true
|
||||||
|
|
||||||
---Shows rarity on a separate line.
|
---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.
|
---Determines whether common rarity will be shown in item descriptions or not.
|
||||||
local SHOW_COMMON_RARITY = true
|
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
|
---Returns an item description pattern in accordance
|
||||||
---with global rarity display settings.
|
---with global rarity display settings.
|
||||||
---@param rarity Item.Rarity
|
---@param rarity Item.Rarity
|
||||||
---@return string
|
---@param descColor ColorString
|
||||||
local function getDescPattern(rarity)
|
---@return string
|
||||||
if not SHOW_RARITY then
|
local function getDescPattern(rarity, descColor)
|
||||||
return DESC_PATTERNS[1]
|
if not SHOW_RARITY or (not SHOW_COMMON_RARITY and rarity == 'common') then
|
||||||
|
return '{title}\n {desc}'
|
||||||
end
|
end
|
||||||
|
|
||||||
if not SHOW_COMMON_RARITY and rarity == 'common' then
|
return '{title}\n {desc}\n\n '..
|
||||||
return DESC_PATTERNS[1]
|
coreColorize(descColor, coreTranslate('item', 'Rarity')..': ')..'{rarity_title}'
|
||||||
end
|
|
||||||
|
|
||||||
return DESC_PATTERNS[2]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param itemDef Item.ItemDefinition
|
---@param itemDef Item.ItemDefinition
|
||||||
@@ -120,7 +113,7 @@ local function itemDefToLuantiDef(itemDef)
|
|||||||
s._description = description
|
s._description = description
|
||||||
s._rarity_title = rarityTitle
|
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
|
s.description = luantiDescription..ITEM_DESC_BACKGROUND_ESCAPE_SEQ
|
||||||
|
|
||||||
local luantiDef = tableMerge(s, c, true) --[[@as ItemDefinition]]
|
local luantiDef = tableMerge(s, c, true) --[[@as ItemDefinition]]
|
||||||
|
|||||||
Reference in New Issue
Block a user