From dec30a82819f93903004a3e9d46bf22f352942b4 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Tue, 15 Jan 2019 00:10:46 -0500 Subject: add theme.[hc] and refactor draw.c --- src/sdl/theme.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/sdl/theme.c (limited to 'src/sdl/theme.c') diff --git a/src/sdl/theme.c b/src/sdl/theme.c new file mode 100644 index 0000000..93b7950 --- /dev/null +++ b/src/sdl/theme.c @@ -0,0 +1,71 @@ +#include "util.h" +#include "theme.h" + +static const theme_t +DEFAULT_THEME = { + .text_styles = {{ + .align = TEXT_ALIGN_TOP_CENTER, + .pad = { 0, 10 }, + .colors = { + { 0xff, 0xff, 0xff, 0xff }, + { 0x00, 0x00, 0x00, 0xff }, + }, + }, { + .align = TEXT_ALIGN_BOTTOM_LEFT, + .pad = { 10, 10 }, + .colors = { + { 0xff, 0xff, 0xff, 0xff }, + { 0x00, 0x00, 0x00, 0xff }, + }, + }, { + .align = TEXT_ALIGN_BOTTOM_RIGHT, + .pad = { 10, 10 }, + .colors = { + { 0xff, 0xff, 0xff, 0xff }, + { 0x00, 0x00, 0x00, 0xff }, + }, + }}, + + .bg_styles = {{ + // normal style + .r = { .base = 0x00 }, + .g = { .base = 0x00 }, + .b = { .base = 0x00 }, + .a = { .base = 0xFF }, + }, { + // won style + .r = { .base = 0x66, .scale = 0x33, .phase = 1000, .period = 2000 }, + .g = { .base = 0x66, .scale = 0x33, .phase = 3000, .period = 5000 }, + .b = { .base = 0x66, .scale = 0x33, .phase = 5000, .period = 7000 }, + .a = { .base = 0xFF }, + }}, +}; + +const theme_t * +theme_get_default(void) { + return &DEFAULT_THEME; +} + +const text_style_t * +theme_get_text_style( + const theme_t * const theme, + const text_style_id_t id +) { + if (id >= TEXT_STYLE_LAST) { + die("invalid text style ID"); + } + return theme->text_styles + id; +} + +const bg_style_t * +theme_get_bg_style( + const theme_t * const theme, + const bg_style_id_t id +) { + if (id >= BG_STYLE_LAST) { + die("invalid BG style ID"); + } + + return theme->bg_styles + id; +} + -- cgit v1.2.3