维护公告

This commit is contained in:
chenxi 2023-06-16 16:16:39 +08:00
parent 805b9bec93
commit a3f223ffe2
2 changed files with 30 additions and 5 deletions

View File

@ -30,6 +30,18 @@ function LoginManager:loginGame()
ModuleManager.MaincityManager:firstEnterMainCity() ModuleManager.MaincityManager:firstEnterMainCity()
end end
function LoginManager:updateServerTime(serverTime)
self.serverTime = (serverTime or 0) // 1000
self.differenceTime = -GFunc.getTickCount()
end
function LoginManager:getServerTime()
if not self.serverTime then
return os.time()
end
return self.serverTime + (self.differenceTime or 0) + GFunc.getTickCount()
end
function LoginManager:getClientInfo() function LoginManager:getClientInfo()
local clientInfo = {} local clientInfo = {}
local bundleId = Platform:getIdentifier() local bundleId = Platform:getIdentifier()
@ -279,7 +291,7 @@ end
function LoginManager:checkServerOpen() function LoginManager:checkServerOpen()
local serverOpenTime = tonumber(self.versionInfo.open_at or 0) local serverOpenTime = tonumber(self.versionInfo.open_at or 0)
local clientTime = Time:getServerTime()*1000 local clientTime = self:getServerTime()*1000
if clientTime < serverOpenTime then -- 未开服 if clientTime < serverOpenTime then -- 未开服
self:showMaintenanceNoticeUI(self.versionInfo.notice, serverOpenTime) self:showMaintenanceNoticeUI(self.versionInfo.notice, serverOpenTime)
return return
@ -353,7 +365,7 @@ function LoginManager:getServerList()
local serverTime = (jsonData.now or 0) local serverTime = (jsonData.now or 0)
if serverTime > 0 then if serverTime > 0 then
Time:updateServerTime(serverTime) ModuleManager.LoginManager:updateServerTime(serverTime)
end end
self.versionInfo = jsonData self.versionInfo = jsonData
self:checkServerOpen() self:checkServerOpen()

View File

@ -16,14 +16,27 @@ end
function MaintenanceNoticeUI:onLoadRootComplete() function MaintenanceNoticeUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
uiMap["maintenance_notice_ui.bg.title_bg.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.NOTICE_TITLE)) uiMap["maintenance_notice_ui.bg.title_bg.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.NOTICE_TITLE))
local contentTx = uiMap["maintenance_notice_ui.bg.img_2.scrollrect.viewport.content.content_tx"]
if self.content == nil or self.content == "" then if self.content == nil or self.content == "" then
uiMap["maintenance_notice_ui.bg.img_2.content_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.MAINTENANCE_NOTICE_DEFAULT)) contentTx:setText(I18N:getGlobalText(I18N.GlobalConst.MAINTENANCE_NOTICE_DEFAULT))
else else
uiMap["maintenance_notice_ui.bg.img_2.content_tx"]:setText(self.content) contentTx:setText(self.content)
end end
local scrollRectHeight = uiMap["maintenance_notice_ui.bg.img_2.scrollrect"]:getRectHeight()
local topOffset = -contentTx:fastGetAnchoredPositionY()
contentTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO):ForceMeshUpdate()
local height = contentTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).renderedHeight
if height > scrollRectHeight then
uiMap["maintenance_notice_ui.bg.img_2.scrollrect"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT).movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic
uiMap["maintenance_notice_ui.bg.img_2.scrollrect.viewport.content"]:setSizeDeltaY(height + topOffset*2)
else
uiMap["maintenance_notice_ui.bg.img_2.scrollrect"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_SCROLL_RECT).movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Clamped
uiMap["maintenance_notice_ui.bg.img_2.scrollrect.viewport.content"]:setSizeDeltaY(scrollRectHeight)
end
uiMap["maintenance_notice_ui.bg.img_2.scrollrect.viewport.content"]:setAnchoredPositionY(0)
uiMap["maintenance_notice_ui.bg.ok_btn"]:addClickListener(function() uiMap["maintenance_notice_ui.bg.ok_btn"]:addClickListener(function()
self:closeUI() self:closeUI()
local clientTime = Time:getServerTime()*1000 local clientTime = ModuleManager.LoginManager:getServerTime()*1000
if clientTime >= self.openTime then if clientTime >= self.openTime then
ModuleManager.LoginManager:resetServerListStartTime() ModuleManager.LoginManager:resetServerListStartTime()
ModuleManager.LoginManager:getServerList() ModuleManager.LoginManager:getServerList()