Adding reboot button on top right

Fixing drawBaseWidget bug
This commit is contained in:
Gabriel Moreira Minossi 2021-01-11 13:44:48 -03:00
parent 1c90d83f88
commit 9e49d86bd9
2 changed files with 11 additions and 6 deletions

View File

@ -1,10 +1,11 @@
-- Import section
Computer = require("computer")
Unicode = require("unicode")
Event = require("event")
DoubleBuffer = require("graphics.doubleBuffering")
Constants = require("api.gui.constants")
Colors = require("graphics.colors")
Widget = require("api.gui.widget")
Constants = require("api.gui.constants")
--
-- GPU resolution should be 160 x 50.
@ -79,14 +80,18 @@ function page.create(element)
drawTitle(element.title)
local panelIndex = 1
for _, pg in pairs(pages) do
for _, pg in ipairs(pages) do
if pg ~= element then
elements.panelSections[panelIndex] = pg
elements.panelSections[panelIndex] = pg.title
drawPanelSection(panelIndex, pg.title)
panelIndex = panelIndex + 1
end
end
elements[4.5] = {onClick = function()
Computer.shutdown(true)
end}
elements[6] = elements.machineWidgets[1]
elements[7] = elements.machineWidgets[2]
elements[8] = elements.machineWidgets[3]

View File

@ -1,8 +1,8 @@
Component = require("component")
Unicode = require("unicode")
Colors = require("graphics.colors")
DoubleBuffer = require("graphics.doubleBuffering")
Constants = require("api.gui.constants")
Colors = require("graphics.colors")
local widget = {}
@ -45,7 +45,7 @@ function widget.drawBaseWidget(x, y, scale, title)
)
DoubleBuffer.drawFrame(x + 1, y + 1, width - 1, height - 1, Colors.labelColor)
DoubleBuffer.drawLine(x + 3, y + 5, x + width - 3, y + 5, Colors.machineBackground, Colors.textColor, "")
DoubleBuffer.drawText(x + (width - Unicode.len(title)) / 2, y + 3, Colors.labelColor, title)
DoubleBuffer.drawText(x + math.floor((width - Unicode.len(title)) / 2), y + 3, Colors.labelColor, title)
end
local function draw(self, index)
@ -71,7 +71,7 @@ local function draw(self, index)
DoubleBuffer.drawText(x + 3 + 3 + Unicode.len("IDLE"), y + height - 3, Colors.textColor, middleInfo)
end
DoubleBuffer.drawText(
x + width - Unicode.len(self.progress .. "/" .. self.maxProgress .. " s") - 2,
x + width - Unicode.len(self.progress .. "/" .. self.maxProgress .. " s") - 3,
y + height - 3,
Colors.accentA,
self.progress .. "/" .. self.maxProgress .. " s"