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

89 lines
2.8 KiB
Lua

local DismissRoomWindow = {}
local M = DismissRoomWindow
function DismissRoomWindow.new(blur_view)
setmetatable(M, {__index = BaseWindow})
local self = setmetatable({}, {__index = M})
self.class = "DismissRoomWindow"
self._currenIndex = 0
self._blur_view = blur_view
self._animation = false
self.onCallback = event("onCallback",true)
self._close_zone = false
self.time = 180
self:init("ui://Common/dismiss_room")
return self
end
function M:init(url)
BaseWindow.init(self,url)
local view = self._view
self.tex_time = view:GetChild("tex_time")
local _btn_aggree = view:GetChild("btn_aggree")
_btn_aggree.onClick:Add(function()
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)
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)
else
self._view:GetChild("tex_tip").text = string.format("[color=#ff9d02]【%s】[/color]发起了解散房间申请,是否同意?",data.req_p.self_user.nick_name)
end
local ctr_falg = self._view:GetController("falg")
local lst_player = self._view:GetChild("lst_player")
lst_player:RemoveChildrenToPool()
local list = data.list
for i=1,#list do
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
local item = lst_player:AddItemFromPool()
if isHidden then
item:GetChild("tex_name").text = "玩家"..tem.player.seat
else
item:GetChild("tex_name").text = tem.player.self_user.nick_name
end
local ctr_item_falg = item:GetController("falg")
ctr_item_falg.selectedIndex = tem.result
-- end
end
end
function M:OnUpdate(deltaTime)
if self.time > 0 then
self.time = self.time - deltaTime
self.time = math.max(0, self.time)
end
self.tex_time.text = tostring(math.floor(self.time))
end
return M