113 lines
2.7 KiB
Lua
113 lines
2.7 KiB
Lua
local RewardCell = class("RewardCell", BaseCell)
|
|
|
|
function RewardCell:init()
|
|
local uiMap = self:getUIMap()
|
|
self.icon = uiMap["reward_cell.item_bg.icon"]
|
|
self.frameBg = uiMap["reward_cell.item_bg"]
|
|
self.mask = uiMap["reward_cell.item_bg.mask"]
|
|
self.check = uiMap["reward_cell.check"]
|
|
self.numTx = uiMap["reward_cell.item_bg.num"]
|
|
end
|
|
|
|
function RewardCell:refresh(reward)
|
|
self:showMask(false, false)
|
|
local id
|
|
if reward.type == GConst.REWARD_TYPE.ITEM then
|
|
self:_refreshItem(reward.item)
|
|
id = reward.item.cfg_id or reward.item.id
|
|
-- elseif reward.type == GConst.REWARD_TYPE.EQUIP then
|
|
-- self:_refreshEquip(reward.equip)
|
|
-- id = reward.equip.id
|
|
end
|
|
|
|
if id then
|
|
self:addClickListener(function()
|
|
ModuleManager.TipsManager:showRewardTips(id, reward.type, self.baseObject)
|
|
end)
|
|
end
|
|
end
|
|
|
|
function RewardCell:refreshByConfig(reward, mask, check)
|
|
self:showMask(mask, check)
|
|
self:showCheck(false)
|
|
local id
|
|
if reward.type == GConst.REWARD_TYPE.ITEM then
|
|
self:_refreshItem(reward)
|
|
id = reward.id
|
|
elseif reward.type == GConst.REWARD_TYPE.EQUIP then
|
|
-- self:_refreshEquip(reward)
|
|
-- id = reward.id
|
|
end
|
|
|
|
if id then
|
|
self:addClickListener(function()
|
|
ModuleManager.TipsManager:showRewardTips(id, reward.type, self.baseObject)
|
|
end)
|
|
end
|
|
end
|
|
|
|
function RewardCell:_refreshItem(item)
|
|
local info = ConfigManager:getConfig("item")[item.cfg_id or item.id]
|
|
if info == nil then
|
|
return
|
|
end
|
|
|
|
self.numTx:setVisible(true)
|
|
self.frameBg:setSprite(GConst.ATLAS_PATH.ICON_ITEM, "frame_0")
|
|
self.icon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, info.icon)
|
|
self.numTx:setText(item.count or item.num)
|
|
end
|
|
|
|
function RewardCell:_refreshEquip(equip)
|
|
local info = ConfigManager:getConfig("equip")[equip.id]
|
|
if info == nil then
|
|
return
|
|
end
|
|
|
|
self.numTx:setVisible(true)
|
|
self.frameBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. info.qlt)
|
|
self.icon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, tostring(info.icon))
|
|
self.numTx:setText(equip.count)
|
|
end
|
|
|
|
function RewardCell:showNumTx(str)
|
|
self.numTx:setText(str)
|
|
end
|
|
|
|
function RewardCell:showNumTx(value)
|
|
self.numTx:setText(value)
|
|
end
|
|
|
|
function RewardCell:showMask(show, syncCheck)
|
|
self.mask:setVisible(show == true)
|
|
self:showCheck(syncCheck)
|
|
end
|
|
|
|
function RewardCell:hideCountTx()
|
|
end
|
|
|
|
function RewardCell:showCheck(show)
|
|
self.check:setVisible(show == true)
|
|
end
|
|
|
|
function RewardCell:setVisible(visible)
|
|
self.baseObject:setActive(visible)
|
|
end
|
|
|
|
function RewardCell:setAnchoredPositionX(x)
|
|
self.baseObject:setAnchoredPositionX(x)
|
|
end
|
|
|
|
function RewardCell:setTouchEnable(enable)
|
|
self.baseObject:setTouchEnable(enable)
|
|
end
|
|
|
|
function RewardCell:addClickListener(func)
|
|
self.baseObject:addClickListener(func)
|
|
end
|
|
|
|
function RewardCell:setLocalScale(x, y, z)
|
|
self.baseObject:setLocalScale(x, y, z)
|
|
end
|
|
|
|
return RewardCell |