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.

211 regels
7.3 KiB

  1. local PdkGameOverView = class("PdkGameOverView", cc.UIView)
  2. local GameOverItem = require("pk_paodekuai.luaScript.Views.Room.Node.PdkGameOverItem")
  3. --[[
  4. "onResponseGameOver" = {
  5. "players" = {
  6. 1 = {
  7. "extString" = "{"bombTimes":0,"loseTimes":2,"maxScore":0,"winTimes":0}"
  8. "totalScore" = -6
  9. "userId" = 1023546
  10. }
  11. 2 = {
  12. "extString" = "{"bombTimes":0,"loseTimes":0,"maxScore":3,"winTimes":2}"
  13. "totalScore" = 6
  14. "userId" = 1023544
  15. }
  16. }
  17. }
  18. ]]
  19. function PdkGameOverView:ctor( overData )
  20. self._data = overData
  21. local ui = loadUI("pk_paodekuai/res/ui/ui_room/ui_pdk_gameoverview.ui")
  22. self.ui = ui
  23. self:addChild(ui)
  24. self:initUi()
  25. self:setPlayerInfo()
  26. end
  27. function PdkGameOverView:initUi()
  28. self.ui.Items.btnShare:registerClick(handler(self , self.onClickShare))
  29. self.ui.Items.btnOk:registerClick(handler(self , self.onClickOk))
  30. if isReviewVersion() then
  31. self.ui.Items.Layout_4:setVisible(false)
  32. end
  33. self.ui.Items.txtRoomID:setString(string.format("房号:%06d", self._data.nShowTableId or 0))
  34. self.ui.Items.txtRoundNum:setString(string.format("%s", os.date("%m-%d %H:%M", os.time()) ))
  35. self.ui.Items.txtRoomRule:setString(string.format("%s", self._data.roomRule or ""))
  36. if #self._data.players == 2 then
  37. local shift = 40
  38. self.ui.Items.ImageView_card_1:setPositionX(134+shift)
  39. self.ui.Items.ImageView_card_2:setPositionX(1145-shift)
  40. end
  41. end
  42. function PdkGameOverView:setPlayerInfo()
  43. local maxUserId = self._data.players[1].userId
  44. local maxScore = self._data.players[1].totalScore
  45. maxScore = tonumber(maxScore)
  46. for i,v in ipairs(self._data.players) do
  47. v.totalScore = tonumber(v.totalScore)
  48. if v.totalScore > maxScore then
  49. maxUserId = v.userId
  50. maxScore = v.totalScore
  51. end
  52. end
  53. local roomInfo = app.room:getRoomInfo()
  54. for i,v in ipairs(self._data.players) do
  55. v.isBigWin = v.userId == maxUserId
  56. v.isHost = v.userId == roomInfo.nRoomOwnedUid
  57. local item = self:createItem(v)
  58. self.ui.Items.Layout_items:addChild(item)
  59. end
  60. self.ui.Items.Layout_items:requestDoLayout();
  61. self.ui.Items.Layout_items:doLayout();
  62. end
  63. function PdkGameOverView:onClickShare( sender )
  64. playBtnEffect()
  65. local fileName = cc.FileUtils:getInstance():getWritablePath()..tostring(self._data.nShowTableId).."_screen.jpg"
  66. cc.FileUtils:getInstance():screenToFile(fileName, function(ret)
  67. if 1 == tonumber(ret) then
  68. local info = {}
  69. info.scene = "talk"
  70. info.contentType = "image"
  71. info.image = fileName
  72. info.isShareZhanjiUrl = true
  73. info.imageWidth = 1000
  74. info.thumbWidth = 100
  75. --app.plugin:shareGame(info)
  76. info.copyData={
  77. type=1,
  78. tableId=self._data.nShowTableId,
  79. userInfos={},
  80. gameId=36,
  81. }
  82. for nUserId,totalData in pairsByKeys(self._data.players) do
  83. local userInfo = app.room:getUserInfo(totalData.userId)
  84. --昵称
  85. local nickname = totalData.nickname or ""
  86. local totalScore = totalData.totalScore
  87. table.insert(info.copyData.userInfos,{nickname=nickname,totalScore=totalScore})
  88. end
  89. local view = import("luaScript.Views.Main.ShareView"):new(info,nil,{endtime=self._data.endTime})
  90. view:setAnchorPoint(cc.p(0.5, 0.5))
  91. app:showWaitDialog(view)
  92. else
  93. showTooltip("截图保存失败")
  94. end
  95. end )
  96. end
  97. function PdkGameOverView:onClickOk( sender )
  98. playBtnEffect()
  99. --app:gotoView(import("luaScript.Views.Main.MainView"):new(GAME_IDS.PaoDeKuai))
  100. gotoMainView(GAME_IDS.PaoDeKuai)
  101. end
  102. function PdkGameOverView:onEnter()
  103. PdkGameOverView.super.onEnter()
  104. setShowCountAll(true)
  105. stopBGMusic()
  106. end
  107. function PdkGameOverView:onExit()
  108. PdkGameOverView.super.onExit(self)
  109. setShowCountAll(false)
  110. end
  111. function PdkGameOverView:createItem( info )
  112. info.totalScore = tonumber(info.totalScore)
  113. local node = loadUI("pk_paodekuai/res/ui/ui_room/ui_pdk_gameoveritem.ui")
  114. setPlayerHeadImage(info.userId, info.headimgurl, node.Items.imgHead)
  115. node.Items.txtNick:setString(getSubStringNickname(info.nickname or ""))
  116. node.Items.txtID:setString("ID:"..info.userId)
  117. --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq
  118. -- begin
  119. local ClubDefine = require("luaScript.Protocol.Club.ClubDefine")
  120. if app.club_php.clubID and app.club_php.clubID ~= 0 then
  121. if app.club_php:getCestIsOpen(app.club_php.clubID) then
  122. --隐私数据
  123. local clubInfo = app.club_php.clubList[app.club_php.clubID]
  124. self.cliext = clubInfo.groupext and clubInfo.groupext.cliext
  125. if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then
  126. if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then
  127. node.Items.txtID:setVisible(true)
  128. else
  129. node.Items.txtID:setVisible(false)
  130. end
  131. end
  132. end
  133. end
  134. if info.userId == tonumber(app.user.loginInfo.uid) then
  135. node.Items.txtID:setVisible(true)
  136. end
  137. -- end
  138. node.Items.imgBest:setVisible(info.isBigWin and info.totalScore>0)
  139. node.Items.imgHost:setVisible(info.isHost)
  140. node.Items.imgHost:setVisible(false)--隐藏房主标签
  141. --"extString" = "{"bombTimes":0,"loseTimes":0,"maxScore":3,"winTimes":2}"
  142. local extData = json.decode(info.extString)
  143. node.Items.txtDjzgfs_1:setString(""..extData.maxScore)
  144. node.Items.txtDczds_1:setString(""..extData.bombTimes)
  145. node.Items.txtSyjs_1:setString(string.format("%d/%d", extData.loseTimes , extData.winTimes))
  146. if info.totalScore > 0 then
  147. node.Items.txtTotalScore:setString("+"..info.totalScore)
  148. node.Items.txtTotalScore:setColor(cc.c3b(212, 16, 16))
  149. node.Items.imgTotalTitle:loadTexture("pk_paodekuai/res/ui/zy_gameresult/pdk_gameresult_img_winbg.png", 0)
  150. else
  151. node.Items.txtTotalScore:setString(""..info.totalScore)
  152. node.Items.imgTotalTitle:loadTexture("pk_paodekuai/res/ui/zy_gameresult/pdk_gameresult_img_losebg.png", 0)
  153. end
  154. if self._data.stopFlag == 9 or self._data.stopFlag == 8 then--解散游戏
  155. local jiesanData = json.decode(self._data.stopResult)
  156. local jiesanLab = node.Items.txtID:getCopied()
  157. local jiesanPos = node.Items.txtID:getPosition()
  158. local config = jiesanLab:getFontConfig();
  159. config.fontSize = 18;
  160. config.texColor = cc.c4b(255,155,155,255)
  161. jiesanLab:setFontConfig(config);
  162. local jiesaninfo = {
  163. [0] = "超时解散",
  164. [1] = "申请解散",
  165. [2] = "同意解散",
  166. [3] = "拒绝",
  167. }
  168. if jiesanData and jiesanData[tostring(info.userId)] then
  169. jiesanLab:setPositionY(jiesanPos.y - 210)
  170. jiesanLab:setPositionX(jiesanPos.x)
  171. jiesanLab:setAnchorPoint(cc.p(0.5, 0.5))
  172. --jiesanLab:setColor(cc.c3b(255,0,0))
  173. if self._data.stopFlag == 9 then
  174. jiesanLab:setText(jiesaninfo[jiesanData[tostring(info.userId)]])
  175. elseif self._data.stopFlag == 8 then
  176. jiesanLab:setText("系统解散")
  177. end
  178. node.Items.Layout_player:addChild(jiesanLab)
  179. end
  180. end
  181. return node
  182. end
  183. function PdkGameOverView:test()
  184. local data = {{}, {}, {}}
  185. local dltWidth = 1273/#data
  186. for i,v in ipairs(data) do
  187. local item = GameOverItem:new(v)
  188. if i==1 then
  189. item:setPosition(cc.p((i-1)*dltWidth+dltWidth/2, 225))
  190. elseif i==3 then
  191. else
  192. item:setPosition(cc.p((i-1)*dltWidth+dltWidth/2, 225))
  193. end
  194. self.ui.Items.Layout_items:addChild(item)
  195. end
  196. end
  197. return PdkGameOverView