Compare commits
3 Commits
e98935cf6f
...
44916bcd3b
| Author | SHA1 | Date | |
|---|---|---|---|
| 44916bcd3b | |||
| 3483cd650a | |||
| c4104a1834 |
@@ -24,7 +24,6 @@ function BaseUI:new(name, getFormSpecString, clearContex)
|
||||
instance.getFormSpecString = getFormSpecString
|
||||
|
||||
if clearContex then
|
||||
core.log(name)
|
||||
-- Ensure that when the form is closed, the context is cleared.
|
||||
instance:registerOnFormQuit(function(player)
|
||||
instance:clearContex(player)
|
||||
|
||||
@@ -4,6 +4,14 @@ local tableCopy, tableMerge, colorize = table.copy, table.merge, core.colorize
|
||||
|
||||
local ItemFactory = Smc.requireItemFactory()
|
||||
|
||||
---Colors the title according to the rarity of the item.
|
||||
---
|
||||
---Note: that if `true`, the `_title_color` will be ignored.
|
||||
local TITLE_RARITY_COLOR = true
|
||||
|
||||
---Shows rarity on a separate line.
|
||||
local SHOW_RARITY = false
|
||||
|
||||
---Determines whether common rarity will be shown in item descriptions or not.
|
||||
local SHOW_COMMON_RARITY = true
|
||||
|
||||
@@ -57,6 +65,10 @@ local Item = {
|
||||
---@param desc string
|
||||
---@return string
|
||||
local function addRarityToDesc(rarity, desc)
|
||||
if not SHOW_RARITY then
|
||||
return desc
|
||||
end
|
||||
|
||||
if not SHOW_COMMON_RARITY and rarity == 'common' then
|
||||
return desc
|
||||
end
|
||||
@@ -98,15 +110,19 @@ local function itemDefToLuantiDef(itemDef)
|
||||
description = string.match(s.name, '%S:(%S+)')..'-desc'
|
||||
end
|
||||
|
||||
assert(s._rarity ~= nil, 'The rarity of an item cannot be empty.')
|
||||
|
||||
if s._title_color ~= nil and s._description_color ~= nil then
|
||||
title = colorize(s._title_color , S(title))
|
||||
if TITLE_RARITY_COLOR then
|
||||
title = colorize(RARITY_COLORS[s._rarity], S(title))
|
||||
else
|
||||
title = colorize(s._title_color, S(title))
|
||||
end
|
||||
description = colorize(s._description_color, S(description))
|
||||
else
|
||||
error('Item description color parameters cannot be empty.')
|
||||
end
|
||||
|
||||
assert(s._rarity ~= nil, 'The rarity of an item cannot be empty.')
|
||||
|
||||
local luantiDescription = addRarityToDesc(s._rarity, title..'\n '..description)
|
||||
|
||||
s._title = title
|
||||
|
||||
@@ -64,3 +64,26 @@ function Smc.requireFormspec()
|
||||
return class
|
||||
end
|
||||
|
||||
---@return CraftSystem
|
||||
function Smc.requireCraftSystem()
|
||||
---@type CraftSystem
|
||||
local class = Mod.getInfo('smc__core__craft_system').require('CraftSystem')
|
||||
|
||||
return class
|
||||
end
|
||||
|
||||
---@return CraftSystem.PrimitiveCraftHandler
|
||||
function Smc.requireCraftSystemPrimitiveCraftHandler()
|
||||
---@type CraftSystem.PrimitiveCraftHandler
|
||||
local class = Mod.getInfo('smc__core__craft_system').require('CraftSystem.PrimitiveCraftHandler')
|
||||
|
||||
return class
|
||||
end
|
||||
|
||||
---@return CraftSystem.ImmersiveCraftHandler
|
||||
function Smc.requireCraftSystemImmersiveCraftHandler()
|
||||
---@type CraftSystem.ImmersiveCraftHandler
|
||||
local class = Mod.getInfo('smc__core__craft_system').require('CraftSystem.ImmersiveCraftHandler')
|
||||
|
||||
return class
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user