2019-06-28 17:50:02 +00:00
|
|
|
local UI = require('opus.ui')
|
|
|
|
local Util = require('opus.util')
|
2018-12-23 03:11:16 +00:00
|
|
|
|
|
|
|
local fs = _G.fs
|
|
|
|
local os = _G.os
|
|
|
|
|
2019-01-30 20:11:41 +00:00
|
|
|
local labelTab = UI.Tab {
|
2018-12-23 03:11:16 +00:00
|
|
|
tabTitle = 'Label',
|
|
|
|
description = 'Set the computer label',
|
|
|
|
labelText = UI.Text {
|
|
|
|
x = 3, y = 2,
|
|
|
|
value = 'Label'
|
|
|
|
},
|
|
|
|
label = UI.TextEntry {
|
|
|
|
x = 9, y = 2, ex = -4,
|
|
|
|
limit = 32,
|
|
|
|
value = os.getComputerLabel(),
|
|
|
|
accelerators = {
|
|
|
|
enter = 'update_label',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
grid = UI.ScrollingGrid {
|
|
|
|
y = 3,
|
|
|
|
values = {
|
|
|
|
{ name = '', value = '' },
|
|
|
|
{ name = 'CC version', value = Util.getVersion() },
|
|
|
|
{ name = 'Lua version', value = _VERSION },
|
|
|
|
{ name = 'MC version', value = Util.getMinecraftVersion() },
|
|
|
|
{ name = 'Disk free', value = Util.toBytes(fs.getFreeSpace('/')) },
|
|
|
|
{ name = 'Computer ID', value = tostring(os.getComputerID()) },
|
|
|
|
{ name = 'Day', value = tostring(os.day()) },
|
|
|
|
},
|
|
|
|
inactive = true,
|
|
|
|
columns = {
|
|
|
|
{ key = 'name', width = 12 },
|
|
|
|
{ key = 'value' },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
function labelTab:eventHandler(event)
|
|
|
|
if event.type == 'update_label' then
|
|
|
|
os.setComputerLabel(self.label.value)
|
|
|
|
self:emit({ type = 'success_message', message = 'Label updated' })
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return labelTab
|