From 7daf5d4727eadf2e196e57e0f4f5b8d4f1370096 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 9 Nov 2018 22:38:55 -0500 Subject: [PATCH] Set up separate background color for prompts vs. console --- src/console.c | 40 ++++++++++++++++++++++++++++++++-------- src/console.h | 2 ++ src/dehacked.c | 2 +- src/doomstat.h | 2 +- src/f_finale.c | 2 +- src/v_video.c | 11 ++++++++--- src/v_video.h | 2 +- 7 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/console.c b/src/console.c index 9bc01cf19..f4234d949 100644 --- a/src/console.c +++ b/src/console.c @@ -232,18 +232,20 @@ UINT8 *yellowmap, *magentamap, *lgreenmap, *bluemap, *graymap, *redmap, *orangem // Console BG color UINT8 *consolebgmap = NULL; +UINT8 *promptbgmap = NULL; +static UINT8 promptbgcolor = UINT8_MAX; -void CON_SetupBackColormap(void) +void CON_SetupBackColormapEx(INT32 color, boolean prompt) { UINT16 i, palsum; UINT8 j, palindex, shift; UINT8 *pal = W_CacheLumpName(GetPalette(), PU_CACHE); - if (!consolebgmap) - consolebgmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); + if (color == INT32_MAX) + color = cons_backcolor.value; shift = 6; // 12 colors -- shift of 7 means 6 colors - switch (cons_backcolor.value) + switch (color) { case 0: palindex = 15; break; // White case 1: palindex = 31; break; // Gray @@ -257,20 +259,42 @@ void CON_SetupBackColormap(void) case 9: palindex = 187; break; // Magenta case 10: palindex = 139; break; // Aqua // Default green - default: palindex = 175; break; -} + default: palindex = 175; color = 11; break; + } + + if (prompt) + { + if (!promptbgmap) + promptbgmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); + + if (color == promptbgcolor) + return; + else + promptbgcolor = color; + } + else if (!consolebgmap) + consolebgmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL); // setup background colormap for (i = 0, j = 0; i < 768; i += 3, j++) { palsum = (pal[i] + pal[i+1] + pal[i+2]) >> shift; - consolebgmap[j] = (UINT8)(palindex - palsum); + if (prompt) + promptbgmap[j] = (UINT8)(palindex - palsum); + else + consolebgmap[j] = (UINT8)(palindex - palsum); } } +void CON_SetupBackColormap(void) +{ + CON_SetupBackColormapEx(cons_backcolor.value, false); + CON_SetupBackColormapEx(1, true); // default to gray +} + static void CONS_backcolor_Change(void) { - CON_SetupBackColormap(); + CON_SetupBackColormapEx(cons_backcolor.value, false); } static void CON_SetupColormaps(void) diff --git a/src/console.h b/src/console.h index 970f841d0..c194f44bf 100644 --- a/src/console.h +++ b/src/console.h @@ -38,7 +38,9 @@ extern UINT8 *yellowmap, *magentamap, *lgreenmap, *bluemap, *graymap, *redmap, * // Console bg color (auto updated to match) extern UINT8 *consolebgmap; +extern UINT8 *promptbgmap; +void CON_SetupBackColormapEx(INT32 color, boolean prompt); void CON_SetupBackColormap(void); void CON_ClearHUD(void); // clear heads up messages diff --git a/src/dehacked.c b/src/dehacked.c index 0802fc49d..61dba24c8 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1779,7 +1779,7 @@ static void readtextprompt(MYFILE *f, INT32 num) { if (1 <= value && value <= MAX_PAGES) { - textprompts[num]->page[value - 1].backcolor = UINT8_MAX; // non-zero default + textprompts[num]->page[value - 1].backcolor = 1; // default to gray readtextpromptpage(f, num, value - 1); } else diff --git a/src/doomstat.h b/src/doomstat.h index eb1726e54..6ff32e95d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -176,7 +176,7 @@ typedef struct boolean rightside; // narrator side, false = left, true = right boolean iconflip; // narrator flip icon horizontally UINT8 lines; // # of lines to show. If name is specified, name takes one of the lines. If 0, defaults to 4. - UINT8 backcolor; // see CON_SetupBackColormap: 0-10, 11 for default, UINT8_MAX for user-defined (CONS_BACKCOLOR) + INT32 backcolor; // see CON_SetupBackColormap: 0-11, INT32_MAX for user-defined (CONS_BACKCOLOR) UINT8 align; // text alignment, 0 = left, 1 = right, 2 = center UINT8 verticalalign; // vertical text alignment, 0 = top, 1 = bottom, 2 = middle UINT8 textspeed; // text speed, delay in tics between characters. diff --git a/src/f_finale.c b/src/f_finale.c index f120cd756..ad9fd26ce 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2199,7 +2199,7 @@ void F_TextPromptDrawer(void) F_GetPageTextGeometry(&pagelines, &rightside, &boxh, &texth, &texty, &namey, &chevrony, &textx, &textr); // Draw background - V_DrawTutorialBack(boxh); + V_DrawPromptBack(boxh, textprompts[cutnum]->page[scenenum].backcolor); // Draw narrator icon if (iconlump != LUMPERROR) diff --git a/src/v_video.c b/src/v_video.c index f8d0b392c..7296dc754 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1481,17 +1481,20 @@ void V_DrawFadeConsBack(INT32 plines) } // Very similar to F_DrawFadeConsBack, except we draw from the middle(-ish) of the screen to the bottom. -void V_DrawTutorialBack(INT32 boxheight) +void V_DrawPromptBack(INT32 boxheight, INT32 color) { UINT8 *deststop, *buf; boxheight *= vid.dupy; + if (color == INT32_MAX) + color = cons_backcolor.value; + #ifdef HWRENDER if (rendermode != render_soft && rendermode != render_none) { UINT32 hwcolor; - switch (cons_backcolor.value) + switch (color) { case 0: hwcolor = 0xffffff00; break; // White case 1: hwcolor = 0x80808000; break; // Gray @@ -1510,12 +1513,14 @@ void V_DrawTutorialBack(INT32 boxheight) } #endif + CON_SetupBackColormapEx(color, true); + // heavily simplified -- we don't need to know x or y position, // just the start and stop positions deststop = screens[0] + vid.rowbytes * vid.height; buf = deststop - vid.rowbytes * ((boxheight * 4) + (boxheight/2)*5); // 4 lines of space plus gaps between and some leeway for (; buf < deststop; ++buf) - *buf = consolebgmap[*buf]; + *buf = promptbgmap[*buf]; } // Gets string colormap, used for 0x80 color codes diff --git a/src/v_video.h b/src/v_video.h index ee958c2fa..84a027963 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -158,7 +158,7 @@ void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum); void V_DrawFadeScreen(UINT16 color, UINT8 strength); void V_DrawFadeConsBack(INT32 plines); -void V_DrawTutorialBack(INT32 boxheight); +void V_DrawPromptBack(INT32 boxheight, INT32 color); // draw a single character void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed);