PGRData/Resources/Scripts/XUi/XUiNewPlayerTask/XUiBtnNewbieTaskTab.lua

76 lines
2.6 KiB
Lua
Raw Normal View History

2022-12-26 08:36:01 +00:00
XUiBtnNewbieTaskTab = XClass(nil, "XUiBtnNewbieTaskTab")
function XUiBtnNewbieTaskTab:Ctor(ui, rootUi, tabInfos)
self.GameObject = ui.gameObject
self.Transform = ui.transform
self.RootUi = rootUi
self.TabInfos = tabInfos
self:InitAutoScript()
self:OnRefreshView()
end
-- auto
-- Automatic generation of code, forbid to edit
function XUiBtnNewbieTaskTab:InitAutoScript()
self:AutoInitUi()
self:AutoAddListener()
end
function XUiBtnNewbieTaskTab:AutoInitUi()
self.BtnNewbieTaskTab = self.Transform:GetComponent("Button")
self.ImgDefault = self.Transform:Find("ImgDefault"):GetComponent("Image")
self.TxtDayDefault = self.Transform:Find("TxtDayDefault"):GetComponent("Text")
self.ImgSelected = self.Transform:Find("ImgSelected"):GetComponent("Image")
self.TxtDaySelected = self.Transform:Find("ImgSelected/TxtDaySelected"):GetComponent("Text")
self.ImgReddot = self.Transform:Find("ImgReddot"):GetComponent("Image")
self.ImgLock = self.Transform:Find("ImgLock"):GetComponent("Image")
end
function XUiBtnNewbieTaskTab:RegisterClickEvent(uiNode, func)
if func == nil then
XLog.Error("XUiBtnNewbieTaskTab:RegisterClickEvent函数参数错误参数func不能为空")
return
end
if type(func) ~= "function" then
XLog.Error("XUiBtnNewbieTaskTab:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func))
end
local listener = function(...)
func(self, ...)
end
CsXUiHelper.RegisterClickEvent(uiNode, listener)
end
function XUiBtnNewbieTaskTab:AutoAddListener()
self:RegisterClickEvent(self.BtnNewbieTaskTab, self.OnBtnNewbieTaskTabClick)
end
-- auto
function XUiBtnNewbieTaskTab:OnBtnNewbieTaskTabClick()
end
function XUiBtnNewbieTaskTab:OnSelectDayTab(isSelect)
self.ImgSelected.gameObject:SetActive(isSelect)
end
function XUiBtnNewbieTaskTab:OnRefreshView()
self.TxtDayDefault.text = CS.XTextManager.GetText("NewbieDayTab1", self.TabInfos.OpenDay)
self.TxtDaySelected.text = CS.XTextManager.GetText("NewbieDayTab1", self.TabInfos.OpenDay)
local isCurrentLock = self:IsCurrentLock()
self.ImgLock.gameObject:SetActive(isCurrentLock)
if isCurrentLock then
self.ImgReddot.gameObject:SetActive(false)
else
self.ImgReddot.gameObject:SetActive(XDataCenter.TaskManager.GetNewbiePlayTaskReddotByOpenDay(self.TabInfos.OpenDay))
end
end
function XUiBtnNewbieTaskTab:IsCurrentLock()
if XPlayer.NewPlayerTaskActiveDay == nil then return true end
return self.TabInfos.OpenDay > XPlayer.NewPlayerTaskActiveDay
end
return XUiBtnNewbieTaskTab