@quenty/settings 11.23.3-canary.550.afa1b3b.0 → 11.23.4-canary.11a5dcf.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -1
- package/package.json +29 -29
- package/src/Client/Player/PlayerSettingsClient.lua +4 -4
- package/src/Client/SettingsServiceClient.lua +21 -21
- package/src/Server/Cmdr/SettingsCmdrService.lua +3 -3
- package/src/Server/Player/PlayerHasSettings.lua +22 -19
- package/src/Server/Player/PlayerSettings.lua +4 -4
- package/src/Server/SettingsService.lua +2 -2
- package/src/Shared/Cmdr/SettingsCmdrUtils.lua +12 -13
- package/src/Shared/Interface/PlayerSettingsInterface.lua +8 -8
- package/src/Shared/Player/PlayerSettingsBase.lua +6 -6
- package/src/Shared/Player/PlayerSettingsConstants.lua +8 -8
- package/src/Shared/Player/PlayerSettingsUtils.lua +2 -2
- package/src/Shared/Setting/SettingDefinition.lua +5 -6
- package/src/Shared/Setting/SettingDefinitionProvider.lua +7 -6
- package/src/Shared/Setting/SettingProperty.lua +12 -12
- package/src/Shared/SettingsDataService.lua +3 -2
- package/test/scripts/Client/ClientMain.client.lua +1 -1
- package/test/scripts/Server/ServerMain.server.lua +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [11.23.
|
|
6
|
+
## [11.23.4-canary.11a5dcf.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/settings@11.23.3...@quenty/settings@11.23.4-canary.11a5dcf.0) (2025-05-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Additional type checking updates ([05ba29a](https://github.com/Quenty/NevermoreEngine/commit/05ba29a03efc9f3feed74b34f1d9dfb237496214))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [11.23.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/settings@11.23.2...@quenty/settings@11.23.3) (2025-04-10)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/settings
|
|
9
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/settings",
|
|
3
|
-
"version": "11.23.
|
|
3
|
+
"version": "11.23.4-canary.11a5dcf.0",
|
|
4
4
|
"description": "Centralized player settings service",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,38 +25,38 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/attributeutils": "14.17.
|
|
29
|
-
"@quenty/baseobject": "10.8.
|
|
30
|
-
"@quenty/binder": "14.19.
|
|
31
|
-
"@quenty/brio": "14.17.
|
|
32
|
-
"@quenty/cmdrservice": "13.22.
|
|
33
|
-
"@quenty/datastore": "13.20.
|
|
34
|
-
"@quenty/ducktype": "5.8.
|
|
28
|
+
"@quenty/attributeutils": "14.17.4-canary.11a5dcf.0",
|
|
29
|
+
"@quenty/baseobject": "10.8.4-canary.11a5dcf.0",
|
|
30
|
+
"@quenty/binder": "14.19.4-canary.11a5dcf.0",
|
|
31
|
+
"@quenty/brio": "14.17.4-canary.11a5dcf.0",
|
|
32
|
+
"@quenty/cmdrservice": "13.22.4-canary.11a5dcf.0",
|
|
33
|
+
"@quenty/datastore": "13.20.4-canary.11a5dcf.0",
|
|
34
|
+
"@quenty/ducktype": "5.8.5-canary.11a5dcf.0",
|
|
35
35
|
"@quenty/enumutils": "3.4.2",
|
|
36
|
-
"@quenty/instanceutils": "13.17.
|
|
37
|
-
"@quenty/jsonutils": "10.10.
|
|
38
|
-
"@quenty/loader": "10.8.
|
|
39
|
-
"@quenty/maid": "3.4.
|
|
40
|
-
"@quenty/observablecollection": "12.20.
|
|
41
|
-
"@quenty/playerbinder": "14.19.
|
|
42
|
-
"@quenty/playerutils": "8.17.
|
|
43
|
-
"@quenty/remotefunctionutils": "10.10.
|
|
44
|
-
"@quenty/remoting": "12.18.
|
|
45
|
-
"@quenty/rx": "13.17.
|
|
46
|
-
"@quenty/rxbinderutils": "14.19.
|
|
47
|
-
"@quenty/rxsignal": "7.17.
|
|
48
|
-
"@quenty/servicebag": "11.11.
|
|
49
|
-
"@quenty/signal": "7.10.
|
|
50
|
-
"@quenty/statestack": "14.18.
|
|
36
|
+
"@quenty/instanceutils": "13.17.4-canary.11a5dcf.0",
|
|
37
|
+
"@quenty/jsonutils": "10.10.5-canary.11a5dcf.0",
|
|
38
|
+
"@quenty/loader": "10.8.4-canary.11a5dcf.0",
|
|
39
|
+
"@quenty/maid": "3.4.4-canary.11a5dcf.0",
|
|
40
|
+
"@quenty/observablecollection": "12.20.4-canary.11a5dcf.0",
|
|
41
|
+
"@quenty/playerbinder": "14.19.4-canary.11a5dcf.0",
|
|
42
|
+
"@quenty/playerutils": "8.17.4-canary.11a5dcf.0",
|
|
43
|
+
"@quenty/remotefunctionutils": "10.10.5-canary.11a5dcf.0",
|
|
44
|
+
"@quenty/remoting": "12.18.4-canary.11a5dcf.0",
|
|
45
|
+
"@quenty/rx": "13.17.4-canary.11a5dcf.0",
|
|
46
|
+
"@quenty/rxbinderutils": "14.19.4-canary.11a5dcf.0",
|
|
47
|
+
"@quenty/rxsignal": "7.17.4-canary.11a5dcf.0",
|
|
48
|
+
"@quenty/servicebag": "11.11.5-canary.11a5dcf.0",
|
|
49
|
+
"@quenty/signal": "7.10.4-canary.11a5dcf.0",
|
|
50
|
+
"@quenty/statestack": "14.18.4-canary.11a5dcf.0",
|
|
51
51
|
"@quenty/string": "3.3.3",
|
|
52
|
-
"@quenty/symbol": "3.4.
|
|
53
|
-
"@quenty/table": "3.7.
|
|
54
|
-
"@quenty/throttle": "10.9.
|
|
55
|
-
"@quenty/tie": "10.20.
|
|
56
|
-
"@quenty/valueobject": "13.17.
|
|
52
|
+
"@quenty/symbol": "3.4.3-canary.11a5dcf.0",
|
|
53
|
+
"@quenty/table": "3.7.5-canary.11a5dcf.0",
|
|
54
|
+
"@quenty/throttle": "10.9.4-canary.11a5dcf.0",
|
|
55
|
+
"@quenty/tie": "10.20.4-canary.11a5dcf.0",
|
|
56
|
+
"@quenty/valueobject": "13.17.4-canary.11a5dcf.0"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "11a5dcf7d4c7a0bfbf3337e97d30e8346ea09d3f"
|
|
62
62
|
}
|
|
@@ -19,12 +19,12 @@ local PlayerSettingsBase = require("PlayerSettingsBase")
|
|
|
19
19
|
local PlayerSettingsConstants = require("PlayerSettingsConstants")
|
|
20
20
|
local PlayerSettingsInterface = require("PlayerSettingsInterface")
|
|
21
21
|
local PlayerSettingsUtils = require("PlayerSettingsUtils")
|
|
22
|
+
local Promise = require("Promise")
|
|
22
23
|
local Remoting = require("Remoting")
|
|
24
|
+
local ServiceBag = require("ServiceBag")
|
|
23
25
|
local Symbol = require("Symbol")
|
|
24
26
|
local ThrottledFunction = require("ThrottledFunction")
|
|
25
27
|
local ValueObject = require("ValueObject")
|
|
26
|
-
local _ServiceBag = require("ServiceBag")
|
|
27
|
-
local _Promise = require("Promise")
|
|
28
28
|
|
|
29
29
|
local UNSET_VALUE = Symbol.named("unsetValue")
|
|
30
30
|
|
|
@@ -38,7 +38,7 @@ export type PlayerSettingsClient = typeof(setmetatable(
|
|
|
38
38
|
_pendingReplicationDataInTransit: ValueObject.ValueObject<any>,
|
|
39
39
|
_toReplicate: { [any]: any? }?,
|
|
40
40
|
_toReplicateCallbacks: { [string]: { [any]: any } },
|
|
41
|
-
_currentReplicationRequest:
|
|
41
|
+
_currentReplicationRequest: Promise.Promise<()>?,
|
|
42
42
|
_queueSendSettingsFunc: ThrottledFunction.ThrottledFunction<()>,
|
|
43
43
|
},
|
|
44
44
|
{} :: typeof({ __index = PlayerSettingsClient })
|
|
@@ -51,7 +51,7 @@ export type PlayerSettingsClient = typeof(setmetatable(
|
|
|
51
51
|
@param serviceBag ServiceBag
|
|
52
52
|
@return PlayerSettingsClient
|
|
53
53
|
]=]
|
|
54
|
-
function PlayerSettingsClient.new(folder: Folder, serviceBag:
|
|
54
|
+
function PlayerSettingsClient.new(folder: Folder, serviceBag: ServiceBag.ServiceBag): PlayerSettingsClient
|
|
55
55
|
local self: PlayerSettingsClient =
|
|
56
56
|
setmetatable(PlayerSettingsBase.new(folder, serviceBag) :: any, PlayerSettingsClient)
|
|
57
57
|
|
|
@@ -11,20 +11,20 @@ local require = require(script.Parent.loader).load(script)
|
|
|
11
11
|
|
|
12
12
|
local Players = game:GetService("Players")
|
|
13
13
|
|
|
14
|
+
local Brio = require("Brio")
|
|
15
|
+
local CancelToken = require("CancelToken")
|
|
14
16
|
local Maid = require("Maid")
|
|
17
|
+
local Observable = require("Observable")
|
|
18
|
+
local PlayerSettingsClient = require("PlayerSettingsClient")
|
|
19
|
+
local Promise = require("Promise")
|
|
20
|
+
local ServiceBag = require("ServiceBag")
|
|
15
21
|
local SettingsCmdrUtils = require("SettingsCmdrUtils")
|
|
16
|
-
local _ServiceBag = require("ServiceBag")
|
|
17
|
-
local _PlayerSettingsClient = require("PlayerSettingsClient")
|
|
18
|
-
local _Observable = require("Observable")
|
|
19
|
-
local _Brio = require("Brio")
|
|
20
|
-
local _CancelToken = require("CancelToken")
|
|
21
|
-
local _Promise = require("Promise")
|
|
22
22
|
|
|
23
23
|
local SettingsServiceClient = {}
|
|
24
24
|
|
|
25
25
|
export type SettingsServiceClient = typeof(setmetatable(
|
|
26
26
|
{} :: {
|
|
27
|
-
_serviceBag:
|
|
27
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
28
28
|
_maid: Maid.Maid,
|
|
29
29
|
_settingsDataService: any,
|
|
30
30
|
},
|
|
@@ -36,7 +36,7 @@ export type SettingsServiceClient = typeof(setmetatable(
|
|
|
36
36
|
|
|
37
37
|
@param serviceBag ServiceBag
|
|
38
38
|
]=]
|
|
39
|
-
function SettingsServiceClient.Init(self: SettingsServiceClient, serviceBag:
|
|
39
|
+
function SettingsServiceClient.Init(self: SettingsServiceClient, serviceBag: ServiceBag.ServiceBag)
|
|
40
40
|
assert(not (self :: any)._serviceBag, "Already initialized")
|
|
41
41
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
42
42
|
self._maid = Maid.new()
|
|
@@ -61,7 +61,7 @@ end
|
|
|
61
61
|
]=]
|
|
62
62
|
function SettingsServiceClient.GetLocalPlayerSettings(
|
|
63
63
|
self: SettingsServiceClient
|
|
64
|
-
):
|
|
64
|
+
): PlayerSettingsClient.PlayerSettingsClient?
|
|
65
65
|
return self:GetPlayerSettings(Players.LocalPlayer)
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -70,8 +70,8 @@ end
|
|
|
70
70
|
|
|
71
71
|
@return Observable<Brio<PlayerSettingsClient>>
|
|
72
72
|
]=]
|
|
73
|
-
function SettingsServiceClient.ObserveLocalPlayerSettingsBrio(self: SettingsServiceClient):
|
|
74
|
-
|
|
73
|
+
function SettingsServiceClient.ObserveLocalPlayerSettingsBrio(self: SettingsServiceClient): Observable.Observable<
|
|
74
|
+
Brio.Brio<PlayerSettingsClient.PlayerSettingsClient>
|
|
75
75
|
>
|
|
76
76
|
return self:ObservePlayerSettingsBrio(Players.LocalPlayer)
|
|
77
77
|
end
|
|
@@ -81,8 +81,8 @@ end
|
|
|
81
81
|
|
|
82
82
|
@return Observable<PlayerSettingsClient | nil>
|
|
83
83
|
]=]
|
|
84
|
-
function SettingsServiceClient.ObserveLocalPlayerSettings(self: SettingsServiceClient):
|
|
85
|
-
|
|
84
|
+
function SettingsServiceClient.ObserveLocalPlayerSettings(self: SettingsServiceClient): Observable.Observable<
|
|
85
|
+
PlayerSettingsClient.PlayerSettingsClient
|
|
86
86
|
>
|
|
87
87
|
return self:ObservePlayerSettings(Players.LocalPlayer)
|
|
88
88
|
end
|
|
@@ -95,8 +95,8 @@ end
|
|
|
95
95
|
]=]
|
|
96
96
|
function SettingsServiceClient.PromiseLocalPlayerSettings(
|
|
97
97
|
self: SettingsServiceClient,
|
|
98
|
-
cancelToken:
|
|
99
|
-
):
|
|
98
|
+
cancelToken: CancelToken.CancelToken
|
|
99
|
+
): Promise.Promise<PlayerSettingsClient.PlayerSettingsClient>
|
|
100
100
|
return self:PromisePlayerSettings(Players.LocalPlayer, cancelToken)
|
|
101
101
|
end
|
|
102
102
|
|
|
@@ -109,7 +109,7 @@ end
|
|
|
109
109
|
function SettingsServiceClient.ObservePlayerSettings(
|
|
110
110
|
self: SettingsServiceClient,
|
|
111
111
|
player: Player
|
|
112
|
-
):
|
|
112
|
+
): Observable.Observable<PlayerSettingsClient.PlayerSettingsClient>
|
|
113
113
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
114
114
|
|
|
115
115
|
return self._settingsDataService:ObservePlayerSettings(player)
|
|
@@ -124,8 +124,8 @@ end
|
|
|
124
124
|
function SettingsServiceClient.ObservePlayerSettingsBrio(
|
|
125
125
|
self: SettingsServiceClient,
|
|
126
126
|
player: Player
|
|
127
|
-
):
|
|
128
|
-
|
|
127
|
+
): Observable.Observable<
|
|
128
|
+
Brio.Brio<PlayerSettingsClient.PlayerSettingsClient>
|
|
129
129
|
>
|
|
130
130
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
131
131
|
|
|
@@ -141,7 +141,7 @@ end
|
|
|
141
141
|
function SettingsServiceClient.GetPlayerSettings(
|
|
142
142
|
self: SettingsServiceClient,
|
|
143
143
|
player: Player
|
|
144
|
-
):
|
|
144
|
+
): PlayerSettingsClient.PlayerSettingsClient?
|
|
145
145
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
146
146
|
|
|
147
147
|
return self._settingsDataService:GetPlayerSettings(player)
|
|
@@ -157,8 +157,8 @@ end
|
|
|
157
157
|
function SettingsServiceClient.PromisePlayerSettings(
|
|
158
158
|
self: SettingsServiceClient,
|
|
159
159
|
player: Player,
|
|
160
|
-
cancelToken:
|
|
161
|
-
):
|
|
160
|
+
cancelToken: CancelToken.CancelToken
|
|
161
|
+
): Promise.Promise<PlayerSettingsClient.PlayerSettingsClient>
|
|
162
162
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
163
163
|
|
|
164
164
|
return self._settingsDataService:PromisePlayerSettings(player, cancelToken)
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
local require = require(script.Parent.loader).load(script)
|
|
8
8
|
|
|
9
|
+
local Maid = require("Maid")
|
|
9
10
|
local PlayerUtils = require("PlayerUtils")
|
|
11
|
+
local ServiceBag = require("ServiceBag")
|
|
10
12
|
local SettingsCmdrUtils = require("SettingsCmdrUtils")
|
|
11
|
-
local Maid = require("Maid")
|
|
12
|
-
local _ServiceBag = require("ServiceBag")
|
|
13
13
|
|
|
14
14
|
local SettingsCmdrService = {}
|
|
15
15
|
SettingsCmdrService.ServiceName = "SettingsCmdrService"
|
|
16
16
|
|
|
17
|
-
function SettingsCmdrService:Init(serviceBag:
|
|
17
|
+
function SettingsCmdrService:Init(serviceBag: ServiceBag.ServiceBag)
|
|
18
18
|
assert(not self._serviceBag, "Already initialized")
|
|
19
19
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
20
20
|
self._maid = Maid.new()
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
local require = require(script.Parent.loader).load(script)
|
|
6
6
|
|
|
7
7
|
local BaseObject = require("BaseObject")
|
|
8
|
-
local PlayerSettingsUtils = require("PlayerSettingsUtils")
|
|
9
|
-
local PlayerSettings = require("PlayerSettings")
|
|
10
|
-
local PlayerDataStoreService = require("PlayerDataStoreService")
|
|
11
8
|
local DataStoreStringUtils = require("DataStoreStringUtils")
|
|
12
|
-
local PlayerSettingsConstants = require("PlayerSettingsConstants")
|
|
13
9
|
local PlayerBinder = require("PlayerBinder")
|
|
10
|
+
local PlayerDataStoreService = require("PlayerDataStoreService")
|
|
11
|
+
local PlayerSettings = require("PlayerSettings")
|
|
12
|
+
local PlayerSettingsConstants = require("PlayerSettingsConstants")
|
|
13
|
+
local PlayerSettingsUtils = require("PlayerSettingsUtils")
|
|
14
|
+
local ServiceBag = require("ServiceBag")
|
|
14
15
|
|
|
15
16
|
local PlayerHasSettings = setmetatable({}, BaseObject)
|
|
16
17
|
PlayerHasSettings.ClassName = "PlayerHasSettings"
|
|
@@ -18,7 +19,7 @@ PlayerHasSettings.__index = PlayerHasSettings
|
|
|
18
19
|
|
|
19
20
|
export type PlayerHasSettings = typeof(setmetatable(
|
|
20
21
|
{} :: {
|
|
21
|
-
_serviceBag:
|
|
22
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
22
23
|
_playerSettingsBinder: PlayerSettings.PlayerSettings,
|
|
23
24
|
_playerDataStoreService: PlayerDataStoreService.PlayerDataStoreService,
|
|
24
25
|
},
|
|
@@ -40,24 +41,24 @@ end
|
|
|
40
41
|
function PlayerHasSettings:_promiseLoadSettings()
|
|
41
42
|
self._settings = self._maid:Add(PlayerSettingsUtils.create())
|
|
42
43
|
|
|
43
|
-
self._maid
|
|
44
|
+
self._maid
|
|
45
|
+
:GivePromise(self._playerDataStoreService:PromiseDataStore(self._obj))
|
|
44
46
|
:Then(function(dataStore)
|
|
45
47
|
-- Ensure we've fully loaded before we parent.
|
|
46
48
|
-- This should ensure the cache is mostly instant.
|
|
47
49
|
|
|
48
50
|
local subStore = dataStore:GetSubStore("settings")
|
|
49
51
|
|
|
50
|
-
return dataStore:Load("settings", {})
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
self
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
end)
|
|
52
|
+
return dataStore:Load("settings", {}):Then(function(settings)
|
|
53
|
+
for settingName, value in settings do
|
|
54
|
+
local attributeName = PlayerSettingsUtils.getAttributeName(settingName)
|
|
55
|
+
self._settings:SetAttribute(attributeName, PlayerSettingsUtils.encodeForAttribute(value))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
self._maid:GiveTask(self._settings.AttributeChanged:Connect(function(attributeName)
|
|
59
|
+
self:_handleAttributeChanged(subStore, attributeName)
|
|
60
|
+
end))
|
|
61
|
+
end)
|
|
61
62
|
end)
|
|
62
63
|
:Catch(function(err)
|
|
63
64
|
warn(string.format("[PlayerHasSettings] - Failed to load settings for player. %s", tostring(err)))
|
|
@@ -84,7 +85,9 @@ function PlayerHasSettings:_handleAttributeChanged(subStore, attributeName)
|
|
|
84
85
|
|
|
85
86
|
if type(newValue) == "string" then
|
|
86
87
|
if (#settingName + #newValue) > PlayerSettingsConstants.MAX_SETTINGS_LENGTH then
|
|
87
|
-
warn(
|
|
88
|
+
warn(
|
|
89
|
+
string.format("[PlayerSettingsClient.SetValue] - Setting is too long for %q. Cannot save.", settingName)
|
|
90
|
+
)
|
|
88
91
|
return
|
|
89
92
|
end
|
|
90
93
|
-- TODO: JSON encode and check length for ther scenarios
|
|
@@ -93,4 +96,4 @@ function PlayerHasSettings:_handleAttributeChanged(subStore, attributeName)
|
|
|
93
96
|
subStore:Store(settingName, newValue)
|
|
94
97
|
end
|
|
95
98
|
|
|
96
|
-
return PlayerBinder.new("PlayerHasSettings", PlayerHasSettings)
|
|
99
|
+
return PlayerBinder.new("PlayerHasSettings", PlayerHasSettings)
|
|
@@ -12,8 +12,8 @@ local PlayerSettingsConstants = require("PlayerSettingsConstants")
|
|
|
12
12
|
local PlayerSettingsInterface = require("PlayerSettingsInterface")
|
|
13
13
|
local PlayerSettingsUtils = require("PlayerSettingsUtils")
|
|
14
14
|
local Remoting = require("Remoting")
|
|
15
|
+
local ServiceBag = require("ServiceBag")
|
|
15
16
|
local SettingsDataService = require("SettingsDataService")
|
|
16
|
-
local _ServiceBag = require("ServiceBag")
|
|
17
17
|
|
|
18
18
|
local PlayerSettings = setmetatable({}, PlayerSettingsBase)
|
|
19
19
|
PlayerSettings.ClassName = "PlayerSettings"
|
|
@@ -21,18 +21,18 @@ PlayerSettings.__index = PlayerSettings
|
|
|
21
21
|
|
|
22
22
|
export type PlayerSettings = typeof(setmetatable(
|
|
23
23
|
{} :: {
|
|
24
|
-
_serviceBag:
|
|
24
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
25
25
|
_remoting: Remoting.Remoting,
|
|
26
26
|
_settingsDataService: SettingsDataService.SettingsDataService,
|
|
27
27
|
},
|
|
28
28
|
{} :: typeof({ __index = PlayerSettings })
|
|
29
29
|
)) & PlayerSettingsBase.PlayerSettingsBase
|
|
30
30
|
|
|
31
|
-
function PlayerSettings.new(folder: Folder, serviceBag:
|
|
31
|
+
function PlayerSettings.new(folder: Folder, serviceBag: ServiceBag.ServiceBag): PlayerSettings
|
|
32
32
|
local self: PlayerSettings = setmetatable(PlayerSettingsBase.new(folder, serviceBag) :: any, PlayerSettings)
|
|
33
33
|
|
|
34
34
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
35
|
-
self._settingsDataService = self._serviceBag:GetService(SettingsDataService)
|
|
35
|
+
self._settingsDataService = self._serviceBag:GetService(SettingsDataService) :: any
|
|
36
36
|
|
|
37
37
|
self:_setupRemoting()
|
|
38
38
|
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
local require = require(script.Parent.loader).load(script)
|
|
8
8
|
|
|
9
9
|
local Maid = require("Maid")
|
|
10
|
-
local
|
|
10
|
+
local ServiceBag = require("ServiceBag")
|
|
11
11
|
|
|
12
12
|
local SettingsService = {}
|
|
13
13
|
SettingsService.ServiceName = "SettingsService"
|
|
14
14
|
|
|
15
|
-
function SettingsService:Init(serviceBag:
|
|
15
|
+
function SettingsService:Init(serviceBag: ServiceBag.ServiceBag)
|
|
16
16
|
assert(not self._serviceBag, "Already initialized")
|
|
17
17
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
18
18
|
self._maid = Maid.new()
|
|
@@ -18,23 +18,23 @@ function SettingsCmdrUtils.registerSettingDefinition(cmdr, serviceBag)
|
|
|
18
18
|
Transform = function(text)
|
|
19
19
|
local definitions = settingsDataService:GetSettingDefinitions()
|
|
20
20
|
local settingNames = {}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
for _, settingDefinition in definitions do
|
|
22
|
+
table.insert(settingNames, settingDefinition:GetSettingName())
|
|
23
|
+
end
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
end
|
|
25
|
+
local find = cmdr.Util.MakeFuzzyFinder(settingNames)
|
|
26
|
+
return find(text)
|
|
27
|
+
end,
|
|
28
28
|
Validate = function(keys)
|
|
29
|
-
|
|
29
|
+
return #keys > 0, "No item model with that name could be found."
|
|
30
30
|
end,
|
|
31
31
|
Autocomplete = function(keys)
|
|
32
|
-
|
|
32
|
+
return keys
|
|
33
33
|
end,
|
|
34
34
|
Parse = function(keys)
|
|
35
|
-
|
|
35
|
+
local name = keys[1]
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
local definitions = settingsDataService:GetSettingDefinitions()
|
|
38
38
|
for _, settingDefinition in definitions do
|
|
39
39
|
if settingDefinition:GetSettingName() == name then
|
|
40
40
|
return settingDefinition
|
|
@@ -42,12 +42,11 @@ function SettingsCmdrUtils.registerSettingDefinition(cmdr, serviceBag)
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
return nil
|
|
45
|
-
end
|
|
45
|
+
end,
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
cmdr.Registry:RegisterType("settingDefinition", settingDefinitionType)
|
|
49
49
|
cmdr.Registry:RegisterType("settingDefinitions", cmdr.Util.MakeListableType(settingDefinitionType))
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
return SettingsCmdrUtils
|
|
52
|
+
return SettingsCmdrUtils
|
|
@@ -7,11 +7,11 @@ local require = require(script.Parent.loader).load(script)
|
|
|
7
7
|
local TieDefinition = require("TieDefinition")
|
|
8
8
|
|
|
9
9
|
return TieDefinition.new("PlayerSettings", {
|
|
10
|
-
GetSettingProperty = TieDefinition.Types.METHOD
|
|
11
|
-
GetValue = TieDefinition.Types.METHOD
|
|
12
|
-
SetValue = TieDefinition.Types.METHOD
|
|
13
|
-
ObserveValue = TieDefinition.Types.METHOD
|
|
14
|
-
RestoreDefault = TieDefinition.Types.METHOD
|
|
15
|
-
EnsureInitialized = TieDefinition.Types.METHOD
|
|
16
|
-
GetPlayer = TieDefinition.Types.METHOD
|
|
17
|
-
})
|
|
10
|
+
GetSettingProperty = TieDefinition.Types.METHOD,
|
|
11
|
+
GetValue = TieDefinition.Types.METHOD,
|
|
12
|
+
SetValue = TieDefinition.Types.METHOD,
|
|
13
|
+
ObserveValue = TieDefinition.Types.METHOD,
|
|
14
|
+
RestoreDefault = TieDefinition.Types.METHOD,
|
|
15
|
+
EnsureInitialized = TieDefinition.Types.METHOD,
|
|
16
|
+
GetPlayer = TieDefinition.Types.METHOD,
|
|
17
|
+
})
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
local require = require(script.Parent.loader).load(script)
|
|
9
9
|
|
|
10
10
|
local BaseObject = require("BaseObject")
|
|
11
|
+
local DataStoreStringUtils = require("DataStoreStringUtils")
|
|
11
12
|
local PlayerSettingsUtils = require("PlayerSettingsUtils")
|
|
13
|
+
local Rx = require("Rx")
|
|
12
14
|
local RxAttributeUtils = require("RxAttributeUtils")
|
|
15
|
+
local ServiceBag = require("ServiceBag")
|
|
13
16
|
local SettingDefinition = require("SettingDefinition")
|
|
14
|
-
local Rx = require("Rx")
|
|
15
|
-
local DataStoreStringUtils = require("DataStoreStringUtils")
|
|
16
|
-
local _ServiceBag = require("ServiceBag")
|
|
17
17
|
|
|
18
18
|
local PlayerSettingsBase = setmetatable({}, BaseObject)
|
|
19
19
|
PlayerSettingsBase.ClassName = "PlayerSettingsBase"
|
|
@@ -22,7 +22,7 @@ PlayerSettingsBase.__index = PlayerSettingsBase
|
|
|
22
22
|
export type PlayerSettingsBase = typeof(setmetatable(
|
|
23
23
|
{} :: {
|
|
24
24
|
_obj: Folder,
|
|
25
|
-
_serviceBag:
|
|
25
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
26
26
|
},
|
|
27
27
|
{} :: typeof({ __index = PlayerSettingsBase })
|
|
28
28
|
)) & BaseObject.BaseObject
|
|
@@ -34,7 +34,7 @@ export type PlayerSettingsBase = typeof(setmetatable(
|
|
|
34
34
|
@param serviceBag ServiceBag
|
|
35
35
|
@return PlayerSettingsBase
|
|
36
36
|
]=]
|
|
37
|
-
function PlayerSettingsBase.new(folder: Folder, serviceBag:
|
|
37
|
+
function PlayerSettingsBase.new(folder: Folder, serviceBag: ServiceBag.ServiceBag): PlayerSettingsBase
|
|
38
38
|
local self: PlayerSettingsBase = setmetatable(BaseObject.new(folder) :: any, PlayerSettingsBase)
|
|
39
39
|
|
|
40
40
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
@@ -164,4 +164,4 @@ function PlayerSettingsBase.EnsureInitialized(_self: PlayerSettingsBase, setting
|
|
|
164
164
|
-- noop
|
|
165
165
|
end
|
|
166
166
|
|
|
167
|
-
return PlayerSettingsBase
|
|
167
|
+
return PlayerSettingsBase
|
|
@@ -8,12 +8,12 @@ local require = require(script.Parent.loader).load(script)
|
|
|
8
8
|
local Table = require("Table")
|
|
9
9
|
|
|
10
10
|
return Table.readonly({
|
|
11
|
-
SETTING_ATTRIBUTE_PREFIX = "Setting_"
|
|
12
|
-
SETTING_DEFAULT_VALUE_SUFFIX = "_Default"
|
|
13
|
-
SETTING_LOCAL_USER_VALUE_SUFFIX = "_Client"
|
|
11
|
+
SETTING_ATTRIBUTE_PREFIX = "Setting_",
|
|
12
|
+
SETTING_DEFAULT_VALUE_SUFFIX = "_Default",
|
|
13
|
+
SETTING_LOCAL_USER_VALUE_SUFFIX = "_Client",
|
|
14
14
|
|
|
15
|
-
PLAYER_SETTINGS_NAME = "PlayerSettings"
|
|
16
|
-
REMOTE_FUNCTION_NAME = "PlayerSettingsRemoteFunction"
|
|
17
|
-
REQUEST_UPDATE_SETTINGS = "requestUpdateSettings"
|
|
18
|
-
MAX_SETTINGS_LENGTH = 2048
|
|
19
|
-
})
|
|
15
|
+
PLAYER_SETTINGS_NAME = "PlayerSettings",
|
|
16
|
+
REMOTE_FUNCTION_NAME = "PlayerSettingsRemoteFunction",
|
|
17
|
+
REQUEST_UPDATE_SETTINGS = "requestUpdateSettings",
|
|
18
|
+
MAX_SETTINGS_LENGTH = 2048,
|
|
19
|
+
})
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
local require = require(script.Parent.loader).load(script)
|
|
9
9
|
|
|
10
|
+
local DataStoreStringUtils = require("DataStoreStringUtils")
|
|
11
|
+
local EnumUtils = require("EnumUtils")
|
|
10
12
|
local PlayerSettingsConstants = require("PlayerSettingsConstants")
|
|
11
13
|
local String = require("String")
|
|
12
|
-
local EnumUtils = require("EnumUtils")
|
|
13
|
-
local DataStoreStringUtils = require("DataStoreStringUtils")
|
|
14
14
|
|
|
15
15
|
local PlayerSettingsUtils = {}
|
|
16
16
|
|
|
@@ -22,12 +22,11 @@ local require = require(script.Parent.loader).load(script)
|
|
|
22
22
|
|
|
23
23
|
local Players = game:GetService("Players")
|
|
24
24
|
|
|
25
|
-
local SettingsDataService = require("SettingsDataService")
|
|
26
|
-
local SettingProperty = require("SettingProperty")
|
|
27
|
-
local ServiceBag = require("ServiceBag")
|
|
28
25
|
local DuckTypeUtils = require("DuckTypeUtils")
|
|
29
26
|
local Maid = require("Maid")
|
|
30
|
-
local
|
|
27
|
+
local ServiceBag = require("ServiceBag")
|
|
28
|
+
local SettingProperty = require("SettingProperty")
|
|
29
|
+
local SettingsDataService = require("SettingsDataService")
|
|
31
30
|
|
|
32
31
|
local SettingDefinition = {}
|
|
33
32
|
SettingDefinition.ClassName = "SettingDefinition"
|
|
@@ -60,7 +59,7 @@ end
|
|
|
60
59
|
|
|
61
60
|
@param serviceBag ServiceBag
|
|
62
61
|
]=]
|
|
63
|
-
function SettingDefinition:Init(serviceBag:
|
|
62
|
+
function SettingDefinition:Init(serviceBag: ServiceBag.ServiceBag)
|
|
64
63
|
assert(serviceBag, "No serviceBag")
|
|
65
64
|
assert(not self._maid, "Already initialized")
|
|
66
65
|
|
|
@@ -195,4 +194,4 @@ function SettingDefinition:Destroy()
|
|
|
195
194
|
self._maid:DoCleaning()
|
|
196
195
|
end
|
|
197
196
|
|
|
198
|
-
return SettingDefinition
|
|
197
|
+
return SettingDefinition
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
local require = require(script.Parent.loader).load(script)
|
|
28
28
|
|
|
29
29
|
local Maid = require("Maid")
|
|
30
|
+
local ServiceBag = require("ServiceBag")
|
|
30
31
|
local SettingDefinition = require("SettingDefinition")
|
|
31
|
-
local _ServiceBag = require("ServiceBag")
|
|
32
32
|
|
|
33
33
|
local SettingDefinitionProvider = {}
|
|
34
34
|
SettingDefinitionProvider.ClassName = "SettingDefinitionProvider"
|
|
@@ -105,7 +105,7 @@ end
|
|
|
105
105
|
|
|
106
106
|
@param serviceBag ServiceBag
|
|
107
107
|
]=]
|
|
108
|
-
function SettingDefinitionProvider:Init(serviceBag:
|
|
108
|
+
function SettingDefinitionProvider:Init(serviceBag: ServiceBag.ServiceBag)
|
|
109
109
|
assert(serviceBag, "No serviceBag")
|
|
110
110
|
assert(not self._maid, "Already initialized")
|
|
111
111
|
|
|
@@ -176,12 +176,13 @@ function SettingDefinitionProvider:__index(index)
|
|
|
176
176
|
error("[SettingDefinitionProvider] - Cannot index provider with nil value")
|
|
177
177
|
elseif SettingDefinitionProvider[index] then
|
|
178
178
|
return SettingDefinitionProvider[index]
|
|
179
|
-
elseif
|
|
179
|
+
elseif
|
|
180
|
+
index == "_lookup"
|
|
180
181
|
or index == "_settingDefinitionList"
|
|
181
182
|
or index == "_maid"
|
|
182
183
|
or index == "_initializedDefinitionLookup"
|
|
183
|
-
or index == "_serviceBag"
|
|
184
|
-
|
|
184
|
+
or index == "_serviceBag"
|
|
185
|
+
then
|
|
185
186
|
return rawget(self, index)
|
|
186
187
|
elseif type(index) == "string" then
|
|
187
188
|
local lookup = rawget(self, "_lookup")
|
|
@@ -228,4 +229,4 @@ function SettingDefinitionProvider:Destroy()
|
|
|
228
229
|
self._maid:DoCleaning()
|
|
229
230
|
end
|
|
230
231
|
|
|
231
|
-
return SettingDefinitionProvider
|
|
232
|
+
return SettingDefinitionProvider
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
local require = require(script.Parent.loader).load(script)
|
|
7
7
|
|
|
8
|
-
local
|
|
8
|
+
local Observable = require("Observable")
|
|
9
|
+
local Promise = require("Promise")
|
|
9
10
|
local Rx = require("Rx")
|
|
10
11
|
local RxSignal = require("RxSignal")
|
|
11
|
-
local
|
|
12
|
-
local
|
|
13
|
-
local _Observable = require("Observable")
|
|
12
|
+
local ServiceBag = require("ServiceBag")
|
|
13
|
+
local SettingsDataService = require("SettingsDataService")
|
|
14
14
|
|
|
15
15
|
local SettingProperty = {}
|
|
16
16
|
SettingProperty.ClassName = "SettingProperty"
|
|
@@ -22,7 +22,7 @@ export type SettingProperty<T> = typeof(setmetatable(
|
|
|
22
22
|
Changed: any,
|
|
23
23
|
DefaultValue: T,
|
|
24
24
|
|
|
25
|
-
_serviceBag:
|
|
25
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
26
26
|
_bridge: SettingsDataService.SettingsDataService,
|
|
27
27
|
_player: Player,
|
|
28
28
|
_definition: any,
|
|
@@ -38,11 +38,11 @@ export type SettingProperty<T> = typeof(setmetatable(
|
|
|
38
38
|
@param definition SettingDefinition
|
|
39
39
|
@return SettingProperty<T>
|
|
40
40
|
]=]
|
|
41
|
-
function SettingProperty.new<T>(serviceBag:
|
|
41
|
+
function SettingProperty.new<T>(serviceBag: ServiceBag.ServiceBag, player: Player, definition): SettingProperty<T>
|
|
42
42
|
local self: SettingProperty<T> = setmetatable({} :: any, SettingProperty)
|
|
43
43
|
|
|
44
44
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
45
|
-
self._bridge = self._serviceBag:GetService(SettingsDataService)
|
|
45
|
+
self._bridge = self._serviceBag:GetService(SettingsDataService) :: any
|
|
46
46
|
|
|
47
47
|
self._player = assert(player, "No player")
|
|
48
48
|
self._definition = assert(definition, "No definition")
|
|
@@ -58,7 +58,7 @@ end
|
|
|
58
58
|
Observes the value of the setting property
|
|
59
59
|
@return Observable<T>
|
|
60
60
|
]=]
|
|
61
|
-
function SettingProperty.Observe<T>(self: SettingProperty<T>):
|
|
61
|
+
function SettingProperty.Observe<T>(self: SettingProperty<T>): Observable.Observable<T>
|
|
62
62
|
return self:_observePlayerSettings():Pipe({
|
|
63
63
|
Rx.where(function(settings)
|
|
64
64
|
return settings ~= nil
|
|
@@ -146,7 +146,7 @@ end
|
|
|
146
146
|
|
|
147
147
|
@return Promise<T>
|
|
148
148
|
]=]
|
|
149
|
-
function SettingProperty.PromiseValue<T>(self: SettingProperty<T>):
|
|
149
|
+
function SettingProperty.PromiseValue<T>(self: SettingProperty<T>): Promise.Promise<T>
|
|
150
150
|
return self:_promisePlayerSettings():Then(function(playerSettings)
|
|
151
151
|
return playerSettings:GetValue(self._definition:GetSettingName(), self._definition:GetDefaultValue())
|
|
152
152
|
end)
|
|
@@ -158,7 +158,7 @@ end
|
|
|
158
158
|
@param value T
|
|
159
159
|
@return Promise
|
|
160
160
|
]=]
|
|
161
|
-
function SettingProperty.PromiseSetValue<T>(self: SettingProperty<T>, value: T):
|
|
161
|
+
function SettingProperty.PromiseSetValue<T>(self: SettingProperty<T>, value: T): Promise.Promise<()>
|
|
162
162
|
return self:_promisePlayerSettings():Then(function(playerSettings)
|
|
163
163
|
playerSettings:SetValue(self._definition:GetSettingName(), value)
|
|
164
164
|
end)
|
|
@@ -185,7 +185,7 @@ end
|
|
|
185
185
|
|
|
186
186
|
@return Promise
|
|
187
187
|
]=]
|
|
188
|
-
function SettingProperty.PromiseRestoreDefault<T>(self: SettingProperty<T>):
|
|
188
|
+
function SettingProperty.PromiseRestoreDefault<T>(self: SettingProperty<T>): Promise.Promise<()>
|
|
189
189
|
return self:_promisePlayerSettings():Then(function(playerSettings)
|
|
190
190
|
playerSettings:RestoreDefault(self._definition:GetSettingName(), self._definition:GetDefaultValue())
|
|
191
191
|
end)
|
|
@@ -203,4 +203,4 @@ function SettingProperty._promisePlayerSettings<T>(self: SettingProperty<T>)
|
|
|
203
203
|
return self._bridge:PromisePlayerSettings(self._player)
|
|
204
204
|
end
|
|
205
205
|
|
|
206
|
-
return SettingProperty
|
|
206
|
+
return SettingProperty
|
|
@@ -15,12 +15,13 @@ local PlayerSettingsInterface = require("PlayerSettingsInterface")
|
|
|
15
15
|
local Rx = require("Rx")
|
|
16
16
|
local RxBrioUtils = require("RxBrioUtils")
|
|
17
17
|
local RxInstanceUtils = require("RxInstanceUtils")
|
|
18
|
-
local
|
|
18
|
+
local ServiceBag = require("ServiceBag")
|
|
19
19
|
|
|
20
20
|
local SettingsDataService = {}
|
|
21
21
|
|
|
22
22
|
export type SettingsDataService = typeof(setmetatable(
|
|
23
23
|
{} :: {
|
|
24
|
+
_serviceBag: ServiceBag.ServiceBag,
|
|
24
25
|
_maid: Maid.Maid,
|
|
25
26
|
},
|
|
26
27
|
{} :: typeof({ __index = SettingsDataService })
|
|
@@ -31,7 +32,7 @@ export type SettingsDataService = typeof(setmetatable(
|
|
|
31
32
|
|
|
32
33
|
@param serviceBag ServiceBag
|
|
33
34
|
]=]
|
|
34
|
-
function SettingsDataService:Init(serviceBag:
|
|
35
|
+
function SettingsDataService:Init(serviceBag: ServiceBag.ServiceBag)
|
|
35
36
|
assert(not self._serviceBag, "Already initialized")
|
|
36
37
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
37
38
|
self._maid = Maid.new()
|
|
@@ -17,7 +17,6 @@ serviceBag:GetService(screenShakeDefinition)
|
|
|
17
17
|
serviceBag:Init()
|
|
18
18
|
serviceBag:Start()
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
local volumeDefinition = SettingDefinition.new("Volume", 1)
|
|
22
21
|
bridge:RegisterSettingDefinition(volumeDefinition)
|
|
23
22
|
|
|
@@ -41,4 +40,3 @@ game.Players.PlayerAdded:Connect(handlePlayer)
|
|
|
41
40
|
for _, player in game.Players:GetPlayers() do
|
|
42
41
|
handlePlayer(player)
|
|
43
42
|
end
|
|
44
|
-
|