-- 能量包 local GroupFastGamesView = {} local M = GroupFastGamesView function GroupFastGamesView.new(gid, blur_view, playIdList) 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 = DataManager.SelfUser.account_id 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 self:GetFlagPlaysData(self.showid) end -- 获取快速开始设置数据 function M:GetFlagPlaysData(showid) local allplays = self.playIdList self.allplays_data = allplays table.sort(self.allplays_data, handler(self, self.SortPlayList)) -- 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() if self.callback then self.callback() end self:Destroy() end function M:SetCallback(callback) self.callback = callback end function M:SortPlayList(a, b) local a_play = a local b_play = b if a_play.gameType == b_play.gameType then if a_play.gameId == a_play.gameId then return a_play.id > b_play.id else return a_play.gameId > b_play.gameId end else return a_play.gameType > b_play.gameType end 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