PGRData/Script/matrix/xui/xuifubenmainlinebanner/XUiPanelChapterBfrt.lua

51 lines
1.8 KiB
Lua
Raw Normal View History

local XUiGridChapterBfrt = require("XUi/XUiFubenMainLineBanner/XUiGridChapterBfrt")
local XUiPanelChapterBfrt = XClass(nil, "XUiPanelChapterBfrt")
function XUiPanelChapterBfrt:Ctor(ui, rootUi)
self.GameObject = ui.gameObject
self.Transform = ui.transform
self.RootUi = rootUi
XTool.InitUiObject(self)
self:InitDynamicTable()
end
function XUiPanelChapterBfrt:InitDynamicTable()
self.ChapterDynamicTable = XDynamicTableNormal.New(self.GameObject)
self.ChapterDynamicTable:SetProxy(XUiGridChapterBfrt)
self.ChapterDynamicTable:SetDelegate(self)
end
--动态列表事件
function XUiPanelChapterBfrt:OnDynamicTableEvent(event, index, grid)
if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then
if self.ChapterIds[index] then
grid:RefreshDatas(self.ChapterIds[index])
end
elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then
self:OnChapterCoverClick(self.ChapterIds[index])
elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then
XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT)
end
end
-- 章节点击事件
function XUiPanelChapterBfrt:OnChapterCoverClick(chapterId)
local doneCb = function()
local chapterCfg = XDataCenter.BfrtManager.GetChapterCfg(chapterId)
self.RootUi:PushUi(function()
XLuaUiManager.Open("UiFubenMainLineChapter", chapterCfg, nil, true)
end)
end -- doneCb
XDataCenter.DlcManager.CheckDownloadForEntry(XDlcConfig.EntryType.Bfrt, chapterId, doneCb)
end
-- 设置数据
function XUiPanelChapterBfrt:SetupBfrtChapters()
self.ChapterIds = self.ChapterIds or XDataCenter.BfrtManager.GetChapterList()
self.ChapterDynamicTable:SetDataSource(self.ChapterIds)
self.ChapterDynamicTable:ReloadDataASync()
end
return XUiPanelChapterBfrt