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.

199 lines
7.4 KiB

  1. local DEEP_COL1 = cc.c3b(0x5a, 0x4c, 0x3b)
  2. local WEAK_COL1 = cc.c3b(0x33, 0x33, 0x33)
  3. local BG_W = 332
  4. local BG_H = 600
  5. local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer")
  6. local LayerRule = EapClass("LayerRule", BaseLayer)
  7. function LayerRule.createWithData(__node, __zorder)
  8. local layer = LayerRule.new()
  9. layer.m_parent = __node
  10. __node:addChild(layer, __zorder)
  11. return layer
  12. end
  13. function LayerRule:myShow()
  14. -- self:addListener(true)
  15. self:initUI()
  16. end
  17. function LayerRule:myClose()
  18. end
  19. function LayerRule:initUI()
  20. self.imgPath = {
  21. "res/ModuleEapSdk/eapsdk_img_null.png",
  22. "res/ModuleEapSdk/eapsdk_public_back_bg6.png",
  23. "res/ModuleEapSdk/eapsdk_public_back_bg4.png",
  24. "res/ModuleEapSdk/eapsdk_bg_bj_sp1.png",
  25. "res/ModuleEapSdk/eapsdk_img_matchIcon.png", --5
  26. "res/ModuleEapSdk/eapsdk_rule_img_title.png",
  27. "res/ModuleEapSdk/eapsdk_img_leftBG.png",
  28. "res/ModuleEapSdk/eapsdk_rule_img_title2.png",
  29. }
  30. local fix_x = display.width
  31. local fix_y = display.cy
  32. local imgBack2 = G_EapAbbreviation.createImageView(self.imgPath[1], self, cc.p(fix_x-896, fix_y), true, 0, 4101, cc.p(0, 0.5))
  33. imgBack2:setSize(cc.size(BG_W, BG_H))
  34. self.imgBack2 = imgBack2
  35. local imgBack3 = G_EapAbbreviation.createImageView(self.imgPath[7], imgBack2, cc.p(0, 0), false, 0, 4101, cc.p(0, 0))
  36. imgBack3:setScale(0.6)
  37. local imgTitle = G_EapAbbreviation.createImageView(self.imgPath[5], imgBack2, cc.p(BG_W/4+10, BG_H-30), false, 3, 4101, cc.p(0.5, 1))
  38. imgTitle:setScale(0.4)
  39. self.imgTitleRule = G_EapAbbreviation.createImageView(self.imgPath[8], imgBack2, cc.p(3*BG_W/4-10, BG_H-70), false, 3, 4101, cc.p(0.5, 1))
  40. self.imgTitleRule:setScale(0.6)
  41. --赛事规则title
  42. self.imgTitleRule1 = G_EapAbbreviation.createImageView(self.imgPath[6], imgBack2, cc.p(BG_W/2, BG_H-130), false, 3, 4101, cc.p(0.5, 1))
  43. self.imgTitleRule1:setScale(0.6)
  44. -- scrollView
  45. self.scrollView = ccui.ScrollView:create()
  46. self.inner_h = 300
  47. self.scrlContent = self.scrollView:getInnerContainer()
  48. self.scrollView:setTouchEnabled(true)
  49. self.scrollView:setBounceEnabled(false)
  50. if self.scrollView.hideAllBar then
  51. self.scrollView:hideAllBar()
  52. end
  53. if self.scrollView.setScrollBarEnabled and type(self.scrollView.setScrollBarEnabled) == "function" then
  54. self.scrollView:setScrollBarEnabled(false)
  55. end
  56. self.scrollView:setSize(cc.size(300, 300))
  57. self.scrollView:setPosition(cc.p(20, 75))
  58. self.scrollView:setInnerContainerSize(cc.size(300, self.inner_h))
  59. imgBack2:addChild(self.scrollView, 4)
  60. self:refreshIcon()
  61. end
  62. function LayerRule:refreshRuleInfo()
  63. local __datas = G_EapSdkMgr.m_matchRule
  64. __datas = __datas or {["StrDes"]='赛事规则'}
  65. local resStr = {}
  66. local strArr = string.split(__datas.StrDes, "\n")
  67. local resStr = strArr
  68. -- local strArr = string.split(__datas.StrDes, "</p>")
  69. -- for i=1, #strArr-1 do
  70. -- local tranStr1 = string.match(strArr[i], "<p.*>(.*)")
  71. -- if tranStr1 then
  72. -- tranStr1 = string.gsub(tranStr1, "<br/>", "")
  73. -- resStr[#resStr+1] = tranStr1
  74. -- end
  75. -- end
  76. local desLabArr = {}
  77. local totalDesH = 0
  78. for i=1, #resStr do
  79. local des1 = resStr[i]
  80. local desLabel, desH = self:createCustomLabel(des1)
  81. desLabArr[#desLabArr+1] = desLabel
  82. desLabel.realH = desH + 10
  83. totalDesH = totalDesH + desLabel.realH
  84. end
  85. --先设置container大小,再添加节点
  86. self.inner_h = 240 + totalDesH
  87. if __datas.VecAwards then
  88. self.inner_h = self.inner_h + #__datas.VecAwards * 50
  89. end
  90. if self.inner_h < 445 then
  91. self.inner_h = 445
  92. end
  93. self.scrollView:setInnerContainerSize(cc.size(300, self.inner_h))
  94. -- local title1 = "积分赛规则"
  95. local title1 = ""
  96. self.rule_y = self.inner_h-20
  97. local lblRuleT = G_EapAbbreviation.createSystemLabel(self.scrollView, cc.p(10, self.rule_y), title1, 18, WEAK_COL1, true)
  98. lblRuleT:setAnchorPoint(cc.p(0, 0.5))
  99. self.ruleCon_y = self.rule_y-30
  100. for i=1, #desLabArr do
  101. local tmpLabel = desLabArr[i]
  102. tmpLabel:setAnchorPoint(cc.p(0.5, 1))
  103. tmpLabel:setPosition(cc.p(150, self.ruleCon_y))
  104. self.ruleCon_y = self.ruleCon_y - (tmpLabel.realH)
  105. self.scrollView:addChild(tmpLabel)
  106. end
  107. -- local title2 = "积分赛奖励"
  108. local title2 = ""
  109. local award_y = self.ruleCon_y - 40
  110. self.lblAward = G_EapAbbreviation.createSystemLabel(self.scrollView, cc.p(10, award_y), title2, 18, WEAK_COL1, true)
  111. self.lblAward:setAnchorPoint(cc.p(0, 0.5))
  112. local imgBack_y = award_y - 30
  113. self.imgBack4 = G_EapAbbreviation.createImageView(self.imgPath[4], self.scrollView, cc.p(150, imgBack_y), true, 2, 2102, cc.p(0.5, 1))
  114. self.imgBack4:setSize(cc.size(260, 40))
  115. local imgLine = G_EapAbbreviation.createImageView(self.imgPath[3], self.imgBack4, cc.p(111, 20))
  116. imgLine:setScale(1, 20)
  117. local title1 = "名次"
  118. G_EapAbbreviation.createSystemLabel(self.imgBack4, cc.p(55.5, 20), title1, 16, nil, true)
  119. local title2 = "奖励"
  120. G_EapAbbreviation.createSystemLabel(self.imgBack4, cc.p(180, 20), title2, 16, nil, true)
  121. local list_y = imgBack_y - 50
  122. local awardsDes = __datas.VecAwards
  123. if awardsDes then
  124. for i=1, #awardsDes do
  125. local awardItem = awardsDes[i]
  126. local itemNode = ccui.Layout:create()
  127. itemNode:setAnchorPoint(cc.p(0.5, 1))
  128. itemNode:setSize(cc.size(260, 40))
  129. itemNode:setPosition(cc.p(150, list_y-(i-1)*40))
  130. self.scrollView:addChild(itemNode)
  131. local title1 = "第"..awardItem.Begin.."名"
  132. if awardItem.Begin ~= awardItem.End then
  133. title1 = "第"..awardItem.Begin.."-"..awardItem.End.."名"
  134. end
  135. G_EapAbbreviation.createSystemLabel(itemNode, cc.p(55, 40/2), title1, 16, DEEP_COL1)
  136. local title2 = ""
  137. if awardItem.VecAwards then
  138. EapDump(awardItem.VecAwards, " awardsDes.VecAwards = ")
  139. for j=1, #awardItem.VecAwards do
  140. local award1 = awardItem.VecAwards[j]
  141. local itemName = G_EapSdkMgr:getItemName(award1.ItemID) or ""
  142. local awardStr = award1.ItemNum..itemName.." "
  143. title2 = title2..awardStr
  144. end
  145. end
  146. G_EapAbbreviation.createSystemLabel(itemNode, cc.p(180, 40/2), title2, 16, DEEP_COL1)
  147. end
  148. end
  149. end
  150. function LayerRule:refreshIcon()
  151. local iconInfo1006 = G_EapSdkMgr:getIconInfo(CONFIG_IMG_1006) --赛事规则
  152. if iconInfo1006 then
  153. local url = iconInfo1006.paths[1]
  154. local saveName = iconInfo1006.categoryId..tostring(iconInfo1006.updateTime)
  155. getUserImage(url, saveName, self.imgTitleRule, cc.size(184, 24))
  156. end
  157. end
  158. function LayerRule:createCustomLabel(resStr)
  159. local tmpLabel = cc.Text:createNode();
  160. tmpLabel:setDefaults();
  161. local config = tmpLabel:getFontConfig();
  162. config.fontSize = 15;
  163. tmpLabel:setFontConfig(config);
  164. tmpLabel:setColor(DEEP_COL1)
  165. tmpLabel:setTextAreaSize(cc.size(260, 0))
  166. tmpLabel:setLinePadding(3)
  167. tmpLabel:setAnchorPoint(cc.p(0,0.5))
  168. tmpLabel:setText(resStr);
  169. local tmpRect = tmpLabel:getVirtualRendererSize()
  170. return tmpLabel, tmpRect.height
  171. end
  172. return LayerRule