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

+180 -17
View File
@@ -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