mirror of
https://github.com/S4mpsa/InfOS.git
synced 2025-08-04 02:16:05 -04:00
Adding method to create machine widget
This commit is contained in:
parent
c830dc58ff
commit
eab31f5f84
@ -15,8 +15,9 @@ local states = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local types = {
|
local types = {
|
||||||
power = "power",
|
POWER = "POWER",
|
||||||
machine = "machine"
|
MULTIBLOCK = "MULTIBLOCK",
|
||||||
|
MACHINE = "MACHINE"
|
||||||
}
|
}
|
||||||
|
|
||||||
local function drawProgress(x, y, width, height, progress, maxProgress, color)
|
local function drawProgress(x, y, width, height, progress, maxProgress, color)
|
||||||
@ -70,7 +71,7 @@ function widget.drawBaseWidget(x, y, width, height, title)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function draw(self, index)
|
local function draw(self, index)
|
||||||
if self.type == types.power then
|
if self.type == types.POWER then
|
||||||
index = 10
|
index = 10
|
||||||
end
|
end
|
||||||
local scale = self.scale or 1
|
local scale = self.scale or 1
|
||||||
@ -198,7 +199,7 @@ function fake.machineWidget.create()
|
|||||||
state = state,
|
state = state,
|
||||||
progress = 0,
|
progress = 0,
|
||||||
maxProgress = state ~= states[3] and state ~= states[4] and math.random(500) or 0,
|
maxProgress = state ~= states[3] and state ~= states[4] and math.random(500) or 0,
|
||||||
type = "machine",
|
type = types.MACHINE,
|
||||||
update = fake.machineWidget.update,
|
update = fake.machineWidget.update,
|
||||||
onClick = fake.machineWidget.onClick,
|
onClick = fake.machineWidget.onClick,
|
||||||
getMiddleString = fake.machineWidget.getMiddleString,
|
getMiddleString = fake.machineWidget.getMiddleString,
|
||||||
@ -206,6 +207,34 @@ function fake.machineWidget.create()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function widget.createMachineWidget(address, name)
|
||||||
|
local getMultiblockStatus = require("domain.multiblock.get-multiblock-status-usecase")
|
||||||
|
local function update(self)
|
||||||
|
for key, value in pairs(getMultiblockStatus(address, self.name)) do
|
||||||
|
self[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local toggleMultiblockWork = require("domain.multiblock.toggle-multiblock-work")
|
||||||
|
local function onClick()
|
||||||
|
toggleMultiblockWork(address)
|
||||||
|
end
|
||||||
|
|
||||||
|
local machineWidget = {
|
||||||
|
name = name,
|
||||||
|
type = types.MULTIBLOCK,
|
||||||
|
update = update,
|
||||||
|
onClick = onClick,
|
||||||
|
getMiddleString = function()
|
||||||
|
end,
|
||||||
|
draw = draw
|
||||||
|
}
|
||||||
|
|
||||||
|
machineWidget:update()
|
||||||
|
|
||||||
|
return machineWidget
|
||||||
|
end
|
||||||
|
|
||||||
fake.powerWidget = {}
|
fake.powerWidget = {}
|
||||||
|
|
||||||
function fake.powerWidget:update()
|
function fake.powerWidget:update()
|
||||||
@ -231,7 +260,7 @@ function fake.powerWidget.create()
|
|||||||
maxProgress = 16000000,
|
maxProgress = 16000000,
|
||||||
dProgress = 1,
|
dProgress = 1,
|
||||||
scale = 2,
|
scale = 2,
|
||||||
type = types.power,
|
type = types.POWER,
|
||||||
update = fake.powerWidget.update,
|
update = fake.powerWidget.update,
|
||||||
onClick = fake.powerWidget.onClick,
|
onClick = fake.powerWidget.onClick,
|
||||||
getMiddleString = fake.powerWidget.getMiddleString,
|
getMiddleString = fake.powerWidget.getMiddleString,
|
||||||
@ -269,7 +298,7 @@ function widget.createPowerWidget(address)
|
|||||||
local powerWidget = {
|
local powerWidget = {
|
||||||
name = "Power",
|
name = "Power",
|
||||||
scale = 2,
|
scale = 2,
|
||||||
type = types.power,
|
type = types.POWER,
|
||||||
update = update,
|
update = update,
|
||||||
onClick = function()
|
onClick = function()
|
||||||
end,
|
end,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user