hengyang_client/lua_probject/main_project/main/poker/PKMainView.lua

157 lines
5.3 KiB
Lua
Raw Normal View History

2025-04-01 10:48:36 +08:00
local TableBG = import('Game.Data.TableBG')
local PKSettingView = import('.PKSettingView')
local MainRightPanelView = import('Game.View.MainRightPanelView')
---
local M = {}
2025-04-27 20:22:15 +08:00
setmetatable(M, { __index = MainView })
2025-04-01 10:48:36 +08:00
local pk_default_bg = 1
local pk_bg_config = {
2025-04-27 20:22:15 +08:00
{ 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' }
2025-04-01 10:48:36 +08:00
}
-- settingViewType:1跑得快显示换牌隐藏返回和解散 2超级拼十隐藏解散和换牌 3其他隐藏换牌根据是否观战显示解散和返回
-- ex_defaultbg 自定义默认背景编号
-- ex_bgconfig 自定义的背景
2025-04-27 20:22:15 +08:00
function M:InitView(url, isHideIpAdds, settingViewType, ex_defaultbg, ex_bgconfig, isHideJiesan, settingUrl)
2025-04-01 10:48:36 +08:00
UIPackage.AddPackage('base/main_poker/ui/Main_Poker')
MainView.InitView(self, url, isHideIpAdds)
2025-04-27 20:22:15 +08:00
2025-05-13 14:13:37 +08:00
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, 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
2025-04-01 10:48:36 +08:00
2025-05-13 14:13:37 +08:00
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()
2025-04-01 10:48:36 +08:00
end
function M:InitXiPai()
2025-04-27 20:22:15 +08:00
self._xipaiPanel = UIPackage.CreateObjectFromURL("ui://Common/panel_handPoke")
self._root_view:AddChild(self._xipaiPanel)
local offset = get_offset(self._full_offset)
2025-04-01 10:48:36 +08:00
self._xipaiPanel.width = GRoot.inst.width - (offset * 2)
self._xipaiPanel.height = GRoot.inst.height
self._xipaiPanel.x = offset
2025-04-27 20:22:15 +08:00
self._xipaiPanel.visible = false
self._handAnimCtr = self._xipaiPanel:GetController("anim")
self._handAnimCtr.selectedIndex = 0
--self:PlayXiPai()
2025-04-01 10:48:36 +08:00
end
function M:PlayXiPai(xipaiCallBack)
2025-04-27 20:22:15 +08:00
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
2025-04-01 10:48:36 +08:00
end
function M:InitXiPai1()
2025-04-27 20:22:15 +08:00
self._xipaiPanel1 = UIPackage.CreateObjectFromURL("ui://Common/panel_handPoke02")
self._root_view:AddChild(self._xipaiPanel1)
local offset = get_offset(self._full_offset)
2025-04-01 10:48:36 +08:00
self._xipaiPanel1.width = GRoot.inst.width - (offset * 2)
self._xipaiPanel1.height = GRoot.inst.height
self._xipaiPanel1.x = offset
2025-04-27 20:22:15 +08:00
self._xipaiPanel1.visible = false
self._handAnimCtr1 = self._xipaiPanel1:GetController("anim")
self._handAnimCtr1.selectedIndex = 0
2025-04-01 10:48:36 +08:00
end
function M:PlayXiPai1(xipaiCallBack)
2025-04-27 20:22:15 +08:00
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
2025-04-01 10:48:36 +08:00
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