diff --git a/src/g_level.cpp b/src/g_level.cpp index 7008572a76..e3321f8840 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -742,12 +742,7 @@ void G_DoCompleted (void) { // Reset world variables for the new hub. P_ClearACSVars(false); } - // With hub statistics the time should be per hub. - // Additionally there is a global time counter now so nothing is missed by changing it - //else if (mode == FINISH_NoHub) - { // Reset time to zero if not entering/staying in a hub. - level.time = 0; - } + level.time = 0; level.maptime = 0; } diff --git a/src/gi.cpp b/src/gi.cpp index 4dfac16f99..705f9b8019 100644 --- a/src/gi.cpp +++ b/src/gi.cpp @@ -163,6 +163,28 @@ const char* GameInfoBoarders[] = } \ } +#define GAMEINFOKEY_FONT(key, variable) \ + else if(nextKey.CompareNoCase(variable) == 0) \ + { \ + sc.MustGetToken(TK_StringConst); \ + gameinfo.key.fontname = sc.String; \ + if (sc.CheckToken(',')) { \ + sc.MustGetToken(TK_StringConst); \ + gameinfo.key.color = sc.String; \ + } else { \ + gameinfo.key.color = NAME_None; \ + } \ + } + +#define GAMEINFOKEY_PATCH(key, variable) \ + else if(nextKey.CompareNoCase(variable) == 0) \ + { \ + sc.MustGetToken(TK_StringConst); \ + gameinfo.key.fontname = sc.String; \ + gameinfo.key.color = NAME_Null; \ + } + + void FMapInfoParser::ParseGameInfo() { sc.MustGetToken('{'); @@ -311,6 +333,11 @@ void FMapInfoParser::ParseGameInfo() GAMEINFOKEY_INT(TextScreenX, "textscreenx") GAMEINFOKEY_INT(TextScreenY, "textscreeny") GAMEINFOKEY_STRING(DefaultEndSequence, "defaultendsequence") + GAMEINFOKEY_FONT(mStatscreenMapNameFont, "statscreen_mapnamefont") + GAMEINFOKEY_FONT(mStatscreenFinishedFont, "statscreen_finishedfont") + GAMEINFOKEY_FONT(mStatscreenEnteringFont, "statscreen_enteringfont") + GAMEINFOKEY_PATCH(mStatscreenFinishedFont, "statscreen_finishedpatch") + GAMEINFOKEY_PATCH(mStatscreenEnteringFont, "statscreen_enteringpatch") else { diff --git a/src/gi.h b/src/gi.h index d9422c039e..4240526250 100644 --- a/src/gi.h +++ b/src/gi.h @@ -66,6 +66,12 @@ struct gameborder_t char br[8]; }; +struct FGIFont +{ + FName fontname; + FName color; +}; + struct gameinfo_t { int flags; @@ -130,6 +136,9 @@ struct gameinfo_t int TextScreenY; FName DefaultEndSequence; FString mMapArrow, mCheatMapArrow; + FGIFont mStatscreenMapNameFont; + FGIFont mStatscreenFinishedFont; + FGIFont mStatscreenEnteringFont; const char *GetFinalePage(unsigned int num) const; }; diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index 4229168147..dbf8446a95 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -47,6 +47,7 @@ #include "gi.h" #include "r_translate.h" #include "templates.h" +#include "gstrings.h" // States for the intermission typedef enum @@ -206,10 +207,39 @@ static bool noautostartmap; // GRAPHICS // +struct FPatchInfo +{ + FFont *mFont; + FTexture *mPatch; + EColorRange mColor; + + void Init(FGIFont &gifont) + { + if (gifont.color == NAME_Null) + { + mPatch = TexMan[gifont.fontname]; // "entering" + mColor = mPatch == NULL? CR_UNTRANSLATED : CR_UNDEFINED; + mFont = NULL; + } + else + { + mFont = V_GetFont(gifont.fontname); + mColor = V_FindFontColor(gifont.color); + mPatch = NULL; + } + if (mFont == NULL) + { + mFont = BigFont; + } + } +}; + +static FPatchInfo mapname; +static FPatchInfo finished; +static FPatchInfo entering; + static TArray yah; // You Are Here graphic static FTexture* splat; // splat -static FTexture* finished; // "Finished!" graphics -static FTexture* entering; // "Entering" graphic static FTexture* sp_secret; // "secret" static FTexture* kills; // "Kills", "Scrt", "Items", "Frags" static FTexture* secret; @@ -697,34 +727,67 @@ static int WI_DrawCharPatch (FFont *font, int charcode, int x, int y, EColorRang // //==================================================================== -int WI_DrawName(int y, const char *levelname) +int WI_DrawName(int y, FTexture *tex, const char *levelname) { - int i; - size_t l; - const char *p; - int h = 0; - int lumph; - - lumph = BigFont->GetHeight() * CleanYfac; - - p = levelname; - if (!p) return 0; - l = strlen(p); - if (!l) return 0; - - FBrokenLines *lines = V_BreakLines(BigFont, screen->GetWidth() / CleanXfac, p); - - if (lines) + // draw + if (tex) { - for (i = 0; lines[i].Width >= 0; i++) - { - screen->DrawText(BigFont, CR_UNTRANSLATED, (SCREENWIDTH - lines[i].Width * CleanXfac) / 2, y + h, - lines[i].Text, DTA_CleanNoMove, true, TAG_DONE); - h += lumph; - } - V_FreeBrokenLines(lines); + screen->DrawTexture(tex, (screen->GetWidth() - tex->GetScaledWidth()*CleanXfac) /2, y, DTA_CleanNoMove, true, TAG_DONE); + return y + (tex->GetScaledHeight() + BigFont->GetHeight()/4) * CleanYfac; + } + else + { + int i; + size_t l; + const char *p; + int h = 0; + int lumph; + + lumph = mapname.mFont->GetHeight() * CleanYfac; + + p = levelname; + if (!p) return 0; + l = strlen(p); + if (!l) return 0; + + FBrokenLines *lines = V_BreakLines(mapname.mFont, screen->GetWidth() / CleanXfac, p); + + if (lines) + { + for (i = 0; lines[i].Width >= 0; i++) + { + screen->DrawText(mapname.mFont, mapname.mColor, (SCREENWIDTH - lines[i].Width * CleanXfac) / 2, y + h, + lines[i].Text, DTA_CleanNoMove, true, TAG_DONE); + h += lumph; + } + V_FreeBrokenLines(lines); + } + return y + h + lumph/4; + } +} + +//==================================================================== +// +// Draws a text, either as patch or as string from the string table +// +//==================================================================== + +int WI_DrawPatchText(int y, FPatchInfo *pinfo, const char *stringname) +{ + const char *string = GStrings(stringname); + int midx = screen->GetWidth() / 2; + + if (pinfo->mPatch != NULL) + { + screen->DrawTexture(pinfo->mPatch, midx - pinfo->mPatch->GetScaledWidth()*CleanXfac/2, y, DTA_CleanNoMove, true, TAG_DONE); + return y + (pinfo->mPatch->GetScaledHeight() * CleanYfac); + } + else + { + screen->DrawText(pinfo->mFont, pinfo->mColor, midx - pinfo->mFont->StringWidth(string)*CleanXfac/2, + y, string, DTA_CleanNoMove, true, TAG_DONE); + return y + pinfo->mFont->GetHeight() * CleanYfac; } - return h + lumph/4; } @@ -736,41 +799,21 @@ int WI_DrawName(int y, const char *levelname) // A level name patch can be specified for all games now, not just Doom. // //==================================================================== + int WI_drawLF () { int y = WI_TITLEY * CleanYfac; - int midx = screen->GetWidth() / 2; - FTexture *tex = wbs->LName0; - - // draw - if (tex) - { - screen->DrawTexture(tex, midx - tex->GetScaledWidth()*CleanXfac/2, y, DTA_CleanNoMove, true, TAG_DONE); - y += (tex->GetScaledHeight() + BigFont->GetHeight()/4) * CleanYfac; - } - else - { - y += WI_DrawName(y, lnametexts[0]); - } + y = WI_DrawName(y, wbs->LName0, lnametexts[0]); + // Adjustment for different font sizes for map name and 'finished'. + y -= ((mapname.mFont->GetHeight() - finished.mFont->GetHeight()) * CleanYfac) / 4; + // draw "Finished!" - FFont *font = gameinfo.gametype & GAME_Raven ? SmallFont : BigFont; - if (y < (NG_STATSY - font->GetHeight()*3/4) * CleanYfac) + if (y < (NG_STATSY - finished.mFont->GetHeight()*3/4) * CleanYfac) { - // don't draw 'finished' if the level name is too high! - if (gameinfo.gametype & GAME_DoomChex) - { - screen->DrawTexture(finished, midx - finished->GetScaledWidth()*CleanXfac/2, y, DTA_CleanNoMove, true, TAG_DONE); - return y + finished->GetScaledHeight() * CleanYfac; - } - else - { - screen->DrawText(font, CR_WHITE, - midx - font->StringWidth("finished")*CleanXfac/2, y - 4*CleanYfac, "finished", - DTA_CleanNoMove, true, TAG_DONE); - return y + font->GetHeight() * CleanYfac; - } + // don't draw 'finished' if the level name is too tall + y = WI_DrawPatchText(y, &finished, "WI_FINISHED"); } return y; } @@ -784,36 +827,14 @@ int WI_drawLF () // A level name patch can be specified for all games now, not just Doom. // //==================================================================== + void WI_drawEL () { int y = WI_TITLEY * CleanYfac; - FFont *font = gameinfo.gametype & GAME_Raven ? SmallFont : BigFont; - // draw "entering" - // be careful with the added height so that it works for oversized 'entering' patches! - if (gameinfo.gametype & GAME_DoomChex) - { - screen->DrawTexture(entering, (SCREENWIDTH - entering->GetScaledWidth() * CleanXfac) / 2, y, DTA_CleanNoMove, true, TAG_DONE); - y += (entering->GetScaledHeight() + font->GetHeight()/4) * CleanYfac; - } - else - { - screen->DrawText(font, CR_WHITE, - (SCREENWIDTH - font->StringWidth("now entering:") * CleanXfac) / 2, y, - "now entering:", DTA_CleanNoMove, true, TAG_DONE); - y += font->GetHeight()*5*CleanYfac/4; - } - - // draw - FTexture *tex = wbs->LName1; - if (tex) - { - screen->DrawTexture(tex, (SCREENWIDTH - tex->GetScaledWidth() * CleanXfac) / 2, y, DTA_CleanNoMove, true, TAG_DONE); - } - else - { - WI_DrawName(y, lnametexts[1]); - } + y = WI_DrawPatchText(y, &entering, "WI_ENTERING"); + y += entering.mFont->GetHeight() * CleanYfac / 4; + WI_DrawName(y, wbs->LName1, lnametexts[1]); } @@ -1905,12 +1926,15 @@ void WI_Ticker(void) } } + void WI_loadData(void) { + entering.Init(gameinfo.mStatscreenEnteringFont); + finished.Init(gameinfo.mStatscreenFinishedFont); + mapname.Init(gameinfo.mStatscreenMapNameFont); + if (gameinfo.gametype & GAME_DoomChex) { - finished = TexMan["WIF"]; // "finished" - entering = TexMan["WIENTER"]; // "entering" kills = TexMan["WIOSTK"]; // "kills" secret = TexMan["WIOSTS"]; // "scrt" sp_secret = TexMan["WISCRT2"]; // "secret" diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index f3fb2bcef9..1a222f1f33 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1563,6 +1563,9 @@ $ifgame(heretic) SWSTRING = "ONLY AVAILABLE IN THE REGISTERED VERSION"; MNU_EPISODE = "Select Episode"; +WI_FINISHED = "finished"; +WI_ENTERING = "Now entering:"; + // Bloodbath announcer BBA_BONED = "%k boned %o like a fish"; diff --git a/wadsrc/static/mapinfo/chex.txt b/wadsrc/static/mapinfo/chex.txt index 79f27f5bfb..acc4462b1f 100644 --- a/wadsrc/static/mapinfo/chex.txt +++ b/wadsrc/static/mapinfo/chex.txt @@ -61,6 +61,9 @@ gameinfo textscreeny = 10 defaultendsequence = "Inter_Pic1" maparrow = "maparrows/arrow.txt", "maparrows/ddtarrow.txt" + statscreen_mapnamefont = "BigFont" + statscreen_finishedpatch = "WIF" + statscreen_enteringpatch = "WIENTER" } skill baby diff --git a/wadsrc/static/mapinfo/doomcommon.txt b/wadsrc/static/mapinfo/doomcommon.txt index 73d0037952..f152aa7309 100644 --- a/wadsrc/static/mapinfo/doomcommon.txt +++ b/wadsrc/static/mapinfo/doomcommon.txt @@ -62,6 +62,9 @@ gameinfo textscreeny = 10 defaultendsequence = "Inter_Cast" maparrow = "maparrows/arrow.txt", "maparrows/ddtarrow.txt" + statscreen_mapnamefont = "BigFont" + statscreen_finishedpatch = "WIF" + statscreen_enteringpatch = "WIENTER" } skill baby diff --git a/wadsrc/static/mapinfo/heretic.txt b/wadsrc/static/mapinfo/heretic.txt index 57aa839f43..33ab58190c 100644 --- a/wadsrc/static/mapinfo/heretic.txt +++ b/wadsrc/static/mapinfo/heretic.txt @@ -61,6 +61,9 @@ gameinfo textscreeny = 5 defaultendsequence = "Inter_Pic1" maparrow = "maparrows/dagger.txt" + statscreen_mapnamefont = "BigFont" + statscreen_finishedfont = "SmallFont" + statscreen_enteringfont = "SmallFont" } skill baby diff --git a/wadsrc/static/mapinfo/hexen.txt b/wadsrc/static/mapinfo/hexen.txt index eeef3b92a6..83202485b5 100644 --- a/wadsrc/static/mapinfo/hexen.txt +++ b/wadsrc/static/mapinfo/hexen.txt @@ -59,6 +59,9 @@ gameinfo textscreeny = 5 defaultendsequence = "Inter_Chess" maparrow = "maparrows/dagger.txt" + statscreen_mapnamefont = "BigFont" + statscreen_finishedfont = "SmallFont" + statscreen_enteringfont = "SmallFont" } skill baby diff --git a/wadsrc/static/mapinfo/strife.txt b/wadsrc/static/mapinfo/strife.txt index 2e6c242cb4..7791d73694 100644 --- a/wadsrc/static/mapinfo/strife.txt +++ b/wadsrc/static/mapinfo/strife.txt @@ -61,6 +61,9 @@ gameinfo textscreeny = 10 defaultendsequence = "Inter_Strife" maparrow = "maparrows/arrow.txt", "maparrows/ddtarrow.txt" + statscreen_mapnamefont = "BigFont" + statscreen_finishedfont = "BigFont", "white" + statscreen_enteringfont = "BigFont", "white" } Intermission Inter_Strife_Good