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.

156 rivejä
4.8 KiB

  1. --
  2. -- xx : 2018 3 27
  3. -- 跑得快战绩单轮详情界面
  4. local PdkDef = require("luaScript.SubGameDefine.PDKDefine")
  5. local PdkDanJuItem = class("PdkDanJuItem")
  6. -- lunshuInfo : 轮数的意思是,一个房间里面会打多局,可能因为流局的原因,某一局要打多轮
  7. -- 标记是否来自俱乐部的作用是:在获取回放数据的时候,确定是使用俱乐部的协议还是子游戏的协议
  8. function PdkDanJuItem:ctor(lunshuInfo, isFromClub)
  9. -- 本局详细信息
  10. self.lunshuInfo = lunshuInfo;
  11. -- 是否来自俱乐部
  12. self.isFromClub = isFromClub;
  13. self.ui = loadUI("pk_paodekuai/res/ui/ui_zhanji/ui_pdk_zhanji_danju_item.ui")
  14. autoAdapt(self.ui)
  15. self.txtScores = {}
  16. for i=1,3 do
  17. local scoreLayout = self.ui.Items["Layout_player_score_"..i]
  18. scoreLayout:setVisible(false)
  19. self.txtScores[i] = self.ui.Items["Text_score_"..i]
  20. self.txtScores[i]:setString("")
  21. end
  22. self:loadData()
  23. self.ui.Items.Button_share:setVisible(false)
  24. -- self.ui.Items.Button_detail:setVisible(false)
  25. self.ui.Items.Button_detail:registerClick(handler(self , self.onClickButtonDetail))
  26. end
  27. function PdkDanJuItem:loadData()
  28. self.ui.Items.Text_xuhao:setString(string.format("%d", self.lunshuInfo.idx))
  29. self.ui.Items.Text_time:setString(os.date("%m-%d %H:%M:%S", self.lunshuInfo.endtime))
  30. if self.lunshuInfo.flag and (self.lunshuInfo.flag == 8 or self.lunshuInfo.flag == 9) then
  31. self.ui.Items.ImageView_Flag:setVisible(true)
  32. else
  33. self.ui.Items.ImageView_Flag:setVisible(false)
  34. end
  35. local endFlag = self.lunshuInfo.flag
  36. local jiesanInfo
  37. if self.lunshuInfo.ext and self.lunshuInfo.ext.disbandStatus then
  38. jiesanInfo = self.lunshuInfo.ext.disbandStatus
  39. end
  40. local count = 0
  41. for uid,score in pairs(self.lunshuInfo.score) do
  42. count = count + 1
  43. if score>0 then
  44. self.txtScores[count]:setFntFile("res/fonts/zhanji_win.fnt")
  45. self.txtScores[count]:setString(string.format("+%d", score))
  46. else
  47. self.txtScores[count]:setFntFile("res/fonts/zhanji_lose.fnt")
  48. self.txtScores[count]:setString(string.format("%d", score))
  49. end
  50. --昵称
  51. local playerInfo = app.playerInfoManager:getPlayerInfo(uid);
  52. if playerInfo then
  53. local len = string.len(playerInfo.name)
  54. if len == 0 then
  55. playerInfo.name = "未知昵称"
  56. end
  57. playerInfo.name = getSubStringNickname(playerInfo.name)
  58. local nameNode = string.format("Text_player_name_%d",count)
  59. self.ui.Items[nameNode]:setText(playerInfo.name)
  60. end
  61. local jsNameNode = string.format("Text_jiesanInfo_%d",count)
  62. local jsItemNode = self.ui.Items[jsNameNode]
  63. if endFlag == 9 and jiesanInfo then
  64. jsItemNode:setVisible(true)
  65. if jiesanInfo[uid] and jiesanInfo[uid] == 0 then
  66. jsItemNode:setText("超时解散")
  67. jsItemNode:setColor(cc.c3b(0,255,0))
  68. elseif jiesanInfo[uid] and jiesanInfo[uid] == 1 then
  69. jsItemNode:setText("申请解散")
  70. jsItemNode:setColor(cc.c3b(255,0,0))
  71. elseif jiesanInfo[uid] and jiesanInfo[uid] == 2 then
  72. jsItemNode:setText("同意解散")
  73. jsItemNode:setColor(cc.c3b(0,255,0))
  74. elseif jiesanInfo[uid] and jiesanInfo[uid] == 3 then
  75. jsItemNode:setText("拒绝解散")
  76. end
  77. elseif endFlag == 8 then--系统解散
  78. jsItemNode:setVisible(true)
  79. jsItemNode:setText("系统解散")
  80. jsItemNode:setColor(cc.c3b(255,0,0))
  81. else
  82. jsItemNode:setVisible(false)
  83. end
  84. local scoreLayout = self.ui.Items["Layout_player_score_"..count]
  85. scoreLayout:setVisible(true)
  86. end
  87. end
  88. function PdkDanJuItem:getRoot()
  89. return self.ui
  90. end
  91. function PdkDanJuItem:onEnter()
  92. PdkDanJuItem.super.onEnter()
  93. end
  94. function PdkDanJuItem:onExit()
  95. end
  96. function PdkDanJuItem:onClickButtonDetail( sender )
  97. playBtnEffect()
  98. --[[if self.lunshuInfo.flag == 9 then
  99. showTooltip("本局提前解散")
  100. return
  101. end--]]
  102. local protocolZhanJi
  103. if self.isFromClub then
  104. protocolZhanJi = app.club_zhanji
  105. else
  106. protocolZhanJi = app:getProtocolZhanJi(GAME_IDS.PaoDeKuai)
  107. end
  108. local function showRecoreView( )
  109. app.waitDialogManager:closeWaitNetworkDialog()
  110. local recordData = nil
  111. local zhanjiInfo = protocolZhanJi.zhanjiInfoList[self.lunshuInfo.pid]
  112. if zhanjiInfo and zhanjiInfo.detail then
  113. local rdata
  114. for k,v in pairs(zhanjiInfo.detail) do
  115. local d = v["1"]
  116. if d then
  117. if d.subid == self.lunshuInfo.subid then
  118. recordData = d
  119. break
  120. end
  121. end
  122. end
  123. end
  124. if recordData and recordData.ops then--回放数据
  125. recordData.nbound = self.lunshuInfo.nbound
  126. recordData.roomid = self.lunshuInfo.roomid
  127. local view = import("pk_paodekuai.luaScript.Views.Room.PdkRoomPlayView"):new(recordData)
  128. view:setAnchorPoint(cc.p(0.5, 0.5))
  129. app:showWaitDialog(view)
  130. else
  131. showTooltip("本局数据不支持回放")
  132. end
  133. end
  134. if protocolZhanJi then
  135. app.waitDialogManager:showWaitNetworkDialog()
  136. protocolZhanJi:getZhanJiDetail(self.lunshuInfo.pid, self.lunshuInfo.subid, showRecoreView)
  137. end
  138. end
  139. return PdkDanJuItem