74 lines
2.5 KiB
Lua
74 lines
2.5 KiB
Lua
local BaseTips = require "app/ui/tips/base_tips"
|
|
local RewardsTips = class("RewardsTips", BaseTips)
|
|
|
|
function RewardsTips:ctor(params)
|
|
self.params = params
|
|
self.tarCornerScreenPos = params.tarCornerScreenPos
|
|
self.location = params.location
|
|
self.callback = params.callback
|
|
end
|
|
|
|
function RewardsTips:getPrefabPath()
|
|
return "assets/prefabs/ui/tips/rewards_tips.prefab"
|
|
end
|
|
|
|
function RewardsTips:init()
|
|
local uiMap = self.root:genAllChildren()
|
|
self.bg = uiMap["rewards_tips.bg"]
|
|
self.descTx = uiMap["rewards_tips.reward_node.desc"]
|
|
self.rewardNode = uiMap["rewards_tips.reward_node.reward_layout"]
|
|
if not self.rewardCells then
|
|
self.rewardCells = {}
|
|
for i = 1, 3 do
|
|
self.rewardCells[i] = CellManager:addCellComp(uiMap["rewards_tips.bg.reward_node.reward_layout.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
|
end
|
|
end
|
|
end
|
|
|
|
function RewardsTips:onLoadRootComplete()
|
|
self:init()
|
|
local tipsBgTransform = self.bg:getTransform()
|
|
self.originSizeDelta = tipsBgTransform.sizeDelta
|
|
self.originPivot = tipsBgTransform.pivot
|
|
self.originAnchoredPosition = tipsBgTransform.anchoredPosition
|
|
self.originLocalPosition = tipsBgTransform.localPosition
|
|
end
|
|
|
|
function RewardsTips:onRefresh()
|
|
self.root:addClickListener(function ()
|
|
self:closeUI()
|
|
end)
|
|
|
|
self.descTx:setText(self.params.customTitleStr or I18N:getGlobalText(I18N.GlobalConst.REWARD_PREVIEW_DESC))
|
|
if self.params.rewards then
|
|
for i, cell in ipairs(self.rewardCells) do
|
|
if self.params.rewards[i] then
|
|
cell:refreshByConfig(self.params.rewards[i])
|
|
-- cell:addClickListener(function()
|
|
-- ModuleManager.TipsManager:showRewardTips(self.params.rewards[i].id, self.params.rewards[i].type, cell:getBaseObject())
|
|
-- end)
|
|
end
|
|
cell:getBaseObject():setActive(self.params.rewards[i] ~= nil)
|
|
end
|
|
end
|
|
self.rewardNode:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout()
|
|
|
|
if self.tarCornerScreenPos then
|
|
self:locate(self.location, self.originSizeDelta, self.bg, self.tarCornerScreenPos)
|
|
end
|
|
end
|
|
|
|
function RewardsTips:onClose()
|
|
if self.originSizeDelta then
|
|
local tipsBgTransform = self.bg:getTransform()
|
|
tipsBgTransform.sizeDelta = self.originSizeDelta
|
|
tipsBgTransform.pivot = self.originPivot
|
|
tipsBgTransform.anchoredPosition = self.originAnchoredPosition
|
|
tipsBgTransform.localPosition = self.originLocalPosition
|
|
end
|
|
if self.callback then
|
|
self.callback()
|
|
end
|
|
end
|
|
|
|
return RewardsTips |