PGRData/Resources/Scripts/XUi/XUiMedal/XUiGridCollection.lua
2022-12-26 14:06:01 +05:30

73 lines
No EOL
2.1 KiB
Lua

XUiGridCollection = XClass(nil, "XUiGridCollection")
local XUiCollectionStyle = require("XUi/XUiMedal/XUiCollectionStyle")
function XUiGridCollection:Ctor(ui)
self.GameObject = ui.gameObject
self.Transform = ui.transform
self.CollectionStyleDic = {} -- Key:收藏品Id Value:XUiCollectionStyle脚本
XTool.InitUiObject(self)
self:AutoAddListener()
end
function XUiGridCollection:AutoAddListener()
self.BtnSelect.CallBack = function()
self:OnBtnSelect()
end
end
function XUiGridCollection:OnBtnSelect()
XLuaUiManager.Open("UiCollectionTip", self.Chapter, self.InType)
end
function XUiGridCollection:UpdateGrid(chapter, parent, inType)
self.Chapter = chapter
self.InType = inType
local styleObj = self.CollectionStyleNode.gameObject:LoadPrefab(chapter.PrefabPath)
self.CollectionStyleDic[chapter.Id] = XUiCollectionStyle.New(styleObj, chapter)
if chapter.MedalImg ~= nil then
self.ImgMedalIconlock:SetRawImage(chapter.MedalImg)
end
self.TxtMedalName.text = chapter.Name
local IsLock = chapter.IsLock
local rootUi = parent.Base or parent.RootUi
local qualityImg = XArrangeConfigs.GeQualityPath(chapter.Quality)
if qualityImg then
rootUi:SetUiSprite(self.ImgQuality, qualityImg)
self.ImgQuality.gameObject:SetActiveEx(true)
else
self.ImgQuality.gameObject:SetActiveEx(false)
end
local levelIcon = XDataCenter.MedalManager.GetLevelIcon(chapter.Id, chapter.Quality)
if levelIcon then
rootUi:SetUiSprite(self.ImgLevel, levelIcon)
self.ImgLevel.gameObject:SetActiveEx(true)
else
self.ImgLevel.gameObject:SetActiveEx(false)
end
self:ShowLock(IsLock)
self:ShowRedPoint(XDataCenter.MedalManager.CheckIsNewMedalById(chapter.Id, chapter.Type))
end
function XUiGridCollection:ShowUesing(bShow)
self.LabelPress.gameObject:SetActiveEx(bShow)
end
function XUiGridCollection:ShowLock(Lock)
self.LabelLock.gameObject:SetActiveEx(Lock)
end
function XUiGridCollection:ShowRedPoint(bShow)
if self.Red then
self.Red.gameObject:SetActiveEx(bShow)
end
end