Initial version - 1.2.0.60
EN: 1.2.0.60 CN: 1.2.0.61 JP: 1.2.0.63 KR: 1.2.0.67
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
local RedDotDefine = {
|
||||
Root = "Root",
|
||||
Mail = "Mail",
|
||||
Mail_UnRead = "Mail.UnRead",
|
||||
Mail_UnReceive = "Mail.UnReceive",
|
||||
Mail_New = "Mail.New",
|
||||
Task = "Task",
|
||||
Task_Daily = "Task.Daily",
|
||||
Task_Guide = "Task.Guide",
|
||||
Task_Tutorial = "Task.Tutorial",
|
||||
WorldClass = "Task.WorldClass",
|
||||
WorldClass_LevelUp = "Task.WorldClass.LevelUp.<param>",
|
||||
WorldClass_Advance = "Task.WorldClass.Advance.<param>",
|
||||
Role = "Role",
|
||||
Role_Item = "Role.Item.<param>",
|
||||
Role_Upgrade = "Role.Item.<param>.Upgrade",
|
||||
Role_AdvanceReward = "Role.Item.<param>.Upgrade.AdvanceReward.<param>",
|
||||
Role_Talent = "Role.Item.<param>.Talent",
|
||||
Role_Relation = "Role.Item.<param>.Relation",
|
||||
Role_AffinityTask = "Role.Item.<param>.Relation.AffinityTask",
|
||||
Role_AffinityPlot = "Role.Item.<param>.Relation.Plot",
|
||||
Role_AffinityPlotItem = "Role.Item.<param>.Relation.Plot.<param>",
|
||||
Role_RecordReward = "Role.Item.<param>.Relation.Record",
|
||||
Role_RecordRewardItem = "Role.Item.<param>.Relation.Record.<param>",
|
||||
Role_Record_Info = "RecordInfo.<param>",
|
||||
Role_Record_Info_Item = "RecordInfo.<param>.Info.<param>",
|
||||
Role_Record_InfoUpdate_Item = "RecordInfo.<param>.Update.<param>",
|
||||
Role_Record_BaseInfoUpdate_Item = "RecordInfo.<param>.BaseInfo_Update",
|
||||
Role_Record_Voice = "RecordVoice.<param>",
|
||||
Role_Record_Voice_Item = "RecordVoice.<param>.<param>",
|
||||
Map = "Map",
|
||||
Map_MainLine = "MainLine",
|
||||
Map_MainLine_Entrance = "MainLine.Entrance",
|
||||
Map_MainLine_Chapter = "MainLine.Entrance.Chapter.<param>",
|
||||
Map_MainLine_Reward = "MainLine.Entrance.Reward.<param>",
|
||||
MainStoryClue = "Clue",
|
||||
MianStoryClue_Use = "Clue.Use.<param>",
|
||||
Story_Set = "MainLine.StorySet",
|
||||
Story_Set_Server = "MainLine.StorySet.Server",
|
||||
Story_Set_Chapter = "MainLine.StorySet.<param>",
|
||||
Story_Set_Section = "MainLine.StorySet.<param>.<param>",
|
||||
Map_TravelerDuel = "TravelerDuel",
|
||||
Task_Season = "TravelerDuel.Season.Task",
|
||||
Task_Duel = "TravelerDuel.Duel.Task",
|
||||
Map_Infinity = "Map.Infinity",
|
||||
Map_InfinityTowerDaily = "Map.Infinity.Daily",
|
||||
Map_InfinityTowerPlot = "Map.Infinity.Plot",
|
||||
Map_Resource = "Map.Resource",
|
||||
Map_RogueBoss = "Map.Resource.RogueBoss",
|
||||
Mall = "Mall",
|
||||
Mall_Free = "Mall.Free",
|
||||
FreePackage = "FreePackage.<param>",
|
||||
Friend = "Friend",
|
||||
Friend_Apply = "Friend.Apply",
|
||||
Friend_Energy = "Friend.Energy",
|
||||
Friend_Info = "Friend.Info",
|
||||
Friend_Info_Title = "Friend.Info.Title",
|
||||
Friend_Title_Item = "Friend.Info.Title.<param>",
|
||||
Friend_Info_Head = "Friend.Info.Head",
|
||||
Friend_Head_Item = "Friend.Info.Head.<param>",
|
||||
Friend_Honor_Title = "Friend.Info.HonorTitle",
|
||||
Friend_Honor_Title_Item = "Friend.Info.HonorTitle.<param>",
|
||||
Dictionary = "Menu.Dictionary",
|
||||
Dictionary_Main = "Menu.Dictionary.Main.<param>",
|
||||
Dictionary_Sub = "Menu.Dictionary.Main.<param>.Sub.<param>",
|
||||
Activity = "Activity",
|
||||
Activity_Tab = "Activity.Tab.<param>",
|
||||
Activity_Periodic_Quest_Group = "Activity.<param>.Periodic.<param>",
|
||||
Activity_Periodic_Final_Reward = "Activity.<param>.Final",
|
||||
Activity_Mining_Quest_Group = "Activity.MiningQuestGroup",
|
||||
Activity_Mining_Quest = "Activity.MiningQuestGroup.<param>",
|
||||
Activity_TowerDefense_LevelTab = "Activity.TowerDefense.Level.<param>",
|
||||
Activity_TowerDefense_Level = "Activity.TowerDefense.Level.<param>.<param>",
|
||||
Activity_TowerDefense_AllStory = "Activity.TowerDefense.Story",
|
||||
Activity_TowerDefense_Story = "Activity.TowerDefense.Story.<param>",
|
||||
Activity_TowerDefense_AllQuest = "Activity.TowerDefense.Quest",
|
||||
Activity_TowerDefense_QuestGroup = "Activity.TowerDefense.Quest.<param>",
|
||||
Activity_TowerDefense_Quest = "Activity.TowerDefense.Quest.<param>.<param>",
|
||||
Activity_Group = "Activity.Group.<param>",
|
||||
Activity_Group_Task = "Activity.Group.<param>.Task.<param>",
|
||||
Activity_Group_Task_Group = "Activity.Group.<param>.Task.<param>.<param>",
|
||||
Activity_GroupNew_Avg = "<param>.Activity_Group_Avg.<param>",
|
||||
Activity_GroupNew_Avg_Group = "<param>.Activity_Group_Avg.<param>.<param>",
|
||||
ActivityLevel = "Activity_Group_New.<param>.ActivityLevel",
|
||||
ActivityLevel_Explore = "Activity_Group_New.<param>.ActivityLevel.Explore",
|
||||
ActivityLevel_Explore_Level = "Activity_Group_New.<param>.ActivityLevel.Explore.<param>",
|
||||
ActivityLevel_Adventure = "Activity_Group_New.<param>.ActivityLevel.Adventure",
|
||||
ActivityLevel_Adventure_Level = "Activity_Group_New.<param>.ActivityLevel.Adventure.<param>",
|
||||
Activity_BdConvert_AllQuest = "Activity.BdConvert.Quest",
|
||||
Activity_BdConvert_Quest = "Activity.BdConvert.Quest.<param>",
|
||||
Activity_New = "Activity_New",
|
||||
Activity_New_Tab = "Activity_New_Tab.<param>",
|
||||
Activity_GroupNew = "Activity_Group_New.<param>",
|
||||
Phone = "Phone",
|
||||
Phone_Chat = "Phone.Chat",
|
||||
Phone_New = "Phone.Chat.New",
|
||||
Phone_UnComplete = "Phone_UnComplete",
|
||||
Phone_New_Item = "Phone.Chat.New.<param>",
|
||||
Phone_UnComplete_Item = "Phone_UnComplete_Item.<param>",
|
||||
Phone_Dating = "Phone.Dating",
|
||||
Phone_Dating_Char = "Phone.Dating.Char.<param>",
|
||||
Phone_Dating_Reward = "Phone.Dating.Char.<param>.Reward.<param>",
|
||||
BattlePass = "BattlePass",
|
||||
BattlePass_Quest = "BattlePass.Quest",
|
||||
BattlePass_Quest_Server = "BattlePass.Quest.Server",
|
||||
BattlePass_Quest_Daily = "BattlePass.Quest.Daily",
|
||||
BattlePass_Quest_Week = "BattlePass.Quest.Week",
|
||||
BattlePass_Reward = "BattlePass.Reward",
|
||||
Menu = "Menu",
|
||||
Disc = "Disc",
|
||||
Disc_Item = "Disc.Item.<param>",
|
||||
Disc_BreakLimit = "Disc.Item.<param>.BreakLimit",
|
||||
Disc_BreakBtn = "Disc.Item.<param>.BreakLimit.BreakBtn",
|
||||
Disc_Music = "Disc.Item.<param>.Music",
|
||||
Disc_SideB = "Disc.Item.<param>.Music.SideB",
|
||||
Disc_SideB_Read = "Disc.Item.<param>.Music.SideB.Read",
|
||||
Disc_SideB_Avg = "Disc.Item.<param>.Music.SideB.Avg",
|
||||
Depot = "Depot",
|
||||
Shop = "Shop",
|
||||
Shop_Daily = "Shop.Daily",
|
||||
StarTowerBook = "StarTowerBook",
|
||||
StarTowerBook_Potential = "StarTowerBook.Potential",
|
||||
StarTowerBook_Potential_Element = "StarTowerBook.Potential.Element.<param>",
|
||||
StarTowerBook_Potential_Char = "StarTowerBook.Potential.Element.<param>.Char.<param>",
|
||||
StarTowerBook_Potential_Reward = "StarTowerBook.Potential.Element.<param>.Char.<param>.Reward",
|
||||
StarTowerBook_Potential_New = "PotentialNew.<param>",
|
||||
StarTowerBook_FateCard = "StarTowerBook.FateCard",
|
||||
StarTowerBook_FateCard_Bundle = "StarTowerBook.FateCard.<param>",
|
||||
StarTowerBook_FateCard_Bundle_Tog = "StarTowerBook.FateCard.<param>.Tog",
|
||||
StarTowerBook_FateCard_Reward = "StarTowerBook.FateCard.<param>.Tog.Reward",
|
||||
StarTowerBook_FateCard_New = "FateCardNew.<param>",
|
||||
StarTowerBook_Event = "StarTowerBook.Event",
|
||||
StarTowerBook_Event_Reward = "StarTowerBook.Event.<param>.Reward",
|
||||
StarTowerBook_Affinity = "StarTowerBook.Affinity",
|
||||
StarTowerBook_Affinity_Reward = "StarTowerBook.Affinity.<param>",
|
||||
Notice = "Notice",
|
||||
Dispatch = "Dispatch",
|
||||
Dispatch_Tab = "Dispatch.Tab.<param>",
|
||||
Dispatch_Reward = "Dispatch.Tab.<param>.Reward.<param>",
|
||||
StarTowerGrowth = "StarTowerGrowth",
|
||||
StarTowerQuest = "StarTowerQuest",
|
||||
Achievement = "Menu.Achievement",
|
||||
Achievement_Tab = "Menu.Achievement.Tab.<param>",
|
||||
Announcement = "Announcement",
|
||||
Announcement_Tab = "Announcement.Tab.<param>",
|
||||
Announcement_Content = "Announcement.Tab.<param>.Content.<param>",
|
||||
Map_ScoreBoss = "Map.ScoreBoss",
|
||||
Map_ScoreBossStar = "Map.ScoreBoss.Star",
|
||||
VampireQuest = "VampireQuest",
|
||||
VampireQuest_Normal = "VampireQuest.Normal",
|
||||
VampireQuest_Hard = "VampireQuest.Hard",
|
||||
VampireQuest_Season = "VampireQuest.Season",
|
||||
VampireTalent = "VampireTalent",
|
||||
JointDrillQuest = "JointDrillQuest"
|
||||
}
|
||||
return RedDotDefine
|
||||
@@ -0,0 +1,210 @@
|
||||
local RedDotManager = {}
|
||||
local RedDotNode = require("GameCore.RedDot.RedDotNode")
|
||||
local stringSplit = string.split
|
||||
local RapidJson = require("rapidjson")
|
||||
local mapKeyList = {}
|
||||
local rootNode, trUIRoot
|
||||
local DEBUG_OPEN = false
|
||||
function RedDotManager.Init()
|
||||
trUIRoot = GameObject.Find("---- UI ----").transform
|
||||
EventManager.Add("LuaEventName_UnRegisterRedDot", RedDotManager, RedDotManager.OnEvent_UnRegisterRedDot)
|
||||
end
|
||||
function RedDotManager.RegisterNode(sKey, param, objGo, nType, bManualRefresh, bRebind)
|
||||
local bCheck, sNodeKey = RedDotManager.GetNodeKey(sKey, param)
|
||||
if not bCheck then
|
||||
return
|
||||
end
|
||||
if objGo ~= nil then
|
||||
local tbParam = {}
|
||||
if param == nil then
|
||||
tbParam.sParam = "empty"
|
||||
elseif type(param) ~= "table" then
|
||||
tbParam.sParam = param
|
||||
else
|
||||
tbParam = param
|
||||
end
|
||||
local bindCS = function(obj)
|
||||
NovaAPI.UnRegisterRedDotNode(obj.gameObject)
|
||||
local trParent = obj.transform.parent
|
||||
obj.transform:SetParent(trUIRoot)
|
||||
obj.gameObject:SetActive(true)
|
||||
local paramJson = RapidJson.encode(tbParam)
|
||||
NovaAPI.AddRedDotNode(obj.gameObject, sKey, paramJson)
|
||||
obj.gameObject:SetActive(false)
|
||||
obj.transform:SetParent(trParent)
|
||||
end
|
||||
if type(objGo) == "table" then
|
||||
for _, v in ipairs(objGo) do
|
||||
bindCS(v.gameObject)
|
||||
end
|
||||
else
|
||||
bindCS(objGo.gameObject)
|
||||
end
|
||||
end
|
||||
local node = RedDotManager.GetNode(sNodeKey)
|
||||
if nil ~= node then
|
||||
if bRebind then
|
||||
node:UnRegisterNode()
|
||||
end
|
||||
node:RegisterNode(objGo, nType, bManualRefresh)
|
||||
end
|
||||
end
|
||||
function RedDotManager.UnRegisterNode(sKey, param, objGo)
|
||||
local bCheck, sNodeKey = RedDotManager.GetNodeKey(sKey, param)
|
||||
if not bCheck then
|
||||
return
|
||||
end
|
||||
if RedDotManager.CheckNodeExist(sNodeKey) then
|
||||
local node = RedDotManager.GetNode(sNodeKey)
|
||||
if nil ~= node then
|
||||
node:UnRegisterNode(objGo)
|
||||
end
|
||||
end
|
||||
end
|
||||
function RedDotManager.OnEvent_UnRegisterRedDot(_, sKey, paramJson, objGo)
|
||||
local tbParam = decodeJson(paramJson)
|
||||
local param
|
||||
if tbParam.sParam == nil then
|
||||
param = tbParam
|
||||
elseif tbParam.sParam == "empty" then
|
||||
param = nil
|
||||
elseif tbParam.sParam ~= nil then
|
||||
param = tbParam.sParam
|
||||
end
|
||||
local bCheck, sNodeKey = RedDotManager.GetNodeKey(sKey, param)
|
||||
if not bCheck then
|
||||
return
|
||||
end
|
||||
if RedDotManager.CheckNodeExist(sNodeKey) then
|
||||
local node = RedDotManager.GetNode(sNodeKey)
|
||||
if nil ~= node then
|
||||
node:UnRegisterNode(objGo)
|
||||
end
|
||||
end
|
||||
end
|
||||
function RedDotManager.SetValid(sKey, param, bValid)
|
||||
local bCheck, sNodeKey = RedDotManager.GetNodeKey(sKey, param)
|
||||
if not bCheck then
|
||||
return
|
||||
end
|
||||
local node = RedDotManager.GetNode(sNodeKey)
|
||||
if nil ~= node then
|
||||
if not node:CheckLeafNode() then
|
||||
return
|
||||
end
|
||||
node:SetValid(bValid)
|
||||
end
|
||||
end
|
||||
function RedDotManager.SetCount(sKey, param, nCount)
|
||||
local bCheck, sNodeKey = RedDotManager.GetNodeKey(sKey, param)
|
||||
if not bCheck then
|
||||
return
|
||||
end
|
||||
local node = RedDotManager.GetNode(sNodeKey)
|
||||
if nil ~= node then
|
||||
if not node:CheckLeafNode() then
|
||||
return
|
||||
end
|
||||
node:SetCount(nCount)
|
||||
end
|
||||
end
|
||||
function RedDotManager.GetValid(sKey, param)
|
||||
local bCheck, sNodeKey = RedDotManager.GetNodeKey(sKey, param)
|
||||
if not bCheck then
|
||||
return
|
||||
end
|
||||
local node = RedDotManager.GetNode(sNodeKey)
|
||||
if nil ~= node then
|
||||
return node:GetValid()
|
||||
end
|
||||
return false
|
||||
end
|
||||
function RedDotManager.RefreshRedDotShow(sKey, param)
|
||||
local bCheck, sNodeKey = RedDotManager.GetNodeKey(sKey, param)
|
||||
if not bCheck then
|
||||
return
|
||||
end
|
||||
if RedDotManager.CheckNodeExist(sNodeKey) then
|
||||
local node = RedDotManager.GetNode(sNodeKey)
|
||||
if nil ~= node then
|
||||
node:RefreshRedDotShow()
|
||||
end
|
||||
end
|
||||
end
|
||||
function RedDotManager.PrintRedDot(sKey, param, bParent, bLeaf)
|
||||
if not DEBUG_OPEN then
|
||||
return
|
||||
end
|
||||
local bCheck, sNodeKey = RedDotManager.GetNodeKey(sKey, param)
|
||||
if not bCheck then
|
||||
return
|
||||
end
|
||||
local node = RedDotManager.GetNode(sNodeKey)
|
||||
if nil ~= node then
|
||||
node:PrintRedDot(bParent, bLeaf)
|
||||
end
|
||||
end
|
||||
function RedDotManager.GetNodeKey(sKey, param)
|
||||
local sNodeKey = ""
|
||||
local bCheck = true
|
||||
if nil == sKey then
|
||||
bCheck = false
|
||||
traceback(string.format("红点注册传入参数错误,请检查!!!, key = %s, param = %s", sKey, param))
|
||||
else
|
||||
if nil == param then
|
||||
sNodeKey = sKey
|
||||
elseif type(param) ~= "table" then
|
||||
sNodeKey = string.gsub(sKey, "<param>", param, 1)
|
||||
else
|
||||
sNodeKey = sKey
|
||||
for _, v in ipairs(param) do
|
||||
sNodeKey = string.gsub(sNodeKey, "<param>", v, 1)
|
||||
end
|
||||
end
|
||||
sNodeKey = string.gsub(sNodeKey, "<param>", "")
|
||||
local tbSplit = stringSplit(sNodeKey, ".") or {}
|
||||
sNodeKey = ""
|
||||
local index = 1
|
||||
for _, v in ipairs(tbSplit) do
|
||||
if nil ~= v and "" ~= v then
|
||||
if index == 1 then
|
||||
sNodeKey = v
|
||||
else
|
||||
sNodeKey = sNodeKey .. "." .. v
|
||||
end
|
||||
index = index + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
return bCheck, sNodeKey
|
||||
end
|
||||
function RedDotManager.GetNode(sNodeKey)
|
||||
if nil == rootNode then
|
||||
rootNode = RedDotNode.new(RedDotDefine.Root)
|
||||
end
|
||||
local curNode = rootNode
|
||||
local tbKeyList = RedDotManager.ParseKey(sNodeKey)
|
||||
for _, key in ipairs(tbKeyList) do
|
||||
local node = curNode:GetChildNode(key)
|
||||
if nil == node then
|
||||
node = curNode:AddChildNode(key)
|
||||
end
|
||||
curNode = node
|
||||
end
|
||||
return curNode
|
||||
end
|
||||
function RedDotManager.CheckNodeExist(sNodeKey)
|
||||
return nil ~= RedDotManager.GetKeyList(sNodeKey)
|
||||
end
|
||||
function RedDotManager.GetKeyList(sNodeKey)
|
||||
return mapKeyList[sNodeKey]
|
||||
end
|
||||
function RedDotManager.ParseKey(sNodeKey)
|
||||
local tbKeyList = RedDotManager.GetKeyList(sNodeKey)
|
||||
if nil == tbKeyList then
|
||||
tbKeyList = stringSplit(sNodeKey, ".") or {}
|
||||
end
|
||||
mapKeyList[sNodeKey] = tbKeyList
|
||||
return tbKeyList
|
||||
end
|
||||
return RedDotManager
|
||||
@@ -0,0 +1,172 @@
|
||||
local RedDotNode = class("RedDotNode")
|
||||
local RedDotType = AllEnum.RedDotType
|
||||
function RedDotNode:ctor(sKey, parent)
|
||||
self.bManualRefresh = nil
|
||||
self.sNodeKey = sKey
|
||||
self.parentNode = parent
|
||||
self.tbChildNodeList = nil
|
||||
self.nRedDotCount = 0
|
||||
self.tbObjNode = nil
|
||||
self.tbTxtRedDotCount = nil
|
||||
self.nShowType = nil
|
||||
end
|
||||
function RedDotNode:RegisterNode(objGo, nType, bManualRefresh)
|
||||
if nil == objGo then
|
||||
traceback(string.format("注册红点失败!!!传入的gameObject为空. nodeKey = %s", self.sNodeKey))
|
||||
return
|
||||
end
|
||||
if nil == nType then
|
||||
nType = RedDotType.Single
|
||||
end
|
||||
self.nShowType = nType
|
||||
self.bManualRefresh = bManualRefresh
|
||||
if self.tbObjNode == nil then
|
||||
self.tbObjNode = {}
|
||||
end
|
||||
if type(objGo) == "table" then
|
||||
for _, v in ipairs(objGo) do
|
||||
local nInstanceId = v.gameObject:GetInstanceID()
|
||||
self.tbObjNode[nInstanceId] = v.gameObject
|
||||
end
|
||||
else
|
||||
local nInstanceId = objGo.gameObject:GetInstanceID()
|
||||
self.tbObjNode[nInstanceId] = objGo.gameObject
|
||||
end
|
||||
self.tbTxtRedDotCount = {}
|
||||
for _, v in pairs(self.tbObjNode) do
|
||||
if v:IsNull() ~= true then
|
||||
local trObj = v.gameObject:GetComponent("Transform")
|
||||
local trNode = trObj:Find("---RedDot---")
|
||||
if nil == trNode then
|
||||
printError("红点UI结构不标准!!!请检查")
|
||||
return
|
||||
end
|
||||
if nType == RedDotType.Number then
|
||||
local trText = trNode:Find("txtRedDot")
|
||||
if nil ~= trText then
|
||||
local nInstanceId = trText:GetInstanceID()
|
||||
self.tbTxtRedDotCount[nInstanceId] = trText:GetComponent("TMP_Text")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
self:RefreshRedDotShow()
|
||||
end
|
||||
function RedDotNode:UnRegisterNode(objGo)
|
||||
if nil == objGo then
|
||||
self.tbObjNode = nil
|
||||
self.tbTxtRedDotCount = nil
|
||||
else
|
||||
if self.tbObjNode == nil then
|
||||
return
|
||||
end
|
||||
if type(objGo) == "table" then
|
||||
for _, v in ipairs(objGo) do
|
||||
local nInstanceId = v:GetInstanceID()
|
||||
self.tbObjNode[nInstanceId] = nil
|
||||
end
|
||||
else
|
||||
local nInstanceId = objGo:GetInstanceID()
|
||||
self.tbObjNode[nInstanceId] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
function RedDotNode:AddChildNode(sKey)
|
||||
if nil == self.tbChildNodeList then
|
||||
self.tbChildNodeList = {}
|
||||
end
|
||||
local node = RedDotNode.new(sKey, self)
|
||||
table.insert(self.tbChildNodeList, node)
|
||||
return node
|
||||
end
|
||||
function RedDotNode:GetChildNode(sKey)
|
||||
if nil ~= self.tbChildNodeList then
|
||||
for _, node in ipairs(self.tbChildNodeList) do
|
||||
if node:GetNodeKey() == sKey then
|
||||
return node
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function RedDotNode:SetValid(bValid)
|
||||
if self:GetValid() == bValid and (nil == self.tbChildNodeList or #self.tbChildNodeList <= 0) then
|
||||
return
|
||||
end
|
||||
if bValid then
|
||||
self.nRedDotCount = self.nRedDotCount + 1
|
||||
else
|
||||
self.nRedDotCount = self.nRedDotCount - 1
|
||||
end
|
||||
if not self.bManualRefresh then
|
||||
self:RefreshRedDotShow()
|
||||
end
|
||||
if nil ~= self.parentNode then
|
||||
self.parentNode:SetValid(bValid)
|
||||
end
|
||||
end
|
||||
function RedDotNode:SetCount(nCount)
|
||||
if self:GetCount() == nCount and (nil == self.tbChildNodeList or #self.tbChildNodeList <= 0) then
|
||||
return
|
||||
end
|
||||
self.nRedDotCount = nCount
|
||||
self:RefreshRedDotShow()
|
||||
if nil ~= self.parentNode then
|
||||
self.parentNode:SetCount(nCount)
|
||||
end
|
||||
end
|
||||
function RedDotNode:RefreshRedDotShow()
|
||||
if nil == self.tbObjNode or nil == next(self.tbObjNode) then
|
||||
return
|
||||
end
|
||||
for _, v in pairs(self.tbObjNode) do
|
||||
if v:IsNull() == true then
|
||||
traceback("疑似上一次注册的红点未注销!!!请检查 nodeKey = " .. self.sNodeKey)
|
||||
else
|
||||
v.gameObject:SetActive(self:GetValid())
|
||||
end
|
||||
end
|
||||
if self.nShowType == RedDotType.Number then
|
||||
for _, v in pairs(self.tbTxtRedDotCount) do
|
||||
NovaAPI.SetTMPText(v, self:GetCount())
|
||||
end
|
||||
end
|
||||
end
|
||||
function RedDotNode:GetNodeKey()
|
||||
return self.sNodeKey
|
||||
end
|
||||
function RedDotNode:GetValid()
|
||||
return self.nRedDotCount > 0
|
||||
end
|
||||
function RedDotNode:GetCount()
|
||||
return self.nRedDotCount
|
||||
end
|
||||
function RedDotNode:CheckLeafNode()
|
||||
return nil == self.tbChildNodeList or #self.tbChildNodeList == 0
|
||||
end
|
||||
function RedDotNode:PrintRedDot(bParent, bLeaf)
|
||||
if self.sNodeKey == "Root" then
|
||||
return
|
||||
end
|
||||
local sObj = ""
|
||||
local nCount = 0
|
||||
if self.tbObjNode ~= nil then
|
||||
for nInsId, v in pairs(self.tbObjNode) do
|
||||
nCount = nCount + 1
|
||||
sObj = sObj .. string.format("%s | %s", nInsId, v.gameObject:GetInstanceID())
|
||||
sObj = sObj .. "\n"
|
||||
end
|
||||
local sLog = string.format("<color=red>[RedDot]</color> 节点key %s|红点state %s|绑定gameObject数量 %s\n", self.sNodeKey, self.nRedDotCount, nCount)
|
||||
sLog = sLog .. sObj
|
||||
traceback(sLog)
|
||||
end
|
||||
if bParent then
|
||||
if nil ~= self.parentNode then
|
||||
self.parentNode:PrintRedDot(true)
|
||||
end
|
||||
elseif bLeaf and nil ~= self.tbChildNodeList then
|
||||
for _, v in ipairs(self.tbChildNodeList) do
|
||||
v:PrintRedDot(nil, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
return RedDotNode
|
||||
Reference in New Issue
Block a user