- allow the language table to supersede the title patches, if appropriate

For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.

This also required removing the 'en' label from the default table,  because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.

Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
This commit is contained in:
Christoph Oelckers 2019-02-15 00:29:24 +01:00
commit aa550310f6
20 changed files with 114 additions and 58 deletions

View file

@ -83,11 +83,11 @@ void FStringTable::LoadLanguage (int lumpnum)
}
if (len == 1 && sc.String[0] == '*')
{
activeMaps.Push(MAKE_ID('*', 0, 0, 0));
activeMaps.Push(global_table);
}
else if (len == 7 && stricmp (sc.String, "default") == 0)
{
activeMaps.Push(MAKE_ID('*', '*', 0, 0));
activeMaps.Push(default_table);
}
else
{
@ -167,18 +167,18 @@ void FStringTable::UpdateLanguage()
auto checkone = [&](uint32_t lang_id)
{
auto list = allStrings.CheckKey(lang_id);
if (list && currentLanguageSet.Find(list) == currentLanguageSet.Size())
currentLanguageSet.Push(list);
if (list && currentLanguageSet.FindEx([&](const auto &element) { return element.first == lang_id; }) == currentLanguageSet.Size())
currentLanguageSet.Push(std::make_pair(lang_id, list));
};
checkone(MAKE_ID('*', '*', '*', 0));
checkone(MAKE_ID('*', 0, 0, 0));
checkone(dehacked_table);
checkone(global_table);
for (int i = 0; i < 4; ++i)
{
checkone(LanguageIDs[i]);
checkone(LanguageIDs[i] & MAKE_ID(0xff, 0xff, 0, 0));
}
checkone(MAKE_ID('*', '*', 0, 0));
checkone(default_table);
}
// Replace \ escape sequences in a string with the escaped characters.
@ -219,7 +219,7 @@ bool FStringTable::exists(const char *name)
FName nm(name, true);
if (nm != NAME_None)
{
uint32_t defaultStrings[] = { MAKE_ID('*', '*', '*', 0), MAKE_ID('*', 0, 0, 0), MAKE_ID('*', '*', 0, 0) };
uint32_t defaultStrings[] = { default_table, global_table, dehacked_table };
for (auto mapid : defaultStrings)
{
@ -235,7 +235,7 @@ bool FStringTable::exists(const char *name)
}
// Finds a string by name and returns its value
const char *FStringTable::operator[] (const char *name) const
const char *FStringTable::GetString(const char *name, uint32_t *langtable) const
{
if (name == nullptr || *name == 0)
{
@ -246,8 +246,12 @@ const char *FStringTable::operator[] (const char *name) const
{
for (auto map : currentLanguageSet)
{
auto item = map->CheckKey(nm);
if (item) return item->GetChars();
auto item = map.second->CheckKey(nm);
if (item)
{
if (langtable) *langtable = map.first;
return item->GetChars();
}
}
}
return nullptr;