local DEEP_COL1 = cc.c3b(0x5a, 0x4c, 0x3b)
local WEAK_COL1 = cc.c3b(0x33, 0x33, 0x33)
local BG_W = 332
local BG_H = 600
local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer")
local LayerRule = EapClass("LayerRule", BaseLayer)
function LayerRule.createWithData(__node, __zorder)
local layer = LayerRule.new()
layer.m_parent = __node
__node:addChild(layer, __zorder)
return layer
end
function LayerRule:myShow()
-- self:addListener(true)
self:initUI()
end
function LayerRule:myClose()
end
function LayerRule:initUI()
self.imgPath = {
"res/ModuleEapSdk/eapsdk_img_null.png",
"res/ModuleEapSdk/eapsdk_public_back_bg6.png",
"res/ModuleEapSdk/eapsdk_public_back_bg4.png",
"res/ModuleEapSdk/eapsdk_bg_bj_sp1.png",
"res/ModuleEapSdk/eapsdk_img_matchIcon.png", --5
"res/ModuleEapSdk/eapsdk_rule_img_title.png",
"res/ModuleEapSdk/eapsdk_img_leftBG.png",
"res/ModuleEapSdk/eapsdk_rule_img_title2.png",
}
local fix_x = display.width
local fix_y = display.cy
local imgBack2 = G_EapAbbreviation.createImageView(self.imgPath[1], self, cc.p(fix_x-896, fix_y), true, 0, 4101, cc.p(0, 0.5))
imgBack2:setSize(cc.size(BG_W, BG_H))
self.imgBack2 = imgBack2
local imgBack3 = G_EapAbbreviation.createImageView(self.imgPath[7], imgBack2, cc.p(0, 0), false, 0, 4101, cc.p(0, 0))
imgBack3:setScale(0.6)
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))
imgTitle:setScale(0.4)
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))
self.imgTitleRule:setScale(0.6)
--赛事规则title
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))
self.imgTitleRule1:setScale(0.6)
-- scrollView
self.scrollView = ccui.ScrollView:create()
self.inner_h = 300
self.scrlContent = self.scrollView:getInnerContainer()
self.scrollView:setTouchEnabled(true)
self.scrollView:setBounceEnabled(false)
if self.scrollView.hideAllBar then
self.scrollView:hideAllBar()
end
if self.scrollView.setScrollBarEnabled and type(self.scrollView.setScrollBarEnabled) == "function" then
self.scrollView:setScrollBarEnabled(false)
end
self.scrollView:setSize(cc.size(300, 300))
self.scrollView:setPosition(cc.p(20, 75))
self.scrollView:setInnerContainerSize(cc.size(300, self.inner_h))
imgBack2:addChild(self.scrollView, 4)
self:refreshIcon()
end
function LayerRule:refreshRuleInfo()
local __datas = G_EapSdkMgr.m_matchRule
__datas = __datas or {["StrDes"]='赛事规则'}
local resStr = {}
local strArr = string.split(__datas.StrDes, "\n")
local resStr = strArr
-- local strArr = string.split(__datas.StrDes, "
")
-- for i=1, #strArr-1 do
-- local tranStr1 = string.match(strArr[i], "(.*)")
-- if tranStr1 then
-- tranStr1 = string.gsub(tranStr1, "
", "")
-- resStr[#resStr+1] = tranStr1
-- end
-- end
local desLabArr = {}
local totalDesH = 0
for i=1, #resStr do
local des1 = resStr[i]
local desLabel, desH = self:createCustomLabel(des1)
desLabArr[#desLabArr+1] = desLabel
desLabel.realH = desH + 10
totalDesH = totalDesH + desLabel.realH
end
--先设置container大小,再添加节点
self.inner_h = 240 + totalDesH
if __datas.VecAwards then
self.inner_h = self.inner_h + #__datas.VecAwards * 50
end
if self.inner_h < 445 then
self.inner_h = 445
end
self.scrollView:setInnerContainerSize(cc.size(300, self.inner_h))
-- local title1 = "积分赛规则"
local title1 = ""
self.rule_y = self.inner_h-20
local lblRuleT = G_EapAbbreviation.createSystemLabel(self.scrollView, cc.p(10, self.rule_y), title1, 18, WEAK_COL1, true)
lblRuleT:setAnchorPoint(cc.p(0, 0.5))
self.ruleCon_y = self.rule_y-30
for i=1, #desLabArr do
local tmpLabel = desLabArr[i]
tmpLabel:setAnchorPoint(cc.p(0.5, 1))
tmpLabel:setPosition(cc.p(150, self.ruleCon_y))
self.ruleCon_y = self.ruleCon_y - (tmpLabel.realH)
self.scrollView:addChild(tmpLabel)
end
-- local title2 = "积分赛奖励"
local title2 = ""
local award_y = self.ruleCon_y - 40
self.lblAward = G_EapAbbreviation.createSystemLabel(self.scrollView, cc.p(10, award_y), title2, 18, WEAK_COL1, true)
self.lblAward:setAnchorPoint(cc.p(0, 0.5))
local imgBack_y = award_y - 30
self.imgBack4 = G_EapAbbreviation.createImageView(self.imgPath[4], self.scrollView, cc.p(150, imgBack_y), true, 2, 2102, cc.p(0.5, 1))
self.imgBack4:setSize(cc.size(260, 40))
local imgLine = G_EapAbbreviation.createImageView(self.imgPath[3], self.imgBack4, cc.p(111, 20))
imgLine:setScale(1, 20)
local title1 = "名次"
G_EapAbbreviation.createSystemLabel(self.imgBack4, cc.p(55.5, 20), title1, 16, nil, true)
local title2 = "奖励"
G_EapAbbreviation.createSystemLabel(self.imgBack4, cc.p(180, 20), title2, 16, nil, true)
local list_y = imgBack_y - 50
local awardsDes = __datas.VecAwards
if awardsDes then
for i=1, #awardsDes do
local awardItem = awardsDes[i]
local itemNode = ccui.Layout:create()
itemNode:setAnchorPoint(cc.p(0.5, 1))
itemNode:setSize(cc.size(260, 40))
itemNode:setPosition(cc.p(150, list_y-(i-1)*40))
self.scrollView:addChild(itemNode)
local title1 = "第"..awardItem.Begin.."名"
if awardItem.Begin ~= awardItem.End then
title1 = "第"..awardItem.Begin.."-"..awardItem.End.."名"
end
G_EapAbbreviation.createSystemLabel(itemNode, cc.p(55, 40/2), title1, 16, DEEP_COL1)
local title2 = ""
if awardItem.VecAwards then
EapDump(awardItem.VecAwards, " awardsDes.VecAwards = ")
for j=1, #awardItem.VecAwards do
local award1 = awardItem.VecAwards[j]
local itemName = G_EapSdkMgr:getItemName(award1.ItemID) or ""
local awardStr = award1.ItemNum..itemName.." "
title2 = title2..awardStr
end
end
G_EapAbbreviation.createSystemLabel(itemNode, cc.p(180, 40/2), title2, 16, DEEP_COL1)
end
end
end
function LayerRule:refreshIcon()
local iconInfo1006 = G_EapSdkMgr:getIconInfo(CONFIG_IMG_1006) --赛事规则
if iconInfo1006 then
local url = iconInfo1006.paths[1]
local saveName = iconInfo1006.categoryId..tostring(iconInfo1006.updateTime)
getUserImage(url, saveName, self.imgTitleRule, cc.size(184, 24))
end
end
function LayerRule:createCustomLabel(resStr)
local tmpLabel = cc.Text:createNode();
tmpLabel:setDefaults();
local config = tmpLabel:getFontConfig();
config.fontSize = 15;
tmpLabel:setFontConfig(config);
tmpLabel:setColor(DEEP_COL1)
tmpLabel:setTextAreaSize(cc.size(260, 0))
tmpLabel:setLinePadding(3)
tmpLabel:setAnchorPoint(cc.p(0,0.5))
tmpLabel:setText(resStr);
local tmpRect = tmpLabel:getVirtualRendererSize()
return tmpLabel, tmpRect.height
end
return LayerRule