-- local EXMainView = import(".EXMainView") local SettingView = require('Game.View.SettingView') local PKSettingView = { __checkMainViewState = nil, __changePokerCallBack = nil, __changePokerSizeCallBack = nil, } local M = PKSettingView function PKSettingView.new(blur_view, show_type, isjiesan, url, cardSizeHandle) 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.onCallback = event('onCallback', 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 local slider_sound = view:GetChild('slider_vedio_sound') local slider_music = view:GetChild('slider_vedio_music') local btn_music = view:GetChild('btn_vedio_music') local btn_sound = view:GetChild('btn_vedio_sound') -- slider_sound.value = GameApplication.Instance.SoundValue -- slider_music.value = GameApplication.Instance.MusicValue slider_music.onChanged:Add(function() -- GameApplication.Instance.MusicValue = slider_music.value -- btn_music.selected = false -- GameApplication.Instance.MusicMute = false; end) slider_sound.onChanged:Add(function() -- GameApplication.Instance.SoundValue = slider_sound.value -- btn_sound.selected = false -- GameApplication.Instance.SoundMute = false; end) btn_sound.onClick:Add(function() -- GameApplication.Instance.SoundMute = btn_sound.selected; end) btn_music.onClick:Add(function() -- GameApplication.Instance.MusicMute = btn_music.selected; end) local _btn_logout = self._view:GetChild('btn_closeRoom') _btn_logout.onClick:Set(function() if self._blur_view.dismiss_room_cd_time > 0 then ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!") else local _gamectr = ControllerManager.GetController(GameController) _gamectr:AskDismissRoom() end end) end function M:Show() BaseWindow.Show(self) -- self:showSettingOption() 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.CloseModalWait2() 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.CloseModalWait2() 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