diff --git a/src/st_stuff.c b/src/st_stuff.c index fa13e008a..2a9d25cc7 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -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<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); } diff --git a/src/v_video.c b/src/v_video.c index 06f96a605..a628b1a8b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -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]; } diff --git a/src/v_video.h b/src/v_video.h index 850206816..ee958c2fa 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(void); +void V_DrawTutorialBack(INT32 boxheight); // draw a single character void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed);