jx_client_neibu/lua_probject/base_project/Game/View/DismissRoomWindow.lua

104 lines
3.5 KiB
Lua
Raw Permalink Normal View History

2025-04-01 10:48:36 +08:00
local DismissRoomWindow = {}
local M = DismissRoomWindow
function DismissRoomWindow.new(blur_view)
2025-10-14 20:44:57 +08:00
setmetatable(M, { __index = BaseWindow })
local self = setmetatable({}, { __index = M })
2025-04-01 10:48:36 +08:00
self.class = "DismissRoomWindow"
self._currenIndex = 0
self._blur_view = blur_view
self._animation = false
2025-10-14 20:44:57 +08:00
self.onCallback = event("onCallback", true)
2025-04-01 10:48:36 +08:00
self._close_zone = false
2025-10-15 18:46:48 +08:00
self._queue = false
2025-04-01 10:48:36 +08:00
self.time = 180
self:init("ui://Common/dismiss_room")
return self
end
function M:init(url)
2025-10-14 20:44:57 +08:00
BaseWindow.init(self, url)
2025-04-01 10:48:36 +08:00
local view = self._view
2025-10-15 18:46:48 +08:00
self._root_view.sortingOrder = 100
2025-04-01 10:48:36 +08:00
self.tex_time = view:GetChild("tex_time")
self.tex_time2 = view:GetChild("tex_time2")
2025-04-01 10:48:36 +08:00
local _btn_aggree = view:GetChild("btn_aggree")
2025-10-14 20:44:57 +08:00
_btn_aggree.onClick:Add(function()
2025-04-01 10:48:36 +08:00
local _gamectr = ControllerManager.GetController(GameController)
if _gamectr then
_gamectr:DismissRoomVote(true)
end
end)
local _btn_reject = view:GetChild("btn_reject")
_btn_reject.onClick:Add(function()
local _gamectr = ControllerManager.GetController(GameController)
if _gamectr then
_gamectr:DismissRoomVote(false)
end
end)
2025-10-15 18:46:48 +08:00
local btn_ok = view:GetChild('btn_ok')
if btn_ok then
btn_ok.onClick:Set(function()
self:Close()
end)
end
2025-04-01 10:48:36 +08:00
end
function M:FillData(data)
self.time = data.time
self.tex_time.text = data.time
local room = DataManager.CurrenRoom
local isHidden = false
if room.room_config and room.room_config.isHidden and room.room_config.isHidden == 1 then
isHidden = true
end
if isHidden then
--self._view:GetChild("tex_tip").text = string.format("[color=#ff9d02]【%s】[/color]发起了解散房间申请,是否同意?","玩家" .. data.req_p.seat)
self._view:GetChild("tex_tip").text = string.format("玩家\\[[color=#70401C]%s[/color]]申请解散房间", data.req_p.seat)
2025-04-01 10:48:36 +08:00
else
--self._view:GetChild("tex_tip").text = string.format("[color=#ff9d02]【%s】[/color]发起了解散房间申请,是否同意?",data.req_p.self_user.nick_name)
2025-10-14 20:44:57 +08:00
self._view:GetChild("tex_tip").text = string.format("玩家\\[[color=#70401C]%s[/color]]申请解散房间",
data.req_p.self_user.nick_name)
2025-04-01 10:48:36 +08:00
end
local ctr_falg = self._view:GetController("falg")
local lst_player = self._view:GetChild("lst_player")
lst_player:RemoveChildrenToPool()
local list = data.list
2025-10-14 20:44:57 +08:00
for i = 1, #list do
2025-04-01 10:48:36 +08:00
local tem = list[i]
if tem.player == DataManager.CurrenRoom.self_player then
ctr_falg.selectedIndex = tem.result
end
-- elseif tem.player ~= data.req_p then
2025-10-14 20:44:57 +08:00
local item = lst_player:AddItemFromPool()
if isHidden then
item:GetChild("tex_name").text = "玩家\\[[color=#70401C]" .. tem.player.seat .. "[/color]]"
else
item:GetChild("tex_name").text = "玩家\\[[color=#70401C]" .. tem.player.self_user.nick_name .. "[/color]]"
end
local ctr_item_falg = item:GetController("falg")
ctr_item_falg.selectedIndex = tem.result
2025-04-01 10:48:36 +08:00
-- end
end
2025-10-15 18:46:48 +08:00
if data._flag_faild then
ctr_falg.selectedIndex = 2
end
2025-04-01 10:48:36 +08:00
end
function M:OnUpdate(deltaTime)
if self.time > 0 then
self.time = self.time - deltaTime
2025-10-14 20:44:57 +08:00
self.time = math.max(0, self.time)
2025-04-01 10:48:36 +08:00
end
self.tex_time.text = tostring(math.floor(self.time)) .. "s"
self.tex_time2.text = tostring(math.floor(self.time))
2025-04-01 10:48:36 +08:00
end
return M