mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 06:53:40 +00:00
- allow retroactive substitution of cluster texts
This is needed to localize Harmony without swapping out the MAPINFO.
This commit is contained in:
parent
c788da46fb
commit
f1408bfb5b
3 changed files with 52 additions and 3 deletions
|
@ -765,12 +765,30 @@ void FMapInfoParser::ParseCluster()
|
|||
ParseAssign();
|
||||
if (ParseLookupName(clusterinfo->EnterText))
|
||||
clusterinfo->flags |= CLUSTER_LOOKUPENTERTEXT;
|
||||
else
|
||||
{
|
||||
FStringf testlabel("CLUSTERENTER%d", clusterinfo->cluster);
|
||||
if (GStrings.MatchDefaultString(testlabel, clusterinfo->EnterText))
|
||||
{
|
||||
clusterinfo->EnterText = testlabel;
|
||||
clusterinfo->flags |= CLUSTER_LOOKUPENTERTEXT;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sc.Compare("exittext"))
|
||||
{
|
||||
ParseAssign();
|
||||
if (ParseLookupName(clusterinfo->ExitText))
|
||||
clusterinfo->flags |= CLUSTER_LOOKUPEXITTEXT;
|
||||
else
|
||||
{
|
||||
FStringf testlabel("CLUSTEREXIT%d", clusterinfo->cluster);
|
||||
if (GStrings.MatchDefaultString(testlabel, clusterinfo->ExitText))
|
||||
{
|
||||
clusterinfo->ExitText = testlabel;
|
||||
clusterinfo->flags |= CLUSTER_LOOKUPEXITTEXT;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sc.Compare("music"))
|
||||
{
|
||||
|
@ -1933,8 +1951,8 @@ level_info_t *FMapInfoParser::ParseMapHeader(level_info_t &defaultinfo)
|
|||
// Workaround to allow localizazion of IWADs which do not have a string label here (e.g. HACX.WAD)
|
||||
// This checks for a string labelled with the MapName and if that is identical to what got parsed here
|
||||
// the string table entry will be used.
|
||||
auto c = GStrings.GetLanguageString(levelinfo->MapName, FStringTable::default_table);
|
||||
if (c && !strcmp(c, sc.String))
|
||||
|
||||
if (GStrings.MatchDefaultString(levelinfo->MapName, sc.String))
|
||||
{
|
||||
levelinfo->flags |= LEVEL_LOOKUPLEVELNAME;
|
||||
levelinfo->LevelName = levelinfo->MapName;
|
||||
|
|
|
@ -250,6 +250,10 @@ bool FStringTable::ParseLanguageCSV(const TArray<uint8_t> &buffer)
|
|||
{
|
||||
InsertString(langentry.second, strName, str);
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteString(langentry.second, strName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -372,6 +376,17 @@ void FStringTable::LoadLanguage (const TArray<uint8_t> &buffer)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FStringTable::DeleteString(int langid, FName label)
|
||||
{
|
||||
allStrings[langid].Remove(label);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FStringTable::InsertString(int langid, FName label, const FString &string)
|
||||
{
|
||||
const char *strlangid = (const char *)&langid;
|
||||
|
@ -386,7 +401,7 @@ void FStringTable::InsertString(int langid, FName label, const FString &string)
|
|||
break;
|
||||
}
|
||||
FString macroname(te.strings[0].GetChars() + index + 2, endindex - index - 2);
|
||||
FStringf lookupstr("%s/%s", strlangid, macroname.GetChars());
|
||||
FStringf lookupstr("%s/%s", strlangid, macroname.GetChars());
|
||||
FStringf replacee("@[%s]", macroname.GetChars());
|
||||
FName lookupname(lookupstr, true);
|
||||
auto replace = allMacros.CheckKey(lookupname);
|
||||
|
@ -550,6 +565,20 @@ const char *FStringTable::GetLanguageString(const char *name, uint32_t langtable
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool FStringTable::MatchDefaultString(const char *name, const char *content) const
|
||||
{
|
||||
// This only compares the first line to avoid problems with bad linefeeds. For the few cases where this feature is needed it is sufficient.
|
||||
auto c = GetLanguageString(name, FStringTable::default_table);
|
||||
if (!c) return false;
|
||||
|
||||
// Check a secondary key, in case the text comparison cannot be done due to needed orthographic fixes (see Harmony's exit text)
|
||||
FStringf checkkey("%s_CHECK", name);
|
||||
auto cc = GetLanguageString(checkkey, FStringTable::default_table);
|
||||
if (cc) c = cc;
|
||||
|
||||
return (c && !strnicmp(c, content, strcspn(content, "\n\r\t")));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Finds a string by name and returns its value. If the string does
|
||||
|
|
|
@ -89,6 +89,7 @@ public:
|
|||
}
|
||||
|
||||
const char *GetLanguageString(const char *name, uint32_t langtable, int gender = -1) const;
|
||||
bool MatchDefaultString(const char *name, const char *content) const;
|
||||
const char *GetString(const char *name, uint32_t *langtable, int gender = -1) const;
|
||||
const char *operator() (const char *name) const; // Never returns NULL
|
||||
const char *operator[] (const char *name) const
|
||||
|
@ -110,6 +111,7 @@ private:
|
|||
bool LoadLanguageFromSpreadsheet(int lumpnum, const TArray<uint8_t> &buffer);
|
||||
bool readMacros(int lumpnum);
|
||||
void InsertString(int langid, FName label, const FString &string);
|
||||
void DeleteString(int langid, FName label);
|
||||
|
||||
static size_t ProcessEscapes (char *str);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue