119 lines
2.9 KiB
Lua
119 lines
2.9 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"]
|
|
self.fragment = uiMap["reward_cell.item_bg.fragment"]
|
|
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.id
|
|
end
|
|
if id then
|
|
self:addClickListener(function()
|
|
local desc = self:getRewardDesc(id, reward.type)
|
|
ModuleManager.TipsManager:showDescTips(desc, 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
|
|
end
|
|
|
|
if id then
|
|
self:addClickListener(function()
|
|
local desc = self:getRewardDesc(id, reward.type)
|
|
ModuleManager.TipsManager:showDescTips(desc, self.baseObject)
|
|
end)
|
|
end
|
|
end
|
|
|
|
function RewardCell:_refreshItem(item)
|
|
local info = ConfigManager:getConfig("item")[item.id]
|
|
if info == nil then
|
|
return
|
|
end
|
|
self.numTx:setVisible(true)
|
|
self.frameBg:setSprite(GConst.ATLAS_PATH.ICON_ITEM, GConst.FRAME_QLT[info.qlt])
|
|
self.numTx:setText(item.count or item.num)
|
|
if info.type == GConst.ItemConst.ITEM_TYPE.HERO_FRAGMENT then
|
|
local heroInfo = ConfigManager:getConfig("hero")[info.parameter]
|
|
if heroInfo then
|
|
self.icon:setLocalScale(0.86, 0.86, 0.86)
|
|
self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, heroInfo.icon)
|
|
else
|
|
self.icon:setSprite(GConst.ATLAS_PATH.COMMON, "common_alpha")
|
|
end
|
|
self.fragment:setVisible(true)
|
|
else
|
|
self.icon:setLocalScale(1, 1, 1)
|
|
self.icon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, info.icon)
|
|
self.fragment:setVisible(false)
|
|
end
|
|
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
|
|
|
|
function RewardCell:getRewardDesc(id, rewardType)
|
|
if rewardType == GConst.REWARD_TYPE.ITEM then
|
|
local item18NInfo = I18N:getConfig("item")[id]
|
|
if item18NInfo then
|
|
return item18NInfo.desc
|
|
end
|
|
end
|
|
return GConst.EMPTY_STRING
|
|
end
|
|
|
|
return RewardCell |