jx_client_neibu/lua_probject/main_project/main/poker2/PKMainView.lua

165 lines
5.5 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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
print("lingmengmainview2", self.dismiss_room_cd_time)
local settingView = PKSettingView.new(self, 0, 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()
local Btn_Ready = _view:GetChild('Btn_Ready')
if Btn_Ready ~= nil then
Btn_Ready.onClick:Set(function()
self._gamectr:PlayerReady()
end)
end
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