Files
SL1900 5e0d58cfad Initial version - 1.2.0.60
EN: 1.2.0.60
CN: 1.2.0.61
JP: 1.2.0.63
KR: 1.2.0.67
2025-12-03 01:00:00 +09:00

73 lines
2.3 KiB
Lua

local ShopGoodsCtrl = class("ShopGoodsCtrl", BaseCtrl)
ShopGoodsCtrl._mapNodeConfig = {
sv = {
sComponentName = "LoopScrollView"
}
}
ShopGoodsCtrl._mapEventConfig = {
ShopRefreshGoods = "CheckGoodsData"
}
function ShopGoodsCtrl:Open(nShopId, nShopAutoTime)
self.nShopId = nShopId
self.nShopAutoTime = nShopAutoTime
self:CheckGoodsData(true)
end
function ShopGoodsCtrl:CheckGoodsData(bResetPos)
PlayerData.Shop:CheckGoodsData(self.nShopId)
self.tbGoods = PlayerData.Shop:GetGoodsList(self.nShopId)
self:SetTimer()
self:RefreshList(bResetPos)
end
function ShopGoodsCtrl:SetTimer()
if self.timer ~= nil then
self.timer:Cancel(false)
self.timer = nil
end
local nTime = PlayerData.Shop:GetGoodsAutoUpdateTime(self.nShopId)
if 0 < nTime and (self.nShopAutoTime == 0 or nTime < self.nShopAutoTime) then
self.timer = self:AddTimer(1, nTime, function()
EventManager.Hit("ShopCloseDetail")
EventManager.Hit(EventId.CloseMessageBox)
self:CheckGoodsData(true)
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Shop_GoodsRefresh"))
end, true, true, false)
end
end
function ShopGoodsCtrl:RefreshList(bResetPos)
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
self:UnbindCtrlByNode(objCtrl)
self.tbGridCtrl[nInstanceId] = nil
end
self._mapNode.sv:SetAnim(0.04)
self._mapNode.sv:Init(#self.tbGoods, self, self.OnGridRefresh, self.OnGridBtnClick, not bResetPos)
end
function ShopGoodsCtrl:OnGridRefresh(goGrid, gridIndex)
local nIndex = gridIndex + 1
local mapData = self.tbGoods[nIndex]
local nInstanceID = goGrid:GetInstanceID()
if not self.tbGridCtrl[nInstanceID] then
self.tbGridCtrl[nInstanceID] = self:BindCtrlByNode(goGrid, "Game.UI.ShopEx.ShopGoodsItemCtrl")
end
self.tbGridCtrl[nInstanceID]:Refresh(mapData)
end
function ShopGoodsCtrl:OnGridBtnClick(goGrid, gridIndex)
local nIndex = gridIndex + 1
local mapData = self.tbGoods[nIndex]
EventManager.Hit(EventId.OpenPanel, PanelId.ShopPopupPanel, mapData, self.nShopId)
end
function ShopGoodsCtrl:Awake()
self.tbGridCtrl = {}
end
function ShopGoodsCtrl:OnEnable()
end
function ShopGoodsCtrl:OnDisable()
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
self:UnbindCtrlByNode(objCtrl)
self.tbGridCtrl[nInstanceId] = nil
end
self.tbGridCtrl = {}
end
function ShopGoodsCtrl:OnDestroy()
end
return ShopGoodsCtrl