local scheduler = require("luaScript.ModuleEapSdk.SdkSocket.scheduler") local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer") local LayerTeamRank = class("LayerTeamRank", BaseLayer) function LayerTeamRank.createWithData(__node, __zorder) local layer = LayerTeamRank.new() layer.m_parent = __node __node:addChild(layer, __zorder) return layer end function LayerTeamRank:myShow() -- self:addListener(true) self:initData() self:initUI() end function LayerTeamRank:myClose() end function LayerTeamRank:initData() self.m_curSel = 1 self.m_menuItems = {} self.scrollView = nil end function LayerTeamRank: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", } 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("LayerTeamRank 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)*122.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) self:refreshSelfInfo() 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:initSelfInfo() end function LayerTeamRank:refreshRankList(__datas) --测试数据 __datas = { { { top = 1, nickName = "抗日小分队1", count = 5, score = 21.2 }, { top = 1, nickName = "抗日小分队1", count = 5, score = 21.2 }, { top = 1, nickName = "抗日小分队1", count = 5, score = 21.2 }, }, { { 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 LayerTeamRank: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+122.5, 25), title1, 23, disCol) --对局数 local title3 = info.count or "-" itemNode.lblCount = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50+2*122.5, 25), title3, 23, disCol) --积分 local title3 = info.score or "-" itemNode.lblScore = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(50+3*122.5, 25), title3, 23, disCol) end function LayerTeamRank:refreshItemInfo(itemNode, info, index) if not itemNode or not index or not info then return end itemNode.infoIndex = index --数据索引 --排名 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 LayerTeamRank:initSelfInfo() local disCol = cc.c3b(0x1e, 0x23, 0x36) local title1 = "-" self.lblMyRank = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(80, 38), title1, 25, disCol) local title2 = "-" self.lblMyTeam = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(80+122.5, 38), title2, 25, disCol) local title3 = "-" self.lblMyCount = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(80+2*122.5, 38), title3, 25, disCol) local title4 = "-" self.lblMyScore = G_EapAbbreviation.createSystemLabel(self.imgBack2, cc.p(80+3*122.5, 38), title4, 25, disCol) end function LayerTeamRank:refreshSelfInfo() local matchInfo = G_EapSdkMgr.m_matchInfos[self.m_curSel] if matchInfo then local info = G_EapSdkMgr:getSelfCoreInfoByID(matchInfo.coreId) if info then local disCol = cc.c3b(0x1e, 0x23, 0x36) local title1 = info.top or "-" self.lblMyRank:setString(title1) local title2 = G_EapSdkMgr.NickName or "-" if G_EapLabelTool.GetUTF8StrNums( title2 ) > 9 then title2 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title2, 9) title2 = title2..".." end self.lblMyName:setString(title2) local title3 = info.score or "-" self.lblMyScore:setString(title3) else local title1 = "-" self.lblMyRank:setString(title1) local title2 = "-" self.lblMyName:setString(title2) local title3 = "-" self.lblMyScore:setString(title3) end end end return LayerTeamRank