From 5a470a7b16a77c1be7b56d8a1d1a40ba7b26788e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 31 Oct 2020 08:21:31 +0800 Subject: [PATCH] UTF-8 string manager, ryzom/ryzomcore#335 --- nel/include/nel/gui/interface_expr.h | 1 + ryzom/client/src/game_context_menu.cpp | 2 +- .../src/interface_v3/action_handler_item.cpp | 6 ++---- ryzom/client/src/interface_v3/dbctrl_sheet.cpp | 8 ++++---- .../interface_v3/dbgroup_list_sheet_trade.cpp | 2 +- .../src/interface_v3/encyclopedia_manager.cpp | 9 +++------ .../src/interface_v3/group_in_scene_bubble.cpp | 3 +-- .../interface_v3/group_phrase_skill_filter.cpp | 2 +- ryzom/client/src/interface_v3/group_skills.cpp | 4 ++-- .../interface_expr_user_fct_game.cpp | 16 ++++++++-------- .../interface_expr_user_fct_items.cpp | 8 ++++---- 11 files changed, 28 insertions(+), 33 deletions(-) diff --git a/nel/include/nel/gui/interface_expr.h b/nel/include/nel/gui/interface_expr.h index 27ed24fe0..b4474ac22 100644 --- a/nel/include/nel/gui/interface_expr.h +++ b/nel/include/nel/gui/interface_expr.h @@ -68,6 +68,7 @@ namespace NLGUI void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; } void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; } void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; } + void setString(const char *value) { clean(); _Type = String; _StringValue = value; } void setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); } void setUserType(CInterfaceExprUserType *value); // reset this object to initial state (no type) diff --git a/ryzom/client/src/game_context_menu.cpp b/ryzom/client/src/game_context_menu.cpp index 441976be8..47ca97a80 100644 --- a/ryzom/client/src/game_context_menu.cpp +++ b/ryzom/client/src/game_context_menu.cpp @@ -798,7 +798,7 @@ void CGameContextMenu::updateContextMenuOutpostState(uint options) { CViewTextMenu *pVTM = _TextOutpostState; if (pVTM) - pVTM->setText(CUtfStringView(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)).toUtf8()); + pVTM->setText(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)); } // apply the active diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 0edd74491..2df888285 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -161,9 +161,8 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() } else { - ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); if (itemInfo.CustomText.empty()) - display->setTextFormatTaged(localDesc.toUtf8()); + display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); else { ucstring text = itemInfo.CustomText; @@ -305,9 +304,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() // Finish the display or add the waiter if (getInventory().isItemInfoUpToDate(ItemSlotId)) { - ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); if (itemInfo.CustomText.empty()) - display->setTextFormatTaged(localDesc.toUtf8()); + display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); else { ucstring text = itemInfo.CustomText; diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index a07d4c2fb..e9575f776 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -3385,7 +3385,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const { // just show the name of the skill // the sheet id is interpreted as a skill enum - help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName( (SKILLS::ESkills)_SheetId.getSInt32() )).toUtf8(); + help= STRING_MANAGER::CStringManagerClient::getSkillLocalizedName( (SKILLS::ESkills)_SheetId.getSInt32() ); } else if(getType() == CCtrlSheetInfo::SheetType_Macro) { @@ -3485,7 +3485,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const CSBrickManager *pBM= CSBrickManager::getInstance(); CSBrickSheet *brick= pBM->getBrick(CSheetId(getSheetId())); if(brick) - help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id)).toUtf8(); + help= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id); else help= _ContextHelp; } @@ -3549,7 +3549,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const { CSPhraseSheet *phrase= dynamic_cast(SheetMngr.get(CSheetId(getSheetId()))); if(phrase) - help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id)).toUtf8(); + help= STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id); else help= _ContextHelp; } @@ -3557,7 +3557,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const { const COutpostBuildingSheet *outpost = asOutpostBuildingSheet(); if (outpost) - help = CUtfStringView(CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32()))).toUtf8(); + help = CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32())); else help = _ContextHelp; } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index 3d59ea644..2b52de9b0 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -269,7 +269,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT if (pOBS != NULL) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - text += string("\n") + CUtfStringView(pSMC->getOutpostBuildingLocalizedDescription(CSheetId(Ctrl->getSheetId()))).toUtf8(); + text += string("\n") + pSMC->getOutpostBuildingLocalizedDescription(CSheetId(Ctrl->getSheetId())); text += "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(pOBS->CostDapper)); text += CI18N::get("uiBotChatTime") + toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute"); if ((pOBS->CostTime % 60) != 0) diff --git a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index 63c5f07c9..25f5bc2e8 100644 --- a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -360,18 +360,15 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) { if (pES->type() == CEntitySheet::ITEM) { - CUtfStringView desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc.toUtf8()); + pRBVT->setText(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); } else if (pES->type() == CEntitySheet::SBRICK) { - CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc.toUtf8()); + pRBVT->setText(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); } else if (pES->type() == CEntitySheet::SPHRASE) { - CUtfStringView desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc.toUtf8()); + pRBVT->setText(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); } } diff --git a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 258700dd2..c3edc87f9 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -531,10 +531,9 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t if (group) { // Skill name - CUtfStringView sSkillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); CViewText *pViewSkillName = dynamic_cast(group->getView("name")); if (pViewSkillName != NULL) - pViewSkillName->setText (sSkillName.toUtf8()); + pViewSkillName->setText (STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); // Skill value CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false); diff --git a/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp b/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp index d246918bd..7d2054fc4 100644 --- a/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -225,7 +225,7 @@ void CGroupPhraseSkillFilter::rebuild() // just text pNode->DisplayText = true; pNode->Template = NULL; - pNode->Text = CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i)).toUtf8(); + pNode->Text = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i); // Action handler? if(!_AHCtrlNode.empty()) diff --git a/ryzom/client/src/interface_v3/group_skills.cpp b/ryzom/client/src/interface_v3/group_skills.cpp index d0efce626..146117d17 100644 --- a/ryzom/client/src/interface_v3/group_skills.cpp +++ b/ryzom/client/src/interface_v3/group_skills.cpp @@ -336,7 +336,7 @@ void CGroupSkills::createAllTreeNodes() // local variable (avoid realloc in loop) vector< pair > tempVec(2); - string sSkillName; + const char *sSkillName; while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop { @@ -366,7 +366,7 @@ void CGroupSkills::createAllTreeNodes() pNode->Id = NLMISC::toString(i); // get Skill Name - sSkillName = CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i)).toUtf8(); + sSkillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i); // just text or template? if(_TemplateSkill.empty()) diff --git a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index a4dfb9d79..9494deacf 100644 --- a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -1083,7 +1083,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostName) // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const std::string name = CUtfStringView(pSMC->getOutpostLocalizedName(CSheetId(nSheet))).toUtf8(); + const char *name = pSMC->getOutpostLocalizedName(CSheetId(nSheet)); result.setString(name); @@ -1110,7 +1110,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostDesc) // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const string name = CUtfStringView(pSMC->getOutpostLocalizedDescription(CSheetId(nSheet))).toUtf8(); + const char *name = pSMC->getOutpostLocalizedDescription(CSheetId(nSheet)); result.setString(name); @@ -1137,7 +1137,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingName) // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const string name = CUtfStringView(pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet))).toUtf8(); + const char *name = pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet)); result.setString(name); @@ -1163,18 +1163,18 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc) } // get sheet name - string name; + const char *name; CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet)); COutpostBuildingSheet *pOBS = dynamic_cast(pSheet); if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty) { // Don't display description if the building is an empty slot - name.clear(); + name = ""; } else { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - name = CUtfStringView(pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet))).toUtf8(); + name = pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet)); } @@ -1203,7 +1203,7 @@ static DECLARE_INTERFACE_USER_FCT(getSquadName) // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const string name = CUtfStringView(pSMC->getSquadLocalizedName(CSheetId(nSheet))).toUtf8(); + const char *name = pSMC->getSquadLocalizedName(CSheetId(nSheet)); result.setString(name); @@ -1230,7 +1230,7 @@ static DECLARE_INTERFACE_USER_FCT(getSquadDesc) // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const string name = CUtfStringView(pSMC->getSquadLocalizedDescription(CSheetId(nSheet))).toUtf8(); + const char *name = pSMC->getSquadLocalizedDescription(CSheetId(nSheet)); result.setString(name); diff --git a/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp b/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp index eafdcccaf..cae4b9d77 100644 --- a/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp +++ b/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp @@ -320,8 +320,8 @@ static DECLARE_INTERFACE_USER_FCT(getSheetName) else { const CItemSheet *itemSheet = getItemSheet(args); - string tmp; - if (itemSheet != NULL) tmp = CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id)).toUtf8(); + const char *tmp = ""; + if (itemSheet != NULL) tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id); result.setString(tmp); return true; } @@ -346,8 +346,8 @@ static DECLARE_INTERFACE_USER_FCT(getItemTranslatedName) return false; } - string tmp; - tmp = CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet)).toUtf8(); + const char *tmp = ""; + tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet); result.setString(tmp); return true; }