chore: upgrade ts2lua-unreal to v0.3.1 with lowercase lib/module.lua & lib/class.lua and commit framework refactor

This commit is contained in:
szy73711 committed 2026-11-30 03:43:42 +08:00
1 parent 783dccf53d
commit 3572f2da43
206 files changed
+14442 -13186

No files matched your search

@@ -0,0 +1,119 @@
local ____lualib = require("lualib_bundle")
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local ____exports = __module.env
local M__share_base_logger = __MODULE__.Import("share.base.logger", __module)
local Logger = M__share_base_logger.Logger
local M__framework_resource_asset_catalog = __MODULE__.Import("framework.resource.asset_catalog", __module)
local ASSET_KEYS = M__framework_resource_asset_catalog.ASSET_KEYS
local M__framework_ui_ui_config = __MODULE__.Import("framework.ui.ui_config", __module)
local RegisterUIConfig = M__framework_ui_ui_config.RegisterUIConfig
local M__framework_ui_ui_window = __MODULE__.Import("framework.ui.ui_window", __module)
local UIWindow = M__framework_ui_ui_window.UIWindow
local M__game_setting_setting_service = __MODULE__.Import("game.setting.setting_service", __module)
local SETTING_KEYS = M__game_setting_setting_service.SETTING_KEYS
local logger = Logger("MiniSettingsWindow")
____exports.MiniSettingsWindow = __TS__DefineClass("MiniSettingsWindow", __module)
local MiniSettingsWindow = ____exports.MiniSettingsWindow
MiniSettingsWindow.name = "MiniSettingsWindow"
__TS__ClassExtends(MiniSettingsWindow, UIWindow)
function MiniSettingsWindow.prototype.____constructor(self, ...)
UIWindow.prototype.____constructor(self, ...)
self.iconLoaded = false
self.toggleClickCount = 0
end
function MiniSettingsWindow.prototype.OnBindWidgets(self)
self.imgIcon = self:RequireWidget("ImgIcon")
self.txtStatus = self:RequireWidget("TxtStatus")
self.btnToggle = self:RequireWidget("BtnToggle")
self.txtToggleLabel = self:RequireWidget("TxtToggleLabel")
self.btnClose = self:RequireWidget("BtnClose")
self:BindButtonClick(
self.btnToggle,
function()
self:HandleToggleClicked()
end
)
self:BindButtonClick(
self.btnClose,
function()
self:Close()
end
)
end
function MiniSettingsWindow.prototype.OnPreShow(self)
local settingSvc = self.ctx:GetService("setting")
if settingSvc ~= nil then
settingSvc.events.on.OnBoolSettingChanged(
function(key, _val)
if key == SETTING_KEYS.SOUND_ENABLED then
self:RefreshDisplay()
end
end,
self
)
end
self:RefreshDisplay()
self:LoadIconTexture()
end
function MiniSettingsWindow.prototype.LoadIconTexture(self)
local resSvc = self.ctx:GetService("resource")
if resSvc == nil then
return
end
resSvc:LoadTextureAsync(
ASSET_KEYS.MINI_SETTINGS_ICON,
self,
function(ok, tex, _lease, err)
if not ok or tex == nil then
logger:Warn("Failed to load MiniSettings icon texture", {err = err})
return
end
self.iconLoaded = true
if self.imgIcon ~= nil and self.imgIcon.SetBrushFromTexture ~= nil then
self.imgIcon:SetBrushFromTexture(tex, false)
end
end
)
end
function MiniSettingsWindow.prototype.HandleToggleClicked(self)
self.toggleClickCount = self.toggleClickCount + 1
local settingSvc = self.ctx:GetService("setting")
if settingSvc ~= nil then
local nextVal = settingSvc:ToggleSoundEnabled()
logger:Info("Sound setting toggled", {soundEnabled = nextVal})
end
end
function MiniSettingsWindow.prototype.RefreshDisplay(self)
local settingSvc = self.ctx:GetService("setting")
local ____temp_0
if settingSvc ~= nil then
____temp_0 = settingSvc:GetSoundEnabled()
else
____temp_0 = true
end
local soundEnabled = ____temp_0
local statusText = soundEnabled and "Sound: ON" or "Sound: OFF"
local btnText = soundEnabled and "Disable Sound" or "Enable Sound"
if self.txtStatus ~= nil and self.txtStatus.SetText ~= nil then
self.txtStatus:SetText(statusText)
end
if self.txtToggleLabel ~= nil and self.txtToggleLabel.SetText ~= nil then
self.txtToggleLabel:SetText(btnText)
end
end
RegisterUIConfig(____exports.MiniSettingsWindow, {
name = "MiniSettingsWindow",
assetKey = ASSET_KEYS.MINI_SETTINGS_WIDGET,
singleton = true,
layer = "popup",
type = "popup",
cacheTag = "no_cache",
blockWorldClick = true
})
function __module.UpdateImports()
Logger = M__share_base_logger.Logger
ASSET_KEYS = M__framework_resource_asset_catalog.ASSET_KEYS
RegisterUIConfig = M__framework_ui_ui_config.RegisterUIConfig
UIWindow = M__framework_ui_ui_window.UIWindow
SETTING_KEYS = M__game_setting_setting_service.SETTING_KEYS
end
@@ -0,0 +1,62 @@
local ____lualib = require("lualib_bundle")
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local __TS__New = ____lualib.__TS__New
local ____exports = __module.env
local M__share_base_scoped_object = __MODULE__.Import("share.base.scoped_object", __module)
local ScopedObject = M__share_base_scoped_object.ScopedObject
local M__share_event_event_hub = __MODULE__.Import("share.event.event_hub", __module)
local EventHub = M__share_event_event_hub.EventHub
--- 阶段 0 冻结的首期全局布尔设置键
____exports.SETTING_KEYS = {SOUND_ENABLED = "mini_settings.sound_enabled"}
____exports.SettingService = __TS__DefineClass("SettingService", __module)
local SettingService = ____exports.SettingService
SettingService.name = "SettingService"
__TS__ClassExtends(SettingService, ScopedObject)
function SettingService.prototype.____constructor(self, saveManager, slotIdentity)
ScopedObject.prototype.____constructor(self)
self.events = __TS__New(EventHub, "SettingEvents")
self.store = saveManager:GetOrOpenStore("setting", slotIdentity, 1)
end
function SettingService.prototype.GetStore(self)
return self.store
end
function SettingService.prototype.GetBool(self, key, defaultValue)
local val = self.store:Get(key)
if type(val) == "boolean" then
return val
end
return defaultValue
end
function SettingService.prototype.SetBool(self, key, value)
local prev = self:GetBool(key, not value)
self.store:Set(key, value)
if prev ~= value then
self.events.emit.OnBoolSettingChanged(key, value)
end
end
function SettingService.prototype.GetSoundEnabled(self)
return self:GetBool(____exports.SETTING_KEYS.SOUND_ENABLED, true)
end
function SettingService.prototype.SetSoundEnabled(self, enabled)
self:SetBool(____exports.SETTING_KEYS.SOUND_ENABLED, enabled)
end
function SettingService.prototype.ToggleSoundEnabled(self)
local nextVal = not self:GetSoundEnabled()
self:SetSoundEnabled(nextVal)
return nextVal
end
function SettingService.prototype.Flush(self)
return self.store:Flush()
end
function SettingService.prototype.Dispose(self)
if self:IsDisposed() then
return
end
self.store:Flush()
self.events:Dispose()
ScopedObject.prototype.Dispose(self)
end
function __module.UpdateImports()
ScopedObject = M__share_base_scoped_object.ScopedObject
EventHub = M__share_event_event_hub.EventHub
end