miduo_client/Assets/ManagedResources/~Lua/Modules/Main/RedpotDebugPanel.lua

180 lines
5.3 KiB
Lua

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