Text prompt features: Name, Icon, IconAlign, Lines

This commit is contained in:
mazmazz 2018-11-03 05:05:15 -04:00
parent a3d000a37e
commit cbcb6a0d6c
3 changed files with 52 additions and 4 deletions

View File

@ -2465,6 +2465,49 @@ static void ST_overlayDrawer(void)
ST_drawDebugInfo();
}
static void ST_drawTutorial(INT32 promptnum, INT32 pagenum)
{
lumpnum_t iconlump = W_CheckNumForName(textprompts[promptnum]->page[pagenum].iconname);
UINT8 pagelines = textprompts[promptnum]->page[pagenum].lines ? textprompts[promptnum]->page[pagenum].lines : 4;
// Vertical calculations
INT32 boxh = pagelines*2;
INT32 texth = textprompts[promptnum]->page[pagenum].name[0] ? (pagelines-1)*2 : pagelines*2; // name takes up first line if it exists
INT32 texty = BASEVIDHEIGHT - ((texth * 4) + (texth/2)*4);
INT32 namey = BASEVIDHEIGHT - ((boxh * 4) + (boxh/2)*4);
// Horizontal calculations
// Shift text to the right if we have a character icon on the left side
// Add 4 margin against icon
INT32 textx = iconlump != LUMPERROR && !textprompts[promptnum]->page[pagenum].rightside ? ((boxh * 4) + (boxh/2)*4) + 4 : 4;
INT32 textr = textprompts[promptnum]->page[pagenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4) + 4) : BASEVIDWIDTH-4;
// Data
patch_t *patch;
char *text;
// Draw background
V_DrawTutorialBack(boxh);
// Draw narrator icon
if (iconlump != LUMPERROR)
{
INT32 iconx = textprompts[promptnum]->page[pagenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4;
patch = W_CachePatchName(textprompts[promptnum]->page[pagenum].iconname, PU_CACHE);
V_DrawFixedPatch(iconx<<FRACBITS, namey<<FRACBITS, FixedDiv(((boxh * 4) + (boxh/2)*4) - 4, patch->width), 0, patch, NULL);
W_UnlockCachedPatch(patch);
}
// Draw text
// \todo Char-by-char printing, see f_finale.c F_WriteText
text = V_WordWrap(textx, textr, 0, textprompts[promptnum]->page[pagenum].text);
V_DrawString(textx, texty, V_SNAPTOBOTTOM, text);
// Draw name
if (textprompts[promptnum]->page[pagenum].name[0])
V_DrawString(textx, namey, V_SNAPTOBOTTOM, textprompts[promptnum]->page[pagenum].name);
}
void ST_Drawer(void)
{
#ifdef SEENAMES
@ -2538,4 +2581,8 @@ void ST_Drawer(void)
ST_overlayDrawer();
}
}
// Draw tutorial text over everything else
//if (tutorialmode)
ST_drawTutorial(0, 0);
}

View File

@ -1481,11 +1481,12 @@ 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(void)
void V_DrawTutorialBack(INT32 boxheight)
{
INT32 charheight = 8*vid.dupy;
UINT8 *deststop, *buf;
boxheight *= vid.dupy;
#ifdef HWRENDER
if (rendermode != render_soft) // no support for OpenGL yet
return;
@ -1494,7 +1495,7 @@ void V_DrawTutorialBack(void)
// 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 * ((charheight * 4) + (charheight/2)*5); // 4 lines of space plus gaps between and some leeway
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];
}

View File

@ -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(void);
void V_DrawTutorialBack(INT32 boxheight);
// draw a single character
void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed);