PGRData/Script/matrix/xui/xuiactivitybranch/XUiGridActivityBranchReward.lua

74 lines
No EOL
2.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local CsXTextManager = CS.XTextManager
local XUiGridActivityBranchReward = XClass(nil, "XUiGridActivityBranchReward")
function XUiGridActivityBranchReward:Ctor(ui)
self.GameObject = ui.gameObject
self.Transform = ui.transform
self:InitAutoScript()
self.GridList = {}
end
function XUiGridActivityBranchReward:SetRootUi(rootUi)
self.RootUi = rootUi
end
function XUiGridActivityBranchReward:Refresh(sectionCfg, curSectionId)
local sectionId = sectionCfg.Id
self.TxtSection.text = sectionCfg.Name
self.TxtLevel.text = CsXTextManager.GetText("ActivityBranchCurLevelDes", sectionCfg.MinLevel, sectionCfg.MaxLevel)
self.TxtCur.gameObject:SetActive(curSectionId == sectionId)
self.RootUi:SetUiSprite(self.ImgIcon, sectionCfg.Icon)
--显示的奖励
local rewards = XRewardManager.GetRewardList(sectionCfg.ShowRewardId)
local start = 0
for i, item in ipairs(rewards) do
start = i
local grid
if self.GridList[i] then
grid = self.GridList[i]
else
local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon)
grid = XUiGridCommon.New(self.RootUi, ui)
grid.Transform:SetParent(self.PanelRewards, false)
self.GridList[i] = grid
end
grid:Refresh(item)
grid.GameObject:SetActive(true)
end
for j = start + 1, #self.GridList do
self.GridList[j].GameObject:SetActive(false)
end
end
-- auto
-- Automatic generation of code, forbid to edit
function XUiGridActivityBranchReward:InitAutoScript()
XTool.InitUiObject(self)
self:AutoAddListener()
end
function XUiGridActivityBranchReward:RegisterClickEvent(uiNode, func)
if func == nil then
XLog.Error("XUiGridActivityBranchReward:RegisterClickEvent函数参数错误参数func不能为空")
return
end
if type(func) ~= "function" then
XLog.Error("XUiGridActivityBranchReward:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func))
end
local listener = function(...)
func(self, ...)
end
CsXUiHelper.RegisterClickEvent(uiNode, listener)
end
function XUiGridActivityBranchReward:AutoAddListener()
end
-- auto
return XUiGridActivityBranchReward