feat(demo): add Bootstrap Demo Hub, Chinese UI font, and UI Demo showcase scene

This commit is contained in:
szy73711 committed 2026-12-01 03:13:35 +08:00
1 parent 3572f2da43
commit 4c83c086f4
49 files changed
+7864 -131

No files matched your search

+161 -12
View File
@@ -102,6 +102,7 @@ function UIManager.prototype.ShowUI(self, ctor, args, onOpened)
if existing:IsLoaded() then
local zOrder = self:AllocateZOrder(config)
existing:ShowInternal(zOrder, args)
self:SyncFullscreenVisibility()
self:SyncFocusAndInputMode()
if onOpened ~= nil then
tbpcall(onOpened, true, existing, nil)
@@ -128,6 +129,7 @@ function UIManager.prototype.ShowUI(self, ctor, args, onOpened)
self.windowStack[#self.windowStack + 1] = cached
local zOrder = self:AllocateZOrder(config)
cached:ReuseInternal(zOrder, args)
self:SyncFullscreenVisibility()
self:SyncFocusAndInputMode()
self.events.emit.OnWindowOpened(config.name, cached)
if onOpened ~= nil then
@@ -174,6 +176,7 @@ function UIManager.prototype.ShowUI(self, ctor, args, onOpened)
win:AttachWidgetInternal(widget)
local zOrder = self:AllocateZOrder(config)
win:ShowInternal(zOrder, args)
self:SyncFullscreenVisibility()
self:SyncFocusAndInputMode()
self.events.emit.OnWindowOpened(config.name, win)
if onOpened ~= nil then
@@ -198,17 +201,53 @@ function UIManager.prototype.CloseSingletonUI(self, ctor)
end
end
function UIManager.prototype.GetTopWindow(self)
local best = nil
local bestZOrder = -1
do
local i = #self.windowStack - 1
while i >= 0 do
local win = self.windowStack[i + 1]
if not win:IsDisposed() and not win:IsClosing() then
return win
local i = 0
while i < #self.windowStack do
do
local win = self.windowStack[i + 1]
if win:IsDisposed() or win:IsClosing() then
goto __continue46
end
local z = win:IsLoaded() and win:GetZOrder() or UI_LAYER_ZORDER[win.config.layer]
if best == nil or z >= bestZOrder then
best = win
bestZOrder = z
end
end
i = i - 1
::__continue46::
i = i + 1
end
end
return nil
return best
end
function UIManager.prototype.GetTopBlockingWindow(self)
local best = nil
local bestZOrder = -1
do
local i = 0
while i < #self.windowStack do
do
local win = self.windowStack[i + 1]
if win:IsDisposed() or win:IsClosing() or not win.config.blockWorldClick then
goto __continue51
end
if win:IsLoaded() and not win:IsVisible() then
goto __continue51
end
local z = win:IsLoaded() and win:GetZOrder() or UI_LAYER_ZORDER[win.config.layer]
if best == nil or z >= bestZOrder then
best = win
bestZOrder = z
end
end
::__continue51::
i = i + 1
end
end
return best
end
function UIManager.prototype.HandleWindowCachedInternal(self, win)
self:RemoveFromStackAndSingleton(win)
@@ -217,11 +256,13 @@ function UIManager.prototype.HandleWindowCachedInternal(self, win)
oldCached:ForceDisposeFromCacheInternal()
end
self.cachedByName[win.config.name] = win
self:SyncFullscreenVisibility()
self:SyncFocusAndInputMode()
self.events.emit.OnWindowClosed(win.config.name, win)
end
function UIManager.prototype.HandleWindowClosedInternal(self, win)
self:RemoveFromStackAndSingleton(win)
self:SyncFullscreenVisibility()
self:SyncFocusAndInputMode()
self.events.emit.OnWindowClosed(win.config.name, win)
end
@@ -240,6 +281,35 @@ function UIManager.prototype.EvictCache(self)
i = i + 1
end
end
return #toEvict
end
function UIManager.prototype.CloseAllExcept(self, keepWindow, alsoEvictCache)
if alsoEvictCache == nil then
alsoEvictCache = false
end
local copy = {}
do
local i = #self.windowStack - 1
while i >= 0 do
if self.windowStack[i + 1] ~= keepWindow then
copy[#copy + 1] = self.windowStack[i + 1]
end
i = i - 1
end
end
do
local i = 0
while i < #copy do
copy[i + 1]:Close()
i = i + 1
end
end
if alsoEvictCache then
self:EvictCache()
end
self:SyncFullscreenVisibility()
self:SyncFocusAndInputMode()
return #copy
end
function UIManager.prototype.CloseAll(self, alsoEvictCache)
if alsoEvictCache == nil then
@@ -265,6 +335,41 @@ function UIManager.prototype.CloseAll(self, alsoEvictCache)
end
self:SyncFocusAndInputMode()
end
function UIManager.prototype.GetWindowStackSnapshot(self)
local list = {}
do
local i = 0
while i < #self.windowStack do
local w = self.windowStack[i + 1]
if not w:IsDisposed() then
list[#list + 1] = {
name = w.config.name,
layer = w.config.layer,
type = w.config.type,
zOrder = w:GetZOrder(),
visible = w:IsVisible(),
loading = w:IsLoading(),
singleton = w.config.singleton,
cacheTag = w.config.cacheTag,
blockWorldClick = w.config.blockWorldClick,
hiddenByFullscreen = w:IsHiddenByFullscreen()
}
end
i = i + 1
end
end
return list
end
function UIManager.prototype.GetCachedWindowNames(self)
local names = {}
for name, w in pairs(self.cachedByName) do
if w ~= nil and not w:IsDisposed() then
names[#names + 1] = name
end
end
table.sort(names)
return names
end
function UIManager.prototype.GetDiagnostics(self)
local openWindows = 0
local loadingWindows = 0
@@ -316,9 +421,53 @@ function UIManager.prototype.RemoveFromStackAndSingleton(self, win)
end
end
end
function UIManager.prototype.SyncFullscreenVisibility(self)
local topFullscreen = nil
local topFullscreenZ = -1
do
local i = 0
while i < #self.windowStack do
local win = self.windowStack[i + 1]
if not win:IsDisposed() and not win:IsClosing() and win:IsLoaded() and win.config.type == "fullscreen" then
local z = win:GetZOrder()
if topFullscreen == nil or z >= topFullscreenZ then
topFullscreen = win
topFullscreenZ = z
end
end
i = i + 1
end
end
do
local i = 0
while i < #self.windowStack do
do
local win = self.windowStack[i + 1]
if win:IsDisposed() or win:IsClosing() or not win:IsLoaded() then
goto __continue103
end
local affectedLayer = win.config.layer == "background" or win.config.layer == "normal"
if not affectedLayer then
goto __continue103
end
if topFullscreen ~= nil and win ~= topFullscreen and win:GetZOrder() < topFullscreenZ then
if win:IsVisible() then
win:SetHiddenByFullscreenInternal(true)
win:Hide()
end
elseif win:IsHiddenByFullscreen() then
win:RestoreFromFullscreenInternal()
end
end
::__continue103::
i = i + 1
end
end
end
function UIManager.prototype.SyncFocusAndInputMode(self)
local top = self:GetTopWindow()
local nextMode = top ~= nil and top.config.blockWorldClick and "ui" or "game"
local topBlocking = self:GetTopBlockingWindow()
local topAny = self:GetTopWindow()
local nextMode = topBlocking ~= nil and "ui" or "game"
self.inputMode = nextMode
local pc = self.playerCtx.playerController
if pc ~= nil and UE ~= nil and UE.UKismetSystemLibrary.IsValid(pc) then
@@ -326,8 +475,8 @@ function UIManager.prototype.SyncFocusAndInputMode(self)
pc.bShowMouseCursor = true
local ____UE_UWidgetBlueprintLibrary_SetInputMode_UIOnlyEx_1 = UE.UWidgetBlueprintLibrary.SetInputMode_UIOnlyEx
local ____temp_0
if top ~= nil then
____temp_0 = top:GetWidget()
if topBlocking ~= nil then
____temp_0 = topBlocking:GetWidget()
else
____temp_0 = nil
end
@@ -337,7 +486,7 @@ function UIManager.prototype.SyncFocusAndInputMode(self)
UE.UWidgetBlueprintLibrary.SetInputMode_GameOnly(pc, false)
end
end
self.events.emit.OnFocusRestored(top ~= nil and top.config.name or nil)
self.events.emit.OnFocusRestored(topAny ~= nil and topAny.config.name or nil)
end
function UIManager.prototype.Dispose(self)
if self:IsDisposed() then