From 2874a36fbe844e1f7ca244227b2a0663465889ba Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 23 Feb 2019 10:40:07 +0100 Subject: [PATCH] - added the final missing piece of localization support, i.e. forcing text based menus. Now a localization mod can disable the graphics patches containing text entirely so that it can properly localize the text based menu variant. If this flag gets set in MAPINFO, it will override all user settings. --- src/gamedata/gi.cpp | 1 + src/gamedata/gi.h | 1 + src/gamedata/textures/texturemanager.cpp | 2 +- src/menu/menu.cpp | 31 +++++++++++++++--------- wadsrc/static/menudef.txt | 3 ++- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/gamedata/gi.cpp b/src/gamedata/gi.cpp index 07a46147e..ebced3c7c 100644 --- a/src/gamedata/gi.cpp +++ b/src/gamedata/gi.cpp @@ -396,6 +396,7 @@ void FMapInfoParser::ParseGameInfo() GAMEINFOKEY_BOOL(swapmenu, "swapmenu") GAMEINFOKEY_BOOL(dontcrunchcorpses, "dontcrunchcorpses") GAMEINFOKEY_BOOL(correctprintbold, "correctprintbold") + GAMEINFOKEY_BOOL(forcetextinmenus, "forcetextinmenus") GAMEINFOKEY_BOOL(intermissioncounter, "intermissioncounter") GAMEINFOKEY_BOOL(nightmarefast, "nightmarefast") GAMEINFOKEY_COLOR(dimcolor, "dimcolor") diff --git a/src/gamedata/gi.h b/src/gamedata/gi.h index 4f27a6969..c9ffa40f8 100644 --- a/src/gamedata/gi.h +++ b/src/gamedata/gi.h @@ -119,6 +119,7 @@ struct gameinfo_t bool swapmenu; bool dontcrunchcorpses; bool correctprintbold; + bool forcetextinmenus; TArray creditPages; TArray finalePages; TArray infoPages; diff --git a/src/gamedata/textures/texturemanager.cpp b/src/gamedata/textures/texturemanager.cpp index 5f8465eea..ff451dd17 100644 --- a/src/gamedata/textures/texturemanager.cpp +++ b/src/gamedata/textures/texturemanager.cpp @@ -421,8 +421,8 @@ bool FTextureManager::OkForLocalization(FTextureID texnum, const char *substitut if (!texnum.isValid()) return false; // First the unconditional settings, 0='never' and 1='always'. + if (cl_localizationmode == 1 || gameinfo.forcetextinmenus) return false; if (cl_localizationmode == 0) return true; - if (cl_localizationmode == 1) return false; uint32_t langtable = 0; if (*substitute == '$') substitute = GStrings.GetString(substitute+1, &langtable); diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 7106443d0..03b66986d 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -414,23 +414,30 @@ void M_SetMenu(FName menu, int param) switch (menu) { case NAME_Mainmenu: - if (gameinfo.gametype & GAME_DoomStrifeChex) + if (gameinfo.gametype & GAME_DoomStrifeChex) // Raven's games always used text based menus { - // For these games we must check up-front if they get localized because in that case another template must be used. - DMenuDescriptor **desc = MenuDescriptors.CheckKey(NAME_Playerclassmenu); - if (desc != nullptr) + if (gameinfo.forcetextinmenus) // If text is forced, this overrides any check. { - if ((*desc)->IsKindOf(RUNTIME_CLASS(DListMenuDescriptor))) + menu = NAME_MainmenuTextOnly; + } + else + { + // For these games we must check up-front if they get localized because in that case another template must be used. + DMenuDescriptor **desc = MenuDescriptors.CheckKey(NAME_Mainmenu); + if (desc != nullptr) { - DListMenuDescriptor *ld = static_cast(*desc); - if (ld->mFromEngine && cl_localizationmode != 0) + if ((*desc)->IsKindOf(RUNTIME_CLASS(DListMenuDescriptor))) { - // This assumes that replacing one graphic will replace all of them. - // So this only checks the "New game" entry for localization capability. - FTextureID texid = TexMan.CheckForTexture("M_NGAME", ETextureType::MiscPatch); - if (!TexMan.OkForLocalization(texid, "$MNU_NEWGAME")) + DListMenuDescriptor *ld = static_cast(*desc); + if (ld->mFromEngine && cl_localizationmode != 0) { - menu = NAME_MainmenuTextOnly; + // This assumes that replacing one graphic will replace all of them. + // So this only checks the "New game" entry for localization capability. + FTextureID texid = TexMan.CheckForTexture("M_NGAME", ETextureType::MiscPatch); + if (!TexMan.OkForLocalization(texid, "$MNU_NEWGAME")) + { + menu = NAME_MainmenuTextOnly; + } } } } diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 389f9a54a..1f073bf72 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -128,7 +128,8 @@ LISTMENU "MainMenuTextOnly" TextItem "$MNU_NEWGAME", "n", "PlayerclassMenu" TextItem "$MNU_OPTIONS", "o", "OptionsMenu" - TextItem "$MNU_GAMEFILES", "g", "GameFilesMenu" + TextItem "$MNU_LOADGAME", "l", "LoadGameMenu" + TextItem "$MNU_SAVEGAME", "s", "SaveGameMenu" IfOption(ReadThis) { TextItem "$MNU_INFO", "i", "ReadThisMenu"