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.

274 lines
9.4 KiB

  1. local scheduler = require("luaScript.ModuleEapSdk.SdkSocket.scheduler")
  2. local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer")
  3. local LayerTeamRank = class("LayerTeamRank", BaseLayer)
  4. function LayerTeamRank.createWithData(__node, __zorder)
  5. local layer = LayerTeamRank.new()
  6. layer.m_parent = __node
  7. __node:addChild(layer, __zorder)
  8. return layer
  9. end
  10. function LayerTeamRank:myShow()
  11. -- self:addListener(true)
  12. self:initData()
  13. self:initUI()
  14. end
  15. function LayerTeamRank:myClose()
  16. end
  17. function LayerTeamRank:initData()
  18. self.m_curSel = 1
  19. self.m_menuItems = {}
  20. self.scrollView = nil
  21. end
  22. function LayerTeamRank:initUI()
  23. self.imgPath = {
  24. "res/ModuleEapSdk/eapsdk_public_back_bg1.png",
  25. "res/ModuleEapSdk/eapsdk_public_back_bg2.png",
  26. "res/ModuleEapSdk/eapsdk_public_back_bg3.png",
  27. "res/ModuleEapSdk/eapsdk_bt_xb_sp.png",
  28. "res/ModuleEapSdk/eapsdk_wj_icon_decor.png",
  29. "res/ModuleEapSdk/eapsdk_wj_btn_back.png",
  30. "res/ModuleEapSdk/eapsdk_button_dx.png",
  31. }
  32. local fix_x = display.width
  33. local fix_y = display.cy
  34. local imgBack2 = G_EapAbbreviation.createImageView(self.imgPath[2], self, cc.p(fix_x-10, fix_y+40), true, 2, 3101, cc.p(1, 0.5))
  35. imgBack2:setSize(cc.size(530, 500))
  36. self.imgBack2 = imgBack2
  37. local imgBack4 = G_EapAbbreviation.createImageView(self.imgPath[3], imgBack2, cc.p(265, 378), true, 0, 3103, cc.p(0.5, 1))
  38. imgBack4:setSize(cc.size(470, 305))
  39. local imgBack5 = G_EapAbbreviation.createImageView(self.imgPath[3], imgBack2, cc.p(265, 63), true, 0, 3104, cc.p(0.5, 1))
  40. imgBack5:setSize(cc.size(470, 50))
  41. local imgBack6 = G_EapAbbreviation.createImageView(self.imgPath[1], imgBack2, cc.p(265, 323), false, 0, 3105, cc.p(0.5, 1))
  42. imgBack6:setScaleX(8.4)
  43. imgBack6:setScaleY(0.04)
  44. local imgArrow1 = G_EapAbbreviation.createImageView(self.imgPath[5], imgBack2, cc.p(82, 468), false)
  45. local imgArrow2 = G_EapAbbreviation.createImageView(self.imgPath[4], imgBack2, cc.p(448, 468), false)
  46. imgArrow1:setScale(0.585)
  47. imgArrow2:setScale(0.585)
  48. local title = "战队选拔赛排行榜"
  49. G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(265, 468), title, 28, cc.c3b(0xc8, 0xa8, 0x88), true)
  50. self.btnBack = ccui.Button:create(self.imgPath[6])
  51. self.btnBack:setPosition(cc.p(30, 470))
  52. imgBack2:addChild(self.btnBack)
  53. addButtonListener(self.btnBack, function()
  54. print("LayerTeamRank btnBack clicked === ")
  55. if G_EapSdkMgr.m_isMatching then
  56. self.m_parent.m_parent:showLayer(LAYER_ENUM.LAYER_TEAM)
  57. else
  58. self.m_parent.m_parent:showLayer(LAYER_ENUM.LAYER_TEAM_END)
  59. end
  60. end)
  61. local normCol = cc.c3b(0xa7, 0xab, 0xb4)
  62. local disCol = cc.c3b(0x1e, 0x23, 0x36)
  63. local titles = {"名次", "战队", "对局数", "积分"}
  64. for i=1, #titles do
  65. local title = titles[i]
  66. G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(80+(i-1)*122.5, 350), title, 25, disCol, true)
  67. end
  68. self.imgRow = G_EapAbbreviation.createImageView(self.imgPath[7], imgBack2, cc.p(110, 382), false)
  69. local btnMenus = G_EapAbbreviation.createMenu(imgBack2, 1, 3200, cc.p(265, 410))
  70. -- for i=1, #G_EapSdkMgr.m_matchInfos do
  71. for i=1, 3 do
  72. local matchItem = G_EapSdkMgr.m_matchInfos[i]
  73. local coreName1 = matchItem and matchItem.coreName or "赛事名称"..i
  74. if G_EapLabelTool.GetUTF8StrNums( coreName1 ) > 9 then
  75. coreName1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(coreName1, 9)
  76. coreName1 = coreName1..".."
  77. end
  78. local item1 = G_EapAbbreviation.createItemFont(btnMenus, cc.p(-156.6+(i-1)*156.6, 0), coreName1, 26, normCol, disCol, true, function()
  79. self.m_menuItems[self.m_curSel]:setEnabled(true)
  80. self.m_menuItems[i]:setEnabled(false)
  81. self.m_curSel = i
  82. self.imgRow:setPositionX(110+(i-1)*150)
  83. --刷新排行榜
  84. self:refreshRankList(G_EapSdkMgr.m_allRanks)
  85. self:refreshSelfInfo()
  86. end)
  87. self.m_menuItems[#self.m_menuItems+1] = item1
  88. end
  89. for i=1,#self.m_menuItems do
  90. if i == 1 then
  91. self.m_menuItems[i]:setEnabled(false)
  92. else
  93. self.m_menuItems[i]:setEnabled(true)
  94. end
  95. end
  96. self:initSelfInfo()
  97. end
  98. function LayerTeamRank:refreshRankList(__datas)
  99. --测试数据
  100. __datas = {
  101. {
  102. {
  103. top = 1,
  104. nickName = "抗日小分队1",
  105. count = 5,
  106. score = 21.2
  107. },
  108. {
  109. top = 1,
  110. nickName = "抗日小分队1",
  111. count = 5,
  112. score = 21.2
  113. },
  114. {
  115. top = 1,
  116. nickName = "抗日小分队1",
  117. count = 5,
  118. score = 21.2
  119. },
  120. },
  121. {
  122. {
  123. top = 1,
  124. nickName = "抗日小分队2",
  125. count = 5,
  126. score = 22.2
  127. },
  128. {
  129. top = 1,
  130. nickName = "抗日小分队3",
  131. count = 5,
  132. score = 22.2
  133. },
  134. {
  135. top = 1,
  136. nickName = "抗日小分队4",
  137. count = 5,
  138. score = 22.2
  139. },
  140. },
  141. {
  142. {
  143. top = 1,
  144. nickName = "抗日小分队5",
  145. count = 5,
  146. score = 23.2
  147. },
  148. {
  149. top = 1,
  150. nickName = "抗日小分队6",
  151. count = 5,
  152. score = 23.2
  153. },
  154. {
  155. top = 1,
  156. nickName = "抗日小分队7",
  157. count = 5,
  158. score = 23.2
  159. },
  160. }
  161. }
  162. if self.scrollView then
  163. self.scrollView:destroySelf()
  164. self.scrollView = nil
  165. end
  166. local EapListView = require("luaScript.ModuleEapSdk.GameTools.EapListView")
  167. self.scrollView = EapListView.createWithData(self.imgBack2, self)
  168. self.scrollView:setPosition(cc.p(31, 73))
  169. self.scrollView:refreshRankList(__datas[self.m_curSel])
  170. end
  171. function LayerTeamRank:initItemInfo(itemNode, info)
  172. local disCol = cc.c3b(0x1e, 0x23, 0x36)
  173. --排名
  174. local title2 = info.top or "-"
  175. itemNode.lblRank = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50, 25), title2, 23, disCol)
  176. --昵称
  177. local title1 = info.nickName or "-"
  178. if G_EapLabelTool.GetUTF8StrNums( title1 ) > 9 then
  179. title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 9)
  180. title1 = title1..".."
  181. end
  182. itemNode.lblName = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50+122.5, 25), title1, 23, disCol)
  183. --对局数
  184. local title3 = info.count or "-"
  185. itemNode.lblCount = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50+2*122.5, 25), title3, 23, disCol)
  186. --积分
  187. local title3 = info.score or "-"
  188. itemNode.lblScore = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50+3*122.5, 25), title3, 23, disCol)
  189. end
  190. function LayerTeamRank:refreshItemInfo(itemNode, info, index)
  191. if not itemNode or not index or not info then
  192. return
  193. end
  194. itemNode.infoIndex = index --数据索引
  195. --排名
  196. local title2 = info.top or "-"
  197. itemNode.lblRank:setString(title2)
  198. --昵称
  199. local title1 = info.nickName or "-"
  200. if G_EapLabelTool.GetUTF8StrNums( title1 ) > 9 then
  201. title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 9)
  202. title1 = title1..".."
  203. end
  204. itemNode.lblName:setString(title1)
  205. --对局数
  206. local title3 = info.count or "-"
  207. itemNode.lblCount:setString(title3)
  208. --积分
  209. local title4 = info.score or "-"
  210. itemNode.lblScore:setString(title4)
  211. end
  212. function LayerTeamRank:initSelfInfo()
  213. local disCol = cc.c3b(0x1e, 0x23, 0x36)
  214. local title1 = "-"
  215. self.lblMyRank = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(80, 38), title1, 25, disCol)
  216. local title2 = "-"
  217. self.lblMyTeam = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(80+122.5, 38), title2, 25, disCol)
  218. local title3 = "-"
  219. self.lblMyCount = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(80+2*122.5, 38), title3, 25, disCol)
  220. local title4 = "-"
  221. self.lblMyScore = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(80+3*122.5, 38), title4, 25, disCol)
  222. end
  223. function LayerTeamRank:refreshSelfInfo()
  224. local matchInfo = G_EapSdkMgr.m_matchInfos[self.m_curSel]
  225. if matchInfo then
  226. local info = G_EapSdkMgr:getSelfCoreInfoByID(matchInfo.coreId)
  227. if info then
  228. local disCol = cc.c3b(0x1e, 0x23, 0x36)
  229. local title1 = info.top or "-"
  230. self.lblMyRank:setString(title1)
  231. local title2 = G_EapSdkMgr.NickName or "-"
  232. if G_EapLabelTool.GetUTF8StrNums( title2 ) > 9 then
  233. title2 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title2, 9)
  234. title2 = title2..".."
  235. end
  236. self.lblMyName:setString(title2)
  237. local title3 = info.score or "-"
  238. self.lblMyScore:setString(title3)
  239. else
  240. local title1 = "-"
  241. self.lblMyRank:setString(title1)
  242. local title2 = "-"
  243. self.lblMyName:setString(title2)
  244. local title3 = "-"
  245. self.lblMyScore:setString(title3)
  246. end
  247. end
  248. end
  249. return LayerTeamRank