Ui enhancements 2.0 (#29)
* canvas overhaul * editor 2.0 * more tweaks * more editor work * completions + refactor * cleanup + editor additions * cleanup + undo overhaul * editor recent/peripherals/redo + cleanup * editor path issues * cleanup * changes for deprecated ui methods - recolor milo - make turtle scripts run again - mob rancher improvements * can now use named colors
This commit was merged in pull request #29.
This commit is contained in:
@@ -11,7 +11,7 @@ if not multishell then
|
||||
end
|
||||
|
||||
local config = Config.load('saver', {
|
||||
enabled = true,
|
||||
enabled = false,
|
||||
timeout = 60,
|
||||
random = true,
|
||||
specific = nil,
|
||||
|
||||
@@ -6,23 +6,26 @@ local config = Config.load('saver', {
|
||||
timeout = 60,
|
||||
})
|
||||
|
||||
local tab = UI.Tab {
|
||||
return UI.Tab {
|
||||
tabTitle = 'Screen Saver',
|
||||
description = 'Screen saver',
|
||||
[1] = UI.Window {
|
||||
x = 2, y = 2, ex = -2, ey = 5,
|
||||
},
|
||||
label1 = UI.Text {
|
||||
x = 2, y = 3,
|
||||
x = 3, y = 3,
|
||||
value = 'Enabled',
|
||||
},
|
||||
checkbox = UI.Checkbox {
|
||||
x = 20, y = 3,
|
||||
x = 21, y = 3,
|
||||
value = config.enabled
|
||||
},
|
||||
label2 = UI.Text {
|
||||
x = 2, y = 4,
|
||||
x = 3, y = 4,
|
||||
value = 'Timeout',
|
||||
},
|
||||
timeout = UI.TextEntry {
|
||||
x = 20, y = 4, width = 6,
|
||||
x = 21, y = 4, width = 6,
|
||||
limit = 4,
|
||||
transform = 'number',
|
||||
value = config.timeout,
|
||||
@@ -31,28 +34,25 @@ local tab = UI.Tab {
|
||||
},
|
||||
},
|
||||
button = UI.Button {
|
||||
x = 20, y = 6,
|
||||
text = 'Update',
|
||||
x = -8, ex = -2, y = -2,
|
||||
text = 'Apply',
|
||||
event = 'update',
|
||||
},
|
||||
}
|
||||
eventHandler = function(self, event)
|
||||
if event.type =='checkbox_change' then
|
||||
config.enabled = not not event.checked
|
||||
|
||||
function tab:eventHandler(event)
|
||||
if event.type =='checkbox_change' then
|
||||
config.enabled = not not event.checked
|
||||
elseif event.type == 'update' then
|
||||
if self.timeout.value then
|
||||
config.timeout = self.timeout.value
|
||||
Config.update('saver', config)
|
||||
|
||||
elseif event.type == 'update' then
|
||||
if self.timeout.value then
|
||||
config.timeout = self.timeout.value
|
||||
Config.update('saver', config)
|
||||
|
||||
self:emit({ type = 'success_message', message = 'Settings updated' })
|
||||
os.queueEvent('config_update', 'saver', config)
|
||||
else
|
||||
self:emit({ type = 'error_message', message = 'Invalid timeout' })
|
||||
self:emit({ type = 'success_message', message = 'Settings updated' })
|
||||
os.queueEvent('config_update', 'saver', config)
|
||||
else
|
||||
self:emit({ type = 'error_message', message = 'Invalid timeout' })
|
||||
end
|
||||
end
|
||||
end
|
||||
return UI.Tab.eventHandler(self, event)
|
||||
end
|
||||
|
||||
return tab
|
||||
return UI.Tab.eventHandler(self, event)
|
||||
end,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user