- 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.
This commit is contained in:
Christoph Oelckers 2019-02-23 10:40:07 +01:00
parent add10029b9
commit 2874a36fbe
5 changed files with 24 additions and 14 deletions

View file

@ -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")

View file

@ -119,6 +119,7 @@ struct gameinfo_t
bool swapmenu;
bool dontcrunchcorpses;
bool correctprintbold;
bool forcetextinmenus;
TArray<FName> creditPages;
TArray<FName> finalePages;
TArray<FName> infoPages;

View file

@ -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);

View file

@ -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<DListMenuDescriptor*>(*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<DListMenuDescriptor*>(*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;
}
}
}
}

View file

@ -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"