-- 茶馆踢出房间操作按钮Layout local ClubTableKickMenu = class("ClubTableKickMenu" , cc.UIView); function ClubTableKickMenu:ctor(clubId, tableIndex ,callback) ClubTableKickMenu.super.ctor(self) self:loadUI() self.tableIndex = tableIndex self.clubId = clubId self.clubInfo = app.club_php.clubList[clubId] self.room = self.clubInfo.rooms[tableIndex] self.callback = callback end function ClubTableKickMenu:loadUI() local ui = loadUI("res/ui/ui_club/ui_club_table_kick_menu.ui") self.ui = ui self:addChild(ui) end function ClubTableKickMenu:onEnter() ClubTableKickMenu.super.onEnter(self) self.ui.Items.Layout_player:setVisible(false); self:bindAllEvent(); self:showPlayerInfo(); end function ClubTableKickMenu:bindAllEvent() self:bindEvent(app.club , "onClubKickResponse" , handler(self , self.onClubKickResponse)); end function ClubTableKickMenu:showPlayerInfo() if not self.room then showTooltip("房间不存在!") return end local gameId = nil local baoJian = app.club_php:getBaoJian(self.clubId,self.room.baoJianId) gameId = baoJian.realGameId local menuList = self.ui.Items.Layout_btn_menu; local uiTemplate = self.ui.Items.Layout_player; for k, v in pairs(self.room.players) do local uiItem = uiTemplate:getCopied() uiItem.Items = getUIItems(uiItem) -- 准备状态 -- 0未连接,可判断离线1已登陆,正常为坐下2准备3在玩4在玩过程中离线5准备但离线6坐下但离线 if v.state == 2 or v.state == 5 then uiItem.Items.Text_status:setText("准备"); elseif v.state == 3 or v.state == 4 then uiItem.Items.Text_status:setText("正在玩"); else uiItem.Items.Text_status:setText("未准备"); end -- 昵称 local nickname = getSubStringNickname(v.nickname,uiItem.Items.Text_name) uiItem.Items.Text_name:setText(nickname); --踢出按钮 uiItem.Items.Button_kick:registerClick(function () local content = "是否将该玩家踢出房间?" if app.club_php:getCestIsOpen(self.clubId) then content = "是否将该选手踢出房间?" end --确认回调 local function okCallback() local kickInfo = ClubKickRequest:new() --游戏id kickInfo.gameid = gameId --房间号 kickInfo.tableid = self.room.roomId --茶馆id kickInfo.groupid = self.clubId --被踢玩家uid kickInfo.beKickUid = v.uid app.club:requestKickInClub(kickInfo) end local function onCancel() end showConfirmDialog(content, okCallback, onCancel, nil); end) menuList:addChild(uiItem); end -- 重新布局 menuList:requestDoLayout() menuList:doLayout() end function ClubTableKickMenu:onClubKickResponse() if self.callback then self.callback(self.tableIndex) end self:removeFromParent() end return ClubTableKickMenu