mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-20 19:02:34 +00:00
Set up separate background color for prompts vs. console
This commit is contained in:
parent
ae4c1e0e82
commit
7daf5d4727
7 changed files with 46 additions and 15 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue