diff --git a/src/d_main.c b/src/d_main.c index 6cd6aaba6..6f9d46f36 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -424,6 +424,7 @@ static void D_Display(void) if (gamestate == GS_LEVEL) { ST_Drawer(); + F_TextPromptDrawer(); HU_Drawer(); } else diff --git a/src/f_finale.c b/src/f_finale.c index 151889c4c..c25dd9eca 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -48,6 +48,7 @@ static INT32 timetonext; // Delay between screen changes static INT32 continuetime; // Short delay when continuing static tic_t animtimer; // Used for some animation timings +static INT16 skullAnimCounter; // Chevron animation static INT32 roidtics; // Asteroid spinning static INT32 deplete; @@ -78,6 +79,8 @@ static patch_t *ttspop7; static void F_SkyScroll(INT32 scrollspeed); +static boolean promptactive = false; + // // CUTSCENE TEXT WRITING // @@ -2015,3 +2018,92 @@ boolean F_CutsceneResponder(event_t *event) return false; } + +void F_EndTextPrompt(void) +{ + promptactive = false; +} + +void F_StartTextPrompt(INT32 promptnum, INT32 pagenum) +{ + // We share vars, so no starting text prompts over cutscenes or title screens! + keypressed = false; + finalecount = 0; + timetonext = 0; + animtimer = 0; + stoptimer = 0; + skullAnimCounter = 0; + + cutnum = promptnum; + scenenum = pagenum; + promptactive = true; +} + +void F_TextPromptDrawer(void) +{ + // reuse: + // cutnum -> promptnum + // scenenum -> pagenum + + if (!promptactive) + return; + + lumpnum_t iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname); + UINT8 pagelines = textprompts[cutnum]->page[scenenum].lines ? textprompts[cutnum]->page[scenenum].lines : 4; + + // Vertical calculations + INT32 boxh = pagelines*2; + INT32 texth = textprompts[cutnum]->page[scenenum].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); + INT32 chevrony = BASEVIDHEIGHT - (((1*2) * 4) + ((1*2)/2)*4); // force on last line + + // 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[cutnum]->page[scenenum].rightside ? ((boxh * 4) + (boxh/2)*4) + 4 : 4; + INT32 textr = textprompts[cutnum]->page[scenenum].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[cutnum]->page[scenenum].rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4; + patch = W_CachePatchName(textprompts[cutnum]->page[scenenum].iconname, PU_CACHE); + V_DrawFixedPatch(iconx<width), V_SNAPTOBOTTOM, 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[cutnum]->page[scenenum].text); + V_DrawString(textx, texty, V_SNAPTOBOTTOM, text); + + // Draw name + // Don't use V_YELLOWMAP here so that the name color can be changed with control codes + if (textprompts[cutnum]->page[scenenum].name[0]) + V_DrawString(textx, namey, V_SNAPTOBOTTOM, textprompts[cutnum]->page[scenenum].name); + + // Draw chevron + V_DrawString(textr-8, chevrony + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); // down arrow +} + +void F_TextPromptTicker(void) +{ + if (!promptactive) + return; + + // advance animation + finalecount++; + cutscene_boostspeed = 0; + + // for the chevron + if (--skullAnimCounter <= 0) + skullAnimCounter = 8; +} diff --git a/src/f_finale.h b/src/f_finale.h index aadc64ad0..eb5872fca 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -33,6 +33,7 @@ void F_IntroTicker(void); void F_TitleScreenTicker(boolean run); void F_CutsceneTicker(void); void F_TitleDemoTicker(void); +void F_TextPromptTicker(void); // Called by main loop. FUNCMATH void F_GameEndDrawer(void); @@ -50,6 +51,10 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset void F_CutsceneDrawer(void); void F_EndCutScene(void); +void F_StartTextPrompt(INT32 promptnum, INT32 pagenum); +void F_TextPromptDrawer(void); +void F_EndTextPrompt(void); + void F_StartGameEnd(void); void F_StartIntro(void); void F_StartTitleScreen(void); diff --git a/src/g_game.c b/src/g_game.c index df8e0fd79..d72a1961b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1934,6 +1934,7 @@ void G_Ticker(boolean run) F_TitleDemoTicker(); P_Ticker(run); // tic the game ST_Ticker(); + F_TextPromptTicker(); AM_Ticker(); HU_Ticker(); break; diff --git a/src/st_stuff.c b/src/st_stuff.c index ce5042971..fa13e008a 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2465,49 +2465,6 @@ 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), V_SNAPTOBOTTOM, 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 @@ -2581,8 +2538,4 @@ void ST_Drawer(void) ST_overlayDrawer(); } } - - // Draw tutorial text over everything else - //if (tutorialmode) - ST_drawTutorial(0, 0); }