simplified checks for colorblind mode

This commit is contained in:
Mikayla
2024-03-12 16:24:32 +00:00
parent 89d56d3101
commit 8dae632b25
10 changed files with 43 additions and 34 deletions

View File

@ -32,8 +32,7 @@ local UNIT_TYPE_LABELS = { "UNKNOWN", "REDSTONE", "BOILER", "TURBINE", "DYNAMIC
-- create new front panel view
---@param panel graphics_element main displaybox
---@param units table unit list
---@param color_mode COLOR_MODE color mode
local function init(panel, units, color_mode)
local function init(panel, units)
local disabled_fg = style.fp.disabled_fg
TextBox{parent=panel,y=1,text="RTU GATEWAY",alignment=ALIGN.CENTER,height=1,fg_bg=style.theme.header}
@ -53,7 +52,7 @@ local function init(panel, units, color_mode)
local modem = LED{parent=system,label="MODEM",colors=ind_grn}
if color_mode == themes.COLOR_MODE.STANDARD then
if not style.colorblind then
local network = RGBLED{parent=system,label="NETWORK",colors={colors.green,colors.red,colors.orange,colors.yellow,colors.gray}}
network.update(types.PANEL_LINK_STATE.DISCONNECTED)
network.register(databus.ps, "link_state", network.update)

View File

@ -12,19 +12,23 @@ local cpair = core.cpair
style.theme = themes.sandstone
style.fp = themes.get_fp_style(style.theme)
style.colorblind = false
style.ind_grn = cpair(colors.green, colors.green_off)
-- set theme per configuration
---@param fp integer fp theme ID (1 = sandstone, 2 = basalt)
function style.set_theme(fp)
if fp == 1 then
---@param fp FP_THEME front panel theme
---@param color_mode COLOR_MODE the color mode to use
function style.set_theme(fp, color_mode)
if fp == themes.FP_THEME.SANDSTONE then
style.theme = themes.sandstone
elseif fp == 2 then
elseif fp == themes.FP_THEME.BASALT then
style.theme = themes.basalt
end
style.fp = themes.get_fp_style(style.theme)
style.colorblind = color_mode ~= themes.COLOR_MODE.STANDARD
end
return style

View File

@ -27,7 +27,7 @@ function renderer.try_start_ui(units, theme, color_mode)
if ui.display == nil then
-- set theme
style.set_theme(theme)
style.set_theme(theme, color_mode)
-- reset terminal
term.setTextColor(colors.white)
@ -49,7 +49,7 @@ function renderer.try_start_ui(units, theme, color_mode)
-- init front panel view
status, msg = pcall(function ()
ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root}
panel_view(ui.display, units, color_mode)
panel_view(ui.display, units)
end)
if status then