void C4Language::LoadInfos(C4Group &hGroup) { char strEntry[_MAX_FNAME + 1]; char *strTable; // Look for language string tables hGroup.ResetSearch(); while (hGroup.FindNextEntry(C4CFN_Language, strEntry)) // For now, we will only load info on the first string table found for a given // language code as there is currently no handling for selecting different string tables // of the same code - the system always loads the first string table found for a given code if (!FindInfo(GetFilenameOnly(strEntry) + SLen(GetFilenameOnly(strEntry)) - 2)) // Load language string table if (hGroup.LoadEntry(strEntry, &strTable, 0, 1)) { // New language info C4LanguageInfo *pInfo = new C4LanguageInfo; // Get language code by entry name SCopy(GetFilenameOnly(strEntry) + SLen(GetFilenameOnly(strEntry)) - 2, pInfo->Code, 2); SCapitalize(pInfo->Code); // Get language name, info, fallback from table CopyResStr("IDS_LANG_NAME", strTable, pInfo->Name); CopyResStr("IDS_LANG_INFO", strTable, pInfo->Info); CopyResStr("IDS_LANG_FALLBACK", strTable, pInfo->Fallback); // Safety: pipe character is not allowed in any language info string SReplaceChar(pInfo->Name, '|', ' '); SReplaceChar(pInfo->Info, '|', ' '); SReplaceChar(pInfo->Fallback, '|', ' '); // Delete table delete [] strTable; // Add info to list pInfo->Next = Infos; Infos = pInfo; } }
C4GUI::Edit::InputResult C4ChatInputDialog::OnChatInput(C4GUI::Edit *edt, bool fPasting, bool fPastingMore) { // no double processing if (fProcessed) return C4GUI::Edit::IR_CloseDlg; // get edit text C4GUI::Edit *pEdt = reinterpret_cast<C4GUI::Edit *>(edt); char *szInputText = const_cast<char *>(pEdt->GetText()); // Store to back buffer Game.MessageInput.StoreBackBuffer(szInputText); // script queried input? if (fObjInput) { fProcessed = true; // check if the target input is still valid C4Player *pPlr = Game.Players.Get(iPlr); if (!pPlr) return C4GUI::Edit::IR_CloseDlg; if (!pPlr->MarkMessageBoardQueryAnswered(pTarget)) { // there was no associated query! return C4GUI::Edit::IR_CloseDlg; } // then do a script callback, incorporating the input into the answer if (fUppercase) SCapitalize(szInputText); StdStrBuf sInput; sInput.Copy(szInputText); sInput.EscapeString(); Game.Control.DoInput( CID_Script, new C4ControlScript( FormatString("OnMessageBoardAnswer(Object(%d), %d, \"%s\")", pTarget ? pTarget->Number : 0, iPlr, sInput.getData()).getData()), CDT_Decide); return C4GUI::Edit::IR_CloseDlg; } else // reroute to message input class Game.MessageInput.ProcessInput(szInputText); // safety: message board commands may do strange things if (!C4GUI::IsGUIValid() || this != pInstance) return C4GUI::Edit::IR_Abort; // select all text to be removed with next keypress // just for pasting mode; usually the dlg will be closed now anyway pEdt->SelectAll(); // avoid dlg close, if more content is to be pasted if (fPastingMore) return C4GUI::Edit::IR_None; fProcessed = true; return C4GUI::Edit::IR_CloseDlg; }