Skip to content

Commit

Permalink
Add a button to force compact mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Sampsa committed Dec 10, 2023
1 parent 187340b commit e2f2326
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 39 deletions.
40 changes: 6 additions & 34 deletions hud/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ local fluidDisplay = require("hud.fluiddisplay")
local component = require("component")
local serialization = require("serialization")
local colors = require("lib.graphics.colors")
local parser = require("lib.utils.parser")
--

local glassData = {}
Expand All @@ -31,7 +30,7 @@ local function load()
local glasses = component.proxy(address)
if glasses then
ar.clear(glasses)
if data.energyDisplay then table.insert(powerDisplayUsers, {component.proxy(address), {data.xRes or 2560, data.yRes or 1440}, data.scale or 3, data.backgroundColor or colors.darkGray, data.primaryColor or colors.electricBlue, data.accentColor or colors.accentColor}) end
if data.energyDisplay then table.insert(powerDisplayUsers, {component.proxy(address), {data.xRes or 2560, data.yRes or 1440}, data.scale or 3, data.backgroundColor or colors.darkGray, data.primaryColor or colors.electricBlue, data.accentColor or colors.accentColor, data.compactMode}) end
if data.fluidDisplay then table.insert(fluidDisplayUsers, {component.proxy(address), {data.xRes or 2560, data.yRes or 1440}, data.scale or 3, data.backgroundColor or colors.darkGray, data.primaryColor or colors.electricBlue, data.accentColor or colors.accentColor}) end
if data.toolbar then table.insert(toolbarUsers, {component.proxy(address), {data.xRes or 2560, data.yRes or 1440}, data.scale or 3, data.offset or 0, data.backgroundColor or colors.darkGray, data.primaryColor or colors.electricBlue, data.accentColor or colors.accentColor}) end
if data.notifications then table.insert(notificationsUsers, {component.proxy(address), {data.xRes or 2560, data.yRes or 1440}, data.scale or 3, data.offset or 0, data.backgroundColor or colors.darkGray, data.primaryColor or colors.electricBlue, data.accentColor or colors.accentColor}) end
Expand Down Expand Up @@ -65,7 +64,7 @@ local function save()

for address, data in pairs(glassData) do
if data.energyDisplay then
table.insert(powerDisplayUsers, {component.proxy(address), {data.xRes or 2560, data.yRes or 1440}, data.scale or 3, data.backgroundColor or colors.darkGray, data.primaryColor or colors.electricBlue, data.accentColor or colors.accentColor})
table.insert(powerDisplayUsers, {component.proxy(address), {data.xRes or 2560, data.yRes or 1440}, data.scale or 3, data.backgroundColor or colors.darkGray, data.primaryColor or colors.electricBlue, data.accentColor or colors.accentColor, data.compactMode})
powerDisplay.changeColor(address, data.backgroundColor, data.primaryColor, data.accentColor)
powerDisplay.remove(address)
end
Expand Down Expand Up @@ -128,6 +127,7 @@ function hud.configure(x, y, gui, graphics, renderer, page)
{name = "Resolution (X)", attribute = "xRes", type = "number", defaultValue = 2560},
{name = "Resolution (Y)", attribute = "yRes", type = "number", defaultValue = 1440},
{name = "Scale", attribute = "scale", type = "number", defaultValue = 3},
{name = "Compact Mode", attribute = "compactMode", type = "boolean", defaultValue = false},
{name = "UTC Offset", attribute = "offset", type = "number", defaultValue = 0},
{name = "Primary Color", attribute = "primaryColor", type = "color", defaultValue = colors.electricBlue},
{name = "Accent Color", attribute = "accentColor", type = "color", defaultValue = colors.magenta},
Expand Down Expand Up @@ -185,14 +185,14 @@ local function updateFluidData()
local data = fluidMaximums[id]
local maximum = 0
if not data then
maximum = getMax(amount)
fluidMaximums[id] = {max=maximum, name=name}
maxium = getMax(amount)
fluidMaximums[id] = {max=maxium, name=name}
doSave = true
else
maximum = data.max
if data.max < amount then
maxium = getMax(amount)
fluidMaximums[id] = {max=maximum, name=name}
fluidMaximums[id] = {max=maxium, name=name}
doSave = true
end
end
Expand All @@ -207,34 +207,6 @@ local function updateFluidData()
saveFluidData()
end
end

-- YOTT tanks
for address, _ in pairs(component.list("gt_machine")) do
local info = component.proxy(address).getSensorInformation()
if (info[1] == "Fluid Name:") then
local name = parser.stripColors(info[2])
local id = string.lower(string.gsub(name, " ", ""))
local amount = parser.getInteger(info[6]) / 10
local capacity = parser.getInteger(info[4])
local data = fluidMaximums[id]
local maximum = 0

if not data then
maximum = getMax(capacity)
fluidMaximums[id] = {max=maximum, name=name}
doSave = true
else
maximum = data.max
if data.max ~= amount then
maximum = getMax(capacity)
fluidMaximums[id] = {max=maximum, name=name}
doSave = true
end
end

fluidData[id] = {amount=amount, name=name, max=maximum, id=id}
end
end
end

function hud.updateFluidSettings()
Expand Down
9 changes: 5 additions & 4 deletions hud/powerdisplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ end

local function getMaxEU()
file = io.open("/home/NIDAS/settings/maxWireless", "r")
local maxValue = 10e5
local maxValue = 0
if file ~= nil then
local data = serialization.unserialize(file:read("*a"))
if maxValue then
Expand Down Expand Up @@ -206,8 +206,9 @@ function powerDisplay.widget(glasses, data)
borderColor = glasses[i][4] or colors.darkGray,
primaryColor = glasses[i][5] or colors.electricBlue,
accentColor = glasses[i][6] or colors.magenta,
width = glasses[i][7] or 0,
heigth = glasses[i][8] or 29
width = 0,
heigth = 29,
compactMode = glasses[i][7] or false
})
end
end
Expand All @@ -216,7 +217,7 @@ function powerDisplay.widget(glasses, data)
if hudObjects[i].width == 0 then hudObjects[i].width = screen.size(hudObjects[i].resolution, hudObjects[i].scale)[1]/2 - 91 end
local h = hudObjects[i].heigth
local w = hudObjects[i].width
local compact = w < 250
local compact = (w < 250) or hudObjects[i].compactMode
local x = 0
local y = screen.size(hudObjects[i].resolution, hudObjects[i].scale)[2] - h
local hProgress = math.ceil(h * 0.4)
Expand Down
2 changes: 1 addition & 1 deletion nidas_version.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return "1.51"
return "1.52"

0 comments on commit e2f2326

Please sign in to comment.