require("Base/BasePanel")
RankingListMainPanel = Inherit(BasePanel)
local this = RankingListMainPanel
local curIndex = 1
local rankKingListGo = {}
local TabBox = require("Modules/Common/TabBox")
local _TabData={ [1] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001",lock = "r_hero_xuanze_002", name = Language[11673] },
[2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001",lock = "r_hero_xuanze_002", name = Language[11674] },
}
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1),
lock = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
}
local ranks = {}
local proud = {}
this.playerScrollHead = {}--排行第一头像
--初始化组件(用于子类重写)
function RankingListMainPanel:InitComponent()
this.spLoader = SpriteLoader.New()
this.tabBox = Util.GetGameObject(self.gameObject, "TabBox")
this.TabCtrl = TabBox.New()
this.BackBtn = Util.GetGameObject(self.gameObject, "bg/btnBack")
this.ItemPre = Util.GetGameObject(self.gameObject, "bg/panel/ItemPre")
this.grid = Util.GetGameObject(self.gameObject, "bg/panel/ScrollParentView/grid")
end
--绑定事件(用于子类重写)
function RankingListMainPanel:BindEvent()
Util.AddClick(this.BackBtn, function()
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function RankingListMainPanel:AddListener()
end
--移除事件监听(用于子类重写)
function RankingListMainPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function RankingListMainPanel:OnOpen(msg)
ranks = msg.ranks
curIndex = 1
LogYellow("#msg.ranks "..#msg.ranks.." "..#msg.proud)
for i = 1, #msg.ranks do
LogYellow("msg.ranks "..msg.ranks[i].uid)
LogYellow("msg.proud "..msg.proud[i])
end
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function RankingListMainPanel:OnShow()
this.TabCtrl:SetTabAdapter(this.TabAdapter)
this.TabCtrl:SetChangeTabCallBack(this.SwitchView)
this.TabCtrl:SetTabIsLockCheck(this.PageTabIsLockCheck)
this.TabCtrl:Init(this.tabBox, _TabData, curIndex)
end
-- tab节点显示自定义
function this.TabAdapter(tab, index, status)
local tabLab = Util.GetGameObject(tab, "Text")
Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status])
tabLab:GetComponent("Text").text = GetCurLanguage() ~= 2 and _TabData[index].name or "".._TabData[index].name..""
tabLab:GetComponent("Text").color = _TabFontColor[status]
Util.GetGameObject(tab, "LockImage"):SetActive(status == "lock" )
if index == 1 then
Util.GetGameObject(tab, "Redpot"):SetActive(RankingManager.RefreshRedPoint1())
else
Util.GetGameObject(tab, "Redpot"):SetActive(RankingManager.RefreshRedPoint2())
end
end-- tab可用性检测
function this.PageTabIsLockCheck(index)
if index == 2 then
if PlayerManager.isCross == 1 then
return false--true, "功能尚未开启,敬请期待!"
else
return true, "未划分跨服分组!"
end
else
return false
end
end
--切换视图
function this.SwitchView(index)
curIndex = index
proud = RankingManager.GetRankProud()
--先执行上一面板关闭逻辑
local currankKingList = {}
for i = 1, math.max(#rankKingListGo, #rankKingList) do
if curIndex == rankKingList[i].isRankingMainPanelShow then
local go = rankKingListGo[i]
if not go then
go=newObject(this.ItemPre)
go.transform:SetParent(this.grid.transform)
go.transform.localScale = Vector3.one
go.transform.localPosition=Vector3.zero;
rankKingListGo[i] = go
end
go.gameObject:SetActive(false)
table.insert(currankKingList, rankKingList[i])
end
end
for i = 1, #rankKingList do
if curIndex == rankKingList[i].isRankingMainPanelShow then
for j = 1, #currankKingList do
if currankKingList[j].rankType == rankKingList[i].rankType then
LogYellow("j "..j)
rankKingListGo[j]:SetActive(true)
this.SingleRankKingListShow(j,i)
end
end
end
end
end
function this.SingleRankKingListShow(indexm,id)
local go = rankKingListGo[indexm]
local sData = rankKingList[id]
local dData = ranks[sData.RankingListMainSortId]
local proud = proud[sData.rankType]
Util.GetGameObject(go,"BG"):GetComponent("Image").sprite = this.spLoader:LoadSprite(sData.bgImage)
Util.GetGameObject(go,"heor"):SetActive(dData.uid ~= 0 )
if dData.uid ~= 0 then
this.SetInfoShow(Util.GetGameObject(go,"heor/infoGo"),dData,sData.rankType,Util.GetGameObject(go,"heor/nameText"))
--头像
local headObj=Util.GetGameObject(go,"heor/Head")
if not this.playerScrollHead[go] then
this.playerScrollHead[go]=CommonPool.CreateNode(POOL_ITEM_TYPE.PLAYER_HEAD,headObj)
end
this.playerScrollHead[go]:Reset()
this.playerScrollHead[go]:SetHead(dData.head)
this.playerScrollHead[go]:SetFrame(dData.headFrame)
this.playerScrollHead[go]:SetLevel(dData.level)
this.playerScrollHead[go]:SetScale(Vector3.one*0.6)
this.playerScrollHead[go]:SetLayer(this.sortingOrder)
this.playerScrollHead[go]:SetEffectScale(0.7)
end
--膜拜
local clickBtn = Util.GetGameObject(go,"clickBtn")
local getRewardBtn = Util.GetGameObject(go,"getRewardBtn")
local getRewardBtnText = Util.GetGameObject(go,"getRewardBtn/Text"):GetComponent("Text")
getRewardBtn:SetActive(dData.uid ~= 0 )
Util.AddOnceClick(clickBtn, function()
UIManager.OpenPanel(UIName.RankingSingleListPanel,sData)
end)
getRewardBtnText.fontSize = GetCurLanguage() ~= 2 and 50 or 40--根据语言设置大小
if proud == 0 then--没有膜拜过
getRewardBtn:GetComponent("Button").enabled = true
Util.GetGameObject(go,"getRewardBtn/redPoint"):SetActive(true)
getRewardBtnText.text = Language[11120]
Util.AddOnceClick(getRewardBtn, function()
NetManager.RankProudRequest(sData.rankType,function ()
RankingManager.SetSingleRankProud(sData.rankType,1)
local spFata = ConfigManager.GetConfigData(ConfigName.SpecialConfig,50)
local itemData = string.split(spFata.Value, "#")
PopupTipPanel.ShowTip(Language[11676]..GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig,tonumber(itemData[1])).Name).."×"..itemData[2].."!")
this.SwitchView(curIndex)
CheckRedPointStatus(RedPointType.RankingSort)
end)
end)
else
getRewardBtn:GetComponent("Button").enabled = false
getRewardBtnText.text = Language[11677]
Util.GetGameObject(go,"getRewardBtn/redPoint"):SetActive(false)
end
Util.SetGray(getRewardBtn,proud ~= 0)
end
--界面关闭时调用(用于子类重写)
function RankingListMainPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function RankingListMainPanel:OnDestroy()
this.spLoader:Destroy()
for _, playerHead in ipairs(this.playerScrollHead) do
playerHead:Recycle()
end
this.playerScrollHead = {}
rankKingListGo = {}
end
function this.SetInfoShow(go,data,rankType,nameText)
local fight = Util.GetGameObject(go,"fight")
local warPower = Util.GetGameObject(go,"warPower")
local trial = Util.GetGameObject(go,"trial")
local FightLeveStar = Util.GetGameObject(go,"FightLeveStar")
fight:SetActive(false)
warPower:SetActive(false)
trial:SetActive(false)
FightLeveStar:SetActive(false)
if rankType == RANK_TYPE.FIGHT_LEVEL_RANK then
fight:SetActive(true)
if nameText then
nameText:GetComponent("Text").text = data.userName
end
Util.GetGameObject(go,"fight"):GetComponent("Text").text = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.MainLevelConfig,data.rankInfo.param1).Name)
elseif rankType == RANK_TYPE.FORCE_CURR_RANK or rankType == RANK_TYPE.JUMPSERVER_FORCE_CURR_RANK then
warPower:SetActive(true)
if nameText then
nameText:GetComponent("Text").text = data.userName
end
Util.GetGameObject(go,"warPower/Text"):GetComponent("Text").text = data.rankInfo.param1--data.force
elseif rankType == RANK_TYPE.GUILD_FORCE_RANK or rankType == RANK_TYPE.JUMPSERVER_GUILD_FORCE_RANK then
warPower:SetActive(true)
if nameText then
nameText:GetComponent("Text").text = data.guildName
end
Util.GetGameObject(go,"warPower/Text"):GetComponent("Text").text = data.rankInfo.param1
elseif rankType == RANK_TYPE.MONSTER_RANK or rankType == RANK_TYPE.JUMPSERVER_MONSTER_RANK then
trial:SetActive(true)
if nameText then
nameText:GetComponent("Text").text = data.userName
end
Util.GetGameObject(go,"trial"):GetComponent("Text").text = GetLanguageStrById(Language[11689])..data.rankInfo.param1
elseif rankType == RANK_TYPE.FIGHTLEVEL_STAR or rankType == RANK_TYPE.JUMPSERVER_FIGHTLEVEL_STAR then--山河社稷图星星
FightLeveStar:SetActive(true)
if nameText then
nameText:GetComponent("Text").text = ""..data.userName..""
end
Util.GetGameObject(FightLeveStar,"Text"):GetComponent("Text").text = data.rankInfo.param1
end
end
return RankingListMainPanel