diff --git a/nel/include/nel/gui/ctrl_text_button.h b/nel/include/nel/gui/ctrl_text_button.h index 25fc9eeac..74e1c1291 100644 --- a/nel/include/nel/gui/ctrl_text_button.h +++ b/nel/include/nel/gui/ctrl_text_button.h @@ -96,8 +96,10 @@ namespace NLGUI bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;} void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;} // Set text (noop if text id) - void setText (const ucstring &text); - ucstring getText () const; + void setText (const std::string &text); + std::string getText () const; + void setTextAsUtf16 (const ucstring &text); + ucstring getTextAsUtf16 () const; void setHardText (const std::string &text); std::string getHardText () const; @@ -130,7 +132,7 @@ namespace NLGUI int luaGetViewText(CLuaState &ls); REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton) - REFLECT_UCSTRING("uc_hardtext", getText, setText); + REFLECT_UCSTRING("uc_hardtext", getTextAsUtf16, setTextAsUtf16); REFLECT_STRING("hardtext", getHardText, setHardText); REFLECT_SINT32("text_x", getTextX, setTextX) REFLECT_SINT32("wmargin", getWMargin, setWMargin) diff --git a/nel/include/nel/gui/group_container.h b/nel/include/nel/gui/group_container.h index 742dfcfb2..399f9c056 100644 --- a/nel/include/nel/gui/group_container.h +++ b/nel/include/nel/gui/group_container.h @@ -477,8 +477,8 @@ namespace NLGUI float _CurrentRolloverAlphaContainer; float _CurrentRolloverAlphaContent; sint32 _LayerSetup; - ucstring _TitleTextOpened; - ucstring _TitleTextClosed; + std::string _TitleTextOpened; + std::string _TitleTextClosed; CViewText *_TitleOpened; CViewText *_TitleClosed; sint32 _TitleDeltaMaxW; diff --git a/nel/include/nel/gui/group_list.h b/nel/include/nel/gui/group_list.h index 58af530b5..6e7587e34 100644 --- a/nel/include/nel/gui/group_list.h +++ b/nel/include/nel/gui/group_list.h @@ -67,13 +67,13 @@ namespace NLGUI * \param line : text to be added * \param color : text color */ - void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true); + void addTextChild (const std::string& line,const NLMISC::CRGBA &textColor, bool multiLine = true); /** * add a text child element to the group, using the text template * \param line : text to be added */ - void addTextChild (const ucstring& line, bool multiLine = true); + void addTextChild (const std::string& line, bool multiLine = true); /// Same as adding a text child but the text will be taken from the string manager void addTextChildID (uint32 id, bool multiLine = true); diff --git a/nel/include/nel/gui/group_menu.h b/nel/include/nel/gui/group_menu.h index 21a740d84..f304a3d60 100644 --- a/nel/include/nel/gui/group_menu.h +++ b/nel/include/nel/gui/group_menu.h @@ -122,12 +122,12 @@ namespace NLGUI // retrieve the index of a line from its id (-1 if not found) sint getLineFromId(const std::string &id); - CViewTextMenu* addLine (const ucstring &name, const std::string &ah, + CViewTextMenu* addLine (const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id="", const std::string &cond = std::string(), const std::string &texture="", bool checkable = false, bool checked = false, bool formatted = false ); - CViewTextMenu* addLineAtIndex(uint index, const ucstring &name, const std::string &ah, + CViewTextMenu* addLineAtIndex(uint index, const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id="", const std::string &cond = std::string(), const std::string &texture="", bool checkable = false, bool checked = false, bool formatted = false @@ -332,12 +332,7 @@ namespace NLGUI virtual void setActive (bool state); virtual bool isWindowUnder (sint32 x, sint32 y); - - // add line with a string, for backward compatibility - void addLine (const std::string &name, const std::string &ah, const std::string ¶ms, - const std::string &id = std::string(), - const std::string &cond = std::string(), const std::string &texture="", - bool checkable = false, bool checked = false); + uint getNumLine() const; void deleteLine(uint index); const std::string getActionHandler(uint lineIndex) const; @@ -350,12 +345,12 @@ namespace NLGUI void setRightClickHandler(uint lineIndex, const std::string &ah = ""); void setRightClickHandlerParam(uint lineIndex, const std::string ¶ms = ""); - void addLine (const ucstring &name, const std::string &ah = "", const std::string ¶ms = "", + void addLine (const std::string &name, const std::string &ah = "", const std::string ¶ms = "", const std::string &id = std::string(), const std::string &cond = std::string(), const std::string &texture="", bool checkable = false, bool checked = false ); - void addLineAtIndex (uint index, const ucstring &name, const std::string &ah = "", const std::string ¶ms = "", + void addLineAtIndex (uint index, const std::string &name, const std::string &ah = "", const std::string ¶ms = "", const std::string &id = std::string(), const std::string &cond = std::string(), const std::string &texture="", bool checkable = false, bool checked = false diff --git a/nel/include/nel/gui/group_paragraph.h b/nel/include/nel/gui/group_paragraph.h index 6142bc33b..0e1898633 100644 --- a/nel/include/nel/gui/group_paragraph.h +++ b/nel/include/nel/gui/group_paragraph.h @@ -84,13 +84,13 @@ namespace NLGUI * \param line : text to be added * \param color : text color */ - void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true); + void addTextChild (const std::string& line,const NLMISC::CRGBA &textColor, bool multiLine = true); /** * add a text child element to the group, using the text template * \param line : text to be added */ - void addTextChild (const ucstring& line, bool multiLine = true); + void addTextChild (const std::string& line, bool multiLine = true); /// Same as adding a text child but the text will be taken from the string manager void addTextChildID (uint32 id, bool multiLine = true); diff --git a/nel/include/nel/gui/group_tree.h b/nel/include/nel/gui/group_tree.h index 266e7e23f..d7518a68d 100644 --- a/nel/include/nel/gui/group_tree.h +++ b/nel/include/nel/gui/group_tree.h @@ -60,7 +60,7 @@ namespace NLGUI bool Show; // If false, the node is not displayed (true default, Root ignored) sint32 YDecal; // Text - ucstring Text; // Internationalized displayed text + std::string Text; // Internationalized displayed text sint32 FontSize; // If -1 (default), then take the groupTree one NLMISC::CRGBA Color; // Template @@ -112,8 +112,10 @@ namespace NLGUI std::string getBitmap() const { return Bitmap; } void setOpened(bool opened) { Opened = opened; } bool getOpened() const { return Opened; } - void setText(const ucstring &text) { Text = text; } - const ucstring& getText() const { return Text; } + void setText(const std::string &text) { Text = text; } + const std::string& getText() const { return Text; } + void setTextAsUtf16(const ucstring &text) { Text = text.toUtf8(); } + ucstring getTextAsUtf16() const { return ucstring::makeFromUtf8(Text); } sint32 getFontSize() const { return FontSize; } void setFontSize(sint32 value) { FontSize = value; } sint32 getYDecal() const { return YDecal; } @@ -181,7 +183,7 @@ namespace NLGUI REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose); REFLECT_BOOL("Opened", getOpened, setOpened); REFLECT_BOOL("Show", getShow, setShow); - REFLECT_UCSTRING_REF("Text", getText, setText); + REFLECT_UCSTRING("Text", getTextAsUtf16, setTextAsUtf16); // FIXME: Lua UTF-8 // lua REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren); REFLECT_LUA_METHOD("getChild", luaGetChild); diff --git a/nel/include/nel/gui/interface_expr.h b/nel/include/nel/gui/interface_expr.h index b967ef7ab..0a9d9b4e9 100644 --- a/nel/include/nel/gui/interface_expr.h +++ b/nel/include/nel/gui/interface_expr.h @@ -59,16 +59,14 @@ namespace NLGUI bool getBool() const; sint64 getInteger() const; double getDouble() const; - std::string getString() const; + const std::string &getString() const; NLMISC::CRGBA getRGBA() const; - const ucstring &getUCString() const; CInterfaceExprUserType *getUserType() const; // set void setBool(bool value) { clean(); _Type = Boolean; _BoolValue = value; } 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 setUCString(const ucstring &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) @@ -99,7 +97,7 @@ namespace NLGUI CInterfaceExprUserType *_UserTypeValue; uint32 _RGBAValue; }; - ucstring _StringValue; // well, can't fit in union, unless we do some horrible hack.. + std::string _StringValue; // well, can't fit in union, unless we do some horrible hack.. private: const char *evalBoolean(const char *expr); const char *evalNumber(const char *expr); diff --git a/nel/include/nel/gui/view_pointer.h b/nel/include/nel/gui/view_pointer.h index cb550e44a..bc605a717 100644 --- a/nel/include/nel/gui/view_pointer.h +++ b/nel/include/nel/gui/view_pointer.h @@ -55,7 +55,7 @@ namespace NLGUI bool getStringMode() const {return _StringMode;} // Set cursor string - void setString (const ucstring &str); + void setString (const std::string &str); // TEMP PATCH void setCursor (const std::string &name) @@ -126,14 +126,14 @@ namespace NLGUI bool _ForceStringMode; CInterfaceGroup *_StringCursor; CInterfaceGroup *_StringCursorHardware; - ucstring _ContextString; + std::string _ContextString; // draw current cursor with the given texture, or, if in hardware mode, change the hardware cursor shape void drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot); private: // set the string into frame for software or hardware version - void setString (const ucstring &str, CInterfaceGroup *target); + void setString(const std::string &str, CInterfaceGroup *target); static bool hwMouse; diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index 2ffaa8d49..933f9a747 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -465,7 +465,7 @@ namespace NLGUI void addDontClipWordLine(std::vector &currLine); // FormatTag build. - static void buildFormatTagText(const std::string &text, std::string &textBuild, std::vector &formatTags, std::vector &tooltips); + static void buildFormatTagText(const std::string &text, std::string &textBuild, std::vector &formatTags, std::vector &tooltips); // FormatTag parsing. bool isFormatTagChange(uint textIndex, uint ctIndex) const; void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const; diff --git a/nel/include/nel/gui/view_text_formated.h b/nel/include/nel/gui/view_text_formated.h index 43a7eb9a8..f6a3cf443 100644 --- a/nel/include/nel/gui/view_text_formated.h +++ b/nel/include/nel/gui/view_text_formated.h @@ -45,7 +45,7 @@ namespace NLGUI { public: virtual ~IViewTextFormatter(){} - virtual ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) = 0; + virtual std::string formatString( const std::string &inputString, const std::string ¶mString ) = 0; }; CViewTextFormated (const TCtorParam ¶m) : CViewText(param) @@ -55,15 +55,15 @@ namespace NLGUI xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual void checkCoords(); - const ucstring &getFormatString() const { return _FormatString; } - void setFormatString(const ucstring &format); + const std::string &getFormatString() const { return _FormatString; } + void setFormatString(const std::string &format); - static ucstring formatString(const ucstring &inputString, const ucstring ¶mString); + static std::string formatString(const std::string &inputString, const std::string ¶mString); static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; } private: - ucstring _FormatString; + std::string _FormatString; static IViewTextFormatter *textFormatter; }; diff --git a/nel/include/nel/gui/view_text_id.h b/nel/include/nel/gui/view_text_id.h index 1e46de062..8c012f319 100644 --- a/nel/include/nel/gui/view_text_id.h +++ b/nel/include/nel/gui/view_text_id.h @@ -58,8 +58,10 @@ namespace NLGUI { public: virtual ~IViewTextProvider(){} - virtual bool getString( uint32 stringId, ucstring &result ) = 0; - virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0; + bool getString(uint32 stringId, std::string &result) { ucstring temp; bool res = getString(stringId, temp); result = temp.toUtf8(); return res; } + bool getDynString(uint32 dynStringId, std::string &result) { ucstring temp; bool res = getDynString(dynStringId, temp); result = temp.toUtf8(); return res; } + virtual bool getString( uint32 stringId, ucstring &result ) = 0; // TODO: UTF-8 + virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0; // TODO: UTF-8 }; CViewTextID(const TCtorParam ¶m) : CViewText(param) diff --git a/nel/include/nel/gui/view_text_id_formated.h b/nel/include/nel/gui/view_text_id_formated.h index cbc494dc1..dfd11d0d4 100644 --- a/nel/include/nel/gui/view_text_id_formated.h +++ b/nel/include/nel/gui/view_text_id_formated.h @@ -49,10 +49,10 @@ namespace NLGUI xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual void checkCoords(); - const ucstring &getFormatString() const { return _FormatString; } - void setFormatString(const ucstring &format); + const std::string &getFormatString() const { return _FormatString; } + void setFormatString(const std::string &format); private: - ucstring _FormatString; + std::string _FormatString; }; } diff --git a/nel/src/gui/ctrl_text_button.cpp b/nel/src/gui/ctrl_text_button.cpp index 154d41633..5cc89c9a7 100644 --- a/nel/src/gui/ctrl_text_button.cpp +++ b/nel/src/gui/ctrl_text_button.cpp @@ -1041,14 +1041,29 @@ namespace NLGUI // *************************************************************************** - void CCtrlTextButton::setText (const ucstring &text) + void CCtrlTextButton::setText (const std::string &text) + { + if (_ViewText && !_IsViewTextId) + _ViewText->setText(text); + } + + // *************************************************************************** + std::string CCtrlTextButton::getText () const + { + if (_ViewText && !_IsViewTextId) + return _ViewText->getText(); + return std::string(); + } + + // *************************************************************************** + void CCtrlTextButton::setTextAsUtf16 (const ucstring &text) { if (_ViewText && !_IsViewTextId) _ViewText->setText(text.toUtf8()); } // *************************************************************************** - ucstring CCtrlTextButton::getText () const + ucstring CCtrlTextButton::getTextAsUtf16 () const { if (_ViewText && !_IsViewTextId) return CUtfStringView(_ViewText->getText()).toUtf16(); diff --git a/nel/src/gui/dbgroup_combo_box.cpp b/nel/src/gui/dbgroup_combo_box.cpp index 66d3220a0..b13005b33 100644 --- a/nel/src/gui/dbgroup_combo_box.cpp +++ b/nel/src/gui/dbgroup_combo_box.cpp @@ -668,7 +668,7 @@ namespace NLGUI { checkable = true; } - groupMenu->addLine(ucstring::makeFromUtf8(getText(i)), "combo_box_select_end", toString(i), + groupMenu->addLine(getText(i), "combo_box_select_end", toString(i), "", std::string(), getTexture(i), checkable); groupMenu->setGrayedLine(i, getGrayed(i)); } diff --git a/nel/src/gui/group_container.cpp b/nel/src/gui/group_container.cpp index 7bab62820..e6b69326b 100644 --- a/nel/src/gui/group_container.cpp +++ b/nel/src/gui/group_container.cpp @@ -1338,19 +1338,19 @@ namespace NLGUI if( name == "title" ) { if( _TitleTextOpened == _TitleTextClosed ) - return _TitleTextOpened.toString(); + return _TitleTextOpened; else return ""; } else if( name == "title_opened" ) { - return _TitleTextOpened.toString(); + return _TitleTextOpened; } else if( name == "title_closed" ) { - return _TitleTextClosed.toString(); + return _TitleTextClosed; } else if( name == "header_active" ) @@ -1997,12 +1997,12 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "content_y_offset", BAD_CAST toString( _ContentYOffset ).c_str() ); if( _TitleTextOpened == _TitleTextClosed ) - xmlSetProp( node, BAD_CAST "title", BAD_CAST _TitleTextOpened.toString().c_str() ); + xmlSetProp( node, BAD_CAST "title", BAD_CAST _TitleTextOpened.c_str() ); else xmlSetProp( node, BAD_CAST "title", BAD_CAST "" ); - xmlSetProp( node, BAD_CAST "title_opened", BAD_CAST _TitleTextOpened.toString().c_str() ); - xmlSetProp( node, BAD_CAST "title_closed", BAD_CAST _TitleTextClosed.toString().c_str() ); + xmlSetProp( node, BAD_CAST "title_opened", BAD_CAST _TitleTextOpened.c_str() ); + xmlSetProp( node, BAD_CAST "title_closed", BAD_CAST _TitleTextClosed.c_str() ); xmlSetProp( node, BAD_CAST "header_active", BAD_CAST toString( _HeaderActive ).c_str() ); if( _HeaderColor.getNodePtr() != NULL ) @@ -3712,7 +3712,7 @@ namespace NLGUI { CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam()); // the title here is actually the DB path - vti->setDBTextID(_TitleTextOpened.toString()); + vti->setDBTextID(_TitleTextOpened); vti->setDynamicString(_TitleClass==TitleTextDynString); _TitleOpened = vti; } @@ -3744,7 +3744,7 @@ namespace NLGUI _TitleOpened->setY (pLayer->getValSInt32 ("title_offset_y")); } _TitleOpened->setFontSize (pLayer->getValSInt32 ("title_font_size")); - if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened.toUtf8()); + if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened); _TitleOpened->setActive (_Opened); // Title when the container is closed @@ -3764,7 +3764,7 @@ namespace NLGUI { CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam()); // the title here is actually the DB path - vti->setDBTextID(_TitleTextClosed.toString()); + vti->setDBTextID(_TitleTextClosed); vti->setDynamicString(_TitleClass==TitleTextDynString); _TitleClosed = vti; } @@ -3796,7 +3796,7 @@ namespace NLGUI _TitleClosed->setY (pLayer->getValSInt32 ("title_offset_y")); } _TitleClosed->setFontSize (pLayer->getValSInt32 ("title_font_size")); - if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed.toUtf8()); + if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed); _TitleClosed->setActive(!_Opened); @@ -3949,7 +3949,7 @@ namespace NLGUI // *************************************************************************** std::string CGroupContainer::getTitle () const { - return _TitleTextOpened.toString(); + return _TitleTextOpened; } // *************************************************************************** @@ -3962,7 +3962,7 @@ namespace NLGUI // *************************************************************************** std::string CGroupContainer::getTitleOpened () const { - return _TitleTextOpened.toString(); + return _TitleTextOpened; } // *************************************************************************** @@ -3975,7 +3975,7 @@ namespace NLGUI // *************************************************************************** std::string CGroupContainer::getTitleClosed () const { - return _TitleTextClosed.toString(); + return _TitleTextClosed; } // *************************************************************************** @@ -3988,7 +3988,7 @@ namespace NLGUI // *************************************************************************** void CGroupContainer::setUCTitleOpened(const ucstring &title) { - _TitleTextOpened = title; + _TitleTextOpened = title.toUtf8(); if (_TitleOpened != NULL) _TitleOpened->setText (title.toUtf8()); invalidateCoords(); @@ -3997,9 +3997,9 @@ namespace NLGUI // *************************************************************************** void CGroupContainer::setUCTitleClosed(const ucstring &title) { - _TitleTextClosed = title; + _TitleTextClosed = title.toUtf8(); if (_TitleClosed != NULL) - _TitleClosed->setText (_TitleTextClosed.toUtf8()); + _TitleClosed->setText (_TitleTextClosed); invalidateCoords(); } diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index 15bd47a68..b559b409f 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -2755,11 +2755,11 @@ namespace NLGUI void CGroupHTML::addString(const ucstring &str) { - ucstring tmpStr = str; + string tmpStr = str.toUtf8(); if (_Localize) { - string _str = tmpStr.toString(); + string _str = tmpStr; string::size_type p = _str.find('#'); if (p == string::npos) { @@ -2800,7 +2800,7 @@ namespace NLGUI } else if (_Object) { - _ObjectScript += tmpStr.toString(); + _ObjectScript += tmpStr; } else if (_SelectOption) { @@ -2853,7 +2853,7 @@ namespace NLGUI (style.GlobalColor == _CurrentViewLink->getModulateGlobalColor())) { // Concat the text - _CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr.toUtf8()); + _CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr); _CurrentViewLink->invalidateContent(); added = true; } @@ -2916,7 +2916,7 @@ namespace NLGUI newLink->setParamsOnLeftClick("name=" + getId() + "|url=" + newLink->Link); } } - newLink->setText(tmpStr.toUtf8()); + newLink->setText(tmpStr); newLink->setMultiLineSpace((uint)((float)(style.FontSize)*LineSpaceFontFactor)); newLink->setMultiLine(true); newLink->setModulateGlobalColor(style.GlobalColor); @@ -5475,7 +5475,7 @@ namespace NLGUI } } - ctrlButton->setText(ucstring::makeFromUtf8(value)); + ctrlButton->setText(value); setTextButtonStyle(ctrlButton, _Style.Current); } @@ -6449,7 +6449,7 @@ namespace NLGUI if (sb) { uint lineIndex = sb->getNumLine(); - sb->addLine(_SelectOptionStr, "", ""); + sb->addLine(_SelectOptionStr.toUtf8(), "", ""); if (_Forms.back().Entries.back().sbOptionDisabled == lineIndex) { diff --git a/nel/src/gui/group_list.cpp b/nel/src/gui/group_list.cpp index 4e04501a8..b94ff6a5f 100644 --- a/nel/src/gui/group_list.cpp +++ b/nel/src/gui/group_list.cpp @@ -521,7 +521,7 @@ namespace NLGUI if (NLMISC::startsWith(propPtr, "ui")) addTextChild(CI18N::get(propPtr)); else - addTextChild(ucstring::makeFromUtf8(propPtr)); + addTextChild(propPtr); } else { @@ -539,7 +539,7 @@ namespace NLGUI // ---------------------------------------------------------------------------- - void CGroupList::addTextChild(const ucstring& line, bool multiLine /*= true*/) + void CGroupList::addTextChild(const std::string& line, bool multiLine /*= true*/) { const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); @@ -548,7 +548,7 @@ namespace NLGUI view->setMultiLine (multiLine); view->setTextMode(_Templ.getTextMode()); if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line.toUtf8()); + view->setText (line); // Herit global-coloring view->setModulateGlobalColor(getModulateGlobalColor()); addChild(view); @@ -558,7 +558,7 @@ namespace NLGUI // ---------------------------------------------------------------------------- - void CGroupList::addTextChild(const ucstring& line, const CRGBA& textColor, bool multiLine /*= true*/) + void CGroupList::addTextChild(const std::string& line, const CRGBA& textColor, bool multiLine /*= true*/) { const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); @@ -566,7 +566,7 @@ namespace NLGUI view->_Parent = this; view->setMultiLine (multiLine); if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line.toUtf8()); + view->setText (line); view->setColor (textColor); // Herit global-coloring view->setModulateGlobalColor(getModulateGlobalColor()); @@ -1289,7 +1289,7 @@ namespace NLGUI ucstring text; if(CLuaIHM::pop(ls, text)) { - addTextChild(text); + addTextChild(text.toUtf8()); // FIXME: Lua UTF-8 } return 0; } @@ -1313,7 +1313,7 @@ namespace NLGUI uint b = (uint) ls.toInteger(4); uint a = (uint) ls.toInteger(5); - addTextChild(ucText, CRGBA(r, g, b, a)); + addTextChild(ucText.toUtf8(), CRGBA(r, g, b, a)); // FIXME: Lua UTF-8 return 0; } diff --git a/nel/src/gui/group_menu.cpp b/nel/src/gui/group_menu.cpp index 109baf278..77f73e18e 100644 --- a/nel/src/gui/group_menu.cpp +++ b/nel/src/gui/group_menu.cpp @@ -275,7 +275,7 @@ namespace NLGUI if (stricmp((char*)cur->name, "action") == 0) { string strId, strAh, strParams, strCond, strTexture; - ucstring ucstrName; + string ucstrName; if (id) strId = (const char*)id; CXMLAutoPtr name((const char*) xmlGetProp (cur, (xmlChar*)"name")); @@ -286,7 +286,7 @@ namespace NLGUI if (NLMISC::startsWith(ptrName, "ui")) ucstrName = CI18N::get(ptrName); else - ucstrName.fromUtf8(ptrName); + ucstrName = ptrName; } CXMLAutoPtr ah((const char*) xmlGetProp (cur, (xmlChar*)"handler")); @@ -1215,7 +1215,7 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ - CViewTextMenu* CGroupSubMenu::addLine (const ucstring &name, const std::string &ah, + CViewTextMenu* CGroupSubMenu::addLine (const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id, const std::string &cond, const std::string &texture, bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */ @@ -1231,11 +1231,11 @@ namespace NLGUI { pV->setMultiLine (true); pV->setMultiLineMaxWOnly (true); - pV->setTextFormatTaged (name.toUtf8()); + pV->setTextFormatTaged (name); } else { - pV->setText (name.toUtf8()); + pV->setText (name); } pV->setColor (_GroupMenu->_Color); pV->setFontSize (_GroupMenu->_FontSize, _GroupMenu->_FontSizeCoef); @@ -1296,7 +1296,7 @@ namespace NLGUI return pV; } - CViewTextMenu* CGroupSubMenu::addLineAtIndex(uint index, const ucstring &name, const std::string &ah, + CViewTextMenu* CGroupSubMenu::addLineAtIndex(uint index, const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id /*=""*/, const std::string &cond /*=std::string()*/, const std::string &texture, bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */ @@ -1319,11 +1319,11 @@ namespace NLGUI { pV->setMultiLine (true); pV->setMultiLineMaxWOnly (true); - pV->setTextFormatTaged (name.toUtf8()); + pV->setTextFormatTaged (name); } else { - pV->setText (name.toUtf8()); + pV->setText (name); } pV->setColor (_GroupMenu->_Color); @@ -1602,7 +1602,7 @@ namespace NLGUI texture = _Lines[k].ViewText->getCheckBox()->getTexture(); } CViewTextMenu *pV = NULL; - pV = copyMenu->addLine (CUtfStringView(_Lines[k].ViewText->getText()).toUtf16(), _Lines[k].AHName, _Lines[k].AHParams, _Lines[k].Id, _Lines[k].Cond, + pV = copyMenu->addLine (_Lines[k].ViewText->getText(), _Lines[k].AHName, _Lines[k].AHParams, _Lines[k].Id, _Lines[k].Cond, texture, _Lines[k].ViewText->getCheckable(), _Lines[k].ViewText->getChecked(), _Lines[k].ViewText->getFormatted ()); copyMenu->_Lines[k].Selectable = _Lines[k].Selectable; pV->setGrayed(_Lines[k].ViewText->getGrayed()); @@ -1858,8 +1858,8 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); ucstring arg1; - nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); - addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4)); + nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); // FIXME: Lua UTF-8 + addLine(arg1.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4)); return 0; } @@ -1874,8 +1874,8 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); ucstring arg1; - nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); - addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5)); + nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); // FIXME: Lua UTF-8 + addLine(arg1.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5)); return 0; } @@ -1890,8 +1890,8 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); ucstring arg2; - nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); - addLineAtIndex((uint) ls.toInteger(1), arg2, ls.toString(3), ls.toString(4), ls.toString(5)); + nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); // FIXME: Lua UTF-8 + addLineAtIndex((uint) ls.toInteger(1), arg2.toUtf8(), ls.toString(3), ls.toString(4), ls.toString(5)); return 0; } @@ -2532,25 +2532,7 @@ namespace NLGUI } // ------------------------------------------------------------------------------------------------ - void CGroupMenu::addLine (const string &name, const string &ah, const string ¶ms, - const std::string &id/*=std::string()*/, - const std::string &cond /*= std::string()*/, const std::string &texture, - bool checkable /*= false*/, bool checked /*= false*/ - ) - { - if (_RootMenu == NULL) - { - _RootMenu = new CGroupSubMenu(CViewText::TCtorParam()); - _RootMenu->_GroupMenu = this; - _RootMenu->setSerializable( false ); - addGroup (_RootMenu); - } - - _RootMenu->addLine (name, ah, params, id, cond, texture, checkable, checked, _Formatted); - } - - // ------------------------------------------------------------------------------------------------ - void CGroupMenu::addLine(const ucstring &name, const std::string &ah, const std::string ¶ms, + void CGroupMenu::addLine(const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id /* = std::string()*/, const std::string &cond /*= std::string()*/, const std::string &texture, bool checkable /*= false*/, bool checked /*= false*/ @@ -2566,7 +2548,7 @@ namespace NLGUI _RootMenu->addLine (name, ah, params, id, cond, texture, checkable, checked, _Formatted); } // ------------------------------------------------------------------------------------------------ - void CGroupMenu::addLineAtIndex(uint index, const ucstring &name, const std::string &ah, + void CGroupMenu::addLineAtIndex(uint index, const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id /*=std::string()*/, const std::string &cond /*=std::string()*/, const std::string &texture, bool checkable /*=false*/, bool checked /*=false*/) diff --git a/nel/src/gui/group_paragraph.cpp b/nel/src/gui/group_paragraph.cpp index f2027a404..a4c2a6da7 100644 --- a/nel/src/gui/group_paragraph.cpp +++ b/nel/src/gui/group_paragraph.cpp @@ -479,7 +479,7 @@ namespace NLGUI if (NLMISC::startsWith(propPtr, "ui")) addTextChild(CI18N::get(propPtr)); else - addTextChild(ucstring::makeFromUtf8(propPtr)); + addTextChild(propPtr); } else { @@ -495,7 +495,7 @@ namespace NLGUI } // ---------------------------------------------------------------------------- - void CGroupParagraph::addTextChild(const ucstring& line, bool multiLine /*= true*/) + void CGroupParagraph::addTextChild(const std::string& line, bool multiLine /*= true*/) { const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); @@ -503,7 +503,7 @@ namespace NLGUI view->setMultiLine (multiLine); view->setTextMode(_Templ.getTextMode()); if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line.toUtf8()); + view->setText (line); // Herit global-coloring view->setModulateGlobalColor(getModulateGlobalColor()); addChild (view); @@ -513,14 +513,14 @@ namespace NLGUI // ---------------------------------------------------------------------------- - void CGroupParagraph::addTextChild(const ucstring& line, const CRGBA& textColor, bool multiLine /*= true*/) + void CGroupParagraph::addTextChild(const std::string& line, const CRGBA& textColor, bool multiLine /*= true*/) { const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); view->_Parent = this; view->setMultiLine (multiLine); if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line.toUtf8()); + view->setText (line); view->setColor (textColor); // Herit global-coloring view->setModulateGlobalColor(getModulateGlobalColor()); diff --git a/nel/src/gui/group_tree.cpp b/nel/src/gui/group_tree.cpp index 93e9880bb..674da9546 100644 --- a/nel/src/gui/group_tree.cpp +++ b/nel/src/gui/group_tree.cpp @@ -309,7 +309,7 @@ namespace NLGUI if (NLMISC::startsWith(ptrName, "ui")) Text = CI18N::get(ptrName); else - ucstring::makeFromUtf8(ptrName); + Text = ptrName; } CXMLAutoPtr color((const char*) xmlGetProp (cur, (xmlChar*)"color")); @@ -1292,7 +1292,7 @@ namespace NLGUI CViewText *pVT = new CViewText(TCtorParam()); line.TextOrTemplate = pVT; pVT->setId("t"+toString(_Lines.size())); - pVT->setText(pNode->Text.toUtf8()); + pVT->setText(pNode->Text); pVT->setColor(pNode->Color); if(pNode->FontSize==-1) pVT->setFontSize(_FontSize); diff --git a/nel/src/gui/interface_expr.cpp b/nel/src/gui/interface_expr.cpp index 813962526..c83c1d722 100644 --- a/nel/src/gui/interface_expr.cpp +++ b/nel/src/gui/interface_expr.cpp @@ -548,7 +548,7 @@ namespace NLGUI case Boolean: return true; case Integer: setBool(_IntegerValue != 0); return true; case Double: setBool(_DoubleValue != 0); return true; - case String: return evalBoolean(_StringValue.toString().c_str()) != NULL; + case String: return evalBoolean(_StringValue.c_str()) != NULL; default: break; } return false; @@ -564,7 +564,7 @@ namespace NLGUI case Integer: return true; case Double: setInteger((sint64) _DoubleValue); return true; case String: - if (evalNumber(_StringValue.toString().c_str())) return toInteger(); + if (evalNumber(_StringValue.c_str())) return toInteger(); return false; case RGBA: setInteger((sint64) _RGBAValue); return true; default: break; @@ -581,7 +581,7 @@ namespace NLGUI case Integer: setDouble((double) _IntegerValue); return true; case Double: return true; case String: - if (evalNumber(_StringValue.toString().c_str())) return toBool(); + if (evalNumber(_StringValue.c_str())) return toBool(); return false; case RGBA: setDouble((double) _RGBAValue); return true; default: break; @@ -627,7 +627,7 @@ namespace NLGUI return true; case String: - setRGBA( NLMISC::CRGBA::stringToRGBA(_StringValue.toString().c_str())); + setRGBA( NLMISC::CRGBA::stringToRGBA(_StringValue.c_str())); return true; default: @@ -869,14 +869,15 @@ namespace NLGUI } //================================================================== - std::string CInterfaceExprValue::getString() const + const std::string &CInterfaceExprValue::getString() const { if (_Type != String) { nlwarning(" bad type!"); - return ""; + static const std::string empty; + return empty; } - return _StringValue.toString(); + return _StringValue; } //================================================================== @@ -895,19 +896,6 @@ namespace NLGUI return col; } - - //================================================================== - const ucstring &CInterfaceExprValue::getUCString() const - { - if (_Type != String) - { - nlwarning(" bad type!"); - static ucstring emptyString; - return emptyString; - } - return _StringValue; - } - //================================================================== CInterfaceExprUserType *CInterfaceExprValue::getUserType() const { diff --git a/nel/src/gui/interface_expr_user_fct.cpp b/nel/src/gui/interface_expr_user_fct.cpp index d0c687d26..7fc097f48 100644 --- a/nel/src/gui/interface_expr_user_fct.cpp +++ b/nel/src/gui/interface_expr_user_fct.cpp @@ -359,13 +359,13 @@ namespace NLGUI { if (!args.empty()) { - ucstring res; + string res; for (uint32 i = 0; i < args.size(); ++i) { args[i].toString(); - res += args[i].getUCString(); + res += args[i].getString(); } - result.setUCString (res); + result.setString (res); return true; } @@ -553,13 +553,13 @@ namespace NLGUI result.setString ((elem->*(pRP->GetMethod.GetString))()); break; case CReflectedProperty::UCString: - result.setUCString ((elem->*(pRP->GetMethod.GetUCString))()); + result.setString ((elem->*(pRP->GetMethod.GetUCString))().toUtf8()); break; case CReflectedProperty::StringRef: result.setString ((elem->*(pRP->GetMethod.GetStringRef))()); break; case CReflectedProperty::UCStringRef: - result.setUCString ((elem->*(pRP->GetMethod.GetUCStringRef))()); + result.setString ((elem->*(pRP->GetMethod.GetUCStringRef))().toUtf8()); break; case CReflectedProperty::RGBA: result.setRGBA ((elem->*(pRP->GetMethod.GetRGBA))()); @@ -1072,7 +1072,7 @@ namespace NLGUI } sint64 nVal = args[0].getInteger(); - ucstring sTmp; + string sTmp; if (nVal < 0) nVal = 0; @@ -1099,7 +1099,7 @@ namespace NLGUI } } - result.setUCString(sTmp); + result.setString(sTmp); return true; } @@ -1121,7 +1121,7 @@ namespace NLGUI } sint64 nVal = args[0].getInteger(); - ucstring sTmp; + string sTmp; if (nVal < 0) nVal = 0; @@ -1150,7 +1150,7 @@ namespace NLGUI } } - result.setUCString(sTmp); + result.setString(sTmp); return true; } @@ -1186,7 +1186,7 @@ namespace NLGUI nlwarning("localize : 1 arg required"); return false; } - result.setUCString(CI18N::get(args[0].getString())); + result.setString(CI18N::get(args[0].getString())); return true; } REGISTER_INTERFACE_USER_FCT("localize", localize); diff --git a/nel/src/gui/interface_link.cpp b/nel/src/gui/interface_link.cpp index 03a1212d3..1cad39c94 100644 --- a/nel/src/gui/interface_link.cpp +++ b/nel/src/gui/interface_link.cpp @@ -121,7 +121,7 @@ namespace NLGUI case CReflectedProperty::UCStringRef: if (valueToAffect.toString()) { - (destElem.*(property.SetMethod.SetUCString))(valueToAffect.getUCString()); + (destElem.*(property.SetMethod.SetUCString))(ucstring::makeFromUtf8(valueToAffect.getString())); } else { diff --git a/nel/src/gui/lua_ihm.cpp b/nel/src/gui/lua_ihm.cpp index 908898e74..c915a8671 100644 --- a/nel/src/gui/lua_ihm.cpp +++ b/nel/src/gui/lua_ihm.cpp @@ -1145,34 +1145,8 @@ namespace NLGUI ls.push(value.getDouble()); break; case CInterfaceExprValue::String: - { - ucstring ucstr= value.getUCString(); - // Yoyo: dynamically decide whether must return a string or a ucstring - bool mustUseUCString= false; - for (uint i = 0; i < ucstr.size (); i++) - { - if (ucstr[i] > 255) - { - mustUseUCString= true; - break; - } - } - // push a ucstring? - if(mustUseUCString) - { - #if LUABIND_VERSION > 600 - luabind::detail::push(ls.getStatePointer(), ucstr); - #else - luabind::object obj(ls.getStatePointer(), ucstr); - obj.pushvalue(); - #endif - } - else - { - ls.push(ucstr.toString()); - } - break; - } + ls.push(value.getString()); + break; case CInterfaceExprValue::RGBA: { CRGBA color = value.getRGBA(); diff --git a/nel/src/gui/view_pointer.cpp b/nel/src/gui/view_pointer.cpp index 973708aa6..3c319c228 100644 --- a/nel/src/gui/view_pointer.cpp +++ b/nel/src/gui/view_pointer.cpp @@ -250,7 +250,7 @@ namespace NLGUI if (vLink->getMouseOverShape(tooltip, rot, col)) { - setString(ucstring::makeFromUtf8(tooltip)); + setString(tooltip); sint32 texId = rVR.getTextureIdFromName ("curs_pick.tga"); CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; @@ -406,7 +406,7 @@ namespace NLGUI splitString(tooltipInfos, "@", tooltipInfosList); texName = tooltipInfosList[0]; tooltip = tooltipInfosList[1]; - setString(ucstring::makeFromUtf8(tooltip)); + setString(tooltip); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 texId = rVR.getTextureIdFromName (texName); @@ -449,7 +449,7 @@ namespace NLGUI } // -------------------------------------------------------------------------------------------------------------------- - void CViewPointer::setString (const ucstring &str, CInterfaceGroup *target) + void CViewPointer::setString(const std::string &str, CInterfaceGroup *target) { if (target) { @@ -458,14 +458,14 @@ namespace NLGUI { CViewText *text = dynamic_cast (element); if (text) - text->setText(str.toUtf8()); + text->setText(str); } element = target->getView ("real_txt"); if (element) { CViewText *text = dynamic_cast (element); if (text) - text->setText(str.toUtf8()); + text->setText(str); } target->updateCoords(); target->updateCoords(); @@ -475,7 +475,7 @@ namespace NLGUI // -------------------------------------------------------------------------------------------------------------------- - void CViewPointer::setString (const ucstring &str) + void CViewPointer::setString (const std::string &str) { if (_ContextString != str) { diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp index 69b117330..b5744925f 100644 --- a/nel/src/gui/view_text.cpp +++ b/nel/src/gui/view_text.cpp @@ -3207,7 +3207,7 @@ namespace NLGUI // *************************************************************************** - void CViewText::buildFormatTagText(const std::string &text, std::string &textBuild, std::vector &formatTags, std::vector &tooltips) + void CViewText::buildFormatTagText(const std::string &text, std::string &textBuild, std::vector &formatTags, std::vector &tooltips) { formatTags.clear(); tooltips.clear(); @@ -3243,7 +3243,7 @@ namespace NLGUI // get old tag. CViewText::CFormatTag ct= precTag; // get new Tab and skip tag. - ucstring uitt = getTooltipTag(text, i); + string uitt = getTooltipTag(text, i); if (uitt.empty()) { ct.IndexTt= -1; @@ -3296,7 +3296,7 @@ namespace NLGUI std::string tempText; // static to avoid reallocation static std::vector tempFormatTags; - static std::vector tempTooltips; + static std::vector tempTooltips; buildFormatTagText(text, tempText, tempFormatTags, tempTooltips); setCase (tempText, _CaseMode); @@ -3344,7 +3344,7 @@ namespace NLGUI pTooltip->setId(_Id+"_tt"+toString(i)); pTooltip->setAvoidResizeParent(avoidResizeParent()); pTooltip->setRenderLayer(getRenderLayer()); - std::string tempTooltipStr = tempTooltips[i].toUtf8(); + std::string tempTooltipStr = tempTooltips[i]; bool isI18N = NLMISC::startsWith(tempTooltipStr, "ui"); pTooltip->setDefaultContextHelp(isI18N ? CI18N::get(tempTooltipStr) : tempTooltipStr); pTooltip->setParentPos(this); @@ -3390,7 +3390,7 @@ namespace NLGUI // to allow cache (avoid infinite recurse in updateCoords() in some case), compute in temp std::string tempText; static std::vector tempLetterColors; - static std::vector tempTooltips; + static std::vector tempTooltips; // parse text buildFormatTagText(text, tempText, tempLetterColors, tempTooltips); diff --git a/nel/src/gui/view_text_formated.cpp b/nel/src/gui/view_text_formated.cpp index 87cfc12bb..dfd57eadf 100644 --- a/nel/src/gui/view_text_formated.cpp +++ b/nel/src/gui/view_text_formated.cpp @@ -38,7 +38,7 @@ namespace NLGUI { if (name == "format") { - return getFormatString().toUtf8(); + return getFormatString(); } else return CViewText::getProperty(name); @@ -48,7 +48,7 @@ namespace NLGUI { if (name == "format") { - setFormatString(ucstring::makeFromUtf8(value)); + setFormatString(value); return; } else @@ -62,7 +62,7 @@ namespace NLGUI return NULL; xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_formated" ); - xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().toUtf8().c_str() ); + xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().c_str() ); return NULL; } @@ -73,9 +73,9 @@ namespace NLGUI if (!CViewText::parse(cur, parentGroup)) return false; CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); if (prop) - setFormatString(ucstring::makeFromUtf8((const char *)prop)); + setFormatString((const char *)prop); else - setFormatString(ucstring("$t")); + setFormatString("$t"); return true; } @@ -83,26 +83,27 @@ namespace NLGUI void CViewTextFormated::checkCoords() { if (!getActive()) return; - ucstring formatedResult; - formatedResult = formatString(_FormatString, ucstring("")); + std::string formatedResult; + formatedResult = formatString(_FormatString, std::string()); // - setText (formatedResult.toUtf8()); + setText (formatedResult); CViewText::checkCoords(); } // **************************************************************************** - void CViewTextFormated::setFormatString(const ucstring &format) + void CViewTextFormated::setFormatString(const std::string &format) { - _FormatString = format; - if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) - _FormatString = NLMISC::CI18N::get (format.toString()); + if (NLMISC::startsWith(format, "ui")) + _FormatString = NLMISC::CI18N::get(format); + else + _FormatString = format; } // **************************************************************************** - ucstring CViewTextFormated::formatString(const ucstring &inputString, const ucstring ¶mString) + std::string CViewTextFormated::formatString(const std::string &inputString, const std::string ¶mString) { - ucstring formatedResult; + std::string formatedResult; if( textFormatter == NULL ) formatedResult = inputString; diff --git a/nel/src/gui/view_text_id.cpp b/nel/src/gui/view_text_id.cpp index 065d02e71..1f1ac5440 100644 --- a/nel/src/gui/view_text_id.cpp +++ b/nel/src/gui/view_text_id.cpp @@ -204,7 +204,7 @@ namespace NLGUI if (!_Initialized) { // String result - ucstring result; + string result; if( textProvider != NULL ) { @@ -218,8 +218,8 @@ namespace NLGUI // Remove all {break} for(;;) { - ucstring::size_type index = result.find (ucstring("{break}")); - if (index == ucstring::npos) break; + string::size_type index = result.find("{break}"); + if (index == string::npos) break; result = result.substr (0, index) + result.substr(index+7, result.size()); } @@ -229,13 +229,13 @@ namespace NLGUI // Modify the text? if(_StringModifier) - _StringModifier->onReceiveTextId(result); + _StringModifier->onReceiveTextId(ucstring::makeFromUtf8(result)); // Set the Text if(_IsTextFormatTaged) - setTextFormatTaged(result.toUtf8()); + setTextFormatTaged(result); else - setText (result.toUtf8()); + setText(result); } CViewText::checkCoords(); } diff --git a/nel/src/gui/view_text_id_formated.cpp b/nel/src/gui/view_text_id_formated.cpp index 5b1dd2a14..88f9a58e0 100644 --- a/nel/src/gui/view_text_id_formated.cpp +++ b/nel/src/gui/view_text_id_formated.cpp @@ -37,7 +37,7 @@ namespace NLGUI { if (name == "format") { - return getFormatString().toUtf8(); + return getFormatString(); } else return CViewTextID::getProperty(name); @@ -47,7 +47,7 @@ namespace NLGUI { if (name == "format") { - setFormatString(ucstring::makeFromUtf8(value)); + setFormatString(value); return; } else @@ -61,7 +61,7 @@ namespace NLGUI return NULL; xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_id_formated" ); - xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().toUtf8().c_str() ); + xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().c_str() ); return node; } @@ -72,9 +72,9 @@ namespace NLGUI if (!CViewTextID::parse(cur, parentGroup)) return false; CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); if (prop) - setFormatString(ucstring::makeFromUtf8((const char *)prop)); + setFormatString((const char *)prop); else - setFormatString(ucstring("$t")); + setFormatString("$t"); return true; } @@ -89,15 +89,15 @@ namespace NLGUI if (!_Initialized) { - ucstring result, formatedResult; + std::string result, formatedResult; bool bValid; if( CViewTextID::getTextProvider() == NULL ) { if(!_DBPath.empty()) - result = ucstring(_DBPath); + result = _DBPath; else - result = ucstring("Text ID = " + NLMISC::toString(_TextId)); + result = "Text ID = " + NLMISC::toString(_TextId); bValid = true; } else @@ -106,7 +106,7 @@ namespace NLGUI } formatedResult = CViewTextFormated::formatString(_FormatString, result); // - setText (formatedResult.toUtf8()); + setText (formatedResult); // if (bValid) { @@ -117,12 +117,13 @@ namespace NLGUI } // **************************************************************************** - void CViewTextIDFormated::setFormatString(const ucstring &format) + void CViewTextIDFormated::setFormatString(const std::string &format) { _Initialized = false; - _FormatString = format; - if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) - _FormatString = NLMISC::CI18N::get (format.toString()); + if (NLMISC::startsWith(format, "ui")) + _FormatString = NLMISC::CI18N::get(format); + else + _FormatString = format; } } diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index 39493495f..b6370602e 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -1350,7 +1350,7 @@ void setTarget(CCtrlBase *ctrl, const string &targetName, ucstring &value) if (ig) { CInterfaceExprValue exprValue; - exprValue.setUCString(value); + exprValue.setString(value.toUtf8()); CInterfaceLink::splitLinkTargets(targetName, ig, targets); for(uint k = 0; k < targets.size(); ++k) diff --git a/ryzom/client/src/contextual_cursor.cpp b/ryzom/client/src/contextual_cursor.cpp index 15dd6a17a..11398f620 100644 --- a/ryzom/client/src/contextual_cursor.cpp +++ b/ryzom/client/src/contextual_cursor.cpp @@ -162,7 +162,7 @@ bool CContextualCursor::context(const std::string &contextName, float dist, cons if(cursName.empty()) cursor->setString(CI18N::get(functions.cursor)); else - cursor->setString(cursName); + cursor->setString(cursName.toUtf8()); } } } diff --git a/ryzom/client/src/interface_v3/action_handler_game.cpp b/ryzom/client/src/interface_v3/action_handler_game.cpp index 4281181a9..dacb6f100 100644 --- a/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -2074,9 +2074,9 @@ class CActionHandlerSetTargetName : public IActionHandler // Set to target CInterfaceExprValue evUCStr; TargetName = STRING_MANAGER::CStringManagerClient::getLocalizedName(TargetName); - evUCStr.setUCString(TargetName); + evUCStr.setString(TargetName.toUtf8()); CInterfaceLink::setTargetProperty(sNameTarget, evUCStr); - evUCStr.setUCString(TargetTitle); + evUCStr.setString(TargetTitle.toUtf8()); CInterfaceLink::setTargetProperty(sTitleTarget, evUCStr); } } diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 2d6a7e6f5..23992f4f6 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -2046,9 +2046,7 @@ class CHandlerItemMenuCheck : public IActionHandler std::string name = groupNames[i]; std::string ahParams = "name=" + name; //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(name); - pGroupMenu->addLine(nameUC, "", "", name); + pGroupMenu->addLine(name, "", "", name); CGroupSubMenu* pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam()); pGroupMenu->setSubMenu(pGroupMenu->getNumLine()-1, pNewSubMenu); if(pNewSubMenu) @@ -2074,7 +2072,7 @@ class CHandlerItemMenuCheck : public IActionHandler { //there is an offset of 1 because TInventory names are pet_animal1/2/3/4 std::string dst = toString("destination=pet_animal%d|", j + 1); - CViewTextMenu* tmp = pNewSubMenu->addLine(ucstring(pMoveToPa[j]->getHardText()),"item_group_move", dst + ahParams, name + toString("_pa%d", j + 1)); + CViewTextMenu* tmp = pNewSubMenu->addLine(pMoveToPa[j]->getHardText(),"item_group_move", dst + ahParams, name + toString("_pa%d", j + 1)); if(tmp) tmp->setGrayed(pMoveToPa[j]->getGrayed()); } } diff --git a/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/ryzom/client/src/interface_v3/action_handler_phrase.cpp index a73d884e8..f55d376bd 100644 --- a/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -1668,7 +1668,7 @@ static DECLARE_INTERFACE_USER_FCT(getSPhraseName) return false; sint sphraseId= (sint)args[0].getInteger(); CSPhraseManager *pPM= CSPhraseManager::getInstance(); - result.setUCString(pPM->getPhrase(sphraseId).Name); + result.setString(pPM->getPhrase(sphraseId).Name.toUtf8()); return true; } else diff --git a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index 8fa8bd08e..4c67b70b3 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -2575,11 +2575,11 @@ static DECLARE_INTERFACE_USER_FCT(getPriceWithFame) sint value= (sint)args[0].getInteger(); sint valueFame= (sint)args[1].getInteger(); if(value==-1) - result.setUCString(CI18N::get("uiBadPrice")); + result.setString(CI18N::get("uiBadPrice")); else if(value==valueFame) - result.setUCString(NLMISC::formatThousands(toString(value))); + result.setString(NLMISC::formatThousands(toString(value))); else - result.setUCString(NLMISC::formatThousands(toString(valueFame)) + " (" + NLMISC::formatThousands(toString(value)) + ")"); + result.setString(NLMISC::formatThousands(toString(valueFame)) + " (" + NLMISC::formatThousands(toString(value)) + ")"); return true; } @@ -2595,7 +2595,7 @@ static DECLARE_INTERFACE_USER_FCT(getBonusOnResale) sint valueHigh= (sint)args[0].getInteger(); sint valueLow= (sint)args[1].getInteger(); sint diff = valueHigh - valueLow; - result.setUCString("+" + NLMISC::formatThousands(toString(diff))); + result.setString("+" + NLMISC::formatThousands(toString(diff))); return true; } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp index da46e9e7b..f008c32f1 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp @@ -56,7 +56,7 @@ CViewText *CDBGroupListSheetMission::CSheetChildMission::createViewText() const CViewTextIDFormated *vti = new CViewTextIDFormated(CViewBase::TCtorParam()); if (Ctrl) vti->setDBLeaf(dynamic_cast(Ctrl->getRootBranch()->getNode(ICDBNode::CTextId("TEXT")))); else vti->setDBLeaf(NULL); - vti->setFormatString(ucstring("$t")); + vti->setFormatString("$t"); return vti; } diff --git a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index 6ab68522d..c9912325f 100644 --- a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -205,7 +205,7 @@ void CEncyclopediaManager::rebuildAlbumList() if (_Albums[i].Name == _AlbumNameSelected) pAlb->Opened = true; if (pSMC->getDynString(_Albums[i].Name, res)) - pAlb->Text = res; + pAlb->Text = res.toUtf8(); else nlwarning("try to construct album without name"); @@ -217,7 +217,7 @@ void CEncyclopediaManager::rebuildAlbumList() pThm->AHName = "ency_click_thema"; pThm->AHParams = toString(_Albums[i].Themas[j].Name); if (pSMC->getDynString(_Albums[i].Themas[j].Name, res)) - pThm->Text = res; + pThm->Text = res.toUtf8(); else nlwarning("try to construct thema without name"); diff --git a/ryzom/client/src/interface_v3/group_compas.cpp b/ryzom/client/src/interface_v3/group_compas.cpp index b43f50a89..f7418e868 100644 --- a/ryzom/client/src/interface_v3/group_compas.cpp +++ b/ryzom/client/src/interface_v3/group_compas.cpp @@ -710,7 +710,7 @@ void CGroupCompasMenu::setActive (bool state) ct.setType(CCompassTarget::North); ct.Name = CI18N::get("uiNorth"); Targets.push_back(ct); - getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name, "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); + getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name.toUtf8(), "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); // Home CCDBNodeLeaf *pos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":HOME_POINT"); sint32 px = (sint32) (pos->getValue64() >> 32); @@ -720,7 +720,7 @@ void CGroupCompasMenu::setActive (bool state) ct.setType(CCompassTarget::Home); ct.Name = CI18N::get("uiHome"); Targets.push_back(ct); - getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name, "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); + getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name.toUtf8(), "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); } // Respawn pos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":BIND_POINT"); @@ -731,7 +731,7 @@ void CGroupCompasMenu::setActive (bool state) ct.setType(CCompassTarget::Respawn); ct.Name = CI18N::get("uiRespawn"); Targets.push_back(ct); - getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name, "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); + getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name.toUtf8(), "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); } // As of 6/5/2007 : The option to point the selection is always proposed even if no slot is currently targeted @@ -741,7 +741,7 @@ void CGroupCompasMenu::setActive (bool state) if (entity != NULL) {*/ //ucstring targetName = CI18N::get("uiTargetTwoPoint") + entity->removeTitleAndShardFromName(entity->getEntityName()); - ucstring targetName = CI18N::get("uiTarget"); + std::string targetName = CI18N::get("uiTarget"); ct.setType(CCompassTarget::Selection); ct.Name = targetName; Targets.push_back(ct); @@ -789,7 +789,7 @@ void CGroupCompasMenu::setActive (bool state) ct.setPositionState(tracker); ct.Name = name; Targets.push_back(ct); - missionSubMenu->addLine(ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); + missionSubMenu->addLine(ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); selectable= true; } } @@ -846,7 +846,7 @@ void CGroupCompasMenu::setActive (bool state) ct.Pos = currCont->ContLandMarks[k].Pos; ct.Name = CStringManagerClient::getPlaceLocalizedName(currCont->ContLandMarks[k].TitleTextID); Targets.push_back(ct); - landMarkSubMenu->addLineAtIndex(contLandMarkIndex++, ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); + landMarkSubMenu->addLineAtIndex(contLandMarkIndex++, ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); selectable= true; } // separator? @@ -869,7 +869,7 @@ void CGroupCompasMenu::setActive (bool state) ct.Pos = sortedLandmarks[k].Pos; ct.Name = sortedLandmarks[k].Title; Targets.push_back(ct); - landMarkSubMenus[sortedLandmarks[k].Type]->addLine(ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); + landMarkSubMenus[sortedLandmarks[k].Type]->addLine(ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); selectable= true; } } @@ -900,7 +900,7 @@ void CGroupCompasMenu::setActive (bool state) if (buildCompassTargetFromTeamMember(ct, k)) { Targets.push_back(ct); - teamSubMenu->addLine(ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); + teamSubMenu->addLine(ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); selectable= true; } } @@ -923,7 +923,7 @@ void CGroupCompasMenu::setActive (bool state) if (buildCompassTargetFromAnimalMember(ct, k)) { Targets.push_back(ct); - animalSubMenu->addLine(ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); + animalSubMenu->addLine(ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); selectable= true; } } @@ -951,7 +951,7 @@ void CGroupCompasMenu::setActive (bool state) CSmartPtr tracker = new CDialogEntityPositionState( i ); ct.setPositionState(tracker); Targets.push_back(ct); - dialogsSubMenu->addLine(ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); + dialogsSubMenu->addLine(ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); selectable= true; } } diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp index ac70c57cc..d7d68477f 100644 --- a/ryzom/client/src/interface_v3/group_map.cpp +++ b/ryzom/client/src/interface_v3/group_map.cpp @@ -3811,7 +3811,7 @@ void CGroupMap::updateClosestLandMarkMenu(const std::string &menu, const NLMISC: std::string lineId = toString("%s:lmcosest%d", menu.c_str(), i); std::string ahParams = toString("type=user|map=%s|index=%d", _Id.c_str(), index); - CViewTextMenu* vt = rootMenu->addLine(ucstring(""), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false); + CViewTextMenu* vt = rootMenu->addLine(std::string(), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false); if (!vt) break; vt->setSingleLineTextFormatTaged(name.toUtf8()); 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 04d05e6f2..62d96280f 100644 --- a/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -224,7 +224,7 @@ void CGroupPhraseSkillFilter::rebuild() // just text pNode->DisplayText = true; pNode->Template = NULL; - pNode->Text= STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i);; + pNode->Text = CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i)).toUtf8(); // 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 053bddf86..4248ea898 100644 --- a/ryzom/client/src/interface_v3/group_skills.cpp +++ b/ryzom/client/src/interface_v3/group_skills.cpp @@ -245,11 +245,11 @@ static DECLARE_INTERFACE_USER_FCT(getSkillBaseText) if(skillValue!=skillBase) { - result.setUCString( toString("(%d)", skillBase) ); + result.setString( toString("(%d)", skillBase) ); } else { - result.setUCString( ucstring() ); + result.setString( std::string() ); } return true; @@ -335,7 +335,7 @@ void CGroupSkills::createAllTreeNodes() // local variable (avoid realloc in loop) vector< pair > tempVec(2); - ucstring sSkillName; + string sSkillName; while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop { @@ -365,7 +365,7 @@ void CGroupSkills::createAllTreeNodes() pNode->Id = NLMISC::toString(i); // get Skill Name - sSkillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i); + sSkillName = CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i)).toUtf8(); // just text or template? if(_TemplateSkill.empty()) @@ -387,7 +387,7 @@ void CGroupSkills::createAllTreeNodes() // Set Skill Name CViewText *pViewSkillName = dynamic_cast(pIG->getView("name")); if (pViewSkillName != NULL) - pViewSkillName->setText (sSkillName.toUtf8()); + pViewSkillName->setText (sSkillName); // Set Skill Max Value CViewText *pViewSkillMax = dynamic_cast(pIG->getView("max")); if (pViewSkillMax != NULL) 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 30126c0d9..82b928211 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 @@ -176,7 +176,7 @@ static DECLARE_INTERFACE_USER_FCT(getCompassText) "uiWNW", }; - result.setUCString( CI18N::get(txts[direction]) ); + result.setString( CI18N::get(txts[direction]) ); return true; } REGISTER_INTERFACE_USER_FCT("getCompassText", getCompassText); @@ -251,7 +251,7 @@ static DECLARE_INTERFACE_USER_FCT(getDifficultyText) } SENTENCE_APPRAISAL::ESentenceAppraisal sa = (SENTENCE_APPRAISAL::ESentenceAppraisal)args[0].getInteger(); - result.setUCString (CI18N::get(SENTENCE_APPRAISAL::toString(sa))); + result.setString (CI18N::get(SENTENCE_APPRAISAL::toString(sa))); return true; } @@ -665,14 +665,14 @@ static DECLARE_INTERFACE_USER_FCT(getKey) CActionsManager::TActionComboMap::const_iterator it = acmap.find(CAction::CName(name.c_str(),param.c_str())); if (it != acmap.end()) { - result.setUCString (it->second.toUCString()); + result.setString (it->second.toUCString().toUtf8()); } else { if (notna) - result.setUCString (ucstring("")); + result.setString (std::string()); else - result.setUCString (CI18N::get("uiNotAssigned")); + result.setString (CI18N::get("uiNotAssigned")); } return true; @@ -1025,9 +1025,9 @@ static DECLARE_INTERFACE_USER_FCT(getBotChatBuyFilterMPText) RM_FABER_TYPE::TRMFType faberType= (RM_FABER_TYPE::TRMFType)args[0].getInteger(); if(faberType>=RM_FABER_TYPE::Unknown) - result.setUCString(CI18N::get("uittBCNoItemPartFilter")); + result.setString(CI18N::get("uittBCNoItemPartFilter")); else - result.setUCString(RM_FABER_TYPE::toLocalString(faberType)); + result.setString(RM_FABER_TYPE::toLocalString(faberType)); return true; } @@ -1076,15 +1076,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostName) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getOutpostLocalizedName(CSheetId(nSheet))); + const std::string name = CUtfStringView(pSMC->getOutpostLocalizedName(CSheetId(nSheet))).toUtf8(); - result.setUCString(name); + result.setString(name); return true; } @@ -1103,15 +1103,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostDesc) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getOutpostLocalizedDescription(CSheetId(nSheet))); + const string name = CUtfStringView(pSMC->getOutpostLocalizedDescription(CSheetId(nSheet))).toUtf8(); - result.setUCString(name); + result.setString(name); return true; } @@ -1130,15 +1130,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingName) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet))); + const string name = CUtfStringView(pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet))).toUtf8(); - result.setUCString(name); + result.setString(name); return true; } @@ -1157,12 +1157,12 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name - ucstring name; + string name; CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet)); COutpostBuildingSheet *pOBS = dynamic_cast(pSheet); if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty) @@ -1173,11 +1173,11 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc) else { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - name = pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet)); + name = CUtfStringView(pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet))).toUtf8(); } - result.setUCString(name); + result.setString(name); return true; } @@ -1196,15 +1196,15 @@ static DECLARE_INTERFACE_USER_FCT(getSquadName) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getSquadLocalizedName(CSheetId(nSheet))); + const string name = CUtfStringView(pSMC->getSquadLocalizedName(CSheetId(nSheet))).toUtf8(); - result.setUCString(name); + result.setString(name); return true; } @@ -1223,15 +1223,15 @@ static DECLARE_INTERFACE_USER_FCT(getSquadDesc) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getSquadLocalizedDescription(CSheetId(nSheet))); + const string name = CUtfStringView(pSMC->getSquadLocalizedDescription(CSheetId(nSheet))).toUtf8(); - result.setUCString(name); + result.setString(name); return true; } @@ -1284,7 +1284,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) // if status wanted is peace or unknow, then "N/A", because there is no attack period in peace mode if( status==OUTPOSTENUMS::Peace || status==OUTPOSTENUMS::UnknownOutpostState ) { - result.setUCString(string(" - ")); + result.setString(string(" - ")); return true; } @@ -1292,7 +1292,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) if( (isAttackPeriod && status>OUTPOSTENUMS::AttackRound) || (!isAttackPeriod && status>OUTPOSTENUMS::DefenseRound) ) { - result.setUCString(CI18N::get("uiOutpostPeriodEnded")); + result.setString(CI18N::get("uiOutpostPeriodEnded")); return true; } @@ -1312,7 +1312,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) tstruct= gmtime(&tval); if(!tstruct) { - result.setUCString(string("Bad Date Received")); + result.setString(string("Bad Date Received")); return true; } dname= tstruct->tm_wday; // 0-6 (Sunday==0!!) @@ -1325,21 +1325,21 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) tstruct= gmtime(&tval); if(!tstruct) { - result.setUCString(string("Bad Date Received")); + result.setString(string("Bad Date Received")); return true; } hend= tstruct->tm_hour; // 0-23 mend= tstruct->tm_min; // 0-59 // translate - ucstring res= CI18N::get("uiOutpostPeriodFormat"); + string res= CI18N::get("uiOutpostPeriodFormat"); strFindReplace( res, "%dayname", CI18N::get(toString("uiDay%d", dname)) ); strFindReplace( res, "%daynumber", toString(dnumber) ); strFindReplace( res, "%month", CI18N::get(toString("uiMonth%02d", month+1)) ); strFindReplace( res, "%timestart", toString("%02d:%02d", hstart, mstart) ); strFindReplace( res, "%timeend", toString("%02d:%02d", hend, mend) ); - result.setUCString(res); + result.setString(res); return true; } REGISTER_INTERFACE_USER_FCT("getOutpostPeriod", getOutpostPeriod) 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 9aeec4e5f..b686db2be 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 @@ -312,16 +312,16 @@ static DECLARE_INTERFACE_USER_FCT(getSheetName) // if from ctrlSheet, then take the correct ACTUAL name (ie from NAMEID if not 0) if(ctrlSheet) { - result.setUCString(ctrlSheet->getItemActualName()); + result.setString(ctrlSheet->getItemActualName().toUtf8()); return true; } // Standard (but less accurate) way else { const CItemSheet *itemSheet = getItemSheet(args); - ucstring tmp; - if (itemSheet != NULL) tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id); - result.setUCString(tmp); + string tmp; + if (itemSheet != NULL) tmp = CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id)).toUtf8(); + result.setString(tmp); return true; } } @@ -345,9 +345,9 @@ static DECLARE_INTERFACE_USER_FCT(getItemTranslatedName) return false; } - ucstring tmp; - tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet); - result.setUCString(tmp); + string tmp; + tmp = CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet)).toUtf8(); + result.setString(tmp); return true; } REGISTER_INTERFACE_USER_FCT("getItemTranslatedName", getItemTranslatedName) diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index 3bae5ccbc..089dc39d0 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -324,12 +324,12 @@ class CStringManagerTextProvider : public CViewTextID::IViewTextProvider class CRyzomTextFormatter : public CViewTextFormated::IViewTextFormatter { public: - ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) + std::string formatString( const std::string &inputString, const std::string ¶mString ) { - ucstring formatedResult; + std::string formatedResult; // Apply the format - for(ucstring::const_iterator it = inputString.begin(); it != inputString.end();) + for(std::string::const_iterator it = inputString.begin(); it != inputString.end();) { if (*it == '$') { @@ -347,13 +347,14 @@ public: case 'p': // add player name if (ClientCfg.Local) { - formatedResult += ucstring("player"); + if (*it == 'P') formatedResult += "PLAYER"; + else formatedResult += "Player"; } else { if(UserEntity) { - ucstring name = UserEntity->getEntityName(); + std::string name = UserEntity->getEntityName().toUtf8(); if (*it == 'P') name = toUpper(name); formatedResult += name; } @@ -363,11 +364,11 @@ public: case 's': case 'b': // add bot name { - ucstring botName; + string botName; bool womanTitle = false; if (ClientCfg.Local) { - botName = ucstring("NPC"); + botName = "NPC"; } else { @@ -387,7 +388,7 @@ public: } else { - botName = entity->getDisplayName(); + botName = entity->getDisplayName().toUtf8(); } CCharacterCL *pChar = dynamic_cast(entity); if (pChar != NULL) @@ -396,40 +397,40 @@ public: } } // get the title translated - ucstring sTitleTranslated = botName; + ucstring sTitleTranslated = botName; // FIXME: UTF-8 CStringPostProcessRemoveName spprn; spprn.Woman = womanTitle; spprn.cbIDStringReceived(sTitleTranslated); - botName = CEntityCL::removeTitleAndShardFromName(botName); + botName = CEntityCL::removeTitleAndShardFromName(botName).toUtf8(); // short name (with no title such as 'guard', 'merchant' ...) if (*it == 's') { // But if there is no name, display only the title if (botName.empty()) - botName = sTitleTranslated; + botName = sTitleTranslated.toUtf8(); } else { // Else we want the title ! if (!botName.empty()) botName += " "; - botName += sTitleTranslated; + botName += sTitleTranslated.toUtf8(); } formatedResult += botName; } break; default: - formatedResult += (ucchar) '$'; + formatedResult += '$'; break; } ++it; } else { - formatedResult += (ucchar) *it; + formatedResult += *it; ++it; } } @@ -2302,7 +2303,7 @@ void CInterfaceManager::addServerString (const std::string &sTarget, uint32 id, if (id == 0) { CInterfaceExprValue val; - val.setUCString (ucstring("")); + val.setString (std::string()); CInterfaceLink::setTargetProperty (sTarget, val); return; } @@ -2320,7 +2321,7 @@ void CInterfaceManager::addServerID (const std::string &sTarget, uint32 id, IStr if (id == 0) { CInterfaceExprValue val; - val.setUCString (ucstring("")); + val.setString (std::string()); CInterfaceLink::setTargetProperty (sTarget, val); return; } @@ -2367,7 +2368,7 @@ void CInterfaceManager::processServerIDString() if (bValid) { ucstrToAffect = STRING_MANAGER::CStringManagerClient::getLocalizedName(ucstrToAffect); - val.setUCString (ucstrToAffect); + val.setString (ucstrToAffect.toUtf8()); CInterfaceLink::setTargetProperty (pISW->Target, val); } @@ -3336,7 +3337,7 @@ void CInterfaceManager::initEmotes() translateEmote(sTmp, sTranslatedName, sCommandName, sCommandNameAlt); // Create a line - pMenu->addLine (sTranslatedName + " (/" + ucstring::makeFromUtf8(sCommandName) + ")", "emote", + pMenu->addLine (sTranslatedName.toUtf8() + " (/" + sCommandName + ")", "emote", "nb="+toString(nEmoteNb)+"|behav="+toString(nBehav), sTmp); } } @@ -3392,7 +3393,7 @@ void CInterfaceManager::initEmotes() { // Yeah that's a quick emote too; set command pMenu->addLineAtIndex (i, - "@{FFFF}/" + ucstring::makeFromUtf8(sCommandName), + "@{FFFF}/" + sCommandName, "emote", "nb="+toString(nEmoteNb)+"|behav="+toString(nBehav), "", "", "", false, false, true); diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index b36d51866..2efdf339b 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -269,7 +269,7 @@ static DECLARE_INTERFACE_USER_FCT(lua) if (CLuaIHM::pop(ls, ucstrVal)) { - result.setUCString(ucstrVal); + result.setString(ucstrVal.toUtf8()); ok = true; } diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp index e285bbaf9..3d23e31f2 100644 --- a/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/ryzom/client/src/interface_v3/people_interraction.cpp @@ -2593,7 +2593,7 @@ public: { for(uint l = 0; l < pl.PartyChats.size(); ++l) { - menu->addLineAtIndex(insertionIndex, pl.PartyChats[l].Window->getTitle(), "chat_target_selected", toString(pl.PartyChats[l].ID)); + menu->addLineAtIndex(insertionIndex, pl.PartyChats[l].Window->getTitle().toUtf8(), "chat_target_selected", toString(pl.PartyChats[l].ID)); ++ insertionIndex; } } @@ -2640,8 +2640,8 @@ public: STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); // replace dynamic channel name and shortcut - ucstring res = CI18N::get("uiFilterMenuDynamic"); - strFindReplace(res, "%channel", title); + string res = CI18N::get("uiFilterMenuDynamic"); + strFindReplace(res, "%channel", title.toUtf8()); strFindReplace(res, "%shortcut", s); pMenu->addLineAtIndex(5 + insertion_index, res, "chat_target_selected", "dyn"+s, "dyn"+s); @@ -2940,7 +2940,7 @@ class CHandlerSelectChatSource : public IActionHandler { if (pc[l].Filter != NULL) { - menu->addLineAtIndex(insertionIndex, pc[l].Window->getTitle(), FILTER_TOGGLE, toString(pc[l].ID)); + menu->addLineAtIndex(insertionIndex, pc[l].Window->getTitle().toUtf8(), FILTER_TOGGLE, toString(pc[l].ID)); menu->setUserGroupLeft(insertionIndex, createMenuCheckBox(FILTER_TOGGLE, toString(pc[l].ID), pc[l].Filter->isListeningWindow(cw))); ++ insertionIndex; } @@ -2956,7 +2956,7 @@ class CHandlerSelectChatSource : public IActionHandler { ucstring title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); - menu->addLineAtIndex(insertionIndex, "["+s+"] " + title, FILTER_TOGGLE, "dyn"+s); + menu->addLineAtIndex(insertionIndex, "["+s+"] " + title.toUtf8(), FILTER_TOGGLE, "dyn"+s); menu->setUserGroupLeft(insertionIndex, createMenuCheckBox(FILTER_TOGGLE, "dyn"+s, pi.ChatInput.DynamicChat[i].isListeningWindow(cw))); ++insertionIndex; } diff --git a/ryzom/client/src/string_manager_client.h b/ryzom/client/src/string_manager_client.h index c977a8380..021d9f433 100644 --- a/ryzom/client/src/string_manager_client.h +++ b/ryzom/client/src/string_manager_client.h @@ -60,6 +60,7 @@ public: // Force the cache to be saved void flushStringCache(); + bool getString(uint32 stringId, std::string &result) { ucstring temp; getString(stringId, temp); result = temp.toUtf8(); } // FIXME: UTF-8 bool getString(uint32 stringId, ucstring &result); void waitString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result); void waitString(uint32 stringId, IStringWaitCallback *pcallback);