Backgrounds.xml can now be localized.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6560 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2013-11-05 19:06:29 +00:00
parent 26dfbe9b55
commit c55cb02a6a
3 changed files with 39 additions and 7 deletions
+20 -1
View File
@@ -1002,7 +1002,26 @@ BOOLEAN LoadExternalGameplayData(STR directoryName)
strcpy(fileName, directoryName);
strcat(fileName, BACKGROUNDSFILENAME);
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("LoadExternalGameplayData, fileName = %s", fileName));
SGP_THROW_IFFALSE(ReadInBackgrounds(fileName), BACKGROUNDSFILENAME);
SGP_THROW_IFFALSE(ReadInBackgrounds(fileName,FALSE), BACKGROUNDSFILENAME);
//Madd: Simple localization
// The idea here is that we can have a separate xml file that's named differently
// but only contains the relevant tags that need to be localized
// then when the file is read in using the same xml reader code, it will only overwrite
// the tags that are contained in the localized file. This only works for items.xml
// since I tweaked the xml_items.cpp to make it work :p
// So for instance, the german file would be called German.Items.xml and would only contain
// the uiIndex (for reference), szItemName, szLongItemName, szItemDesc, szBRName, and szBRDesc tags
#ifndef ENGLISH
AddLanguagePrefix(fileName);
if ( FileExists(fileName) )
{
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("LoadExternalGameplayData, fileName = %s", fileName));
SGP_THROW_IFFALSE(ReadInBackgrounds(fileName,TRUE), BACKGROUNDSFILENAME);
}
#endif
//////////////////
// IMP Portraits List by Jazz
strcpy(fileName, directoryName);
+1 -1
View File
@@ -465,7 +465,7 @@ extern BOOLEAN ReadInIMPPortraits(STR fileName, BOOLEAN localizedVersion);
extern void LoadIMPPortraitsTEMP();
// Flugente: backgrounds
extern BOOLEAN ReadInBackgrounds(STR fileName );
extern BOOLEAN ReadInBackgrounds(STR fileName, BOOLEAN localizedVersion );
extern BOOLEAN WriteBackgrounds( STR fileName);
//Enabled\Disabled profile sound by Jazz
+18 -5
View File
@@ -24,6 +24,8 @@ struct
}
typedef enemyRankParseData;
BOOLEAN localizedTextOnly_BG;
UINT16 num_found_background = 0; // the correct number is set on reading the xml
#define XML_BACKGROUND_AP_MAX 8
@@ -43,7 +45,8 @@ backgroundStartElementHandle(void *userData, const XML_Char *name, const XML_Cha
{
pData->curElement = ELEMENT_LIST;
memset(pData->curArray,0,sizeof(BACKGROUND_VALUES)*pData->maxArraySize);
if ( !localizedTextOnly_BG )
memset(pData->curArray,0,sizeof(BACKGROUND_VALUES)*pData->maxArraySize);
pData->maxReadDepth++; //we are not skipping this element
}
@@ -51,7 +54,8 @@ backgroundStartElementHandle(void *userData, const XML_Char *name, const XML_Cha
{
pData->curElement = ELEMENT;
memset(&pData->curBackground,0,sizeof(BACKGROUND_VALUES));
if ( !localizedTextOnly_BG )
memset(&pData->curBackground,0,sizeof(BACKGROUND_VALUES));
pData->maxReadDepth++; //we are not skipping this element
}
@@ -168,10 +172,17 @@ backgroundEndElementHandle(void *userData, const XML_Char *name)
if(pData->curBackground.uiIndex < pData->maxArraySize)
{
pData->curArray[pData->curBackground.uiIndex] = pData->curBackground;
if ( localizedTextOnly_BG )
{
wcscpy(pData->curArray[pData->curBackground.uiIndex].szName,pData->curBackground.szName);
wcscpy(pData->curArray[pData->curBackground.uiIndex].szShortName,pData->curBackground.szShortName);
wcscpy(pData->curArray[pData->curBackground.uiIndex].szDescription,pData->curBackground.szDescription);
}
else
pData->curArray[pData->curBackground.uiIndex] = pData->curBackground;
}
num_found_background = pData->curBackground.uiIndex;
num_found_background = pData->curBackground.uiIndex;
}
else if(strcmp(name, "uiIndex") == 0)
{
@@ -540,7 +551,7 @@ backgroundEndElementHandle(void *userData, const XML_Char *name)
pData->currentDepth--;
}
BOOLEAN ReadInBackgrounds(STR fileName)
BOOLEAN ReadInBackgrounds(STR fileName, BOOLEAN localizedVersion)
{
HWFILE hFile;
UINT32 uiBytesRead;
@@ -551,6 +562,8 @@ BOOLEAN ReadInBackgrounds(STR fileName)
enemyRankParseData pData;
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading Backgrounds.xml" );
localizedTextOnly_BG = localizedVersion;
// Open file
hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );