From 146a683b8d8315ef15dc1c9286f0983834f48d88 Mon Sep 17 00:00:00 2001 From: pk33 Date: Mon, 4 Nov 2024 21:42:06 +0100 Subject: Change ui text colour at arbitrary position --- src/strings33.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/strings33.c') diff --git a/src/strings33.c b/src/strings33.c index 0bb7ea0..8613c02 100644 --- a/src/strings33.c +++ b/src/strings33.c @@ -14,6 +14,18 @@ static Font33 *fonts[2] = { }; +static u32 textColours[9] = { + 0xff000000, + 0xffffffff, + 0xffff0000, + 0xff00ff00, + 0xff0000ff, + 0xffffff00, + 0xff00ffff, + 0xffff00ff, + 0xffffaa00, +}; + void e33_uprintf( Surface *surf, Size f, u32 col, Size x, Size y, const char *fmt, ... ) { @@ -43,6 +55,7 @@ void e33_uprint( Surface *surf, Size f, u32 col, Size x, Size y, const char *str Size strWid = 0; for( i = 0; i < slen; ++i ) { + if( str[i] < 0x20 ) continue; strWid += glyphs[ str[i] - 0x20 ].width; } @@ -59,6 +72,12 @@ void e33_uprint( Surface *surf, Size f, u32 col, Size x, Size y, const char *str for( i = 0, ofs = 0; i < slen; ++i ) { + if( str[i] < 0x20 ) + { + col = textColours[str[i]]; + continue; + } + FontGlyph33 *glyph = &glyphs[ str[i] - 0x20 ]; Size numPlots = glyph->num_plots; Size gWidth = glyph->width; -- cgit v1.2.3