mirror of
https://github.com/kepler155c/opus
synced 2025-10-20 18:27:40 +00:00
kiosk settings
This commit is contained in:
55
sys/apps/system/kiosk.lua
Normal file
55
sys/apps/system/kiosk.lua
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
local UI = require('ui')
|
||||||
|
|
||||||
|
local device = _G.device
|
||||||
|
local peripheral = _G.peripheral
|
||||||
|
local settings = _G.settings
|
||||||
|
|
||||||
|
local tab = UI.Tab {
|
||||||
|
tabTitle = 'Kiosk',
|
||||||
|
description = 'Kiosk options',
|
||||||
|
form = UI.Form {
|
||||||
|
x = 2,
|
||||||
|
manualControls = true,
|
||||||
|
monitor = UI.Chooser {
|
||||||
|
formLabel = 'Monitor', formKey = 'monitor',
|
||||||
|
},
|
||||||
|
textScale = UI.Chooser {
|
||||||
|
formLabel = 'Font Size', formKey = 'textScale',
|
||||||
|
nochoice = 'Small',
|
||||||
|
choices = {
|
||||||
|
{ name = 'Small', value = '.5' },
|
||||||
|
{ name = 'Large', value = '1' },
|
||||||
|
},
|
||||||
|
help = 'Adjust text scaling',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function tab:enable()
|
||||||
|
local choices = { }
|
||||||
|
|
||||||
|
for k,v in pairs(device) do
|
||||||
|
if v.type == 'monitor' then
|
||||||
|
table.insert(choices, { name = k, value = v.name })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.form.monitor.choices = choices
|
||||||
|
self.form.monitor.value = settings.get('kiosk.monitor')
|
||||||
|
|
||||||
|
self.form.textScale.value = settings.get('kiosk.textscale')
|
||||||
|
|
||||||
|
UI.Tab.enable(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function tab:eventHandler(event)
|
||||||
|
if event.type == 'choice_change' then
|
||||||
|
settings.set('kiosk.monitor', self.form.monitor.value)
|
||||||
|
settings.set('kiosk.textscale', self.form.textScale.value)
|
||||||
|
settings.save('.settings')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if peripheral.find('monitor') then
|
||||||
|
return tab
|
||||||
|
end
|
@@ -3,6 +3,21 @@ local UI = require('ui')
|
|||||||
local settings = _G.settings
|
local settings = _G.settings
|
||||||
|
|
||||||
if settings then
|
if settings then
|
||||||
|
local settingsTab = UI.Tab {
|
||||||
|
tabTitle = 'Settings',
|
||||||
|
description = 'Computercraft configurable settings',
|
||||||
|
grid = UI.Grid {
|
||||||
|
y = 2,
|
||||||
|
autospace = true,
|
||||||
|
sortColumn = 'name',
|
||||||
|
columns = {
|
||||||
|
{ heading = 'Setting', key = 'name' },
|
||||||
|
{ heading = 'Value', key = 'value' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function settingsTab:enable()
|
||||||
local values = { }
|
local values = { }
|
||||||
for _,v in pairs(settings.getNames()) do
|
for _,v in pairs(settings.getNames()) do
|
||||||
local value = settings.get(v)
|
local value = settings.get(v)
|
||||||
@@ -14,21 +29,9 @@ if settings then
|
|||||||
value = value,
|
value = value,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
self.grid:setValues(values)
|
||||||
local settingsTab = UI.Tab {
|
UI.Tab.enable(self)
|
||||||
tabTitle = 'Settings',
|
end
|
||||||
description = 'Computercraft configurable settings',
|
|
||||||
grid = UI.Grid {
|
|
||||||
y = 2,
|
|
||||||
values = values,
|
|
||||||
autospace = true,
|
|
||||||
sortColumn = 'name',
|
|
||||||
columns = {
|
|
||||||
{ heading = 'Setting', key = 'name' },
|
|
||||||
{ heading = 'Value', key = 'value' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
function settingsTab:eventHandler(event)
|
function settingsTab:eventHandler(event)
|
||||||
if event.type == 'grid_select' then
|
if event.type == 'grid_select' then
|
||||||
|
Reference in New Issue
Block a user