diff --git a/desktop_version/lang/README-programmers.txt b/desktop_version/lang/README-programmers.txt index c078f081..f3e1f5fb 100644 --- a/desktop_version/lang/README-programmers.txt +++ b/desktop_version/lang/README-programmers.txt @@ -53,7 +53,8 @@ A not-technically-exhaustive list of all flags (which are defined in Font.h): - PR_FONT_LEVEL Use level-specific font (room names, cutscenes, etc) - PR_FONT_8X8 Use 8x8 font no matter what - PR_BRIGHTNESS(value) Use this brightness 0-255 (this value is mixed with - r, g and b for an alpha effect) + r, g and b for an alpha effect, and accounts for + colored glyphs correctly) - PR_BOR Draw a black border around the text - PR_LEFT [DEFAULT] Left-align text/place at X coordinate - PR_CEN Center-align text relative to X (X is center) diff --git a/desktop_version/src/Font.cpp b/desktop_version/src/Font.cpp index 44370056..54b15def 100644 --- a/desktop_version/src/Font.cpp +++ b/desktop_version/src/Font.cpp @@ -58,8 +58,7 @@ struct PrintFlags { uint8_t scale; Font* font_sel; - uint8_t alpha; - uint8_t colorglyph_bri; + uint8_t brightness; bool border; bool align_cen; bool align_right; @@ -657,18 +656,7 @@ static PrintFlags decode_print_flags(uint32_t flags) PrintFlags pf; pf.scale = FLAG_PART(0, 3) + 1; pf.font_sel = fontsel_to_font(FLAG_PART(3, 5)); - - if (flags & PR_AB_IS_BRI) - { - pf.alpha = 255; - pf.colorglyph_bri = ~FLAG_PART(8, 8) & 0xff; - } - else - { - pf.alpha = ~FLAG_PART(8, 8) & 0xff; - pf.colorglyph_bri = 255; - } - + pf.brightness = ~FLAG_PART(8, 8) & 0xff; pf.border = flags & PR_BOR; pf.align_cen = flags & PR_CEN; pf.align_right = flags & PR_RIGHT; @@ -929,8 +917,7 @@ static int print_char( uint8_t r, uint8_t g, uint8_t b, - const uint8_t a, - const uint8_t colorglyph_bri + const uint8_t brightness ) { /* Draws the glyph for a codepoint at x,y. @@ -943,10 +930,17 @@ static int print_char( if (glyph->flags & GLYPH_COLOR && (r | g | b) != 0) { - r = g = b = colorglyph_bri; + r = g = b = brightness; + } + else if (brightness < 255) + { + float bri_factor = brightness / (float) 255; + r *= bri_factor; + g *= bri_factor; + b *= bri_factor; } - graphics.draw_grid_tile(f->image, glyph->image_idx, x, y, f->glyph_w, f->glyph_h, r, g, b, a, scale, scale * (graphics.flipmode ? -1 : 1)); + graphics.draw_grid_tile(f->image, glyph->image_idx, x, y, f->glyph_w, f->glyph_h, r, g, b, scale, scale * (graphics.flipmode ? -1 : 1)); return glyph->advance * scale; } @@ -1137,8 +1131,7 @@ void print( r, g, b, - pf.alpha, - pf.colorglyph_bri + pf.brightness ); } } diff --git a/desktop_version/src/Font.h b/desktop_version/src/Font.h index a8d40fce..5949b900 100644 --- a/desktop_version/src/Font.h +++ b/desktop_version/src/Font.h @@ -43,11 +43,8 @@ #define PR_FONT_LEVEL (1 << 3) /* use level-specific font (room names, cutscene dialogue, etc) */ #define PR_FONT_8X8 (2 << 3) /* use 8x8 font no matter what */ #define PR_FONT_IDX(idx) ((SDL_clamp(idx, 0, 28) + 3) << 3) /* use given font index */ -#define PR_AB_IS_BRI (1 << 16) -#define PR_ALPHA(value) /* use this alpha value 0-255 (incompatible with PR_COLORGLYPH_BRI) */\ - ((~SDL_clamp((int)(value), 0, 255) & 0xff) << 8) -#define PR_COLORGLYPH_BRI(value) /* use this brightness 0-255 for colored glyphs (button icons) */\ - (((~SDL_clamp((int)(value), 0, 255) & 0xff) << 8) | PR_AB_IS_BRI) +#define PR_BRIGHTNESS(value) /* use this brightness 0-255 for the text (accounts for button glyphs correctly) */\ + (((~SDL_clamp((int)(value), 0, 255) & 0xff) << 8)) #define PR_BOR (1 << 17) /* draw a black border around the text (was bprint/bigbprint) */ #define PR_LEFT (0 << 18) /* default, left-align text/place at x coordinate */ #define PR_CEN (1 << 18) /* center-align text relative to X (X is center) or to screen if X == -1 */ diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index f896d96f..8f8888b4 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -843,11 +843,11 @@ void Graphics::drawgui(void) for (j = 0; j < textboxes[i].lines.size(); j++) { font::print( - textboxes[i].print_flags | PR_COLORGLYPH_BRI(tl_lerp*255) | PR_CJK_LOW, + textboxes[i].print_flags | PR_BRIGHTNESS(tl_lerp*255) | PR_CJK_LOW, textboxes[i].xp + 8, yp + text_yoff + text_sign * (j * font_height), textboxes[i].lines[j], - r, g, b + textboxes[i].r, textboxes[i].g, textboxes[i].b ); } } @@ -1696,22 +1696,15 @@ void Graphics::drawgravityline( int t ) void Graphics::drawtrophytext(void) { - int temp, temp2, temp3; int brightness; if (obj.trophytext < 15) { const int usethismult = lerp(obj.oldtrophytext, obj.trophytext); - temp = (196 * usethismult) / 15; - temp2 = (196 * usethismult) / 15; - temp3 = ((255 - help.glow) * usethismult) / 15; brightness = (usethismult/15.0)*255; } else { - temp = 196; - temp2 = 196; - temp3 = 255 - help.glow; brightness = 255; } @@ -1795,12 +1788,12 @@ void Graphics::drawtrophytext(void) if (top_text != NULL) { font::string_wordwrap(0, top_text, 304, &lines); - font::print_wrap(PR_CEN | PR_COLORGLYPH_BRI(brightness) | PR_BOR, -1, 11-(lines-1)*5, top_text, temp, temp2, temp3); + font::print_wrap(PR_CEN | PR_BRIGHTNESS(brightness) | PR_BOR, -1, 11-(lines-1)*5, top_text, 196, 196, 255 - help.glow); } if (bottom_text != NULL) { font::string_wordwrap(0, bottom_text, 304, &lines); - font::print_wrap(PR_CEN | PR_COLORGLYPH_BRI(brightness) | PR_BOR, -1, 221-(lines-1)*5, bottom_text, temp, temp2, temp3); + font::print_wrap(PR_CEN | PR_BRIGHTNESS(brightness) | PR_BOR, -1, 221-(lines-1)*5, bottom_text, 196, 196, 255 - help.glow); } } diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 373d5d76..010cdacc 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1961,11 +1961,15 @@ void gamerender(void) } #if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR) - if(map.custommode && !map.custommodeforreal && !game.advancetext){ + if(map.custommode && !map.custommodeforreal && !game.advancetext){ //Return to level editor int alpha = graphics.lerp(ed.oldreturneditoralpha, ed.returneditoralpha); - font::print(PR_ALPHA(alpha) | PR_BOR, 5, 5, loc::gettext("[Press ENTER to return to editor]"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); - } + + if (alpha > 100) + { + font::print(PR_BRIGHTNESS(alpha) | PR_BOR, 5, 5, loc::gettext("[Press ENTER to return to editor]"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); + } + } #endif @@ -1997,13 +2001,13 @@ void gamerender(void) int alpha = graphics.lerp(game.oldreadytotele, game.readytotele); font::print( - PR_COLORGLYPH_BRI(alpha) | PR_CEN | PR_BOR, + PR_BRIGHTNESS(alpha) | PR_CEN | PR_BOR, -1, graphics.flipmode ? 20 : 210, final_string, - alpha - 20 - (help.glow / 2), - alpha - 20 - (help.glow / 2), - alpha + 235 - (help.glow / 2), + 235 - (help.glow / 2), + 255 ); } @@ -2223,13 +2227,13 @@ void gamerender(void) if (game.activity_r == 0 && game.activity_g == 0 && game.activity_b == 0) { font::print( - game.activity_print_flags | PR_COLORGLYPH_BRI(act_alpha*255), + game.activity_print_flags | PR_BRIGHTNESS(act_alpha*255), centered_x + game.activity_x, game.activity_y + 12, final_string, - 196*act_alpha, - 196*act_alpha, - (255 - help.glow)*act_alpha + 196, + 196, + 255 - help.glow ); } else @@ -2244,13 +2248,13 @@ void gamerender(void) game.activity_b*act_alpha ); font::print( - game.activity_print_flags | PR_COLORGLYPH_BRI(act_alpha*255) | PR_CJK_LOW, + game.activity_print_flags | PR_BRIGHTNESS(act_alpha*255) | PR_CJK_LOW, centered_x + game.activity_x, game.activity_y + 12, final_string, - game.activity_r*act_alpha, - game.activity_g*act_alpha, - game.activity_b*act_alpha + game.activity_r, + game.activity_g, + game.activity_b ); } }