You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

288 lines
8.0 KiB

  1. -- 房间内用于显示玩家信息的界面
  2. local ChatDef = require("luaScript.GameChatDefine")
  3. local RoomPlayerInfoViewNew = class("RoomPlayerInfoViewNew", cc.UIView)
  4. --[[
  5. 使用方法:
  6. local view = import("luaScript.Views.Room.RoomPlayerInfoViewNew"):new(nUserId, userInfo)
  7. view:setAnchorPoint(cc.p(0.5, 0.5))
  8. app:showWaitDialog(view, 0, true)
  9. --]]
  10. -- uid : 玩家游戏ID
  11. -- userInfo : 玩家信息
  12. -- headPos : 玩家头像未知
  13. function RoomPlayerInfoViewNew:ctor(uid, userInfo)
  14. RoomPlayerInfoViewNew.super.ctor(self);
  15. self.uid = uid;
  16. local ttUserInfo = type(userInfo)=="string" and json.decode(userInfo) or userInfo
  17. self.sex = tonumber(ttUserInfo.sex) or 1
  18. self.imageUrl = ttUserInfo.headimgurl
  19. self.nickname = ttUserInfo.nickname
  20. self.addr = "未知"
  21. local gpsInfo = ttUserInfo.gpsInfo
  22. if gpsInfo and gpsInfo.addr and gpsInfo.addr~="" then
  23. self.addr = gpsInfo.addr
  24. end
  25. self:loadUI()
  26. end
  27. function RoomPlayerInfoViewNew:loadUI()
  28. local ui = loadUI("res/ui/ui_fangjian/ui_fangjian_wanjiaxinxi.ui")
  29. self.ui = ui
  30. self:addChild(ui)
  31. end
  32. function RoomPlayerInfoViewNew:onEnter()
  33. RoomPlayerInfoViewNew.super.onEnter(self)
  34. -- 点击空白区域关闭界面
  35. self.ui.Items.Layout:registerClick(handler(self, self.onClose))
  36. -- 玩家ID
  37. self.ui.Items.Text_ID:setText(tostring(self.uid))
  38. --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq
  39. -- begin
  40. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  41. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  42. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  43. --隐私数据
  44. local clubInfo = app.club_php.clubList[app.club_php.clubID]
  45. self.cliext = clubInfo.groupext and clubInfo.groupext.cliext
  46. if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
  47. if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then
  48. self.ui.Items.Layout_4:setVisible(true)
  49. else
  50. self.ui.Items.Layout_4:setVisible(false)
  51. end
  52. end
  53. end
  54. end
  55. if self.uid == tonumber(app.user.loginInfo.uid) then
  56. self.ui.Items.Layout_4:setVisible(true)
  57. end
  58. self.ui.Items.Layout_Info:requestDoLayout()
  59. self.ui.Items.Layout_Info:doLayout()
  60. -- end
  61. -- 玩家性别
  62. -- local sexImage
  63. -- if self.sex == 1 then
  64. -- sexImage = "userInfo_boy.png"
  65. -- else
  66. -- sexImage = "userInfo_girl.png"
  67. -- end
  68. -- self.ui.Items.ImageView_Sex:loadTexture(sexImage, cc.TextureResType.plistType)
  69. -- 玩家昵称
  70. local nickname = getShortName(self.nickname)
  71. self.ui.Items.Text_Name:setText(nickname)
  72. -- 玩家头像
  73. setPlayerHeadImage(self.uid, self.imageUrl, self.ui.Items.ImageView_head)
  74. -- 信用评级
  75. --self.ui.Items.Text_XingYong:setVisible(false)
  76. -- 注册时间
  77. -- local time = os.date("%Y.%m.%d",os.time())
  78. -- self.ui.Items.Text_4:setVisible(false)
  79. self.ui.Items.Text_4:setText("地 址:")
  80. self.ui.Items.Text_RegTime:setText(self.addr)
  81. -- self.ui.Items.Text_RegTime:setVisible(false)--:setText(tostring(time))
  82. -- 语音按钮
  83. -- local strRecordTime = tostring(self.recordTime).."''"
  84. -- self.ui.Items.Text_Voice:setText(strRecordTime);
  85. self.ui.Items.Button_uplog:registerClick(handler(self, self.onClickUpLog))
  86. self.ui.Items.Button_voice:registerClick(handler(self, self.onClickVoice))
  87. -- self.ui.Items.Button_Close:registerClick(handler(self, self.onClose))
  88. -- 道具按钮
  89. local Item_Prop = self.ui.Items.Item_Prop
  90. Item_Prop:setVisible(false)
  91. local uiScorllView = self.ui.Items.ScrollView
  92. uiScorllView:removeAllChildren()
  93. uiScorllView:hideAllBar();
  94. uiScorllView:getInnerContainer():setAutoSize(true)
  95. -- loadSpriteFrameFile(Prop_Btn_File)
  96. for _, propId in ipairs(GamePropSort) do
  97. local config = GameProp[propId]
  98. if config then
  99. local item = Item_Prop:getCopied()
  100. local uiBtn = item:getChildByName("Button_Prop")
  101. local ImageView_Lock = item:getChildByName("ImageView_Lock")
  102. ImageView_Lock:setVisible(false)
  103. if config.icon then
  104. uiBtn:loadTextureNormal("res/ui/zy_tongyong/zy_prop/"..config.icon)
  105. uiBtn:loadTexturePressed("res/ui/zy_tongyong/zy_prop/"..config.icon)
  106. uiBtn:loadTextureDisabled("res/ui/zy_tongyong/zy_prop/"..config.icon)
  107. end
  108. uiBtn:registerClick(function() self:onClickProp(propId) end)
  109. uiScorllView:addChild(item)
  110. end
  111. end
  112. self:updateTips()
  113. self:startPropTimer()
  114. self:checkPropModuleStatus()
  115. end
  116. function RoomPlayerInfoViewNew:updateTips()
  117. local isMe = self.uid == app.user.loginInfo.uid
  118. self.ui.Items.Button_uplog:setVisible(isMe)
  119. if app.user:canSendChatMessage(ChatDef.MessageType.Prop) then
  120. if isMe then
  121. self.ui.Items.Text_tip:setText("点击道具全桌群发")
  122. else
  123. self.ui.Items.Text_tip:setText("点击发送道具")
  124. end
  125. end
  126. end
  127. function RoomPlayerInfoViewNew:startPropTimer()
  128. if app.user:canSendChatMessage(ChatDef.MessageType.Prop) then
  129. return
  130. end
  131. local propTime = ChatDef.TimeInterval[ChatDef.MessageType.Prop]
  132. local lastTime = app.user:getLastChatTime(ChatDef.MessageType.Prop)
  133. local tempTime = os.time() - lastTime -->= ChatDef.TimeInterval[ChatDef.MessageType.Prop]
  134. local startTime = propTime - tempTime
  135. if startTime<0 then
  136. startTime = propTime
  137. end
  138. local childs = self.ui.Items.ScrollView:getChildren()
  139. local allBtn = {}
  140. -- local allTime = {}
  141. local allLock = {}
  142. for k,item in pairs(childs) do
  143. local Button_Prop = item:getChildByName("Button_Prop")
  144. local ImageView_Lock = item:getChildByName("ImageView_Lock")
  145. Button_Prop:setTouchEnabled(false)
  146. ImageView_Lock:setVisible(true)
  147. table.insert(allBtn,Button_Prop)
  148. table.insert(allLock,ImageView_Lock)
  149. end
  150. local function setAllLockFalse()
  151. for k,lock in pairs(allLock) do
  152. lock:setVisible(false)
  153. end
  154. end
  155. local function setAllBtn()
  156. for k,btn in pairs(allBtn) do
  157. btn:setTouchEnabled(true)
  158. end
  159. end
  160. local function setAllTime(t)
  161. self.ui.Items.Text_tip:setText(t.."秒后可发送道具")
  162. end
  163. setAllTime(startTime)
  164. self:stopAllActions()
  165. self:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.DelayTime:create(1),cc.CallFunc:create(function()
  166. startTime = startTime-1
  167. if startTime<=0 then
  168. startTime = 0
  169. self:stopAllActions()
  170. logD("RoomPlayerInfoViewNew stopAllActions")
  171. setAllBtn()
  172. setAllLockFalse()
  173. self:updateTips()
  174. return
  175. end
  176. setAllTime(startTime)
  177. end))))
  178. end
  179. -- 发送道具
  180. function RoomPlayerInfoViewNew:onClickProp(propIdx)
  181. if not app.user:canSendChatMessage(ChatDef.MessageType.Prop) then
  182. showTooltip("操作太过频繁,请稍后再发!")
  183. return
  184. end
  185. local uidSender = app.user.loginInfo.uid
  186. local uidReceiver = self.uid
  187. local data =
  188. {
  189. propIdx = propIdx,
  190. uidSender = uidSender,
  191. uidReceiver = uidReceiver,
  192. --isQunFa = uidSender == uidReceiver and 1 or 0,
  193. }
  194. local content = json.encode(data)
  195. local ret = app.user:sendChatMessage(ChatDef.MessageType.Prop, content);
  196. if ret then
  197. self:onClose()
  198. end
  199. end
  200. -- 上传日志
  201. function RoomPlayerInfoViewNew:onClickUpLog( sender )
  202. playBtnEffect()
  203. local view = import("luaScript.Views.Room.UplogView"):new()
  204. view:setAnchorPoint(cc.p(0.5, 0.5))
  205. app:showWaitDialog(view)
  206. end
  207. -- 播放语音
  208. function RoomPlayerInfoViewNew:onClickVoice()
  209. playBtnEffect()
  210. app.user:dispatchEvent({name = GAME_EVENT.CHAT_REPLAY_VOICE , nUserId = self.uid})
  211. end
  212. -- 关闭界面
  213. function RoomPlayerInfoViewNew:onClose()
  214. playBtnEffect()
  215. self:removeFromParent()
  216. end
  217. ---
  218. -- 检测互动道具是否可以使用
  219. -- 亲友圈配置
  220. -- @return
  221. --
  222. function RoomPlayerInfoViewNew:checkPropModuleStatus ()
  223. if not app.room then
  224. return
  225. end
  226. local roomInfo = app.room.roomInfo or {}
  227. local strGameInfo = roomInfo.strGameInfo or roomInfo.nGameInfo or ""
  228. local info = json.decode(strGameInfo) or {}
  229. local isFobid = info.forbidProp == 1
  230. local childs = self.ui.Items.ScrollView:getChildren() or {}
  231. for k, item in pairs(childs) do
  232. item:getChildByName("Button_Prop"):setTouchEnabled(not isFobid)
  233. item:getChildByName("ImageView_Lock"):setVisible(isFobid)
  234. end
  235. if isFobid then
  236. self.ui.Items.Text_tip:setText("当前房间不可使用互动道具")
  237. end
  238. self.ui.Items.Button_voice:setVisible(not isFobid)
  239. end
  240. return RoomPlayerInfoViewNew;