【GM】添加红点数据查看工具

dev_chengFeng
gaoxin 2021-04-09 16:14:24 +08:00
parent 3418b63e02
commit 196dfa34dd
8 changed files with 1560 additions and 5 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0581b94302b81b24fb80d75e1fb969ca
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -374,7 +374,9 @@ UIName = {
FuXingGaoZhaoPanel = 383,--福星高照
TianShuMiJuan = 381,--天枢密卷弹窗
ActivityMainPanel = 384, --活动新界面
FifteenDayGiftPanel = 385,--十五日登录
FifteenDayGiftPanel = 385,--十五日登录
RedpotDebugPanel = 386, -- 红点debug
}
SubUIConfig = {

View File

@ -91,6 +91,7 @@ function GMPanel:InitComponent()
{type = GMType.Function, subType = GMSubType.Server, inputNum = 1, args = "23#0#%s", btnTip = Language[11176], inputTip = {Language[11196]}, callBack = nil},
{type = GMType.Function, subType = GMSubType.Server, inputNum = 1, args = "24#%s", btnTip = Language[11197], inputTip = {Language[11198]}, callBack = nil},
{type = GMType.Function, subType = GMSubType.Func, inputNum = 1, args = "", btnTip = Language[12175], inputTip = {Language[12176]}, callBack = this.TestFuncGuide},
{type = GMType.Function, subType = GMSubType.Func, inputNum = 0, args = "", btnTip = "红点Debug", inputTip = {""}, callBack = this.OpenRedDebug},
{type = GMType.Battle, subType = GMSubType.Func, inputNum = 0, args = "", btnTip = Language[11199], inputTip = {""}, callBack = this.GoTestBattle},
@ -322,6 +323,10 @@ function this.TestFuncGuide(text)
local gid = tonumber(text)
GuideManager.AddFuncGuide(gid)
end
-- 红点Debug
function this.OpenRedDebug()
UIManager.OpenPanel(UIName.RedpotDebugPanel)
end
-- 添加圣物
function this.AddHoly(text)
local command = "//addholy %s %s"

View File

@ -0,0 +1,180 @@
require("Base/BasePanel")
local RedpotDebugPanel = Inherit(BasePanel)
local RPData = require("Modules/Player/RedPointData")
--初始化组件(用于子类重写)
function RedpotDebugPanel:InitComponent()
self.btnClose = Util.GetGameObject(self.gameObject, "btnClose")
self.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
self.p_red = Util.GetGameObject(self.gameObject, "p_red")
self.p_id = Util.GetGameObject(self.gameObject, "p_id"):GetComponent("Text")
self.cRoot = Util.GetGameObject(self.gameObject, "rect")
self.cNode = Util.GetGameObject(self.gameObject, "node")
local rootHight = self.cRoot.transform.rect.height
local width = self.cRoot.transform.rect.width
if not self.ScrollView then
self.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.cRoot.transform,
self.cNode, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 35))
self.scrollView.moveTween.MomentumAmount = 1
self.scrollView.moveTween.Strength = 2
end
self.result = Util.GetGameObject(self.gameObject, "result"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function RedpotDebugPanel:BindEvent()
Util.AddOnceClick(self.btnClose, function()
self:ClosePanel()
end)
Util.AddOnceClick(self.btnBack, function()
if not self.CurPRed then
return
end
self.CurPRed = RPData:GetRedParent(self.CurPRed)
self:RefreshShow()
end)
end
--添加事件监听(用于子类重写)
function RedpotDebugPanel:AddListener()
end
--移除事件监听(用于子类重写)
function RedpotDebugPanel:RemoveListener()
end
function RedpotDebugPanel:OnSortingOrderChange()
end
--界面打开时调用(用于子类重写)
function RedpotDebugPanel:OnOpen(...)
self.CurPRed = nil
self:RefreshShow()
end
-- 打开,重新打开时回调
function RedpotDebugPanel:OnShow()
end
function RedpotDebugPanel:RefreshShow()
local list = self:GetCurRedList()
self.scrollView:SetData(list, function(index, node)
self:RedNodeAdapter(node, list[index])
end)
if self.CurPRed then
self.p_id.gameObject:SetActive(true)
self.p_red.gameObject:SetActive(true)
self.btnBack.gameObject:SetActive(true)
self.p_id.text = self.CurPRed
Util.SetGray(self.p_red, RPData:GetRedValue(self.CurPRed) <= 0)
else
self.p_id.gameObject:SetActive(false)
self.p_red.gameObject:SetActive(false)
self.btnBack.gameObject:SetActive(false)
end
end
-- 获取当前要显示的红点的list
function RedpotDebugPanel:GetCurRedList()
local list = {}
if self.CurPRed then
list = RPData:GetRedChildren(self.CurPRed)
else
local _data = RPData:GetAllRedData()
for node, value in pairs(_data) do
if not RPData:GetRedParent(node) then
table.insert(list, node)
end
end
table.sort(list, function(a, b)
return a < b
end)
end
return list
end
--
function RedpotDebugPanel:RedNodeAdapter(node, rp)
local red = Util.GetGameObject(node, "red")
local id = Util.GetGameObject(node, "id"):GetComponent("Text")
local btnChild = Util.GetGameObject(node, "child")
local btnCheck = Util.GetGameObject(node, "check")
id.text = rp
Util.SetGray(red, RPData:GetRedValue(rp) <= 0)
Util.AddOnceClick(btnChild, function()
local list = RPData:GetRedChildren(rp)
if #list <= 0 then
self.result.text = "no child red"
return
end
-- 设置红点显示
self.CurPRed = rp
self:RefreshShow()
end)
Util.AddOnceClick(btnCheck, function()
local list = RPData:GetRedChildren(rp)
if #list > 0 then
self.result.text = "parent, no check!"
return
end
local _checkFunc = RPData:GetCheckList()
local tip = ""
local value = nil
-- 判断是否解锁
if _checkFunc[rp] and _checkFunc[rp].openType then
local isOpen = ActTimeCtrlManager.SingleFuncState(_checkFunc[rp].openType)
if not isOpen then
value = 0
end
tip = tip .."funcType = ".._checkFunc[rp].openType.. ", isOpen = "..tostring(isOpen)
else
tip = tip .."no funcType"
end
tip = tip .." "
if not value then
-- 判断是否是服务器红点
if RPData:GetServerRed(rp) then
value = RPData:GetServerRed(rp)
tip = tip .."server red, value = "..tostring(value).."\t"
-- 判断是否注册了检测方法
elseif _checkFunc[rp] and _checkFunc[rp].func then
value = _checkFunc[rp].func(rp) and 1 or 0
tip = tip .."normal red, value = "..tostring(value).."\t"
end
end
tip = tip .." "
-- 数据正确性检测
if not value then
tip = tip .."error red type = node"
end
self.result.text = tip
end)
end
--界面关闭时调用(用于子类重写)
function RedpotDebugPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function RedpotDebugPanel:OnDestroy()
end
return RedpotDebugPanel

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0e23d81f42845b44fb9567c009587990
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -54,12 +54,12 @@ local RedPointData = {}
function RedPointData:SetParent(child, parent)
-- 不能相反
if _parentIndex[parent] == child then
Log("试图将一个红点的父红点注册为其子红点, parent == ".. parent.. ", child == ".. child)
LogError("试图将一个红点的父红点注册为其子红点, parent == ".. parent.. ", child == ".. child)
return
end
-- 一个子节点只能有一个父节点
if _parentIndex[child] then
Log("红点id == " .. child.. ",重复设置了父级,请检查")
LogError("红点id == " .. child.. ",重复设置了父级,请检查")
return
end
-- 设置子节点对应的父节点
@ -78,6 +78,19 @@ end
function RedPointData:GetRedParent(node)
return _parentIndex[node]
end
function RedPointData:GetRedChildren(node)
local list = {}
for c, p in pairs(_parentIndex) do
if p == node then
table.insert(list, c)
end
end
-- 排序
table.sort(list, function(a, b)
return _childIndex[a] < _childIndex[b]
end)
return list
end
-- 对叶子节点设置红点状态
@ -96,6 +109,11 @@ function RedPointData:GetRedValue(node)
return _data[node]
end
-- 获取所有红点数据
function RedPointData:GetAllRedData()
return _data
end
-- 注册红点检测方法
function RedPointData:AddCheckFunc(node, func, openType)
if _childNum[node] and _childNum[node] > 0 then

View File

@ -158,8 +158,8 @@ function this.InitRedPointAllRelate()
RPData:SetParent(RedPointType.DailyTask, RedPointType.DailyTaskMain)
RPData:SetParent(RedPointType.QinglongSerectTreasure, RedPointType.DailyTaskMain)
RPData:SetParent(RedPointType.QinglongSerectTreasureTrail, RedPointType.DailyTaskMain)
RPData:SetParent(RedPointType.QinglongSerectTreasure, RedPointType.TreasureOfSl)
RPData:SetParent(RedPointType.QinglongSerectTreasureTrail, RedPointType.TreasureOfSl)
-- RPData:SetParent(RedPointType.QinglongSerectTreasure, RedPointType.TreasureOfSl)
-- RPData:SetParent(RedPointType.QinglongSerectTreasureTrail, RedPointType.TreasureOfSl)
RPData:SetParent(RedPointType.SecretTer_MaxBoxReward, RedPointType.SecretTer)
RPData:SetParent(RedPointType.SecretTer_HaveFreeTime, RedPointType.SecretTer)
RPData:SetParent(RedPointType.SecretTer_IsCanFight, RedPointType.SecretTer)