|
- local DEEP_COL1 = cc.c3b(0x0b, 0x2d, 0x67)
- local WEAK_COL1 = cc.c3b(0xf8, 0xee, 0xc1)
- local BG_W = 332
- local BG_H = 600
-
- local scheduler = require("luaScript.ModuleEapSdk.SdkSocket.scheduler")
- local BaseLayer = require("luaScript.ModuleEapSdk.BaseLayers.BaseLayer")
- local LayerRank = EapClass("LayerRank", BaseLayer)
-
- function LayerRank.createWithData(__node, __zorder)
- local layer = LayerRank.new()
- layer.m_parent = __node
- __node:addChild(layer, __zorder)
- return layer
- end
-
- function LayerRank:myShow()
- -- self:addListener(true)
- self:initData()
- self:initUI()
- end
-
- function LayerRank:myClose()
- end
-
- function LayerRank:initData()
- self.m_curSel = 1
- self.m_curType = 1 --1:积分赛排行 2:亲友排行
- self.m_matchIDs = {} --matchid数组
- self.m_menuItems = {}
- self.scrollView = nil
- end
-
- function LayerRank: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",
- "res/ModuleEapSdk/Eap_Score/eapsdk_img_scoreRankTitle.png",
-
- "res/ModuleEapSdk/Eap_Score/eapsdk_img_pageBG.png", --10
- "res/ModuleEapSdk/Eap_Score/eapsdk_btn_scoreRank1.png",
- "res/ModuleEapSdk/Eap_Score/eapsdk_btn_scoreRank2.png",
- "res/ModuleEapSdk/Eap_Score/eapsdk_btn_winRank1.png",
- "res/ModuleEapSdk/Eap_Score/eapsdk_btn_winRank2.png",
- "res/ModuleEapSdk/Eap_Score/eapsdk_img_ranklistTitle.png", --15
- "res/ModuleEapSdk/Eap_Score/eapsdk_img_ranklistBG1.png",
- "res/ModuleEapSdk/Eap_Score/eapsdk_img_ranklistBG2.png",
- "res/ModuleEapSdk/Eap_Score/eapsdk_rank_img_tips.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[9], imgBack2, cc.p(3*BG_W/4-10, BG_H-20), false, 3, 4101, cc.p(0.5, 1))
- self.imgTitleRule1:setScale(0.65)
-
- --大列表
- -- self.scrollBig = ccui.ScrollView:create()
- -- self.inner_h = 430 + 130 + 100
- -- self.scrollBig:setBounceEnabled(false)
- -- self.scrollBig:setTouchEnabled(true)
- -- if self.scrollBig.hideAllBar then
- -- self.scrollBig:hideAllBar()
- -- end
-
- -- self.scrollBig:setSize(cc.size(BG_W, BG_H-130))
- -- self.scrollBig:setPosition(cc.p(0, 0))
-
- -- self.scrollBig:setInnerContainerSize(cc.size(BG_W, self.inner_h))
- -- imgBack2:addChild(self.scrollBig, 4)
-
- self.scrollBig = cc.Node:create()
- self.inner_h = 430 + 130 + 100
- self.scrollBig:setPosition(cc.p(0, BG_H-130-self.inner_h))
- imgBack2:addChild(self.scrollBig, 4)
-
- local init_x = 27.5
- local offY = self.inner_h-30
- --切换积分赛,排行榜
-
- --切换积分赛,大赢家排行榜
- local btnMenus1 = cc.Node:create()
- btnMenus1:setPosition(cc.p(166, offY))
- self.scrollBig:addChild(btnMenus1)
-
- self.btnScore = ccui.ImageView:create(self.imgPath[12])
- self.btnScore:setPosition(cc.p(-70, 0))
- btnMenus1:addChild(self.btnScore)
- addButtonListener(self.btnScore, function()
- G_EapSocketLogin.request_markLog(MARK_LOG10006)
- print("self.btnScore clicked ========= ")
- self.btnScore:setTouchEnabled(false)
- self.btnWin:setTouchEnabled(true)
- self.btnScore:loadTexture(self.imgPath[12])
- self.btnWin:loadTexture(self.imgPath[13])
-
- self.m_curType = 1
- self:refreshRankList(self.m_matchIDs[self.m_curSel])
- end)
-
- self.btnWin = ccui.ImageView:create(self.imgPath[13])
- self.btnWin:setPosition(cc.p(70, 0))
- btnMenus1:addChild(self.btnWin)
- addButtonListener(self.btnWin, function()
- G_EapSocketLogin.request_markLog(MARK_LOG10005)
- print("self.btnWin clicked ========= ")
- self.btnScore:setTouchEnabled(true)
- self.btnWin:setTouchEnabled(false)
- self.btnScore:loadTexture(self.imgPath[11])
- self.btnWin:loadTexture(self.imgPath[14])
-
- self.m_curType = 2
- self:refreshRankList(self.m_matchIDs[self.m_curSel])
- end)
- self.btnScore:setScale(0.6)
- self.btnWin:setScale(0.6)
- self.btnScore:setTouchEnabled(false)
- self.btnWin:setTouchEnabled(true)
-
- local imgBack4 = G_EapAbbreviation.createImageView(self.imgPath[15], self.scrollBig, cc.p(BG_W/2, offY-65), false, 0, 3103, cc.p(0.5, 1))
- imgBack4:setScale(0.6)
-
- self.imgRow = G_EapAbbreviation.createImageView(self.imgPath[10], self.scrollBig, cc.p(BG_W/2, offY-25), false, 0, 3103, cc.p(0.5, 1))
- self.imgRow:setScale(0.6)
- -- local btnMenus = G_EapAbbreviation.createMenu(imgBack2, 1, 3200, cc.p(166, 410+60))
- local btnMenus = cc.Node:create()
- btnMenus:setPosition(cc.p(BG_W/2, offY-40))
- self.scrollBig:addChild(btnMenus)
- local vecMatchInfos = {}
- for k,v in pairs(G_EapSdkMgr.m_matchInfos) do
- vecMatchInfos[#vecMatchInfos+1] = v
- self.m_matchIDs[#self.m_matchIDs+1] = k
- end
-
- self.btnMenus = btnMenus
- if not G_EapSdkMgr.m_pointSelGameID then
- btnMenus:setVisible(false)
- end
- for i=1, #vecMatchInfos do
- local matchItem = vecMatchInfos[i]
- local gameInfo = G_EapSdkMgr:getGameInfo(matchItem.GameID)
- local coreName1 = gameInfo and gameInfo.name or "赛事名称"..i
- if G_EapLabelTool.GetUTF8StrNums( coreName1 ) > 9 then
- coreName1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(coreName1, 9)
- coreName1 = coreName1..".."
- end
-
- local item1 = self:createItemFont(btnMenus, i, coreName1)
- addButtonListener(item1, function()
- print("item1 clicked ========= ")
- self:setItemFontEnable(self.m_menuItems[self.m_curSel], true)
- self:setItemFontEnable(self.m_menuItems[i], false)
- self.m_curSel = i
-
- -- self.imgRow:setPositionX(45+(i-1)*150)
- --刷新排行榜
- self:refreshRankList(self.m_matchIDs[self.m_curSel])
- end)
- self.m_menuItems[#self.m_menuItems+1] = item1
- end
-
- for i=1,#self.m_menuItems do
- if i == 1 then
- self:setItemFontEnable(self.m_menuItems[i], false)
- else
- self:setItemFontEnable(self.m_menuItems[i], true)
- end
- end
-
- self:initSelfRank()
- self:initGameTips()
- self:refreshIcon()
- end
-
- function LayerRank:refreshRankList(__matchID)
- if not G_EapSdkMgr.m_pointSelGameID then
- self.btnMenus:setVisible(false)
- return
- else
- self.m_matchIDs = {}
- local index = 1
- for k,v in pairs(G_EapSdkMgr.m_matchInfos) do
- self.m_matchIDs[#self.m_matchIDs+1] = k
-
- local gameInfo = G_EapSdkMgr:getGameInfo(v.GameID)
- local coreName1 = gameInfo and gameInfo.name or "赛事名称"..k
- if G_EapLabelTool.GetUTF8StrNums( coreName1 ) > 6 then
- coreName1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(coreName1, 6)
- coreName1 = coreName1..".."
- end
- self.m_menuItems[index]:setTitleText(coreName1)
- index = index + 1
- end
-
- self.btnMenus:setVisible(true)
- end
- if __matchID ~= self.m_matchIDs[self.m_curSel] then
- return
- end
- local __datas = nil
- if self.m_curType == 1 then
- __datas = G_EapSdkMgr.m_allRanks[__matchID]
- elseif self.m_curType == 2 then
- __datas = G_EapSdkMgr.m_friendMatchInfos[__matchID]
- end
-
- if __datas then
- table.sort(__datas, function(a,b)
- local rank_a = a.Rank or 0 --赛程积分
- local rank_b = b.Rank or 0
- return rank_a < rank_b
- end)
- end
- self:refreshSelfRank()
-
- if self.scrollView then
- self.scrollView:destroySelf()
- self.scrollView = nil
- end
- if not __datas then
- return
- end
-
- local EapListView = require("luaScript.ModuleEapSdk.GameTools.EapListView")
- self.scrollView = EapListView.createWithData(self.scrollBig, self)
- local params = {
- scrl_h = 245-84+50, -- 外框高度
- scrl_w = 332, -- 外框宽度
- inner_h = 245-84+50, -- 内容器高度
- item_h = 56, -- 元素高度
- }
- self.scrollView:setScrlParam(params)
- self.scrollView:setPosition(cc.p(22, 74+130+100))
- self.scrollView:refreshRankList(__datas)
- self.scrollView:setLocalZOrder(5)
-
- end
-
- function LayerRank:initItemInfo(itemNode, info)
- local item_h = 56
- local initX = 48
- info = info or {}
- itemNode.m_id = info.PID
- --排名
- if not info.Rank then
- info.Rank = 0
- end
- local tmpRank = info.Rank or "-"
- local curScore = info.Calcu or 0
- local blScore = info.BlScore or 0
- local allNum = info.AllNum or 0
- local reScore = info.ReScore or 0
- local gameCount = info.ReNum or 0
- local blRank = info.BlRank or 0
- local acRank = info.AcRank or 0
- local reRank = info.ReRank or 0
-
- if curScore ~= 0 then
- curScore = string.format("%.2f", curScore)
- end
- if blScore ~= 0 then
- blScore = string.format("%.2f", blScore)
- end
-
- local imgItemBG = G_EapAbbreviation.createImageView(self.imgPath[17], itemNode, cc.p(288/2, item_h/2))
- imgItemBG:setScale(0.6)
- --名次
- local title2 = tmpRank
- itemNode.lblRank = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(initX/2, 28), title2, 12, DEEP_COL1)
- --昵称
- local userInfo = G_EapSdkMgr.m_userBaseInfos[info.PID]
- local nickname = userInfo and userInfo.strNickname
- local title1 = nickname or tostring(info.PID)
- if G_EapLabelTool.GetUTF8StrNums( title1 ) > 5 then
- title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 5)
- title1 = title1..".."
- end
- itemNode.lblName = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(initX/2+initX, 28), title1, 12, DEEP_COL1)
-
- --赛程分
- local title3 = curScore
- itemNode.lblScore = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(initX/2+initX*2, 28), title3, 12, DEEP_COL1)
-
- --平均局数
- local title4 = blScore
- itemNode.lblCount = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(initX/2+initX*3, 28+8), title4, 12, DEEP_COL1)
- --平均局数排名
- title4 = "/"..blRank
- itemNode.lblBlRank = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(initX/2+initX*3, 28-8), title4, 12, DEEP_COL1)
-
- --比赛局数
- local title5 = allNum
- itemNode.lblAllNum = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(initX/2+initX*4, 28+8), title5, 12, DEEP_COL1)
- --比赛局数排名
- title5 = "/"..acRank
- itemNode.lblAllRank = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(initX/2+initX*4, 28-8), title5, 12, DEEP_COL1)
-
- --热力局数
- local title6 = gameCount
- itemNode.lblReNum = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(initX/2+initX*5, 28+8), title6, 12, DEEP_COL1)
- --热力局数排名
- title6 = "/"..reRank
- itemNode.lblReRank = G_EapAbbreviation.createSystemLabel(itemNode, cc.p(initX/2+initX*5, 28-8), title6, 12, DEEP_COL1)
- end
-
-
- function LayerRank:refreshItemInfo(itemNode, info, index)
- if not itemNode or not index or not info then
- return
- end
-
- itemNode.m_id = info.PID
- itemNode.infoIndex = index --数据索引
- itemNode.m_info = info
- --排名
- if not info.Rank then
- info.Rank = 0
- end
-
- local tmpRank = info.Rank or "-"
- local curScore = info.Calcu or 0
- local blScore = info.BlScore or 0
- local allNum = info.AllNum or 0
- local reScore = info.ReScore or 0
- local gameCount = info.ReNum or 0
- local blRank = info.BlRank or 0
- local acRank = info.AcRank or 0
- local reRank = info.ReRank or 0
-
- if curScore ~= 0 then
- curScore = string.format("%.2f", curScore)
- end
- if blScore ~= 0 then
- blScore = string.format("%.2f", blScore)
- end
-
- local title2 = tmpRank
- itemNode.lblRank:setString(title2)
- --昵称
- local userInfo = G_EapSdkMgr.m_userBaseInfos[info.PID]
- local nickname = userInfo and userInfo.strNickname
- local title1 = nickname or tostring(info.PID)
- if G_EapLabelTool.GetUTF8StrNums( title1 ) > 5 then
- title1 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title1, 5)
- title1 = title1..".."
- end
- itemNode.lblName:setString(title1)
-
- --赛程分
- local title3 = curScore
- itemNode.lblScore:setString(title3)
-
- --平均局数
- local title4 = blScore
- itemNode.lblCount:setString(title4)
- --平均局数
- title4 = "/"..blRank
- itemNode.lblBlRank:setString(title4)
-
- --比赛局数
- local title5 = allNum
- itemNode.lblAllNum:setString(title5)
- --比赛局数
- title5 = "/"..acRank
- itemNode.lblAllRank:setString(title5)
-
- --热力局数
- local title6 = gameCount
- itemNode.lblReNum:setString(title6)
- --热力局数
- title6 = "/"..reRank
- itemNode.lblReRank:setString(title6)
- end
-
- function LayerRank:createItemFont(__parent, __index, __title)
- local sysFont = G_EapAbbreviation.getSystemFont()
- local item1 = ccui.Button:create()
- item1:setScale9Enabled(true)
- item1:setSize(cc.size(111, 50))
- item1:setPosition(cc.p(-95+(__index-1)*111, 0))
- local ttfConfig = {}
- ttfConfig.fontFilePath = sysFont
- ttfConfig.fontSize = 18
- ttfConfig.glyphs = cc.GLYPHCOLLECTION_DYNAMIC
- ttfConfig.customGlyphs = nil
- ttfConfig.distanceFieldEnabled = false
- ttfConfig.outlineSize = 0
- item1:setFontConfig(ttfConfig)
- item1:setTitleText(__title)
- __parent:addChild(item1)
- return item1
- end
-
- function LayerRank:setItemFontEnable(__node, __state)
- if __node then
- if __state then
- __node:setTitleColor(DEEP_COL1)
- else
- __node:setTitleColor(WEAK_COL1)
- end
- __node:setTouchEnabled(__state)
- end
- end
-
- --刷新个人信息
- function LayerRank:refreshUserInfo()
- if G_EapSdkMgr.m_userBaseInfos and self.scrollView then
- for k, v in pairs(G_EapSdkMgr.m_userBaseInfos) do
- local userInfo = v
- local item = self.scrollView:getItemByID(k)
- if userInfo and item then
- local nickname = userInfo.strNickname or tostring(userInfo.nPID) or ""
- if G_EapLabelTool.GetUTF8StrNums( nickname ) > 5 then
- nickname = G_EapLabelTool.GetUTF8StrByIdxNumEx(nickname, 5)
- nickname = nickname..".."
- end
- item.lblName:setString(nickname or "ID:"..k)
- end
- end
- end
- end
-
- function LayerRank:initSelfRank()
- local init_x = 24
-
- local imgBack5 = G_EapAbbreviation.createImageView(self.imgPath[16], self.scrollBig, cc.p(BG_W/2, 60+130+100), false, 0, 3104, cc.p(0.5, 1))
- imgBack5:setScale(0.6)
- local node_self = cc.Node:create()
- node_self:setPosition(cc.p(22, 10+130+100))
- self.scrollBig:addChild(node_self)
-
- local title1 = "-"
- self.lblMyRank = G_EapAbbreviation.createSystemLabel(node_self, cc.p(init_x, 28), title1, 12, DEEP_COL1)
- self.lblMyName = G_EapAbbreviation.createSystemLabel(node_self, cc.p(init_x+48, 28), title1, 12, DEEP_COL1)
- self.lblMyScore = G_EapAbbreviation.createSystemLabel(node_self, cc.p(init_x+2*48, 28), title1, 12, DEEP_COL1)
- self.lblMyBlScore = G_EapAbbreviation.createSystemLabel(node_self, cc.p(init_x+3*48, 28+8), title1, 12, DEEP_COL1)
- self.lblMyAllNum = G_EapAbbreviation.createSystemLabel(node_self, cc.p(init_x+4*48, 28+8), title1, 12, DEEP_COL1)
- self.lblMyReNum = G_EapAbbreviation.createSystemLabel(node_self, cc.p(init_x+5*48, 28+8), title1, 12, DEEP_COL1)
- self.lblMyBlRank = G_EapAbbreviation.createSystemLabel(node_self, cc.p(init_x+3*48, 28-8), title1, 12, DEEP_COL1)
- self.lblMyAllRank = G_EapAbbreviation.createSystemLabel(node_self, cc.p(init_x+4*48, 28-8), title1, 12, DEEP_COL1)
- self.lblMyReRank = G_EapAbbreviation.createSystemLabel(node_self, cc.p(init_x+5*48, 28-8), title1, 12, DEEP_COL1)
- end
-
- function LayerRank:refreshSelfRank()
- local init_x = 110+200
- local matchID = self.m_matchIDs[self.m_curSel]
-
- local info = G_EapSdkMgr.m_selfRank[matchID]
- if info then
- local tmpRank = info.Rank or "-"
- local curScore = info.Calcu or 0
- local blScore = info.BlScore or 0
- local allNum = info.AllNum or 0
- local reScore = info.ReScore or 0
- local gameCount = info.ReNum or 0
- local blRank = info.BlRank or 0
- local acRank = info.AcRank or 0
- local reRank = info.ReRank or 0
-
- if curScore ~= 0 then
- curScore = string.format("%.2f", curScore)
- end
- if blScore ~= 0 then
- blScore = string.format("%.2f", blScore)
- end
-
- local title1 = tmpRank
- self.lblMyRank:setString(title1)
-
- local title2 = G_EapSdkMgr.NickName or "-"
- if G_EapLabelTool.GetUTF8StrNums( title2 ) > 6 then
- title2 = G_EapLabelTool.GetUTF8StrByIdxNumEx(title2, 6)
- title2 = title2..".."
- end
- self.lblMyName:setString(title2)
- local title3 = curScore
- self.lblMyScore:setString(title3)
- local title4 = blScore
- self.lblMyBlScore:setString(title4)
- local title5 = allNum
- self.lblMyAllNum:setString(title5)
- local title6 = gameCount
- self.lblMyReNum:setString(title6)
- title4 = "/"..blRank
- self.lblMyBlRank:setString(title4)
- title5 = "/"..acRank
- self.lblMyAllRank:setString(title5)
- title6 = "/"..reRank
- self.lblMyReRank:setString(title6)
- else
- local title1 = "-"
- self.lblMyRank:setString(title1)
- self.lblMyName:setString(title1)
- self.lblMyScore:setString(title1)
- self.lblMyBlScore:setString(title1)
- self.lblMyAllNum:setString(title1)
- self.lblMyReNum:setString(title1)
- self.lblMyBlRank:setString(title1)
- self.lblMyAllRank:setString(title1)
- self.lblMyReRank:setString(title1)
- end
- end
-
- function LayerRank:initGameTips()
- -- self.imgGameTips = G_EapAbbreviation.createImageView(self.imgPath[18], self.scrollBig, cc.p(BG_W/2, 30), false, 0, 3104, cc.p(0.5, 0))
- -- self.imgGameTips:setScale(0.6)
- local tipStr = "多赢牌,多对局提高排名(满100局后进入排行)"
- G_EapAbbreviation.createSystemLabel(self.scrollBig, cc.p(BG_W/2, 130+100-15), tipStr, 15, DEEP_COL1, true)
- end
-
- function LayerRank:refreshIcon()
- local iconInfo1008 = G_EapSdkMgr:getIconInfo(CONFIG_IMG_1008) --赛事排行榜
- if iconInfo1008 then
- local url = iconInfo1008.paths[1]
- local saveName = iconInfo1008.categoryId..tostring(iconInfo1008.updateTime)
- getUserImage(url, saveName, self.imgTitleRule, cc.size(184, 24))
- end
- end
-
- return LayerRank
|