hengyang_client/lua_probject/base_project/Game/View/NewGroup/GroupSelectPlayView.lua

60 lines
1.3 KiB
Lua

--牌友圈选择玩法View
local GroupSelectPlayView = {}
local M = GroupSelectPlayView
function GroupSelectPlayView.new(blur_view, curGroup, i)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "GroupSelectPlayView"
self._close_destroy = true
self._blur_view = blur_view
self.curGroup = curGroup
self:init("ui://NewGroup/Win_SelectGame")
self:FillView(i)
return self
end
function M:FillView(i)
self.lst_game = self._view:GetChild("lst_game")
self.lst_game:SetVirtual()
self.lst_game.itemRenderer = function(index, obj)
self:OnRenderItem(index, obj)
end
self.lst_game.numItems = #self.curGroup.playList + 1
self.lst_game.selectedIndex = i
end
function M:OnRenderItem(index, obj)
if index == 0 then
obj.title = "全部"
else
local play = self.curGroup.playList[index]
obj.title = play.name
end
obj.onClick:Set(function()
if self.lst_game.selectedIndex ~= index then
self._update = index
end
self:Destroy()
end)
end
function M:SetCallback(callback)
self.callback = callback
end
-- 销毁窗口
function M:Destroy(remove_map)
if self._update then
self.callback(self._update)
else
self.callback()
end
BaseWindow.Destroy(self,remove_map)
end
return M