Update AA synchronization, CW progression and diagnostics
This commit is contained in:
1 parent
67a819a4d3
commit
30bee81fe9
30 files changed
+1143
-55
No files matched your search
+61
-6
@@ -6,6 +6,22 @@ local GameObject = CS.UnityEngine.GameObject
|
||||
local CanvasGroup = CS.UnityEngine.CanvasGroup
|
||||
local Camera = CS.UnityEngine.Camera
|
||||
|
||||
-- The server supplies its installation's log directory in the heartbeat.
|
||||
local function diagnostic(message)
|
||||
CS.UnityEngine.Debug.Log(message)
|
||||
local ok, err = pcall(function()
|
||||
local dir = _G.__GAC_DIAGNOSTICS_DIR
|
||||
if not dir or dir == '' then error('server diagnostics directory unavailable') end
|
||||
CS.System.IO.Directory.CreateDirectory(dir)
|
||||
local path = CS.System.IO.Path.Combine(dir, 'hide-ui.log')
|
||||
CS.System.IO.File.AppendAllText(path, tostring(CS.System.DateTime.Now) .. ' ' .. message .. '\n')
|
||||
end)
|
||||
if not ok and _G.__HIDE_UI_FILE_ERROR ~= tostring(err) then
|
||||
_G.__HIDE_UI_FILE_ERROR = tostring(err)
|
||||
CS.UnityEngine.Debug.Log('[GaC HideUI] file log error: ' .. tostring(err))
|
||||
end
|
||||
end
|
||||
|
||||
-- Names observed under UIRoot in this Client, plus the existing battle HUD.
|
||||
-- Never target an ancestor shared by HUD and character/reward dialogs.
|
||||
local HUD_PATHS = {
|
||||
@@ -58,8 +74,9 @@ _G.__HIDE_UI_ENABLED = _G.__HIDE_UI_ENABLED or false
|
||||
_G.__HIDE_UI_TARGETS = _G.__HIDE_UI_TARGETS or {}
|
||||
|
||||
local function restore_hud()
|
||||
local count, errors = 0, 0
|
||||
for id, state in pairs(_G.__HIDE_UI_TARGETS) do
|
||||
pcall(function()
|
||||
local ok = pcall(function()
|
||||
if state.group then
|
||||
if state.added then
|
||||
CS.UnityEngine.Object.Destroy(state.group)
|
||||
@@ -70,8 +87,11 @@ local function restore_hud()
|
||||
end
|
||||
end
|
||||
end)
|
||||
count = count + 1
|
||||
if not ok then errors = errors + 1 end
|
||||
_G.__HIDE_UI_TARGETS[id] = nil
|
||||
end
|
||||
diagnostic('[GaC HideUI] restored=' .. count .. ' errors=' .. errors)
|
||||
end
|
||||
|
||||
local function protected_name(name)
|
||||
@@ -91,6 +111,9 @@ local function hide_object(obj)
|
||||
state = {group=group, added=added, alpha=group.alpha,
|
||||
raycast=group.blocksRaycasts, interactable=group.interactable}
|
||||
_G.__HIDE_UI_TARGETS[id] = state
|
||||
if _G.__HIDE_UI_SCAN_DIAG then
|
||||
_G.__HIDE_UI_SCAN_DIAG.added = _G.__HIDE_UI_SCAN_DIAG.added + 1
|
||||
end
|
||||
end
|
||||
state.group.alpha = 0
|
||||
state.group.blocksRaycasts = false
|
||||
@@ -166,7 +189,14 @@ end
|
||||
|
||||
local function hide_hud()
|
||||
for _, path in ipairs(HUD_PATHS) do
|
||||
pcall(function() hide_hud_tree(GameObject.Find(path)) end)
|
||||
local ok, err = pcall(function()
|
||||
local obj = GameObject.Find(path)
|
||||
if obj and obj.activeInHierarchy then
|
||||
table.insert(_G.__HIDE_UI_SCAN_DIAG.paths, path)
|
||||
end
|
||||
hide_hud_tree(obj)
|
||||
end)
|
||||
if not ok then table.insert(_G.__HIDE_UI_SCAN_DIAG.errors, path .. ': ' .. tostring(err)) end
|
||||
end
|
||||
local ok, err = pcall(function()
|
||||
local flags = CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags), 60)
|
||||
@@ -176,6 +206,7 @@ local function hide_hud()
|
||||
or typeof(CS.RPG.Client.BattleGamePhase):GetField("_HudPage", flags)
|
||||
local manager = CS.RPG.Client.GlobalVars.s_GamePhaseManager
|
||||
local phase = manager and _G.__HIDE_UI_PHASE_FIELD:GetValue(manager)
|
||||
_G.__HIDE_UI_SCAN_DIAG.phase = phase and tostring(phase:GetType().Name) or 'none'
|
||||
if phase and typeof(CS.RPG.Client.BattleGamePhase):IsInstanceOfType(phase) then
|
||||
local hud = _G.__HIDE_UI_BATTLE_HUD_FIELD:GetValue(phase)
|
||||
if hud and hud.Trans then hide_hud_tree(hud.Trans.gameObject) end
|
||||
@@ -189,13 +220,14 @@ local function hide_hud()
|
||||
end)
|
||||
if not ok and _G.__HIDE_UI_LAST_ERROR ~= tostring(err) then
|
||||
_G.__HIDE_UI_LAST_ERROR = tostring(err)
|
||||
CS.UnityEngine.Debug.Log("[GaC HideUI] Battle HUD: " .. tostring(err))
|
||||
diagnostic("[GaC HideUI] Battle HUD: " .. tostring(err))
|
||||
end
|
||||
pcall(function()
|
||||
local pagesOK, pagesErr = pcall(function()
|
||||
local ui = CS.RPG.Client.GlobalVars.s_UIManager
|
||||
local pages = ui:GetAllPageNames()
|
||||
for i = 0, pages.Count - 1 do
|
||||
local name = tostring(pages[i]); local lower = string.lower(name)
|
||||
table.insert(_G.__HIDE_UI_SCAN_DIAG.pages, name)
|
||||
local page = ui:GetPageByName(name)
|
||||
if page and page.ChildDialogs then
|
||||
for j = 0, page.ChildDialogs.Count - 1 do
|
||||
@@ -219,16 +251,18 @@ local function hide_hud()
|
||||
end
|
||||
hide_rank_controls(GameObject.Find("UIRoot/Page/AvatarMainPage(Clone)/Root/AvatarRankPanel"))
|
||||
end)
|
||||
if not pagesOK then table.insert(_G.__HIDE_UI_SCAN_DIAG.errors, 'pages: ' .. tostring(pagesErr)) end
|
||||
end
|
||||
|
||||
function _G.__HIDE_UI_TICK()
|
||||
pcall(function()
|
||||
local ok, err = pcall(function()
|
||||
local frame = Time.frameCount
|
||||
if _G.__HIDE_UI_LAST_FRAME == frame then return end
|
||||
_G.__HIDE_UI_LAST_FRAME = frame
|
||||
local toggled = Input.GetKeyDown(KeyCode.Backslash)
|
||||
if toggled then
|
||||
_G.__HIDE_UI_ENABLED = not _G.__HIDE_UI_ENABLED
|
||||
diagnostic('[GaC HideUI] enabled=' .. tostring(_G.__HIDE_UI_ENABLED))
|
||||
if not _G.__HIDE_UI_ENABLED then restore_hud() end
|
||||
end
|
||||
-- The page/child scan walks Unity UI trees, so keep it to once a second.
|
||||
@@ -237,10 +271,31 @@ function _G.__HIDE_UI_TICK()
|
||||
local now = Time.unscaledTime
|
||||
if toggled or now >= (_G.__HIDE_UI_NEXT_SCAN or 0) then
|
||||
_G.__HIDE_UI_NEXT_SCAN = now + 1.0
|
||||
hide_hud()
|
||||
local started = Time.realtimeSinceStartup
|
||||
local diag = {added=0, paths={}, pages={}, errors={}, phase='unknown'}
|
||||
_G.__HIDE_UI_SCAN_DIAG = diag
|
||||
local scanOK, scanErr = pcall(hide_hud)
|
||||
_G.__HIDE_UI_SCAN_DIAG = nil
|
||||
if not scanOK then table.insert(diag.errors, 'scan: ' .. tostring(scanErr)) end
|
||||
local elapsed = (Time.realtimeSinceStartup - started) * 1000
|
||||
local signature = diag.phase .. '|' .. table.concat(diag.pages, ',') .. '|'
|
||||
.. table.concat(diag.paths, ',') .. '|' .. table.concat(diag.errors, ',')
|
||||
if toggled or diag.added > 0 or #diag.errors > 0 or elapsed >= 20
|
||||
or signature ~= _G.__HIDE_UI_DIAG_SIGNATURE
|
||||
or now >= (_G.__HIDE_UI_DIAG_NEXT or 0) then
|
||||
_G.__HIDE_UI_DIAG_SIGNATURE = signature
|
||||
_G.__HIDE_UI_DIAG_NEXT = now + 30
|
||||
diagnostic(string.format('[GaC HideUI] scan_ms=%.2f phase=%s added=%d pages=[%s] paths=[%s] errors=[%s]',
|
||||
elapsed, diag.phase, diag.added, table.concat(diag.pages, ','),
|
||||
table.concat(diag.paths, ','), table.concat(diag.errors, ',')))
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
if not ok and _G.__HIDE_UI_TICK_ERROR ~= tostring(err) then
|
||||
_G.__HIDE_UI_TICK_ERROR = tostring(err)
|
||||
diagnostic('[GaC HideUI] tick error: ' .. tostring(err))
|
||||
end
|
||||
end
|
||||
|
||||
-- Restore targets from the previous policy (including VersionText) on upgrade.
|
||||
|
||||
Reference in new issue
Block a user