chore: re-added have_a_coffee discussion, fixed text readability, fixed centering of texts, new system.ui functions for drawing in contour, fixed ddr types, fixed meter drawing
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Zoltan Timar
2026-04-09 16:36:19 +02:00
parent 8921f02821
commit 9d56ca2e7a
18 changed files with 296 additions and 127 deletions

View File

@@ -90,12 +90,54 @@ end
--- @param[opt] bg_color number The background fill color (default: Config.colors.dark_grey).<br/>
--- @param[opt] border_color number The border color (default: Config.colors.white).<br/>
--- @param[opt] center_text boolean Whether to center each line inside the box. Defaults to false.<br/>
local function draw_rounded_rect_fill(x, y, w, h, radius, color)
local inner_w = w - radius * 2
local inner_h = h - radius * 2
if inner_w > 0 and inner_h > 0 then
rect(x + radius, y + radius, inner_w, inner_h, color)
end
if inner_w > 0 and radius > 0 then
rect(x + radius, y, inner_w, radius, color)
rect(x + radius, y + h - radius, inner_w, radius, color)
end
if radius > 0 and inner_h > 0 then
rect(x, y + radius, radius, inner_h, color)
rect(x + w - radius, y + radius, radius, inner_h, color)
end
for row = 0, radius - 1 do
for col = 0, radius - 1 do
if col + row >= radius - 1 then
pix(x + radius - 1 - col, y + radius - 1 - row, color)
pix(x + w - radius + col, y + radius - 1 - row, color)
pix(x + radius - 1 - col, y + h - radius + row, color)
pix(x + w - radius + col, y + h - radius + row, color)
end
end
end
end
local function draw_rounded_rect_border(x, y, w, h, radius, color)
line(x + radius, y, x + w - radius - 1, y, color)
line(x + radius, y + h - 1, x + w - radius - 1, y + h - 1, color)
line(x, y + radius, x, y + h - radius - 1, color)
line(x + w - 1, y + radius, x + w - 1, y + h - radius - 1, color)
pix(x + radius - 1, y + 1, color)
pix(x + 1, y + radius - 1, color)
pix(x + w - radius, y + 1, color)
pix(x + w - 2, y + radius - 1, color)
pix(x + radius - 1, y + h - 2, color)
pix(x + 1, y + h - radius, color)
pix(x + w - radius, y + h - 2, color)
pix(x + w - 2, y + h - radius, color)
end
function UI.draw_textbox(text, box_x, box_y, box_w, box_h, scroll_y, color, bg_color, border_color, center_text)
color = color or Config.colors.white
bg_color = bg_color or Config.colors.dark_grey
bg_color = bg_color or Config.colors.black
border_color = border_color or Config.colors.white
center_text = center_text or false
local r = 3
local padding = 4
local line_height = 8
local inner_x = box_x + padding
@@ -110,7 +152,7 @@ function UI.draw_textbox(text, box_x, box_y, box_w, box_h, scroll_y, color, bg_c
base_y = inner_y + math.floor((visible_height - text_height) / 2)
end
rect(box_x, box_y, box_w, box_h, bg_color)
draw_rounded_rect_fill(box_x, box_y, box_w, box_h, r, bg_color)
for i, line in ipairs(lines) do
local ly = base_y + (i - 1) * line_height - scroll_y
@@ -123,7 +165,7 @@ function UI.draw_textbox(text, box_x, box_y, box_w, box_h, scroll_y, color, bg_c
end
end
rectb(box_x, box_y, box_w, box_h, border_color)
draw_rounded_rect_border(box_x, box_y, box_w, box_h, r, border_color)
end
--- Wraps text.