|
-
- -- 房间内用于显示玩家信息的界面
-
- local ChatDef = require("luaScript.GameChatDefine")
-
- local RoomPlayerInfoView = class("RoomPlayerInfoView", cc.UIView)
-
- --[[
- 使用方法:
-
- local view = import("luaScript.Views.Room.RoomPlayerInfoView"):new(nUserId, userInfo, posHead)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view, 0, true)
-
- --]]
-
- -- uid : 玩家游戏ID
- -- userInfo : 玩家信息
- -- headPos : 玩家头像未知
- function RoomPlayerInfoView:ctor(uid, userInfo, headPos, szHead, recordTime, replayRecord,idVisible)
- RoomPlayerInfoView.super.ctor(self);
-
- self.uid = uid;
- self.headPos = headPos;
- self.szHead = szHead;
- self.idVisible = idVisible;
-
- self.recordTime = tonumber(recordTime) or 0
- self.replayRecord = replayRecord;
-
- 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
-
- local ui = loadUI("res/ui/ui_fangjian/ui_fangjian_wanjiaxinxi.ui")
- self.ui = ui;
- self:addChild(ui);
- end
-
- function RoomPlayerInfoView:onEnter()
- RoomPlayerInfoView.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
- if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
- local clubInfo = app.club_php.clubList[app.club_php.clubID]
- 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_RegTime:setVisible(false)--:setText(tostring(time))
-
-
- --显示隐藏游戏内选手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.idVisible = true
- else
- self.idVisible = false
- end
- end
- end
- end
- if self.uid == tonumber(app.user.loginInfo.uid) then
- self.idVisible = true
- end
- self:setIDVisible(self.idVisible)
-
- -- 语音按钮
- -- 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)
-
- --loadSpriteFromFile(Prop_Btn_File)
- -- 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)
- -- local progress = nil
- -- local percent = 0
- 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)
-
- -- local sp = cc.Sprite:createWithSpriteFrameName("userInfo_prop_bgr.png")
-
- -- local progress = cc.ProgressTimer:create(sp)
- -- progress:setPosition(uiBtn:getPosition())
- -- progress:setTag(100)
- -- progress:setReverseDirection(true)
- -- progress:setColor(cc.c3b(255,0,0))
- -- item:addChild(progress)
- end
-
- uiBtn:registerClick(function() self:onClickProp(propId) end)
- uiScorllView:addChild(item)
- end
- end
-
-
-
-
- -- self.ui.Items.ImageView_me:setVisible(isMe)
- -- self.ui.Items.Text_tipOther:setVisible(isMe)
- -- self.ui.Items.Text_tipOther_1:setVisible(isMe)
-
-
- self:updateTips()
- self:startPropTimer()
- -- self:updatePosition()
-
- self:checkPropModuleStatus()
- end
-
- function RoomPlayerInfoView: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 RoomPlayerInfoView: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 Text_Time = item:getChildByName("Text_Time")
- local ImageView_Lock = item:getChildByName("ImageView_Lock")
- -- local progress = item:getChildByTag(100)
- -- progress:setPercentage(100)
- -- Text_Time:setLocalZOrder(1)
- --
- -- Button_Prop:setColor(cc.c3b(0,0,0))
- Button_Prop:setTouchEnabled(false)
- ImageView_Lock:setVisible(true)
-
- table.insert(allBtn,Button_Prop)
- -- table.insert(allTime,Text_Time)
- -- table.insert(allLock,progress)
- table.insert(allLock,ImageView_Lock)
- end
-
- -- local function setAllPercentage(value)
- -- -- logD("value:"..value)
- -- for k,lock in pairs(allLock) do
- -- -- lock:setVisible(false)
- -- lock:setPercentage(value)
- -- end
- -- end
-
- local function setAllLockFalse()
- -- logD("value:"..value)
- for k,lock in pairs(allLock) do
- lock:setVisible(false)
- -- lock:setPercentage(value)
- end
- end
-
- local function setAllBtn()
- for k,btn in pairs(allBtn) do
- -- btn:setColor(cc.c3b(255,255,255))
- btn:setTouchEnabled(true)
- end
- end
-
- local function setAllTime(t)
- self.ui.Items.Text_tip:setText(t.."秒后可发送道具")
- -- for k,time in pairs(allTime) do
- -- time:setText(t)
- -- end
- 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()
- setAllBtn()
- -- setAllPercentage(0)
- setAllLockFalse()
- self:updateTips()
- -- setAllTime("")
- return
- -- startTime = ChatDef.TimeInterval[ChatDef.MessageType.Prop]
- end
- -- setAllPercentage(100-(propTime-startTime)/propTime*100)
- setAllTime(startTime)
- -- progress:setPercentage(startTime/ChatDef.TimeInterval[ChatDef.MessageType.Prop]*100)
- end))))
- end
-
- -- 根据玩家头像节点的位置,自动调整本界面的位置
- function RoomPlayerInfoView:updatePosition()
-
- -- 把屏幕划分为9个相等的区域,根据玩家头像所在的区域,决定本界面在玩家头像的什么位置
-
-
- local function getAnchorPoint(pos)
- local qu = 2
- --local winSize = cc.Director:getInstance():getOpenGLView():getFrameSize();
- local winSize = cc.Director:getInstance():getWinSize()
- local minWidth = winSize.width / qu;
- local minHeight = winSize.height / qu;
-
- local szHead = self.szHead;
-
- -- 左下
- if pos.x <= minWidth and pos.y <= minHeight then
- return cc.p(0,0), cc.p(szHead.width / 2, -szHead.height / 2); --
- -- 左
- elseif pos.x <= minWidth and pos.y >= minHeight and pos.y <= minHeight * (qu - 1) then
- return cc.p(0,0.5), cc.p(szHead.width / 2, 0);
- -- 左上
- elseif pos.x <= minWidth and pos.y >= minHeight * (qu - 1) then
- return cc.p(0,1), cc.p(szHead.width / 2, szHead.height / 2);--
- -- 上
- elseif pos.x >= minWidth and pos.x <= minWidth * (qu - 1) and pos.y >= minHeight * (qu - 1) then
- return cc.p(0.5,1), cc.p(0, 0);---szHead.height / 2
- -- 右上
- elseif pos.x >= minWidth * (qu - 1) and pos.y >= minHeight * (qu - 1) then
- return cc.p(1,1), cc.p(-szHead.width / 2, szHead.height / 2);---szHead.height / 2
- -- 右
- elseif pos.x >= minWidth * (qu - 1) and pos.y >= minHeight and pos.y <= minHeight * (qu - 1) then
- return cc.p(1,0.5), cc.p(-szHead.width / 2, 0);
- -- 右下
- elseif pos.x >= minWidth * (qu - 1) and pos.y <= minHeight then
- return cc.p(1,0), cc.p(-szHead.width / 2, -szHead.height / 2); --szHead.height / 2
- -- 下
- elseif pos.x >= minWidth and pos.x <= minWidth * (qu - 1) and pos.y <= minHeight then
- return cc.p(0.5,0), cc.p(0, -szHead.height / 2 ); --szHead.height / 2
- -- 中
- else
- return cc.p(0,0), cc.p(0,0);
- end
-
- return cc.p(0,0), cc.p(0,0);
- end
-
- local anPoint, point = getAnchorPoint(self.headPos)
- local pos = cc.p(self.headPos.x + point.x, self.headPos.y + point.y );--
- self.ui.Items.Layout_1:setAnchorPoint(anPoint);
- self.ui.Items.Layout_1:setPosition(pos);
- end
-
- -- 发送道具
- function RoomPlayerInfoView: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 RoomPlayerInfoView:onClickUpLog( sender )
- playBtnEffect()
- local view = import("luaScript.Views.Room.UplogView"):new()
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view)
- end
-
- -- 播放语音
- function RoomPlayerInfoView:onClickVoice()
- playBtnEffect()
- if self.recordTime <= 0 then
- showTooltip("无历史消息")
- return
- end
-
- if self.replayRecord then
- self.replayRecord(self.uid)
- end
-
- -- local nodeClip = self.ui.Items.Layout_2;
-
- -- nodeClip:playClip("say");
- -- nodeClip:runDelay(self.recordTime, function()
- -- nodeClip:stopClip("say")
- -- end)
- end
-
- -- 关闭界面
- function RoomPlayerInfoView:onClose()
- playBtnEffect()
- self:removeFromParent()
- end
-
- -- 关闭界面
- function RoomPlayerInfoView:setIDVisible(bVisible)
- self.ui.Items.Layout_4:setVisible(bVisible)
- self.ui.Items.Layout_Info:requestDoLayout()
- self.ui.Items.Layout_Info:doLayout()
- end
- ---
- -- 检测互动道具是否可以使用
- -- 亲友圈配置
- -- @return
- --
- function RoomPlayerInfoView: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 RoomPlayerInfoView;
|