游戏中解散

master
罗家炜 2025-09-04 16:58:05 +08:00
parent a58a000bb7
commit 0b92af04ca
6 changed files with 100 additions and 36 deletions

View File

@ -710,7 +710,7 @@ function M:UpdateFamilyRoom(fgCtr, id)
obj:GetChild('btn_watch').onClick:Set(function() obj:GetChild('btn_watch').onClick:Set(function()
roomCtr:PublicWitnessRoom( roomCtr:PublicWitnessRoom(
Protocol.WEB_FG_Witness_ROOM, Protocol.WEB_FG_Witness_ROOM,
roomList[newIndex].id, startRoom[newIndex].id,
id, id,
function(response) function(response)
if (response.ReturnCode == -1) then if (response.ReturnCode == -1) then
@ -730,9 +730,39 @@ function M:UpdateFamilyRoom(fgCtr, id)
end end
end, end,
playInfo.gameId, playInfo.gameId,
roomList[newIndex].pid startRoom[newIndex].pid
) )
end) end)
obj:GetChild('btn_jiesan').onClick:Set(function()
local _curren_msg =
MsgWindow.new(
self._root_view,
'确定要解散该房间吗?',
MsgWindow.MsgMode.OkAndCancel
)
_curren_msg.onOk:Add(
function()
ViewUtil.ShowModalWait(self._root_view)
local fgCtr = ControllerManager.GetController(NewGroupController)
fgCtr:FG_RemoveRoom(
id,
startRoom[newIndex].id,
function(res)
if self._is_destroy then
return
end
ViewUtil.CloseModalWait()
if res.ReturnCode ~= 0 then
ViewUtil.ErrorTip(res.ReturnCode, '删除房间失败!')
return
end
end
)
end
)
_curren_msg:Show()
end)
else else
local newIndex = index - #readyRoom + 1 local newIndex = index - #readyRoom + 1
local playInfo = playList[newIndex] local playInfo = playList[newIndex]
@ -771,6 +801,7 @@ function M:UpdateFamilyRoom(fgCtr, id)
) )
end) end)
obj:GetChild('btn_watch').onClick:Clear() obj:GetChild('btn_watch').onClick:Clear()
obj:GetChild('btn_jiesan').onClick:Clear()
end end
end end
-- print("=================================================list_room", list_room, list_room.numItems, all_num) -- print("=================================================list_room", list_room, list_room.numItems, all_num)

View File

@ -41,27 +41,27 @@ function M:init(url)
self.cBtn = self._view:GetController('cBtn') self.cBtn = self._view:GetController('cBtn')
-- slider_sound.value = GameApplication.Instance.SoundValue slider_sound.value = GameApplication.Instance.SoundValue
-- slider_music.value = GameApplication.Instance.MusicValue slider_music.value = GameApplication.Instance.MusicValue
slider_music.onChanged:Add(function() slider_music.onChanged:Add(function()
-- GameApplication.Instance.MusicValue = slider_music.value GameApplication.Instance.MusicValue = slider_music.value
-- btn_music.selected = false btn_music.selected = false
-- GameApplication.Instance.MusicMute = false; GameApplication.Instance.MusicMute = false;
end) end)
slider_sound.onChanged:Add(function() slider_sound.onChanged:Add(function()
-- GameApplication.Instance.SoundValue = slider_sound.value GameApplication.Instance.SoundValue = slider_sound.value
-- btn_sound.selected = false btn_sound.selected = false
-- GameApplication.Instance.SoundMute = false; GameApplication.Instance.SoundMute = false;
end) end)
btn_sound.onClick:Add(function() btn_sound.onClick:Add(function()
-- GameApplication.Instance.SoundMute = btn_sound.selected; GameApplication.Instance.SoundMute = btn_sound.selected;
end) end)
btn_music.onClick:Add(function() btn_music.onClick:Add(function()
-- GameApplication.Instance.MusicMute = btn_music.selected; GameApplication.Instance.MusicMute = btn_music.selected;
end) end)
local _btn_logout = self._view:GetChild('btn_cancelRoom') local _btn_logout = self._view:GetChild('btn_cancelRoom')
@ -93,6 +93,18 @@ function M:init(url)
ViewManager.ChangeView(ViewManager.View_Family) ViewManager.ChangeView(ViewManager.View_Family)
end) end)
end) end)
self._view:GetChild("btn_closeRoom").onClick:Set(function()
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:LevelRoom(function(res)
print("退出房间")
if res.ReturnCode ~= 0 then
ViewUtil.ErrorTip(res.ReturnCode)
return
end
ViewManager.ChangeView(ViewManager.View_Family)
end)
end)
end end
return M return M

View File

@ -70,19 +70,19 @@ function M:InitView(url)
self._text_remined = self._view:GetChild('remaining_card') self._text_remined = self._view:GetChild('remaining_card')
self._text_round = self._view:GetChild('text_round') self._text_round = self._view:GetChild('text_round')
self._cursor = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Ani_play_bj") self._cursor = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Ani_play_bj")
self._state.onChanged:Add(function() -- self._state.onChanged:Add(function()
self:UpdatePlayerInfoView() -- self:UpdatePlayerInfoView()
end) -- end)
self:UpdateRound() self:UpdateRound()
-- self:InitPlayerInfoView() self:InitPlayerInfoView()
self._player_card_info = {} self._player_card_info = {}
local _player_card_info = self._player_card_info local _player_card_info = self._player_card_info
for i = 1, #room.player_list do for i = 1, #room.player_list do
local p = room.player_list[i] local p = room.player_list[i]
local index = self:GetPos(p.seat) local index = self:GetPos(p.seat)
print("lingmeng index", index) print("lingmeng index", index)
-- local info = self._player_info[index] local info = self._player_info[index]
local tem = self._view:GetChild("player_card_info" .. index) local tem = self._view:GetChild("player_card_info" .. index)
_player_card_info[index] = self:NewMJPlayerCardInfoView(tem, index) _player_card_info[index] = self:NewMJPlayerCardInfoView(tem, index)
local cardInfo = _player_card_info[index] local cardInfo = _player_card_info[index]
@ -92,8 +92,8 @@ function M:InitView(url)
for i = 1, #p.fz_list do for i = 1, #p.fz_list do
cardInfo:UpdateFzList(p.fz_list[i], -1) cardInfo:UpdateFzList(p.fz_list[i], -1)
end end
-- info:FillData(p) info:FillData(p)
-- info._view.visible = true info._view.visible = true
end end
local btn_rule = self._view:GetChild('btn_rule') local btn_rule = self._view:GetChild('btn_rule')
@ -154,8 +154,14 @@ function M:EventInit()
local _gamectr = self._gamectr local _gamectr = self._gamectr
_gamectr:AddEventListener(GameEvent.PlayerEnter, function(...) _gamectr:AddEventListener(GameEvent.PlayerEnter, function(...)
self:PlayMJSound("user_enter.mp3")
local arg = { ... } local arg = { ... }
print("lingmeng witness PlayerEnter") local p = arg[1]
local info = self._player_info[self:GetPos(p.seat)]
info:FillData(p)
info._view.visible = true
info:SetPlayer(p)
info:FillData()
end) end)
_gamectr:AddEventListener(GameEvent.WitnessPlayerEnter, function(...) _gamectr:AddEventListener(GameEvent.WitnessPlayerEnter, function(...)
@ -307,7 +313,6 @@ function M:EventInit()
-- if #niao == 0 then self._view:GetChild("n13").visible = false end -- if #niao == 0 then self._view:GetChild("n13").visible = false end
self._clearingView:InitData(0, _room, result, nil, function(...) self._clearingView:InitData(0, _room, result, nil, function(...)
DataManager.CurrenRoom.self_player.card_list = {} DataManager.CurrenRoom.self_player.card_list = {}
self._state.selectedIndex = 2
self._clearingView = nil self._clearingView = nil
end) end)
end end
@ -350,7 +355,7 @@ function M:InitPlayerInfoView()
self._player_info = {} self._player_info = {}
local _player_info = self._player_info local _player_info = self._player_info
for i = 1, self._room.room_config.people_num do for i = 1, self._room.room_config.people_num do
local tem = self._view:GetChild(string.format("player_info%d_%d", i, (self._state.selectedIndex % 2) + 1)) local tem = self._view:GetChild(string.format("player_info%d_2", i))
_player_info[i] = PlayerInfoView.new(tem, self) _player_info[i] = PlayerInfoView.new(tem, self)
tem.visible = false tem.visible = false
end end
@ -427,20 +432,20 @@ function M:ShowJing()
end end
end end
function M:UpdatePlayerInfoView() -- function M:UpdatePlayerInfoView()
self._player_info = {} -- self._player_info = {}
local _player_info = self._player_info -- local _player_info = self._player_info
local list = self._room.player_list -- local list = self._room.player_list
for i = 1, self._room.room_config.people_num do -- for i = 1, self._room.room_config.people_num do
local seat = self:GetPos(list[i].seat) -- local seat = self:GetPos(list[i].seat)
local tem = self._view:GetChild(string.format("player_info%d_%d", seat, -- local tem = self._view:GetChild(string.format("player_info%d_%d", seat,
(self._state.selectedIndex == 4 and 1 or 0) + 1)) -- (self._state.selectedIndex == 4 and 1 or 0) + 1))
_player_info[seat] = PlayerInfoView.new(tem, self) -- _player_info[seat] = PlayerInfoView.new(tem, self)
_player_info[seat]:FillData(list[i]) -- _player_info[seat]:FillData(list[i])
printlog("lingmeng _player_info", tem, seat, list[i].self_user.nick_name) -- printlog("lingmeng _player_info", tem, seat, list[i].self_user.nick_name)
end -- end
end -- end
function M:OnUpdate() function M:OnUpdate()
if (self._popEvent) then if (self._popEvent) then

View File

@ -157,6 +157,17 @@ function M:init(url)
ViewManager.ChangeView(ViewManager.View_Family) ViewManager.ChangeView(ViewManager.View_Family)
end) end)
end) end)
--游戏内解散房间功能
self._view:GetController('lev').selectedIndex = 0
self.btn_closeRoom.onClick:Set(function()
if self._flag_witness then
local _room = DataManager.CurrenRoom
self._mainView._gamectr:ExitWitnessGame(_room.play_id, _room.game_id, _room.room_id)
ViewManager.ChangeView(ViewManager.View_Family)
return
end
end)
end end
--[[ --[[

View File

@ -5,6 +5,9 @@
<remark page="1" value="申请解散房间"/> <remark page="1" value="申请解散房间"/>
</controller> </controller>
<controller name="cBtnSelect" pages="0,,1," selected="0"/> <controller name="cBtnSelect" pages="0,,1," selected="0"/>
<controller name="lev" pages="0,,1," selected="0">
<remark page="0" value="管理"/>
</controller>
<displayList> <displayList>
<image id="n17_xblm" name="n17" src="xblm1a8" fileName="Main_new/Main/Image/bg.png" xy="0,0" size="1438,899"> <image id="n17_xblm" name="n17" src="xblm1a8" fileName="Main_new/Main/Image/bg.png" xy="0,0" size="1438,899">
<relation target="" sidePair="width-width,height-height"/> <relation target="" sidePair="width-width,height-height"/>
@ -37,7 +40,9 @@
<gearDisplay controller="cBtn" pages="1"/> <gearDisplay controller="cBtn" pages="1"/>
<relation target="" sidePair="center-center"/> <relation target="" sidePair="center-center"/>
</component> </component>
<component id="n33_xo4i" name="n33" src="xo4i1br" fileName="Main_new/Main/Component/btn_vipCancel.xml" xy="1037,715"/> <component id="n33_xo4i" name="btn_jiesan" src="xo4i1br" fileName="Main_new/Main/Component/btn_vipCancel.xml" xy="1037,715">
<gearDisplay controller="lev" pages="0"/>
</component>
<component id="n34_ta4f" name="btn_close" src="vg2c4" fileName="buttons/Btn_close.xml" pkg="27vd145b" xy="1312,19" visible="false" touchable="false"/> <component id="n34_ta4f" name="btn_close" src="vg2c4" fileName="buttons/Btn_close.xml" pkg="27vd145b" xy="1312,19" visible="false" touchable="false"/>
</displayList> </displayList>
</component> </component>