mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 13:15:50 +00:00
Migrate DevSettings to PluginSettings for much better config flow (#572)
* Add the devsetting config options into settings * Create dropdown component and add setting controls * Static dropdwon width and spin arrow * Improve dropdown option contrast and border * Forgot to make the settings page respect the static spacing, oops * Smaller arrow * Vert padding * Reset option for settings * Hide reset button when on default * Respect the logLevel setting * Portal settings out to external typechecking module * Implement new configs using the new singleton Settings * Remove DevSettings * Update test runner to use new settings * More helpful test failure output * Support non-plugin environment * Migrate dropdown to new packages system * Clean up components a tad
This commit is contained in:
@@ -7,18 +7,22 @@ local Rojo = script:FindFirstAncestor("Rojo")
|
||||
local Packages = Rojo.Packages
|
||||
|
||||
local Log = require(Packages.Log)
|
||||
local Roact = require(Packages.Roact)
|
||||
|
||||
local defaultSettings = {
|
||||
openScriptsExternally = false,
|
||||
twoWaySync = false,
|
||||
showNotifications = true,
|
||||
playSounds = true,
|
||||
typecheckingEnabled = false,
|
||||
logLevel = "Info",
|
||||
}
|
||||
|
||||
local Settings = {}
|
||||
|
||||
Settings._values = table.clone(defaultSettings)
|
||||
Settings._updateListeners = {}
|
||||
Settings._bindings = {}
|
||||
|
||||
if plugin then
|
||||
for name, defaultValue in pairs(Settings._values) do
|
||||
@@ -45,6 +49,9 @@ end
|
||||
|
||||
function Settings:set(name, value)
|
||||
self._values[name] = value
|
||||
if self._bindings[name] then
|
||||
self._bindings[name].set(value)
|
||||
end
|
||||
|
||||
if plugin then
|
||||
-- plugin:SetSetting hits disc instead of memory, so it can be slow. Spawn so we don't hang.
|
||||
@@ -76,4 +83,21 @@ function Settings:onChanged(name, callback)
|
||||
end
|
||||
end
|
||||
|
||||
function Settings:getBinding(name)
|
||||
local cached = self._bindings[name]
|
||||
if cached then
|
||||
return cached.bind
|
||||
end
|
||||
|
||||
local bind, set = Roact.createBinding(self._values[name])
|
||||
self._bindings[name] = {
|
||||
bind = bind,
|
||||
set = set,
|
||||
}
|
||||
|
||||
Log.trace(string.format("Created binding for setting '%s'", name))
|
||||
|
||||
return bind
|
||||
end
|
||||
|
||||
return Settings
|
||||
|
||||
Reference in New Issue
Block a user