mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
need to use a compact signal bar due to how edge extensions work
This commit is contained in:
parent
f22d699baf
commit
57dc20692b
@ -5,6 +5,7 @@ local util = require("scada-common.util")
|
|||||||
local element = require("graphics.element")
|
local element = require("graphics.element")
|
||||||
|
|
||||||
---@class signal_bar_args
|
---@class signal_bar_args
|
||||||
|
---@field compact? boolean true to use a single character (works better against edges that extend out colors)
|
||||||
---@field colors_low_med? cpair color a for low signal quality, color b for medium signal quality
|
---@field colors_low_med? cpair color a for low signal quality, color b for medium signal quality
|
||||||
---@field disconnect_color? color color for the 'x' on disconnect
|
---@field disconnect_color? color color for the 'x' on disconnect
|
||||||
---@field parent graphics_element
|
---@field parent graphics_element
|
||||||
@ -20,7 +21,7 @@ local element = require("graphics.element")
|
|||||||
---@return graphics_element element, element_id id
|
---@return graphics_element element, element_id id
|
||||||
local function signal_bar(args)
|
local function signal_bar(args)
|
||||||
args.height = 1
|
args.height = 1
|
||||||
args.width = 2
|
args.width = util.trinary(args.compact, 1, 2)
|
||||||
|
|
||||||
-- create new graphics element base object
|
-- create new graphics element base object
|
||||||
local e = element.new(args)
|
local e = element.new(args)
|
||||||
@ -52,6 +53,17 @@ local function signal_bar(args)
|
|||||||
function e.redraw()
|
function e.redraw()
|
||||||
e.w_set_cur(1, 1)
|
e.w_set_cur(1, 1)
|
||||||
|
|
||||||
|
if args.compact then
|
||||||
|
if e.value == 1 then
|
||||||
|
e.w_blit("\x90", blit_1, blit_bkg)
|
||||||
|
elseif e.value == 2 then
|
||||||
|
e.w_blit("\x94", blit_2, blit_bkg)
|
||||||
|
elseif e.value == 3 then
|
||||||
|
e.w_blit("\x95", blit_3, blit_bkg)
|
||||||
|
else
|
||||||
|
e.w_blit("x", blit_0, blit_bkg)
|
||||||
|
end
|
||||||
|
else
|
||||||
if e.value == 1 then
|
if e.value == 1 then
|
||||||
e.w_blit("\x9f ", blit_bkg .. blit_bkg, blit_1 .. blit_bkg)
|
e.w_blit("\x9f ", blit_bkg .. blit_bkg, blit_1 .. blit_bkg)
|
||||||
elseif e.value == 2 then
|
elseif e.value == 2 then
|
||||||
@ -62,6 +74,7 @@ local function signal_bar(args)
|
|||||||
e.w_blit(" x", blit_0 .. blit_0, blit_bkg .. blit_bkg)
|
e.w_blit(" x", blit_0 .. blit_0, blit_bkg .. blit_bkg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- initial draw
|
-- initial draw
|
||||||
e.redraw()
|
e.redraw()
|
||||||
|
@ -38,8 +38,8 @@ local function init(main)
|
|||||||
|
|
||||||
-- window header message
|
-- window header message
|
||||||
TextBox{parent=main,y=1,text="DEV ALPHA APP S C ",alignment=ALIGN.LEFT,height=1,fg_bg=style.header}
|
TextBox{parent=main,y=1,text="DEV ALPHA APP S C ",alignment=ALIGN.LEFT,height=1,fg_bg=style.header}
|
||||||
local svr_conn = SignalBar{parent=main,y=1,x=20,colors_low_med=cpair(colors.red,colors.yellow),disconnect_color=colors.lightGray,fg_bg=cpair(colors.white,colors.gray)}
|
local svr_conn = SignalBar{parent=main,y=1,x=22,compact=true,colors_low_med=cpair(colors.red,colors.yellow),disconnect_color=colors.lightGray,fg_bg=cpair(colors.green,colors.gray)}
|
||||||
local crd_conn = SignalBar{parent=main,y=1,x=24,colors_low_med=cpair(colors.red,colors.yellow),disconnect_color=colors.lightGray,fg_bg=cpair(colors.white,colors.gray)}
|
local crd_conn = SignalBar{parent=main,y=1,x=26,compact=true,colors_low_med=cpair(colors.red,colors.yellow),disconnect_color=colors.lightGray,fg_bg=cpair(colors.green,colors.gray)}
|
||||||
|
|
||||||
db.ps.subscribe("svr_conn_quality", svr_conn.set_value)
|
db.ps.subscribe("svr_conn_quality", svr_conn.set_value)
|
||||||
db.ps.subscribe("crd_conn_quality", crd_conn.set_value)
|
db.ps.subscribe("crd_conn_quality", crd_conn.set_value)
|
||||||
|
Loading…
Reference in New Issue
Block a user