From 1af2cdba8d97d59d757bd12fd031b82ddfe19f53 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sat, 26 Apr 2025 15:21:09 -0400 Subject: [PATCH] #616 fixes to coordinator pellet color option --- coordinator/config/hmi.lua | 1 + coordinator/config/system.lua | 1 + coordinator/configure.lua | 1 + coordinator/startup.lua | 2 +- coordinator/ui/components/process_ctl.lua | 6 +-- coordinator/ui/components/unit_detail.lua | 2 +- coordinator/ui/style.lua | 50 ++++++++++++----------- 7 files changed, 35 insertions(+), 28 deletions(-) diff --git a/coordinator/config/hmi.lua b/coordinator/config/hmi.lua index 89daef6..80c67fe 100644 --- a/coordinator/config/hmi.lua +++ b/coordinator/config/hmi.lua @@ -250,6 +250,7 @@ function hmi.create(tool_ctl, main_pane, cfg_sys, divs, style) local function submit_ui_opts() tmp_cfg.Time24Hour = tool_ctl.clock_fmt.get_value() == 1 + tmp_cfg.GreenPuPellet = tool_ctl.pellet_color.get_value() == 1 tmp_cfg.TempScale = tool_ctl.temp_scale.get_value() tmp_cfg.EnergyScale = tool_ctl.energy_scale.get_value() main_pane.set_value(7) diff --git a/coordinator/config/system.lua b/coordinator/config/system.lua index 3bb035f..5becf55 100644 --- a/coordinator/config/system.lua +++ b/coordinator/config/system.lua @@ -380,6 +380,7 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, ext, style) try_set(tool_ctl.num_units, ini_cfg.UnitCount) try_set(tool_ctl.dis_flow_view, ini_cfg.DisableFlowView) try_set(tool_ctl.s_vol, ini_cfg.SpeakerVolume) + try_set(tool_ctl.pellet_color, ini_cfg.GreenPuPellet) try_set(tool_ctl.clock_fmt, tri(ini_cfg.Time24Hour, 1, 2)) try_set(tool_ctl.temp_scale, ini_cfg.TempScale) try_set(tool_ctl.energy_scale, ini_cfg.EnergyScale) diff --git a/coordinator/configure.lua b/coordinator/configure.lua index d76aac2..474c727 100644 --- a/coordinator/configure.lua +++ b/coordinator/configure.lua @@ -78,6 +78,7 @@ local tool_ctl = { -- settings elements from hmi dis_flow_view = nil, ---@type Checkbox s_vol = nil, ---@type NumberField + pellet_color = nil, ---@type RadioButton clock_fmt = nil, ---@type RadioButton temp_scale = nil, ---@type RadioButton energy_scale = nil, ---@type RadioButton diff --git a/coordinator/startup.lua b/coordinator/startup.lua index ee9468e..323af98 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -19,7 +19,7 @@ local renderer = require("coordinator.renderer") local sounder = require("coordinator.sounder") local threads = require("coordinator.threads") -local COORDINATOR_VERSION = "v1.6.13" +local COORDINATOR_VERSION = "v1.6.14" local CHUNK_LOAD_DELAY_S = 30.0 diff --git a/coordinator/ui/components/process_ctl.lua b/coordinator/ui/components/process_ctl.lua index f649ac5..780905e 100644 --- a/coordinator/ui/components/process_ctl.lua +++ b/coordinator/ui/components/process_ctl.lua @@ -325,7 +325,7 @@ local function new_view(root, x, y) TextBox{parent=waste_status,y=i,text="U"..i.." Waste",width=8} local a_waste = IndicatorLight{parent=waste_status,x=10,y=i,label="Auto",colors=ind_wht} - local waste_m = StateIndicator{parent=waste_status,x=17,y=i,states=style.waste.states_abbrv,value=1,min_width=6} + local waste_m = StateIndicator{parent=waste_status,x=17,y=i,states=style.get_waste().states_abbrv,value=1,min_width=6} a_waste.register(unit.unit_ps, "U_AutoWaste", a_waste.update) waste_m.register(unit.unit_ps, "U_WasteProduct", waste_m.update) @@ -339,11 +339,11 @@ local function new_view(root, x, y) TextBox{parent=waste_sel,text="WASTE PRODUCTION",alignment=ALIGN.CENTER,width=21,x=1,y=2,fg_bg=cutout_fg_bg} local rect = Rectangle{parent=waste_sel,border=border(1,colors.brown,true),width=21,height=22,x=1,y=3} - local status = StateIndicator{parent=rect,x=2,y=1,states=style.waste.states,value=1,min_width=17} + local status = StateIndicator{parent=rect,x=2,y=1,states=style.get_waste().states,value=1,min_width=17} status.register(facility.ps, "current_waste_product", status.update) - local waste_prod = RadioButton{parent=rect,x=2,y=3,options=style.waste.options,callback=process.set_process_waste,radio_colors=cpair(style.theme.accent_dark,style.theme.accent_light),select_color=colors.brown} + local waste_prod = RadioButton{parent=rect,x=2,y=3,options=style.get_waste().options,callback=process.set_process_waste,radio_colors=cpair(style.theme.accent_dark,style.theme.accent_light),select_color=colors.brown} waste_prod.register(facility.ps, "process_waste_product", waste_prod.set_value) diff --git a/coordinator/ui/components/unit_detail.lua b/coordinator/ui/components/unit_detail.lua index 8c9ce7a..44d082c 100644 --- a/coordinator/ui/components/unit_detail.lua +++ b/coordinator/ui/components/unit_detail.lua @@ -398,7 +398,7 @@ local function init(parent, id) local waste_proc = Rectangle{parent=main,border=border(1,colors.brown,true),thin=true,width=33,height=3,x=46,y=49} local waste_div = Div{parent=waste_proc,x=2,y=1,width=31,height=1} - local waste_mode = MultiButton{parent=waste_div,x=1,y=1,options=style.waste.unit_opts,callback=unit.set_waste,min_width=6} + local waste_mode = MultiButton{parent=waste_div,x=1,y=1,options=style.get_waste().unit_opts,callback=unit.set_waste,min_width=6} waste_mode.register(u_ps, "U_WasteMode", waste_mode.set_value) diff --git a/coordinator/ui/style.lua b/coordinator/ui/style.lua index e22cb90..2aff611 100644 --- a/coordinator/ui/style.lua +++ b/coordinator/ui/style.lua @@ -227,30 +227,34 @@ style.sps = { } } -local pu_color = util.trinary(config.GreenPuPellet, colors.green, colors.cyan) -local po_color = util.trinary(config.GreenPuPellet, colors.cyan, colors.green) +-- get waste styling, which depends on the configuration +---@return { states: { color: color, text: string }, states_abbrv: { color: color, text: string }, options: string[], unit_opts: { text: string, fg_bg: cpair, active_fg_bg:cpair } } +function style.get_waste() + local pu_color = util.trinary(config.GreenPuPellet, colors.green, colors.cyan) + local po_color = util.trinary(config.GreenPuPellet, colors.cyan, colors.green) -style.waste = { - -- auto waste processing states - states = { - { color = cpair(colors.black, pu_color), text = "PLUTONIUM" }, - { color = cpair(colors.black, po_color), text = "POLONIUM" }, - { color = cpair(colors.black, colors.purple), text = "ANTI MATTER" } - }, - states_abbrv = { - { color = cpair(colors.black, pu_color), text = "Pu" }, - { color = cpair(colors.black, po_color), text = "Po" }, - { color = cpair(colors.black, colors.purple), text = "AM" } - }, - -- process radio button options - options = { "Plutonium", "Polonium", "Antimatter" }, - -- unit waste selection - unit_opts = { - { text = "Auto", fg_bg = cpair(colors.black, colors.lightGray), active_fg_bg = cpair(colors.white, colors.gray) }, - { text = "Pu", fg_bg = cpair(colors.black, colors.lightGray), active_fg_bg = cpair(colors.black, pu_color) }, - { text = "Po", fg_bg = cpair(colors.black, colors.lightGray), active_fg_bg = cpair(colors.black, po_color) }, - { text = "AM", fg_bg = cpair(colors.black, colors.lightGray), active_fg_bg = cpair(colors.black, colors.purple) } + return { + -- auto waste processing states + states = { + { color = cpair(colors.black, pu_color), text = "PLUTONIUM" }, + { color = cpair(colors.black, po_color), text = "POLONIUM" }, + { color = cpair(colors.black, colors.purple), text = "ANTI MATTER" } + }, + states_abbrv = { + { color = cpair(colors.black, pu_color), text = "Pu" }, + { color = cpair(colors.black, po_color), text = "Po" }, + { color = cpair(colors.black, colors.purple), text = "AM" } + }, + -- process radio button options + options = { "Plutonium", "Polonium", "Antimatter" }, + -- unit waste selection + unit_opts = { + { text = "Auto", fg_bg = cpair(colors.black, colors.lightGray), active_fg_bg = cpair(colors.white, colors.gray) }, + { text = "Pu", fg_bg = cpair(colors.black, colors.lightGray), active_fg_bg = cpair(colors.black, pu_color) }, + { text = "Po", fg_bg = cpair(colors.black, colors.lightGray), active_fg_bg = cpair(colors.black, po_color) }, + { text = "AM", fg_bg = cpair(colors.black, colors.lightGray), active_fg_bg = cpair(colors.black, colors.purple) } + } } -} +end return style