#78 removed use of data in graphics layouts since we don't have data at construct time

This commit is contained in:
Mikayla Fischler 2022-09-05 16:04:32 -04:00
parent 621adbbcbc
commit 473763fd27
6 changed files with 26 additions and 37 deletions

View File

@ -16,7 +16,7 @@ local config = require("coordinator.config")
local coordinator = require("coordinator.coordinator")
local renderer = require("coordinator.renderer")
local COORDINATOR_VERSION = "alpha-v0.4.2"
local COORDINATOR_VERSION = "alpha-v0.4.3"
local print = util.print
local println = util.println

View File

@ -18,9 +18,8 @@ local border = core.graphics.border
---@param x integer
---@param y integer
---@param id integer
---@param data boiler_session_db|boilerv_session_db
---@param ps psil
local function new_view(root, x, y, id, data, ps)
local function new_view(root, x, y, id, ps)
local tag = id .. "_"
local boiler = Rectangle{parent=root,border=border(1, colors.gray, true),width=31,height=7,x=x,y=y}
@ -29,8 +28,8 @@ local function new_view(root, x, y, id, data, ps)
local lu_col = cpair(colors.gray, colors.gray)
local status = StateIndicator{parent=boiler,x=10,y=1,states=style.boiler.states,value=1,min_width=10}
local temp = DataIndicator{parent=boiler,x=5,y=3,lu_colors=lu_col,label="Temp:",unit="K",format="%10.2f",value=data.state.temperature,width=22,fg_bg=text_fg_bg}
local boil_r = DataIndicator{parent=boiler,x=5,y=4,lu_colors=lu_col,label="Boil:",unit="mB/t",format="%10.0f",value=data.state.boil_rate,commas=true,width=22,fg_bg=text_fg_bg}
local temp = DataIndicator{parent=boiler,x=5,y=3,lu_colors=lu_col,label="Temp:",unit="K",format="%10.2f",value=0,width=22,fg_bg=text_fg_bg}
local boil_r = DataIndicator{parent=boiler,x=5,y=4,lu_colors=lu_col,label="Boil:",unit="mB/t",format="%10.0f",value=0,commas=true,width=22,fg_bg=text_fg_bg}
ps.subscribe(tag .. "computed_status", status.update)
ps.subscribe(tag .. "temperature", temp.update)
@ -50,11 +49,6 @@ local function new_view(root, x, y, id, data, ps)
ps.subscribe(tag .. "water_fill", water.update)
ps.subscribe(tag .. "steam_fill", steam.update)
ps.subscribe(tag .. "ccool_fill", ccool.update)
hcool.update(data.tanks.hcool_fill)
water.update(data.tanks.water_fill)
steam.update(data.tanks.steam_fill)
ccool.update(data.tanks.ccool_fill)
end
return new_view

View File

@ -27,9 +27,9 @@ local function new_view(root, x, y, data, ps)
local lu_col = cpair(colors.gray, colors.gray)
local status = StateIndicator{parent=reactor,x=8,y=1,states=style.reactor.states,value=1,min_width=14}
local core_temp = DataIndicator{parent=reactor,x=2,y=3,lu_colors=lu_col,label="Core Temp:",unit="K",format="%10.2f",value=data.mek_status.temp,width=26,fg_bg=text_fg_bg}
local burn_r = DataIndicator{parent=reactor,x=2,y=4,lu_colors=lu_col,label="Burn Rate:",unit="mB/t",format="%10.1f",value=data.mek_status.act_burn_rate,width=26,fg_bg=text_fg_bg}
local heating_r = DataIndicator{parent=reactor,x=2,y=5,lu_colors=lu_col,label="Heating:",unit="mB/t",format="%12.0f",value=data.mek_status.heating_rate,commas=true,width=26,fg_bg=text_fg_bg}
local core_temp = DataIndicator{parent=reactor,x=2,y=3,lu_colors=lu_col,label="Core Temp:",unit="K",format="%10.2f",value=0,width=26,fg_bg=text_fg_bg}
local burn_r = DataIndicator{parent=reactor,x=2,y=4,lu_colors=lu_col,label="Burn Rate:",unit="mB/t",format="%10.1f",value=0,width=26,fg_bg=text_fg_bg}
local heating_r = DataIndicator{parent=reactor,x=2,y=5,lu_colors=lu_col,label="Heating:",unit="mB/t",format="%12.0f",value=0,commas=true,width=26,fg_bg=text_fg_bg}
ps.subscribe("computed_status", status.update)
ps.subscribe("temp", core_temp.update)
@ -43,8 +43,10 @@ local function new_view(root, x, y, data, ps)
TextBox{parent=reactor_fills,text="HCOOL",x=2,y=4,height=1,fg_bg=text_fg_bg}
TextBox{parent=reactor_fills,text="WASTE",x=2,y=5,height=1,fg_bg=text_fg_bg}
local ccool_color = util.trinary(data.mek_status.ccool_type == "sodium", cpair(colors.lightBlue,colors.gray), cpair(colors.blue,colors.gray))
local hcool_color = util.trinary(data.mek_status.hcool_type == "superheated_sodium", cpair(colors.orange,colors.gray), cpair(colors.white,colors.gray))
-- local ccool_color = util.trinary(data.mek_status.ccool_type == "sodium", cpair(colors.lightBlue,colors.gray), cpair(colors.blue,colors.gray))
-- local hcool_color = util.trinary(data.mek_status.hcool_type == "superheated_sodium", cpair(colors.orange,colors.gray), cpair(colors.white,colors.gray))
local ccool_color = util.trinary(true, cpair(colors.lightBlue,colors.gray), cpair(colors.blue,colors.gray))
local hcool_color = util.trinary(true, cpair(colors.orange,colors.gray), cpair(colors.white,colors.gray))
local fuel = HorizontalBar{parent=reactor_fills,x=8,y=1,show_percent=true,bar_fg_bg=cpair(colors.black,colors.gray),height=1,width=14}
local ccool = HorizontalBar{parent=reactor_fills,x=8,y=2,show_percent=true,bar_fg_bg=ccool_color,height=1,width=14}
@ -55,11 +57,6 @@ local function new_view(root, x, y, data, ps)
ps.subscribe("ccool_fill", ccool.update)
ps.subscribe("hcool_fill", hcool.update)
ps.subscribe("waste_fill", waste.update)
fuel.update(data.mek_status.fuel_fill)
ccool.update(data.mek_status.ccool_fill)
hcool.update(data.mek_status.hcool_fill)
waste.update(data.mek_status.waste_fill)
end
return new_view

View File

@ -18,9 +18,8 @@ local border = core.graphics.border
---@param x integer
---@param y integer
---@param id integer
---@param data turbine_session_db|turbinev_session_db
---@param ps psil
local function new_view(root, x, y, id, data, ps)
local function new_view(root, x, y, id, ps)
local tag = id .. "_"
local turbine = Rectangle{parent=root,border=border(1, colors.gray, true),width=23,height=7,x=x,y=y}
@ -29,8 +28,8 @@ local function new_view(root, x, y, id, data, ps)
local lu_col = cpair(colors.gray, colors.gray)
local status = StateIndicator{parent=turbine,x=8,y=1,states=style.turbine.states,value=1,min_width=10}
local prod_rate = DataIndicator{parent=turbine,x=5,y=3,lu_colors=lu_col,label="",unit="MFE",format="%10.2f",value=data.state.prod_rate,width=16,fg_bg=text_fg_bg}
local flow_rate = DataIndicator{parent=turbine,x=5,y=4,lu_colors=lu_col,label="",unit="mB/t",format="%10.0f",value=data.state.flow_rate,commas=true,width=16,fg_bg=text_fg_bg}
local prod_rate = DataIndicator{parent=turbine,x=5,y=3,lu_colors=lu_col,label="",unit="MFE",format="%10.2f",value=0,width=16,fg_bg=text_fg_bg}
local flow_rate = DataIndicator{parent=turbine,x=5,y=4,lu_colors=lu_col,label="",unit="mB/t",format="%10.0f",value=0,commas=true,width=16,fg_bg=text_fg_bg}
ps.subscribe(tag .. "computed_status", status.update)
ps.subscribe(tag .. "prod_rate", prod_rate.update)
@ -39,8 +38,6 @@ local function new_view(root, x, y, id, data, ps)
local steam = VerticalBar{parent=turbine,x=2,y=1,fg_bg=cpair(colors.white,colors.gray),height=5,width=2}
ps.subscribe(tag .. "steam_fill", steam.update)
steam.update(data.tanks.steam_fill)
end
return new_view

View File

@ -73,8 +73,8 @@ local function make(parent, x, y, unit)
-- BOILERS --
-------------
if num_boilers >= 1 then boiler_view(root, 16, 11, 1, unit.boiler_data_tbl[1], unit.boiler_ps_tbl[1]) end
if num_boilers >= 2 then boiler_view(root, 16, 19, 2, unit.boiler_data_tbl[2], unit.boiler_ps_tbl[2]) end
if num_boilers >= 1 then boiler_view(root, 16, 11, 1, unit.boiler_ps_tbl[1]) end
if num_boilers >= 2 then boiler_view(root, 16, 19, 2, unit.boiler_ps_tbl[2]) end
--------------
-- TURBINES --
@ -84,17 +84,17 @@ local function make(parent, x, y, unit)
local no_boilers = num_boilers == 0
if (num_turbines >= 3) or no_boilers or (num_boilers == 1 and num_turbines >= 2) then
turbine_view(root, 58, 3, t_idx, unit.turbine_data_tbl[t_idx], unit.turbine_ps_tbl[t_idx])
turbine_view(root, 58, 3, t_idx, unit.turbine_ps_tbl[t_idx])
t_idx = t_idx + 1
end
if (num_turbines >= 1 and not no_boilers) or num_turbines >= 2 then
turbine_view(root, 58, 11, t_idx, unit.turbine_data_tbl[t_idx], unit.turbine_ps_tbl[t_idx])
turbine_view(root, 58, 11, t_idx, unit.turbine_ps_tbl[t_idx])
t_idx = t_idx + 1
end
if (num_turbines >= 2 and num_boilers >= 2) or num_turbines >= 3 then
turbine_view(root, 58, 19, t_idx, unit.turbine_data_tbl[t_idx], unit.turbine_ps_tbl[t_idx])
turbine_view(root, 58, 19, t_idx, unit.turbine_ps_tbl[t_idx])
end
local steam_pipes_b = {}

View File

@ -3,15 +3,16 @@
--
local database = require("coordinator.database")
local style = require("coordinator.ui.style")
local unit_overview = require("coordinator.ui.components.unit_overview")
local core = require("graphics.core")
local DisplayBox = require("graphics.elements.displaybox")
local TextBox = require("graphics.elements.textbox")
local unit_overview = require("coordinator.ui.components.unit_overview")
local TEXT_ALIGN = core.graphics.TEXT_ALIGN
local function init(monitor)