1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-16 05:34:49 +00:00
opus/sys/apps/system/label.lua

51 lines
1.4 KiB
Lua
Raw Normal View History

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
return UI.Tab {
2020-04-27 01:39:58 +00:00
title = 'Label',
2018-12-23 03:11:16 +00:00
description = 'Set the computer label',
labelText = UI.Text {
x = 3, y = 3,
2018-12-23 03:11:16 +00:00
value = 'Label'
},
label = UI.TextEntry {
x = 9, y = 3, ex = -4,
2018-12-23 03:11:16 +00:00
limit = 32,
value = os.getComputerLabel(),
accelerators = {
enter = 'update_label',
},
},
[1] = UI.Window {
x = 2, y = 2, ex = -2, ey = 4,
},
2018-12-23 03:11:16 +00:00
grid = UI.ScrollingGrid {
x = 2, y = 5, ex = -2, ey = -2,
2018-12-23 03:11:16 +00:00
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()) },
},
disableHeader = true,
2018-12-23 03:11:16 +00:00
inactive = true,
columns = {
{ key = 'name', width = 12 },
{ key = 'value', textColor = colors.yellow },
2018-12-23 03:11:16 +00:00
},
},
eventHandler = function(self, event)
if event.type == 'update_label' and self.label.value then
os.setComputerLabel(self.label.value)
self:emit({ type = 'success_message', message = 'Label updated' })
return true
end
end,
2018-12-23 03:11:16 +00:00
}