110 lines
2.6 KiB
Lua
110 lines
2.6 KiB
Lua
-- 能量包
|
|
|
|
local GroupFastGamesView = {}
|
|
|
|
local M = GroupFastGamesView
|
|
|
|
function GroupFastGamesView.new(gid, blur_view, playIdList, uid)
|
|
setmetatable(M, { __index = BaseWindow })
|
|
local self = setmetatable({}, { __index = M })
|
|
|
|
self.class = "GroupFastGamesView"
|
|
self._close_destroy = true
|
|
self.group_id = gid
|
|
self.blur_view = blur_view
|
|
self.playIdList = playIdList
|
|
self.allplays_data = {}
|
|
self.uid = uid
|
|
self.showid = 0
|
|
self:init("ui://NewGroup/Win_SelectGames")
|
|
self:FillView()
|
|
return self
|
|
end
|
|
|
|
|
|
function M:FillView()
|
|
--lst_allplays
|
|
self.showid = Utils.LoadLocalFile("selectplay"..self.uid)
|
|
|
|
self.lst_allplays = self._view:GetChild("lst_allplays")
|
|
self.lst_allplays:SetVirtual()
|
|
self.lst_allplays.itemRenderer = function(index, obj)
|
|
self:OnRenderAllPlaysItem(index, obj, self.showid)
|
|
end
|
|
printlog(self.showid)
|
|
self:GetFlagPlaysData(self.showid)
|
|
end
|
|
|
|
-- 获取快速开始设置数据
|
|
function M:GetFlagPlaysData(showid)
|
|
|
|
local allplays = self.playIdList
|
|
self.allplays_data = allplays
|
|
local tmp = {}
|
|
for i=1,#allplays do
|
|
if showid==allplays[i].id.."" then
|
|
tmp = self.allplays_data[1]
|
|
self.allplays_data[1] = self.allplays_data[i]
|
|
self.allplays_data[i] = tmp
|
|
end
|
|
end
|
|
self.lst_allplays.numItems = #self.allplays_data
|
|
|
|
end
|
|
|
|
function M:OnRenderAllPlaysItem(index, obj,showid)
|
|
|
|
local data = self.allplays_data[index+1]
|
|
local exconfig = ExtendManager.GetExtendConfig(data.gameId)
|
|
local datajson = json.decode(data.config)
|
|
local r = {}
|
|
exconfig:FillRoomConfig(r, datajson)
|
|
local gameStr = ""
|
|
gameStr = string.gsub(r.room_config:GetDes(), "\r", "")
|
|
obj:GetChild("tex_name").text = data.name
|
|
obj:GetChild("tex_display").text = gameStr
|
|
|
|
if showid~=nil then
|
|
if data.id.."" == showid then
|
|
obj:GetChild("gxbtn").selected = true
|
|
else
|
|
obj:GetChild("gxbtn").selected = false
|
|
end
|
|
end
|
|
|
|
obj:GetChild("gxbtn").onClick:Set(function()
|
|
self:SelectPlaysItem(data.id,index+1,data.name)
|
|
end)
|
|
--obj:GetChild("gxbtn").selected =
|
|
end
|
|
|
|
function M:SelectPlaysItem(id,index,gamename)
|
|
self.lst_allplays = self._view:GetChild("lst_allplays")
|
|
Utils.SaveLocalFile("selectplay"..self.uid, id)
|
|
Utils.SaveLocalFile("selectplayname"..self.uid, gamename)
|
|
for key, value in pairs(self.playIdList) do
|
|
if key==index then
|
|
self.playIdList[index].show = true
|
|
else
|
|
self.playIdList[key].show = false
|
|
end
|
|
end
|
|
self:FillView()
|
|
|
|
end
|
|
|
|
function M:SetCallback(callback)
|
|
self.callback = callback
|
|
end
|
|
|
|
-- 销毁窗口
|
|
function M:Destroy(remove_map)
|
|
if self.callback then
|
|
self.callback()
|
|
end
|
|
BaseWindow.Destroy(self, remove_map)
|
|
ImageLoad.Clear(self.class)
|
|
end
|
|
|
|
return M
|