Files
SL1900 5e0d58cfad 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
2025-12-03 01:00:00 +09:00

66 lines
2.1 KiB
Lua

local LampNoticeCtrl = class("LampNoticeCtrl", BaseCtrl)
local maxWidth = 1000
local startSpace = 200
LampNoticeCtrl._mapNodeConfig = {
root = {sNodeName = "Root"},
animator = {sNodeName = "Root", sComponentName = "Animator"},
txt_Content = {sComponentName = "TMP_Text"},
content = {
sNodeName = "txt_Content",
sComponentName = "RectTransform"
},
mask = {
sComponentName = "LayoutElement"
},
MoveUpdate = {
sNodeName = "Root",
sComponentName = "LampNoticeScroll"
}
}
LampNoticeCtrl._mapEventConfig = {
ShowNoticeContent = "OnEvent_ShowContent",
CloseLampNotice = "OnEvent_HideContent"
}
LampNoticeCtrl._mapRedDotConfig = {}
function LampNoticeCtrl:Awake()
maxWidth = self._mapNode.mask.preferredWidth
self._mapNode.root:SetActive(false)
end
function LampNoticeCtrl:OnEvent_ShowContent(sContent, nShowTime)
self._mapNode.MoveUpdate:StopLampNoticeMove()
self._mapNode.root:SetActive(true)
self._mapNode.animator:Play("LampNotice_in")
self._mapNode.content.gameObject:SetActive(false)
NovaAPI.SetTMPText(self._mapNode.txt_Content, sContent)
local cb = function()
self._mapNode.animator:Play("LampNotice_out")
local close = function()
self._mapNode.root:SetActive(false)
self._mapNode.MoveUpdate:StopLampNoticeMove()
end
self:AddTimer(1, 0.2, close, true, true, true, nil)
end
self._mapNode.content.gameObject:SetActive(true)
CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.content)
local width = self._mapNode.content.sizeDelta.x
if width > maxWidth then
local startPosX = width / 2 + maxWidth / 2 - startSpace
self._mapNode.content.anchoredPosition = Vector2(startPosX, 0)
local nSpeed = ConfigTable.GetConfigValue("LampNoticeScrollSpeed")
local endPosX = -startPosX
self._mapNode.MoveUpdate:SetLampNoticeMove(self._mapNode.content, nSpeed, endPosX, cb)
else
self._mapNode.content.anchoredPosition = Vector2(0, 0)
self.timer = self:AddTimer(1, nShowTime, cb, true, true, true, nil)
end
end
function LampNoticeCtrl:OnEvent_HideContent(bIsDelay)
if bIsDelay then
if self.timer ~= nil then
self.timer:_Stop()
end
self._mapNode.root:SetActive(false)
end
end
return LampNoticeCtrl