-- 房间内用于显示玩家信息的界面 local ChatDef = require("luaScript.GameChatDefine") local RoomPlayerInfoViewNew = class("RoomPlayerInfoViewNew", cc.UIView) --[[ 使用方法: local view = import("luaScript.Views.Room.RoomPlayerInfoViewNew"):new(nUserId, userInfo) view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view, 0, true) --]] -- uid : 玩家游戏ID -- userInfo : 玩家信息 -- headPos : 玩家头像未知 function RoomPlayerInfoViewNew:ctor(uid, userInfo) RoomPlayerInfoViewNew.super.ctor(self); self.uid = uid; local ttUserInfo = type(userInfo)=="string" and json.decode(userInfo) or userInfo self.sex = tonumber(ttUserInfo.sex) or 1 self.imageUrl = ttUserInfo.headimgurl self.nickname = ttUserInfo.nickname self.addr = "未知" local gpsInfo = ttUserInfo.gpsInfo if gpsInfo and gpsInfo.addr and gpsInfo.addr~="" then self.addr = gpsInfo.addr end self:loadUI() end function RoomPlayerInfoViewNew:loadUI() local ui = loadUI("res/ui/ui_fangjian/ui_fangjian_wanjiaxinxi.ui") self.ui = ui self:addChild(ui) end function RoomPlayerInfoViewNew:onEnter() RoomPlayerInfoViewNew.super.onEnter(self) -- 点击空白区域关闭界面 self.ui.Items.Layout:registerClick(handler(self, self.onClose)) -- 玩家ID self.ui.Items.Text_ID:setText(tostring(self.uid)) --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq -- begin local ClubDefine = require("luaScript.Protocol.Club.ClubDefine") if app.club_php.clubID and app.club_php.clubID ~= 0 then if app.club_php:getCestIsOpen(app.club_php.clubID) then --隐私数据 local clubInfo = app.club_php.clubList[app.club_php.clubID] self.cliext = clubInfo.groupext and clubInfo.groupext.cliext if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then self.ui.Items.Layout_4:setVisible(true) else self.ui.Items.Layout_4:setVisible(false) end end end end if self.uid == tonumber(app.user.loginInfo.uid) then self.ui.Items.Layout_4:setVisible(true) end self.ui.Items.Layout_Info:requestDoLayout() self.ui.Items.Layout_Info:doLayout() -- end -- 玩家性别 -- local sexImage -- if self.sex == 1 then -- sexImage = "userInfo_boy.png" -- else -- sexImage = "userInfo_girl.png" -- end -- self.ui.Items.ImageView_Sex:loadTexture(sexImage, cc.TextureResType.plistType) -- 玩家昵称 local nickname = getShortName(self.nickname) self.ui.Items.Text_Name:setText(nickname) -- 玩家头像 setPlayerHeadImage(self.uid, self.imageUrl, self.ui.Items.ImageView_head) -- 信用评级 --self.ui.Items.Text_XingYong:setVisible(false) -- 注册时间 -- local time = os.date("%Y.%m.%d",os.time()) -- self.ui.Items.Text_4:setVisible(false) self.ui.Items.Text_4:setText("地 址:") self.ui.Items.Text_RegTime:setText(self.addr) -- self.ui.Items.Text_RegTime:setVisible(false)--:setText(tostring(time)) -- 语音按钮 -- local strRecordTime = tostring(self.recordTime).."''" -- self.ui.Items.Text_Voice:setText(strRecordTime); self.ui.Items.Button_uplog:registerClick(handler(self, self.onClickUpLog)) self.ui.Items.Button_voice:registerClick(handler(self, self.onClickVoice)) -- self.ui.Items.Button_Close:registerClick(handler(self, self.onClose)) -- 道具按钮 local Item_Prop = self.ui.Items.Item_Prop Item_Prop:setVisible(false) local uiScorllView = self.ui.Items.ScrollView uiScorllView:removeAllChildren() uiScorllView:hideAllBar(); uiScorllView:getInnerContainer():setAutoSize(true) -- loadSpriteFrameFile(Prop_Btn_File) for _, propId in ipairs(GamePropSort) do local config = GameProp[propId] if config then local item = Item_Prop:getCopied() local uiBtn = item:getChildByName("Button_Prop") local ImageView_Lock = item:getChildByName("ImageView_Lock") ImageView_Lock:setVisible(false) if config.icon then uiBtn:loadTextureNormal("res/ui/zy_tongyong/zy_prop/"..config.icon) uiBtn:loadTexturePressed("res/ui/zy_tongyong/zy_prop/"..config.icon) uiBtn:loadTextureDisabled("res/ui/zy_tongyong/zy_prop/"..config.icon) end uiBtn:registerClick(function() self:onClickProp(propId) end) uiScorllView:addChild(item) end end self:updateTips() self:startPropTimer() self:checkPropModuleStatus() end function RoomPlayerInfoViewNew:updateTips() local isMe = self.uid == app.user.loginInfo.uid self.ui.Items.Button_uplog:setVisible(isMe) if app.user:canSendChatMessage(ChatDef.MessageType.Prop) then if isMe then self.ui.Items.Text_tip:setText("点击道具全桌群发") else self.ui.Items.Text_tip:setText("点击发送道具") end end end function RoomPlayerInfoViewNew:startPropTimer() if app.user:canSendChatMessage(ChatDef.MessageType.Prop) then return end local propTime = ChatDef.TimeInterval[ChatDef.MessageType.Prop] local lastTime = app.user:getLastChatTime(ChatDef.MessageType.Prop) local tempTime = os.time() - lastTime -->= ChatDef.TimeInterval[ChatDef.MessageType.Prop] local startTime = propTime - tempTime if startTime<0 then startTime = propTime end local childs = self.ui.Items.ScrollView:getChildren() local allBtn = {} -- local allTime = {} local allLock = {} for k,item in pairs(childs) do local Button_Prop = item:getChildByName("Button_Prop") local ImageView_Lock = item:getChildByName("ImageView_Lock") Button_Prop:setTouchEnabled(false) ImageView_Lock:setVisible(true) table.insert(allBtn,Button_Prop) table.insert(allLock,ImageView_Lock) end local function setAllLockFalse() for k,lock in pairs(allLock) do lock:setVisible(false) end end local function setAllBtn() for k,btn in pairs(allBtn) do btn:setTouchEnabled(true) end end local function setAllTime(t) self.ui.Items.Text_tip:setText(t.."秒后可发送道具") end setAllTime(startTime) self:stopAllActions() self:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.DelayTime:create(1),cc.CallFunc:create(function() startTime = startTime-1 if startTime<=0 then startTime = 0 self:stopAllActions() logD("RoomPlayerInfoViewNew stopAllActions") setAllBtn() setAllLockFalse() self:updateTips() return end setAllTime(startTime) end)))) end -- 发送道具 function RoomPlayerInfoViewNew:onClickProp(propIdx) if not app.user:canSendChatMessage(ChatDef.MessageType.Prop) then showTooltip("操作太过频繁,请稍后再发!") return end local uidSender = app.user.loginInfo.uid local uidReceiver = self.uid local data = { propIdx = propIdx, uidSender = uidSender, uidReceiver = uidReceiver, --isQunFa = uidSender == uidReceiver and 1 or 0, } local content = json.encode(data) local ret = app.user:sendChatMessage(ChatDef.MessageType.Prop, content); if ret then self:onClose() end end -- 上传日志 function RoomPlayerInfoViewNew:onClickUpLog( sender ) playBtnEffect() local view = import("luaScript.Views.Room.UplogView"):new() view:setAnchorPoint(cc.p(0.5, 0.5)) app:showWaitDialog(view) end -- 播放语音 function RoomPlayerInfoViewNew:onClickVoice() playBtnEffect() app.user:dispatchEvent({name = GAME_EVENT.CHAT_REPLAY_VOICE , nUserId = self.uid}) end -- 关闭界面 function RoomPlayerInfoViewNew:onClose() playBtnEffect() self:removeFromParent() end --- -- 检测互动道具是否可以使用 -- 亲友圈配置 -- @return -- function RoomPlayerInfoViewNew:checkPropModuleStatus () if not app.room then return end local roomInfo = app.room.roomInfo or {} local strGameInfo = roomInfo.strGameInfo or roomInfo.nGameInfo or "" local info = json.decode(strGameInfo) or {} local isFobid = info.forbidProp == 1 local childs = self.ui.Items.ScrollView:getChildren() or {} for k, item in pairs(childs) do item:getChildByName("Button_Prop"):setTouchEnabled(not isFobid) item:getChildByName("ImageView_Lock"):setVisible(isFobid) end if isFobid then self.ui.Items.Text_tip:setText("当前房间不可使用互动道具") end self.ui.Items.Button_voice:setVisible(not isFobid) end return RoomPlayerInfoViewNew;