local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef") local ZPFunctions = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions") local ZPWanFa=ZPFramework.ImportWanFa("luaScript.SubGameDefine.ZiPai.ZPWanFa") local ZPRoomToolView = class("ZPRoomToolView", cc.UIView) function ZPRoomToolView:ctor() ZPRoomToolView.super.ctor(self); --是否是该场景点了准备 self.isTouchCurScene = false end function ZPRoomToolView:loadUi() local ui = loadUI("zp_base/res/ui/ui_fangjian/zipai_ui_Tool.ui"); self.ui = ui; self:addChild(ui); end function ZPRoomToolView:onEnter() ZPRoomToolView.super.onEnter(self) self:loadUi() --测试开关 self.ui.Items.Layout_Test:setVisible(false) --播放队列 self.ui.Items.Button_Play:registerClick(function () app.net:onMsgResume() end) --停止队列 self.ui.Items.Button_Stop:registerClick(function () app.net:onMsgPause() end) -- 复制功能 self.ui.Items.btnCopy:registerClick(function () --playBtnEffect() self:onClickFriends(true) end) -- --上传日记 -- local day = os.date("%Y-%m-%d") -- local key = string.format("dingdinglog-%s",day) -- local isShow = cc.UserDefault:getInstance():getBoolForKey(key,false) -- if isShow or isReviewVersion() then -- self.ui.Items.Button_updateLog:setVisible(false) -- end -- if isDebug() or cc.Application:getInstance():getTargetPlatform() == 0 then -- self.ui.Items.Button_updateLog:setVisible(true) -- end -- self.ui.Items.Button_updateLog:registerClick(handler(self , self.onClickLog)) -- 邀请微信好友 self.ui.Items.btnInvite:registerClick(handler(self , self.onClickFriends)) -- 准备按钮 self.ui.Items.Button_Ready:registerClick(handler(self , self.onClickReady)) -- 详情 self.ui.Items.Button_ruleIntro:registerClick(handler(self , self.onClickRule)) self.ui.Items.Button_ruleIntro:setVisible(false) --邀请俱乐部成员 self.ui.Items.Button_Invite_Club:registerClick(handler(self , self.onClickInviteClub)) -- 快速开始 self.ui.Items.Button_EarlyStart:registerClick(handler(self , self.onClickQuickStart)) self.ui.Items.Button_EarlyStart:setVisible(false) if self.ui.Items.Button_club then self.ui.Items.Button_club:setVisible(false) end if isReviewVersion() then self.ui.Items.btnInvite:setVisible(false) self.ui.Items.Button_Invite_Club:setVisible(false) end self:initButtonFace() self:initButtonVoice() end function ZPRoomToolView:hideOther() -- 通知游戏场景关掉一些界面 if app and app.room then app.room:dispatchEvent({name = "onHideOther"}); end end function ZPRoomToolView:onClickReady() self.ui:sendMsg(app.room, "callReadyRequest"); playVoice("res/sound/room/sit.ogg") self.isTouchCurScene = true end -- 聊天界面 function ZPRoomToolView:onClickChat() playBtnEffect() local view = import("zp_base.luaScript.Views.Room.ZPRoomSettingView"):new(); view:setAnchorPoint(cc.p(0.5, 0.5)); app:showWaitDialog(view); end --点击玩法 function ZPRoomToolView:onClickLog() print("=========================DingDingLog===============================") local uiTechnialView uiTechnialView = import("luaScript.Views.Room.UplogView"):new() self:addChild(uiTechnialView) end -- 邀请好友 function ZPRoomToolView:onClickFriends(iscopy)--是否是复制功能 local roomInfo = app.room.roomInfo; local tt = { [0] = "零缺三", [1] = "一缺二", [2] = "二缺一", [3] = "满座", } local tt2 = { [0] = "零缺二", [1] = "一缺一", [2] = "满座", } local tt3 = { [0] = "零缺四", [1] = "一缺三", [2] = "二缺二", [3] = "三缺一", [4] = "满座", } local jsonInfo = json.decode(roomInfo.strGameInfo) local num = table.nums(app.room.roomInfo.memberList) local strNum = tt[num] if tonumber(jsonInfo.playnum) == 2 then strNum = tt2[num] elseif tonumber(jsonInfo.playnum) == 4 or tonumber(jsonInfo.playnum) == -1 then strNum = tt3[num] end --局数 local strGameNum = string.format("%s局", app.room.roomInfo.nTotalGameNum) local title = string.format("%s 房号[%s] %s %s" , ZPDef.GameName,app.room.roomInfo.nShowTableId,strNum,strGameNum) if app.club_php.clubID and app.club_php.clubID ~= 0 then title = string.format("%s %sID[%d]", title,(app.club_php:getCestIsOpen(app.club_php.clubID) and PLN.CLUB_CEST_NAME or PLN.CLUB_NAME), tonumber(app.club_php.clubID)) end local strGameMode = ZPWanFa.getRuleInfo(app.room.roomInfo.strGameInfo) local strNames = "" local index = 0 for k,v in pairs(app.room.roomInfo.memberList) do index = index + 1 local userInfo = json.decode(v.userInfo) local name = getSubStringNickname(userInfo.nickname) strNames = strNames..name if index < num then strNames = strNames.."," end end local desc = string.format("%s \n玩家:%s", strGameMode, strNames) print(desc) local info = {} info.title = title info.description = desc info.copyData={type=2} local view = import("luaScript.Views.Main.ShareView"):new(info) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) if iscopy and true == iscopy then view:onClickCopy() else playBtnEffect() end end function ZPRoomToolView:onClickRule() self.ui.Items.ImageView_Rule_bg:setVisible(not self.ui.Items.ImageView_Rule_bg:isVisible()) end function ZPRoomToolView:showFastStart(is) local roomInfo = app.room.roomInfo local curCount = roomInfo.nGameStartCount or 0 if curCount > 0 or (roomInfo.nStatus and roomInfo.nStatus>=ZPDef.ReconnectState.GAME_STATUS_WAIT_OUT_CARDS and roomInfo.nStatus<=ZPDef.ReconnectState.GAME_STATUS_GAME_OVER) then self.ui.Items.Button_EarlyStart:setVisible(false) else local gameInfo=json.decode(roomInfo.strGameInfo) local playnum = gameInfo.playnum or 0 if playnum == -1 then playnum = 4 end local isShowEarlyStart = table.nums(app.room.roomInfo.memberList) < playnum and table.nums(app.room.roomInfo.memberList) > 1 if true == is and isShowEarlyStart and curCount<=0 then self.ui.Items.Button_EarlyStart:setVisible(true) else self.ui.Items.Button_EarlyStart:setVisible(false) end if gameInfo.startMode and gameInfo.startMode == 0 then--不是快速组局 self.ui.Items.Button_EarlyStart:setVisible(false) end end end function ZPRoomToolView:onClickQuickStart() playBtnEffect() app.room:requestQuickStart(1) end function ZPRoomToolView:onClickInviteClub() playBtnEffect() if app.club_php.clubID and app.club_php.clubID ~= 0 then local roomInfo = app.room.roomInfo; local strInvite = ZPFunctions.getClubInviteWanFa(roomInfo.gameId or app.gameId, roomInfo) local view = import("luaScript.Views.Club.ClubInvite"):new(roomInfo.nShowTableId, strInvite) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end end --设置邀请茶馆成员显示 function ZPRoomToolView:setInviteClubVisible(bVisible) if self.ui.Items.Button_Invite_Club then if app.club_php.clubID and app.club_php.clubID ~= 0 then self.ui.Items.Button_Invite_Club:setVisible(bVisible) else self.ui.Items.Button_Invite_Club:setVisible(false) end --self.ui.Items.Button_Invite_Club:setVisible(false) local roomInfo = app.room.roomInfo or {} local gameId = roomInfo.gameId or app.gameId local gameConfig = getSubGameConfig(gameId) if gameConfig.isOpenClubInvite == false then self.ui.Items.Button_Invite_Club:getParent():setVisible(false) end end end --按钮位置调整 function ZPRoomToolView:updateButtonPosition() if not self.ui.Items.Layout_Button then return end if not self.ui.Items.Button_Invite_Club then return end self.ui.Items.Button_Ready:getParent():setVisible(self.ui.Items.Button_Ready:isVisible()) self.ui.Items.btnInvite:getParent():setVisible(self.ui.Items.btnInvite:isVisible()) if self.ui.Items.Button_Invite_Club then self.ui.Items.Button_Invite_Club:getParent():setVisible(self.ui.Items.Button_Invite_Club:isVisible()) end local roomInfo = app.room.roomInfo or {} local gameId = roomInfo.gameId or app.gameId local gameConfig = getSubGameConfig(gameId) if gameConfig.isOpenClubInvite == false then self.ui.Items.Button_Invite_Club:getParent():setVisible(false) end if self.ui.Items.Layout_Button then self.ui.Items.Layout_Button:requestDoLayout() self.ui.Items.Layout_Button:doLayout() end end --- -- 初始化语音 -- @return -- function ZPRoomToolView:initButtonVoice () if self.ui.Items.Button_Voice then self:initVoiceComponent() self.ui.Items.Button_Voice:setVisible(not ZPFunctions.isVoiceFobided()) end end --- -- 初始化语音聊天功能 -- @return -- function ZPRoomToolView:initVoiceComponent() local voiceComponentView = import("luaScript.Views.Room.RoomVoiceComponentView"):new(self.ui.Items.Button_Voice) self:addChild(voiceComponentView) end --- -- 初始化聊天 -- @return -- function ZPRoomToolView:initButtonFace () if self.ui.Items.Button_Face then self.ui.Items.Button_Face:registerClick(handler(self,self.onClickFace)) self.ui.Items.Button_Face:setVisible(not ZPFunctions.isPropFobided()) end end --- -- 聊天按钮点击事件 -- @return -- function ZPRoomToolView:onClickFace() local chatView = import("luaScript.Views.Room.RoomChatView"):new(ZPDef.ChatTxt or {}, nil) chatView:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(chatView,0,true) end --- -- 隐藏语音按钮 -- @return -- function ZPRoomToolView:hideVoiceButton () self.ui.Items.Button_Voice:setVisible(false) end --- -- 隐藏聊天按钮 -- @return -- function ZPRoomToolView:hideFaceButton () self.ui.Items.Button_Face:setVisible(false) end return ZPRoomToolView;