84 lines
2.3 KiB
Lua
84 lines
2.3 KiB
Lua
local ItemCell = class("ItemCell", BaseCell)
|
|
|
|
function ItemCell:refresh(entity)
|
|
local uiMap = self:getUIMap()
|
|
local icon = uiMap["item_cell.icon"]
|
|
local num = uiMap["item_cell.num"]
|
|
local bg = uiMap["item_cell.bg"]
|
|
local mask = uiMap["item_cell.mask"]
|
|
local check = uiMap["item_cell.check"]
|
|
local lock = uiMap["item_cell.lock"]
|
|
local rarityIcon = uiMap["item_cell.rarity_icon"]
|
|
|
|
local rarity = entity:getRarity()
|
|
if rarity then
|
|
rarityIcon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, "frame_ssr_" .. rarity)
|
|
end
|
|
rarityIcon:setVisible(rarity ~= nil)
|
|
icon:setSprite(entity:getIconRes())
|
|
bg:setSprite(entity:getFrameRes())
|
|
bg:setSprite(GConst.ATLAS_PATH.ICON_ITEM, "frame_" .. entity:getQuality())
|
|
num:setText(GFunc.num2Str(entity:getCount()))
|
|
mask:setVisible(false)
|
|
check:setVisible(false)
|
|
lock:setVisible(false)
|
|
end
|
|
|
|
function ItemCell:refreshByCfg(id, count)
|
|
local uiMap = self:getUIMap()
|
|
local icon = uiMap["item_cell.icon"]
|
|
local num = uiMap["item_cell.num"]
|
|
local bg = uiMap["item_cell.bg"]
|
|
local mask = uiMap["item_cell.mask"]
|
|
local check = uiMap["item_cell.check"]
|
|
local lock = uiMap["item_cell.lock"]
|
|
local rarityIcon = uiMap["item_cell.rarity_icon"]
|
|
|
|
local cfg = ConfigManager:getConfig("item")[id]
|
|
local rarity = cfg.rarity
|
|
if rarity then
|
|
rarityIcon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, "frame_ssr_" .. rarity)
|
|
end
|
|
rarityIcon:setVisible(rarity ~= nil)
|
|
icon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, cfg.icon)
|
|
bg:setSprite(GConst.ATLAS_PATH.ICON_ITEM, "frame_" .. cfg.qlt)
|
|
num:setText(GFunc.num2Str(count))
|
|
mask:setVisible(false)
|
|
check:setVisible(false)
|
|
lock:setVisible(false)
|
|
end
|
|
|
|
function ItemCell:setTouchEnable(enable)
|
|
self:getBaseObject():setTouchEnable(enable == true)
|
|
end
|
|
|
|
function ItemCell:addClickListener(func)
|
|
self:getBaseObject():addClickListener(func)
|
|
end
|
|
|
|
function ItemCell:showMask(showMask)
|
|
local uiMap = self:getUIMap()
|
|
local mask = uiMap["item_cell.mask"]
|
|
mask:setVisible(showMask == true)
|
|
end
|
|
|
|
function ItemCell:showCheck(showCheck)
|
|
local uiMap = self:getUIMap()
|
|
local check = uiMap["item_cell.check"]
|
|
check:setVisible(showCheck == true)
|
|
end
|
|
|
|
function ItemCell:showLock(showLock)
|
|
local uiMap = self:getUIMap()
|
|
local lock = uiMap["item_cell.lock"]
|
|
lock:setVisible(showLock == true)
|
|
end
|
|
|
|
function ItemCell:setNum(numStr)
|
|
local uiMap = self:getUIMap()
|
|
local num = uiMap["item_cell.num"]
|
|
num:setText(numStr)
|
|
end
|
|
|
|
return ItemCell
|