mirror of
https://github.com/S4mpsa/InfOS.git
synced 2025-08-04 02:16:05 -04:00
Adding reboot button
This commit is contained in:
parent
a7ef9a0002
commit
d995a8f670
@ -65,7 +65,7 @@ Event.listen(
|
|||||||
local function drawTitle(title)
|
local function drawTitle(title)
|
||||||
local x = Constants.baseWidth
|
local x = Constants.baseWidth
|
||||||
local y = 1
|
local y = 1
|
||||||
local width = 3 * Constants.baseWidth
|
local width = math.floor(2.5 * Constants.baseWidth)
|
||||||
local height = math.floor(0.8 * Constants.baseHeight)
|
local height = math.floor(0.8 * Constants.baseHeight)
|
||||||
Widget.drawBaseWidget(x, y, width, height, title)
|
Widget.drawBaseWidget(x, y, width, height, title)
|
||||||
end
|
end
|
||||||
@ -88,6 +88,14 @@ local function drawNavigationButton(self, index)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function drawRebootButton()
|
||||||
|
local width = math.floor(0.3 * Constants.baseWidth)
|
||||||
|
local height = math.floor(0.6 * Constants.baseHeight)
|
||||||
|
local x = math.floor(3.25 * Constants.baseWidth) + math.floor((Constants.baseWidth - width) / 2)
|
||||||
|
local y = math.floor((Constants.baseHeight - height) / 2)
|
||||||
|
Widget.drawBaseWidget(x, y, width, height, "Restart")
|
||||||
|
end
|
||||||
|
|
||||||
local function clickNavigationButton(self)
|
local function clickNavigationButton(self)
|
||||||
if not self.active then
|
if not self.active then
|
||||||
return
|
return
|
||||||
@ -135,6 +143,7 @@ function page.create(element)
|
|||||||
for i = 1, 9 do
|
for i = 1, 9 do
|
||||||
elements.machineWidgets.active[i] = elements.machineWidgets[9 * (elements.machineWidgets.active.index - 1) + i]
|
elements.machineWidgets.active[i] = elements.machineWidgets[9 * (elements.machineWidgets.active.index - 1) + i]
|
||||||
end
|
end
|
||||||
|
|
||||||
elements.navigationButtons[1] = {
|
elements.navigationButtons[1] = {
|
||||||
title = "◀",
|
title = "◀",
|
||||||
active = true,
|
active = true,
|
||||||
@ -154,11 +163,14 @@ function page.create(element)
|
|||||||
draw = drawNavigationButton
|
draw = drawNavigationButton
|
||||||
}
|
}
|
||||||
|
|
||||||
elements[4.5] = {
|
elements.rebootButton = {
|
||||||
onClick = function()
|
onClick = function()
|
||||||
Computer.shutdown(true)
|
Computer.shutdown(true)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
drawRebootButton()
|
||||||
|
|
||||||
|
elements[4.5] = elements.rebootButton
|
||||||
|
|
||||||
elements[6] = elements.machineWidgets.active[1]
|
elements[6] = elements.machineWidgets.active[1]
|
||||||
elements[7] = elements.machineWidgets.active[2]
|
elements[7] = elements.machineWidgets.active[2]
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
-- Import section
|
|
||||||
Page = require("api.gui.page")
|
|
||||||
Graphics = require("graphics.graphics")
|
|
||||||
Colors = require("colors")
|
|
||||||
Component = require("component")
|
|
||||||
GPU = Component.gpu
|
|
||||||
--
|
|
||||||
|
|
||||||
local panel = {
|
|
||||||
currentPage = Page.overview
|
|
||||||
}
|
|
||||||
|
|
||||||
function panel.render()
|
|
||||||
Graphics.rectangle(GPU, 0, 0, 20, 160, Colors.background)
|
|
||||||
for index, page in ipairs(Page) do
|
|
||||||
if page ~= panel.currentPage then
|
|
||||||
Graphics.text(GPU, 0, 10 * (index - 1), Colors.labelColor, panel.title)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function panel.navigate(page)
|
|
||||||
panel.findText(page.title)
|
|
||||||
page.render()
|
|
||||||
end
|
|
||||||
|
|
||||||
return panel
|
|
Loading…
x
Reference in New Issue
Block a user