From a182706feb0f4112063f73a3cca8ef133cd2aa66 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 18 Sep 2024 17:55:02 +0200 Subject: colorize message if hint or error --- test-client/visual.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test-client/visual.ts') diff --git a/test-client/visual.ts b/test-client/visual.ts index d63bee03..6802b2b4 100644 --- a/test-client/visual.ts +++ b/test-client/visual.ts @@ -221,6 +221,8 @@ function message_str(m: Message): string { return "[unknown message type]" } +const MESSAGE_BG = { "normal": "#fff", "hint": "#111", "error": "#fff" } +const MESSAGE_FG = { "normal": "#000", "hint": "#fff", "error": "#a00" } function draw_message(m: MessageData, server?: boolean) { ctx.save() ctx.translate(m.anim_position.x, m.anim_position.y) @@ -259,12 +261,12 @@ function draw_message(m: MessageData, server?: boolean) { if (!server) ctx.translate(0, -lines.length * 15 / 2) - ctx.fillStyle = "#fffa" + ctx.fillStyle = MESSAGE_BG[m.style] ctx.beginPath() ctx.roundRect(-w / 2, -5, w, lines.length * 15 + 10, 5) ctx.fill() - ctx.fillStyle = "black" + ctx.fillStyle = MESSAGE_FG[m.style] ctx.textAlign = "left" ctx.textBaseline = "top" for (let i = 0; i < lines.length; i++) -- cgit v1.2.3-70-g09d2