mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
simplified checks for colorblind mode
This commit is contained in:
parent
89d56d3101
commit
8dae632b25
@ -16,7 +16,6 @@ local unit_view = require("coordinator.ui.layout.unit_view")
|
|||||||
|
|
||||||
local core = require("graphics.core")
|
local core = require("graphics.core")
|
||||||
local flasher = require("graphics.flasher")
|
local flasher = require("graphics.flasher")
|
||||||
local themes = require("graphics.themes")
|
|
||||||
|
|
||||||
local DisplayBox = require("graphics.elements.displaybox")
|
local DisplayBox = require("graphics.elements.displaybox")
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ end
|
|||||||
-- apply renderer configurations
|
-- apply renderer configurations
|
||||||
---@param config crd_config
|
---@param config crd_config
|
||||||
function renderer.configure(config)
|
function renderer.configure(config)
|
||||||
style.set_themes(config.MainTheme, config.FrontPanelTheme, config.ColorMode ~= themes.COLOR_MODE.STANDARD)
|
style.set_themes(config.MainTheme, config.FrontPanelTheme, config.ColorMode)
|
||||||
|
|
||||||
engine.color_mode = config.ColorMode
|
engine.color_mode = config.ColorMode
|
||||||
engine.disable_flow_view = config.DisableFlowView
|
engine.disable_flow_view = config.DisableFlowView
|
||||||
@ -135,7 +134,7 @@ function renderer.try_start_fp()
|
|||||||
-- show front panel view on terminal
|
-- show front panel view on terminal
|
||||||
status, msg = pcall(function ()
|
status, msg = pcall(function ()
|
||||||
engine.ui.front_panel = DisplayBox{window=term.native(),fg_bg=style.fp.root}
|
engine.ui.front_panel = DisplayBox{window=term.native(),fg_bg=style.fp.root}
|
||||||
panel_view(engine.ui.front_panel, #engine.monitors.unit_displays, engine.color_mode)
|
panel_view(engine.ui.front_panel, #engine.monitors.unit_displays)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if status then
|
if status then
|
||||||
|
@ -13,7 +13,6 @@ local style = require("coordinator.ui.style")
|
|||||||
local pkt_entry = require("coordinator.ui.components.pkt_entry")
|
local pkt_entry = require("coordinator.ui.components.pkt_entry")
|
||||||
|
|
||||||
local core = require("graphics.core")
|
local core = require("graphics.core")
|
||||||
local themes = require("graphics.themes")
|
|
||||||
|
|
||||||
local Div = require("graphics.elements.div")
|
local Div = require("graphics.elements.div")
|
||||||
local ListBox = require("graphics.elements.listbox")
|
local ListBox = require("graphics.elements.listbox")
|
||||||
@ -36,8 +35,7 @@ local led_grn = style.led_grn
|
|||||||
-- create new front panel view
|
-- create new front panel view
|
||||||
---@param panel graphics_element main displaybox
|
---@param panel graphics_element main displaybox
|
||||||
---@param num_units integer number of units (number of unit monitors)
|
---@param num_units integer number of units (number of unit monitors)
|
||||||
---@param color_mode COLOR_MODE color mode
|
local function init(panel, num_units)
|
||||||
local function init(panel, num_units, color_mode)
|
|
||||||
local ps = iocontrol.get_db().fp.ps
|
local ps = iocontrol.get_db().fp.ps
|
||||||
|
|
||||||
TextBox{parent=panel,y=1,text="SCADA COORDINATOR",alignment=ALIGN.CENTER,height=1,fg_bg=style.fp_theme.header}
|
TextBox{parent=panel,y=1,text="SCADA COORDINATOR",alignment=ALIGN.CENTER,height=1,fg_bg=style.fp_theme.header}
|
||||||
@ -61,7 +59,7 @@ local function init(panel, num_units, color_mode)
|
|||||||
|
|
||||||
local modem = LED{parent=system,label="MODEM",colors=led_grn}
|
local modem = LED{parent=system,label="MODEM",colors=led_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}}
|
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.update(types.PANEL_LINK_STATE.DISCONNECTED)
|
||||||
network.register(ps, "link_state", network.update)
|
network.register(ps, "link_state", network.update)
|
||||||
|
@ -84,12 +84,13 @@ local deepslate = {
|
|||||||
style.theme = smooth_stone
|
style.theme = smooth_stone
|
||||||
|
|
||||||
-- set themes per configurations
|
-- set themes per configurations
|
||||||
---@param main integer main theme ID (1 = smooth_stone, 2 = deepslate)
|
---@param main UI_THEME main UI theme
|
||||||
---@param fp integer fp theme ID (1 = sandstone, 2 = basalt)
|
---@param fp FP_THEME front panel theme
|
||||||
---@param colorblind boolean true if in a colorblind mode
|
---@param color_mode COLOR_MODE the color mode to use
|
||||||
function style.set_themes(main, fp, colorblind)
|
function style.set_themes(main, fp, color_mode)
|
||||||
style.ind_bkg = colors.gray
|
local colorblind = color_mode ~= themes.COLOR_MODE.STANDARD
|
||||||
|
|
||||||
|
style.ind_bkg = colors.gray
|
||||||
style.ind_hi_box_bg = util.trinary(colorblind, colors.black, colors.gray)
|
style.ind_hi_box_bg = util.trinary(colorblind, colors.black, colors.gray)
|
||||||
|
|
||||||
if main == themes.UI_THEME.SMOOTH_STONE then
|
if main == themes.UI_THEME.SMOOTH_STONE then
|
||||||
@ -100,6 +101,8 @@ function style.set_themes(main, fp, colorblind)
|
|||||||
style.ind_hi_box_bg = util.trinary(colorblind, colors.black, colors.lightGray)
|
style.ind_hi_box_bg = util.trinary(colorblind, colors.black, colors.lightGray)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
style.colorblind = colorblind
|
||||||
|
|
||||||
style.root = cpair(style.theme.text, style.theme.bg)
|
style.root = cpair(style.theme.text, style.theme.bg)
|
||||||
style.label = cpair(style.theme.label, style.theme.bg)
|
style.label = cpair(style.theme.label, style.theme.bg)
|
||||||
|
|
||||||
|
@ -36,8 +36,7 @@ local ind_red = style.ind_red
|
|||||||
|
|
||||||
-- create new front panel view
|
-- create new front panel view
|
||||||
---@param panel graphics_element main displaybox
|
---@param panel graphics_element main displaybox
|
||||||
---@param color_mode COLOR_MODE color mode
|
local function init(panel)
|
||||||
local function init(panel, color_mode)
|
|
||||||
local s_hi_box = style.theme.highlight_box
|
local s_hi_box = style.theme.highlight_box
|
||||||
|
|
||||||
local disabled_fg = style.fp.disabled_fg
|
local disabled_fg = style.fp.disabled_fg
|
||||||
@ -61,7 +60,7 @@ local function init(panel, color_mode)
|
|||||||
local reactor = LEDPair{parent=system,label="REACTOR",off=colors.red,c1=colors.yellow,c2=colors.green}
|
local reactor = LEDPair{parent=system,label="REACTOR",off=colors.red,c1=colors.yellow,c2=colors.green}
|
||||||
local modem = LED{parent=system,label="MODEM",colors=ind_grn}
|
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}}
|
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.update(types.PANEL_LINK_STATE.DISCONNECTED)
|
||||||
network.register(databus.ps, "link_state", network.update)
|
network.register(databus.ps, "link_state", network.update)
|
||||||
|
@ -12,20 +12,24 @@ local cpair = core.cpair
|
|||||||
|
|
||||||
style.theme = themes.sandstone
|
style.theme = themes.sandstone
|
||||||
style.fp = themes.get_fp_style(style.theme)
|
style.fp = themes.get_fp_style(style.theme)
|
||||||
|
style.colorblind = false
|
||||||
|
|
||||||
style.ind_grn = cpair(colors.green, colors.green_off)
|
style.ind_grn = cpair(colors.green, colors.green_off)
|
||||||
style.ind_red = cpair(colors.red, colors.red_off)
|
style.ind_red = cpair(colors.red, colors.red_off)
|
||||||
|
|
||||||
-- set theme per configuration
|
-- set theme per configuration
|
||||||
---@param fp integer fp theme ID (1 = sandstone, 2 = basalt)
|
---@param fp FP_THEME front panel theme
|
||||||
function style.set_theme(fp)
|
---@param color_mode COLOR_MODE the color mode to use
|
||||||
if fp == 1 then
|
function style.set_theme(fp, color_mode)
|
||||||
|
if fp == themes.FP_THEME.SANDSTONE then
|
||||||
style.theme = themes.sandstone
|
style.theme = themes.sandstone
|
||||||
elseif fp == 2 then
|
elseif fp == themes.FP_THEME.BASALT then
|
||||||
style.theme = themes.basalt
|
style.theme = themes.basalt
|
||||||
end
|
end
|
||||||
|
|
||||||
style.fp = themes.get_fp_style(style.theme)
|
style.fp = themes.get_fp_style(style.theme)
|
||||||
|
|
||||||
|
style.colorblind = color_mode ~= themes.COLOR_MODE.STANDARD
|
||||||
end
|
end
|
||||||
|
|
||||||
return style
|
return style
|
||||||
|
@ -26,7 +26,7 @@ function renderer.try_start_ui(theme, color_mode)
|
|||||||
|
|
||||||
if ui.display == nil then
|
if ui.display == nil then
|
||||||
-- set theme
|
-- set theme
|
||||||
style.set_theme(theme)
|
style.set_theme(theme, color_mode)
|
||||||
|
|
||||||
-- reset terminal
|
-- reset terminal
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
@ -48,7 +48,7 @@ function renderer.try_start_ui(theme, color_mode)
|
|||||||
-- init front panel view
|
-- init front panel view
|
||||||
status, msg = pcall(function ()
|
status, msg = pcall(function ()
|
||||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root}
|
ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root}
|
||||||
panel_view(ui.display, color_mode)
|
panel_view(ui.display)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if status then
|
if status then
|
||||||
|
@ -32,8 +32,7 @@ local UNIT_TYPE_LABELS = { "UNKNOWN", "REDSTONE", "BOILER", "TURBINE", "DYNAMIC
|
|||||||
-- create new front panel view
|
-- create new front panel view
|
||||||
---@param panel graphics_element main displaybox
|
---@param panel graphics_element main displaybox
|
||||||
---@param units table unit list
|
---@param units table unit list
|
||||||
---@param color_mode COLOR_MODE color mode
|
local function init(panel, units)
|
||||||
local function init(panel, units, color_mode)
|
|
||||||
local disabled_fg = style.fp.disabled_fg
|
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}
|
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}
|
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}}
|
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.update(types.PANEL_LINK_STATE.DISCONNECTED)
|
||||||
network.register(databus.ps, "link_state", network.update)
|
network.register(databus.ps, "link_state", network.update)
|
||||||
|
@ -12,19 +12,23 @@ local cpair = core.cpair
|
|||||||
|
|
||||||
style.theme = themes.sandstone
|
style.theme = themes.sandstone
|
||||||
style.fp = themes.get_fp_style(style.theme)
|
style.fp = themes.get_fp_style(style.theme)
|
||||||
|
style.colorblind = false
|
||||||
|
|
||||||
style.ind_grn = cpair(colors.green, colors.green_off)
|
style.ind_grn = cpair(colors.green, colors.green_off)
|
||||||
|
|
||||||
-- set theme per configuration
|
-- set theme per configuration
|
||||||
---@param fp integer fp theme ID (1 = sandstone, 2 = basalt)
|
---@param fp FP_THEME front panel theme
|
||||||
function style.set_theme(fp)
|
---@param color_mode COLOR_MODE the color mode to use
|
||||||
if fp == 1 then
|
function style.set_theme(fp, color_mode)
|
||||||
|
if fp == themes.FP_THEME.SANDSTONE then
|
||||||
style.theme = themes.sandstone
|
style.theme = themes.sandstone
|
||||||
elseif fp == 2 then
|
elseif fp == themes.FP_THEME.BASALT then
|
||||||
style.theme = themes.basalt
|
style.theme = themes.basalt
|
||||||
end
|
end
|
||||||
|
|
||||||
style.fp = themes.get_fp_style(style.theme)
|
style.fp = themes.get_fp_style(style.theme)
|
||||||
|
|
||||||
|
style.colorblind = color_mode ~= themes.COLOR_MODE.STANDARD
|
||||||
end
|
end
|
||||||
|
|
||||||
return style
|
return style
|
||||||
|
@ -27,7 +27,7 @@ function renderer.try_start_ui(units, theme, color_mode)
|
|||||||
|
|
||||||
if ui.display == nil then
|
if ui.display == nil then
|
||||||
-- set theme
|
-- set theme
|
||||||
style.set_theme(theme)
|
style.set_theme(theme, color_mode)
|
||||||
|
|
||||||
-- reset terminal
|
-- reset terminal
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
@ -49,7 +49,7 @@ function renderer.try_start_ui(units, theme, color_mode)
|
|||||||
-- init front panel view
|
-- init front panel view
|
||||||
status, msg = pcall(function ()
|
status, msg = pcall(function ()
|
||||||
ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root}
|
ui.display = DisplayBox{window=term.current(),fg_bg=style.fp.root}
|
||||||
panel_view(ui.display, units, color_mode)
|
panel_view(ui.display, units)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if status then
|
if status then
|
||||||
|
@ -12,19 +12,22 @@ local cpair = core.cpair
|
|||||||
|
|
||||||
style.theme = themes.sandstone
|
style.theme = themes.sandstone
|
||||||
style.fp = themes.get_fp_style(style.theme)
|
style.fp = themes.get_fp_style(style.theme)
|
||||||
|
style.colorblind = false
|
||||||
|
|
||||||
style.ind_grn = cpair(colors.green, colors.green_off)
|
style.ind_grn = cpair(colors.green, colors.green_off)
|
||||||
|
|
||||||
-- set theme per configuration
|
-- set theme per configuration
|
||||||
---@param fp integer fp theme ID (1 = sandstone, 2 = basalt)
|
---@param fp FP_THEME front panel theme
|
||||||
function style.set_theme(fp)
|
function style.set_theme(fp, color_mode)
|
||||||
if fp == 1 then
|
if fp == themes.FP_THEME.SANDSTONE then
|
||||||
style.theme = themes.sandstone
|
style.theme = themes.sandstone
|
||||||
elseif fp == 2 then
|
elseif fp == themes.FP_THEME.BASALT then
|
||||||
style.theme = themes.basalt
|
style.theme = themes.basalt
|
||||||
end
|
end
|
||||||
|
|
||||||
style.fp = themes.get_fp_style(style.theme)
|
style.fp = themes.get_fp_style(style.theme)
|
||||||
|
|
||||||
|
style.colorblind = color_mode ~= themes.COLOR_MODE.STANDARD
|
||||||
end
|
end
|
||||||
|
|
||||||
return style
|
return style
|
||||||
|
Loading…
Reference in New Issue
Block a user