--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}) 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._full = true self._anim_pop = 2 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/SettingWindow1') end return self end function M:init(url) SettingView.init(self, url) -- show_type:1隐藏所有 2隐藏解散和换牌 3隐藏返回和换牌 -- 设置界面有换牌功能的,需要在mainview中重写方法UpdateCard self._view:GetController('type').selectedIndex = self._show_type -- show_type1玩法的换牌功能 if self._show_type == 1 then local room = DataManager.CurrenRoom local c1 = self._view:GetController('paimian') local user_id = DataManager.SelfUser.account_id local json_data = Utils.LoadLocalFile(user_id .. room.game_id .. 'pai') if json_data == nil then local _gamectr = self._gamectr c1.selectedIndex = 0 else local _data = json.decode(json_data) local pai = _data['pai'] c1.selectedIndex = pai end c1.onChanged:Set( function() if self.__changePokerCallBack then self.__changePokerCallBack(c1.selectedIndex) end --点击换牌按钮后保存当前游戏的牌 local user_id = DataManager.SelfUser.account_id local _data = {} _data['pai'] = c1.selectedIndex local key = user_id .. room.game_id .. 'pai' Utils.SaveLocalFile(key, json.encode(_data)) end ) local card_size = self._view:GetController('card_size') json_data = Utils.LoadLocalFile(user_id .. room.game_id .. 'cardsize') if json_data == nil then local _gamectr = self._gamectr card_size.selectedIndex = 1 else local _data = json.decode(json_data) local cardsize = _data['cardsize'] card_size.selectedIndex = cardsize end card_size.onChanged:Set( function() if self.__changePokerSizeCallBack then self.__changePokerSizeCallBack(card_size.selectedIndex) end --点击换牌按钮后保存当前游戏的牌 local user_id = DataManager.SelfUser.account_id local _data = {} _data['cardsize'] = card_size.selectedIndex local key = user_id .. room.game_id .. 'cardsize' Utils.SaveLocalFile(key, json.encode(_data)) end ) self._view:GetChild('btn_close').onClick:Add( function(...) self:Destroy() end ) end if self.isjiesan then self._view:GetChild('n82').visible = false end end function M:Show() SettingView.Show(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