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 diff --git a/pocket/config/system.lua b/pocket/config/system.lua index 321ef59..110a6cf 100644 --- a/pocket/config/system.lua +++ b/pocket/config/system.lua @@ -53,25 +53,43 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, style, exit) --#region Pocket UI local ui_c_1 = Div{parent=ui_cfg,x=2,y=4,width=24} + local ui_c_2 = Div{parent=ui_cfg,x=2,y=4,width=24} + + local ui_pane = MultiPane{parent=net_cfg,x=1,y=4,panes={ui_c_1,ui_c_2}} TextBox{parent=ui_cfg,x=1,y=2,text=" Pocket UI",fg_bg=cpair(colors.black,colors.lime)} - TextBox{parent=ui_c_1,x=1,y=1,height=3,text="You may customize units below."} + TextBox{parent=ui_c_1,x=1,y=1,height=3,text="You may customize UI options below."} - TextBox{parent=ui_c_1,x=1,y=4,text="Temperature Scale"} - local temp_scale = RadioButton{parent=ui_c_1,x=1,y=5,default=ini_cfg.TempScale,options=types.TEMP_SCALE_NAMES,callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.lime} + TextBox{parent=ui_c_1,y=4,text="Po/Pu Pellet Color"} + local pellet_color = RadioButton{parent=ui_c_1,y=5,default=util.trinary(ini_cfg.GreenPuPellet,1,2),options={"Green Pu/Cyan Po","Cyan Pu/Green Po"},callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.lime} - TextBox{parent=ui_c_1,x=1,y=10,text="Energy Scale"} - local energy_scale = RadioButton{parent=ui_c_1,x=1,y=11,default=ini_cfg.EnergyScale,options=types.ENERGY_SCALE_NAMES,callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.lime} + TextBox{parent=ui_c_1,y=8,height=4,text="In Mekanism 10.4 and later, pellet colors now match gas colors (Cyan Pu/Green Po).",fg_bg=g_lg_fg_bg} local function submit_ui_opts() + tmp_cfg.GreenPuPellet = pellet_color.get_value() == 1 + ui_pane.set_value(2) + end + + PushButton{parent=ui_c_1,x=1,y=15,text="\x1b Back",callback=function()main_pane.set_value(1)end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg} + PushButton{parent=ui_c_1,x=19,y=15,text="Next \x1a",callback=submit_ui_opts,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg} + + TextBox{parent=ui_c_2,x=1,y=1,height=3,text="You may customize units below."} + + TextBox{parent=ui_c_2,x=1,y=4,text="Temperature Scale"} + local temp_scale = RadioButton{parent=ui_c_2,x=1,y=5,default=ini_cfg.TempScale,options=types.TEMP_SCALE_NAMES,callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.lime} + + TextBox{parent=ui_c_2,x=1,y=10,text="Energy Scale"} + local energy_scale = RadioButton{parent=ui_c_2,x=1,y=11,default=ini_cfg.EnergyScale,options=types.ENERGY_SCALE_NAMES,callback=function()end,radio_colors=cpair(colors.lightGray,colors.black),select_color=colors.lime} + + local function submit_ui_units() tmp_cfg.TempScale = temp_scale.get_value() tmp_cfg.EnergyScale = energy_scale.get_value() main_pane.set_value(3) end - PushButton{parent=ui_c_1,x=1,y=15,text="\x1b Back",callback=function()main_pane.set_value(1)end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg} - PushButton{parent=ui_c_1,x=19,y=15,text="Next \x1a",callback=submit_ui_opts,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg} + PushButton{parent=ui_c_2,x=1,y=15,text="\x1b Back",callback=function()ui_pane.set_value(1)end,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg} + PushButton{parent=ui_c_2,x=19,y=15,text="Next \x1a",callback=submit_ui_units,fg_bg=nav_fg_bg,active_fg_bg=btn_act_fg_bg} --#endregion @@ -266,6 +284,7 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, style, exit) load_settings(settings_cfg, true) load_settings(ini_cfg) + try_set(pellet_color, ini_cfg.GreenPuPellet) try_set(temp_scale, ini_cfg.TempScale) try_set(energy_scale, ini_cfg.EnergyScale) try_set(svr_chan, ini_cfg.SVR_Channel) @@ -374,6 +393,8 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, style, exit) val = string.rep("*", string.len(val)) elseif f[1] == "LogMode" then val = tri(raw == log.MODE.APPEND, "append", "replace") + elseif f[1] == "GreenPuPellet" then + val = tri(raw, "Green Pu/Cyan Po", "Cyan Pu/Green Po") elseif f[1] == "TempScale" then val = util.strval(types.TEMP_SCALE_NAMES[raw]) elseif f[1] == "EnergyScale" then diff --git a/pocket/configure.lua b/pocket/configure.lua index 175be03..d714d9f 100644 --- a/pocket/configure.lua +++ b/pocket/configure.lua @@ -29,7 +29,8 @@ local CENTER = core.ALIGN.CENTER -- changes to the config data/format to let the user know local changes = { { "v0.9.2", { "Added temperature scale options" } }, - { "v0.11.3", { "Added energy scale options" } } + { "v0.11.3", { "Added energy scale options" } }, + { "v0.13.2", { "Added option for Po/Pu pellet green/cyan pairing" } } } ---@class pkt_configurator @@ -64,6 +65,7 @@ local tool_ctl = { ---@class pkt_config local tmp_cfg = { + GreenPuPellet = false, TempScale = 1, ---@type TEMP_SCALE EnergyScale = 1, ---@type ENERGY_SCALE SVR_Channel = nil, ---@type integer @@ -84,6 +86,7 @@ local settings_cfg = {} -- all settings fields, their nice names, and their default values local fields = { + { "GreenPuPellet", "Pellet Colors", false }, { "TempScale", "Temperature Scale", types.TEMP_SCALE.KELVIN }, { "EnergyScale", "Energy Scale", types.ENERGY_SCALE.FE }, { "SVR_Channel", "SVR Channel", 16240 }, diff --git a/pocket/pocket.lua b/pocket/pocket.lua index 7bfe669..e0e285c 100644 --- a/pocket/pocket.lua +++ b/pocket/pocket.lua @@ -38,6 +38,7 @@ pocket.config = config function pocket.load_config() if not settings.load("/pocket.settings") then return false end + config.GreenPuPellet = settings.get("GreenPuPellet") config.TempScale = settings.get("TempScale") config.EnergyScale = settings.get("EnergyScale") @@ -54,6 +55,7 @@ function pocket.load_config() local cfv = util.new_validator() + cfv.assert_type_bool(config.GreenPuPellet) cfv.assert_type_int(config.TempScale) cfv.assert_range(config.TempScale, 1, 4) cfv.assert_type_int(config.EnergyScale) diff --git a/pocket/startup.lua b/pocket/startup.lua index c1d55ef..a2eddd6 100644 --- a/pocket/startup.lua +++ b/pocket/startup.lua @@ -22,7 +22,7 @@ local pocket = require("pocket.pocket") local renderer = require("pocket.renderer") local threads = require("pocket.threads") -local POCKET_VERSION = "v0.13.1-beta" +local POCKET_VERSION = "v0.13.2-beta" local println = util.println local println_ts = util.println_ts diff --git a/pocket/ui/apps/waste.lua b/pocket/ui/apps/waste.lua index 8037d82..bd39e7c 100644 --- a/pocket/ui/apps/waste.lua +++ b/pocket/ui/apps/waste.lua @@ -95,8 +95,8 @@ local function new_view(root) local function set_waste(mode) process.set_unit_waste(i, mode) end - local waste_prod = StateIndicator{parent=u_div,x=16,y=3,states=style.waste.states_abbrv,value=1,min_width=6} - local waste_mode = RadioButton{parent=u_div,y=3,options=style.waste.unit_opts,callback=set_waste,radio_colors=cpair(colors.lightGray,colors.gray),select_color=colors.white} + local waste_prod = StateIndicator{parent=u_div,x=16,y=3,states=style.get_waste().states_abbrv,value=1,min_width=6} + local waste_mode = RadioButton{parent=u_div,y=3,options=style.get_waste().unit_opts,callback=set_waste,radio_colors=cpair(colors.lightGray,colors.gray),select_color=colors.white} waste_prod.register(u_ps, "U_WasteProduct", waste_prod.update) waste_mode.register(u_ps, "U_WasteMode", waste_mode.set_value) @@ -159,8 +159,8 @@ local function new_view(root) TextBox{parent=c_div,y=1,text="Waste Control",alignment=ALIGN.CENTER} - local status = StateIndicator{parent=c_div,x=3,y=3,states=style.waste.states,value=1,min_width=17} - local waste_prod = RadioButton{parent=c_div,y=5,options=style.waste.options,callback=process.set_process_waste,radio_colors=cpair(colors.lightGray,colors.gray),select_color=colors.white} + local status = StateIndicator{parent=c_div,x=3,y=3,states=style.get_waste().states,value=1,min_width=17} + local waste_prod = RadioButton{parent=c_div,y=5,options=style.get_waste().options,callback=process.set_process_waste,radio_colors=cpair(colors.lightGray,colors.gray),select_color=colors.white} status.register(f_ps, "current_waste_product", status.update) waste_prod.register(f_ps, "process_waste_product", waste_prod.set_value) diff --git a/pocket/ui/style.lua b/pocket/ui/style.lua index 7b35cc4..0c77806 100644 --- a/pocket/ui/style.lua +++ b/pocket/ui/style.lua @@ -2,12 +2,18 @@ -- Graphics Style Options -- -local core = require("graphics.core") +local util = require("scada-common.util") + +local core = require("graphics.core") + +local pocket = require("pocket.pocket") local style = {} local cpair = core.cpair +local config = pocket.config + -- GLOBAL -- style.root = cpair(colors.white, colors.black) @@ -171,22 +177,29 @@ style.sps = { } } -style.waste = { - -- auto waste processing states - states = { - { color = cpair(colors.black, colors.green), text = "PLUTONIUM" }, - { color = cpair(colors.black, colors.cyan), text = "POLONIUM" }, - { color = cpair(colors.black, colors.purple), text = "ANTI MATTER" } - }, - states_abbrv = { - { color = cpair(colors.black, colors.green), text = "Pu" }, - { color = cpair(colors.black, colors.cyan), text = "Po" }, - { color = cpair(colors.black, colors.purple), text = "AM" } - }, - -- process radio button options - options = { "Plutonium", "Polonium", "Antimatter" }, - -- unit waste selection - unit_opts = { "Auto", "Plutonium", "Polonium", "Antimatter" } -} +-- get waste styling, which depends on the configuration +---@return { states: { color: color, text: string }, states_abbrv: { color: color, text: string }, options: string[], unit_opts: string[] } +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) + + 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 = { "Auto", "Plutonium", "Polonium", "Antimatter" } + } +end return style