2097 lines
72 KiB
Lua
2097 lines
72 KiB
Lua
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 GroupMngMemberInviteView = import(".MngView.GroupMngMemberInviteView")
|
||
local GroupMngMemberHpListView = import(".MngView.GroupMngMemberHpListView")
|
||
local GroupMngMenKangView = import(".MngView.GroupMngMenKangView")
|
||
local GroupMngPiLaoZhi = import(".MngView.GroupMngPiLaoZhi")
|
||
-- local GroupPartnerRewardsView = import(".GroupPartnerRewardsView")
|
||
|
||
-- local HeadView = require('Game/View/LobbyHeadView')
|
||
GroupNumberInputView_Game = import(".MngView.GroupNumberInputView")
|
||
|
||
local GroupInfoView = {}
|
||
local M = GroupInfoView
|
||
|
||
local currentSelectPlay = 0
|
||
|
||
function GroupInfoView.new(curGroup, fg_info)
|
||
setmetatable(M, { __index = BaseView })
|
||
local self = setmetatable({}, { __index = M })
|
||
self.class = 'GroupInfoView'
|
||
self.curGroup = curGroup
|
||
curGroup.layer = 0
|
||
self.fg_info = fg_info
|
||
self.roominfo = {}
|
||
self.gameIdList = {}
|
||
self.playIdList = {}
|
||
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, 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)
|
||
--printlog("aaaaaaaaawwwwwwwwwwwwwwwwwwwwwwwwwwwww")
|
||
--pt(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
|
||
-- printlog("aaaaaaaaaaaaaaaaaaaccccccccccccccccccccccc ",weight)
|
||
--pt(room)
|
||
return weight
|
||
end
|
||
|
||
|
||
-- 房间排序
|
||
local function SortRooms(a, b)
|
||
-- printlog("SortRooms====》》》》",currentSelectPlay)
|
||
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.." 限制积分:"..room.limitInRoom/1000 ..")"
|
||
-- else
|
||
-- str=str..")"
|
||
-- end
|
||
|
||
|
||
local str = ""
|
||
if room.limitInRoom then
|
||
str = str .. room.limitInRoom / 1000
|
||
end
|
||
|
||
if room.round == nil then
|
||
room.round = 0
|
||
end
|
||
|
||
|
||
--printlog("wwwwwwwwwww1111111111111111 ",room.round," ",room.times)
|
||
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 / 1000
|
||
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[2] = 'ui://NewGroup/Item_room2'
|
||
ROOM_ITEM[3] = 'ui://NewGroup/Item_room3'
|
||
ROOM_ITEM[4] = 'ui://NewGroup/Item_room4'
|
||
ROOM_ITEM[5] = 'ui://NewGroup/Item_room5'
|
||
ROOM_ITEM[6] = 'ui://NewGroup/Item_room6'
|
||
ROOM_ITEM[8] = 'ui://NewGroup/Item_room8'
|
||
ROOM_ITEM[9] = 'ui://NewGroup/Item_room9'
|
||
ROOM_ITEM[10] = 'ui://NewGroup/Item_room10'
|
||
|
||
local ROOM_ITEM_PLAY = {}
|
||
ROOM_ITEM_PLAY[1] = 'ui://NewGroup/Play_room1'
|
||
ROOM_ITEM_PLAY[2] = 'ui://NewGroup/Play_room2'
|
||
ROOM_ITEM_PLAY[3] = 'ui://NewGroup/Play_room3'
|
||
|
||
|
||
-- 填充房间列表
|
||
-- 全部玩法和单个玩法的假房间填充方式不同
|
||
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
|
||
--printlog("aaaaaaaaaaaaaaaaa11111111111111111111111111111111")
|
||
-- 单个玩法
|
||
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
|
||
--printlog("aaaaaaaaaaaaaaaaa222222222222222222222222222")
|
||
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 = hp.tex_times_room / 1000
|
||
end
|
||
|
||
for i = 1, totalNum do
|
||
self.curRooms[#self.curRooms + 1] = defaultRoom
|
||
end
|
||
end
|
||
end
|
||
else
|
||
--printlog("aaaaaaaaaaaaaaaaa33333333333333333333333333333333")
|
||
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 = hp.tex_times_room / 1000
|
||
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
|
||
printlog("wwwwwwwwwww22222222222222222 ", room.round, " ", room.times)
|
||
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_gameName = item:GetChild('tex_gameName')
|
||
local tex_playName = item:GetChild('tex_playName')
|
||
local pipeijoin = item:GetChild('pipeijoin')
|
||
|
||
if (index == 0) then
|
||
-- tex_gameName.text = __getLayerName(self, 0)
|
||
item:GetController('all').selectedIndex = 1
|
||
else
|
||
item:GetController('all').selectedIndex = 0
|
||
pipeijoin.onClick:Add(
|
||
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
|
||
)
|
||
tex_playName.text, tex_gameName.text = __getLayerName(self, self.playIdList[index])
|
||
item.data = tex_playName.text
|
||
end
|
||
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
|
||
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
|
||
end
|
||
|
||
if item.icon == self.currentGameItemName then
|
||
item.icon = self.currentGameItemName .. "-1"
|
||
item:GetChild("n11").text = gameName
|
||
end
|
||
item:GetChild("n22").text = index + 1
|
||
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
|
||
|
||
|
||
|
||
local count = 0
|
||
local curGroup = self.curGroup
|
||
local gameid = self:GetSelectedGameID()
|
||
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
|
||
--[[for k,v in pairs(DataManager.SelfUser.PlayLocalList) do
|
||
if tonumber(k)==p_data.id then
|
||
isHasPlayC=v
|
||
end
|
||
end--]]
|
||
|
||
if (gameid == 0 or p_data.gameId == gameid) and isHasPlayC and isvip == self._showVipRooms then
|
||
count = count + 1
|
||
self.playIdList[count] = p_data.id
|
||
end
|
||
end
|
||
|
||
local lst_layer = self.lst_layer
|
||
-- printlog("添加玩法====>>>>",count)
|
||
-- pt(curGroup.playList)
|
||
lst_layer.numItems = count + 1
|
||
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
|
||
|
||
if lst_layer.selectedIndex == 0 or lst_layer.selectedIndex == -1 then
|
||
return 0
|
||
else
|
||
if lst_layer.selectedIndex <= #self.playIdList then
|
||
return self.playIdList[lst_layer.selectedIndex]
|
||
else
|
||
return 0
|
||
end
|
||
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
|
||
-- )
|
||
|
||
pt(self.curGroup)
|
||
self._view:GetChild('tex_id').text = "ID:" .. self.curGroup.id
|
||
|
||
self._view:GetChild('tex_name').text = self.curGroup.name
|
||
self._view:GetChild('tex_tableNum').text = string.format("进行:%d桌", self.curGroup.room_num)
|
||
-- self._view:GetChild('tex_hp').text = DataManager.SelfUser.diamo
|
||
print("lingmenginitgroup", self.curGroup.id, 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')
|
||
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
|
||
self.lst_layer.selectedIndex = 0
|
||
self:__refreshPay()
|
||
__analyseGameListData(self)
|
||
__analysePlayListData(self)
|
||
__fillRoomData(self)
|
||
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(context)
|
||
self._view:GetChild('btn_start2').text = context.data.data
|
||
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
|
||
return ROOM_ITEM_PLAY[self.curGroup:getPlay(room.pid).gameType]
|
||
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.visible = true
|
||
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
|
||
)
|
||
|
||
-- 选择玩法按钮
|
||
local btn_choose = self._view:GetChild('btn_choose')
|
||
btn_choose.onClick:Set(
|
||
function()
|
||
self.lstgameVisible = not self.lstgameVisible
|
||
if (self.lstgameVisible) then
|
||
self.lst_game:TweenMove(Vector2.New(3, 100), 0.3)
|
||
else
|
||
self.lst_game:TweenMove(Vector2.New(3, 760), 0.3)
|
||
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
|
||
)
|
||
|
||
-- 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._view:GetChild('btn_menkan').onClick:Set(function()
|
||
if not self.mng_view_menkan then
|
||
self.mng_view_menkan = GroupMngMenKangView.new(self.curGroup.id)
|
||
end
|
||
self.mng_view_menkan:Show()
|
||
end)
|
||
self._view:GetChild('btn_pilaozhi').onClick:Set(function()
|
||
if not self.mng_view_pilao then
|
||
self.mng_view_pilao = GroupMngPiLaoZhi.new(self.curGroup.id)
|
||
end
|
||
self.mng_view_pilao:Show()
|
||
end)
|
||
|
||
|
||
self:__loadGroupData()
|
||
self:__refreshManager()
|
||
UpdateBeat:Add(self.__onUpdate, self)
|
||
self._view.visible = false
|
||
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)
|
||
printlog("进入房间返回事件==========》》》")
|
||
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()
|
||
--print("成员..........................................")
|
||
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 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()
|
||
--print("成员..........................................")
|
||
if not self.mng_view_invite then
|
||
self.mng_view_invite = GroupMngMemberInviteView.new(self.curGroup.id)
|
||
end
|
||
print("lingmeng-self.mng_view_invite", self.mng_view_invite)
|
||
self.mng_view_invite:Show()
|
||
-- self:SetRoomListVisible(false)
|
||
end)
|
||
|
||
--查看成员hp值,带分配
|
||
local btn_hp = self._view:GetChild('btn_hp')
|
||
btn_hp.onClick:Set(function()
|
||
if not self.mng_view_hp then
|
||
self.mng_view_hp = GroupMngMemberHpListView.new(self.curGroup.id)
|
||
end
|
||
self.mng_view_hp:Show()
|
||
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
|
||
)
|
||
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()
|
||
--printlog("1111111111111111111111111111",self.curGroup.hp)
|
||
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()
|
||
--print("hidePipei=============")
|
||
--print(self._view)
|
||
--print(self._view:GetController('pipei'))
|
||
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
|
||
|
||
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()
|
||
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
|
||
if self.mng_view_invite then
|
||
self.mng_view_invite:Destroy()
|
||
end
|
||
if self.mng_view_hp then
|
||
self.mng_view_hp: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
|