-- local EXMainView = import(".EXMainView") local SettingView = require('Game.View.SettingView') local PKSettingView = { __checkMainViewState = nil, __changePokerCallBack = nil, __changePokerSizeCallBack = nil, } local M = PKSettingView local function IsRoomOwer() --local roomOwner = self._room.player_list[1].self_user.account_id local roomOwner = DataManager.CurrenRoom.player_list[1].self_user.account_id return roomOwner == DataManager.SelfUser.account_id end function M:Reflash() if IsRoomOwer() then self.cBtn.selectedIndex = 1 end if DataManager.CurrenRoom.playing or DataManager.CurrenRoom.curren_round > 0 then self.cBtn.selectedIndex = 1 end if self._flag_witness then self.cBtn.selectedIndex = 0 end end function M:Show() BaseWindow.Show(self) self:Reflash() end function M:Close() BaseWindow.Close(self) end function PKSettingView.new(blur_view, show_type, isjiesan, url, cardSizeHandle, flag_witness) setmetatable(SettingView, { __index = BaseWindow }) setmetatable(M, { __index = SettingView }) -- setmetatable(M, { __index = BaseWindow }) local self = setmetatable({}, { __index = M }) self.class = 'PKSettingView' self._currenIndex = 0 self._blur_view = blur_view self._flag_witness = flag_witness self.onCallback = event('onCallback', true) self._mainView = blur_view self._close_destroy = true self.stateIndex = 0 self.cd_time = 0 self._btn_dismiss_room_enable = true self._close_destroy = true self._show_type = show_type self.isjiesan = isjiesan self.__changePokerSizeCallBack = cardSizeHandle if url ~= nil then self:init(url) else self:init('ui://Main_Poker/Setting') end return self end function M:init(url) BaseWindow.init(self, url) local view = self._view self.slider_sound = self._view:GetChild('slider_vedio_sound') self.slider_music = self._view:GetChild('slider_vedio_music') self.btn_music = self._view:GetChild('btn_vedio_music') self.btn_sound = self._view:GetChild('btn_vedio_sound') self.btn_cancelRoom = self._view:GetChild("btn_cancelRoom") self.btn_closeRoom = self._view:GetChild("btn_closeRoom") self.cBtnSelect = self._view:GetController("cBtnSelect") self.cBtn = self._view:GetController('cBtn') self.slider_sound.value = GameApplication.Instance.SoundValue self.slider_music.value = GameApplication.Instance.MusicValue self.btn_sound.selected = GameApplication.Instance.SoundMute self.btn_music.selected = GameApplication.Instance.MusicMute self.slider_music.onChanged:Add(function() local value = math.floor(self.slider_music.value) if value > 0 then self.btn_music.selected = false GameApplication.Instance.MusicMute = false; else self.btn_music.selected = true GameApplication.Instance.MusicMute = true; end GameApplication.Instance.MusicValue = value end) self.slider_sound.onChanged:Add(function() local value = math.floor(self.slider_sound.value) if value > 0 then self.btn_sound.selected = false GameApplication.Instance.SoundMute = false; else self.btn_sound.selected = true GameApplication.Instance.SoundMute = true; end GameApplication.Instance.SoundValue = value end) self.btn_sound.onClick:Add(function() GameApplication.Instance.SoundMute = self.btn_sound.selected; self.slider_sound.value = 0 GameApplication.Instance.SoundValue = 0 end) self.btn_music.onClick:Add(function() GameApplication.Instance.MusicMute = self.btn_music.selected; end) self.btn_cancelRoom.onClick:Set(function() -- if self._mainView.dismiss_room_cd_time > 0 then -- ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!") -- return -- end local _gamectr = ControllerManager.GetController(GameController) _gamectr:AskDismissRoom() end) 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) self:Destroy() ViewManager.ChangeView(ViewManager.View_Family) return end 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) local group = DataManager.groups:get(DataManager.CurrenRoom.group_id) self._view:GetController('lev').selectedIndex = (group and group.lev and group.lev < 3) and 0 or 1 self._view: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( DataManager.CurrenRoom.group_id, DataManager.CurrenRoom.room_id, function(res) if self._is_destroy then return end ViewUtil.CloseModalWait() if res.ReturnCode ~= 0 then ViewUtil.ErrorTip(res.ReturnCode, '删除房间失败!') return else 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 ) _curren_msg:Show() end) end function M:Destroy() BaseWindow.Destroy(self) -- self:showSettingOption() end -- 显示设置界面按钮 function M:showSettingOption() local btn_back = self._view:GetChild('btn_back') if btn_back ~= nil then btn_back.onClick:Set( function() local room = DataManager.CurrenRoom local ispanguangzhe = room.self_player.seat == 0 local tip_owner = '您是否退出房间?\n(退出房间后房间将解散)' local tip = '您是否退出房间?' local tipStr = '' if room.agent then tipStr = '您是否返回?' else tipStr = (not ispanguangzhe and room.owner_id == room.self_player.self_user.account_id) and tip_owner or tip end local _curren_msg = MsgWindow.new(self._root_view, tipStr, MsgWindow.MsgMode.OkAndCancel) _curren_msg.onOk:Add( function() -- 如果游戏已经开始,是旁观者发出退出协议,否则的话不能离开 -- 如果没开始,发出退出协议 -- 不用考虑回放,回放不会显示返回按钮 local state = self.__checkMainViewState() local _gamectr = ControllerManager.GetController(GameController) if state > 0 and state < 3 then if ispanguangzhe then ViewUtil.ShowModalWait(self._root_view) _gamectr:LevelRoom( function(res) ViewUtil.CloseModalWait() if res.ReturnCode == 0 then ViewManager.ChangeView(ViewManager.View_Lobby) else ViewUtil.ErrorTip(res.ReturnCode) end end ) else ViewUtil.ErrorTip(nil, '房间已开始,无法退出游戏。') end else ViewUtil.ShowModalWait(self._root_view) _gamectr:LevelRoom( function(res) ViewUtil.CloseModalWait() if res.ReturnCode == 0 then ViewManager.ChangeView(ViewManager.View_Lobby) else ViewUtil.ErrorTip(res.ReturnCode) end end ) end end ) _curren_msg:Show() end ) end end return M