2025-06-30 08:39:00 +08:00
|
|
|
-- 能量包
|
|
|
|
|
|
|
|
|
|
local GroupFastGamesView = {}
|
|
|
|
|
|
|
|
|
|
local M = GroupFastGamesView
|
|
|
|
|
|
2025-07-26 04:49:56 +08:00
|
|
|
function GroupFastGamesView.new(gid, blur_view, playIdList)
|
|
|
|
|
setmetatable(M, { __index = BaseWindow })
|
|
|
|
|
local self = setmetatable({}, { __index = M })
|
2025-06-30 08:39:00 +08:00
|
|
|
|
2025-07-26 04:49:56 +08:00
|
|
|
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
|
2025-06-30 08:39:00 +08:00
|
|
|
|
|
|
|
|
function M:FillView()
|
2025-07-26 04:49:56 +08:00
|
|
|
--lst_allplays
|
|
|
|
|
self.showid = Utils.LoadLocalFile("selectplay" .. self.uid)
|
|
|
|
|
|
|
|
|
|
self.lst_allplays = self._view:GetChild("lst_allplays")
|
2025-06-30 08:39:00 +08:00
|
|
|
self.lst_allplays:SetVirtual()
|
|
|
|
|
self.lst_allplays.itemRenderer = function(index, obj)
|
2025-07-26 04:49:56 +08:00
|
|
|
self:OnRenderAllPlaysItem(index, obj, self.showid)
|
2025-06-30 08:39:00 +08:00
|
|
|
end
|
2025-07-26 04:49:56 +08:00
|
|
|
self:GetFlagPlaysData(self.showid)
|
2025-06-30 08:39:00 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取快速开始设置数据
|
|
|
|
|
function M:GetFlagPlaysData(showid)
|
2025-07-26 04:49:56 +08:00
|
|
|
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
|
2025-06-30 08:39:00 +08:00
|
|
|
end
|
|
|
|
|
|
2025-07-26 04:49:56 +08:00
|
|
|
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 = {}
|
2025-06-30 08:39:00 +08:00
|
|
|
exconfig:FillRoomConfig(r, datajson)
|
2025-07-26 04:49:56 +08:00
|
|
|
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 =
|
2025-06-30 08:39:00 +08:00
|
|
|
end
|
|
|
|
|
|
2025-07-26 04:49:56 +08:00
|
|
|
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()
|
2025-06-30 08:39:00 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:SetCallback(callback)
|
2025-07-26 04:49:56 +08:00
|
|
|
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
|
2025-07-27 00:34:40 +08:00
|
|
|
return a_play.id > b_play.id
|
2025-07-26 04:49:56 +08:00
|
|
|
else
|
2025-07-27 00:34:40 +08:00
|
|
|
return a_play.gameId > b_play.gameId
|
2025-07-26 04:49:56 +08:00
|
|
|
end
|
|
|
|
|
else
|
2025-07-27 00:34:40 +08:00
|
|
|
return a_play.gameType > b_play.gameType
|
2025-07-26 04:49:56 +08:00
|
|
|
end
|
2025-06-30 08:39:00 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 销毁窗口
|
|
|
|
|
function M:Destroy(remove_map)
|
2025-07-26 04:49:56 +08:00
|
|
|
-- if self.callback then
|
|
|
|
|
-- self.callback()
|
|
|
|
|
-- end
|
|
|
|
|
BaseWindow.Destroy(self, remove_map)
|
|
|
|
|
ImageLoad.Clear(self.class)
|
2025-06-30 08:39:00 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return M
|