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:
1 parent
783dccf53d
commit
3572f2da43
206 files changed
+14442
-13186
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user