local JoinGroupView = import('.JoinGroupView') local GroupJoinsView = import('.GroupJoinsView') local GroupSetDefaultGameView = import('.GroupSetDefaultGameView') local GroupManagerView = import('.GroupManagerView') local GroupRemitView = import('.GroupRemitView') local RoomItem = import('.RoomItem') local FGInvitedMsgView = import('.FGInvitedMsgView') local GroupMemberFagLogView = import('./MngView/GroupMemberFagLogView') local GroupMngGameListView = import(".MngView/GroupMngGameListView") local GroupMngFagPackView = import('.GroupMngFagPackView') local GroupMailView = import('.GroupMailView') local GroupSelectPlayView = import('.GroupSelectPlayView') local GroupMngSettingView = import('.GroupMngSettingView') local GroupPartnerRobotGames = import('./MngView/GroupPartnerRobotGames') -- local HeadView = require('Game/View/LobbyHeadView') GroupNumberInputView_Game = import(".MngView.GroupNumberInputView") local GroupMngPersonStatAloneView = import(".MngView.GroupMngPersonStatAloneView") local GroupInfoView = {} local M = GroupInfoView local currentSelectPlay = 0 function GroupInfoView.new(curGroup, fg_info, root_view, groupMainView) setmetatable(M, { __index = BaseView }) local self = setmetatable({}, { __index = M }) self.class = 'GroupInfoView' self.curGroup = curGroup curGroup.layer = 0 self.fg_info = fg_info self._root_view_for_embed = root_view self._groupMainView_to_embed = groupMainView self.roominfo = {} self.gameIdList = {} self.playIdList = {} -- (是否置顶) self.pinnedPlays = {} self._full = true self._get_data = false self._showVipRooms = 0 self.lstgameVisible = false self.isShowRoomItem = (self.curGroup.lev == 1 or self.curGroup.lev == 2) DataManager.SelfUser.cur_group = self self.FillGameItemList = {} self:InitView('ui://NewGroup/Main_GroupInfo') return self end -- 获取具体玩法名 local function __getLayerName(self, pid) if pid == 0 then return '全 部' end --if not self._get_data then -- return self.playNames[pid] or '已删除' --end local p_data = self.curGroup:getPlay(pid) return p_data and p_data.name or '已删除' end -- 获取玩法名 local function __getLayerName1(self, pid) if pid == 0 then return '全 部' end --if not self._get_data then -- return self.playNames[pid] or '已删除' --end local p_data = self.curGroup:getPlay(pid) return p_data and p_data.game_name or '已删除' end -- 加载背景图 local bg_pref = 'base/newgroup/bg/bg0' local function __setBG(url) local tex_bg = ResourcesManager.LoadObjectByGroup(url .. '.png', typeof(UnityEngine.Texture), url) local bg = GImage() bg.texture = FairyGUI.NTexture(tex_bg) bg.width = 1751 bg.height = 1001 return bg end -- 显示背景 local function __showBG(main_view) local num = PlayerPrefs.GetInt('fgroup_bg') if num == 0 then num = 1 end local url = bg_pref .. num local anchor = main_view:GetChild('bg_anchor') anchor:RemoveChildren(0, -1, true) local bg = __setBG(url) anchor:AddChild(bg) bg.x = -50 bg.y = 0 end local function RoomWeight(room) local weight = 0 if room.status == 1 then weight = weight + 1 elseif room.default then weight = weight + 0 elseif #room.plist == 0 then weight = weight + 0 elseif room.maxPlayers > #room.plist then weight = weight + (10 - room.maxPlayers + #room.plist) elseif room.maxPlayers == #room.plist then weight = weight + 1 end room.weight = weight return weight end local function RoomWeight1(room) local weight = 0 if room.status == 1 then weight = weight + 20 elseif room.default then weight = weight + 0 elseif #room.plist == 0 then weight = weight + 0 elseif room.maxPlayers > #room.plist then weight = 0.5 --weight + (10 - room.maxPlayers + #room.plist) elseif room.maxPlayers == #room.plist then weight = weight + 1 end room.weight = weight return weight end -- 房间排序 local function SortRooms(a, b) if currentSelectPlay == 0 then local rwa = RoomWeight(a) local rwb = RoomWeight(b) if rwa ~= rwb then return rwa > rwb else return a.pid < b.pid end else local rwa = RoomWeight1(a) local rwb = RoomWeight1(b) if rwa ~= rwb then return rwa < rwb else return a.pid < b.pid end end end -- 填充房间对象 local list_offline = {} local function __fillRoomItem(self, index, item, room) if not room then local rooms = self.curRooms if not rooms then return end room = rooms[index + 1] end if not room then return end local curGroup = self.curGroup local roomid = room.id local plist = room.plist local state = room.status local str = nil local room_item = self.roomItems[item] local play = self.curGroup:getPlay(room.pid) if not room_item then room_item = RoomItem.new(item, room.maxPlayers, self.isShowRoomItem) self.roomItems[item] = room_item end room_item:SetPlay(play) -- local str="(人数:".. room.maxPlayers -- if room.limitInRoom then -- str=str.." 限制积分:"..d2ad(room.limitInRoom) ..")" -- else -- str=str..")" -- end local str = "" if room.limitInRoom then str = d2ad(str .. room.limitInRoom) end if room.round == nil then room.round = 0 end room_item.tex_round.text = room.status >= -1 and string.format('%s/%s', room.round, room.times) or "" local name = __getLayerName(self, room.pid) room_item.tex_gamename.text = name room_item.tex_limit.text = str -- local currentNum = 0 -- if plist ~= nil then -- currentNum = #plist -- end -- room_item.tex_roomid.text = tostring(currentNum) .. '/' .. tostring(room.maxPlayers) -- local desk = __fillDesk(room.maxPlayers,item) local desk = room_item.desk --local play = self.curGroup:getPlay(room.pid) local isHidden = 0 if play then if play.isHidden and play.isHidden == 1 then isHidden = 1 elseif play.config then local config = json.decode(play.config) if config.isHidden and config.isHidden == 1 then isHidden = 1 end end play.isHidden = isHidden end room_item.ctr_color.selectedIndex = play and play.deskId or room.color or 0 if not room.default then for i = 1, room.maxPlayers do local p_head = room_item.heads[i] local p_item = p_head.p_item local btn_head = p_head.btn_head btn_head._iconObject.texture = room_item.def_icon if i > #plist then p_item.visible = false else p_item.visible = true local p = plist[i] if isHidden == 0 then p_head.tex_name.text = ViewUtil.stringEllipsis(p.nick) p_head.tex_id.text = "ID:" .. p.aid ImageLoad.Load(p.portrait, btn_head._iconObject, self.class) if p.hp then local str1 = "积分:" local hp = p.hp / 100 p_head.text_score.text = str1 .. hp end else p_head.tex_name.text = "智能" p_head.tex_id.text = "防作弊" -- btn_head._iconObject.url = "ui://Common/hiddenHead" -- ImageLoad.Load("ui://Common/hiddenHead", btn_head._iconObject, self.class) end if p.off_time and p.off_time > 0 then p_item:GetController('offline').selectedIndex = 1 local cur_time = os.time() local tex_time = p_item:GetChild('tex_time') tex_time.text = (cur_time - math.min(p.off_time, cur_time)) .. '秒' local tem = {} tem.time = math.min(p.off_time, cur_time) tem.item = tex_time table.insert(list_offline, tem) else p_item:GetController('offline').selectedIndex = 0 end end end else for i = 1, room.maxPlayers do local p_head = room_item.heads[i] local p_item = p_head.p_item p_item.visible = false end end -- desk.touchable = false desk.onClick:Set( function() if room.default or self.curGroup.lev == 3 then -- 房间点击:假房间 匹配,真房间 加入 if room.default or isHidden == 1 then self:__startGame(room.id, room.pid, true, isHidden) else self:__joinRoom(roomid) end else if self.roominfo.view and not self.roominfo.view.isDisposed then self.roominfo.view:Dispose() end local riv = UIPackage.CreateObjectFromURL('ui://NewGroup/Win_roomInfo') self.roominfo.view = riv self.roominfo.room = room riv:GetChild('tex_room_id').text = room.id and '房间号:' .. room.id or '' local play = self.curGroup:getPlay(room.pid) riv:GetChild('tex_room_name').text = play.name self:InitRoomInfoView() riv:GetChild('btn_enter').onClick:Set( function() riv:Dispose() if room.default or isHidden == 1 then self:__startGame(room.id, room.pid, true, isHidden) else self:__joinRoom(roomid) end end ) riv:GetChild('btn_del').onClick:Set( function() local _curren_msg = MsgWindow.new( self._root_view, '确定解散该桌子吗?\r(解散该桌子没有任何结算信息,请谨慎操作)', MsgWindow.MsgMode.OkAndCancel ) _curren_msg.onOk:Add( function() ViewUtil.ShowModalWait(self._root_view) local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_RemoveRoom( self.curGroup.id, roomid, function(res) if self._is_destroy then return end ViewUtil.CloseModalWait() if res.ReturnCode ~= 0 then ViewUtil.ErrorTip(res.ReturnCode, '删除房间失败!') return else riv:Dispose() end end ) end ) _curren_msg:Show() end ) riv:GetChild('btn_close').onClick:Set( function() riv:Dispose() end ) self._view:AddChild(riv) riv:Center() end local key = tostring(self.curGroup.id) self.fg_info[key] = room.pid local filename = 'fginfo_' .. DataManager.SelfUser.account_id Utils.SaveLocalFile(filename, json.encode(self.fg_info)) end ) end local ROOM_ITEM = {} ROOM_ITEM[1] = 'ui://NewGroup/Item_room2' ROOM_ITEM[2] = 'ui://NewGroup/Item_room2_1' ROOM_ITEM[3] = 'ui://NewGroup/Item_room2_2' ROOM_ITEM[4] = 'ui://NewGroup/Item_room2_3' ROOM_ITEM[5] = 'ui://NewGroup/Item_room2_4' ROOM_ITEM[6] = 'ui://NewGroup/Item_room2_5' -- ROOM_ITEM[9] = 'ui://NewGroup/Item_room9' -- ROOM_ITEM[10] = 'ui://NewGroup/Item_room10' -- 填充房间列表 -- 全部玩法和单个玩法的假房间填充方式不同 local function __fillRoomData(self) local curGroup = self.curGroup local lst_room = self.lst_room local currentPlayID = self:GetSelectedPlayID() local currentGameID = self:GetSelectedGameID() -- self.lst_layer.visible = currentGameID > 0 --self.line1.visible = currentGameID > 0 if currentPlayID > 0 then local rooms = self.curGroup:getPlay(currentPlayID).rooms local trooms = {} for i = 1, #rooms do local room = rooms[i] local play = self.curGroup:getPlay(room.pid) local isvip = 0 local isHidden = 0 if play then if play.isvip and play.isvip == 1 then isvip = 1 end if play.isHidden and play.isHidden == 1 then isHidden = 1 end if (play.isvip == nil or play.isHidden == nil) and play.config then local config = json.decode(play.config) if config.isvip and config.isvip == 1 then isvip = 1 end if config.isHidden and config.isHidden == 1 then isHidden = 1 end end play.isHidden = isHidden play.isvip = isvip ----------- if isvip == self._showVipRooms then if isHidden == 1 then if #room.plist == room.maxPlayers or self.curGroup.lev < 3 then table.insert(trooms, room) end else table.insert(trooms, room) end end end end self.curRooms = membe_clone(trooms) local room = membe_clone(self.curGroup.default_rooms[self.curGroup:getPlayIndex(currentPlayID)]) local play = self.curGroup:getPlay(room.pid) local isvip = 0 if play then if play.isvip and play.isvip == 1 then isvip = 1 elseif play.config then local config = json.decode(play.config) if config.isvip and config.isvip == 1 then isvip = 1 end end play.isvip = isvip ------ if isvip == self._showVipRooms then local hp = json.decode(play.hpData) if hp and hp.maxRound then room.times = hp.maxRound end if hp and hp.limitInRoom then room.limitInRoom = hp.limitInRoom end table.insert(self.curRooms, room) end ----- end else if currentGameID == 0 then local rooms = curGroup.rooms local trooms = {} for i = 1, #rooms do local room = rooms[i] local play = self.curGroup:getPlay(room.pid) local isvip = 0 local isHidden = 0 if play then if play.isvip and play.isvip == 1 then isvip = 1 end if play.isHidden and play.isHidden == 1 then isHidden = 1 end if (play.isvip == nil or play.isHidden == nil) and play.config then local config = json.decode(play.config) if config.isvip and config.isvip == 1 then isvip = 1 end if config.isHidden and config.isHidden == 1 then isHidden = 1 end end play.isHidden = isHidden play.isvip = isvip ----- if isvip == self._showVipRooms then if play.isHidden == 1 then if #room.plist == room.maxPlayers or self.curGroup.lev < 3 then table.insert(trooms, room) end else table.insert(trooms, room) end end end end self.curRooms = membe_clone(trooms) for i = 1, #self.curGroup.playList do local defaultRoom = self.curGroup.default_rooms[i] local play = self.curGroup:getPlay(defaultRoom.pid) local isvip = 0 if play then if play.isvip and play.isvip == 1 then isvip = 1 elseif play.config then local config = json.decode(play.config) if config.isvip and config.isvip == 1 then isvip = 1 end end play.isvip = isvip end if isvip == self._showVipRooms then local hp = json.decode(self.curGroup.playList[i].hpData) defaultRoom.limitInRoom = hp.limitInRoom if hp.maxRound then defaultRoom.times = hp.maxRound end local totalNum = 1 if hp.tex_times_room then totalNum = d2ad(hp.tex_times_room) end for i = 1, totalNum do self.curRooms[#self.curRooms + 1] = defaultRoom end end end else self.curRooms = {} for i = 1, #self.curGroup.playList do local p_data = self.curGroup.playList[i] local isvip = 0 local isHidden = 0 if p_data.isvip and p_data.isvip == 1 then isvip = 1 end if p_data.isHidden and p_data.isHidden == 1 then isHidden = 1 end if (p_data.isvip == nil or p_data.isHidden == nil) and p_data.config then local config = json.decode(p_data.config) if config.isvip and config.isvip == 1 then isvip = 1 end if config.isHidden and config.isHidden == 1 then isHidden = 1 end end p_data.isvip = isvip p_data.isHidden = isHidden if p_data.gameId == currentGameID and isvip == self._showVipRooms then local tempRooms = membe_clone(p_data.rooms) if #tempRooms > 0 then for j = 1, #tempRooms do local tempRoom = tempRooms[j] if isHidden == 1 then if tempRoom.maxPlayers == #tempRoom.plist or self.curGroup.lev < 3 then self.curRooms[#self.curRooms + 1] = tempRoom end else self.curRooms[#self.curRooms + 1] = tempRoom end end end local hp = json.decode(p_data.hpData) if hp and hp.maxRound then self.curGroup.default_rooms[i].times = hp.maxRound end if hp and hp.limitInRoom then self.curGroup.default_rooms[i].limitInRoom = hp.limitInRoom end local totalNum = 1 if hp and hp.tex_times_room then totalNum = d2ad(hp.tex_times_room) end for j = 1, totalNum do self.curRooms[#self.curRooms + 1] = self.curGroup.default_rooms[i] end end end end end currentSelectPlay = self:GetSelectedPlayID() table.sort(self.curRooms, SortRooms) list_offline = {} if self.curGroup.lev < 3 then self.lst_room.numItems = #self.curRooms else if self.curGroup.show_num > 0 and #self.curRooms > self.curGroup.show_num then local tr = {} for j = 1, #self.curRooms do if #tr < self.curGroup.show_num or self.curRooms[j].default == true then table.insert(tr, self.curRooms[j]) end end self.curRooms = tr end self.lst_room.numItems = #self.curRooms end -- if self._ctr_search.selectedIndex == 1 then -- self.lst_room_search:RemoveChildrenToPool() -- for i = 1, #curGroup.rooms do -- local room = curGroup.rooms[i] -- if room.id == self.search_key then -- local item = self.lst_room_search:AddItemFromPool(ROOM_ITEM[room.maxPlayers]) -- __fillRoomItem(self, nil, item, room) -- else -- for i = 1, #room.plist do -- local p = room.plist[i] -- if self.search_key == tostring(p.aid) then -- local item = self.lst_room_search:AddItemFromPool(ROOM_ITEM[room.maxPlayers]) -- __fillRoomItem(self, nil, item, room) -- break -- end -- end -- end -- end -- end if self.roominfo.view and not self.roominfo.view.isDisposed then for i = 1, #curGroup.rooms do if curGroup.rooms[i].id == self.roominfo.room.id then self.roominfo.room = curGroup.rooms[i] self:InitRoomInfoView() end end end end function M:InitRoomInfoView() local room = self.roominfo.room if not room.default then self.roominfo.view:GetChild('tex_round').text = string.format('(%s/%s)', room.round, room.times) local lst_player = self.roominfo.view:GetChild('lst_player') lst_player:RemoveChildrenToPool() if room.plist and #room.plist > 0 then for i = 1, #room.plist do local p = room.plist[i] local item = lst_player:AddItemFromPool() item:GetChild('tex_name').text = ViewUtil.stringEllipsis(p.nick) local play = self.curGroup:getPlay(room.pid) -- local score = play.hpOnOff == 0 and p.score or d2ad(p.score * play.hp_times) -- score = score >= 0 and '+' .. score or score -- item:GetController('nega').selectedIndex = p.score >= 0 and 0 or 1 -- item:GetChild('tex_score').text = score item:GetChild('tex_score').visible = false ImageLoad.Load(p.portrait, item:GetChild('btn_head')._iconObject, self.class) end end end end -- 显示默认选择的玩法 function M:ShowSelectedGame() do return end local btn_choose = self._view:GetChild('btn_choose') local tex_gamename = btn_choose:GetChild('tex_gamename') local pid = self.fg_info[tostring(self.curGroup.id)] local play = self.curGroup:getPlay(pid) if play then tex_gamename.text = play.name else btn_choose:GetController('null').selectedIndex = 1 end end -- 玩法名字显示 local function __fillPlayItem(self, index, item) local tex_game = item:GetChild('tex_game') local tex_jutifenleiName = item:GetChild('tex_jutifenleiName') local pipeijoin = item:GetChild('pipeijoin') local tex_paiming = item:GetChild('tex_paiming') -- 获取置顶控制器和按钮 local ctr_isZhiDing = item:GetController('isZhiDing') local btn_pin = item:GetChild('btn_pin') local playId = self.playIdList[index + 1] if not playId then item.visible = false return end item.visible = true -- 处理“全部”选项 (playId == 0) if playId == 0 then tex_game.text = "全 部" tex_jutifenleiName.text = "全 部" tex_paiming.text = "0" -- 全部不显示排名 -- 隐藏置顶相关UI if ctr_isZhiDing then ctr_isZhiDing.selectedIndex = 2 -- 默认未置顶状态 end if btn_pin then --btn_pin.grayed = true --设置按钮变灰 btn_pin.touchable = false -- 禁止点击,防止误触 end -- 绑定点击事件:选择全部 pipeijoin.onClick:Set(function() --刷新房间列表 self:__loadPlayData() end) return end -- 设置置顶控制器状态 if ctr_isZhiDing then local isPinned = self.pinnedPlays[playId] ctr_isZhiDing.selectedIndex = isPinned and 1 or 0 if btn_pin then btn_pin.visible = true end end -- 绑定置顶按钮点击事件 if btn_pin then btn_pin.onClick:Set(function() self:_togglePinPlay(playId) end) end pipeijoin.onClick:Set(function() local currentPlayID = self:GetSelectedPlayID() if currentPlayID == 0 then ViewUtil.ErrorTip(nil, '请选择具体玩法') return end self:__startGame("", currentPlayID, false) end) tex_game.text = __getLayerName(self, playId) tex_jutifenleiName.text = __getLayerName1(self, playId) tex_paiming.text = index end local _iconMap = {} local function __fillExtendIcon(id, callback) local File = System.IO.File local path = Application.persistentDataPath .. '/UserData/Icon' if not System.IO.Directory.Exists(path) then System.IO.Directory.CreateDirectory(path) end local file = path .. '/icon_' .. id .. '.png' local version for k, v in pairs(DataManager.SelfUser.games) do if v.game_id == id then version = v.version break end end local loc_version local ver_file = path .. '/Icon_' .. id if _iconMap[id] then callback(_iconMap[id].ntexture) else if File.Exists(ver_file) then loc_version = File.ReadAllText(ver_file) end if not File.Exists(file) or not loc_version or loc_version ~= version then coroutine.start( function() Utils.DownloadFile( GetGameInfo('pack_url') .. '/icons/icon_' .. id .. '.png', file, function(...) File.WriteAllText(ver_file, version) local bytes = File.ReadAllBytes(file) local texture = UnityEngine.Texture2D(128, 128) texture:LoadImage(bytes) local ntexture = FairyGUI.NTexture(texture) _iconMap[id] = { texture = texture, ntexture = ntexture } callback(ntexture) end ) end ) else local bytes = File.ReadAllBytes(file) local texture = UnityEngine.Texture2D(128, 128) texture:LoadImage(bytes) local ntexture = FairyGUI.NTexture(texture) _iconMap[id] = { texture = texture, ntexture = ntexture } callback(ntexture) end end end local function GetGameName(index) if index == 0 then return "全 部" end local list = DataManager.SelfUser.games for k, v in ipairs(list) do if v.game_id == index then return v.name end end return "" end -- 玩法名字显示 local function __fillGameItem(self, index, item) local gameName = "" if (index == 0) then item.icon = 'ui://NewGroup/quyxtb' gameName = GetGameName(0) item:GetChild("n11").text = gameName item:GetChild("n22").text = gameName if self.currentGameItemName == nil then item.icon = 'ui://NewGroup/quyxtb-1' end else local gameId = self.gameIdList[index] local config = ExtendManager.GetExtendConfig(gameId) local mode = config:GetGameInfo() local iconName = mode:GetIconUrl1() item.icon = iconName gameName = GetGameName(gameId) item:GetChild("n11").text = gameName item:GetChild("n22").text = gameName end if item.icon == self.currentGameItemName then item.icon = self.currentGameItemName .. "-1" item:GetChild("n11").text = gameName item:GetChild("n22").text = gameName end end local function __analysePlayListData(self) self.playIdList = {} DataManager.SelfUser.PlayLocalList = {} local playName = "playfaconfig" .. self.curGroup.id local json_data = Utils.LoadLocalFile(playName) if json_data then local data = json.decode(json_data) DataManager.SelfUser.PlayLocalList = data end -- 获取当前选中的分类类型 (0=全部, 1=麻将, 2=扑克, 3=字牌) local selectType = 0 if self.ctr_fennlieM then selectType = self.ctr_fennlieM.selectedIndex end local curGroup = self.curGroup local gameid = self:GetSelectedGameID() -- 构建 gameId 到 gameType 的映射表 local gameTypeMap = {} for k, v in pairs(DataManager.SelfUser.games) do if v.game_id and v.gameType then gameTypeMap[v.game_id] = tonumber(v.gameType) end end -- 首先添加“全部”选项,ID设为0 table.insert(self.playIdList, 0) -- 临时表,用于存储符合条件的具体玩法及其原始索引 local tempPlayList = {} for i = 1, #curGroup.playList do local p_data = curGroup.playList[i] local isvip = 0 if p_data.isvip and p_data.isvip == 1 then isvip = 1 elseif p_data.config then local config = json.decode(p_data.config) if config.isvip and config.isvip == 1 then isvip = 1 end end p_data.isvip = isvip local isHasPlayC = true -- 分类筛选逻辑 local matchType = false if selectType == 0 then -- 0 表示全部,直接匹配 matchType = true else local currentGameType = gameTypeMap[p_data.gameId] if currentGameType and currentGameType == selectType then matchType = true end end -- 筛选条件:游戏ID匹配、VIP状态匹配、分类匹配 if (gameid == 0 or p_data.gameId == gameid) and isHasPlayC and isvip == self._showVipRooms and matchType then table.insert(tempPlayList, { id = p_data.id, originalIndex = i -- 记录原始位置,用于恢复顺序 }) end end -- 排序逻辑:置顶的排在前面(排除“全部”),非置顶的保持原始相对顺序 table.sort(tempPlayList, function(a, b) local aPinned = self.pinnedPlays[a.id] local bPinned = self.pinnedPlays[b.id] -- 如果 a 置顶且 b 未置顶,a 排前面 if aPinned and not bPinned then return true end -- 如果 b 置顶且 a 未置顶,b 排前面 if not aPinned and bPinned then return false end -- 如果状态相同(都置顶或都未置顶),按原始索引排序(保持稳定) return a.originalIndex < b.originalIndex end) -- 提取排序后的 ID 列表,追加到“全部”之后 for i = 1, #tempPlayList do table.insert(self.playIdList, tempPlayList[i].id) end local lst_layer = self.lst_layer lst_layer.numItems = #self.playIdList -- 处理选中状态 if lst_layer.numItems > 0 then -- 如果当前选中的玩法还在列表中,保持选中;否则选中第一个(通常是“全部”) local currentSelectedId = self:GetSelectedPlayID() local foundIndex = -1 for i = 1, #self.playIdList do if self.playIdList[i] == currentSelectedId then foundIndex = i - 1 -- FairyGUI index from 0 break end end if foundIndex ~= -1 then lst_layer.selectedIndex = foundIndex else lst_layer.selectedIndex = 0 -- 默认选中“全部” end else lst_layer.selectedIndex = -1 end end -- 切换置顶状态 function M:_togglePinPlay(playId) if not playId or playId == 0 then return end -- 防止对“全部”进行置顶操作 -- 互斥置顶逻辑 local isCurrentlyPinned = self.pinnedPlays[playId] if isCurrentlyPinned then self.pinnedPlays[playId] = false else -- 取消其他所有置顶 for pid, _ in pairs(self.pinnedPlays) do self.pinnedPlays[pid] = false end self.pinnedPlays[playId] = true end -- 刷新列表 __analysePlayListData(self) __fillRoomData(self) self:__loadPlayData() end local function __analyseGameListData(self) self.gameIdList = {} local count = 0 local curGroup = self.curGroup for i = 1, #curGroup.playList do local p_data = curGroup.playList[i] local isvip = 0 if p_data.isvip and p_data.isvip == 1 then isvip = 1 elseif p_data.config then local config = json.decode(p_data.config) if config.isvip and config.isvip == 1 then isvip = 1 end end p_data.isvip = isvip if isvip == self._showVipRooms then local existed = false for j = 1, #self.gameIdList do if self.gameIdList[j] == p_data.gameId then existed = true end end if existed == false then self.gameIdList[#self.gameIdList + 1] = p_data.gameId end end end self.lst_game.numItems = #self.gameIdList + 1 end function M:GetSelectedGameID() if self.lst_game.selectedIndex == -1 or self.lst_game.selectedIndex == 0 then return 0 else if self.lst_game.selectedIndex <= #self.gameIdList then return self.gameIdList[self.lst_game.selectedIndex] else return 0 end end end function M:GetSelectedPlayID() local lst_layer = self.lst_layer -- 如果没有选中项或索引无效,返回 0 if lst_layer.selectedIndex == -1 then return 0 end -- selectedIndex 从 0 开始,playIdList 从 1 开始,所以需要 +1 local index = lst_layer.selectedIndex + 1 if index <= #self.playIdList then return self.playIdList[index] else return 0 end end function M:InitView(url) BaseView.InitView(self, url) self._full_offset = false -- __showBG(self._view) -- local btndel = self._view:GetChild("btn_del") -- local texroomid = self._view:GetChild('tex_roomid') -- btndel.onClick:Set( -- function() -- local delroomid -- delroomid = (texroomid.text) or 0 -- if texroomid.text == "" then -- ViewUtil.CloseModalWait() -- ViewUtil.ErrorTip(nil, '输入不能为空') -- return -- end -- local _curren_msg = -- MsgWindow.new( -- self._root_view, -- '确定解散该桌子吗?\r(解散该桌子没有任何结算信息,请谨慎操作)', -- MsgWindow.MsgMode.OkAndCancel -- ) -- _curren_msg.onOk:Add( -- function() -- ViewUtil.ShowModalWait(self._root_view) -- local fgCtr = ControllerManager.GetController(NewGroupController) -- fgCtr:FG_RemoveRoom( -- self.curGroup.id, -- delroomid, -- function(res) -- if self._is_destroy then -- return -- end -- ViewUtil.CloseModalWait() -- if res.ReturnCode ~= 0 then -- ViewUtil.ErrorTip(res.ReturnCode, '删除房间失败!') -- return -- else -- ViewUtil.ErrorTip(res.ReturnCode, '删除房间成功!') -- end -- end -- ) -- end -- ) -- _curren_msg:Show() -- end -- ) self._view:GetChild('tex_id').text = "ID:" .. self.curGroup.id self._view:GetChild('tex_name1').text = self.curGroup.name -- self._view:GetChild('tex_p_name').text = ViewUtil.stringEllipsis(DataManager.SelfUser.nick_name) -- self._view:GetChild('tex_p_id').text = DataManager.SelfUser.account_id -- local player_diamond = self._view:GetChild('player_diamond') -- player_diamond.onClick:Add( -- function() -- local pay_url = GetGameInfo('pay_url') .. 'accId=' .. DataManager.SelfUser.account_id -- UnityEngine.Application.OpenURL(pay_url) -- end -- ) --local btn_head = self._view:GetChild('btn_head') --ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject) -- btn_head.onClick:Set( -- function() -- local headView = HeadView.new(self._root_view, DataManager.SelfUser) -- headView:Show() -- end -- ) -- self._view:GetChild('player_diamond').text = self.curGroup.diamo self._view:GetController('alliance').selectedIndex = self.curGroup.type == 2 and 1 or 0 self.ctr_newmail = self._view:GetController('new_mail') self.lst_game = self._view:GetChild('game_list') if self.lst_game then if self.lst_game then self.lst_game:SetVirtual() self.lst_game.itemRenderer = function(index, item) __fillGameItem(self, index, item) end -- local btn_remit = self._view:GetChild('btn_remit') -- btn_remit.visible = false -- -- 游戏类型列表点击事件:当用户点击某个游戏类型时,刷新玩法和房间列表 -- self.lst_game.onClickItem:Add( -- function(pas) -- -- 防止重复点击同一个游戏项 -- if self.currentSelectItem == pas.data then -- return -- end -- -- 记录当前选中的游戏项图标名称 -- local name = pas.data.icon -- self.currentSelectItem = pas.data -- self.currentGameItemName = name -- -- 重置玩法列表选中索引为"全部"(索引0) -- self.lst_layer.selectedIndex = 0 -- -- 刷新体力值显示 -- self:__refreshPay() -- -- 重新分析游戏列表数据(去重后的游戏ID列表) -- __analyseGameListData(self) -- -- 重新分析玩法列表数据(根据选中的游戏类型过滤玩法) -- __analysePlayListData(self) -- -- 重新填充房间列表数据(根据新的筛选条件显示房间) -- __fillRoomData(self) -- end -- ) end end -- 初始化分类控制器 fennlieM self.ctr_fennlieM = self._view:GetController('fennlieM') if self.ctr_fennlieM then -- 默认选中“全部” (index 0) self.ctr_fennlieM.selectedIndex = 0 -- 监听控制器变化,当用户切换分类时刷新玩法列表 self.ctr_fennlieM.onChanged:Add(function() -- 重新分析玩法列表数据(根据新的分类筛选) __analysePlayListData(self) -- 刷新房间列表(因为玩法变了,房间也要跟着变) __fillRoomData(self) -- 刷新体力值显示等UI状态 self:__loadPlayData() end) end -- self.line1 = self._view:GetChild('line1') --self.line1.visible = false self.lst_layer = self._view:GetChild('lst_layer') self.lst_layer:SetVirtual() self.lst_layer.itemRenderer = function(index, item) __fillPlayItem(self, index, item) --if index>0 then -- __fillPlayItem(self, index, item) --else -- item.width = 0 -- item.height = 0 -- item.visible = false -- end end self.lst_layer.onClickItem:Add( function() self:__loadPlayData() end ) local btn_quanbu = self._view:GetChild('btn_quanbu') btn_quanbu.onClick:Set( function() self.lst_layer.selectedIndex = 0 self:__loadPlayData() end ) self.roomItems = {} self.lst_room = self._view:GetChild('lst_room') self.lst_room:SetVirtual() self.lst_room.itemRenderer = function(index, item) __fillRoomItem(self, index, item) end self.lst_room.itemProvider = function(index) local rooms = self.curRooms if not rooms then return end local room = rooms[index + 1] if not room then return end -- pt(self.curGroup:getPlay(room.pid)) -- return ROOM_ITEM[(self.curGroup:getPlay(room.pid).gameId%10)%6+1 ] return ROOM_ITEM[self.curGroup:getPlay(room.pid).gameType or 1] end self.lst_room.fairyBatching = true -- 全部玩法的快速开始按钮 local btn_start = self._view:GetChild('btn_start') btn_start.onClick:Set( function() local pid = self.fg_info[tostring(self.curGroup.id)] if pid == 0 then ViewUtil.ErrorTip(nil, '没有选择玩法') return end self:__startGame("", pid, false) end ) -- 快速开始按钮 local btn_start2 = self._view:GetChild('btn_start2') btn_start2.onClick:Set( function() local currentPlayID = self:GetSelectedPlayID() if currentPlayID == 0 then if self.lst_layer.selectedIndex == 0 and self.lst_game.selectedIndex > 0 then local pid = self.fg_info[tostring(self.curGroup.id)] if pid == 0 then ViewUtil.ErrorTip(nil, '没有选择玩法') return end local p_data = self.curGroup:getPlay(pid) local currentGameID = self:GetSelectedGameID() if currentGameID == p_data.gameId then currentPlayID = pid end end if currentPlayID == 0 then ViewUtil.ErrorTip(nil, '没有选择玩法') return end end self:__startGame("", currentPlayID, false) end ) self.tex_SelectRoom = self._view:GetChild('tex_SelectRoom') -- 选择玩法按钮 local btn_choose = self._view:GetChild('btn_choose') local tex_Selec_yd = self._view:GetController('tex_Selec_yd') tex_Selec_yd.selectedIndex = 1 btn_choose.onClick:Set( function() -- self.lstgameVisible = not self.lstgameVisible -- if (self.lstgameVisible) then -- self.lst_game:TweenMove(Vector2.New(3,146), 0.3) -- else -- self.lst_game:TweenMove(Vector2.New(3,1232), 0.3) -- end -- self.lstgameVisible = not self.lstgameVisible -- -- 获取 btn_choose 的当前 Y 坐标 -- local targetY = btn_choose.y -- local lst_game_height = self.tex_SelectRoom.height -- local offset = 5 -- 间距 -- if (self.lstgameVisible) then -- -- 显示:移动到 btn_choose 上方 -- self.tex_SelectRoom:TweenMove(Vector2.New(btn_choose.x, targetY - lst_game_height - offset), 0.3) -- else -- -- 隐藏:移出屏幕可视区域 -- self.tex_SelectRoom:TweenMove(Vector2.New(btn_choose.x, targetY + lst_game_height + 100), 0.3) -- end if tex_Selec_yd.selectedIndex == 1 then tex_Selec_yd.selectedIndex = 0 else tex_Selec_yd.selectedIndex = 1 end end -- function() -- local sgv = -- GroupSetDefaultGameView.new( -- self.curGroup.id, -- self._root_view, -- function(num) -- if num == 0 then -- return -- end -- local pid = 0 -- pid = self.curGroup.playList[num].id -- btn_choose:GetChild('tex_gamename').text = __getLayerName(self, pid) -- btn_choose:GetController('null').selectedIndex = 0 -- local key = tostring(self.curGroup.id) -- self.fg_info[key] = pid -- local filename = 'fginfo_' .. DataManager.SelfUser.account_id -- Utils.SaveLocalFile(filename, json.encode(self.fg_info)) -- end -- ) -- local tem = self.fg_info[tostring(self.curGroup.id)] -- local play_index = self.curGroup:getPlayIndex(tem) -- if play_index == -1 then -- play_index = 1 -- end -- local setCallBackFunc=function() -- __analysePlayListData(self) -- end -- sgv:FillData(self.curGroup.playList, play_index,setCallBackFunc) -- sgv:Show() -- end ) local btn_close = self._view:GetChild('btn_close') btn_close.onClick:Set( function() self:Destroy() end ) -- btn_qyg_dakai按钮:刷新列表页 local btn_qyg_dakai = self._view:GetChild('btn_qyg_dakai') if btn_qyg_dakai then btn_qyg_dakai.onClick:Set( function() -- 如果嵌入了GroupMainView,则刷新它 if self._groupMainView_to_embed then local groupMainView = self._groupMainView_to_embed -- 检查GroupMainView是否有效 if not groupMainView._view or groupMainView._view.isDisposed then --printlog("警告:GroupMainView已销毁,无法刷新") return end ViewUtil.ShowModalWait(self._root_view_for_embed, "刷新中...") local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_GroupList(function(res) ViewUtil.CloseModalWait() -- 再次检查视图有效性 if self._is_destroy then return end if not groupMainView._view or groupMainView._view.isDisposed then --printlog("警告:GroupMainView在数据返回后已销毁") return end if res.ReturnCode == 0 then --printlog("刷新牌友圈列表成功,开始更新UI") -- 延迟50ms再刷新,确保FairyGUI内部状态稳定 coroutine.start(function() coroutine.wait(0.05) -- 最后一次检查 if not groupMainView._view or groupMainView._view.isDisposed then return end -- 调用GroupMainView的FillData方法刷新列表 if groupMainView.FillData then pcall(function() groupMainView:FillData() --printlog("GroupMainView FillData调用完成") end) end end) else ViewUtil.ErrorTip(res.ReturnCode, '刷新牌友圈列表失败!') end end) end end ) end -- local btn_cancel = self._view:GetChild('node_matching'):GetChild('btn_cancel') -- btn_cancel.onClick:Set( -- function() -- local _gameCtrl = ControllerManager.GetController(GameController) -- local _currentCtrl = ControllerManager.GetCurrenController() -- if _gameCtrl == _currentCtrl then -- _gameCtrl:LevelRoom( -- function(res) -- if res.ReturnCode == 0 then -- self._view:GetController('pipei').selectedIndex = 0 -- end -- end -- ) -- return -- end -- self._view:GetController('pipei').selectedIndex = 0 -- end -- ) local lst_layer = self._view:GetChild('lst_layer') self._layer_index = self.curGroup.layer -- self._ctr_search = self._view:GetController('search') -- self.lst_room_search = self._view:GetChild('lst_room_search') -- local btn_search = self._view:GetChild('btn_search') -- btn_search.onClick:Set( -- function() -- local search_key = self._view:GetChild('tex_id_search').text -- if (self._ctr_search.selectedIndex == 1 and search_key == self.search_key) or search_key == '' then -- return -- end -- self.search_key = search_key -- self._ctr_search.selectedIndex = 1 -- __fillRoomData(self) -- end -- ) self.tex_fag = self._view:GetChild('tex_fag') self.tex_diamo = self._view:GetChild('player_diamond') -- self:__loadLastData() self:__loadGroupData() self:__refreshManager() UpdateBeat:Add(self.__onUpdate, self) -- 如果传入了GroupMainView,则将其嵌入到详情页中 if self._groupMainView_to_embed and self._root_view_for_embed then self:_embedGroupMainView() end self._view.visible = false end function M:Reconnect() self:__loadGroupData() end -- 切换到另一个圈子的详情页 function M:SwitchToGroup(newGroup) if not newGroup or newGroup.id == self.curGroup.id then return end -- 更新当前圈子 self.curGroup = newGroup newGroup.layer = 0 DataManager.SelfUser.cur_group = self -- 重新加载圈子数据 self:__loadGroupData() self:__refreshManager() -- 刷新UI显示 self._view:GetChild('tex_id').text = "ID:" .. self.curGroup.id self._view:GetChild('tex_name1').text = self.curGroup.name -- 重置玩法和房间列表 self.gameIdList = {} self.playIdList = {} self.roomItems = {} -- 重新分析数据 __analyseGameListData(self) __analysePlayListData(self) __fillRoomData(self) -- 刷新嵌入的GroupMainView列表(如果存在) if self._groupMainView_to_embed and self._groupMainView_to_embed.FillData then pcall(function() self._groupMainView_to_embed:FillData() end) end end -- 嵌入GroupMainView到详情页中 function M:_embedGroupMainView() local root_view = self._root_view_for_embed local groupMainView = self._groupMainView_to_embed -- 设置GroupMainView的父节点为详情页的根节点 groupMainView:SetParent(root_view) -- 设置GroupMainView的锚点和位置 groupMainView:SetAnchor(0, 0, 1, 1) groupMainView:SetPos(0, 0) groupMainView:SetSize(root_view:GetSize()) -- 设置GroupMainView的可见性 groupMainView.visible = true -- 传递必要的数据或回调给GroupMainView groupMainView:FillData() end function M:__saveLastData() if not self._get_data then self._get_data = true end local data = json.encode(self.curGroup.playList) Utils.SaveLocalFile(self.curGroup.id .. "fg_table_info", data) end function M:__loadLastData() local json_data = Utils.LoadLocalFile(self.curGroup.id .. "fg_table_info") if not json_data then return end pcall(function() local data = json.decode(json_data) self.curRooms = {} self.playNames = {} for i = 1, #data do local t = data[i] if not list_check(self.gameIdList, t.gameId) then table.insert(self.gameIdList, t.gameId) end table.insert(self.playIdList, t.id) local room = { maxPlayers = t.maxPlayers, status = 0, default = true, pid = t.id, color = t.deskId } table.insert(self.curRooms, room) self.playNames[t.id] = t.name end self.lst_game.numItems = #self.gameIdList + 1 self.lst_layer.visible = false --self.line1.visible = false self.lst_layer.numItems = #self.playIdList + 1 self.lst_room.numItems = #self.curRooms end) end local CLASS_LOBBT = 'LobbyView' local timer = 0 function M:__onUpdate() if self.pause then return end if self._pipeiTime and self._pipeiTime > 0 then local deltaTime = Time.deltaTime self._pipeiTime = self._pipeiTime - deltaTime self._pipeiTime = math.max(self._pipeiTime, 0) if self._pipeiTime == 0 then self._view:GetChild('node_matching'):GetChild('text_time').text = "当前排位时间较长,请耐心等待..." self._view:GetChild('node_matching'):GetController('quxiao').selectedIndex = 1 else local time = math.floor(self._pipeiTime) self._view:GetChild('node_matching'):GetChild('text_time').text = "玩家排位中," .. time .. "秒后可退出..." end end if self.__join_room then local cview = ViewManager.GetCurrenView() if (cview.class == CLASS_LOBBT) then self.__join_room = false self._view.visible = true self:__ShowNotice() end else if self.curGroup then if self.curGroup.update_room then self.curGroup.update_room = false __fillRoomData(self) end if self.curGroup.update_info then self.curGroup.update_info = false self:_evtUpdatePlayerInfo() end if self.curGroup.update_joins then self.curGroup.update_joins = false self:_setHongDian(false) if self.curGroup.lev < 3 then self:_evtUpdateMsg() end end if self.curGroup.update_play then self.curGroup.update_play = false self:_evtAddPlay() if self.mng_view4 then self.mng_view4:RefreshPage(4) end end local deltaTime = Time.deltaTime timer = timer + deltaTime if timer > 1 then timer = 0 for i = 1, #list_offline do local tem = list_offline[i] if tem and not tem.item.isDisposed then tem.item.text = (os.time() - tem.time) .. '秒' end end end end end end function M:__joinRoom(room_id) ViewUtil.ShowModalWait(self._root_view, '正在加入游戏...', 'join_room') local roomCtr = ControllerManager.GetController(RoomController) local _gameCtrl = ControllerManager.GetController(GameController) local _currentCtrl = ControllerManager.GetCurrenController() if _gameCtrl == _currentCtrl then if _gameCtrl.tmpRoomID ~= room_id then _gameCtrl:LevelRoom( function(res) roomCtr:PublicJoinRoom( Protocol.WEB_FG_JOIN_ROOM, room_id, false, function(response) if (response.ReturnCode == -1) then ViewUtil.CloseModalWait('join_room') RestartGame() return end if response.ReturnCode == -2 then self:__joinRoom(room_id) return elseif response.ReturnCode ~= 0 then ViewUtil.CloseModalWait('join_room') ViewUtil.ErrorMsg(self._root_view, response.ReturnCode, '进入房间失败') return end self.__join_room = true -- local mgr_ctr = ControllerManager.GetController(GroupMgrController) -- mgr_ctr:disconnect() self._view.visible = false ImageLoad.Clear(self.class) ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id) ViewUtil.CloseModalWait('join_room') timer = 0 end, self.curGroup.id ) end ) return end end roomCtr:PublicJoinRoom( Protocol.WEB_FG_JOIN_ROOM, room_id, false, function(response) pt(response) if (response.ReturnCode == -1) then ViewUtil.CloseModalWait('join_room') RestartGame() return end if response.ReturnCode == -2 then self:__joinRoom(room_id) return elseif response.ReturnCode ~= 0 then ViewUtil.CloseModalWait('join_room') ViewUtil.ErrorMsg(self._root_view, response.ReturnCode, '进入房间失败') return end self.__join_room = true -- local mgr_ctr = ControllerManager.GetController(GroupMgrController) -- mgr_ctr:disconnect() self._view.visible = false ImageLoad.Clear(self.class) ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id) ViewUtil.CloseModalWait('join_room') timer = 0 end, self.curGroup.id ) end function M:__joinRoom_match(roomid, pid, is_null, isHidden, callback) if isHidden == nil then isHidden = 0 local play = self.curGroup:getPlay(pid) if play then if play.isHidden and play.isHidden == 1 then isHidden = 1 elseif play.config then local config = json.decode(play.config) if config.isHidden and config.isHidden == 1 then isHidden = 1 end end play.isHidden = isHidden end end if isHidden == 1 then ViewUtil.CloseModalWait() if not DataManager.SelfUser.location then DataManager.SelfUser.location = Location.new() end if DataManager.SelfUser.location:Location2String() == "" then -- if DataManager.SelfUser.location:Location2String() == "" then ViewUtil.ErrorTip(nil, "没有打开GPS定位,不能参与该游戏") get_gps() return end if self.wait_Pipei ~= nil then coroutine.stop(self.wait_Pipei) end self.wait_Pipei = nil self.wait_Pipei = coroutine.start(function() -- local t = math.random( 1, 3 ) -- coroutine.wait(t) local roomCtr = ControllerManager.GetController(RoomController) roomCtr:PublicJoinRoom( Protocol.WEB_FG_QUEUE_ROOM, roomid, is_null, function(response) if (response.ReturnCode == -1) then self._view:GetController('pipei').selectedIndex = 0 ViewUtil.CloseModalWait('join_room') RestartGame() return end if response.ReturnCode ~= 0 then self._view:GetController('pipei').selectedIndex = 0 callback(response.ReturnCode) return else self:showPipei(self.curGroup:getPlay(pid)) ControllerManager.GetCurrenController():PlayerReady() -- UpdateBeat:Add(__checkExitRoom,self) -- local mgr_ctr = ControllerManager.GetController(GroupMgrController) -- mgr_ctr:disconnect() -- self.__join_room = true -- self._view.visible = false -- ImageLoad.Clear(self.class) -- ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id) -- callback(response.ReturnCode) -- ViewUtil.CloseModalWait('join_room') -- timer = 0 end end, self.curGroup.id, pid ) end) return end local roomCtr = ControllerManager.GetController(RoomController) roomCtr:PublicJoinRoom( Protocol.WEB_FG_MATCH_ROOM, roomid, is_null, function(response) if (response.ReturnCode == -1) then ViewUtil.CloseModalWait('join_room') RestartGame() return end if response.ReturnCode ~= 0 then callback(response.ReturnCode) return else -- UpdateBeat:Add(__checkExitRoom,self) self.__join_room = true -- local mgr_ctr = ControllerManager.GetController(GroupMgrController) -- mgr_ctr:disconnect() self._view.visible = false ImageLoad.Clear(self.class) ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id) callback(response.ReturnCode) ViewUtil.CloseModalWait('join_room') timer = 0 end end, self.curGroup.id, pid ) end function M:_evtAddPlay() local lst_layer = self.lst_layer __analyseGameListData(self) __analysePlayListData(self) __fillRoomData(self) end function M:_evtDelPlay() local lst_layer = self.lst_layer __analyseGameListData(self) __analysePlayListData(self) __fillRoomData(self) end function M:_evtUpdatePlay() local lst_layer = self.lst_layer __analyseGameListData(self) __analysePlayListData(self) __fillRoomData(self) end function M:_evtDelRoom() local lst_room = self.lst_room __fillRoomData(self) end function M:_evtAddRoom() local lst_room = self.lst_room __fillRoomData(self) end function M:_evtUpdateRoom() local lst_room = self.lst_room __fillRoomData(self) end function M:_evtUpdatePlayerInfo() self.tex_fag.text = '' .. d2ad(self.curGroup.hp) self.tex_diamo.text = self.curGroup.diamo -- self._view:GetController("manager").selectedIndex = (self.curGroup.lev < 3 or self.curGroup.partnerLev > 0) and 1 or 0 end function M:_evtUpdateMsg() local joins = self.curGroup.joins self._view:GetChild('btn_msg'):GetController('tip').selectedIndex = joins > 0 and 1 or 0 if joins > 0 and self.curGroup.apply == 0 then local msg = '有玩家申请加入您的大联盟,请尽快处理' local msg_view = MsgWindow.new(self._root_view, msg, MsgWindow.MsgMode.OnlyOk) msg_view:Show() self:_setHongDian(true) end end function M:_setHongDian(isShow) --红点提示 local member_tips = self._view:GetChild('member_tips') member_tips.visible = isShow end function M:_evtInvited(...) local arg = { ... } local data = arg[1] local imv = FGInvitedMsgView.new( self._root_view, self.curGroup.id, function(roomid) self:__joinRoom(roomid) end ) imv:FillData(data) imv:Show() end -- 更新牌友圈事件 function M:_evtUpdateGroup(...) -- local btn_remit = self._view:GetChild('btn_remit') -- local option = self.curGroup.option or 0 -- btn_remit.visible = self.curGroup.hide_action == 0 and true or false -- if bit:_and(option,4) > 0 then -- btn_remit.visible = false -- else -- btn_remit.visible = true -- end end -- 未读邮件通知 function M:_evtNewMailTip(...) self.ctr_newmail.selectedIndex = 1 end function M:SetRoomListVisible(visible) self.lst_room.visible = visible end function M:__refreshManager() local btn_manager = self._view:GetChild('btn_manager') btn_manager.onClick:Set(function() local win = GroupMngSettingView.new(self.curGroup.id) win:Show() end) local btn_stat = self._view:GetChild('btn_stat') btn_stat.onClick:Set( function() if not self.mng_view2 then self.mng_view2 = GroupManagerView.new(self._root_view, self.curGroup.id, 2) end -- self:SetRoomListVisible(false) self.mng_view2:Show() end ) local btn_partner = self._view:GetChild('btn_partner') btn_partner.onClick:Set( function() if not self.mng_view3 then self.mng_view3 = GroupManagerView.new(self._root_view, self.curGroup.id, 5) self.mng_view3:SetCurrentGroupInfoViewIns(function() self:OnclickMember() end) end self.mng_view3:Show() -- self:SetRoomListVisible(false) end ) local btn_play = self._view:GetChild('btn_play') btn_play.onClick:Set(function() local gl_view = GroupMngGameListView.new(self.curGroup.id) gl_view:Show() -- self:SetRoomListVisible(false) end) local bth_record = self._view:GetChild('bth_record') bth_record.onClick:Set(function() local gl_bth_record = GroupMngPersonStatAloneView.new(self.curGroup.id) gl_bth_record:InitView() gl_bth_record:Show() end) local btn_fginfo = self._view:GetChild('btn_fginfo') btn_fginfo.onClick:Set( function() local m = {} m.uid = DataManager.SelfUser.account_id m.portrait = DataManager.SelfUser.head_url m.nick = DataManager.SelfUser.nick_name local mflv = GroupMemberFagLogView.new(self.curGroup.id, m, true) mflv:Show() end ) end function M:OnclickMember() if not self.mng_view3 then self.mng_view3 = GroupManagerView.new(self._root_view, self.curGroup.id, 5) end self.mng_view3:Show() end -- 显示公告 function M:__ShowNotice() local group = DataManager.groups:get(self.curGroup.id) local str_notice = group.notice local empty_notice = not str_notice or str_notice == '' local com_notice = self._view:GetChild('com_notice') local com_message = com_notice:GetChild('message') com_notice.visible = not empty_notice local tex_notice = com_message:GetChild('tex_message') tex_notice.text = str_notice local speed_x = 100 local start_x = com_message.width + 100 -- local dd = tex_notice.width / com_message.width local dur_time = (start_x + tex_notice.width + 100) / speed_x if self._tw_notice then self._tw_notice:Stop() end self._tw_notice = DSTween.To( 0, 1, dur_time, function(value) tex_notice.x = start_x - speed_x * value * dur_time end ):OnComplete( function() self._tw_notice = nil self:__ShowNotice() end ) end -- 显示玩法信息 function M:__loadPlayData() -- 体力值显示 self:__refreshPay() -- 房间对象填充 __fillRoomData(self) end -- 初始化圈子信息 function M:__loadGroupData() if self.mng_view then self.mng_view:Close() end local curGroup = self.curGroup curGroup.update_room = false curGroup.update_info = false curGroup.update_joins = false ViewUtil.ShowModalWait(self._root_view, "正在进入牌友圈,请稍等...") local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_EnterGroup( curGroup.id, function(res) -- if self._is_destroy then -- return -- end ViewUtil.CloseModalWait() if res.ReturnCode ~= 0 then --self._view.visible=false --ViewUtil.ErrorTip(res.ReturnCode, "获取圈子数据失败") else self._view.visible = true self:Show() self:__saveLastData() local mgr_ctr = ControllerManager.GetController(GroupMgrController) mgr_ctr:AddEventListener(GroupMgrEvent.AddPlay, handler(self, self._evtAddPlay)) mgr_ctr:AddEventListener(GroupMgrEvent.DelPlay, handler(self, self._evtDelPlay)) mgr_ctr:AddEventListener(GroupMgrEvent.UpdatePlay, handler(self, self._evtUpdatePlay)) mgr_ctr:AddEventListener(GroupMgrEvent.AddRoom, handler(self, self._evtAddRoom)) mgr_ctr:AddEventListener(GroupMgrEvent.DelRoom, handler(self, self._evtDelRoom)) mgr_ctr:AddEventListener(GroupMgrEvent.UpdateRoom, handler(self, self._evtUpdateRoom)) mgr_ctr:AddEventListener(GroupMgrEvent.UpdatePlayerInfo, handler(self, self._evtUpdatePlayerInfo)) -- mgr_ctr:AddEventListener(GroupMgrEvent.UpdateMessage, handler(self,self._evtUpdateMsg)) mgr_ctr:AddEventListener(GroupMgrEvent.BeInvited, handler(self, self._evtInvited)) mgr_ctr:AddEventListener(GroupMgrEvent.UpdateGroup, handler(self, self._evtUpdateGroup)) mgr_ctr:AddEventListener(GroupMgrEvent.NewMailTip, handler(self, self._evtNewMailTip)) local ctr_manager = self._view:GetController('manager') ctr_manager.selectedIndex = self.curGroup.lev < 3 and self.curGroup.lev or (self.curGroup.partnerLev > 0 and 3 or 0) if self.curGroup.lev < 3 then local ctr_msg = self._view:GetController('msg') ctr_msg.selectedIndex = 1 end local btn_vip = self._view:GetChild("btn_vip") if self.curGroup.isvip == 1 then local vip = self.fg_info[tostring(self.curGroup.id) .. "vip"] or 0 self._showVipRooms = vip btn_vip:GetController("vip").selectedIndex = math.abs(self._showVipRooms - 1) btn_vip.onClick:Set(function() btn_vip:GetController("vip").selectedIndex = self._showVipRooms self._showVipRooms = math.abs(self._showVipRooms - 1) self:_evtUpdatePlay() local key = tostring(self.curGroup.id) .. "vip" self.fg_info[key] = self._showVipRooms local filename = 'fginfo_' .. DataManager.SelfUser.account_id Utils.SaveLocalFile(filename, json.encode(self.fg_info)) end) end -- 玩法列表初始化 __analyseGameListData(self) __analysePlayListData(self) self.lst_layer.selectedIndex = 0 self.lst_game.selectedIndex = 0 self._view:GetController('all').selectedIndex = 1 self:ShowSelectedGame() -- 加载玩法信息 self:__loadPlayData() -- 显示公告 self:__ShowNotice() curGroup.update_room = false local btn_msg = self._view:GetChild('btn_msg') btn_msg.onClick:Set( function() if not self.mng_view1 then self.mng_view1 = GroupManagerView.new(self._root_view, self.curGroup.id, 1) end self.mng_view1:Show(5) -- self:SetRoomListVisible(false) end ) local btn_invite = self._view:GetChild('btn_invite') btn_invite.displayObject.gameObject:SetActive(false) --[[btn_invite.onClick:Set(function() if not self.mng_view3 then self.mng_view3 = GroupManagerView.new(self._root_view, self.curGroup.id, 3) end self.mng_view3:Show(1) end)--]] -- local btn_rank = self._view:GetChild("btn_rank") -- btn_rank.onClick:Set(function() -- local rv = GroupRank.new(self._root_view, self.curGroup.id) -- rv:Show() -- end) -- local btn_remit = self._view:GetChild('btn_remit') -- btn_remit.onClick:Set( -- function() -- local remit_view = GroupRemitView.new(self._root_view, self.curGroup) -- remit_view:Show() -- end -- ) local option = self.curGroup.option or 0 if self.curGroup.lev < 3 then self:_evtUpdateMsg() end -- btn_remit.visible = self.curGroup.hide_action == 0 and true or false -- if bit:_and(option,4) > 0 then -- btn_remit.visible = false -- else -- btn_remit.visible = true -- end -- 选择玩法面板 local btn_mail = self._view:GetChild('btn_mail') self.ctr_newmail.selectedIndex = self.curGroup.mail_tip or -1 btn_mail.onClick:Set( function() self.ctr_newmail.selectedIndex = 0 local gmv = GroupMailView.new(self._root_view, self.curGroup) gmv:SetCallback( function() btn_mail.selected = false end ) gmv:Show() end ) local btn_bxx = self._view:GetChild('btn_bxx') btn_bxx.onClick:Set( function() local ctrNum = 1 -- if self.curGroup.lev==3 and self.curGroup.partnerLev>0 or self.curGroup.lev==1 or self.curGroup.lev==2 then -- ctrNum=2 -- end if self.curGroup.lev == 1 then ctrNum = 2 end ctrNum = 2 local gmv = GroupMngFagPackView.new(self.curGroup.id, self._root_view, ctrNum, DataManager.SelfUser.account_id) gmv:SetCallback( function() btn_bxx.selected = false end ) gmv:Show() end ) local robot_btn = self._view:GetChild('btn_rebot') robot_btn.onClick:Set( function() local gmv = GroupPartnerRobotGames.new(self.curGroup.id, DataManager.SelfUser.account_id) gmv:Show() end ) end end ) end -- 匹配游戏 function M:__startGame(roomid, pid, is_null, isHidden, callback) ViewUtil.ShowModalWait(self._root_view, '正在加入游戏...', 'join_room') local _gameCtrl = ControllerManager.GetController(GameController) local _currentCtrl = ControllerManager.GetCurrenController() if _gameCtrl == _currentCtrl then _gameCtrl:LevelRoom( function(res) self:__joinRoom_match( roomid, pid, is_null, isHidden, function(code) if code == -2 then self:__startGame(roomid, pid, is_null, isHidden, callback) elseif code ~= 0 then ViewUtil.ErrorMsg(self._root_view, code, '进入房间失败') ViewUtil.CloseModalWait('join_room') end if callback then callback() end end ) end ) return end self:__joinRoom_match( roomid, pid, is_null, isHidden, function(code) if code == -2 then self:__startGame(roomid, pid, is_null, isHidden, callback) elseif code ~= 0 then ViewUtil.ErrorMsg(self._root_view, code, '进入房间失败') ViewUtil.CloseModalWait('join_room') end if callback then callback() end end ) end -- 显示各玩法体力值信息 function M:__refreshPay() self.tex_fag.text = '' .. d2ad(self.curGroup.hp or 0) self.tex_diamo.text = self.curGroup.diamo local ctr_all = self._view:GetController('all') local currentPlayID = self:GetSelectedPlayID() local currentGameID = self:GetSelectedGameID() if currentPlayID > 0 then --self._view:GetChild("tex_name").text = __getLayerName(self,currentPlayID) ctr_all.selectedIndex = 0 else if currentGameID == 0 then ctr_all.selectedIndex = 1 else ctr_all.selectedIndex = 0 end -- self._view:GetChild("tex_name").text = __getLayerName(self,0) self._view:GetChild('tex_name').text = self.curGroup.name end end -- 分享牌友圈 function M:__share() local tem = self.curGroup local str = string.format('【%s】 邀请您加入!', tem.name) local url = string.format( '%s?type=t1&playerId=%s&groupId=%s', GetGameInfo('share_group_link'), DataManager.SelfUser.account_id, tem.id ) local json_data = {} json_data['title'] = string.format('大联盟号【%s】', tem.id) local mediaObject = {} mediaObject['url'] = url mediaObject['type'] = 0 json_data['mediaObject'] = mediaObject json_data['description'] = str json_data['scene'] = 0 GameApplication.Instance:ShareLink(1, json.encode(json_data), nil) end function M:showPipei(play) self._view:GetController('pipei').selectedIndex = 1 self._view:GetChild('node_matching'):GetController('quxiao').selectedIndex = 0 if play then self._view:GetChild('node_matching'):GetChild('text_title').text = play.name self._view:GetChild('node_matching'):GetChild('text_des').text = DataManager.CurrenRoom.room_config:GetDes() end self._pipeiTime = 20 end function M:hidePipei() if self._view:GetController('pipei') then self._view:GetController('pipei').selectedIndex = 0 end end function M:SetCallBack(callback) self._callback = nil self._callback = callback end function M:Reconnect() self:__loadGroupData() end -- 嵌入GroupMainView到详情页中 function M:_embedGroupMainView() if not self._groupMainView_to_embed or not self._root_view_for_embed then return end local groupMainView = self._groupMainView_to_embed -- 设置父视图引用,用于切换圈子 groupMainView._parentInfoView = self -- 记录原始父容器,以便关闭时恢复 if groupMainView._view and groupMainView._view.parent then groupMainView._originalParent = groupMainView._view.parent end -- 先隐藏视图 if groupMainView._view then groupMainView._view.visible = false end -- 将列表页添加到详情页的lnfo_group组件中 local container = self._view:GetChild('lnfo_group') if container then -- 从原父节点移除 if groupMainView._view.parent then groupMainView._view.parent:RemoveChild(groupMainView._view) end -- 添加到lnfo_group容器 container:AddChild(groupMainView._view) -- 延迟显示,确保FairyGUI内部状态稳定 coroutine.start(function() coroutine.wait(0.05) if groupMainView._view and not groupMainView._view.isDisposed then groupMainView._view.visible = true end end) end end function M:Show() get_gps() BaseView.Show(self) local user = DataManager.SelfUser local roomid = user.room_id if user.group_id == self.curGroup.id and string.len(roomid) > 1 then self:__joinRoom(roomid) user.group_id = 0 end end function M:Destroy() -- 先执行恢复子视图的回调逻辑 if self._groupMainView_to_embed and self._groupMainView_to_embed._view then local groupMainView = self._groupMainView_to_embed -- 将列表页移回原容器 if groupMainView._originalParent and not groupMainView._view.isDisposed then pcall(function() -- 从当前父节点移除 if groupMainView._view.parent then groupMainView._view.parent:RemoveChild(groupMainView._view) end -- 添加到原父节点 groupMainView._originalParent:AddChild(groupMainView._view) groupMainView._originalParent = nil groupMainView._view.visible = false end) end end BaseView.Destroy(self) UpdateBeat:Remove(self.__onUpdate, self) ImageLoad.Clear(self.class) GRoot.inst:HidePopup() timer = 0 self.pause = true local fgCtr = ControllerManager.GetController(NewGroupController) fgCtr:FG_ExitGroupMgr() if self._pm_mgr_view then self._pm_mgr_view:Dispose() end if self._pm_set_view then self._pm_set_view:Dispose() end if self._pm_rs_view then self._pm_rs_view:Dispose() end if self._callback then self._callback() end if self.mng_view1 then self.mng_view1:Destroy() end if self.mng_view2 then self.mng_view2:Destroy() end if self.mng_view3 then self.mng_view3:Destroy() end if self.mng_view4 then self.mng_view4:Destroy() end DataManager.SelfUser.cur_group = nil if self._tw_notice then self._tw_notice:Stop() end for i, v in pairs(_iconMap) do v.texture:Destroy() v.ntexture:Unload() end _iconMap = {} end return M