local TableBG = import('Game.Data.TableBG') local PKSettingView = import('.PKSettingView') local MainRightPanelView = import('Game.View.MainRightPanelView') --- local M = {} setmetatable(M, {__index = MainView}) local pk_default_bg = 1 local pk_bg_config = { {id = 1, url = 'base/main_poker/bg/bg3', thumb = 'ui://Main_Poker/bg3'}, {id = 2, url = 'base/main_poker/bg/bg2', thumb = 'ui://Main_Poker/bg2'}, {id = 3, url = 'base/main_poker/bg/bg1', thumb = 'ui://Main_Poker/bg1'} } -- settingViewType:1跑得快:显示换牌,隐藏返回和解散 2超级拼十:隐藏解散和换牌 3其他:隐藏换牌,根据是否观战显示解散和返回 -- ex_defaultbg 自定义默认背景编号 -- ex_bgconfig 自定义的背景 function M:InitView(url, isHideIpAdds, settingViewType, ex_defaultbg, ex_bgconfig, isHideJiesan,settingUrl) UIPackage.AddPackage('base/main_poker/ui/Main_Poker') MainView.InitView(self, url, isHideIpAdds) local default_bg = ex_defaultbg or pk_default_bg local bg_config = ex_bgconfig or pk_bg_config -- 设置界面初始化方法 self.NewSettingView = function(self) -- 根据settingViewType和self._state判断界面按钮功能显示 local stype = 0 local room = DataManager.CurrenRoom local ispanguangzhe = room.self_player.seat == 0 if self._state.selectedIndex == 3 then stype = 0 elseif settingViewType < 2 then stype = settingViewType elseif settingViewType == 2 then if (ispanguangzhe or self._state.selectedIndex == 0) then stype = 2 else stype = 3 end elseif settingViewType == 3 then if not ispanguangzhe and self._state.selectedIndex > 0 then stype = 3 else stype = 2 end end--self._root_view local settingView = PKSettingView.new(self._root_view, stype, isHideJiesan, settingUrl,handler(self, self.UpdateCardSize)) -- 获取MainView界面state控制器选项 settingView.__checkMainViewState = function() return self._state.selectedIndex end -- 设置界面换牌功能回调 if settingViewType == 1 then settingView.__changePokerCallBack = handler(self, self.UpdateCard) settingView.__changePokerSizeCallBack = handler(self, self.UpdateCardSize) end settingView:FillBgSection( function(url) LoadGameBg(url, self._root_view) end, self._room.game_id, default_bg, bg_config ) return settingView end local _view = self._view TableBG.LoadTableBG(default_bg, self._room.game_id, self._root_view, bg_config) local rightpanel = self._view:GetChild('right_panel') if rightpanel then self._rightPanelView = MainRightPanelView.new(self, rightpanel) end self:InitXiPai() self:InitXiPai1() end function M:InitXiPai() self._xipaiPanel = UIPackage.CreateObjectFromURL("ui://Common/panel_handPoke") self._root_view:AddChild(self._xipaiPanel) local offset = get_offset(self._full_offset) self._xipaiPanel.width = GRoot.inst.width - (offset * 2) self._xipaiPanel.height = GRoot.inst.height self._xipaiPanel.x = offset self._xipaiPanel.visible=false self._handAnimCtr=self._xipaiPanel:GetController("anim") self._handAnimCtr.selectedIndex=0 --self:PlayXiPai() end function M:PlayXiPai(xipaiCallBack) if self._xipaiPanel then coroutine.start(function() self._xipaiPanel.visible=true self._xipaiPanel:GetTransition("XiPai"):Play() self._handAnimCtr.selectedIndex=1 coroutine.wait(3.5) self._handAnimCtr.selectedIndex=0 self._xipaiPanel.visible=false if xipaiCallBack then xipaiCallBack() end end) end end function M:InitXiPai1() self._xipaiPanel1 = UIPackage.CreateObjectFromURL("ui://Common/panel_handPoke02") self._root_view:AddChild(self._xipaiPanel1) local offset = get_offset(self._full_offset) self._xipaiPanel1.width = GRoot.inst.width - (offset * 2) self._xipaiPanel1.height = GRoot.inst.height self._xipaiPanel1.x = offset self._xipaiPanel1.visible=false self._handAnimCtr1=self._xipaiPanel1:GetController("anim") self._handAnimCtr1.selectedIndex=0 end function M:PlayXiPai1(xipaiCallBack) if self._xipaiPanel1 then coroutine.start(function() self._xipaiPanel1.visible=true self._xipaiPanel1:GetTransition("XiPai"):Play() self._handAnimCtr1.selectedIndex=1 coroutine.wait(3.5) self._handAnimCtr1.selectedIndex=0 self._xipaiPanel1.visible=false if xipaiCallBack then xipaiCallBack() end end) end end -- 设置界面的换牌回调,需要换牌的玩法settingViewType传1,重写这个方法 function M:UpdateCard(index) end function M:UpdateCardSize(index) end function M:Destroy() UIPackage.RemovePackage('base/main_poker/ui/Main_Poker') MainView.Destroy(self) end return M