UTF-8 string manager, ryzom/ryzomcore#335

develop
kaetemi 4 years ago
parent 9d534882e8
commit 5a470a7b16

@ -68,6 +68,7 @@ namespace NLGUI
void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; } void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; }
void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; } void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; }
void setString(const std::string &value) { clean(); _Type = String; _StringValue = 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 setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); }
void setUserType(CInterfaceExprUserType *value); void setUserType(CInterfaceExprUserType *value);
// reset this object to initial state (no type) // reset this object to initial state (no type)

@ -798,7 +798,7 @@ void CGameContextMenu::updateContextMenuOutpostState(uint options)
{ {
CViewTextMenu *pVTM = _TextOutpostState; CViewTextMenu *pVTM = _TextOutpostState;
if (pVTM) if (pVTM)
pVTM->setText(CUtfStringView(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)).toUtf8()); pVTM->setText(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet));
} }
// apply the active // apply the active

@ -161,9 +161,8 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived()
} }
else else
{ {
ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id));
if (itemInfo.CustomText.empty()) if (itemInfo.CustomText.empty())
display->setTextFormatTaged(localDesc.toUtf8()); display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id));
else else
{ {
ucstring text = itemInfo.CustomText; ucstring text = itemInfo.CustomText;
@ -305,9 +304,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
// Finish the display or add the waiter // Finish the display or add the waiter
if (getInventory().isItemInfoUpToDate(ItemSlotId)) if (getInventory().isItemInfoUpToDate(ItemSlotId))
{ {
ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id));
if (itemInfo.CustomText.empty()) if (itemInfo.CustomText.empty())
display->setTextFormatTaged(localDesc.toUtf8()); display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id));
else else
{ {
ucstring text = itemInfo.CustomText; ucstring text = itemInfo.CustomText;

@ -3385,7 +3385,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
{ {
// just show the name of the skill // just show the name of the skill
// the sheet id is interpreted as a skill enum // 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) else if(getType() == CCtrlSheetInfo::SheetType_Macro)
{ {
@ -3485,7 +3485,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
CSBrickManager *pBM= CSBrickManager::getInstance(); CSBrickManager *pBM= CSBrickManager::getInstance();
CSBrickSheet *brick= pBM->getBrick(CSheetId(getSheetId())); CSBrickSheet *brick= pBM->getBrick(CSheetId(getSheetId()));
if(brick) if(brick)
help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id)).toUtf8(); help= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id);
else else
help= _ContextHelp; help= _ContextHelp;
} }
@ -3549,7 +3549,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
{ {
CSPhraseSheet *phrase= dynamic_cast<CSPhraseSheet*>(SheetMngr.get(CSheetId(getSheetId()))); CSPhraseSheet *phrase= dynamic_cast<CSPhraseSheet*>(SheetMngr.get(CSheetId(getSheetId())));
if(phrase) if(phrase)
help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id)).toUtf8(); help= STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id);
else else
help= _ContextHelp; help= _ContextHelp;
} }
@ -3557,7 +3557,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
{ {
const COutpostBuildingSheet *outpost = asOutpostBuildingSheet(); const COutpostBuildingSheet *outpost = asOutpostBuildingSheet();
if (outpost) if (outpost)
help = CUtfStringView(CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32()))).toUtf8(); help = CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32()));
else else
help = _ContextHelp; help = _ContextHelp;
} }

@ -269,7 +269,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT
if (pOBS != NULL) if (pOBS != NULL)
{ {
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); 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 += "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(pOBS->CostDapper));
text += CI18N::get("uiBotChatTime") + toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute"); text += CI18N::get("uiBotChatTime") + toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute");
if ((pOBS->CostTime % 60) != 0) if ((pOBS->CostTime % 60) != 0)

@ -360,18 +360,15 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName)
{ {
if (pES->type() == CEntitySheet::ITEM) if (pES->type() == CEntitySheet::ITEM)
{ {
CUtfStringView desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); pRBVT->setText(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet)));
pRBVT->setText(desc.toUtf8());
} }
else if (pES->type() == CEntitySheet::SBRICK) else if (pES->type() == CEntitySheet::SBRICK)
{ {
CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); pRBVT->setText(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet)));
pRBVT->setText(desc.toUtf8());
} }
else if (pES->type() == CEntitySheet::SPHRASE) else if (pES->type() == CEntitySheet::SPHRASE)
{ {
CUtfStringView desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); pRBVT->setText(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet)));
pRBVT->setText(desc.toUtf8());
} }
} }

@ -531,10 +531,9 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t
if (group) if (group)
{ {
// Skill name // Skill name
CUtfStringView sSkillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId));
CViewText *pViewSkillName = dynamic_cast<CViewText*>(group->getView("name")); CViewText *pViewSkillName = dynamic_cast<CViewText*>(group->getView("name"));
if (pViewSkillName != NULL) if (pViewSkillName != NULL)
pViewSkillName->setText (sSkillName.toUtf8()); pViewSkillName->setText (STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId));
// Skill value // Skill value
CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false); CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false);

@ -225,7 +225,7 @@ void CGroupPhraseSkillFilter::rebuild()
// just text // just text
pNode->DisplayText = true; pNode->DisplayText = true;
pNode->Template = NULL; 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? // Action handler?
if(!_AHCtrlNode.empty()) if(!_AHCtrlNode.empty())

@ -336,7 +336,7 @@ void CGroupSkills::createAllTreeNodes()
// local variable (avoid realloc in loop) // local variable (avoid realloc in loop)
vector< pair<string, string> > tempVec(2); vector< pair<string, string> > tempVec(2);
string sSkillName; const char *sSkillName;
while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop
{ {
@ -366,7 +366,7 @@ void CGroupSkills::createAllTreeNodes()
pNode->Id = NLMISC::toString(i); pNode->Id = NLMISC::toString(i);
// get Skill Name // 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? // just text or template?
if(_TemplateSkill.empty()) if(_TemplateSkill.empty())

@ -1083,7 +1083,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostName)
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); 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); result.setString(name);
@ -1110,7 +1110,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostDesc)
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); 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); result.setString(name);
@ -1137,7 +1137,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingName)
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); 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); result.setString(name);
@ -1163,18 +1163,18 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc)
} }
// get sheet name // get sheet name
string name; const char *name;
CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet)); CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet));
COutpostBuildingSheet *pOBS = dynamic_cast<COutpostBuildingSheet*>(pSheet); COutpostBuildingSheet *pOBS = dynamic_cast<COutpostBuildingSheet*>(pSheet);
if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty) if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty)
{ {
// Don't display description if the building is an empty slot // Don't display description if the building is an empty slot
name.clear(); name = "";
} }
else else
{ {
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); 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 // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); 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); result.setString(name);
@ -1230,7 +1230,7 @@ static DECLARE_INTERFACE_USER_FCT(getSquadDesc)
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); 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); result.setString(name);

@ -320,8 +320,8 @@ static DECLARE_INTERFACE_USER_FCT(getSheetName)
else else
{ {
const CItemSheet *itemSheet = getItemSheet(args); const CItemSheet *itemSheet = getItemSheet(args);
string tmp; const char *tmp = "";
if (itemSheet != NULL) tmp = CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id)).toUtf8(); if (itemSheet != NULL) tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id);
result.setString(tmp); result.setString(tmp);
return true; return true;
} }
@ -346,8 +346,8 @@ static DECLARE_INTERFACE_USER_FCT(getItemTranslatedName)
return false; return false;
} }
string tmp; const char *tmp = "";
tmp = CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet)).toUtf8(); tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet);
result.setString(tmp); result.setString(tmp);
return true; return true;
} }

Loading…
Cancel
Save