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.

377 lines
12 KiB

  1. local scheduler = require("luaScript.ModuleEapSdk.SdkSocket.scheduler")
  2. local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer")
  3. local LayerTeamDetail = class("LayerTeamDetail", BaseLayer)
  4. function LayerTeamDetail.createWithData(__node, __zorder)
  5. local layer = LayerTeamDetail.new()
  6. layer.m_parent = __node
  7. __node:addChild(layer, __zorder)
  8. return layer
  9. end
  10. function LayerTeamDetail:myShow()
  11. self:addListener(true)
  12. self:initData()
  13. self:initUI()
  14. end
  15. function LayerTeamDetail:myClose()
  16. end
  17. function LayerTeamDetail:initData()
  18. self.m_curSel = 1
  19. self.m_menuItems = {}
  20. self.m_teamDetails = {}
  21. self.scrollView = nil
  22. self.m_curShowDetail = -1
  23. end
  24. function LayerTeamDetail:initUI()
  25. self.imgPath = {
  26. "res/ModuleEapSdk/eapsdk_public_back_bg1.png",
  27. "res/ModuleEapSdk/eapsdk_public_back_bg2.png",
  28. "res/ModuleEapSdk/eapsdk_public_back_bg3.png",
  29. "res/ModuleEapSdk/eapsdk_bt_xb_sp.png",
  30. "res/ModuleEapSdk/eapsdk_wj_icon_decor.png",
  31. "res/ModuleEapSdk/eapsdk_wj_btn_back.png",
  32. "res/ModuleEapSdk/eapsdk_button_dx.png",
  33. "res/ModuleEapSdk/eapsdk_img_arrow"
  34. }
  35. local fix_x = display.width
  36. local fix_y = display.cy
  37. 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))
  38. imgBack2:setSize(cc.size(530, 500))
  39. self.imgBack2 = imgBack2
  40. local imgBack4 = G_EapAbbreviation.createImageView(self.imgPath[3], imgBack2, cc.p(265, 378), true, 0, 3103, cc.p(0.5, 1))
  41. imgBack4:setSize(cc.size(470, 305))
  42. local imgBack5 = G_EapAbbreviation.createImageView(self.imgPath[3], imgBack2, cc.p(265, 63), true, 0, 3104, cc.p(0.5, 1))
  43. imgBack5:setSize(cc.size(470, 50))
  44. local imgBack6 = G_EapAbbreviation.createImageView(self.imgPath[1], imgBack2, cc.p(265, 323), false, 0, 3105, cc.p(0.5, 1))
  45. imgBack6:setScaleX(8.4)
  46. imgBack6:setScaleY(0.04)
  47. local imgArrow1 = G_EapAbbreviation.createImageView(self.imgPath[5], imgBack2, cc.p(82, 468), false)
  48. local imgArrow2 = G_EapAbbreviation.createImageView(self.imgPath[4], imgBack2, cc.p(448, 468), false)
  49. imgArrow1:setScale(0.585)
  50. imgArrow2:setScale(0.585)
  51. local title = "战队详情"
  52. G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(265, 468), title, 28, cc.c3b(0xc8, 0xa8, 0x88), true)
  53. self.btnBack = ccui.Button:create(self.imgPath[6])
  54. self.btnBack:setPosition(cc.p(30, 470))
  55. imgBack2:addChild(self.btnBack)
  56. addButtonListener(self.btnBack, function()
  57. print("LayerTeamDetail btnBack clicked === ")
  58. if G_EapSdkMgr.m_isMatching then
  59. self.m_parent.m_parent:showLayer(LAYER_ENUM.LAYER_TEAM)
  60. else
  61. self.m_parent.m_parent:showLayer(LAYER_ENUM.LAYER_TEAM_END)
  62. end
  63. end)
  64. local normCol = cc.c3b(0xa7, 0xab, 0xb4)
  65. local disCol = cc.c3b(0x1e, 0x23, 0x36)
  66. local titles = {"名次", "战队", "对局数", "积分"}
  67. for i=1, #titles do
  68. local title = titles[i]
  69. G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(80+(i-1)*112.5, 350), title, 25, disCol, true)
  70. end
  71. self.imgRow = G_EapAbbreviation.createImageView(self.imgPath[7], imgBack2, cc.p(110, 382), false)
  72. local btnMenus = G_EapAbbreviation.createMenu(imgBack2, 1, 3200, cc.p(265, 410))
  73. -- for i=1, #G_EapSdkMgr.m_matchInfos do
  74. for i=1, 3 do
  75. local matchItem = G_EapSdkMgr.m_matchInfos[i]
  76. local coreName1 = matchItem and matchItem.coreName or "赛事名称"..i
  77. if G_EapLabelTool.GetUTF8StrNums( coreName1 ) > 9 then
  78. coreName1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(coreName1, 9)
  79. coreName1 = coreName1..".."
  80. end
  81. local item1 = G_EapAbbreviation.createItemFont(btnMenus, cc.p(-156.6+(i-1)*156.6, 0), coreName1, 26, normCol, disCol, true, function()
  82. self.m_menuItems[self.m_curSel]:setEnabled(true)
  83. self.m_menuItems[i]:setEnabled(false)
  84. self.m_curSel = i
  85. self.imgRow:setPositionX(110+(i-1)*150)
  86. --刷新排行榜
  87. self:refreshRankList(G_EapSdkMgr.m_allRanks)
  88. end)
  89. self.m_menuItems[#self.m_menuItems+1] = item1
  90. end
  91. for i=1,#self.m_menuItems do
  92. if i == 1 then
  93. self.m_menuItems[i]:setEnabled(false)
  94. else
  95. self.m_menuItems[i]:setEnabled(true)
  96. end
  97. end
  98. self:initDetailNode()
  99. end
  100. --战队详情面板
  101. function LayerTeamDetail:initDetailNode()
  102. local disCol = cc.c3b(0x1e, 0x23, 0x36)
  103. local imgBack4 = G_EapAbbreviation.createImageView(self.imgPath[1], self.imgBack2, cc.p(265, 300), true, 0, 3106, cc.p(0.5, 1))
  104. imgBack4:setSize(cc.size(460, 200))
  105. self.detailNode = imgBack4
  106. local titles = {"队员", "对局数", "积分"}
  107. for i=1, #titles do
  108. local title = titles[i]
  109. G_EapAbbreviation.createSystemLabel(imgBack4, cc.p(80+(i-1)*150, 180), title, 22, disCol, true)
  110. end
  111. for i=1, 4 do
  112. local itemNode = ccui.Layout:create()
  113. itemNode:setAnchorPoint(cc.p(0.5, 1))
  114. itemNode:setSize(cc.size(460, 40))
  115. itemNode:setPosition(cc.p(230, 40*i))
  116. imgBack4:addChild(itemNode)
  117. --队员昵称
  118. local title1 = "-"
  119. itemNode.lblName = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(80+150, 20), title1, 23, disCol)
  120. --对局数
  121. local title2 = "-"
  122. itemNode.lblCount = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(80, 20), title2, 23, disCol)
  123. --积分
  124. local title3 = "-"
  125. itemNode.lblScore = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(80+2*150, 20), title3, 23, disCol)
  126. self.m_teamDetails[#self.m_teamDetails+1] = itemNode
  127. end
  128. self.detailNode:setVisible(false)
  129. end
  130. function LayerTeamDetail:refreshDetail(info)
  131. if info and #info > 0 then
  132. for i=1, #info do
  133. local itemNode = self.m_teamDetails[i]
  134. if itemNode then
  135. local detail = info[i]
  136. --昵称
  137. local title1 = detail.name or "-"
  138. if G_EapLabelTool.GetUTF8StrNums( title1 ) > 9 then
  139. title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 9)
  140. title1 = title1..".."
  141. end
  142. itemNode.lblName:setString(title1)
  143. --对局数
  144. local title3 = detail.count or "-"
  145. itemNode.lblCount:setString(title3)
  146. --积分
  147. local title4 = detail.score or "-"
  148. itemNode.lblScore:setString(title4)
  149. end
  150. end
  151. end
  152. end
  153. function LayerTeamDetail:refreshRankList(__datas)
  154. --测试数据
  155. __datas = {
  156. {
  157. {
  158. top = 1,
  159. nickName = "抗日小分队1",
  160. count = 5,
  161. score = 21.2,
  162. detail = {
  163. {
  164. name = "李云龙",
  165. count = 2,
  166. score = 3,
  167. },
  168. {
  169. name = "黄继光",
  170. count = 1,
  171. score = 5,
  172. },
  173. {
  174. name = "燕双鹰",
  175. count = 1,
  176. score = 8,
  177. },
  178. {
  179. name = "董存瑞",
  180. count = 1,
  181. score = 10,
  182. }
  183. }
  184. },
  185. {
  186. top = 1,
  187. nickName = "抗日小分队2",
  188. count = 5,
  189. score = 21.2,
  190. detail = {
  191. {
  192. name = "李云龙2",
  193. count = 2,
  194. score = 3,
  195. },
  196. {
  197. name = "黄继光2",
  198. count = 1,
  199. score = 5,
  200. },
  201. {
  202. name = "燕双鹰2",
  203. count = 1,
  204. score = 8,
  205. },
  206. {
  207. name = "董存瑞2",
  208. count = 1,
  209. score = 10,
  210. }
  211. }
  212. },
  213. {
  214. top = 1,
  215. nickName = "抗日小分队3",
  216. count = 5,
  217. score = 21.2,
  218. detail = {
  219. {
  220. name = "李云龙3",
  221. count = 2,
  222. score = 3,
  223. },
  224. {
  225. name = "黄继光3",
  226. count = 1,
  227. score = 5,
  228. },
  229. {
  230. name = "燕双鹰3",
  231. count = 1,
  232. score = 8,
  233. },
  234. {
  235. name = "董存瑞3",
  236. count = 1,
  237. score = 10,
  238. }
  239. }
  240. },
  241. },
  242. {
  243. {
  244. top = 1,
  245. nickName = "抗日小分队2",
  246. count = 5,
  247. score = 22.2
  248. },
  249. {
  250. top = 1,
  251. nickName = "抗日小分队3",
  252. count = 5,
  253. score = 22.2
  254. },
  255. {
  256. top = 1,
  257. nickName = "抗日小分队4",
  258. count = 5,
  259. score = 22.2
  260. },
  261. },
  262. {
  263. {
  264. top = 1,
  265. nickName = "抗日小分队5",
  266. count = 5,
  267. score = 23.2
  268. },
  269. {
  270. top = 1,
  271. nickName = "抗日小分队6",
  272. count = 5,
  273. score = 23.2
  274. },
  275. {
  276. top = 1,
  277. nickName = "抗日小分队7",
  278. count = 5,
  279. score = 23.2
  280. },
  281. }
  282. }
  283. if self.scrollView then
  284. self.scrollView:destroySelf()
  285. self.scrollView = nil
  286. end
  287. local EapListView = require("luaScript.ModuleEapSdk.GameTools.EapListView")
  288. self.scrollView = EapListView.createWithData(self.imgBack2, self)
  289. self.scrollView:setPosition(cc.p(31, 73))
  290. self.scrollView:refreshRankList(__datas[self.m_curSel])
  291. end
  292. function LayerTeamDetail:initItemInfo(itemNode, info)
  293. local disCol = cc.c3b(0x1e, 0x23, 0x36)
  294. --排名
  295. local title2 = info.top or "-"
  296. itemNode.lblRank = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50, 25), title2, 23, disCol)
  297. --昵称
  298. local title1 = info.nickName or "-"
  299. if G_EapLabelTool.GetUTF8StrNums( title1 ) > 9 then
  300. title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 9)
  301. title1 = title1..".."
  302. end
  303. itemNode.lblName = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50+112.5, 25), title1, 23, disCol)
  304. --对局数
  305. local title3 = info.count or "-"
  306. itemNode.lblCount = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50+2*112.5, 25), title3, 23, disCol)
  307. --积分
  308. local title3 = info.score or "-"
  309. itemNode.lblScore = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50+3*112.5, 25), title3, 23, disCol)
  310. --详情
  311. addButtonListener(itemNode, function()
  312. if itemNode.m_info.detail then
  313. self.detailNode:setVisible(true)
  314. self:refreshDetail(itemNode.m_info.detail)
  315. end
  316. end)
  317. end
  318. function LayerTeamDetail:refreshItemInfo(itemNode, info, index)
  319. if not itemNode or not index or not info then
  320. return
  321. end
  322. itemNode.infoIndex = index --数据索引
  323. itemNode.m_info = info
  324. --排名
  325. local title2 = info.top or "-"
  326. itemNode.lblRank:setString(title2)
  327. --昵称
  328. local title1 = info.nickName or "-"
  329. if G_EapLabelTool.GetUTF8StrNums( title1 ) > 9 then
  330. title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 9)
  331. title1 = title1..".."
  332. end
  333. itemNode.lblName:setString(title1)
  334. --对局数
  335. local title3 = info.count or "-"
  336. itemNode.lblCount:setString(title3)
  337. --积分
  338. local title4 = info.score or "-"
  339. itemNode.lblScore:setString(title4)
  340. end
  341. function LayerTeamDetail:onTouchEnd(touch)
  342. local touchPos = touch:getLocation()
  343. local transPos = self.imgBack2:convertToNodeSpace(touchPos)
  344. local rect = self.detailNode:getBoundingBox()
  345. if not cc.rectContainsPoint(rect, transPos) then
  346. self.detailNode:setVisible(false)
  347. end
  348. end
  349. return LayerTeamDetail