feat(demo): add Bootstrap Demo Hub, Chinese UI font, and UI Demo showcase scene
This commit is contained in:
1 parent
3572f2da43
commit
4c83c086f4
49 files changed
+7864
-131
No files matched your search
@@ -1,8 +1,42 @@
|
||||
local ____exports = __module.env
|
||||
---
|
||||
-- @noSelfInFile
|
||||
____exports.ASSET_KEYS = {MINI_SETTINGS_ICON = "tex.mini_settings_icon", MINI_SETTINGS_WIDGET = "ui.mini_settings"}
|
||||
____exports.BASE_ASSET_PATHS = {[____exports.ASSET_KEYS.MINI_SETTINGS_ICON] = "/Game/UI/Textures/T_MiniSettingsIcon.T_MiniSettingsIcon", [____exports.ASSET_KEYS.MINI_SETTINGS_WIDGET] = "/Game/UI/WBP_MiniSettings.WBP_MiniSettings_C"}
|
||||
____exports.ASSET_KEYS = {
|
||||
MINI_SETTINGS_ICON = "tex.mini_settings_icon",
|
||||
MINI_SETTINGS_WIDGET = "ui.mini_settings",
|
||||
DEMO_AVATAR_TEX = "tex.demo_avatar",
|
||||
DEMO_BADGE_A_TEX = "tex.demo_badge_a",
|
||||
DEMO_BADGE_B_TEX = "tex.demo_badge_b",
|
||||
DEMO_HUB_WIDGET = "ui.demo_hub",
|
||||
DEMO_HUB_ITEM_WIDGET = "ui.demo_hub_item",
|
||||
UI_DEMO_MAIN_WIDGET = "ui.demo_ui_main",
|
||||
UI_DEMO_LIST_ITEM_WIDGET = "ui.demo_ui_list_item",
|
||||
UI_DEMO_NORMAL_WIDGET = "ui.demo_ui_normal",
|
||||
UI_DEMO_FULLSCREEN_WIDGET = "ui.demo_ui_fullscreen",
|
||||
UI_DEMO_MODAL_WIDGET = "ui.demo_ui_modal",
|
||||
UI_DEMO_CACHED_WIDGET = "ui.demo_ui_cached",
|
||||
UI_DEMO_MULTI_WIDGET = "ui.demo_ui_multi",
|
||||
UI_DEMO_TOAST_WIDGET = "ui.demo_ui_toast",
|
||||
UI_DEMO_SYSTEM_WIDGET = "ui.demo_ui_system"
|
||||
}
|
||||
____exports.BASE_ASSET_PATHS = {
|
||||
[____exports.ASSET_KEYS.MINI_SETTINGS_ICON] = "/Game/UI/Textures/T_MiniSettingsIcon.T_MiniSettingsIcon",
|
||||
[____exports.ASSET_KEYS.MINI_SETTINGS_WIDGET] = "/Game/UI/WBP_MiniSettings.WBP_MiniSettings_C",
|
||||
[____exports.ASSET_KEYS.DEMO_AVATAR_TEX] = "/Game/UI/Textures/T_DemoAvatar.T_DemoAvatar",
|
||||
[____exports.ASSET_KEYS.DEMO_BADGE_A_TEX] = "/Game/UI/Textures/T_DemoBadgeA.T_DemoBadgeA",
|
||||
[____exports.ASSET_KEYS.DEMO_BADGE_B_TEX] = "/Game/UI/Textures/T_DemoBadgeB.T_DemoBadgeB",
|
||||
[____exports.ASSET_KEYS.DEMO_HUB_WIDGET] = "/Game/UI/Demo/WBP_DemoHub.WBP_DemoHub_C",
|
||||
[____exports.ASSET_KEYS.DEMO_HUB_ITEM_WIDGET] = "/Game/UI/Demo/WBP_DemoHubItem.WBP_DemoHubItem_C",
|
||||
[____exports.ASSET_KEYS.UI_DEMO_MAIN_WIDGET] = "/Game/UI/Demo/WBP_UIDemoMain.WBP_UIDemoMain_C",
|
||||
[____exports.ASSET_KEYS.UI_DEMO_LIST_ITEM_WIDGET] = "/Game/UI/Demo/WBP_UIDemoListItem.WBP_UIDemoListItem_C",
|
||||
[____exports.ASSET_KEYS.UI_DEMO_NORMAL_WIDGET] = "/Game/UI/Demo/WBP_UIDemoNormal.WBP_UIDemoNormal_C",
|
||||
[____exports.ASSET_KEYS.UI_DEMO_FULLSCREEN_WIDGET] = "/Game/UI/Demo/WBP_UIDemoFullscreen.WBP_UIDemoFullscreen_C",
|
||||
[____exports.ASSET_KEYS.UI_DEMO_MODAL_WIDGET] = "/Game/UI/Demo/WBP_UIDemoModal.WBP_UIDemoModal_C",
|
||||
[____exports.ASSET_KEYS.UI_DEMO_CACHED_WIDGET] = "/Game/UI/Demo/WBP_UIDemoCached.WBP_UIDemoCached_C",
|
||||
[____exports.ASSET_KEYS.UI_DEMO_MULTI_WIDGET] = "/Game/UI/Demo/WBP_UIDemoMulti.WBP_UIDemoMulti_C",
|
||||
[____exports.ASSET_KEYS.UI_DEMO_TOAST_WIDGET] = "/Game/UI/Demo/WBP_UIDemoToast.WBP_UIDemoToast_C",
|
||||
[____exports.ASSET_KEYS.UI_DEMO_SYSTEM_WIDGET] = "/Game/UI/Demo/WBP_UIDemoSystem.WBP_UIDemoSystem_C"
|
||||
}
|
||||
function ____exports.RegisterBaseAssetCatalog(subsystem)
|
||||
for logicalKey, softPath in pairs(____exports.BASE_ASSET_PATHS) do
|
||||
subsystem:RegisterBaseAssetKey(logicalKey, softPath)
|
||||
|
||||
@@ -21,19 +21,46 @@ end
|
||||
function UEButtonDelegateBackend.prototype.BindButtonClicked(self, button)
|
||||
return self.subsystem:BindButtonClicked(button)
|
||||
end
|
||||
function UEButtonDelegateBackend.prototype.BindButtonHovered(self, button)
|
||||
return self.subsystem:BindButtonHovered(button)
|
||||
end
|
||||
function UEButtonDelegateBackend.prototype.BindButtonUnhovered(self, button)
|
||||
return self.subsystem:BindButtonUnhovered(button)
|
||||
end
|
||||
function UEButtonDelegateBackend.prototype.BindCheckBoxChanged(self, checkBox)
|
||||
return self.subsystem:BindCheckBoxChanged(checkBox)
|
||||
end
|
||||
function UEButtonDelegateBackend.prototype.BindSliderChanged(self, slider)
|
||||
return self.subsystem:BindSliderChanged(slider)
|
||||
end
|
||||
function UEButtonDelegateBackend.prototype.BindSpinBoxChanged(self, spinBox)
|
||||
return self.subsystem:BindSpinBoxChanged(spinBox)
|
||||
end
|
||||
function UEButtonDelegateBackend.prototype.BindEditableTextChanged(self, textBox)
|
||||
return self.subsystem:BindEditableTextChanged(textBox)
|
||||
end
|
||||
function UEButtonDelegateBackend.prototype.BindEditableTextCommitted(self, textBox)
|
||||
return self.subsystem:BindEditableTextCommitted(textBox)
|
||||
end
|
||||
function UEButtonDelegateBackend.prototype.BindComboBoxSelectionChanged(self, comboBox)
|
||||
return self.subsystem:BindComboBoxSelectionChanged(comboBox)
|
||||
end
|
||||
function UEButtonDelegateBackend.prototype.UnbindButtonClicked(self, bindingId)
|
||||
return self.subsystem:UnbindButtonClicked(bindingId)
|
||||
return self.subsystem:UnbindWidgetEvent(bindingId)
|
||||
end
|
||||
function UEButtonDelegateBackend.prototype.UnbindWidgetEvent(self, bindingId)
|
||||
return self.subsystem:UnbindWidgetEvent(bindingId)
|
||||
end
|
||||
function UEButtonDelegateBackend.prototype.GetActiveBindingCount(self)
|
||||
return self.subsystem:GetActiveBindingCount()
|
||||
end
|
||||
local ButtonBindingHandle = __TS__DefineClass("ButtonBindingHandle", __module)
|
||||
ButtonBindingHandle.name = "ButtonBindingHandle"
|
||||
function ButtonBindingHandle.prototype.____constructor(self, bridge, bindingId)
|
||||
local WidgetBindingHandle = __TS__DefineClass("WidgetBindingHandle", __module)
|
||||
WidgetBindingHandle.name = "WidgetBindingHandle"
|
||||
function WidgetBindingHandle.prototype.____constructor(self, bridge, bindingId)
|
||||
self.bridge = bridge
|
||||
self.bindingId = bindingId
|
||||
end
|
||||
function ButtonBindingHandle.prototype.Dispose(self)
|
||||
function WidgetBindingHandle.prototype.Dispose(self)
|
||||
if self.bridge ~= nil then
|
||||
local b = self.bridge
|
||||
self.bridge = nil
|
||||
@@ -56,36 +83,125 @@ function UIDelegateBridge.prototype.____constructor(self, ctx, backend)
|
||||
bridgeByGameInstanceKey[self.giKey] = self
|
||||
end
|
||||
end
|
||||
function UIDelegateBridge.prototype.BindButtonClick(self, button, callback, owner)
|
||||
local bindingId = self.backend:BindButtonClicked(button)
|
||||
assert(bindingId > 0, "UIDelegateBridge.BindButtonClick: failed to bind button")
|
||||
function UIDelegateBridge.prototype.RegisterBinding(self, bindingId, callback, owner)
|
||||
assert(bindingId > 0, "UIDelegateBridge: failed to bind UMG widget event")
|
||||
self.bindings[bindingId] = {bindingId = bindingId, callback = callback, owner = owner}
|
||||
local handle = __TS__New(ButtonBindingHandle, self, bindingId)
|
||||
local handle = __TS__New(WidgetBindingHandle, self, bindingId)
|
||||
if owner ~= nil and __TS__InstanceOf(owner, ScopedObject) then
|
||||
owner:AddScopedObject(handle)
|
||||
end
|
||||
return handle
|
||||
end
|
||||
function UIDelegateBridge.prototype.BindButtonClick(self, button, callback, owner)
|
||||
local bindingId = self.backend:BindButtonClicked(button)
|
||||
return self:RegisterBinding(bindingId, callback, owner)
|
||||
end
|
||||
function UIDelegateBridge.prototype.BindButtonHovered(self, button, callback, owner)
|
||||
assert(self.backend.BindButtonHovered ~= nil, "UIDelegateBridge backend does not support BindButtonHovered")
|
||||
local bindingId = self.backend:BindButtonHovered(button)
|
||||
return self:RegisterBinding(bindingId, callback, owner)
|
||||
end
|
||||
function UIDelegateBridge.prototype.BindButtonUnhovered(self, button, callback, owner)
|
||||
assert(self.backend.BindButtonUnhovered ~= nil, "UIDelegateBridge backend does not support BindButtonUnhovered")
|
||||
local bindingId = self.backend:BindButtonUnhovered(button)
|
||||
return self:RegisterBinding(bindingId, callback, owner)
|
||||
end
|
||||
function UIDelegateBridge.prototype.BindCheckBoxChanged(self, checkBox, callback, owner)
|
||||
assert(self.backend.BindCheckBoxChanged ~= nil, "UIDelegateBridge backend does not support BindCheckBoxChanged")
|
||||
local bindingId = self.backend:BindCheckBoxChanged(checkBox)
|
||||
return self:RegisterBinding(bindingId, callback, owner)
|
||||
end
|
||||
function UIDelegateBridge.prototype.BindSliderChanged(self, slider, callback, owner)
|
||||
assert(self.backend.BindSliderChanged ~= nil, "UIDelegateBridge backend does not support BindSliderChanged")
|
||||
local bindingId = self.backend:BindSliderChanged(slider)
|
||||
return self:RegisterBinding(bindingId, callback, owner)
|
||||
end
|
||||
function UIDelegateBridge.prototype.BindSpinBoxChanged(self, spinBox, callback, owner)
|
||||
assert(self.backend.BindSpinBoxChanged ~= nil, "UIDelegateBridge backend does not support BindSpinBoxChanged")
|
||||
local bindingId = self.backend:BindSpinBoxChanged(spinBox)
|
||||
return self:RegisterBinding(bindingId, callback, owner)
|
||||
end
|
||||
function UIDelegateBridge.prototype.BindEditableTextChanged(self, textBox, callback, owner)
|
||||
assert(self.backend.BindEditableTextChanged ~= nil, "UIDelegateBridge backend does not support BindEditableTextChanged")
|
||||
local bindingId = self.backend:BindEditableTextChanged(textBox)
|
||||
return self:RegisterBinding(bindingId, callback, owner)
|
||||
end
|
||||
function UIDelegateBridge.prototype.BindEditableTextCommitted(self, textBox, callback, owner)
|
||||
assert(self.backend.BindEditableTextCommitted ~= nil, "UIDelegateBridge backend does not support BindEditableTextCommitted")
|
||||
local bindingId = self.backend:BindEditableTextCommitted(textBox)
|
||||
return self:RegisterBinding(bindingId, callback, owner)
|
||||
end
|
||||
function UIDelegateBridge.prototype.BindComboBoxSelectionChanged(self, comboBox, callback, owner)
|
||||
assert(self.backend.BindComboBoxSelectionChanged ~= nil, "UIDelegateBridge backend does not support BindComboBoxSelectionChanged")
|
||||
local bindingId = self.backend:BindComboBoxSelectionChanged(comboBox)
|
||||
return self:RegisterBinding(bindingId, callback, owner)
|
||||
end
|
||||
function UIDelegateBridge.prototype.UnbindById(self, bindingId)
|
||||
if self.bindings[bindingId] == nil then
|
||||
return
|
||||
end
|
||||
self.bindings[bindingId] = nil
|
||||
self.backend:UnbindButtonClicked(bindingId)
|
||||
if self.backend.UnbindWidgetEvent ~= nil then
|
||||
self.backend:UnbindWidgetEvent(bindingId)
|
||||
else
|
||||
self.backend:UnbindButtonClicked(bindingId)
|
||||
end
|
||||
end
|
||||
function UIDelegateBridge.prototype.DispatchButtonClicked(self, bindingId)
|
||||
function UIDelegateBridge.prototype.ResolveLiveRecord(self, bindingId)
|
||||
if self:IsDisposed() then
|
||||
return
|
||||
return nil
|
||||
end
|
||||
local rec = self.bindings[bindingId]
|
||||
if rec == nil then
|
||||
return
|
||||
return nil
|
||||
end
|
||||
if rec.owner ~= nil and rec.owner:IsDisposed() then
|
||||
self:UnbindById(bindingId)
|
||||
return
|
||||
return nil
|
||||
end
|
||||
return rec
|
||||
end
|
||||
function UIDelegateBridge.prototype.DispatchButtonClicked(self, bindingId)
|
||||
local rec = self:ResolveLiveRecord(bindingId)
|
||||
if rec ~= nil then
|
||||
tbpcall(rec.callback)
|
||||
end
|
||||
end
|
||||
function UIDelegateBridge.prototype.DispatchActionEvent(self, bindingId)
|
||||
local rec = self:ResolveLiveRecord(bindingId)
|
||||
if rec ~= nil then
|
||||
tbpcall(rec.callback)
|
||||
end
|
||||
end
|
||||
function UIDelegateBridge.prototype.DispatchBoolChanged(self, bindingId, value)
|
||||
local rec = self:ResolveLiveRecord(bindingId)
|
||||
if rec ~= nil then
|
||||
tbpcall(rec.callback, value)
|
||||
end
|
||||
end
|
||||
function UIDelegateBridge.prototype.DispatchFloatChanged(self, bindingId, value)
|
||||
local rec = self:ResolveLiveRecord(bindingId)
|
||||
if rec ~= nil then
|
||||
tbpcall(rec.callback, value)
|
||||
end
|
||||
end
|
||||
function UIDelegateBridge.prototype.DispatchTextChanged(self, bindingId, text)
|
||||
local rec = self:ResolveLiveRecord(bindingId)
|
||||
if rec ~= nil then
|
||||
tbpcall(rec.callback, text)
|
||||
end
|
||||
end
|
||||
function UIDelegateBridge.prototype.DispatchTextCommitted(self, bindingId, text, commitMethod)
|
||||
local rec = self:ResolveLiveRecord(bindingId)
|
||||
if rec ~= nil then
|
||||
tbpcall(rec.callback, text, commitMethod)
|
||||
end
|
||||
end
|
||||
function UIDelegateBridge.prototype.DispatchSelectionChanged(self, bindingId, selectedItem, selectType)
|
||||
local rec = self:ResolveLiveRecord(bindingId)
|
||||
if rec ~= nil then
|
||||
tbpcall(rec.callback, selectedItem, selectType)
|
||||
end
|
||||
tbpcall(rec.callback)
|
||||
end
|
||||
function UIDelegateBridge.prototype.GetActiveBindingCount(self)
|
||||
return self.backend:GetActiveBindingCount()
|
||||
@@ -110,8 +226,7 @@ function UIDelegateBridge.prototype.Dispose(self)
|
||||
end
|
||||
ScopedObject.prototype.Dispose(self)
|
||||
end
|
||||
--- 供 C++ FLuaCallbackBridge::CallInt 回调的纯函数入口。
|
||||
--
|
||||
---
|
||||
-- @noSelf
|
||||
function ____exports.OnNativeButtonClicked(gameInstance, bindingId)
|
||||
local bridge = bridgeByGameInstanceKey[GetGameInstanceKey(gameInstance)]
|
||||
@@ -121,6 +236,54 @@ function ____exports.OnNativeButtonClicked(gameInstance, bindingId)
|
||||
end
|
||||
---
|
||||
-- @noSelf
|
||||
function ____exports.OnNativeActionEvent(gameInstance, bindingId)
|
||||
local bridge = bridgeByGameInstanceKey[GetGameInstanceKey(gameInstance)]
|
||||
if bridge ~= nil then
|
||||
bridge:DispatchActionEvent(bindingId)
|
||||
end
|
||||
end
|
||||
---
|
||||
-- @noSelf
|
||||
function ____exports.OnNativeBoolChanged(gameInstance, bindingId, value)
|
||||
local bridge = bridgeByGameInstanceKey[GetGameInstanceKey(gameInstance)]
|
||||
if bridge ~= nil then
|
||||
bridge:DispatchBoolChanged(bindingId, value)
|
||||
end
|
||||
end
|
||||
---
|
||||
-- @noSelf
|
||||
function ____exports.OnNativeFloatChanged(gameInstance, bindingId, value)
|
||||
local bridge = bridgeByGameInstanceKey[GetGameInstanceKey(gameInstance)]
|
||||
if bridge ~= nil then
|
||||
bridge:DispatchFloatChanged(bindingId, value)
|
||||
end
|
||||
end
|
||||
---
|
||||
-- @noSelf
|
||||
function ____exports.OnNativeTextChanged(gameInstance, bindingId, text)
|
||||
local bridge = bridgeByGameInstanceKey[GetGameInstanceKey(gameInstance)]
|
||||
if bridge ~= nil then
|
||||
bridge:DispatchTextChanged(bindingId, text)
|
||||
end
|
||||
end
|
||||
---
|
||||
-- @noSelf
|
||||
function ____exports.OnNativeTextCommitted(gameInstance, bindingId, text, commitMethod)
|
||||
local bridge = bridgeByGameInstanceKey[GetGameInstanceKey(gameInstance)]
|
||||
if bridge ~= nil then
|
||||
bridge:DispatchTextCommitted(bindingId, text, commitMethod)
|
||||
end
|
||||
end
|
||||
---
|
||||
-- @noSelf
|
||||
function ____exports.OnNativeSelectionChanged(gameInstance, bindingId, selectedItem, selectType)
|
||||
local bridge = bridgeByGameInstanceKey[GetGameInstanceKey(gameInstance)]
|
||||
if bridge ~= nil then
|
||||
bridge:DispatchSelectionChanged(bindingId, selectedItem, selectType)
|
||||
end
|
||||
end
|
||||
---
|
||||
-- @noSelf
|
||||
function ____exports.CreateUEUIDelegateBridge(ctx)
|
||||
if ctx.gameInstance == nil then
|
||||
return nil
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,7 +20,9 @@ function UIWindow.prototype.____constructor(self, ...)
|
||||
self.isVisible = false
|
||||
self.isClosing = false
|
||||
self.isCached = false
|
||||
self.buttonBindings = {}
|
||||
self.hiddenByFullscreen = false
|
||||
self.currentZOrder = 0
|
||||
self.widgetBindings = {}
|
||||
end
|
||||
function UIWindow.prototype.InitContextInternal(self, ctx, uiManager, config, widgetAdapter)
|
||||
self.ctx = ctx
|
||||
@@ -31,6 +33,9 @@ end
|
||||
function UIWindow.prototype.GetWidget(self)
|
||||
return self.widget
|
||||
end
|
||||
function UIWindow.prototype.GetZOrder(self)
|
||||
return self.currentZOrder
|
||||
end
|
||||
function UIWindow.prototype.IsLoading(self)
|
||||
return self.isLoading
|
||||
end
|
||||
@@ -46,6 +51,12 @@ end
|
||||
function UIWindow.prototype.IsCached(self)
|
||||
return self.isCached
|
||||
end
|
||||
function UIWindow.prototype.IsHiddenByFullscreen(self)
|
||||
return self.hiddenByFullscreen
|
||||
end
|
||||
function UIWindow.prototype.SetHiddenByFullscreenInternal(self, hidden)
|
||||
self.hiddenByFullscreen = hidden
|
||||
end
|
||||
function UIWindow.prototype.SetLoadingStateInternal(self, loading, handle)
|
||||
self.isLoading = loading
|
||||
self.classLoadHandle = handle
|
||||
@@ -69,30 +80,99 @@ function UIWindow.prototype.RequireWidget(self, widgetName)
|
||||
)
|
||||
return child
|
||||
end
|
||||
function UIWindow.prototype.BindButtonClick(self, button, callback)
|
||||
function UIWindow.prototype.TrackWidgetBinding(self, handle)
|
||||
if handle ~= nil then
|
||||
self.widgetBindings[#self.widgetBindings + 1] = handle
|
||||
end
|
||||
return handle
|
||||
end
|
||||
function UIWindow.prototype.GetDelegateBridge(self)
|
||||
local bridge = self.ctx:GetService("uiDelegateBridge")
|
||||
if bridge == nil then
|
||||
logger:Warn("UIDelegateBridge not registered on context", {window = self.config.name})
|
||||
return nil
|
||||
end
|
||||
local handle = bridge:BindButtonClick(button, callback, self)
|
||||
self.buttonBindings[#self.buttonBindings + 1] = handle
|
||||
return handle
|
||||
return bridge
|
||||
end
|
||||
function UIWindow.prototype.UnbindAllButtons(self)
|
||||
function UIWindow.prototype.BindButtonClick(self, button, callback)
|
||||
local bridge = self:GetDelegateBridge()
|
||||
if bridge == nil then
|
||||
return nil
|
||||
end
|
||||
return self:TrackWidgetBinding(bridge:BindButtonClick(button, callback, self))
|
||||
end
|
||||
function UIWindow.prototype.BindButtonHovered(self, button, callback)
|
||||
local bridge = self:GetDelegateBridge()
|
||||
if bridge == nil then
|
||||
return nil
|
||||
end
|
||||
return self:TrackWidgetBinding(bridge:BindButtonHovered(button, callback, self))
|
||||
end
|
||||
function UIWindow.prototype.BindButtonUnhovered(self, button, callback)
|
||||
local bridge = self:GetDelegateBridge()
|
||||
if bridge == nil then
|
||||
return nil
|
||||
end
|
||||
return self:TrackWidgetBinding(bridge:BindButtonUnhovered(button, callback, self))
|
||||
end
|
||||
function UIWindow.prototype.BindCheckBoxChanged(self, checkBox, callback)
|
||||
local bridge = self:GetDelegateBridge()
|
||||
if bridge == nil then
|
||||
return nil
|
||||
end
|
||||
return self:TrackWidgetBinding(bridge:BindCheckBoxChanged(checkBox, callback, self))
|
||||
end
|
||||
function UIWindow.prototype.BindSliderChanged(self, slider, callback)
|
||||
local bridge = self:GetDelegateBridge()
|
||||
if bridge == nil then
|
||||
return nil
|
||||
end
|
||||
return self:TrackWidgetBinding(bridge:BindSliderChanged(slider, callback, self))
|
||||
end
|
||||
function UIWindow.prototype.BindSpinBoxChanged(self, spinBox, callback)
|
||||
local bridge = self:GetDelegateBridge()
|
||||
if bridge == nil then
|
||||
return nil
|
||||
end
|
||||
return self:TrackWidgetBinding(bridge:BindSpinBoxChanged(spinBox, callback, self))
|
||||
end
|
||||
function UIWindow.prototype.BindEditableTextChanged(self, textBox, callback)
|
||||
local bridge = self:GetDelegateBridge()
|
||||
if bridge == nil then
|
||||
return nil
|
||||
end
|
||||
return self:TrackWidgetBinding(bridge:BindEditableTextChanged(textBox, callback, self))
|
||||
end
|
||||
function UIWindow.prototype.BindEditableTextCommitted(self, textBox, callback)
|
||||
local bridge = self:GetDelegateBridge()
|
||||
if bridge == nil then
|
||||
return nil
|
||||
end
|
||||
return self:TrackWidgetBinding(bridge:BindEditableTextCommitted(textBox, callback, self))
|
||||
end
|
||||
function UIWindow.prototype.BindComboBoxChanged(self, comboBox, callback)
|
||||
local bridge = self:GetDelegateBridge()
|
||||
if bridge == nil then
|
||||
return nil
|
||||
end
|
||||
return self:TrackWidgetBinding(bridge:BindComboBoxSelectionChanged(comboBox, callback, self))
|
||||
end
|
||||
function UIWindow.prototype.UnbindAllWidgetEvents(self)
|
||||
do
|
||||
local i = 0
|
||||
while i < #self.buttonBindings do
|
||||
self.buttonBindings[i + 1]:Dispose()
|
||||
while i < #self.widgetBindings do
|
||||
self.widgetBindings[i + 1]:Dispose()
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
self.buttonBindings = {}
|
||||
self.widgetBindings = {}
|
||||
end
|
||||
function UIWindow.prototype.ShowInternal(self, zOrder, args)
|
||||
if self:IsDisposed() or self.isClosing then
|
||||
return
|
||||
end
|
||||
self.currentZOrder = zOrder
|
||||
self.hiddenByFullscreen = false
|
||||
tbpcall(function()
|
||||
self:OnPreShow(args)
|
||||
end)
|
||||
@@ -111,6 +191,7 @@ function UIWindow.prototype.ReuseInternal(self, zOrder, args)
|
||||
end
|
||||
self.isCached = false
|
||||
self.isClosing = false
|
||||
self.hiddenByFullscreen = false
|
||||
self:EnableAllEventListeners()
|
||||
self:OnBindWidgets()
|
||||
tbpcall(function()
|
||||
@@ -118,6 +199,22 @@ function UIWindow.prototype.ReuseInternal(self, zOrder, args)
|
||||
end)
|
||||
self:ShowInternal(zOrder, args)
|
||||
end
|
||||
function UIWindow.prototype.RestoreFromFullscreenInternal(self)
|
||||
if self:IsDisposed() or self.isClosing or self.isCached or not self.isLoaded then
|
||||
return
|
||||
end
|
||||
self.hiddenByFullscreen = false
|
||||
if self.isVisible then
|
||||
return
|
||||
end
|
||||
if self.widget ~= nil and self.widgetAdapter:IsWidgetValid(self.widget) then
|
||||
self.widgetAdapter:SetVisible(self.widget, true)
|
||||
end
|
||||
self.isVisible = true
|
||||
tbpcall(function()
|
||||
self:OnShow()
|
||||
end)
|
||||
end
|
||||
function UIWindow.prototype.Hide(self)
|
||||
if not self.isVisible then
|
||||
return
|
||||
@@ -143,9 +240,10 @@ function UIWindow.prototype.Close(self, onClosed)
|
||||
local canCache = self.config.cacheTag == "cache" and self.isLoaded and self.widget ~= nil and self.widgetAdapter:IsWidgetValid(self.widget) and not self.ctx:IsShuttingDown()
|
||||
if canCache then
|
||||
self.isVisible = false
|
||||
self.hiddenByFullscreen = false
|
||||
self.isCached = true
|
||||
self.isClosing = false
|
||||
self:UnbindAllButtons()
|
||||
self:UnbindAllWidgetEvents()
|
||||
self:DisableAllEventListeners()
|
||||
self.widgetAdapter:RemoveFromParent(self.widget)
|
||||
tbpcall(function()
|
||||
@@ -163,7 +261,8 @@ function UIWindow.prototype.Close(self, onClosed)
|
||||
end)
|
||||
end
|
||||
self.isVisible = false
|
||||
self:UnbindAllButtons()
|
||||
self.hiddenByFullscreen = false
|
||||
self:UnbindAllWidgetEvents()
|
||||
if self.widget ~= nil and self.widgetAdapter:IsWidgetValid(self.widget) then
|
||||
self.widgetAdapter:RemoveFromParent(self.widget)
|
||||
end
|
||||
@@ -176,7 +275,8 @@ function UIWindow.prototype.Close(self, onClosed)
|
||||
end
|
||||
function UIWindow.prototype.ForceDisposeFromCacheInternal(self)
|
||||
self.isCached = false
|
||||
self:UnbindAllButtons()
|
||||
self.hiddenByFullscreen = false
|
||||
self:UnbindAllWidgetEvents()
|
||||
if self.widget ~= nil and self.widgetAdapter:IsWidgetValid(self.widget) then
|
||||
self.widgetAdapter:RemoveFromParent(self.widget)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user