From c27547c3a3bfc2f53130a186a862212f76e2f707 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 1 Nov 2020 06:23:58 +0800 Subject: [PATCH] UTF-8 various, ryzom/ryzomcore#335 --- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_manager.h | 2 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 18 +++++----- ryzom/client/src/login.cpp | 34 +++++++------------ ryzom/client/src/misc.cpp | 4 +-- ryzom/client/src/misc.h | 4 +-- ryzom/client/src/net_manager.cpp | 2 +- .../src/game_share/bg_downloader_msg.cpp | 4 +-- .../common/src/game_share/bg_downloader_msg.h | 2 +- 9 files changed, 32 insertions(+), 40 deletions(-) diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index 963093235..1b36c91d5 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2413,7 +2413,7 @@ void CInterfaceManager::messageBox(const ucstring &text, const string &masterGro // ------------------------------------------------------------------------------------------------ -void CInterfaceManager::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, +void CInterfaceManager::messageBoxWithHelp(const std::string &text, const std::string &masterGroup, const std::string &ahOnOk, const std::string ¶msOnOk, TCaseMode caseMode) { diff --git a/ryzom/client/src/interface_v3/interface_manager.h b/ryzom/client/src/interface_v3/interface_manager.h index 2aed09dc5..91178677d 100644 --- a/ryzom/client/src/interface_v3/interface_manager.h +++ b/ryzom/client/src/interface_v3/interface_manager.h @@ -310,7 +310,7 @@ public: * The help button with open a browser on ryzom.com faq * ui:interface:message_box_with_help must be defined in xml, with a "text" ViewText son */ - void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup="ui:interface", + void messageBoxWithHelp(const std::string &text, const std::string &masterGroup="ui:interface", const std::string &ahOnOk = std::string(), const std::string ¶msOnOk= std::string(), TCaseMode caseMode = CaseFirstSentenceLetterUp); diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 4e6599fa1..0e97c73f7 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -527,9 +527,9 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) luabind::def("messageBox", (void(*)(const ucstring &, const std::string &)) &messageBox), luabind::def("messageBox", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox), luabind::def("messageBox", (void(*)(const std::string &)) &messageBox), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp), + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp), // TODO: Lua UTF-8 + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp), // TODO: Lua UTF-8 + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp), // TODO: Lua UTF-8 luabind::def("messageBoxWithHelp", (void(*)(const std::string &)) &messageBoxWithHelp), LUABIND_FUNC(replacePvpEffectParam), LUABIND_FUNC(secondsSince1970ToHour), @@ -2929,23 +2929,23 @@ void CLuaIHMRyzom::messageBox(const std::string &text) } // *************************************************************************** -void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text) +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text) // TODO: Lua UTF-8 { //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text); + pIM->messageBoxWithHelp(text.toUtf8()); } // *************************************************************************** -void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup) +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup) // TODO: Lua UTF-8 { //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text, masterGroup); + pIM->messageBoxWithHelp(text.toUtf8(), masterGroup); } // *************************************************************************** -void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode) +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode) // TODO: Lua UTF-8 { if (caseMode < 0 || caseMode >= CaseCount) { @@ -2954,7 +2954,7 @@ void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string & //H_AUTO(Lua_CLuaIHM_messageBox) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text, masterGroup, "" , "", (TCaseMode) caseMode); + pIM->messageBoxWithHelp(text.toUtf8(), masterGroup, "" , "", (TCaseMode) caseMode); } // *************************************************************************** diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp index d0f6243b8..bedd66f7c 100644 --- a/ryzom/client/src/login.cpp +++ b/ryzom/client/src/login.cpp @@ -243,7 +243,7 @@ void createOptionalCatUI() pVT = dynamic_cast(pNewLine->getView("size")); if (pVT != NULL) { - pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size).toUtf8()); + pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size)); } // Add to the list @@ -467,8 +467,8 @@ void loginMainLoop() bool res = false; BGDownloader::TTaskResult taskResult = BGDownloader::TaskResult_Unknown; bool finished = false; - ucstring bgDownloaderError; #ifdef RYZOM_BG_DOWNLOADER + string bgDownloaderError; if (isBGDownloadEnabled()) { finished = bgDownloader.isTaskEnded(taskResult, bgDownloaderError); @@ -657,7 +657,7 @@ void loginMainLoop() totalPatchSize = bgDownloader.getTotalSize(); BGDownloader::TTaskResult taskResult; bool finished = false; - ucstring bgDownloaderError; + string bgDownloaderError; finished = bgDownloader.isTaskEnded(taskResult, bgDownloaderError); if (finished) { @@ -670,8 +670,8 @@ void loginMainLoop() if (taskResult == BGDownloader::TaskResult_Error) { - setPatcherStateText("ui:login:patching", ucstring()); - setPatcherProgressText("ui:login:patching", ucstring()); + setPatcherStateText("ui:login:patching", string()); + setPatcherProgressText("ui:login:patching", string()); if (!fatalMessageBoxShown) { @@ -723,10 +723,10 @@ void loginMainLoop() } CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TOTAL_SIZE_PATCH)); - ucstring sTmp; + string sTmp; sTmp = BGDownloader::getWrittenSize(currentPatchingSize); sTmp += " / " + BGDownloader::getWrittenSize(totalPatchSize); - if (pVT != NULL) pVT->setText(sTmp.toUtf8()); + if (pVT != NULL) pVT->setText(sTmp); } // else if (screen == UI_VARIABLES_SCREEN_CATDISP) // If we are displaying patch info else if (LoginSM.getCurrentState() == CLoginStateMachine::st_display_cat) @@ -775,10 +775,10 @@ void loginMainLoop() // Total size of the patches is optional cats + required cat (f(optCat)) + non opt cat CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TOTAL_SIZE)); - if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(TotalPatchSize).toUtf8()); + if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(TotalPatchSize)); pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NON_OPTIONAL_SIZE)); - if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(nNonOptSize).toUtf8()); + if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(nNonOptSize)); } } } @@ -802,7 +802,7 @@ void initLoginScreen() // version std::string ext; - if (ClientApp.find("ryzom_") != ucstring::npos) + if (ClientApp.find("ryzom_") != string::npos) ext = " (" + ClientApp.substr(6) + ")"; CViewText *pV = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:checkpass:content:ver_value")); @@ -1878,7 +1878,7 @@ class CAHReboot : public IActionHandler } catch (const std::exception &e) { - im->messageBoxWithHelp(ucstring::makeFromUtf8(e.what()), "ui:login", "login_quit"); + im->messageBoxWithHelp(e.what(), "ui:login", "login_quit"); } } }; @@ -2354,10 +2354,6 @@ inline string parseTooltip(const string & initString, const string & tagName) tooltip = tooltip.substr(0, tooltip.find("<")); } - ucstring uc; - uc.fromUtf8(tooltip);; - tooltip = uc.toString(); - return tooltip; } @@ -2377,10 +2373,6 @@ inline string parseCommentError(const string & initString, const string & tagNam error = error.substr(0, error.find("<")); } - ucstring uc; - uc.fromUtf8(error);; - error = uc.toString(); - return error; } @@ -3304,7 +3296,7 @@ void loginIntro() if (i != 0) { beginLoading(IntroNVidia); - ucstring nmsg(""); + string nmsg(""); ProgressBar.newMessage (nmsg); } @@ -3330,7 +3322,7 @@ void loginIntro() Driver->AsyncListener.isKeyPushed (KeySPACE)) break; - const ucstring nmsg(""); + const string nmsg(""); ProgressBar.newMessage (nmsg); IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); diff --git a/ryzom/client/src/misc.cpp b/ryzom/client/src/misc.cpp index 9816202d4..4e35cfc2a 100644 --- a/ryzom/client/src/misc.cpp +++ b/ryzom/client/src/misc.cpp @@ -879,7 +879,7 @@ NLMISC::CRGBA interpClientCfgColor(const string &src, string &dest) if (src[0] == '&') { string::size_type nextPos = src.find('&', 1); - if (nextPos != ucstring::npos) + if (nextPos != string::npos) { std::string colorCode; colorCode.resize(nextPos - 1); @@ -980,7 +980,7 @@ std::string getStringCategoryIfAny(const string &src, string &dest) // *************************************************************************** -sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1) +sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1) // OLD { // start const ucchar *start1= s1.c_str(); diff --git a/ryzom/client/src/misc.h b/ryzom/client/src/misc.h index 96568c22e..c48b18137 100644 --- a/ryzom/client/src/misc.h +++ b/ryzom/client/src/misc.h @@ -193,8 +193,8 @@ enum TFilter3d RYZOM_MAX_FILTER_3D, }; -// compare 2 ucstring s0 and s1, without regard to case. give start and size for sequence p0 -sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1); +// compare 2 ucstring s0 and s1, without regard to case. give start and size for sequence p0 // OLD +sint ucstrnicmp(const ucstring &s0, uint p0, uint n0, const ucstring &s1); // OLD /** Compute a non-continuous noise with uniform repartition in [0, 1], with the given noise object * By default repartition is not uniform for noise diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index 2c94b956d..6b73acba2 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -4340,7 +4340,7 @@ NLMISC_COMMAND(testDuelInvite, "","") //{ // uint32 index; // fromString(args[0], index); -// ucstring ucstr = args[1]; +// ucstring ucstr = args[1]; // OLD // // vector code; // diff --git a/ryzom/common/src/game_share/bg_downloader_msg.cpp b/ryzom/common/src/game_share/bg_downloader_msg.cpp index 297770ddb..e26aad9be 100644 --- a/ryzom/common/src/game_share/bg_downloader_msg.cpp +++ b/ryzom/common/src/game_share/bg_downloader_msg.cpp @@ -26,10 +26,10 @@ namespace BGDownloader const wchar_t *DownloaderMutexName = L"RyzomBgDownloader"; -ucstring getWrittenSize(uint32 nSize) +std::string getWrittenSize(uint32 nSize) { float fSize = ((float)nSize)/(1024.0f*1024.0f); - ucstring ucs = NLMISC::toString("%.1f", fSize) + " " + NLMISC::CI18N::get("uiMb"); + std::string ucs = NLMISC::toString("%.1f", fSize) + " " + NLMISC::CI18N::get("uiMb"); return ucs; } diff --git a/ryzom/common/src/game_share/bg_downloader_msg.h b/ryzom/common/src/game_share/bg_downloader_msg.h index da903493f..4ed562168 100644 --- a/ryzom/common/src/game_share/bg_downloader_msg.h +++ b/ryzom/common/src/game_share/bg_downloader_msg.h @@ -137,7 +137,7 @@ extern const wchar_t *DownloaderMutexName; // get patch written size in megabytes -ucstring getWrittenSize(uint32 nSize); +std::string getWrittenSize(uint32 nSize); std::string toString(TMsgType msgType);