From 3e992169677f9115cd2c17dd64b49c3c31f30029 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 2 Aug 2019 09:11:40 +0200 Subject: [PATCH] - added option to print a map author's name on the summary screen For now only with font-printed map names. Allowing this with titlepatches will require more work and an option to disable. --- src/g_hub.cpp | 1 + src/g_level.cpp | 5 +++ src/g_levellocals.h | 1 + src/gamedata/g_mapinfo.cpp | 8 ++++ src/gamedata/g_mapinfo.h | 1 + src/gamedata/gi.cpp | 2 + src/gamedata/gi.h | 1 + src/scripting/vmthunks.cpp | 1 + src/wi_stuff.cpp | 2 + src/wi_stuff.h | 2 + wadsrc/static/mapinfo/chex.txt | 1 + wadsrc/static/mapinfo/doomcommon.txt | 2 + wadsrc/static/mapinfo/heretic.txt | 1 + wadsrc/static/mapinfo/hexen.txt | 1 + wadsrc/static/mapinfo/mindefaults.txt | 1 + wadsrc/static/mapinfo/strife.txt | 1 + wadsrc/static/zscript/base.zs | 2 + .../zscript/ui/statscreen/statscreen.zs | 38 ++++++++++++++++++- wadsrc/static/zscript/ui/statscreen/types.zs | 2 + 19 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/g_hub.cpp b/src/g_hub.cpp index 0e70deb1a..a31de7d42 100644 --- a/src/g_hub.cpp +++ b/src/g_hub.cpp @@ -134,6 +134,7 @@ void G_LeavingHub(FLevelLocals *Level, int mode, cluster_info_t * cluster, wbsta else { wbs->thisname = cluster->ClusterName; + wbs->thisauthor = ""; } wbs->LName0.SetInvalid(); // The level's own name was just invalidated, and so was its name patch. } diff --git a/src/g_level.cpp b/src/g_level.cpp index 741018d2d..9f0239a1d 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -840,6 +840,7 @@ bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo) wminfo.finished_ep = cluster - 1; wminfo.LName0 = TexMan.CheckForTexture(info->PName, ETextureType::MiscPatch); wminfo.thisname = info->LookupLevelName(&langtable[0]); // re-get the name so we have more info about its origin. + wminfo.thisauthor = info->AuthorName; wminfo.current = MapName; if (deathmatch && @@ -849,6 +850,7 @@ bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo) wminfo.next = MapName; wminfo.LName1 = wminfo.LName0; wminfo.nextname = wminfo.thisname; + wminfo.nextauthor = wminfo.thisauthor; } else { @@ -858,12 +860,14 @@ bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo) wminfo.next = ""; wminfo.LName1.SetInvalid(); wminfo.nextname = ""; + wminfo.nextauthor = ""; } else { wminfo.next = nextinfo->MapName; wminfo.LName1 = TexMan.CheckForTexture(nextinfo->PName, ETextureType::MiscPatch); wminfo.nextname = nextinfo->LookupLevelName(&langtable[1]); + wminfo.nextauthor = nextinfo->AuthorName; } } @@ -1637,6 +1641,7 @@ void FLevelLocals::Init() NextMap = info->NextMap; NextSecretMap = info->NextSecretMap; F1Pic = info->F1Pic; + AuthorName = info->AuthorName; hazardcolor = info->hazardcolor; hazardflash = info->hazardflash; diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 4068b56ee..ff7749b37 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -512,6 +512,7 @@ public: FString MapName; // the lump name (E1M1, MAP01, etc) FString NextMap; // go here when using the regular exit FString NextSecretMap; // map to go to when used secret exit + FString AuthorName; FString F1Pic; FTranslator *Translator; EMapType maptype; diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index 09e8cb485..93ac043bc 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -242,6 +242,7 @@ void level_info_t::Reset() flags3 = 0; Music = ""; LevelName = ""; + AuthorName = ""; FadeTable = "COLORMAP"; WallHorizLight = -8; WallVertLight = +8; @@ -923,6 +924,13 @@ DEFINE_MAP_OPTION(next, true) parse.ParseNextMap(info->NextMap); } +DEFINE_MAP_OPTION(author, true) +{ + parse.ParseAssign(); + parse.sc.MustGetString(); + info->AuthorName = parse.sc.String; +} + DEFINE_MAP_OPTION(secretnext, true) { parse.ParseAssign(); diff --git a/src/gamedata/g_mapinfo.h b/src/gamedata/g_mapinfo.h index f105d3f0c..116e23529 100644 --- a/src/gamedata/g_mapinfo.h +++ b/src/gamedata/g_mapinfo.h @@ -323,6 +323,7 @@ struct level_info_t FString Music; FString LevelName; + FString AuthorName; int8_t WallVertLight, WallHorizLight; int musicorder; FCompressedBuffer Snapshot; diff --git a/src/gamedata/gi.cpp b/src/gamedata/gi.cpp index 2d168b5e8..380fc66b6 100644 --- a/src/gamedata/gi.cpp +++ b/src/gamedata/gi.cpp @@ -60,6 +60,7 @@ DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mStatscreenMapNameFont) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mStatscreenEnteringFont) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mStatscreenFinishedFont) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mStatscreenContentFont) +DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mStatscreenAuthorFont) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, gibfactor) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, intermissioncounter) DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, statusscreen_single) @@ -427,6 +428,7 @@ void FMapInfoParser::ParseGameInfo() GAMEINFOKEY_FONT(mStatscreenFinishedFont, "statscreen_finishedfont") GAMEINFOKEY_FONT(mStatscreenEnteringFont, "statscreen_enteringfont") GAMEINFOKEY_FONT(mStatscreenContentFont, "statscreen_contentfont") + GAMEINFOKEY_FONT(mStatscreenAuthorFont, "statscreen_authorfont") GAMEINFOKEY_BOOL(norandomplayerclass, "norandomplayerclass") GAMEINFOKEY_BOOL(forcekillscripts, "forcekillscripts") // [JM] Force kill scripts on thing death. (MF7_NOKILLSCRIPTS overrides.) GAMEINFOKEY_STRING(Dialogue, "dialogue") diff --git a/src/gamedata/gi.h b/src/gamedata/gi.h index d66ea00ff..676630211 100644 --- a/src/gamedata/gi.h +++ b/src/gamedata/gi.h @@ -192,6 +192,7 @@ struct gameinfo_t FGIFont mStatscreenFinishedFont; FGIFont mStatscreenEnteringFont; FGIFont mStatscreenContentFont; + FGIFont mStatscreenAuthorFont; bool norandomplayerclass; bool forcekillscripts; FName statusscreen_single; diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index fbf412890..e6113e847 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -3061,6 +3061,7 @@ DEFINE_FIELD(FLevelLocals, MapName) DEFINE_FIELD(FLevelLocals, NextMap) DEFINE_FIELD(FLevelLocals, NextSecretMap) DEFINE_FIELD(FLevelLocals, F1Pic) +DEFINE_FIELD(FLevelLocals, AuthorName) DEFINE_FIELD(FLevelLocals, maptype) DEFINE_FIELD(FLevelLocals, Music) DEFINE_FIELD(FLevelLocals, musicorder) diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index 1e319a146..3a4327524 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -860,6 +860,8 @@ DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, current); DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, next); DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, nextname); DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, thisname); +DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, nextauthor); +DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, thisauthor); DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, LName0); DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, LName1); DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, maxkills); diff --git a/src/wi_stuff.h b/src/wi_stuff.h index 3ff4828b1..d9f089c85 100644 --- a/src/wi_stuff.h +++ b/src/wi_stuff.h @@ -56,6 +56,8 @@ struct wbstartstruct_t FString next; // next level, [RH] actual map name FString nextname; // printable name for next level. FString thisname; // printable name for next level. + FString nextauthor; // printable name for next level. + FString thisauthor; // printable name for next level. FTextureID LName0; FTextureID LName1; diff --git a/wadsrc/static/mapinfo/chex.txt b/wadsrc/static/mapinfo/chex.txt index 50f896fd3..42760eaab 100644 --- a/wadsrc/static/mapinfo/chex.txt +++ b/wadsrc/static/mapinfo/chex.txt @@ -68,6 +68,7 @@ gameinfo statscreen_finishedfont = "*BigFont" statscreen_enteringfont = "*BigFont" statscreen_contentfont = "*BigFont" + statscreen_authorFont = "*SmallFont", "gray" statscreen_coop = "CoopStatusScreen" statscreen_dm = "DeathmatchStatusScreen" statscreen_single = "DoomStatusScreen" diff --git a/wadsrc/static/mapinfo/doomcommon.txt b/wadsrc/static/mapinfo/doomcommon.txt index 018183c58..ca9722b56 100644 --- a/wadsrc/static/mapinfo/doomcommon.txt +++ b/wadsrc/static/mapinfo/doomcommon.txt @@ -68,6 +68,8 @@ gameinfo statscreen_finishedfont = "*BigFont", "red" statscreen_enteringfont = "*BigFont", "red" statscreen_contentfont = "*BigFont", "red" + statscreen_authorFont = "*SmallFont", "brick" + statscreen_coop = "CoopStatusScreen" statscreen_dm = "DeathmatchStatusScreen" statscreen_single = "DoomStatusScreen" diff --git a/wadsrc/static/mapinfo/heretic.txt b/wadsrc/static/mapinfo/heretic.txt index 63a636bc7..41c378ee1 100644 --- a/wadsrc/static/mapinfo/heretic.txt +++ b/wadsrc/static/mapinfo/heretic.txt @@ -67,6 +67,7 @@ gameinfo statscreen_finishedfont = "*SmallFont" statscreen_enteringfont = "*SmallFont" statscreen_contentfont = "*BigFont" + statscreen_authorFont = "*SmallFont" statscreen_coop = "CoopStatusScreen" statscreen_dm = "DeathmatchStatusScreen" statscreen_single = "RavenStatusScreen" diff --git a/wadsrc/static/mapinfo/hexen.txt b/wadsrc/static/mapinfo/hexen.txt index 9cb767726..2e9196075 100644 --- a/wadsrc/static/mapinfo/hexen.txt +++ b/wadsrc/static/mapinfo/hexen.txt @@ -65,6 +65,7 @@ gameinfo statscreen_finishedfont = "*SmallFont" statscreen_enteringfont = "*SmallFont" statscreen_contentfont = "*BigFont" + statscreen_authorFont = "*SmallFont" statscreen_coop = "CoopStatusScreen" statscreen_dm = "DeathmatchStatusScreen" statscreen_single = "RavenStatusScreen" diff --git a/wadsrc/static/mapinfo/mindefaults.txt b/wadsrc/static/mapinfo/mindefaults.txt index 4af996203..bfe370540 100644 --- a/wadsrc/static/mapinfo/mindefaults.txt +++ b/wadsrc/static/mapinfo/mindefaults.txt @@ -58,6 +58,7 @@ gameinfo statscreen_finishedfont = "*BigFont" statscreen_enteringfont = "*BigFont" statscreen_contentfont = "*BigFont" + statscreen_authorFont = "*SmallFont" messageboxclass = "MessageBoxMenu" } diff --git a/wadsrc/static/mapinfo/strife.txt b/wadsrc/static/mapinfo/strife.txt index 72cd8b9b2..75b7120fd 100644 --- a/wadsrc/static/mapinfo/strife.txt +++ b/wadsrc/static/mapinfo/strife.txt @@ -66,6 +66,7 @@ gameinfo statscreen_finishedfont = "*BigFont", "white" statscreen_enteringfont = "*BigFont", "white" statscreen_contentfont = "*BigFont" + statscreen_authorFont = "*SmallFont" statscreen_coop = "CoopStatusScreen" statscreen_dm = "DeathmatchStatusScreen" statscreen_single = "RavenStatusScreen" diff --git a/wadsrc/static/zscript/base.zs b/wadsrc/static/zscript/base.zs index 3b52b2730..0dc38f983 100644 --- a/wadsrc/static/zscript/base.zs +++ b/wadsrc/static/zscript/base.zs @@ -404,6 +404,7 @@ struct GameInfoStruct native native GIFont mStatscreenEnteringFont; native GIFont mStatscreenFinishedFont; native GIFont mStatscreenContentFont; + native GIFont mStatscreenAuthorFont; native double gibfactor; native bool intermissioncounter; native Name mSliderColor; @@ -685,6 +686,7 @@ struct LevelLocals native native String NextSecretMap; native readonly String F1Pic; native readonly int maptype; + native readonly String AuthorName; native readonly String Music; native readonly int musicorder; native readonly TextureID skytexture1; diff --git a/wadsrc/static/zscript/ui/statscreen/statscreen.zs b/wadsrc/static/zscript/ui/statscreen/statscreen.zs index 10160efc2..9bf2a8241 100644 --- a/wadsrc/static/zscript/ui/statscreen/statscreen.zs +++ b/wadsrc/static/zscript/ui/statscreen/statscreen.zs @@ -107,6 +107,7 @@ class StatusScreen abstract play version("2.5") PatchInfo finished; PatchInfo entering; PatchInfo content; + PatchInfo author; TextureID p_secret; TextureID kills; @@ -120,6 +121,7 @@ class StatusScreen abstract play version("2.5") // [RH] Info to dynamically generate the level name graphics String lnametexts[2]; + String authortexts[2]; bool snl_pointeron; @@ -181,6 +183,32 @@ class StatusScreen abstract play version("2.5") return 0; } + //==================================================================== + // + // Draws a level author's name with the big font + // + //==================================================================== + + int DrawAuthor(int y, String levelname) + { + if (levelname.Length() > 0) + { + int h = 0; + int lumph = author.mFont.GetHeight() * CleanYfac; + + BrokenLines lines = author.mFont.BreakLines(levelname, screen.GetWidth() / CleanXfac); + + int count = lines.Count(); + for (int i = 0; i < count; i++) + { + screen.DrawText(author.mFont, author.mColor, (screen.GetWidth() - lines.StringWidth(i) * CleanXfac) / 2, y + h, lines.StringAt(i), DTA_CleanNoMove, true); + h += lumph; + } + return y + h; + } + return 0; + } + //==================================================================== // // Only kept so that mods that were accessing it continue to compile @@ -261,6 +289,8 @@ class StatusScreen abstract play version("2.5") y += disp * CleanYfac; } + if (!ispatch) y = DrawAuthor(y, authortexts[0]); + // draw "Finished!" int statsy = multiplayer? NG_STATSY : SP_STATSY * CleanYFac; @@ -314,7 +344,10 @@ class StatusScreen abstract play version("2.5") y += disp * CleanYfac; } - DrawName(y, wbs.LName1, lnametexts[1]); + y = DrawName(y, wbs.LName1, lnametexts[1]); + ispatch = wbs.LName1.isValid(); + if (!ispatch) DrawAuthor(y, authortexts[1]); + } @@ -802,6 +835,7 @@ class StatusScreen abstract play version("2.5") finished.Init(gameinfo.mStatscreenFinishedFont); mapname.Init(gameinfo.mStatscreenMapNameFont); content.Init(gameinfo.mStatscreenContentFont); + author.Init(gameinfo.mStatscreenAuthorFont); Kills = TexMan.CheckForTexture("WIOSTK", TexMan.Type_MiscPatch); // "kills" Secret = TexMan.CheckForTexture("WIOSTS", TexMan.Type_MiscPatch); // "scrt", not used @@ -815,6 +849,8 @@ class StatusScreen abstract play version("2.5") lnametexts[0] = wbstartstruct.thisname; lnametexts[1] = wbstartstruct.nextname; + authortexts[0] = wbstartstruct.thisauthor; + authortexts[1] = wbstartstruct.nextauthor; bg = InterBackground.Create(wbs); noautostartmap = bg.LoadBackground(false); diff --git a/wadsrc/static/zscript/ui/statscreen/types.zs b/wadsrc/static/zscript/ui/statscreen/types.zs index 972a47b0c..24084ca73 100644 --- a/wadsrc/static/zscript/ui/statscreen/types.zs +++ b/wadsrc/static/zscript/ui/statscreen/types.zs @@ -24,6 +24,8 @@ struct WBStartStruct native version("2.4") native String next; // next level, [RH] actual map name native String nextname; // next level, printable name native String thisname; // this level, printable name + native String nextauthor; // next level, printable name + native String thisauthor; // this level, printable name native TextureID LName0; native TextureID LName1;