101 lines
2.5 KiB
Lua
101 lines
2.5 KiB
Lua
local UIWidgetBase = require_ex('Common/Core/UIWidgetBase')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MainHudExpandNode = HL.Class('MainHudExpandNode', UIWidgetBase)
|
|
|
|
|
|
|
|
MainHudExpandNode.m_isExpanded = HL.Field(HL.Boolean) << false
|
|
|
|
|
|
MainHudExpandNode.m_autoTimerId = HL.Field(HL.Number) << -1
|
|
|
|
|
|
MainHudExpandNode.m_belongNode = HL.Field(HL.Table)
|
|
|
|
|
|
|
|
|
|
|
|
MainHudExpandNode.InitMainHudExpandNode = HL.Method(HL.Table) << function(self, belongNode)
|
|
if self.m_belongNode then
|
|
logger.error("已经初始化了", self.view.transform:PathFromRoot())
|
|
return
|
|
end
|
|
|
|
self.m_belongNode = belongNode
|
|
self.gameObject:SetActive(true)
|
|
self:SetExpanded(false, true)
|
|
end
|
|
|
|
|
|
|
|
MainHudExpandNode.StartAutoCloseTimer = HL.Method() << function(self)
|
|
self:ClearAutoCloseTimer()
|
|
self.m_autoTimerId = self:_StartTimer(self.view.config.EXPAND_TIME, function()
|
|
self:SetExpanded(false)
|
|
end)
|
|
end
|
|
|
|
|
|
|
|
MainHudExpandNode.ClearAutoCloseTimer = HL.Method() << function(self)
|
|
self.m_autoTimerId = self:_ClearTimer(self.m_autoTimerId)
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
MainHudExpandNode.SetExpanded = HL.Method(HL.Boolean, HL.Opt(HL.Boolean)) << function(self, expand, skipAnimation)
|
|
local node = self.m_belongNode
|
|
local hasContent = node.m_curInsideBtnCount and node.m_curInsideBtnCount > 0
|
|
if expand and not hasContent then
|
|
|
|
return
|
|
end
|
|
self.m_isExpanded = expand
|
|
self.m_autoTimerId = self:_ClearTimer(self.m_autoTimerId)
|
|
if DeviceInfo.usingController then
|
|
self:_OnAnimationFinished()
|
|
return
|
|
end
|
|
if skipAnimation or not hasContent then
|
|
self:_OnAnimationFinished()
|
|
else
|
|
self.transform.localScale = Vector3.one
|
|
self.view.closeExpandBtn.gameObject:SetActive(true)
|
|
node.expandBtn.gameObject:SetActive(false)
|
|
if expand then
|
|
self.view.animationWrapper:PlayInAnimation(function()
|
|
self:_OnAnimationFinished()
|
|
end)
|
|
else
|
|
self.view.animationWrapper:PlayOutAnimation(function()
|
|
self:_OnAnimationFinished()
|
|
end)
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
MainHudExpandNode._OnAnimationFinished = HL.Method() << function(self)
|
|
local node = self.m_belongNode
|
|
self.transform.localScale = self.m_isExpanded and Vector3.one or Vector3.zero
|
|
self.view.closeExpandBtn.gameObject:SetActive(self.m_isExpanded)
|
|
node.expandBtn.gameObject:SetActive(not self.m_isExpanded and node.m_curInsideBtnCount and node.m_curInsideBtnCount > 0 and (not DeviceInfo.usingController))
|
|
end
|
|
|
|
|
|
HL.Commit(MainHudExpandNode)
|
|
return MainHudExpandNode
|