mirror of
https://github.com/S4mpsa/InfOS.git
synced 2025-08-04 02:16:05 -04:00
Adding progress bars to widgets
Changing colors
This commit is contained in:
parent
f1964f7af0
commit
feca39a4ed
@ -20,22 +20,22 @@ local colors = {
|
|||||||
|
|
||||||
---[[
|
---[[
|
||||||
local newColors = {
|
local newColors = {
|
||||||
machineBackground = colors.darkGray,
|
|
||||||
progressBackground = colors.lightGray,
|
|
||||||
labelColor = colors.chocolate,
|
|
||||||
errorColor = colors.red,
|
|
||||||
idleColor = colors.purple,
|
|
||||||
workingColor = colors.steelBlue,
|
|
||||||
positiveEUColor = colors.lime,
|
|
||||||
negativeEUColor = colors.brown,
|
|
||||||
timeColor = colors.purple,
|
|
||||||
textColor = colors.black,
|
|
||||||
hudColor = colors.darkSlateGrey,
|
|
||||||
mainColor = colors.rosyBrown,
|
|
||||||
background = colors.black,
|
background = colors.black,
|
||||||
|
machineBackground = colors.darkSlateGrey,
|
||||||
|
progressBackground = colors.purple,
|
||||||
|
barColor = colors.magenta,
|
||||||
|
labelColor = colors.chocolate,
|
||||||
|
idleColor = colors.brown,
|
||||||
|
workingColor = colors.green,
|
||||||
|
errorColor = colors.red,
|
||||||
|
positiveEUColor = colors.lime,
|
||||||
|
negativeEUColor = colors.red,
|
||||||
|
timeColor = colors.purple,
|
||||||
|
textColor = colors.brown,
|
||||||
|
hudColor = colors.darkSlateGrey,
|
||||||
|
mainColor = colors.steelBlue,
|
||||||
accentA = colors.cyan,
|
accentA = colors.cyan,
|
||||||
accentB = colors.magenta,
|
accentB = colors.blue
|
||||||
barColor = colors.blue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, color in pairs(newColors) do
|
for name, color in pairs(newColors) do
|
||||||
|
@ -4,7 +4,7 @@ Colors = require("colors")
|
|||||||
|
|
||||||
local widgets = {}
|
local widgets = {}
|
||||||
|
|
||||||
function widgets.gtMachineInit(GPU, name, address)
|
function widgets.gtMabchineInit(GPU, name, address)
|
||||||
local maintenanceIndex = 0
|
local maintenanceIndex = 0
|
||||||
local machine = util.machine(address)
|
local machine = util.machine(address)
|
||||||
Graphics.rectangle(GPU, 1, 1, 28, 9, Colors.background)
|
Graphics.rectangle(GPU, 1, 1, 28, 9, Colors.background)
|
||||||
@ -99,7 +99,8 @@ function widgets.gtMachine(GPU, name, address)
|
|||||||
end
|
end
|
||||||
_, f, _ = GPU.get(6, 1)
|
_, f, _ = GPU.get(6, 1)
|
||||||
if
|
if
|
||||||
((Graphics.windows[name].data == 0 or string.match(machine.getSensorInformation()[Graphics.windows[name].data], ".*c0.*")) and
|
((Graphics.windows[name].data == 0 or
|
||||||
|
string.match(machine.getSensorInformation()[Graphics.windows[name].data], ".*c0.*")) and
|
||||||
machine.isWorkAllowed()) == true
|
machine.isWorkAllowed()) == true
|
||||||
then
|
then
|
||||||
if f ~= Colors.background then
|
if f ~= Colors.background then
|
||||||
|
@ -4,8 +4,8 @@ SingleBlock = require("data.datasource.single-block")
|
|||||||
EnergyProvider = require("data.datasource.energy-provider")
|
EnergyProvider = require("data.datasource.energy-provider")
|
||||||
Colors = require("graphics.colors")
|
Colors = require("graphics.colors")
|
||||||
Unicode = require("unicode")
|
Unicode = require("unicode")
|
||||||
local doubleBuffer = require("graphics.doubleBuffering")
|
Graphics = require("graphics.graphics")
|
||||||
--
|
DoubleBuffer = require("graphics.doubleBuffering")
|
||||||
|
|
||||||
local cleanroomAddresses = require("config.addresses.cleanroom")
|
local cleanroomAddresses = require("config.addresses.cleanroom")
|
||||||
local multiBlockAddresses = require("config.addresses.multi-blocks")
|
local multiBlockAddresses = require("config.addresses.multi-blocks")
|
||||||
@ -16,8 +16,11 @@ local getMultiblockStatuses = require("domain.multiblock.get-multiblock-status-u
|
|||||||
local getEnergyStatus = require("domain.energy.get-energy-status-usecase")
|
local getEnergyStatus = require("domain.energy.get-energy-status-usecase")
|
||||||
local listMiners = require("domain.miner.list-miners-usecase")
|
local listMiners = require("domain.miner.list-miners-usecase")
|
||||||
local getMinersStatuses = require("domain.miner.get-miner-status-usecase")
|
local getMinersStatuses = require("domain.miner.get-miner-status-usecase")
|
||||||
|
|
||||||
|
local GPU = Component.gpu
|
||||||
--
|
--
|
||||||
|
|
||||||
|
--[[
|
||||||
local cleanroomMachines = {}
|
local cleanroomMachines = {}
|
||||||
for name, address in pairs(cleanroomAddresses) do
|
for name, address in pairs(cleanroomAddresses) do
|
||||||
table.insert(cleanroomMachines, SingleBlock:new(address, name))
|
table.insert(cleanroomMachines, SingleBlock:new(address, name))
|
||||||
@ -59,24 +62,25 @@ for multiblockName, status in pairs(multiblocksStatuses) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
require("api.sound.zelda-secret")()
|
require("api.sound.zelda-secret")()
|
||||||
|
--]]
|
||||||
local component = {
|
local component = {
|
||||||
name = "Machine",
|
name = "Machine",
|
||||||
working = true,
|
working = true,
|
||||||
leftInfo = "LV",
|
leftInfo = "ON",
|
||||||
middleInfo = "something",
|
middleInfo = "something",
|
||||||
rightInfo = "16 / 32 s",
|
rightInfo = "16 / 32 s",
|
||||||
progress = 0,
|
progress = 0,
|
||||||
maxProgress = 16000
|
maxProgress = 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
local width = 40
|
local width = 40
|
||||||
local height = 10
|
local height = 10
|
||||||
local function drawWidget(index, component, scale)
|
|
||||||
scale = scale or 1
|
local function drawTitle(title)
|
||||||
local x = width + width * ((index - 1) % 3)
|
local x = width
|
||||||
local y = height * math.ceil((index) / 3)
|
local y = 0
|
||||||
doubleBuffer.drawRectangle(
|
local scale = 3
|
||||||
|
DoubleBuffer.drawRectangle(
|
||||||
x + 1,
|
x + 1,
|
||||||
y + 1,
|
y + 1,
|
||||||
width * scale - 1,
|
width * scale - 1,
|
||||||
@ -85,25 +89,62 @@ local function drawWidget(index, component, scale)
|
|||||||
Colors.machineBackground,
|
Colors.machineBackground,
|
||||||
"█"
|
"█"
|
||||||
)
|
)
|
||||||
doubleBuffer.drawFrame(x + 1, y + 1, width * scale - 1, height - 1, Colors.labelColor)
|
DoubleBuffer.drawFrame(x + 1, y + 1, width * scale - 1, height - 1, Colors.labelColor)
|
||||||
doubleBuffer.drawLine(x + 3, y + 5, x + width * scale - 3, y + 5, Colors.machineBackground, Colors.mainColor, "─")
|
DoubleBuffer.drawLine(x + 3, y + 6, x + width * scale - 3, y + 6, Colors.machineBackground, Colors.textColor, "─")
|
||||||
doubleBuffer.drawText(x + 3, y + 2, Colors.labelColor, component.name)
|
DoubleBuffer.drawText(x + (width * scale - Unicode.len(title)) / 2, y + 5, Colors.mainColor, title)
|
||||||
doubleBuffer.drawText(
|
end
|
||||||
|
|
||||||
|
local function drawProgress(x, y, width, height, progress, maxProgress, color)
|
||||||
|
progress = math.floor(progress * (width + height - 2) / maxProgress)
|
||||||
|
|
||||||
|
local lengths = {
|
||||||
|
first = progress > 5 and 5 or progress,
|
||||||
|
second = progress > height - 2 + 5 and height - 2 or progress - (5),
|
||||||
|
third = progress > width - 6 + height - 2 + 5 and width - 6 or progress - (height - 2 + 5)
|
||||||
|
}
|
||||||
|
DoubleBuffer.drawRectangle(x + 6 - lengths.first, y + 1, lengths.first, 1, color, color, "█")
|
||||||
|
DoubleBuffer.drawRectangle(x + 1, y + 2, 1, lengths.second, color, color, "█")
|
||||||
|
DoubleBuffer.drawRectangle(x + 1, y + height, lengths.third, 1, color, color, "█")
|
||||||
|
DoubleBuffer.drawRectangle(x + width - 4, y + height, lengths.first, 1, color, color, "█")
|
||||||
|
DoubleBuffer.drawRectangle(x + width, y + height - lengths.second, 1, lengths.second, color, color, "█")
|
||||||
|
DoubleBuffer.drawRectangle(x + 1 + width - lengths.third, y + 1, lengths.third, 1, color, color, "█")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function drawWidget(index, component, scale)
|
||||||
|
scale = scale or 1
|
||||||
|
local x = width + width * ((index - 1) % 3)
|
||||||
|
local y = height * math.ceil((index) / 3)
|
||||||
|
DoubleBuffer.drawRectangle(
|
||||||
|
x + 1,
|
||||||
|
y + 1,
|
||||||
|
width * scale - 1,
|
||||||
|
height - 1,
|
||||||
|
Colors.machineBackground,
|
||||||
|
Colors.machineBackground,
|
||||||
|
"█"
|
||||||
|
)
|
||||||
|
|
||||||
|
drawProgress(x, y, width * scale - 1, height - 1, 1, 1, Colors.progressBackground)
|
||||||
|
drawProgress(x, y, width * scale - 1, height - 1, component.progress, component.maxProgress, Colors.barColor)
|
||||||
|
|
||||||
|
DoubleBuffer.drawLine(x + 3, y + 5, x + width * scale - 3, y + 5, Colors.machineBackground, Colors.textColor, "─")
|
||||||
|
DoubleBuffer.drawText(x + 3, y + 3, Colors.labelColor, component.name)
|
||||||
|
DoubleBuffer.drawText(
|
||||||
x + 3,
|
x + 3,
|
||||||
y + 7,
|
y + 7,
|
||||||
component.working and Colors.workingColor or Colors.errorColor,
|
component.working and Colors.workingColor or Colors.errorColor,
|
||||||
component.leftInfo
|
component.leftInfo
|
||||||
)
|
)
|
||||||
if component.middleInfo then
|
if component.middleInfo then
|
||||||
doubleBuffer.drawText(
|
DoubleBuffer.drawText(
|
||||||
x + width * scale / 2 - Unicode.len(component.middleInfo) + 3,
|
x + 3 + 3 + Unicode.len(component.leftInfo),
|
||||||
y + height - 3,
|
y + height - 3,
|
||||||
Colors.accentB,
|
Colors.textColor,
|
||||||
component.middleInfo
|
component.middleInfo
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
if component.rightInfo then
|
if component.rightInfo then
|
||||||
doubleBuffer.drawText(
|
DoubleBuffer.drawText(
|
||||||
x + width * scale - Unicode.len(tostring(component.rightInfo)) - 3,
|
x + width * scale - Unicode.len(tostring(component.rightInfo)) - 3,
|
||||||
y + height - 3,
|
y + height - 3,
|
||||||
Colors.accentA,
|
Colors.accentA,
|
||||||
@ -112,10 +153,12 @@ local function drawWidget(index, component, scale)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
drawTitle("Overview")
|
||||||
while true do
|
while true do
|
||||||
component.progress = component.progress + math.random(0, 1000)
|
component.progress = component.progress + 1
|
||||||
component.rightInfo = component.progress .. " / " .. component.maxProgress
|
component.rightInfo = component.progress .. " / " .. component.maxProgress .. " s"
|
||||||
if component.progress >= component.maxProgress then
|
if component.progress >= component.maxProgress then
|
||||||
|
os.sleep(0.5)
|
||||||
component.progress = 0
|
component.progress = 0
|
||||||
end
|
end
|
||||||
for index = 1, 10 do
|
for index = 1, 10 do
|
||||||
@ -125,8 +168,8 @@ while true do
|
|||||||
drawWidget(index, component, 2)
|
drawWidget(index, component, 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
doubleBuffer.drawChanges()
|
DoubleBuffer.drawChanges()
|
||||||
os.sleep(0.5)
|
os.sleep(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user