From ecabc00ec5338da1569f552a089dab194b610243 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 08:40:06 +0800 Subject: [PATCH] UTF-8 various, ryzom/ryzomcore#335 --- ryzom/client/src/init.cpp | 16 ++++++------- .../interface_v3/group_in_scene_user_info.cpp | 12 +++++----- ryzom/client/src/interface_v3/group_map.cpp | 10 ++++---- ryzom/client/src/progress.cpp | 24 +++++++++---------- ryzom/client/src/r2/auto_group.cpp | 6 ++--- ryzom/client/src/r2/editor.cpp | 6 ++--- ryzom/client/src/r2/tool_draw_prim.cpp | 6 ++--- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/ryzom/client/src/init.cpp b/ryzom/client/src/init.cpp index ebb713a73..41c924baf 100644 --- a/ryzom/client/src/init.cpp +++ b/ryzom/client/src/init.cpp @@ -168,7 +168,7 @@ extern NLMISC::CCmdArgs Args; // Tips of the day count #define RZ_NUM_TIPS 17 -ucstring TipsOfTheDay; +std::string TipsOfTheDay; uint TipsOfTheDayIndex; // includes for following register classes @@ -272,19 +272,19 @@ static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARA { if (CI18N::hasTranslation("TheSagaOfRyzom")) { - if (!SetWindowTextW(hwndDlg, (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str ())) + if (!SetWindowTextW(hwndDlg, nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()))) { nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str()); } } - SetDlgItemTextW(hwndDlg, IDC_ERROR_MSG_TEXT, (WCHAR*) CurrentErrorMessage.c_str ()); + SetDlgItemTextW(hwndDlg, IDC_ERROR_MSG_TEXT, (WCHAR*)CurrentErrorMessage.c_str()); if (CI18N::hasTranslation("uiRyzomErrorMsgBoxExit")) { - SetDlgItemTextW(hwndDlg, IDOK, (WCHAR*)CI18N::get ("uiRyzomErrorMsgBoxExit").c_str ()); + SetDlgItemTextW(hwndDlg, IDOK, nlUtf8ToWide(CI18N::get("uiRyzomErrorMsgBoxExit").c_str())); } if (CI18N::hasTranslation("uiRyzomErrorMsgBoxHelp")) { - SetDlgItemTextW(hwndDlg, IDC_RYZOM_ERROR_HELP, (WCHAR*)CI18N::get ("uiRyzomErrorMsgBoxHelp").c_str ()); + SetDlgItemTextW(hwndDlg, IDC_RYZOM_ERROR_HELP, nlUtf8ToWide(CI18N::get("uiRyzomErrorMsgBoxHelp").c_str())); } RECT rect; RECT rectDesktop; @@ -343,7 +343,7 @@ void ExitClientError (const char *format, ...) /* ucstring ucstr; ucstr.fromUtf8 (str); - MessageBoxW (NULL, (WCHAR*)ucstr.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_OK|MB_ICONERROR); + MessageBoxW (NULL, (WCHAR *)ucstr.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONERROR); */ #else fprintf (stderr, "%s\n", str); @@ -360,7 +360,7 @@ void ExitClientError (const char *format, ...) void ClientInfo (const ucstring &message) { #ifdef NL_OS_WINDOWS - MessageBoxW (NULL, (WCHAR*)message.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_OK|MB_ICONINFORMATION); + MessageBoxW(NULL, (WCHAR *)message.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONINFORMATION); #endif } @@ -368,7 +368,7 @@ void ClientInfo (const ucstring &message) bool ClientQuestion (const ucstring &message) { #ifdef NL_OS_WINDOWS - return MessageBoxW (NULL, (WCHAR*)message.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_YESNO|MB_ICONQUESTION) != IDNO; + return MessageBoxW(NULL, (WCHAR *)message.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_YESNO|MB_ICONQUESTION) != IDNO; #else return false; #endif diff --git a/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index fa88db43e..c5dc116e3 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -200,9 +200,9 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) // Names const char *templateName; - ucstring theTribeName; - ucstring entityName = entity->getDisplayName(); - ucstring entityTitle = entity->getTitle(); + const char *theTribeName = ""; + std::string entityName = entity->getDisplayName(); + std::string entityTitle = entity->getTitle().toUtf8(); // For some NPC's the name is empty and only a title is given, // in that case, treat the title as the name. @@ -780,19 +780,19 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) // Set player name if (info->_Name) { - info->_Name->setText(entityName.toUtf8()); + info->_Name->setText(entityName); info->_Name->setModulateGlobalColor(false); } // Set player title if (info->_Title) - info->_Title->setText(entityTitle.toUtf8()); + info->_Title->setText(entityTitle); // Set tribe name if (info->_TribeName) { nlassert(info->_GuildName == NULL); - info->_TribeName->setText(theTribeName.toUtf8()); + info->_TribeName->setText(theTribeName); } // Init user leaf nodes diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp index 7725d45f9..b5302885e 100644 --- a/ryzom/client/src/interface_v3/group_map.cpp +++ b/ryzom/client/src/interface_v3/group_map.cpp @@ -2530,19 +2530,19 @@ void CGroupMap::createLMWidgets(const std::vector &lms) NLMISC::CVector2f mapPos; worldToMap(mapPos, rCLM.Pos); - const ucstring ucsTmp(CStringManagerClient::getPlaceLocalizedName(rCLM.TitleTextID)); - const ucstring lcTitle = toLower(ucsTmp); + const char *ucsTmp = CStringManagerClient::getPlaceLocalizedName(rCLM.TitleTextID); + const std::string lcTitle = toLower(ucsTmp); bool searchMatch = notWorldMode && _LandmarkFilter.size() > 0 && filterLandmark(lcTitle); if (searchMatch) - _MatchedLandmarks.push_back(SMatchedLandmark(rCLM.Pos, ucsTmp, _ContinentLMOptions)); + _MatchedLandmarks.push_back(SMatchedLandmark(rCLM.Pos, ucstring::makeFromUtf8(ucsTmp), _ContinentLMOptions)); // Add button if not a region nor a place if ((rCLM.Type != CContLandMark::Region) && (rCLM.Type != CContLandMark::Place) && (rCLM.Type != CContLandMark::Street)) { if (rCLM.Type != CContLandMark::Stable) - addLandMark(_ContinentLM, mapPos, ucsTmp, _ContinentLMOptions); + addLandMark(_ContinentLM, mapPos, ucstring::makeFromUtf8(ucsTmp), _ContinentLMOptions); else addLandMark(_ContinentLM, mapPos, CI18N::get("uiStable"), _ContinentLMOptions); _ContinentLM.back()->Type = rCLM.Type; @@ -2551,7 +2551,7 @@ void CGroupMap::createLMWidgets(const std::vector &lms) else // just add a text { CLandMarkText *pNewText = new CLandMarkText(CViewBase::TCtorParam()); - pNewText->setText(ucsTmp.toUtf8()); + pNewText->setText(ucsTmp); pNewText->Pos = mapPos; pNewText->setParent(this); pNewText->setParentPosRef(Hotspot_BL); diff --git a/ryzom/client/src/progress.cpp b/ryzom/client/src/progress.cpp index e75b4a984..c27e285e1 100644 --- a/ryzom/client/src/progress.cpp +++ b/ryzom/client/src/progress.cpp @@ -50,7 +50,7 @@ extern NL3D::UMaterial LoadingMaterialFull; extern std::vector LogoBitmaps; extern uint TipsOfTheDayIndex; -extern ucstring TipsOfTheDay; +extern string TipsOfTheDay; extern bool UseEscapeDuringLoading; CProgress::CProgress () @@ -287,8 +287,8 @@ void CProgress::internalProgress (float value) // Display the tips of the day. TextContext->setFontSize((uint)(16.f * fontFactor)); TextContext->setHotSpot(UTextContext::MiddleTop); - ucstring::size_type index = 0; - ucstring::size_type end = TipsOfTheDay.find((ucchar)'\n'); + string::size_type index = 0; + string::size_type end = TipsOfTheDay.find('\n'); if (end == string::npos) end = TipsOfTheDay.size(); float fY = ClientCfg.TipsY; @@ -297,15 +297,15 @@ void CProgress::internalProgress (float value) while (index < end) { // Get the line - ucstring line = TipsOfTheDay.substr (index, end-index); + string line = TipsOfTheDay.substr (index, end-index); // Draw the line TextContext->printAt(0.5f, fY, line); fY = nextLine (TextContext->getFontSize(), Driver->getWindowHeight(), fY); index=end+1; - end = TipsOfTheDay.find((ucchar)'\n', index); - if (end == ucstring::npos) + end = TipsOfTheDay.find('\n', index); + if (end == string::npos) end = TipsOfTheDay.size(); } @@ -338,7 +338,7 @@ void CProgress::internalProgress (float value) TextContext->setFontSize((uint)(15.f * fontFactor)); TextContext->setHotSpot(UTextContext::BottomLeft); - ucstring uc = CI18N::get("uiR2EDTPEscapeToInteruptLoading") + " (" + _TPCancelText + ") - " + CI18N::get("uiDelayedTPCancel"); + string uc = CI18N::get("uiR2EDTPEscapeToInteruptLoading") + " (" + _TPCancelText.toUtf8() + ") - " + CI18N::get("uiDelayedTPCancel"); UTextContext::CStringInfo info = TextContext->getStringInfo(uc); float stringX = 0.5f - info.StringWidth/(ClientCfg.Width*2); TextContext->printAt(stringX, 7.f / ClientCfg.Height, uc); @@ -386,13 +386,13 @@ void CProgress::internalProgress (float value) TextContext->setFontSize( (uint)(16.f * fontFactor)); // build the ucstr(s) - ucstring ucstr = CI18N::get((*itpc).Text); - vector vucstr; - ucstring sep("\n"); - splitUCString(ucstr,sep,vucstr); + string ucstr = CI18N::get((*itpc).Text); + vector vucstr; + string sep("\n"); + splitString(ucstr,sep,vucstr); // Letter size - UTextContext::CStringInfo si = TextContext->getStringInfo(ucstring("|")); + UTextContext::CStringInfo si = TextContext->getStringInfo("|"); uint fontHeight = (uint) si.StringHeight + 2; // we add 2 pixels for the gap uint i; diff --git a/ryzom/client/src/r2/auto_group.cpp b/ryzom/client/src/r2/auto_group.cpp index ee269376c..7da977b3d 100644 --- a/ryzom/client/src/r2/auto_group.cpp +++ b/ryzom/client/src/r2/auto_group.cpp @@ -279,12 +279,12 @@ void CAutoGroup::group(CObject *newEntityDesc, const NLMISC::CVectorD &createPos getEditor().getDMC().flushActions(); return; } - ucstring readableName; + string readableName; CLuaState &ls = getEditor().getLua(); R2::getEditor().getEnv()["PaletteIdToGroupTranslation"][newEntityDesc->getAttr("Base")->toString()].push(); if (ls.isString(-1)) - readableName.fromUtf8(ls.toString(-1)); - ucstring ucGroupName = ucstring(readableName + " " + CI18N::get("uiR2EDNameGroup")); + readableName = ls.toString(-1); + string ucGroupName = readableName + " " + CI18N::get("uiR2EDNameGroup"); newGroup->set("Name", getEditor().genInstanceName(ucGroupName).toUtf8()); getEditor().getDMC().requestInsertNode(destGroup->getParentAct()->getId(), diff --git a/ryzom/client/src/r2/editor.cpp b/ryzom/client/src/r2/editor.cpp index 3628dfe93..c9b47e6a3 100644 --- a/ryzom/client/src/r2/editor.cpp +++ b/ryzom/client/src/r2/editor.cpp @@ -1571,12 +1571,12 @@ int CEditor::luaGetUserEntityName(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 1); // this is a method if (UserEntity) { - ucstring name = UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis; - ls.push( name.toUtf8() ); + string name = UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis; + ls.push( name ); } else { - ls.push(std::string("")); + ls.push(std::string()); } return 1; diff --git a/ryzom/client/src/r2/tool_draw_prim.cpp b/ryzom/client/src/r2/tool_draw_prim.cpp index c32682626..7ec119e29 100644 --- a/ryzom/client/src/r2/tool_draw_prim.cpp +++ b/ryzom/client/src/r2/tool_draw_prim.cpp @@ -551,9 +551,9 @@ void CToolDrawPrim::commit() if (!_Extending) { // set readable name - ucstring readableName = NLMISC::CI18N::get(_PrimType == Road ? "uiR2EDNameBotRoad" : "uiR2EDNameBotRegion"); - readableName = getEditor().genInstanceName(readableName); - desc->set("Name", readableName.toUtf8()); + string readableName = NLMISC::CI18N::get(_PrimType == Road ? "uiR2EDNameBotRoad" : "uiR2EDNameBotRegion"); + readableName = getEditor().genInstanceName(readableName).toUtf8(); + desc->set("Name", readableName); // send creation command // tmp : static npc counter // add in component list of default feature