|
- local scheduler = require("luaScript.ModuleEapSdk.SdkSocket.scheduler")
- local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer")
- local LayerTeamDetail = class("LayerTeamDetail", BaseLayer)
-
- function LayerTeamDetail.createWithData(__node, __zorder)
- local layer = LayerTeamDetail.new()
- layer.m_parent = __node
- __node:addChild(layer, __zorder)
- return layer
- end
-
- function LayerTeamDetail:myShow()
- self:addListener(true)
- self:initData()
- self:initUI()
- end
-
- function LayerTeamDetail:myClose()
- end
-
- function LayerTeamDetail:initData()
- self.m_curSel = 1
- self.m_menuItems = {}
- self.m_teamDetails = {}
- self.scrollView = nil
- self.m_curShowDetail = -1
- end
-
- function LayerTeamDetail:initUI()
- self.imgPath = {
- "res/ModuleEapSdk/eapsdk_public_back_bg1.png",
- "res/ModuleEapSdk/eapsdk_public_back_bg2.png",
- "res/ModuleEapSdk/eapsdk_public_back_bg3.png",
- "res/ModuleEapSdk/eapsdk_bt_xb_sp.png",
- "res/ModuleEapSdk/eapsdk_wj_icon_decor.png",
- "res/ModuleEapSdk/eapsdk_wj_btn_back.png",
- "res/ModuleEapSdk/eapsdk_button_dx.png",
- "res/ModuleEapSdk/eapsdk_img_arrow"
- }
-
- local fix_x = display.width
- local fix_y = display.cy
- 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))
- imgBack2:setSize(cc.size(530, 500))
- self.imgBack2 = imgBack2
-
- local imgBack4 = G_EapAbbreviation.createImageView(self.imgPath[3], imgBack2, cc.p(265, 378), true, 0, 3103, cc.p(0.5, 1))
- imgBack4:setSize(cc.size(470, 305))
- local imgBack5 = G_EapAbbreviation.createImageView(self.imgPath[3], imgBack2, cc.p(265, 63), true, 0, 3104, cc.p(0.5, 1))
- imgBack5:setSize(cc.size(470, 50))
- local imgBack6 = G_EapAbbreviation.createImageView(self.imgPath[1], imgBack2, cc.p(265, 323), false, 0, 3105, cc.p(0.5, 1))
- imgBack6:setScaleX(8.4)
- imgBack6:setScaleY(0.04)
-
- local imgArrow1 = G_EapAbbreviation.createImageView(self.imgPath[5], imgBack2, cc.p(82, 468), false)
- local imgArrow2 = G_EapAbbreviation.createImageView(self.imgPath[4], imgBack2, cc.p(448, 468), false)
- imgArrow1:setScale(0.585)
- imgArrow2:setScale(0.585)
-
- local title = "战队详情"
- G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(265, 468), title, 28, cc.c3b(0xc8, 0xa8, 0x88), true)
-
- self.btnBack = ccui.Button:create(self.imgPath[6])
- self.btnBack:setPosition(cc.p(30, 470))
- imgBack2:addChild(self.btnBack)
-
- addButtonListener(self.btnBack, function()
- print("LayerTeamDetail btnBack clicked === ")
- if G_EapSdkMgr.m_isMatching then
- self.m_parent.m_parent:showLayer(LAYER_ENUM.LAYER_TEAM)
- else
- self.m_parent.m_parent:showLayer(LAYER_ENUM.LAYER_TEAM_END)
- end
- end)
-
- local normCol = cc.c3b(0xa7, 0xab, 0xb4)
- local disCol = cc.c3b(0x1e, 0x23, 0x36)
-
- local titles = {"名次", "战队", "对局数", "积分"}
- for i=1, #titles do
- local title = titles[i]
- G_EapAbbreviation.createSystemLabel(imgBack2, cc.p(80+(i-1)*112.5, 350), title, 25, disCol, true)
- end
-
- self.imgRow = G_EapAbbreviation.createImageView(self.imgPath[7], imgBack2, cc.p(110, 382), false)
- local btnMenus = G_EapAbbreviation.createMenu(imgBack2, 1, 3200, cc.p(265, 410))
- -- for i=1, #G_EapSdkMgr.m_matchInfos do
- for i=1, 3 do
- local matchItem = G_EapSdkMgr.m_matchInfos[i]
- local coreName1 = matchItem and matchItem.coreName or "赛事名称"..i
- if G_EapLabelTool.GetUTF8StrNums( coreName1 ) > 9 then
- coreName1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(coreName1, 9)
- coreName1 = coreName1..".."
- end
- local item1 = G_EapAbbreviation.createItemFont(btnMenus, cc.p(-156.6+(i-1)*156.6, 0), coreName1, 26, normCol, disCol, true, function()
- self.m_menuItems[self.m_curSel]:setEnabled(true)
- self.m_menuItems[i]:setEnabled(false)
- self.m_curSel = i
-
- self.imgRow:setPositionX(110+(i-1)*150)
- --刷新排行榜
- self:refreshRankList(G_EapSdkMgr.m_allRanks)
- end)
- self.m_menuItems[#self.m_menuItems+1] = item1
- end
-
- for i=1,#self.m_menuItems do
- if i == 1 then
- self.m_menuItems[i]:setEnabled(false)
- else
- self.m_menuItems[i]:setEnabled(true)
- end
- end
- self:initDetailNode()
- end
-
- --战队详情面板
- function LayerTeamDetail:initDetailNode()
- local disCol = cc.c3b(0x1e, 0x23, 0x36)
- local imgBack4 = G_EapAbbreviation.createImageView(self.imgPath[1], self.imgBack2, cc.p(265, 300), true, 0, 3106, cc.p(0.5, 1))
- imgBack4:setSize(cc.size(460, 200))
- self.detailNode = imgBack4
-
- local titles = {"队员", "对局数", "积分"}
- for i=1, #titles do
- local title = titles[i]
- G_EapAbbreviation.createSystemLabel(imgBack4, cc.p(80+(i-1)*150, 180), title, 22, disCol, true)
- end
-
- for i=1, 4 do
- local itemNode = ccui.Layout:create()
- itemNode:setAnchorPoint(cc.p(0.5, 1))
- itemNode:setSize(cc.size(460, 40))
- itemNode:setPosition(cc.p(230, 40*i))
- imgBack4:addChild(itemNode)
-
- --队员昵称
- local title1 = "-"
- itemNode.lblName = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(80+150, 20), title1, 23, disCol)
- --对局数
- local title2 = "-"
- itemNode.lblCount = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(80, 20), title2, 23, disCol)
- --积分
- local title3 = "-"
- itemNode.lblScore = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(80+2*150, 20), title3, 23, disCol)
-
- self.m_teamDetails[#self.m_teamDetails+1] = itemNode
- end
- self.detailNode:setVisible(false)
- end
-
- function LayerTeamDetail:refreshDetail(info)
- if info and #info > 0 then
- for i=1, #info do
- local itemNode = self.m_teamDetails[i]
- if itemNode then
- local detail = info[i]
- --昵称
- local title1 = detail.name or "-"
- if G_EapLabelTool.GetUTF8StrNums( title1 ) > 9 then
- title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 9)
- title1 = title1..".."
- end
- itemNode.lblName:setString(title1)
- --对局数
- local title3 = detail.count or "-"
- itemNode.lblCount:setString(title3)
- --积分
- local title4 = detail.score or "-"
- itemNode.lblScore:setString(title4)
- end
- end
- end
- end
-
- function LayerTeamDetail:refreshRankList(__datas)
- --测试数据
- __datas = {
- {
- {
- top = 1,
- nickName = "抗日小分队1",
- count = 5,
- score = 21.2,
- detail = {
- {
- name = "李云龙",
- count = 2,
- score = 3,
- },
- {
- name = "黄继光",
- count = 1,
- score = 5,
- },
- {
- name = "燕双鹰",
- count = 1,
- score = 8,
- },
- {
- name = "董存瑞",
- count = 1,
- score = 10,
- }
- }
- },
- {
- top = 1,
- nickName = "抗日小分队2",
- count = 5,
- score = 21.2,
- detail = {
- {
- name = "李云龙2",
- count = 2,
- score = 3,
- },
- {
- name = "黄继光2",
- count = 1,
- score = 5,
- },
- {
- name = "燕双鹰2",
- count = 1,
- score = 8,
- },
- {
- name = "董存瑞2",
- count = 1,
- score = 10,
- }
- }
- },
- {
- top = 1,
- nickName = "抗日小分队3",
- count = 5,
- score = 21.2,
- detail = {
- {
- name = "李云龙3",
- count = 2,
- score = 3,
- },
- {
- name = "黄继光3",
- count = 1,
- score = 5,
- },
- {
- name = "燕双鹰3",
- count = 1,
- score = 8,
- },
- {
- name = "董存瑞3",
- count = 1,
- score = 10,
- }
- }
- },
- },
- {
- {
- top = 1,
- nickName = "抗日小分队2",
- count = 5,
- score = 22.2
- },
- {
- top = 1,
- nickName = "抗日小分队3",
- count = 5,
- score = 22.2
- },
- {
- top = 1,
- nickName = "抗日小分队4",
- count = 5,
- score = 22.2
- },
- },
- {
- {
- top = 1,
- nickName = "抗日小分队5",
- count = 5,
- score = 23.2
- },
- {
- top = 1,
- nickName = "抗日小分队6",
- count = 5,
- score = 23.2
- },
- {
- top = 1,
- nickName = "抗日小分队7",
- count = 5,
- score = 23.2
- },
- }
- }
- if self.scrollView then
- self.scrollView:destroySelf()
- self.scrollView = nil
- end
- local EapListView = require("luaScript.ModuleEapSdk.GameTools.EapListView")
- self.scrollView = EapListView.createWithData(self.imgBack2, self)
- self.scrollView:setPosition(cc.p(31, 73))
- self.scrollView:refreshRankList(__datas[self.m_curSel])
- end
-
- function LayerTeamDetail:initItemInfo(itemNode, info)
- local disCol = cc.c3b(0x1e, 0x23, 0x36)
- --排名
- local title2 = info.top or "-"
- itemNode.lblRank = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50, 25), title2, 23, disCol)
- --昵称
- local title1 = info.nickName or "-"
- if G_EapLabelTool.GetUTF8StrNums( title1 ) > 9 then
- title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 9)
- title1 = title1..".."
- end
- itemNode.lblName = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50+112.5, 25), title1, 23, disCol)
- --对局数
- local title3 = info.count or "-"
- itemNode.lblCount = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50+2*112.5, 25), title3, 23, disCol)
- --积分
- local title3 = info.score or "-"
- itemNode.lblScore = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50+3*112.5, 25), title3, 23, disCol)
-
- --详情
- addButtonListener(itemNode, function()
- if itemNode.m_info.detail then
- self.detailNode:setVisible(true)
- self:refreshDetail(itemNode.m_info.detail)
- end
- end)
- end
-
- function LayerTeamDetail:refreshItemInfo(itemNode, info, index)
- if not itemNode or not index or not info then
- return
- end
-
- itemNode.infoIndex = index --数据索引
- itemNode.m_info = info
- --排名
- local title2 = info.top or "-"
- itemNode.lblRank:setString(title2)
- --昵称
- local title1 = info.nickName or "-"
- if G_EapLabelTool.GetUTF8StrNums( title1 ) > 9 then
- title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 9)
- title1 = title1..".."
- end
- itemNode.lblName:setString(title1)
- --对局数
- local title3 = info.count or "-"
- itemNode.lblCount:setString(title3)
- --积分
- local title4 = info.score or "-"
- itemNode.lblScore:setString(title4)
- end
-
- function LayerTeamDetail:onTouchEnd(touch)
- local touchPos = touch:getLocation()
- local transPos = self.imgBack2:convertToNodeSpace(touchPos)
- local rect = self.detailNode:getBoundingBox()
- if not cc.rectContainsPoint(rect, transPos) then
- self.detailNode:setVisible(false)
- end
- end
- return LayerTeamDetail
|