diff options
Diffstat (limited to '')
-rw-r--r-- | src/text/Messages.cpp | 33 | ||||
-rw-r--r-- | src/text/Text.cpp | 14 | ||||
-rw-r--r-- | src/text/Text.h | 3 |
3 files changed, 44 insertions, 6 deletions
diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp index 5abaa7ae..82ab294c 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -9,6 +9,8 @@ #include "ControllerConfig.h" +#include "Font.h" + tMessage CMessages::BriefMessages[NUMBRIEFMESSAGES]; tPreviousBrief CMessages::PreviousBriefs[NUMPREVIOUSBRIEFS]; tBigMessage CMessages::BIGMessages[NUMBIGMESSAGES]; @@ -50,6 +52,15 @@ CMessages::WideStringCopy(wchar *dst, wchar *src, uint16 size) dst[i] = '\0'; } +wchar FixupChar(wchar c) +{ +#ifdef MORE_LANGUAGES + if (CFont::IsJapanese()) + return c & 0x7fff; +#endif + return c; +} + bool CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size) { @@ -59,10 +70,10 @@ CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size) return false; for (int32 i = 0; i < size; i++) { - if (!str1[i]) + if (FixupChar(str1[i]) == '\0') break; - if (str1[i] != str2[i]) + if (FixupChar(str1[i]) != FixupChar(str2[i])) return false; } return true; @@ -368,7 +379,12 @@ CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32 int32 i = 0; for (int32 c = 0; c < size;) { +#ifdef MORE_LANGUAGES + if ((CFont::IsJapanese() && str[c] == (0x8000 | '~') && str[c + 1] == (0x8000 | '1') && str[c + 2] == (0x8000 | '~')) || + (!CFont::IsJapanese() && str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~')) { +#else if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') { +#endif switch (i) { case 0: sprintf(numStr, "%d", n1); break; case 1: sprintf(numStr, "%d", n2); break; @@ -406,7 +422,13 @@ CMessages::InsertStringInString(wchar *str1, wchar *str2) wchar *_str1 = str1; uint16 i; for (i = 0; i < total_size; ) { - if (*_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~') { +#ifdef MORE_LANGUAGES + if ((CFont::IsJapanese() && *_str1 == (0x8000 | '~') && *(_str1 + 1) == (0x8000 | 'a') && *(_str1 + 2) == (0x8000 | '~')) + || (*_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~')) + { +#else + if (*_str1 == '~' && *(_str1 + 1) == 'a' && *(_str1 + 2) == '~') { +#endif _str1 += 3; for (int j = 0; j < str2_size; j++) { tempstr[i++] = str2[j]; @@ -437,7 +459,12 @@ CMessages::InsertPlayerControlKeysInString(wchar *str) wchar *_outstr = outstr; for (i = 0; i < strSize;) { +#ifdef MORE_LANGUAGES + if ((CFont::IsJapanese() && str[i] == (0x8000 | '~') && str[i + 1] == (0x8000 | 'k') && str[i + 2] == (0x8000 | '~')) || + (!CFont::IsJapanese() && str[i] == '~' && str[i + 1] == 'k' && str[i + 2] == '~')) { +#else if (str[i] == '~' && str[i + 1] == 'k' && str[i + 2] == '~') { +#endif i += 4; for (int32 cont = 0; cont < MAX_CONTROLLERACTIONS; cont++) { uint16 contSize = GetWideStringLength(ControlsManager.m_aActionNames[cont]); diff --git a/src/text/Text.cpp b/src/text/Text.cpp index f481403d..549f68d9 100644 --- a/src/text/Text.cpp +++ b/src/text/Text.cpp @@ -1,6 +1,9 @@ #include "common.h" #include "FileMgr.h" +#ifdef MORE_LANGUAGES +#include "Game.h" +#endif #include "Frontend.h" #include "Messages.h" #include "Text.h" @@ -50,6 +53,9 @@ CText::Load(void) case LANGUAGE_RUSSIAN: sprintf(filename, "RUSSIAN.GXT"); break; + case LANGUAGE_JAPANESE: + sprintf(filename, "JAPANESE.GXT"); + break; #endif } @@ -257,7 +263,7 @@ CData::Unload(void) void AsciiToUnicode(const char *src, wchar *dst) { - while((*dst++ = *src++) != '\0'); + while((*dst++ = (unsigned char)*src++) != '\0'); } char* @@ -266,7 +272,11 @@ UnicodeToAscii(wchar *src) static char aStr[256]; int len; for(len = 0; *src != '\0' && len < 256-1; len++, src++) +#ifdef MORE_LANGUAGES + if(*src < 128 || ((CGame::russianGame || CGame::japaneseGame) && *src < 256)) +#else if(*src < 128) +#endif aStr[len] = *src; else aStr[len] = '#'; @@ -306,4 +316,4 @@ void TextCopy(wchar *dst, const wchar *src) { while((*dst++ = *src++) != '\0'); -} +}
\ No newline at end of file diff --git a/src/text/Text.h b/src/text/Text.h index 00d1c5e6..4255e2a5 100644 --- a/src/text/Text.h +++ b/src/text/Text.h @@ -12,8 +12,9 @@ struct CKeyEntry wchar *value; char key[8]; }; + // If this fails, CKeyArray::Load will have to be fixed -static_assert(sizeof(CKeyEntry) == 12, "CKeyEntry: error"); +VALIDATE_SIZE(CKeyEntry, 12); class CKeyArray { |