diff options
author | Andrey Nazarov <skuller@skuller.net> | 2013-09-08 21:25:00 +0400 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2013-09-08 21:25:00 +0400 |
commit | a281b7ea9bb4d0667cb6916155855df1c53cd724 (patch) | |
tree | 918090231398818a0f285df1d6f4c19ae670621d | |
parent | 7dd8cc2890095f98855d65b6e5e8c295bfb81bb1 (diff) |
Allow inverted color in HUD strings.
-rw-r--r-- | inc/client/client.h | 2 | ||||
-rw-r--r-- | src/client/screen.c | 4 | ||||
-rw-r--r-- | src/refresh/gl/draw.c | 18 | ||||
-rw-r--r-- | src/refresh/sw/draw.c | 18 |
4 files changed, 24 insertions, 18 deletions
diff --git a/inc/client/client.h b/inc/client/client.h index 47560e7..14e2e1b 100644 --- a/inc/client/client.h +++ b/inc/client/client.h @@ -111,7 +111,7 @@ void SCR_UpdateScreen(void); #define UI_DROPSHADOW 0x00000010 #define UI_ALTCOLOR 0x00000020 #define UI_IGNORECOLOR 0x00000040 -#define UI_ALTESCAPES 0x00000080 +#define UI_XORCOLOR 0x00000080 #define UI_AUTOWRAP 0x00000100 #define UI_MULTILINE 0x00000200 #define UI_DRAWCURSOR 0x00000400 diff --git a/src/client/screen.c b/src/client/screen.c index a981794..906d684 100644 --- a/src/client/screen.c +++ b/src/client/screen.c @@ -1505,13 +1505,13 @@ STAT PROGRAMS R_DrawString(x, y, 0, MAX_STRING_CHARS, string, scr.font_pic) #define HUD_DrawAltString(x, y, string) \ - R_DrawString(x, y, UI_ALTCOLOR, MAX_STRING_CHARS, string, scr.font_pic) + R_DrawString(x, y, UI_XORCOLOR, MAX_STRING_CHARS, string, scr.font_pic) #define HUD_DrawCenterString(x, y, string) \ SCR_DrawStringMulti(x, y, UI_CENTER, MAX_STRING_CHARS, string, scr.font_pic) #define HUD_DrawAltCenterString(x, y, string) \ - SCR_DrawStringMulti(x, y, UI_CENTER|UI_ALTCOLOR, MAX_STRING_CHARS, string, scr.font_pic) + SCR_DrawStringMulti(x, y, UI_CENTER | UI_XORCOLOR, MAX_STRING_CHARS, string, scr.font_pic) static void HUD_DrawNumber(int x, int y, int color, int width, int value) { diff --git a/src/refresh/gl/draw.c b/src/refresh/gl/draw.c index af80a59..60b233f 100644 --- a/src/refresh/gl/draw.c +++ b/src/refresh/gl/draw.c @@ -203,7 +203,7 @@ void R_DrawFill32(int x, int y, int w, int h, uint32_t color) _GL_StretchPic(x, y, w, h, 0, 0, 1, 1, color, TEXNUM_WHITE, 0); } -static inline void draw_char(int x, int y, int c, qboolean alt, image_t *image) +static inline void draw_char(int x, int y, int flags, int c, image_t *image) { float s, t; @@ -211,7 +211,13 @@ static inline void draw_char(int x, int y, int c, qboolean alt, image_t *image) return; } - c |= alt << 7; + if (flags & UI_ALTCOLOR) { + c |= 0x80; + } + if (flags & UI_XORCOLOR) { + c ^= 0x80; + } + s = (c & 15) * 0.0625f; t = (c >> 4) * 0.0625f; @@ -227,23 +233,21 @@ static inline void draw_char(int x, int y, int c, qboolean alt, image_t *image) } GL_StretchPic(x, y, CHAR_WIDTH, CHAR_HEIGHT, s, t, - s + 0.0625f, t + 0.0625f, draw.colors[alt].u32, image); + s + 0.0625f, t + 0.0625f, draw.colors[c >> 7].u32, image); } void R_DrawChar(int x, int y, int flags, int c, qhandle_t font) { - qboolean alt = (flags & UI_ALTCOLOR) ? qtrue : qfalse; - draw_char(x, y, c & 255, alt, IMG_ForHandle(font)); + draw_char(x, y, flags, c & 255, IMG_ForHandle(font)); } int R_DrawString(int x, int y, int flags, size_t maxlen, const char *s, qhandle_t font) { image_t *image = IMG_ForHandle(font); - qboolean alt = (flags & UI_ALTCOLOR) ? qtrue : qfalse; while (maxlen-- && *s) { byte c = *s++; - draw_char(x, y, c, alt, image); + draw_char(x, y, flags, c, image); x += CHAR_WIDTH; } diff --git a/src/refresh/sw/draw.c b/src/refresh/sw/draw.c index 9bd9b51..f4faa84 100644 --- a/src/refresh/sw/draw.c +++ b/src/refresh/sw/draw.c @@ -405,7 +405,7 @@ void R_DrawPic(int x, int y, qhandle_t pic) image->upload_width * TEX_BYTES, image->pixels[0], draw.colors[0]); } -static inline void draw_char(int x, int y, int ch, qboolean alt, image_t *image) +static inline void draw_char(int x, int y, int flags, int ch, image_t *image) { int x2, y2; byte *data; @@ -413,12 +413,17 @@ static inline void draw_char(int x, int y, int ch, qboolean alt, image_t *image) if ((ch & 127) == 32) return; - ch |= alt << 7; + if (flags & UI_ALTCOLOR) + ch |= 0x80; + + if (flags & UI_XORCOLOR) + ch ^= 0x80; + x2 = (ch & 15) * CHAR_WIDTH; y2 = ((ch >> 4) & 15) * CHAR_HEIGHT; data = image->pixels[0] + y2 * image->upload_width * TEX_BYTES + x2 * TEX_BYTES; - R_DrawFixedData(x, y, CHAR_WIDTH, CHAR_HEIGHT, image->upload_width * TEX_BYTES, data, draw.colors[alt]); + R_DrawFixedData(x, y, CHAR_WIDTH, CHAR_HEIGHT, image->upload_width * TEX_BYTES, data, draw.colors[ch >> 7]); } void R_DrawChar(int x, int y, int flags, int ch, qhandle_t font) @@ -432,7 +437,7 @@ void R_DrawChar(int x, int y, int flags, int ch, qhandle_t font) if (image->upload_width != 128 || image->upload_height != 128) return; - draw_char(x, y, ch, !!(flags & UI_ALTCOLOR), image); + draw_char(x, y, flags, ch & 255, image); } /* @@ -444,7 +449,6 @@ int R_DrawString(int x, int y, int flags, size_t maxChars, const char *string, qhandle_t font) { image_t *image; - qboolean alt; if (!font) return x; @@ -453,11 +457,9 @@ int R_DrawString(int x, int y, int flags, size_t maxChars, if (image->upload_width != 128 || image->upload_height != 128) return x; - alt = (flags & UI_ALTCOLOR) ? qtrue : qfalse; - while (maxChars-- && *string) { byte c = *string++; - draw_char(x, y, c, alt, image); + draw_char(x, y, flags, c, image); x += CHAR_WIDTH; } |