aboutsummaryrefslogtreecommitdiff
path: root/src/sdl/theme.c
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2019-01-15 00:10:46 -0500
committerPaul Duncan <pabs@pablotron.org>2019-01-15 00:10:46 -0500
commitdec30a82819f93903004a3e9d46bf22f352942b4 (patch)
tree46b06f9f7de3d0b3a5fa446dc13cf7727d0e87c3 /src/sdl/theme.c
parent7fdd6f36c8181115c60b781dc97b71107fb7da65 (diff)
downloadsok-dec30a82819f93903004a3e9d46bf22f352942b4.tar.bz2
sok-dec30a82819f93903004a3e9d46bf22f352942b4.zip
add theme.[hc] and refactor draw.c
Diffstat (limited to 'src/sdl/theme.c')
-rw-r--r--src/sdl/theme.c71
1 files changed, 71 insertions, 0 deletions
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;
+}
+