diff options
Diffstat (limited to 'src/text')
-rw-r--r-- | src/text/Messages.cpp | 85 | ||||
-rw-r--r-- | src/text/Messages.h | 2 | ||||
-rw-r--r-- | src/text/Text.cpp | 13 | ||||
-rw-r--r-- | src/text/Text.h | 16 |
4 files changed, 107 insertions, 9 deletions
diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp index 81339ae0..f55e6bd7 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -11,6 +11,8 @@ #include "Font.h" +#include "Pad.h" + tMessage CMessages::BriefMessages[NUMBRIEFMESSAGES]; tPreviousBrief CMessages::PreviousBriefs[NUMPREVIOUSBRIEFS]; tBigMessage CMessages::BIGMessages[NUMBIGMESSAGES]; @@ -441,6 +443,64 @@ CMessages::InsertStringInString(wchar *str1, wchar *str2) str1[i++] = '\0'; } +int +CMessages::GetTokenPadKeyString(const wchar *in, wchar *out) +{ + wchar str[256]; + memset(str, 0, sizeof(str)); + str[0] = 'C'; + + // TODO: there was a switch here but that's stupid + str[1] = CPad::GetPad(0)->Mode + 48; + + while (*in != '~') in++; + in++; + + int i = 1; + while (*in != '~') + str[1+i++] = *(in++); + + wchar *text = TheText.Get(UnicodeToAscii(str)); + if (!text) return i; + while (text[0] != '\0') + { + if (text[0] == '~') + { + switch (text[1]) + { + case 'L': + *(out++) = 'M'; + break; + case 'N': + *(out++) = 'O'; + break; + case 'O': + *(out++) = 227; + break; + case 'R': + *(out++) = 'S'; + break; + case 'S': + *(out++) = 225; + break; + case 'T': + *(out++) = 224; + break; + case 'X': + *(out++) = 226; + break; + default: + break; + } + text += 3; + } + else { + *(out++) = *(text++); + } + } + return i; +} + void CMessages::InsertPlayerControlKeysInString(wchar *str) { @@ -450,7 +510,7 @@ CMessages::InsertPlayerControlKeysInString(wchar *str) if (!str) return; uint16 strSize = GetWideStringLength(str); - memset(keybuf, 0, 256*sizeof(wchar)); + memset(keybuf, 0, 256*sizeof(wchar)); // not memset? :O wchar *_outstr = outstr; for (i = 0; i < strSize;) { @@ -460,9 +520,16 @@ CMessages::InsertPlayerControlKeysInString(wchar *str) #else if (str[i] == '~' && str[i + 1] == 'k' && str[i + 2] == '~') { #endif + memset(keybuf, 0, 256 * sizeof(wchar)); i += 4; - bool done = false; - for (int32 cont = 0; cont < MAX_CONTROLLERACTIONS && !done; cont++) { + i += GetTokenPadKeyString(&str[i], keybuf) + 1; + uint16 keybuf_size = GetWideStringLength(keybuf); + for (uint16 j = 0; j < keybuf_size; j++) { + *(_outstr++) = keybuf[j]; + keybuf[j] = '\0'; + } + + /*for (int32 cont = 0; cont < MAX_CONTROLLERACTIONS && !done; cont++) { uint16 contSize = GetWideStringLength(ControlsManager.m_aActionNames[cont]); if (contSize != 0) { if (WideStringCompare(&str[i], ControlsManager.m_aActionNames[cont], contSize)) { @@ -476,7 +543,7 @@ CMessages::InsertPlayerControlKeysInString(wchar *str) i += contSize + 1; } } - } + }*/ } else { *(_outstr++) = str[i++]; } @@ -813,3 +880,13 @@ CMessages::ClearAllMessagesDisplayedByGame() CHud::GetRidOfAllHudMessages(); CUserDisplay::Pager.ClearMessages(); } + +void +CMessages::ClearThisBigPrintNow(uint32 id) +{ + if (BIGMessages[id].m_Stack[0].m_pText) + ClearThisBigPrint(BIGMessages[id].m_Stack[0].m_pText); + CHud::m_BigMessage[id][0] = '\0'; + BigMessageInUse[id] = 0.0f; +} + diff --git a/src/text/Messages.h b/src/text/Messages.h index e8ba1bf7..51112908 100644 --- a/src/text/Messages.h +++ b/src/text/Messages.h @@ -61,6 +61,8 @@ public: static void ClearThisPrint(wchar *str); static void ClearThisBigPrint(wchar *str); static void ClearAllMessagesDisplayedByGame(void); + static void ClearThisBigPrintNow(uint32 id); + static int GetTokenPadKeyString(const wchar *in, wchar *out); // unused or cut //static void AddMessageSoonWithString(wchar*, uint32, uint16, wchar*); diff --git a/src/text/Text.cpp b/src/text/Text.cpp index 1369d1db..e387fe01 100644 --- a/src/text/Text.cpp +++ b/src/text/Text.cpp @@ -11,7 +11,7 @@ wchar WideErrorString[25]; -CText TheText; +CText *CText::msInstance = nil; CText::CText(void) { @@ -39,7 +39,7 @@ CText::Load(void) CFileMgr::SetDir("TEXT"); switch(FrontEndMenuManager.m_PrefsLanguage){ case CMenuManager::LANGUAGE_AMERICAN: - sprintf(filename, "AMERICAN.GXT"); + sprintf(filename, "ENGLISH.GXT"); break; case CMenuManager::LANGUAGE_FRENCH: sprintf(filename, "FRENCH.GXT"); @@ -91,11 +91,13 @@ CText::Load(void) keyArray.Update(data.chars); CFileMgr::CloseFile(file); CFileMgr::SetDir(""); + bIsLoaded = true; } void CText::Unload(void) { + bIsLoaded = false; CMessages::ClearAllMessagesDisplayedByGame(); keyArray.Unload(); data.Unload(); @@ -243,7 +245,7 @@ CText::LoadMissionText(char *MissionTableName) CFileMgr::SetDir("TEXT"); switch (FrontEndMenuManager.m_PrefsLanguage) { case CMenuManager::LANGUAGE_AMERICAN: - sprintf(filename, "AMERICAN.GXT"); + sprintf(filename, "ENGLISH.GXT"); break; case CMenuManager::LANGUAGE_FRENCH: sprintf(filename, "FRENCH.GXT"); @@ -305,6 +307,11 @@ CText::LoadMissionText(char *MissionTableName) bIsMissionTextLoaded = true; } +bool +CText::IsLoaded() +{ + return bIsLoaded; +} void CKeyArray::Load(size_t length, int file, size_t* offset) diff --git a/src/text/Text.h b/src/text/Text.h index 1174216c..05387346 100644 --- a/src/text/Text.h +++ b/src/text/Text.h @@ -58,7 +58,7 @@ public: uint32 offset; }; - enum {MAX_MISSION_TEXTS = 90}; // beware that LCS has more + enum {MAX_MISSION_TEXTS = 200}; Entry data[MAX_MISSION_TEXTS]; uint16 size; // You can make this size_t if you want to exceed 32-bit boundaries, everything else should be ready. @@ -84,6 +84,9 @@ class CText bool bIsMissionTextLoaded; char szMissionTableName[8]; CMissionTextOffsets MissionTextOffsets; + bool bIsLoaded; + + static CText *msInstance; public: CText(void); void Load(void); @@ -94,6 +97,15 @@ public: void GetNameOfLoadedMissionText(char *outName); void ReadChunkHeader(ChunkHeader *buf, int32 file, size_t *bytes_read); void LoadMissionText(char *MissionTableName); + bool IsLoaded(); + void GetUTF8(const char*, char*, int); // TODO but unused + + static CText &Instance() + { + if (!msInstance) + msInstance = new CText; + return *msInstance; + } }; -extern CText TheText; +#define TheText CText::Instance() |