PGRData/Script/matrix/xui/xuishop/XUiShopWaferSelect.lua

88 lines
3.5 KiB
Lua
Raw Normal View History

2024-09-01 20:49:41 +00:00
--[[
v1.29
-
1
2
3-
4
5
654
7
825
--]]
local XUiShopWaferSelect = XLuaUiManager.Register(XLuaUi, "UiShopWaferSelect")
function XUiShopWaferSelect:OnAwake()
self:InitComponent()
self:InitDynamicTable()
end
function XUiShopWaferSelect:OnStart(SelectData, dataProvider, selectCallBack)
self.DataProvider = dataProvider
self.SelectCallBack = selectCallBack
self.CurData = SelectData
self:UpdateGridList()
end
function XUiShopWaferSelect:InitComponent()
self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end
self.BtnClose.CallBack = function() self:OnBtnCloseClick() end
self.BtnCancel.CallBack = function() self:OnBtnCloseClick() end
self.BtnTanchuangClose.CallBack = function() self:OnBtnCloseClick() end
self.GridSuitSimple.gameObject:SetActiveEx(false)
end
function XUiShopWaferSelect:InitDynamicTable()
self.DynamicTable = XDynamicTableNormal.New(self.PanelSelectList.gameObject)
self.DynamicTable:SetDelegate(self)
self.DynamicTable:SetProxy(require("XUi/XUiShop/XUiShopWaferSelectGrid"))
end
function XUiShopWaferSelect:OnDynamicTableEvent(event, index, grid)
if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then
grid:Init(self)
elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then
local data = self.DataProvider[index]
self:UpdateGrid(grid, data)
elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then
local data = self.DataProvider[index]
self:OnGridClick(data)
end
end
function XUiShopWaferSelect:OnGridClick(data)
self.CurData = data
for k, v in ipairs(self.DataProvider) do
local grid = self.DynamicTable:GetGridByIndex(k)
if grid then
self:UpdateGrid(grid, v)
end
end
end
function XUiShopWaferSelect:UpdateGrid(grid, data)
if data then
local isSelected = self.CurData == data
grid:Refresh(data, isSelected)
end
end
function XUiShopWaferSelect:UpdateGridList()
self.ImgEmpty.gameObject:SetActiveEx(not self.DataProvider or #self.DataProvider == 0)
self.DynamicTable:SetDataSource(self.DataProvider)
self.DynamicTable:ReloadDataASync()
end
function XUiShopWaferSelect:OnBtnConfirmClick()
if self.SelectCallBack then
self.SelectCallBack(self.CurData)
end
self:Close()
end
function XUiShopWaferSelect:OnBtnCloseClick()
self:Close()
end
return XUiShopWaferSelect