From 145a502eb8c895beec77c3e5c7eeb6f2c58cf9ed Mon Sep 17 00:00:00 2001 From: Tuomas Virtanen Date: Sun, 16 Jul 2023 00:41:44 +0300 Subject: [PATCH] Move text color handling to palette. Not quite correct, more fixes needed. --- src/console/console.c | 22 +---- src/console/console_type.h | 2 - src/formats/palette.c | 7 -- src/formats/palette.h | 2 - src/game/gui/dialog.c | 12 +-- src/game/gui/text_render.c | 65 +++++++------- src/game/gui/text_render.h | 35 ++++---- src/game/gui/textbutton.c | 42 ++------- src/game/gui/textbutton.h | 3 +- src/game/gui/textinput.c | 8 +- src/game/gui/textselector.c | 7 +- src/game/gui/textslider.c | 7 +- src/game/gui/trn_menu.c | 4 +- src/game/gui/trnselect.c | 4 +- src/game/scenes/arena.c | 4 +- src/game/scenes/cutscene.c | 11 ++- src/game/scenes/mainmenu/menu_audio.c | 2 +- src/game/scenes/mainmenu/menu_configuration.c | 2 +- src/game/scenes/mainmenu/menu_connect.c | 2 +- src/game/scenes/mainmenu/menu_gameplay.c | 2 +- src/game/scenes/mainmenu/menu_input.c | 2 +- src/game/scenes/mainmenu/menu_keyboard.c | 2 +- src/game/scenes/mainmenu/menu_listen.c | 2 +- src/game/scenes/mainmenu/menu_main.c | 2 +- src/game/scenes/mainmenu/menu_net.c | 2 +- src/game/scenes/mainmenu/menu_presskey.c | 6 +- src/game/scenes/mainmenu/menu_video.c | 2 +- src/game/scenes/mainmenu/menu_video_confirm.c | 2 +- src/game/scenes/mechlab.c | 2 +- src/game/scenes/mechlab/lab_dash_main.c | 6 +- src/game/scenes/mechlab/lab_dash_newplayer.c | 4 +- src/game/scenes/mechlab/lab_dash_trnselect.c | 2 +- src/game/scenes/mechlab/lab_menu_confirm.c | 4 +- src/game/scenes/mechlab/lab_menu_customize.c | 6 +- .../mechlab/lab_menu_difficultyselect.c | 4 +- src/game/scenes/mechlab/lab_menu_main.c | 2 +- src/game/scenes/mechlab/lab_menu_select.c | 4 +- src/game/scenes/mechlab/lab_menu_trade.c | 2 +- src/game/scenes/mechlab/lab_menu_training.c | 6 +- src/game/scenes/melee.c | 87 ++++++++++--------- src/game/scenes/scoreboard.c | 4 +- src/game/scenes/vs.c | 4 +- src/game/utils/score.c | 4 +- src/resources/fonts.c | 2 +- src/video/color.h | 7 +- src/video/surface.c | 14 +-- src/video/video.c | 5 -- src/video/video.h | 5 -- 48 files changed, 184 insertions(+), 253 deletions(-) diff --git a/src/console/console.c b/src/console/console.c index 1c5bfcbbb..c08b9ea0b 100644 --- a/src/console/console.c +++ b/src/console/console.c @@ -183,7 +183,6 @@ void console_output_render() { int x = 0; int y = 0; unsigned int lines = 0; - const color textcolor = color_create(121, 121, 121, 255); for(unsigned int i = con->output_pos; i != con->output_tail && lines < 15; i = BUFFER_INC(i)) { char c = con->output[i]; @@ -193,7 +192,7 @@ void console_output_render() { lines++; } else { // TODO add word wrapping? - font_render_char(&font_small, c, x, y + con->ypos - 100, textcolor); + font_render_char(&font_small, c, x, y + con->ypos - 100, TEXT_MEDIUM_GREEN); x += font_small.w; } } @@ -206,8 +205,6 @@ int console_init() { con->isopen = 0; con->ownsinput = 0; con->ypos = 0; - con->ticks = 0; - con->dir = 0; con->input[0] = '\0'; con->output[0] = '\0'; con->output_head = 0; @@ -314,12 +311,10 @@ void console_render() { con->histpos_changed = 0; } video_draw(&con->background, -1, con->ypos - 101); - int t = con->ticks / 2; // input line - font_render(&font_small, con->input, 0, con->ypos - 7, color_create(121, 121, 121, 255)); + font_render(&font_small, con->input, 0, con->ypos - 7, TEXT_MEDIUM_GREEN); // cursor - font_render(&font_small, CURSOR_STR, strlen(con->input) * font_small.w, con->ypos - 7, - color_create(121 - t, 121 - t, 121 - t, 255)); + font_render(&font_small, CURSOR_STR, strlen(con->input) * font_small.w, con->ypos - 7, TEXT_BLINKY_GREEN); console_output_render(); } } @@ -336,17 +331,6 @@ void console_tick() { con->ypos = 0; } } - if(!con->dir) { - con->ticks++; - } else { - con->ticks--; - } - if(con->ticks > 120) { - con->dir = 1; - } - if(con->ticks == 0) { - con->dir = 0; - } } void console_add_cmd(const char *name, command_func func, const char *doc) { diff --git a/src/console/console_type.h b/src/console/console_type.h index 309ccd3b9..8e4cf5355 100644 --- a/src/console/console_type.h +++ b/src/console/console_type.h @@ -19,8 +19,6 @@ typedef struct { int isopen; int ownsinput; int ypos; - unsigned int ticks; - unsigned int dir; hashmap cmds; // string -> command } console; diff --git a/src/formats/palette.c b/src/formats/palette.c index 7f610b162..e79e70b5f 100644 --- a/src/formats/palette.c +++ b/src/formats/palette.c @@ -42,13 +42,6 @@ unsigned char palette_resolve_color(uint8_t r, uint8_t g, uint8_t b, const palet return 0; } -color palette_lookup_color(uint8_t i, const palette *pal) { - uint8_t red = pal->data[i][0] & 0xff; - uint8_t green = pal->data[i][1] & 0xff; - uint8_t blue = pal->data[i][2] & 0xff; - return color_create(red, green, blue, 255); -} - int palette_to_gimp_palette(const palette *pal, const char *filename) { sd_writer *w; const unsigned char *d; diff --git a/src/formats/palette.h b/src/formats/palette.h index 71780807b..18e47f08d 100644 --- a/src/formats/palette.h +++ b/src/formats/palette.h @@ -65,8 +65,6 @@ void palette_free(palette *pal); */ unsigned char palette_resolve_color(uint8_t r, uint8_t g, uint8_t b, const palette *pal); -color palette_lookup_color(uint8_t i, const palette *pal); - /*! \brief Exports palette to GIMP palette file. * * Exports a palette to GIMP palette format (GPL). Palette remappings are NOT diff --git a/src/game/gui/dialog.c b/src/game/gui/dialog.c index 6100d6000..c7c12633d 100644 --- a/src/game/gui/dialog.c +++ b/src/game/gui/dialog.c @@ -12,12 +12,12 @@ void dialog_create(dialog *dlg, dialog_style style, const char *text, int x, int text_settings tconf; text_defaults(&tconf); tconf.font = FONT_BIG; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; text_settings tconf_desc; text_defaults(&tconf_desc); tconf_desc.font = FONT_SMALL; - tconf_desc.cforeground = color_create(0, 121, 0, 255); + tconf_desc.cforeground = TEXT_MEDIUM_GREEN; dlg->x = x; dlg->y = y; @@ -36,15 +36,15 @@ void dialog_create(dialog *dlg, dialog_style style, const char *text, int x, int if(style == DIALOG_STYLE_YES_NO) { dlg->yes = textbutton_create(&tconf, "YES", COM_ENABLED, NULL, NULL); dlg->no = textbutton_create(&tconf, "NO", COM_ENABLED, NULL, NULL); - textbutton_set_border(dlg->yes, COLOR_BLUE); - textbutton_set_border(dlg->no, COLOR_BLUE); + textbutton_set_border(dlg->yes, TEXT_MEDIUM_GREEN); + textbutton_set_border(dlg->no, TEXT_MEDIUM_GREEN); component_layout(dlg->yes, x + 54, x + h + 6, 8, 8); component_layout(dlg->no, x + 114, x + h + 6, 8, 8); component_select(dlg->yes, 1); dlg->result = DIALOG_RESULT_YES_OK; } else if(style == DIALOG_STYLE_OK) { dlg->ok = textbutton_create(&tconf, "OK", COM_ENABLED, NULL, NULL); - textbutton_set_border(dlg->ok, COLOR_BLUE); + textbutton_set_border(dlg->ok, TEXT_MEDIUM_GREEN); component_layout(dlg->ok, x + 84, x + h + 6, 8, 8); component_select(dlg->ok, 1); dlg->result = DIALOG_RESULT_YES_OK; @@ -86,7 +86,7 @@ void dialog_render(dialog *dlg) { if(dlg->ok) { component_render(dlg->ok); } - font_render_wrapped_shadowed(&font_small, dlg->text, dlg->x + 15, dlg->y + 3, MAX_WIDTH, COLOR_GREEN, + font_render_wrapped_shadowed(&font_small, dlg->text, dlg->x + 15, dlg->y + 3, MAX_WIDTH, TEXT_MEDIUM_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); } diff --git a/src/game/gui/text_render.c b/src/game/gui/text_render.c index 6e62284f2..0d7da88d5 100644 --- a/src/game/gui/text_render.c +++ b/src/game/gui/text_render.c @@ -2,13 +2,13 @@ #include #include "game/gui/text_render.h" +#include "utils/log.h" #include "utils/vector.h" #include "video/video.h" void text_defaults(text_settings *settings) { memset(settings, 0, sizeof(text_settings)); - settings->cforeground = color_create(0xFF, 0xFF, 0xFF, 0xFF); - settings->opacity = 0xFF; + settings->cforeground = 0xFF; } void text_render_char(const text_settings *settings, int x, int y, char ch) { @@ -31,26 +31,20 @@ void text_render_char(const text_settings *settings, int x, int y, char ch) { } // Handle shadows if necessary - float of = settings->opacity / 255.0f; if(settings->shadow & TEXT_SHADOW_RIGHT) - video_render_sprite_flip_scale_opacity_tint(*sur, x + 1, y, BLEND_ALPHA, 0, 255, FLIP_NONE, 1.0f, 1.0f, of * 80, - settings->cforeground); + video_draw_offset(*sur, x + 1, y, 0xC0, 255); if(settings->shadow & TEXT_SHADOW_LEFT) - video_render_sprite_flip_scale_opacity_tint(*sur, x - 1, y, BLEND_ALPHA, 0, 255, FLIP_NONE, 1.0f, 1.0f, of * 80, - settings->cforeground); + video_draw_offset(*sur, x - 1, y, 0xC0, 255); if(settings->shadow & TEXT_SHADOW_BOTTOM) - video_render_sprite_flip_scale_opacity_tint(*sur, x, y + 1, BLEND_ALPHA, 0, 255, FLIP_NONE, 1.0f, 1.0f, of * 80, - settings->cforeground); + video_draw_offset(*sur, x, y + 1, 0xC0, 255); if(settings->shadow & TEXT_SHADOW_TOP) - video_render_sprite_flip_scale_opacity_tint(*sur, x, y - 1, BLEND_ALPHA, 0, 255, FLIP_NONE, 1.0f, 1.0f, of * 80, - settings->cforeground); + video_draw_offset(*sur, x, y - 1, 0xC0, 255); - // Handle the font face itself - video_render_sprite_flip_scale_opacity_tint(*sur, x, y, BLEND_ALPHA, 0, 255, FLIP_NONE, 1.0f, 1.0f, - settings->opacity, settings->cforeground); + // Draw the actual font + video_draw_offset(*sur, x, y, settings->cforeground, 255); } -int text_find_max_strlen(int maxchars, const char *ptr) { +int text_find_max_strlen(int max_chars, const char *ptr) { int i; int len = strlen(ptr); @@ -65,8 +59,8 @@ int text_find_max_strlen(int maxchars, const char *ptr) { // Walk through the rest of the string int last_space = i; - int max = maxchars + i; - int lstart = i; + int max = max_chars + i; + int line_start = i; for(; i < len; i++) { // If we detect newline, this line ends here if(ptr[i] == '\n') @@ -76,7 +70,7 @@ int text_find_max_strlen(int maxchars, const char *ptr) { if(i >= max) { if(ptr[i] == ' ') { // If we are at valid end character (space), end here return i; - } else if(last_space != lstart) { + } else if(last_space != line_start) { return last_space; } } else if(ptr[i] == ' ') { @@ -244,11 +238,11 @@ void text_render(const text_settings *settings, int x, int y, int w, int h, cons /// ---------------- OLD RENDERER FUNCTIONS --------------------- -void font_render_char(const font *font, char ch, int x, int y, color c) { +void font_render_char(const font *font, char ch, int x, int y, uint8_t c) { font_render_char_shadowed(font, ch, x, y, c, 0); } -void font_render_char_shadowed(const font *font, char ch, int x, int y, color c, int shadow_flags) { +void font_render_char_shadowed(const font *font, char ch, int x, int y, uint8_t c, int shadow_flags) { // Make sure code is valid int code = ch - 32; surface **sur = NULL; @@ -261,23 +255,23 @@ void font_render_char_shadowed(const font *font, char ch, int x, int y, color c, // Handle shadows if necessary if(shadow_flags & TEXT_SHADOW_RIGHT) - video_render_sprite_flip_scale_opacity_tint(*sur, x + 1, y, BLEND_ALPHA, 0, 255, FLIP_NONE, 1.0f, 1.0f, 80, c); + video_draw_offset(*sur, x + 1, y, 0xC0, 255); if(shadow_flags & TEXT_SHADOW_LEFT) - video_render_sprite_flip_scale_opacity_tint(*sur, x - 1, y, BLEND_ALPHA, 0, 255, FLIP_NONE, 1.0f, 1.0f, 80, c); + video_draw_offset(*sur, x - 1, y, 0xC0, 255); if(shadow_flags & TEXT_SHADOW_BOTTOM) - video_render_sprite_flip_scale_opacity_tint(*sur, x, y + 1, BLEND_ALPHA, 0, 255, FLIP_NONE, 1.0f, 1.0f, 80, c); + video_draw_offset(*sur, x, y + 1, 0xC0, 255); if(shadow_flags & TEXT_SHADOW_TOP) - video_render_sprite_flip_scale_opacity_tint(*sur, x, y - 1, BLEND_ALPHA, 0, 255, FLIP_NONE, 1.0f, 1.0f, 80, c); + video_draw_offset(*sur, x, y - 1, 0xC0, 255); // Handle the font face itself - video_render_sprite_tint(*sur, x, y, c, 0); + video_draw_offset(*sur, x, y, c, 255); } -void font_render_len(const font *font, const char *text, int len, int x, int y, color c) { +void font_render_len(const font *font, const char *text, int len, int x, int y, uint8_t c) { font_render_len_shadowed(font, text, len, x, y, c, 0); } -void font_render_len_shadowed(const font *font, const char *text, int len, int x, int y, color c, int shadow_flags) { +void font_render_len_shadowed(const font *font, const char *text, int len, int x, int y, uint8_t c, int shadow_flags) { int pos_x = x; for(int i = 0; i < len; i++) { font_render_char_shadowed(font, text[i], pos_x, y, c, shadow_flags); @@ -285,21 +279,21 @@ void font_render_len_shadowed(const font *font, const char *text, int len, int x } } -void font_render(const font *font, const char *text, int x, int y, color c) { +void font_render(const font *font, const char *text, int x, int y, uint8_t c) { int len = strlen(text); font_render_len(font, text, len, x, y, c); } -void font_render_shadowed(const font *font, const char *text, int x, int y, color c, int shadow_flags) { +void font_render_shadowed(const font *font, const char *text, int x, int y, uint8_t c, int shadow_flags) { int len = strlen(text); font_render_len_shadowed(font, text, len, x, y, c, shadow_flags); } -void font_render_wrapped(const font *font, const char *text, int x, int y, int w, color c) { +void font_render_wrapped(const font *font, const char *text, int x, int y, int w, uint8_t c) { font_render_wrapped_shadowed(font, text, x, y, w, c, 0); } -void font_render_wrapped_internal(const font *font, const char *text, int x, int y, int max_w, color c, +void font_render_wrapped_internal(const font *font, const char *text, int x, int y, int max_w, uint8_t c, int shadow_flags, int only_size, int *out_w, int *out_h) { int len = strlen(text); int has_newline = 0; @@ -395,18 +389,17 @@ void font_render_wrapped_internal(const font *font, const char *text, int x, int } } -void font_render_wrapped_shadowed(const font *font, const char *text, int x, int y, int w, color c, int shadow_flags) { +void font_render_wrapped_shadowed(const font *font, const char *text, int x, int y, int w, uint8_t c, + int shadow_flags) { int tmp; font_render_wrapped_internal(font, text, x, y, w, c, shadow_flags, 0, &tmp, &tmp); } void font_get_wrapped_size(const font *font, const char *text, int max_w, int *out_w, int *out_h) { - static color c = {0}; - font_render_wrapped_internal(font, text, 0, 0, max_w, c, 0, 1, out_w, out_h); + font_render_wrapped_internal(font, text, 0, 0, max_w, 0, 0, 1, out_w, out_h); } void font_get_wrapped_size_shadowed(const font *font, const char *text, int max_w, int shadow_flag, int *out_w, int *out_h) { - static color c = {0}; - font_render_wrapped_internal(font, text, 0, 0, max_w, c, shadow_flag, 1, out_w, out_h); + font_render_wrapped_internal(font, text, 0, 0, max_w, 0, shadow_flag, 1, out_w, out_h); } diff --git a/src/game/gui/text_render.h b/src/game/gui/text_render.h index 390af17b2..12c8b8eb3 100644 --- a/src/game/gui/text_render.h +++ b/src/game/gui/text_render.h @@ -1,11 +1,19 @@ #ifndef TEXT_RENDER_H #define TEXT_RENDER_H -#include "resources/fonts.h" -#include "video/color.h" #include #include +#include "resources/fonts.h" +#include "utils/str.h" +#include "video/color.h" + +#define TEXT_DARK_GREEN 0xFE +#define TEXT_MEDIUM_GREEN 0xFE +#define TEXT_BLINKY_GREEN 0xFF +#define TEXT_BLACK 0 +#define TEXT_TRN_BLUE 0xAB + typedef enum { TEXT_TOP = 0, @@ -40,13 +48,11 @@ enum TEXT_SHADOW_BOTTOM = 0x2, TEXT_SHADOW_LEFT = 0x4, TEXT_SHADOW_RIGHT = 0x8, - TEXT_SHADOW_HORIZONTAL = 0xC, - TEXT_SHADOW_VERTICAL = 0x3, TEXT_SHADOW_ALL = 0xF }; typedef struct { - color cforeground; + uint8_t cforeground; text_valign valign; text_halign halign; text_padding padding; @@ -55,13 +61,12 @@ typedef struct { uint8_t shadow; uint8_t cspacing; uint8_t lspacing; - uint8_t opacity; bool wrap; } text_settings; // New text rendering functions void text_defaults(text_settings *settings); -int text_find_max_strlen(int maxchars, const char *ptr); +int text_find_max_strlen(int max_chars, const char *ptr); int text_find_line_count(text_direction dir, int cols, int rows, int len, const char *text); void text_render_char(const text_settings *settings, int x, int y, char ch); void text_render(const text_settings *settings, int x, int y, int w, int h, const char *text); @@ -71,13 +76,13 @@ int text_char_width(const text_settings *settings); void font_get_wrapped_size(const font *font, const char *text, int max_w, int *out_w, int *out_h); void font_get_wrapped_size_shadowed(const font *font, const char *text, int max_w, int shadow_flag, int *out_w, int *out_h); -void font_render_char(const font *font, char ch, int x, int y, color c); -void font_render_char_shadowed(const font *font, char ch, int x, int y, color c, int shadow_flags); -void font_render_len(const font *font, const char *text, int len, int x, int y, color c); -void font_render_len_shadowed(const font *font, const char *text, int len, int x, int y, color c, int shadow_flags); -void font_render(const font *font, const char *text, int x, int y, color c); -void font_render_shadowed(const font *font, const char *text, int x, int y, color c, int shadow_flags); -void font_render_wrapped(const font *font, const char *text, int x, int y, int w, color c); -void font_render_wrapped_shadowed(const font *font, const char *text, int x, int y, int w, color c, int shadow_flags); +void font_render_char(const font *font, char ch, int x, int y, uint8_t c); +void font_render_char_shadowed(const font *font, char ch, int x, int y, uint8_t c, int shadow_flags); +void font_render_len(const font *font, const char *text, int len, int x, int y, uint8_t c); +void font_render_len_shadowed(const font *font, const char *text, int len, int x, int y, uint8_t c, int shadow_flags); +void font_render(const font *font, const char *text, int x, int y, uint8_t c); +void font_render_shadowed(const font *font, const char *text, int x, int y, uint8_t c, int shadow_flags); +void font_render_wrapped(const font *font, const char *text, int x, int y, int w, uint8_t c); +void font_render_wrapped_shadowed(const font *font, const char *text, int x, int y, int w, uint8_t c, int shadow_flags); #endif // TEXT_RENDER_H diff --git a/src/game/gui/textbutton.c b/src/game/gui/textbutton.c index 5cc411aaa..1226c49d8 100644 --- a/src/game/gui/textbutton.c +++ b/src/game/gui/textbutton.c @@ -11,22 +11,18 @@ typedef struct { char *text; text_settings tconf; - int ticks; - int dir; - int border_enabled; int border_created; - color border_color; + uint8_t border_color; surface border; textbutton_click_cb click_cb; void *userdata; } textbutton; -void textbutton_set_border(component *c, color col) { +void textbutton_set_border(component *c, uint8_t color) { textbutton *tb = widget_get_obj(c); - tb->border_enabled = 1; - tb->border_color = col; + tb->border_color = color; if(tb->border_created) { // destroy the old border first surface_free(&tb->border); @@ -37,12 +33,6 @@ void textbutton_set_border(component *c, color col) { int fsize = text_char_width(&tb->tconf); int width = chars * fsize; menu_background_border_create(&tb->border, width + 6, fsize + 3); - tb->border_created = 1; -} - -void textbutton_remove_border(component *c) { - textbutton *tb = widget_get_obj(c); - tb->border_enabled = 0; } void textbutton_set_text(component *c, const char *text) { @@ -58,17 +48,16 @@ static void textbutton_render(component *c) { // Select color and render if(component_is_selected(c)) { - int t = tb->ticks / 2; - tb->tconf.cforeground = color_create(80 - t, 220 - t * 2, 80 - t, 255); + tb->tconf.cforeground = TEXT_BLINKY_GREEN; } else if(component_is_disabled(c)) { - tb->tconf.cforeground = color_create(121, 121, 121, 255); + tb->tconf.cforeground = 0xC0; } else { - tb->tconf.cforeground = color_create(0, 121, 0, 255); + tb->tconf.cforeground = TEXT_MEDIUM_GREEN; } text_render(&tb->tconf, c->x, c->y, c->w, c->h, tb->text); // Border - if(tb->border_enabled) { + if(tb->border_created) { video_draw(&tb->border, c->x - 2, c->y - 2); } } @@ -87,24 +76,8 @@ static int textbutton_action(component *c, int action) { return 1; } -static void textbutton_tick(component *c) { - textbutton *tb = widget_get_obj(c); - if(!tb->dir) { - tb->ticks++; - } else { - tb->ticks--; - } - if(tb->ticks > 120) { - tb->dir = 1; - } - if(tb->ticks == 0) { - tb->dir = 0; - } -} - static void textbutton_free(component *c) { textbutton *tb = widget_get_obj(c); - if(tb->border_created) { surface_free(&tb->border); } @@ -126,7 +99,6 @@ component *textbutton_create(const text_settings *tconf, const char *text, int d widget_set_render_cb(c, textbutton_render); widget_set_action_cb(c, textbutton_action); - widget_set_tick_cb(c, textbutton_tick); widget_set_free_cb(c, textbutton_free); return c; diff --git a/src/game/gui/textbutton.h b/src/game/gui/textbutton.h index a1a212100..692d0cd1e 100644 --- a/src/game/gui/textbutton.h +++ b/src/game/gui/textbutton.h @@ -8,8 +8,7 @@ typedef void (*textbutton_click_cb)(component *c, void *userdata); component *textbutton_create(const text_settings *tconf, const char *text, int disabled, textbutton_click_cb cb, void *userdata); -void textbutton_set_border(component *c, color col); +void textbutton_set_border(component *c, uint8_t color); void textbutton_set_text(component *c, const char *text); -void textbutton_remove_border(component *c); #endif // TEXTBUTTON_H diff --git a/src/game/gui/textinput.c b/src/game/gui/textinput.c index 993d611e7..0683830ae 100644 --- a/src/game/gui/textinput.c +++ b/src/game/gui/textinput.c @@ -34,7 +34,7 @@ static void textinput_render(component *c) { if(component_is_selected(c)) { if(chars > 0) { - tb->tconf.cforeground = color_create(80, 220, 80, 255); + tb->tconf.cforeground = TEXT_BLINKY_GREEN; tb->buf[chars] = '\x7F'; tb->buf[chars + 1] = 0; text_render(&tb->tconf, c->x, c->y, c->w, c->h, tb->buf); @@ -42,17 +42,17 @@ static void textinput_render(component *c) { } } else if(component_is_disabled(c)) { if(chars > 0) { - tb->tconf.cforeground = color_create(121, 121, 121, 255); + tb->tconf.cforeground = 0xC0; text_render(&tb->tconf, c->x, c->y, c->w, c->h, tb->buf); } } else { if(chars > 0) { - tb->tconf.cforeground = color_create(0, 121, 0, 255); + tb->tconf.cforeground = TEXT_MEDIUM_GREEN; text_render(&tb->tconf, c->x, c->y, c->w, c->h, tb->buf); } } if(chars == 0) { - tb->tconf.cforeground = color_create(121, 121, 121, 255); + tb->tconf.cforeground = 0xC0; text_render(&tb->tconf, c->x, c->y, c->w, c->h, tb->text); } } diff --git a/src/game/gui/textselector.c b/src/game/gui/textselector.c index 8e08a1370..29928957f 100644 --- a/src/game/gui/textselector.c +++ b/src/game/gui/textselector.c @@ -64,12 +64,11 @@ static void textselector_render(component *c) { // Render text if(component_is_selected(c)) { - int t = tb->ticks / 2; - tb->tconf.cforeground = color_create(80 - t, 220 - t * 2, 80 - t, 255); + tb->tconf.cforeground = TEXT_BLINKY_GREEN; } else if(component_is_disabled(c)) { - tb->tconf.cforeground = color_create(121, 121, 121, 255); + tb->tconf.cforeground = 0xC0; } else { - tb->tconf.cforeground = color_create(0, 121, 0, 255); + tb->tconf.cforeground = TEXT_MEDIUM_GREEN; } text_render(&tb->tconf, c->x, c->y, c->w, c->h, buf); } diff --git a/src/game/gui/textslider.c b/src/game/gui/textslider.c index 1a164f6ea..4a70f75ae 100644 --- a/src/game/gui/textslider.c +++ b/src/game/gui/textslider.c @@ -38,12 +38,11 @@ static void textslider_render(component *c) { } if(component_is_selected(c)) { - int t = tb->ticks / 2; - tb->tconf.cforeground = color_create(80 - t, 220 - t * 2, 80 - t, 255); + tb->tconf.cforeground = TEXT_BLINKY_GREEN; } else if(component_is_disabled(c)) { - tb->tconf.cforeground = color_create(121, 121, 121, 255); + tb->tconf.cforeground = 0xC0; } else { - tb->tconf.cforeground = color_create(0, 121, 0, 255); + tb->tconf.cforeground = TEXT_MEDIUM_GREEN; } text_render(&tb->tconf, c->x, c->y, c->w, c->h, str_c(&txt)); str_free(&txt); diff --git a/src/game/gui/trn_menu.c b/src/game/gui/trn_menu.c index 1d60786ed..4157cd617 100644 --- a/src/game/gui/trn_menu.c +++ b/src/game/gui/trn_menu.c @@ -262,9 +262,7 @@ static void trnmenu_render(component *c) { // Render button sheet if(m->button_sheet) { - video_render_sprite_flip_scale_opacity_tint(m->button_sheet, m->sheet_x, m->sheet_y, BLEND_ALPHA, 0, 255, - FLIP_NONE, 1.0f, 1.0f, clamp(s->opacity * 255, 0, 255), - color_create(0xFF, 0xFF, 0xFF, 0xFF)); + video_draw(m->button_sheet, m->sheet_x, m->sheet_y); } // Handle components diff --git a/src/game/gui/trnselect.c b/src/game/gui/trnselect.c index 98109b6ba..662b74363 100644 --- a/src/game/gui/trnselect.c +++ b/src/game/gui/trnselect.c @@ -86,10 +86,10 @@ void load_description(component **c, const char *desc) { tconf.halign = TEXT_CENTER; tconf.valign = TEXT_MIDDLE; if(color >= 0) { - tconf.cforeground = palette_lookup_color(color, video_get_base_palette()); + tconf.cforeground = color; } else { // WAR invitational seems to use this color, none is specified - tconf.cforeground = palette_lookup_color(0xa5, video_get_base_palette()); + tconf.cforeground = 0xa5; } if(*c) { diff --git a/src/game/scenes/arena.c b/src/game/scenes/arena.c index 07c51795a..78d5df3f7 100644 --- a/src/game/scenes/arena.c +++ b/src/game/scenes/arena.c @@ -35,7 +35,7 @@ #include "video/surface.h" #include "video/video.h" -#define TEXT_COLOR color_create(186, 250, 250, 255) +#define TEXT_COLOR 0xC7 #define HAR1_START_POS 110 #define HAR2_START_POS 211 @@ -1337,7 +1337,7 @@ int arena_create(scene *scene) { text_settings tconf; text_defaults(&tconf); tconf.font = FONT_BIG; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_DARK_GREEN; tconf.halign = TEXT_CENTER; // Arena menu diff --git a/src/game/scenes/cutscene.c b/src/game/scenes/cutscene.c index 22a2622cb..3ef65b6f4 100644 --- a/src/game/scenes/cutscene.c +++ b/src/game/scenes/cutscene.c @@ -114,7 +114,7 @@ int cutscene_create(scene *scene) { local->text_x = 10; local->text_y = 5; local->text_width = 300; - local->text_conf.cforeground = COLOR_YELLOW; + local->text_conf.cforeground = 0xF8; break; case SCENE_END1: @@ -122,7 +122,7 @@ int cutscene_create(scene *scene) { local->text_x = 10; local->text_y = 157; local->text_width = 300; - local->text_conf.cforeground = COLOR_RED; + local->text_conf.cforeground = 0xFD; // Pilot face animation *ani = &bk_get_info(&scene->bk_data, 3)->ani; @@ -146,8 +146,9 @@ int cutscene_create(scene *scene) { local->text_x = 10; local->text_y = 160; local->text_width = 300; - local->text_conf.cforeground = COLOR_GREEN; + local->text_conf.cforeground = 0xF8; break; + case SCENE_NORTHAM: case SCENE_KATUSHAI: case SCENE_WAR: @@ -176,9 +177,7 @@ int cutscene_create(scene *scene) { local->text_x = 10; local->text_y = 160; local->text_width = 300; - - local->text_conf.cforeground = palette_lookup_color(248, video_get_base_palette()); - + local->text_conf.cforeground = 0xF8; break; } diff --git a/src/game/scenes/mainmenu/menu_audio.c b/src/game/scenes/mainmenu/menu_audio.c index 6c367ee3e..f515c1fbe 100644 --- a/src/game/scenes/mainmenu/menu_audio.c +++ b/src/game/scenes/mainmenu/menu_audio.c @@ -94,7 +94,7 @@ component *menu_audio_create(scene *s) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; // Create menu and its header component *menu = menu_create(11); diff --git a/src/game/scenes/mainmenu/menu_configuration.c b/src/game/scenes/mainmenu/menu_configuration.c index 0bd41b181..604b3fea0 100644 --- a/src/game/scenes/mainmenu/menu_configuration.c +++ b/src/game/scenes/mainmenu/menu_configuration.c @@ -36,7 +36,7 @@ component *menu_configuration_create(scene *s) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; component *menu = menu_create(11); menu_attach(menu, label_create(&tconf, "CONFIGURATION")); diff --git a/src/game/scenes/mainmenu/menu_connect.c b/src/game/scenes/mainmenu/menu_connect.c index 1f2e4db07..27bbc0654 100644 --- a/src/game/scenes/mainmenu/menu_connect.c +++ b/src/game/scenes/mainmenu/menu_connect.c @@ -180,7 +180,7 @@ component *menu_connect_create(scene *s) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; component *menu = menu_create(11); menu_attach(menu, label_create(&tconf, "CONNECT TO SERVER")); diff --git a/src/game/scenes/mainmenu/menu_gameplay.c b/src/game/scenes/mainmenu/menu_gameplay.c index 4aa633e20..3c9f3988a 100644 --- a/src/game/scenes/mainmenu/menu_gameplay.c +++ b/src/game/scenes/mainmenu/menu_gameplay.c @@ -23,7 +23,7 @@ component *menu_gameplay_create(scene *s) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; component *menu = menu_create(11); menu_attach(menu, label_create(&tconf, "GAMEPLAY")); diff --git a/src/game/scenes/mainmenu/menu_input.c b/src/game/scenes/mainmenu/menu_input.c index 5755fab3a..859ef05c3 100644 --- a/src/game/scenes/mainmenu/menu_input.c +++ b/src/game/scenes/mainmenu/menu_input.c @@ -184,7 +184,7 @@ component *menu_input_create(scene *s, int player_id) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; component *menu = menu_create(11); menu_attach(menu, label_create(&tconf, "CHOOSE INPUT")); diff --git a/src/game/scenes/mainmenu/menu_keyboard.c b/src/game/scenes/mainmenu/menu_keyboard.c index 4d9400e35..68bc318fd 100644 --- a/src/game/scenes/mainmenu/menu_keyboard.c +++ b/src/game/scenes/mainmenu/menu_keyboard.c @@ -131,7 +131,7 @@ guiframe *menu_keyboard_create(scene *s, int selected_player) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; local->frame = guiframe_create(25, 5, 270, 140); component *menu = menu_create(11); diff --git a/src/game/scenes/mainmenu/menu_listen.c b/src/game/scenes/mainmenu/menu_listen.c index 0a3cdebbc..97c21714b 100644 --- a/src/game/scenes/mainmenu/menu_listen.c +++ b/src/game/scenes/mainmenu/menu_listen.c @@ -140,7 +140,7 @@ component *menu_listen_create(scene *s) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; // Create the menu component *menu = menu_create(11); diff --git a/src/game/scenes/mainmenu/menu_main.c b/src/game/scenes/mainmenu/menu_main.c index 0c2bfc145..e91a0e9c2 100644 --- a/src/game/scenes/mainmenu/menu_main.c +++ b/src/game/scenes/mainmenu/menu_main.c @@ -95,7 +95,7 @@ component *menu_main_create(scene *s) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_DARK_GREEN; component *menu = menu_create(11); menu_attach(menu, textbutton_create(&tconf, "ONE PLAYER GAME", COM_ENABLED, mainmenu_1v1, s)); diff --git a/src/game/scenes/mainmenu/menu_net.c b/src/game/scenes/mainmenu/menu_net.c index 4e60ac8bf..27135b57f 100644 --- a/src/game/scenes/mainmenu/menu_net.c +++ b/src/game/scenes/mainmenu/menu_net.c @@ -28,7 +28,7 @@ component *menu_net_create(scene *s) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; component *menu = menu_create(11); menu_attach(menu, label_create(&tconf, "NETWORK PLAY")); diff --git a/src/game/scenes/mainmenu/menu_presskey.c b/src/game/scenes/mainmenu/menu_presskey.c index 4ac1c4970..4f24de2ab 100644 --- a/src/game/scenes/mainmenu/menu_presskey.c +++ b/src/game/scenes/mainmenu/menu_presskey.c @@ -65,7 +65,7 @@ void menu_presskey_tick(component *c) { if(local->warn_timeout == 0) { for(int i = 0; i < 2; i++) { text_settings *tconf = label_get_text_settings(local->text[i]); - tconf->cforeground = color_create(0, 121, 0, 255); + tconf->cforeground = TEXT_MEDIUM_GREEN; } } } @@ -90,7 +90,7 @@ void menu_presskey_tick(component *c) { // Set texts to red as a warning for(int m = 0; m < 2; m++) { text_settings *tconf = label_get_text_settings(local->text[m]); - tconf->cforeground = color_create(121, 0, 0, 255); + tconf->cforeground = 0xF6; } local->warn_timeout = 50; return; @@ -114,7 +114,7 @@ component *menu_presskey_create(char **key) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; component *menu = menu_create(11); local->text[0] = label_create(&tconf, "PRESS A KEY FOR"); diff --git a/src/game/scenes/mainmenu/menu_video.c b/src/game/scenes/mainmenu/menu_video.c index 2fd3cc24d..c70ff9d07 100644 --- a/src/game/scenes/mainmenu/menu_video.c +++ b/src/game/scenes/mainmenu/menu_video.c @@ -122,7 +122,7 @@ component *menu_video_create(scene *s) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; // Create menu and its header component *menu = menu_create(11); diff --git a/src/game/scenes/mainmenu/menu_video_confirm.c b/src/game/scenes/mainmenu/menu_video_confirm.c index 3c00af978..60cd00486 100644 --- a/src/game/scenes/mainmenu/menu_video_confirm.c +++ b/src/game/scenes/mainmenu/menu_video_confirm.c @@ -70,7 +70,7 @@ component *menu_video_confirm_create(scene *s, settings_video *old_settings) { text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; component *menu = menu_create(11); menu_attach(menu, label_create(&tconf, "ACCEPT RESOLUTION?")); diff --git a/src/game/scenes/mechlab.c b/src/game/scenes/mechlab.c index 3733b34f1..b1bc67dfd 100644 --- a/src/game/scenes/mechlab.c +++ b/src/game/scenes/mechlab.c @@ -455,7 +455,7 @@ int mechlab_create(scene *scene) { tconf.font = FONT_SMALL; tconf.halign = TEXT_CENTER; tconf.valign = TEXT_MIDDLE; - tconf.cforeground = color_create(255, 255, 0, 255); + tconf.cforeground = TEXT_DARK_GREEN; local->hint = label_create(&tconf, "HINTY"); component_set_pos_hints(local->hint, 32, 131); diff --git a/src/game/scenes/mechlab/lab_dash_main.c b/src/game/scenes/mechlab/lab_dash_main.c index e5975aed8..6618f2436 100644 --- a/src/game/scenes/mechlab/lab_dash_main.c +++ b/src/game/scenes/mechlab/lab_dash_main.c @@ -165,18 +165,18 @@ component *lab_dash_main_create(scene *s, dashboard_widgets *dw) { text_settings tconf_dark; text_defaults(&tconf_dark); tconf_dark.font = FONT_SMALL; - tconf_dark.cforeground = color_create(0, 200, 0, 255); + tconf_dark.cforeground = TEXT_DARK_GREEN; text_settings tconf_light; text_defaults(&tconf_light); tconf_light.font = FONT_SMALL; - tconf_light.cforeground = color_create(50, 240, 50, 255); + tconf_light.cforeground = TEXT_BLINKY_GREEN; text_settings tconf_light_centered; text_defaults(&tconf_light_centered); tconf_light_centered.font = FONT_SMALL; tconf_light_centered.halign = TEXT_CENTER; - tconf_light_centered.cforeground = color_create(50, 240, 50, 255); + tconf_light_centered.cforeground = TEXT_BLINKY_GREEN; // Pilot image dw->photo = pilotpic_create(PIC_PLAYERS, 0); diff --git a/src/game/scenes/mechlab/lab_dash_newplayer.c b/src/game/scenes/mechlab/lab_dash_newplayer.c index db882981f..395531ce7 100644 --- a/src/game/scenes/mechlab/lab_dash_newplayer.c +++ b/src/game/scenes/mechlab/lab_dash_newplayer.c @@ -14,7 +14,7 @@ component *lab_dash_newplayer_create(scene *s, newplayer_widgets *nw) { text_defaults(&tconf); tconf.font = FONT_SMALL; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 0, 123, 255); + tconf.cforeground = TEXT_TRN_BLUE; // Background name box animation *main_sheets = &bk_get_info(&s->bk_data, 1)->ani; @@ -25,7 +25,7 @@ component *lab_dash_newplayer_create(scene *s, newplayer_widgets *nw) { xysizer_attach(xy, label_create(&tconf, lang_get(192)), 110, 43, 100, 50); // Input field - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; nw->input = textinput_create(&tconf, "Name", ""); component_select(nw->input, 1); textinput_enable_background(nw->input, 0); diff --git a/src/game/scenes/mechlab/lab_dash_trnselect.c b/src/game/scenes/mechlab/lab_dash_trnselect.c index d20527fa9..11616ab44 100644 --- a/src/game/scenes/mechlab/lab_dash_trnselect.c +++ b/src/game/scenes/mechlab/lab_dash_trnselect.c @@ -32,7 +32,7 @@ component *lab_dash_trnselect_create(scene *s, trnselect_widgets *tw) { text_defaults(&tconf); tconf.font = FONT_SMALL; tconf.halign = TEXT_CENTER; - tconf.cforeground = color_create(0, 0, 123, 255); + tconf.cforeground = TEXT_TRN_BLUE; // Pilot image tw->trnselect = trnselect_create(); diff --git a/src/game/scenes/mechlab/lab_menu_confirm.c b/src/game/scenes/mechlab/lab_menu_confirm.c index 4e5f7a922..802761fce 100644 --- a/src/game/scenes/mechlab/lab_menu_confirm.c +++ b/src/game/scenes/mechlab/lab_menu_confirm.c @@ -39,7 +39,7 @@ component *lab_menu_confirm_create(scene *s, lab_menu_select_cb yes, void *yesda text_settings tconf; text_defaults(&tconf); tconf.font = FONT_SMALL; - tconf.cforeground = color_create(0, 0, 123, 255); + tconf.cforeground = TEXT_TRN_BLUE; tconf.valign = TEXT_MIDDLE; tconf.halign = TEXT_CENTER; @@ -73,7 +73,7 @@ component *lab_menu_confirm_create(scene *s, lab_menu_select_cb yes, void *yesda trnmenu_attach(menu, button); // Add text label - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; component *label = label_create(&tconf, title); component_set_pos_hints(label, 10, 155); component_set_size_hints(label, 300, 10); diff --git a/src/game/scenes/mechlab/lab_menu_customize.c b/src/game/scenes/mechlab/lab_menu_customize.c index 6ae07810c..c59ab0141 100644 --- a/src/game/scenes/mechlab/lab_menu_customize.c +++ b/src/game/scenes/mechlab/lab_menu_customize.c @@ -739,7 +739,7 @@ component *lab_menu_customize_create(scene *s) { text_settings tconf; text_defaults(&tconf); tconf.font = FONT_SMALL; - tconf.cforeground = color_create(0, 0, 123, 255); + tconf.cforeground = TEXT_TRN_BLUE; // Init GUI buttons with locations from the "select" button sprites for(int i = 0; i < animation_get_sprite_count(main_buttons); i++) { @@ -777,13 +777,13 @@ component *lab_menu_customize_create(scene *s) { tconf.halign = TEXT_LEFT; tconf.valign = TEXT_TOP; tconf.lspacing = 2; - tconf.cforeground = color_create(0, 200, 0, 255); + tconf.cforeground = 0xA5; label1 = label_create(&tconf, ""); component_set_size_hints(label1, 90, 80); component_set_pos_hints(label1, 210, 150); trnmenu_attach(menu, label1); - tconf.cforeground = color_create(0, 255, 0, 255); + tconf.cforeground = 0xA7; label2 = label_create(&tconf, ""); component_set_size_hints(label2, 90, 80); component_set_pos_hints(label2, 210, 158); diff --git a/src/game/scenes/mechlab/lab_menu_difficultyselect.c b/src/game/scenes/mechlab/lab_menu_difficultyselect.c index 50429644a..5a055c82e 100644 --- a/src/game/scenes/mechlab/lab_menu_difficultyselect.c +++ b/src/game/scenes/mechlab/lab_menu_difficultyselect.c @@ -64,7 +64,7 @@ component *lab_menu_difficultyselect_create(scene *s) { text_settings tconf; text_defaults(&tconf); tconf.font = FONT_SMALL; - tconf.cforeground = color_create(0, 0, 123, 255); + tconf.cforeground = TEXT_TRN_BLUE; // Init GUI buttons with locations from the "select" button sprites for(int i = 0; i < animation_get_sprite_count(main_buttons); i++) { @@ -85,7 +85,7 @@ component *lab_menu_difficultyselect_create(scene *s) { } // Add text label - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; component *label = label_create(&tconf, "SELECT A DIFFICULTY LEVEL"); component_set_pos_hints(label, 87, 155); component_set_size_hints(label, 150, 10); diff --git a/src/game/scenes/mechlab/lab_menu_main.c b/src/game/scenes/mechlab/lab_menu_main.c index 379124cae..d4588d7c2 100644 --- a/src/game/scenes/mechlab/lab_menu_main.c +++ b/src/game/scenes/mechlab/lab_menu_main.c @@ -243,7 +243,7 @@ component *lab_menu_main_create(scene *s, bool character_loaded) { text_settings tconf; text_defaults(&tconf); tconf.font = FONT_SMALL; - tconf.cforeground = color_create(0, 0, 123, 255); + tconf.cforeground = TEXT_TRN_BLUE; // Init GUI buttons with locations from the "select" button sprites for(int i = 0; i < animation_get_sprite_count(main_buttons); i++) { diff --git a/src/game/scenes/mechlab/lab_menu_select.c b/src/game/scenes/mechlab/lab_menu_select.c index c74fc66d3..454acb7d4 100644 --- a/src/game/scenes/mechlab/lab_menu_select.c +++ b/src/game/scenes/mechlab/lab_menu_select.c @@ -43,7 +43,7 @@ component *lab_menu_select_create(scene *s, lab_menu_select_cb select, void *sel text_settings tconf; text_defaults(&tconf); tconf.font = FONT_SMALL; - tconf.cforeground = color_create(0, 0, 123, 255); + tconf.cforeground = TEXT_TRN_BLUE; lab_menu_select_t *selector = omf_calloc(1, sizeof(lab_menu_select_t)); selector->cb = select; @@ -88,7 +88,7 @@ component *lab_menu_select_create(scene *s, lab_menu_select_cb select, void *sel // TODO the left-right buttons apply on focus, not select // Add text label - tconf.cforeground = color_create(0, 121, 0, 255); + tconf.cforeground = TEXT_MEDIUM_GREEN; // TODO interpolate %s in the string here with blank component *label = label_create(&tconf, lang_get(title)); component_set_pos_hints(label, 87, 155); diff --git a/src/game/scenes/mechlab/lab_menu_trade.c b/src/game/scenes/mechlab/lab_menu_trade.c index 75fa1fa85..a47746b29 100644 --- a/src/game/scenes/mechlab/lab_menu_trade.c +++ b/src/game/scenes/mechlab/lab_menu_trade.c @@ -237,7 +237,7 @@ component *lab_menu_trade_create(scene *s) { text_settings tconf; text_defaults(&tconf); tconf.font = FONT_SMALL; - tconf.cforeground = color_create(0, 0, 123, 255); + tconf.cforeground = TEXT_TRN_BLUE; // Init GUI buttons with locations from the "select" button sprites for(int i = 0; i < animation_get_sprite_count(main_buttons); i++) { diff --git a/src/game/scenes/mechlab/lab_menu_training.c b/src/game/scenes/mechlab/lab_menu_training.c index ae724899a..cfa4735a5 100644 --- a/src/game/scenes/mechlab/lab_menu_training.c +++ b/src/game/scenes/mechlab/lab_menu_training.c @@ -177,7 +177,7 @@ component *lab_menu_training_create(scene *s) { text_settings tconf; text_defaults(&tconf); tconf.font = FONT_SMALL; - tconf.cforeground = color_create(0, 0, 123, 255); + tconf.cforeground = TEXT_TRN_BLUE; // Init GUI buttons with locations from the "select" button sprites for(int i = 0; i < animation_get_sprite_count(main_buttons); i++) { @@ -212,13 +212,13 @@ component *lab_menu_training_create(scene *s) { tconf.direction = TEXT_HORIZONTAL; tconf.halign = TEXT_LEFT; tconf.valign = TEXT_TOP; - tconf.cforeground = color_create(0, 200, 0, 255); + tconf.cforeground = 0xA5; label1 = label_create(&tconf, ""); component_set_size_hints(label1, 90, 110); component_set_pos_hints(label1, 200, 148); trnmenu_attach(menu, label1); - tconf.cforeground = color_create(0, 255, 0, 255); + tconf.cforeground = 0xA7; label2 = label_create(&tconf, ""); component_set_size_hints(label2, 90, 110); component_set_pos_hints(label2, 200, 186); diff --git a/src/game/scenes/melee.c b/src/game/scenes/melee.c index 4469346a5..1afdaf922 100644 --- a/src/game/scenes/melee.c +++ b/src/game/scenes/melee.c @@ -16,11 +16,14 @@ #include "resources/pilots.h" #include "resources/sprite.h" #include "utils/allocator.h" -#include "utils/log.h" #include "utils/random.h" #include "video/video.h" #define MAX_STAT 20 +#define TEXT_GREEN 0xA6 +#define RED_CURSOR_INDEX 0xF6 +#define BLUE_CURSOR_INDEX 0xF7 +#define VIOLET_CURSOR_INDEX 0xF8 typedef struct { int x; @@ -118,6 +121,21 @@ void melee_free(scene *scene) { scene_set_userdata(scene, local); } +static void set_cursor_colors(int offset) { + palette *pal = video_get_base_palette(); + int base = 120; + pal->data[RED_CURSOR_INDEX][0] = base + offset; + pal->data[RED_CURSOR_INDEX][1] = 0; + pal->data[RED_CURSOR_INDEX][2] = 0; + pal->data[BLUE_CURSOR_INDEX][0] = 0; + pal->data[BLUE_CURSOR_INDEX][1] = 0; + pal->data[BLUE_CURSOR_INDEX][2] = base + offset; + pal->data[VIOLET_CURSOR_INDEX][0] = base + offset; + pal->data[VIOLET_CURSOR_INDEX][1] = 0; + pal->data[VIOLET_CURSOR_INDEX][2] = base + offset; + video_force_pal_refresh(); +} + void melee_tick(scene *scene, int paused) { melee_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); @@ -148,14 +166,18 @@ void melee_tick(scene *scene, int paused) { } while((i = i->next)); } - local->ticks++; - if(local->page == HAR_SELECT && local->ticks % 10 == 1) { object_dynamic_tick(&local->har_player1[CURSOR_INDEX(local, 0)]); if(player2->selectable) { object_dynamic_tick(&local->har_player2[CURSOR_INDEX(local, 1)]); } } + + // Tick cursor colors + local->ticks++; + double rate = ((double)local->ticks) / 25.0; + int num = round((sin(rate) + 1.0) * 64); + set_cursor_colors(num); } void refresh_pilot_stats(melee_local *local) { @@ -387,30 +409,14 @@ static void draw_highlight(const melee_local *local, const cursor_data *cursor, video_draw_offset(&local->select_hilight, x, y, offset, 255); } -/** - * Get current color palette index for a given tick. This is used in the pulsing effect of the - * har or pilot selector highlight thingy. - */ -static int get_index_for_tick(int ticks) { - double rate = ((double)ticks) / 18.0; - return round((sin(rate) + 1.0) * 3) + 1; -} - static void render_highlights(const melee_local *local, bool player2_is_selectable) { - int index = get_index_for_tick(local->ticks); if(player2_is_selectable && CURSORS_MATCH(local)) { - int base = 0xE0; - int offset = CURSORS_DONE(local) ? base + 7 : base + index; - draw_highlight(local, &local->cursor[0], offset); + draw_highlight(local, &local->cursor[0], VIOLET_CURSOR_INDEX); } else { if(player2_is_selectable) { - int base = 0xA8; - int offset = CURSOR_B_DONE(local) ? base + 7 : base + index; - draw_highlight(local, &local->cursor[1], offset); + draw_highlight(local, &local->cursor[1], BLUE_CURSOR_INDEX); } - int base = 0xB0; - int offset = CURSOR_A_DONE(local) ? base + 7 : base + index; - draw_highlight(local, &local->cursor[0], offset); + draw_highlight(local, &local->cursor[0], RED_CURSOR_INDEX); } } @@ -434,12 +440,12 @@ static void render_pilot_select(melee_local *local, bool player2_is_selectable) video_draw(&local->bg_player_bio, 0, 62); // player bio - font_render_wrapped_shadowed(&font_small, lang_get(135 + current_a), 4, 66, 152, COLOR_GREEN, + font_render_wrapped_shadowed(&font_small, lang_get(135 + current_a), 4, 66, 152, TEXT_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); // player stats - font_render_shadowed(&font_small, lang_get(216), 74 + 27, 4, COLOR_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); - font_render_shadowed(&font_small, lang_get(217), 74 + 19, 22, COLOR_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); - font_render_shadowed(&font_small, lang_get(218), 74 + 12, 40, COLOR_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); + font_render_shadowed(&font_small, lang_get(216), 74 + 27, 4, TEXT_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); + font_render_shadowed(&font_small, lang_get(217), 74 + 19, 22, TEXT_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); + font_render_shadowed(&font_small, lang_get(218), 74 + 12, 40, TEXT_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); component_render(local->bar_power[0]); component_render(local->bar_agility[0]); component_render(local->bar_endurance[0]); @@ -449,32 +455,32 @@ static void render_pilot_select(melee_local *local, bool player2_is_selectable) video_draw(&local->bg_player_bio, 320 - local->bg_player_bio.w, 62); // player bio font_render_wrapped_shadowed(&font_small, lang_get(135 + current_b), 320 - local->bg_player_bio.w + 4, 66, 152, - COLOR_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); + TEXT_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); // player stats - font_render_shadowed(&font_small, lang_get(216), 320 - 66 - local->bg_player_stats.w + 27, 4, COLOR_GREEN, + font_render_shadowed(&font_small, lang_get(216), 320 - 66 - local->bg_player_stats.w + 27, 4, TEXT_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); - font_render_shadowed(&font_small, lang_get(217), 320 - 66 - local->bg_player_stats.w + 19, 22, COLOR_GREEN, + font_render_shadowed(&font_small, lang_get(217), 320 - 66 - local->bg_player_stats.w + 19, 22, TEXT_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); - font_render_shadowed(&font_small, lang_get(218), 320 - 66 - local->bg_player_stats.w + 12, 40, COLOR_GREEN, + font_render_shadowed(&font_small, lang_get(218), 320 - 66 - local->bg_player_stats.w + 12, 40, TEXT_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); component_render(local->bar_power[1]); component_render(local->bar_agility[1]); component_render(local->bar_endurance[1]); } else { // 'choose your pilot' - font_render_wrapped_shadowed(&font_small, lang_get(187), 160, 97, 160, COLOR_GREEN, + font_render_wrapped_shadowed(&font_small, lang_get(187), 160, 97, 160, TEXT_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); } object_render(&local->player2_placeholder); // player 1 name - font_render_wrapped_shadowed(&font_small, lang_get(20 + current_a), 0, 52, 66, COLOR_BLACK, + font_render_wrapped_shadowed(&font_small, lang_get(20 + current_a), 0, 52, 66, TEXT_BLACK, TEXT_SHADOW_TOP | TEXT_SHADOW_LEFT); if(player2_is_selectable) { // player 2 name - font_render_wrapped_shadowed(&font_small, lang_get(20 + current_b), 320 - 66, 52, 66, COLOR_BLACK, + font_render_wrapped_shadowed(&font_small, lang_get(20 + current_b), 320 - 66, 52, 66, TEXT_BLACK, TEXT_SHADOW_TOP | TEXT_SHADOW_LEFT); } @@ -504,12 +510,12 @@ static void render_har_select(melee_local *local, bool player2_is_selectable) { object_render(&local->har_player1[CURSOR_INDEX(local, 0)]); // player 1 name - font_render_wrapped_shadowed(&font_small, lang_get(20 + local->pilot_id_a), 0, 52, 66, COLOR_BLACK, + font_render_wrapped_shadowed(&font_small, lang_get(20 + local->pilot_id_a), 0, 52, 66, TEXT_BLACK, TEXT_SHADOW_TOP | TEXT_SHADOW_LEFT); if(player2_is_selectable) { // player 2 name - font_render_wrapped_shadowed(&font_small, lang_get(20 + local->pilot_id_b), 320 - 66, 52, 66, COLOR_BLACK, + font_render_wrapped_shadowed(&font_small, lang_get(20 + local->pilot_id_b), 320 - 66, 52, 66, TEXT_BLACK, TEXT_SHADOW_TOP | TEXT_SHADOW_LEFT); // currently selected player @@ -523,16 +529,16 @@ static void render_har_select(melee_local *local, bool player2_is_selectable) { str vs_text; str_from_format(&vs_text, "%s VS. %s", har_get_name(CURSOR_INDEX(local, 0)), har_get_name(CURSOR_INDEX(local, 1))); - font_render_wrapped_shadowed(&font_small, str_c(&vs_text), 80, 107, 150, COLOR_BLACK, + font_render_wrapped_shadowed(&font_small, str_c(&vs_text), 80, 107, 150, TEXT_BLACK, TEXT_SHADOW_TOP | TEXT_SHADOW_LEFT); str_free(&vs_text); } else { // 'choose your HAR' - font_render_wrapped_shadowed(&font_small, lang_get(186), 160, 97, 160, COLOR_GREEN, + font_render_wrapped_shadowed(&font_small, lang_get(186), 160, 97, 160, TEXT_MEDIUM_GREEN, TEXT_SHADOW_RIGHT | TEXT_SHADOW_BOTTOM); // render HAR name - font_render_wrapped_shadowed(&font_small, har_get_name(CURSOR_INDEX(local, 0)), 130, 107, 66, COLOR_BLACK, + font_render_wrapped_shadowed(&font_small, har_get_name(CURSOR_INDEX(local, 0)), 130, 107, 66, TEXT_BLACK, TEXT_SHADOW_TOP | TEXT_SHADOW_LEFT); } } @@ -554,10 +560,10 @@ void melee_render(scene *scene) { str wins_text_a, wins_text_b; str_from_format(&wins_text_a, "Wins: %d", s1->wins); str_from_format(&wins_text_b, "Wins: %d", s2->wins); - font_render_shadowed(&font_small, str_c(&wins_text_a), text_x, 107, COLOR_BLACK, + font_render_shadowed(&font_small, str_c(&wins_text_a), text_x, 107, TEXT_BLACK, TEXT_SHADOW_TOP | TEXT_SHADOW_LEFT); text_x = 312 - str_size(&wins_text_b) * font_small.w; - font_render_shadowed(&font_small, str_c(&wins_text_a), text_x, 107, COLOR_BLACK, + font_render_shadowed(&font_small, str_c(&wins_text_a), text_x, 107, TEXT_BLACK, TEXT_SHADOW_TOP | TEXT_SHADOW_LEFT); str_free(&wins_text_a); str_free(&wins_text_b); @@ -711,6 +717,7 @@ int melee_create(scene *scene) { component_layout(local->bar_endurance[1], 320 - 66 - local->bg_player_stats.w, 48, 20 * 4, 8); refresh_pilot_stats(local); + set_cursor_colors(0); // initialize nova selection cheat memset(local->har_selected, 0, sizeof(local->har_selected)); diff --git a/src/game/scenes/scoreboard.c b/src/game/scenes/scoreboard.c index c17db347a..23749bb38 100644 --- a/src/game/scenes/scoreboard.c +++ b/src/game/scenes/scoreboard.c @@ -13,8 +13,8 @@ #include "video/video.h" #define MAX_PAGES (NUMBER_OF_ROUND_TYPES - 1) -#define TEXT_COLOR_HEADER color_create(80, 220, 80, 0xFF) -#define TEXT_COLOR_SCORES color_create(0xFF, 0xFF, 0xFF, 0xFF) +#define TEXT_COLOR_HEADER TEXT_BLINKY_GREEN +#define TEXT_COLOR_SCORES 0x7F #define CURSOR_STR "\x7f" typedef struct scoreboard_local_t { diff --git a/src/game/scenes/vs.c b/src/game/scenes/vs.c index 7f34d9c47..e62778de7 100644 --- a/src/game/scenes/vs.c +++ b/src/game/scenes/vs.c @@ -272,10 +272,10 @@ void vs_render(scene *scene) { object_render(&local->arena_select); // arena name - font_render_wrapped(&font_small, lang_get(56 + local->arena), 56 + 72, 153, (211 - 72) - 4, COLOR_GREEN); + font_render_wrapped(&font_small, lang_get(56 + local->arena), 56 + 72, 153, (211 - 72) - 4, TEXT_MEDIUM_GREEN); // arena description - font_render_wrapped(&font_small, lang_get(66 + local->arena), 56 + 72, 160, (211 - 72) - 4, COLOR_GREEN); + font_render_wrapped(&font_small, lang_get(66 + local->arena), 56 + 72, 160, (211 - 72) - 4, TEXT_MEDIUM_GREEN); } else if(player2->pilot && player2->pilot->pilot_id == PILOT_KREISSACK && settings_get()->gameplay.difficulty < 2) { // kriessack, but not on Veteran or higher diff --git a/src/game/utils/score.c b/src/game/utils/score.c index 8afd028bb..f366adda5 100644 --- a/src/game/utils/score.c +++ b/src/game/utils/score.c @@ -6,14 +6,14 @@ #include #include -#define TEXT_COLOR color_create(186, 250, 250, 255) +#define TEXT_COLOR 0xC7 #define SLIDER_DISTANCE 50 #define SLIDER_HANG_TIME 25 #define SCRAP 100000 #define DESTRUCTION 200000 -typedef struct score_text_t { +typedef struct score_text { char *text; float position; // Position of text between middle of screen and (x,y). 1.0 at middle, 0.0 at end vec2i start; diff --git a/src/resources/fonts.c b/src/resources/fonts.c index e84d51e9e..6c992dd06 100644 --- a/src/resources/fonts.c +++ b/src/resources/fonts.c @@ -59,7 +59,7 @@ int font_load(font *font, const char *filename, unsigned int size) { sd_vga_image_create(&img, pixsize, pixsize); for(int i = 0; i < 224; i++) { sur = omf_calloc(1, sizeof(surface)); - sd_font_decode(&sdfont, &img, i, 0xFE); + sd_font_decode(&sdfont, &img, i, 0); surface_create_from_vga(sur, &img); vector_append(&font->surfaces, &sur); } diff --git a/src/video/color.h b/src/video/color.h index 0e8d16d46..8e6b352ac 100644 --- a/src/video/color.h +++ b/src/video/color.h @@ -1,12 +1,7 @@ #ifndef COLOR_H #define COLOR_H -#define COLOR_RED color_create(255, 0, 0, 255) -#define COLOR_GREEN color_create(0, 255, 0, 255) -#define COLOR_BLUE color_create(0, 0, 255, 255) -#define COLOR_YELLOW color_create(255, 255, 0, 255) -#define COLOR_WHITE color_create(255, 255, 255, 255) -#define COLOR_BLACK color_create(0, 0, 0, 255) +#define COLOR_YELLOW 0xFF typedef struct color_t color; diff --git a/src/video/surface.c b/src/video/surface.c index 5784d15b8..0669587cc 100644 --- a/src/video/surface.c +++ b/src/video/surface.c @@ -5,19 +5,21 @@ #include #include -uint32_t static fnv_32a_buf(const void *buf, unsigned int len) { +#define FNV_INITIAL ((uint32_t)2166136261) + +static void fnv_32a_buf(uint32_t *hash, const void *buf, unsigned int len) { unsigned char *bp = (unsigned char *)buf; unsigned char *be = bp + len; - uint32_t hash = ((uint32_t)2166136261); while(bp < be) { - hash ^= (uint32_t)*bp++; - hash *= ((uint32_t)0x01000193); + *hash ^= (uint32_t)*bp++; + *hash *= ((uint32_t)0x01000193); } - return hash; } static inline void create_hash(surface *sur) { - sur->hash = fnv_32a_buf(sur->data, sur->w * sur->h); + sur->hash = FNV_INITIAL; + fnv_32a_buf(&sur->hash, sur->data, sur->w * sur->h); + fnv_32a_buf(&sur->hash, sur->stencil, sur->w * sur->h); } void surface_create(surface *sur, int w, int h) { diff --git a/src/video/video.c b/src/video/video.c index 95f98dec6..c2313613c 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -320,11 +320,6 @@ void video_draw(const surface *src_surface, int x, int y) { video_draw_offset(src_surface, x, y, 0, 255); } -void video_render_sprite_tint(surface *sur, int sx, int sy, color c, int pal_offset) { - video_render_sprite_flip_scale_opacity_tint(sur, sx, sy, BLEND_ALPHA, pal_offset, 255, FLIP_NONE, 1.0f, 1.0f, 255, - c); -} - void video_render_sprite_flip_scale_opacity_tint(surface *sur, int sx, int sy, VIDEO_BLEND_MODE blend_mode, int pal_offset, int pal_limit, unsigned int flip_mode, float x_percent, float y_percent, uint8_t opacity, color tint) { diff --git a/src/video/video.h b/src/video/video.h index f1b4e3e5d..6a9daaef9 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -19,11 +19,6 @@ void video_reinit_renderer(); void video_get_state(int *w, int *h, int *fs, int *vsync); void video_move_target(int x, int y); -/** - * @deprecated - */ -void video_render_sprite_tint(surface *sur, int x, int y, color c, int pal_offset); - /** * @deprecated */