diff --git a/nel/include/nel/3d/computed_string.h b/nel/include/nel/3d/computed_string.h index c4404f661..35bfb692c 100644 --- a/nel/include/nel/3d/computed_string.h +++ b/nel/include/nel/3d/computed_string.h @@ -182,6 +182,7 @@ public: CMaterial *Material; CRGBA Color; std::string Text; + size_t Length; uint32 CacheVersion; diff --git a/nel/include/nel/3d/u_text_context.h b/nel/include/nel/3d/u_text_context.h index 9cf710b11..c5d31b886 100644 --- a/nel/include/nel/3d/u_text_context.h +++ b/nel/include/nel/3d/u_text_context.h @@ -104,8 +104,11 @@ public: */ float StringLine; - CStringInfo() {StringWidth= StringHeight= StringLine= 0;} - CStringInfo(float w, float h, float l) {StringWidth= w; StringHeight= h; StringLine = l;} + /// The length in characters + size_t StringLength; + + CStringInfo() { StringWidth = StringHeight = StringLine = 0; StringLength = 0; } + CStringInfo(float w, float h, float l, size_t len) { StringWidth = w; StringHeight = h; StringLine = l; StringLength = len; } /** * Get the string's origin diff --git a/nel/include/nel/gui/dbgroup_combo_box.h b/nel/include/nel/gui/dbgroup_combo_box.h index 6f42572bb..61e447f4e 100644 --- a/nel/include/nel/gui/dbgroup_combo_box.h +++ b/nel/include/nel/gui/dbgroup_combo_box.h @@ -60,13 +60,15 @@ namespace NLGUI // Combo Texts void resetTexts(); - void addText(const ucstring &text); - void setText(uint i, const ucstring &text); - void insertText(uint i, const ucstring &text); - const ucstring &getText(uint i) const; + void addText(const std::string &text); + void setText(uint i, const std::string &text); + void insertText(uint i, const std::string &text); + const std::string &getText(uint i) const; + ucstring getTextAsUtf16(uint i) const; uint getTextId(uint i) const; uint getTextPos(uint nId) const; - const ucstring &getTexture(uint i) const; + const std::string &getTexture(uint i) const; + ucstring getTextureAsUtf16(uint i) const; void setGrayed(uint i, bool g); bool getGrayed(uint i) const; void removeText(uint nPos); @@ -87,11 +89,13 @@ namespace NLGUI std::string getSelectionText() const; // view text - void setViewText(const ucstring & text); - ucstring getViewText() const; + void setViewText(const std::string & text); + std::string getViewText() const; + void setViewTextAsUtf16(const ucstring &text) { setViewText(text.toUtf8()); } + ucstring getViewTextAsUtf16() const; CViewText *getViewText(); - void setTexture(uint i, const ucstring &texture); + void setTexture(uint i, const std::string &texture); sint32 evalContentWidth() const; @@ -122,7 +126,7 @@ namespace NLGUI REFLECT_LUA_METHOD("resetTexts", luaResetTexts) REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb) REFLECT_STRING ("selection_text", getSelectionText, setSelectionText) - REFLECT_UCSTRING ("view_text", getViewText, setViewText) + REFLECT_UCSTRING ("view_text", getViewTextAsUtf16, setViewTextAsUtf16) // FIXME: Better to have UTF-8 REFLECT_EXPORT_END @@ -137,8 +141,8 @@ namespace NLGUI // sint32 CInterfaceProperty _Selection; sint32 _NotLinkedToDBSelection; - std::vector > _Texts; - std::vector _Textures; + std::vector > _Texts; + std::vector _Textures; std::vector _Grayed; // Action Handler called on combo click @@ -155,7 +159,7 @@ namespace NLGUI CCtrlBaseButton *_SelectButton; bool _IsExternViewText; - ucstring _ExternViewText; + std::string _ExternViewText; private: diff --git a/nel/include/nel/gui/dbview_quantity.h b/nel/include/nel/gui/dbview_quantity.h index 16a11f5a0..c23b394ab 100644 --- a/nel/include/nel/gui/dbview_quantity.h +++ b/nel/include/nel/gui/dbview_quantity.h @@ -57,7 +57,7 @@ namespace NLGUI CInterfaceProperty _NumberMax; sint32 _Cache; sint32 _CacheMax; - ucstring _EmptyText; + std::string _EmptyText; void buildTextFromCache(); }; diff --git a/nel/include/nel/gui/group_editbox.h b/nel/include/nel/gui/group_editbox.h index 62b78584c..36b8d63b4 100644 --- a/nel/include/nel/gui/group_editbox.h +++ b/nel/include/nel/gui/group_editbox.h @@ -63,15 +63,16 @@ namespace NLGUI virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); /// Accessors - u32string getInputString() const { return _InputString; } + std::string getInputString() const; + std::string getPrompt() const; const u32string &getInputStringRef() const { return _InputString; } - const ucstring &getPrompt() const { return _Prompt; } + const u32string &getPromptRef() const { return _Prompt; } /** Set the prompt * NB : line returns are encoded as '\n', not '\r\n' */ - void setPrompt(const ucstring &s) { _Prompt = s; } - void setInputString(const u32string &str); + void setPrompt(const std::string &s); + void setInputString(const std::string &str); void setInputStringRef(const u32string &str) {_InputString = str; }; void setInputStringAsInt(sint32 val); sint32 getInputStringAsInt() const; @@ -79,10 +80,10 @@ namespace NLGUI sint64 getInputStringAsInt64() const; void setInputStringAsFloat(float val); float getInputStringAsFloat() const; - void setInputStringAsUtf8(const std::string &str); - std::string getInputStringAsUtf8() const; void setInputStringAsUtf16(const ucstring &str); ucstring getInputStringAsUtf16() const; + void setInputStringAsUtf32(const u32string &str); + u32string getInputStringAsUtf32() const { return _InputString; } void setColor(NLMISC::CRGBA col); @@ -189,7 +190,7 @@ namespace NLGUI REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll); REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText); REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText); - REFLECT_STRING("input_string", getInputStringAsUtf8, setInputStringAsUtf8); + REFLECT_STRING("input_string", getInputString, setInputString); REFLECT_UCSTRING("uc_input_string", getInputStringAsUtf16, setInputStringAsUtf16); REFLECT_EXPORT_END @@ -228,7 +229,7 @@ namespace NLGUI NLMISC::CRGBA _BackSelectColor; // Text info - ucstring _Prompt; + u32string _Prompt; u32string _InputString; CViewText *_ViewText; diff --git a/nel/include/nel/gui/group_html.h b/nel/include/nel/gui/group_html.h index 590c43a89..1013a8b10 100644 --- a/nel/include/nel/gui/group_html.h +++ b/nel/include/nel/gui/group_html.h @@ -765,7 +765,7 @@ namespace NLGUI std::string _TextAreaScript; // Get last char - ucchar getLastChar() const; + u32char getLastChar() const; // Current link view class CViewLink *_CurrentViewLink; diff --git a/nel/include/nel/gui/string_case.h b/nel/include/nel/gui/string_case.h index ec8fa2925..300d72c76 100644 --- a/nel/include/nel/gui/string_case.h +++ b/nel/include/nel/gui/string_case.h @@ -39,6 +39,7 @@ namespace NLGUI void setCase( ucstring &str, TCaseMode mode ); + void setCase( std::string &str, TCaseMode mode ); } diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index 57ab6a096..2ffaa8d49 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -84,7 +84,8 @@ namespace NLGUI /// Set - void setText (const ucstring &text); + void setText(const std::string &text); + void setTextAsUtf16 (const ucstring &text); void setFontName (const std::string &name); void setFontSize (sint nFontSize, bool coef = true); void setEmbolden (bool nEmbolden); @@ -95,7 +96,8 @@ namespace NLGUI void setShadowColor (const NLMISC::CRGBA &color); void setShadowOffset (sint x, sint y); void setLineMaxW (sint nMaxW, bool invalidate=true); - void setOverflowText(const ucstring &text) { _OverflowText = text; } + void setOverflowText(const std::string &text) { _OverflowText = text; } + void setOverflowTextAsUtf16(const ucstring &text) { _OverflowText = text.toUtf8(); } void setMultiLine (bool bMultiLine); void setMultiLineSpace (sint nMultiLineSpace); void setMultiLineMaxWOnly (bool state); @@ -112,8 +114,9 @@ namespace NLGUI void disableStringSelection(); /// Get - - ucstring getText() const { return _Text; } + std::string getText() const { return _Text; } + ucstring getTextAsUtf16() const; + ucstring getHardTextAsUtf16() const; sint getFontSize() const; std::string getFontName() const { return _FontName; } bool getEmbolden() { return _Embolden; } @@ -124,7 +127,7 @@ namespace NLGUI NLMISC::CRGBA getShadowColor() { return _ShadowColor; } void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; } sint getLineMaxW() const { return _LineMaxW; } - ucstring getOverflowText() const { return _OverflowText; } + ucstring getOverflowTextAsUtf16() const { return _OverflowText; } bool getMultiLine() const { return _MultiLine; } sint getMultiLineSpace() const { return _MultiLineSpace; } bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; } @@ -174,8 +177,9 @@ namespace NLGUI /// From a line number, get the character at which it ends (not including any '\n' ), or -1 if invalid void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const; - std::string getHardText() const { std::string result; _Text.toString (result); return result; } + std::string getHardText() const { return _HardText.empty() ? _Text : _HardText; } void setHardText (const std::string &ht); + void setHardTextAsUtf16(const ucstring &ht); std::string getColorAsString() const; void setColorAsString(const std::string &ht); @@ -188,9 +192,11 @@ namespace NLGUI /** Setup a Text with Format Tags. Text is store without color/format tags, and special array is allocated for Format association */ - void setTextFormatTaged(const ucstring &text); + void setTextFormatTaged(const std::string &text); + void setTextFormatTagedAsUtf16(const ucstring &text); - void setSingleLineTextFormatTaged(const ucstring &text); + void setSingleLineTextFormatTaged(const std::string &text); + void setSingleLineTextFormatTagedAsUtf16(const ucstring &text); // Remove end space void removeEndSpaces(); @@ -216,10 +222,12 @@ namespace NLGUI int luaSetLineMaxW(CLuaState &ls); REFLECT_EXPORT_START(CViewText, CViewBase) + REFLECT_STRING("text", getText, setText); REFLECT_STRING("hardtext", getHardText, setHardText); - REFLECT_UCSTRING("uc_hardtext", getText, setText); - REFLECT_UCSTRING("uc_hardtext_format", getText, setTextFormatTaged); - REFLECT_UCSTRING("uc_hardtext_single_line_format", getText, setSingleLineTextFormatTaged); + // REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions + REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16); + REFLECT_UCSTRING("uc_hardtext_format", getTextAsUtf16, setTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense + REFLECT_UCSTRING("uc_hardtext_single_line_format", getTextAsUtf16, setSingleLineTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense REFLECT_STRING ("color", getColorAsString, setColorAsString); REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA); REFLECT_SINT32 ("alpha", getAlpha, setAlpha); @@ -228,7 +236,6 @@ namespace NLGUI REFLECT_LUA_METHOD("setLineMaxW", luaSetLineMaxW); REFLECT_EXPORT_END - virtual void serial(NLMISC::IStream &f); // Sets the parent element @@ -236,9 +243,11 @@ namespace NLGUI void setParentElm( CInterfaceElement *parent ){ _ParentElm = parent; } protected: - std::string _HardtextFormat; /// Text to display. - ucstring _Text; + std::string _HardTextFormat; + std::string _HardText; + std::string _Text; + mutable sint _TextLength; /// index of the computed String associated to this text control uint _Index; /// info on the computed String associated to this text control @@ -278,7 +287,7 @@ namespace NLGUI sint32 _LineMaxW; /// For single line, true if the text is clamped (ie displayed with "...") bool _SingleLineTextClamped; - ucstring _OverflowText; + std::string _OverflowText; /// Multiple lines handling bool _MultiLine; @@ -339,7 +348,7 @@ namespace NLGUI public: // default ctor CWord(uint numSpaces = 0) : Index(0), NumSpaces(numSpaces) {} - ucstring Text; + std::string Text; uint Index; // index of the info for this word NL3D::UTextContext::CStringInfo Info; uint NumSpaces; // number of spaces before this word @@ -347,7 +356,7 @@ namespace NLGUI CFormatInfo Format; public: // build from a string, using the current text context - void build(const ucstring &text, NL3D::UTextContext &textContext, uint numSpaces= 0); + void build(const std::string &text, NL3D::UTextContext &textContext, uint numSpaces= 0); }; typedef std::vector TWordVect; @@ -360,7 +369,7 @@ namespace NLGUI // Clear the line & remove text contexts void clear(NL3D::UTextContext &textContext); // Add a new word (and its context) in the line + a number of spaces to append at the end of the line - void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, float fontWidth, NL3D::UTextContext &textContext); + void addWord(const std::string &word, uint numSpaces, const CFormatInfo &wordFormat, float fontWidth, NL3D::UTextContext &textContext); void addWord(const CWord &word, float fontWidth); uint getNumWords() const { return (uint)_Words.size(); } CWord &getWord(uint index) { return _Words[index]; } @@ -434,7 +443,7 @@ namespace NLGUI void setup (); void setupDefault (); - void setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd); + void setStringSelectionSkipingSpace(uint stringId, const std::string &text, sint charStart, sint charEnd); // void pushString(const ucstring &str, bool deleteSpaceAtStart = false); @@ -442,7 +451,7 @@ namespace NLGUI void onInvalidateContent(); // may append a new line, and append a word to the last line (no spaces) - void flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat); + void flushWordInLine(std::string &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat); // Clear all the lines and free their datas void clearLines(); // Update in the case of a multiline text @@ -456,7 +465,7 @@ namespace NLGUI void addDontClipWordLine(std::vector &currLine); // FormatTag build. - static void buildFormatTagText(const ucstring &text, ucstring &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/misc/common.h b/nel/include/nel/misc/common.h index a5d1b2f27..2f678acef 100644 --- a/nel/include/nel/misc/common.h +++ b/nel/include/nel/misc/common.h @@ -227,17 +227,18 @@ inline double isValidDouble (double v) * \param str a string to transform to lower case */ -std::string toLower ( const char *str ); -std::string toLower ( const std::string &str ); -void toLower ( char *str ); +std::string toLower ( const char *str ); // Ascii only +std::string toLower ( const std::string &str ); // Ascii only +void toLower ( char *str ); // Ascii only char toLower ( const char ch ); // convert only one character /** Convert a string in upper case. * \param a string to transform to upper case */ -std::string toUpper ( const std::string &str); -void toUpper ( char *str); +// std::string toUpper ( const char *str ); // Ascii only +std::string toUpper ( const std::string &str); // Ascii only +void toUpper ( char *str); // Ascii only /** diff --git a/nel/include/nel/misc/ucstring.h b/nel/include/nel/misc/ucstring.h index 5b7597f00..8bbcd828d 100644 --- a/nel/include/nel/misc/ucstring.h +++ b/nel/include/nel/misc/ucstring.h @@ -50,7 +50,7 @@ public: ucstring(const std::string &str) : ucstringbase() { - rawCopy(str); + fromUtf8(str); } ~ucstring() { } @@ -171,8 +171,6 @@ public: return ret; } -private: - void rawCopy(const std::string &str); }; inline ucstring operator+(const ucstringbase &ucstr, ucchar c) @@ -262,6 +260,12 @@ ucstring toUpper(const ucstring &str); void toUpper(ucchar *str); ucchar toUpper(ucchar c); +std::string toLowerAsUtf8(const char *str); +std::string toLowerAsUtf8(const std::string &str); + +std::string toUpperAsUtf8(const char *str); +std::string toUpperAsUtf8(const std::string &str); + }; #endif // NL_UCSTRING_H diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h index a23c2abca..61291f421 100644 --- a/nel/include/nel/misc/utf_string_view.h +++ b/nel/include/nel/misc/utf_string_view.h @@ -26,12 +26,13 @@ namespace NLMISC { /// String view for UTF-8 and UTF-32 iteration as 32-bit codepoints. /// This string view keeps the string as a reference, it does not make a copy. /// Only use this for iterating a string's codepoints. -/// Strings are not required to be NUL-terminated, but must have at least one character extra. +/// String must be NUL terminated, but its size may specify a substring. class CUtfStringView { public: inline CUtfStringView() : m_Str(NULL), m_Size(0), m_Iterator(utf32Iterator) {} + inline CUtfStringView(const std::string &utf8Str) : m_Str(utf8Str.c_str()), m_Size(utf8Str.size()), m_Iterator(utf8Iterator) {} inline CUtfStringView(const char *utf8Str) : m_Str(utf8Str), m_Size(strlen(utf8Str)), m_Iterator(utf8Iterator) {} inline CUtfStringView(const char *utf8Str, size_t len): m_Str(utf8Str), m_Size(len), m_Iterator(utf8Iterator) { @@ -51,8 +52,8 @@ public: } #endif - inline CUtfStringView(const std::string &utf8Str) : m_Str(utf8Str.c_str()), m_Size(utf8Str.size()), m_Iterator(utf8Iterator) {} inline CUtfStringView(const ucstring &utf16Str) : m_Str(utf16Str.c_str()), m_Size(utf16Str.size() << 1), m_Iterator(utf16Iterator) {} + inline CUtfStringView(const ucchar *utf16Str) : m_Str(utf16Str), m_Size(strlen((const char *)utf16Str) & (ptrdiff_t)(-2)), m_Iterator(utf16Iterator) {} inline CUtfStringView(const u32string &utf32Str) : m_Str(utf32Str.c_str()), m_Size(utf32Str.size() << 2), m_Iterator(utf32Iterator) {} std::string toUtf8(bool reEncode = false) const; // Makes a copy @@ -60,6 +61,7 @@ public: u32string toUtf32() const; // Makes a copy std::wstring toWide() const; // Platform dependent, UTF-16 or UTF-32. Makes a copy. + std::string toAscii() const; // Returns only values 0-127, 7-bit ASCII. Makes a copy. inline bool isUtf8() const { return m_Iterator == utf8Iterator; } inline bool isUtf16() const { return m_Iterator == utf16Iterator; } @@ -95,9 +97,18 @@ public: this->~const_iterator(); return *new(this) const_iterator(other); } + + const void *ptr() const { return m_Addr; } private: friend class CUtfStringView; - inline const_iterator(const CUtfStringView &view, const void *addr) : m_View(view), m_Addr(addr), m_Char(addr ? view.m_Iterator(&m_Addr) : 0) { } + inline const_iterator(const CUtfStringView &view, const void *addr) : m_View(view), m_Addr(addr), m_Char(addr ? view.m_Iterator(&m_Addr) : 0) + { + if ((ptrdiff_t)m_Addr > ((ptrdiff_t)m_View.m_Str + m_View.m_Size)) + { + m_Addr = 0; + m_Char = 0; + } + } const CUtfStringView &m_View; const void *m_Addr; // Next address u32char m_Char; @@ -115,6 +126,8 @@ public: inline bool empty() const { return !m_Size; } const void *ptr() const { return m_Str; } + size_t count() const; // Slow count of UTF-32 characters + inline CUtfStringView substr(const iterator &begin, const iterator &end) const { return CUtfStringView(begin.m_Addr, (ptrdiff_t)end.m_Addr - (ptrdiff_t)begin.m_Addr, m_Iterator); @@ -129,6 +142,8 @@ public: return *new(this) CUtfStringView(other); } + static void append(std::string &str, u32char c); + private: typedef u32char (*TIterator)(const void **addr); static u32char utf8Iterator(const void **addr); diff --git a/nel/src/3d/font_manager.cpp b/nel/src/3d/font_manager.cpp index 70fb59639..872c1fd3d 100644 --- a/nel/src/3d/font_manager.cpp +++ b/nel/src/3d/font_manager.cpp @@ -130,6 +130,7 @@ void CFontManager::computeString (NLMISC::CUtfStringView sv, output.CacheVersion = getCacheVersion(); uint j = 0; + size_t idx = 0; { CVertexBufferReadWrite vba; output.Vertices.lock (vba); @@ -138,8 +139,7 @@ void CFontManager::computeString (NLMISC::CUtfStringView sv, hlfPixScrH = 0.f; // For all chars - //for (uint i = 0; i < s.size(); i++) - for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++idx) { // Creating font k.Char = *it; @@ -211,6 +211,8 @@ void CFontManager::computeString (NLMISC::CUtfStringView sv, } } output.Vertices.setNumVertices (j); + output.Length = idx; + nlassert(output.Length == NLMISC::CUtfStringView(output.Text).count()); // compile string info output.StringWidth = (float)penx; @@ -314,6 +316,8 @@ void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv, penx += pLI->AdvX; } } + output.Length = idx; + nlassert(output.Length == std::min(len, NLMISC::CUtfStringView(output.Text).count())); // compile string info output.StringWidth = (float)penx; diff --git a/nel/src/3d/text_context_user.cpp b/nel/src/3d/text_context_user.cpp index 95d9ebe1c..447122293 100644 --- a/nel/src/3d/text_context_user.cpp +++ b/nel/src/3d/text_context_user.cpp @@ -275,23 +275,23 @@ UTextContext::CStringInfo CTextContextUser::getStringInfo(uint32 i) CComputedString *cstr= _TextContext.getComputedString(i); if(!cstr) - return CStringInfo(0, 0, 0); + return CStringInfo(0, 0, 0, 0); else - return CStringInfo(cstr->StringWidth, cstr->StringHeight, cstr->StringLine); + return CStringInfo(cstr->StringWidth, cstr->StringHeight, cstr->StringLine, cstr->Length); } UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringView sv) { H_AUTO2; _TextContext.computeStringInfo(sv, _CacheString); - return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine); + return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine, _CacheString.Length); } UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringView sv, size_t len) { H_AUTO2; _TextContext.computeStringInfo(sv, _CacheString, len); - return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine); + return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine, _CacheString.Length); } void CTextContextUser::clear() { diff --git a/nel/src/gui/CMakeLists.txt b/nel/src/gui/CMakeLists.txt index bb5a0b7f2..4dd53e857 100644 --- a/nel/src/gui/CMakeLists.txt +++ b/nel/src/gui/CMakeLists.txt @@ -1,8 +1,7 @@ FILE(GLOB SRC *.cpp *.h) FILE(GLOB HEADERS ../../include/nel/gui/*.h) -SOURCE_GROUP("include" FILES ${HEADERS}) -SOURCE_GROUP("src" FILES ${SRC}) +SOURCE_GROUP("" FILES ${HEADERS} ${SRC}) NL_TARGET_LIB(nelgui ${SRC} ${HEADERS}) diff --git a/nel/src/gui/ctrl_text_button.cpp b/nel/src/gui/ctrl_text_button.cpp index 942dd11f8..1bd32be27 100644 --- a/nel/src/gui/ctrl_text_button.cpp +++ b/nel/src/gui/ctrl_text_button.cpp @@ -136,7 +136,7 @@ namespace NLGUI if( name == "hardtext" ) { if( _ViewText != NULL ) - return _ViewText->getText().toString(); + return _ViewText->getText(); else return std::string( "" ); } @@ -316,7 +316,7 @@ namespace NLGUI if( name == "hardtext" ) { if( _ViewText != NULL ) - _ViewText->setText( value ); + _ViewText->setHardText( value ); return; } else @@ -487,7 +487,7 @@ namespace NLGUI xmlNewProp( node, BAD_CAST "wmargin", BAD_CAST toString( _WMargin ).c_str() ); xmlNewProp( node, BAD_CAST "wmin", BAD_CAST toString( _WMin ).c_str() ); xmlNewProp( node, BAD_CAST "hmin", BAD_CAST toString( _HMin ).c_str() ); - xmlNewProp( node, BAD_CAST "hardtext", BAD_CAST _ViewText->getText().toString().c_str() ); + xmlNewProp( node, BAD_CAST "hardtext", BAD_CAST _ViewText->getText().c_str() ); xmlNewProp( node, BAD_CAST "text_y", BAD_CAST toString( _TextY ).c_str() ); xmlNewProp( node, BAD_CAST "text_x", BAD_CAST toString( _TextX ).c_str() ); xmlNewProp( node, BAD_CAST "text_underlined", BAD_CAST toString( _ViewText->getUnderlined() ).c_str() ); @@ -596,11 +596,11 @@ namespace NLGUI if (prop) { const char *propPtr = prop; - ucstring text; + std::string text; if (NLMISC::startsWith(propPtr, "ui")) - text = CI18N::get(propPtr); + text = CI18N::get(propPtr).toUtf8(); else - text.fromUtf8(propPtr); + text = propPtr; _ViewText->setText(text); } } @@ -990,7 +990,7 @@ namespace NLGUI nlassert( v != NULL ); _ViewText = dynamic_cast< CViewText* >( v ); _ViewText->setId( _Id + "_text" ); - _ViewText->setText( ucstring( "text" ) ); + _ViewText->setText( "text" ); _ViewText->setSerializable( false ); } @@ -1044,14 +1044,14 @@ namespace NLGUI void CCtrlTextButton::setText (const ucstring &text) { if (_ViewText && !_IsViewTextId) - _ViewText->setText(text); + _ViewText->setText(text.toUtf8()); } // *************************************************************************** ucstring CCtrlTextButton::getText () const { if (_ViewText && !_IsViewTextId) - return _ViewText->getText(); + return CUtfStringView(_ViewText->getText()).toUtf16(); return ucstring(""); } diff --git a/nel/src/gui/dbgroup_combo_box.cpp b/nel/src/gui/dbgroup_combo_box.cpp index 59a8b03c8..dd7f2154d 100644 --- a/nel/src/gui/dbgroup_combo_box.cpp +++ b/nel/src/gui/dbgroup_combo_box.cpp @@ -43,9 +43,9 @@ namespace NLGUI void force_link_dbgroup_combo_box_cpp() { } // Compare strings - static inline bool lt_text(const std::pair &s1, const std::pair &s2) + static inline bool lt_text(const std::pair &s1, const std::pair &s2) { - return toLower(s1.second) < toLower(s2.second); + return toLowerAsUtf8(s1.second) < toLowerAsUtf8(s2.second); } std::string CDBGroupComboBox::measureMenu; @@ -183,10 +183,10 @@ namespace NLGUI if (name) { const char *propPtr = name; - ucstring Text = ucstring::makeFromUtf8(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - Text = CI18N::get (propPtr); - addText(Text); + if (NLMISC::startsWith(propPtr, "ui")) + addText(CI18N::get(propPtr).toUtf8()); + else + addText(propPtr); } } child = child->next; @@ -236,7 +236,7 @@ namespace NLGUI // change selected text if(_CacheSelection<0 || _CacheSelection>=(sint32)_Texts.size() ) { - _ViewText->setText(ucstring()); + _ViewText->setText(std::string()); } else if(_IsExternViewText) { @@ -274,7 +274,7 @@ namespace NLGUI } // *************************************************************************** - void CDBGroupComboBox::addText(const ucstring &text) + void CDBGroupComboBox::addText(const std::string &text) { dirt(); _Texts.push_back(make_pair((uint)_Texts.size(), text)); @@ -283,7 +283,7 @@ namespace NLGUI } // *************************************************************************** - void CDBGroupComboBox::setText(uint i, const ucstring &text) + void CDBGroupComboBox::setText(uint i, const std::string &text) { dirt(); if(i<_Texts.size()) @@ -291,7 +291,7 @@ namespace NLGUI } // *************************************************************************** - void CDBGroupComboBox::insertText(uint i, const ucstring &text) + void CDBGroupComboBox::insertText(uint i, const std::string &text) { dirt(); if(i<_Texts.size()) @@ -313,7 +313,7 @@ namespace NLGUI } // *************************************************************************** - void CDBGroupComboBox::setTexture(uint i, const ucstring &texture) + void CDBGroupComboBox::setTexture(uint i, const std::string &texture) { dirt(); if(i<_Textures.size()) @@ -351,13 +351,19 @@ namespace NLGUI } // *************************************************************************** - const ucstring &CDBGroupComboBox::getText(uint i) const + const std::string &CDBGroupComboBox::getText(uint i) const { - static ucstring null; - if(i<_Texts.size()) + static const std::string empty; + if (i < _Texts.size()) return _Texts[i].second; else - return null; + return empty; + } + + // *************************************************************************** + ucstring CDBGroupComboBox::getTextAsUtf16(uint i) const + { + return ucstring::makeFromUtf8(getText(i)); } // *************************************************************************** @@ -385,15 +391,21 @@ namespace NLGUI { sort(_Texts.begin(), _Texts.end(), lt_text); } - + // *************************************************************************** - const ucstring &CDBGroupComboBox::getTexture(uint i) const + const std::string &CDBGroupComboBox::getTexture(uint i) const { - static ucstring null; - if(i<_Textures.size()) + static const std::string empty; + if (i < _Textures.size()) return _Textures[i]; else - return null; + return empty; + } + + // *************************************************************************** + ucstring CDBGroupComboBox::getTextureAsUtf16(uint i) const + { + return ucstring::makeFromUtf8(getTexture(i)); } // *************************************************************************** @@ -452,8 +464,7 @@ namespace NLGUI sint32 value; for(uint i=0; igetText(); + return _ViewText->getText(); + } + + // *************************************************************************** + ucstring CDBGroupComboBox::getViewTextAsUtf16() const + { + return CUtfStringView(_ViewText->getText()).toUtf16(); } // *************************************************************************** @@ -486,18 +503,14 @@ namespace NLGUI // *************************************************************************** std::string CDBGroupComboBox::getSelectionText() const { - ucstring text; if (_LinkedToDB) { - text = getText(_Selection.getSInt32()); + return getText(_Selection.getSInt32()); } else { - text = getText(_NotLinkedToDBSelection); + return getText(_NotLinkedToDBSelection); } - std::string texteS; - text.toString(texteS); - return texteS; } // *************************************************************************** @@ -538,8 +551,7 @@ namespace NLGUI sint32 value; for(uint i=0; iaddLine(getText(i), "combo_box_select_end", toString(i), - "", std::string(), getTexture(i).toString(), checkable); + groupMenu->addLine(ucstring::makeFromUtf8(getText(i)), "combo_box_select_end", toString(i), + "", std::string(), getTexture(i), checkable); groupMenu->setGrayedLine(i, getGrayed(i)); } diff --git a/nel/src/gui/dbview_number.cpp b/nel/src/gui/dbview_number.cpp index af768140c..7ba4c17ba 100644 --- a/nel/src/gui/dbview_number.cpp +++ b/nel/src/gui/dbview_number.cpp @@ -43,7 +43,7 @@ namespace NLGUI { _Positive = false; _Cache= 0; - setText(ucstring("0")); + setText(std::string("0")); _Divisor = 1; _Modulo = 0; } @@ -225,7 +225,7 @@ namespace NLGUI // init cache. _Cache= 0; - setText(ucstring("0")); + setText(std::string("0")); return true; } @@ -238,9 +238,9 @@ namespace NLGUI if (_Cache != val) { _Cache= val; - ucstring value = _Format ? NLMISC::formatThousands(toString(val)) : toString(val); - if (_Positive) setText(val >= 0 ? ( ucstring(_Prefix) + value + ucstring(_Suffix) ) : ucstring("?")); - else setText( ucstring(_Prefix) + value + ucstring(_Suffix) ); + std::string value = _Format ? NLMISC::formatThousands(toString(val)) : toString(val); + if (_Positive) setText(val >= 0 ? ( _Prefix.toString() + value + _Suffix.toString() ) : "?"); + else setText( _Prefix.toString() + value + _Suffix.toString() ); } } diff --git a/nel/src/gui/dbview_quantity.cpp b/nel/src/gui/dbview_quantity.cpp index 0b01f14f0..0f90d598e 100644 --- a/nel/src/gui/dbview_quantity.cpp +++ b/nel/src/gui/dbview_quantity.cpp @@ -63,7 +63,7 @@ namespace NLGUI else if( name == "emptytext" ) { - return _EmptyText.toString(); + return _EmptyText; } else return CViewText::getProperty( name ); @@ -112,7 +112,7 @@ namespace NLGUI else xmlSetProp( node, BAD_CAST "valuemax", BAD_CAST "" ); - xmlSetProp( node, BAD_CAST "emptytext", BAD_CAST _EmptyText.toString().c_str() ); + xmlSetProp( node, BAD_CAST "emptytext", BAD_CAST _EmptyText.c_str() ); return node; } @@ -148,9 +148,9 @@ namespace NLGUI { const char *propPtr = ptr; if (NLMISC::startsWith(propPtr, "ui")) - _EmptyText = CI18N::get(propPtr); + _EmptyText = CI18N::get(propPtr).toUtf8(); else - _EmptyText.fromUtf8(propPtr); + _EmptyText = propPtr; } // init cache. diff --git a/nel/src/gui/group_container.cpp b/nel/src/gui/group_container.cpp index 87fb59c38..7bab62820 100644 --- a/nel/src/gui/group_container.cpp +++ b/nel/src/gui/group_container.cpp @@ -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); + if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened.toUtf8()); _TitleOpened->setActive (_Opened); // Title when the container is closed @@ -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); + if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed.toUtf8()); _TitleClosed->setActive(!_Opened); @@ -3990,7 +3990,7 @@ namespace NLGUI { _TitleTextOpened = title; if (_TitleOpened != NULL) - _TitleOpened->setText (title); + _TitleOpened->setText (title.toUtf8()); invalidateCoords(); } @@ -3999,7 +3999,7 @@ namespace NLGUI { _TitleTextClosed = title; if (_TitleClosed != NULL) - _TitleClosed->setText (_TitleTextClosed); + _TitleClosed->setText (_TitleTextClosed.toUtf8()); invalidateCoords(); } diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp index b9dc44895..768c69066 100644 --- a/nel/src/gui/group_editbox.cpp +++ b/nel/src/gui/group_editbox.cpp @@ -96,7 +96,7 @@ namespace NLGUI _ViewTextDeltaX(0) { - _Prompt = ">"; + _Prompt = u32string(1, (u32char)'>'); _BackSelectColor= CRGBA::White; _TextSelectColor= CRGBA::Black; } @@ -170,7 +170,7 @@ namespace NLGUI else if( name == "prompt" ) { - return _Prompt.toString(); + return CUtfStringView(_Prompt).toUtf8(); } else if( name == "enter_type" ) @@ -354,7 +354,7 @@ namespace NLGUI else if( name == "prompt" ) { - _Prompt = value; + _Prompt = CUtfStringView(value).toUtf32(); return; } else @@ -477,7 +477,7 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "max_chars_size", BAD_CAST toString( _MaxCharsSize ).c_str() ); xmlSetProp( node, BAD_CAST "enter_loose_focus", BAD_CAST toString( _LooseFocusOnEnter ).c_str() ); xmlSetProp( node, BAD_CAST "enter_recover_focus", BAD_CAST toString( _RecoverFocusOnEnter ).c_str() ); - xmlSetProp( node, BAD_CAST "prompt", BAD_CAST _Prompt.toString().c_str() ); + xmlSetProp( node, BAD_CAST "prompt", BAD_CAST CUtfStringView(_Prompt).toUtf8().c_str() ); std::string e; switch( _EntryType ) @@ -606,7 +606,7 @@ namespace NLGUI if (prop) _ResetFocusOnHide = convertBool(prop); prop = (char*) xmlGetProp( cur, (xmlChar*)"prompt" ); - if (prop) _Prompt = (const char*)prop; + if (prop) _Prompt = CUtfStringView((const char*)prop).toUtf32(); prop = (char*) xmlGetProp( cur, (xmlChar*)"entry_type" ); _EntryType = Text; @@ -1015,7 +1015,7 @@ namespace NLGUI _CursorAtPreviousLineEnd = false; if (_ClearOnEscape) { - setInputString(u32string()); + setInputStringAsUtf32(u32string()); triggerOnChangeAH(); } CWidgetManager::getInstance()->setCaptureKeyboard(NULL); @@ -1179,7 +1179,7 @@ namespace NLGUI if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (!_CanUndo) return false; _ModifiedInputString = _InputString; - setInputString(_StartInputString); + setInputStringAsUtf32(_StartInputString); _CanUndo = false; _CanRedo = true; setCursorPos((sint32)_InputString.length()); @@ -1192,7 +1192,7 @@ namespace NLGUI { if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (!_CanRedo) return false; - setInputString(_ModifiedInputString); + setInputStringAsUtf32(_ModifiedInputString); _CanUndo = true; _CanRedo = false; setCursorPos((sint32)_InputString.length()); @@ -1303,7 +1303,7 @@ namespace NLGUI default: break; } // update the text - setInputString(_InputString); + setInputStringAsUtf32(_InputString); // if event of type char or string, consider handle all of them if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring ) @@ -1433,16 +1433,14 @@ namespace NLGUI { if (_ViewText) { - ucstring usTmp; + std::string usTmp; if (_EntryType == Password) { - usTmp = _Prompt; - for (uint32 i = 0; i < _InputString.size(); ++i) - usTmp += "*"; + usTmp = CUtfStringView(_Prompt + u32string(_InputString.size(), 0x2022)).toUtf8(); } else { - usTmp = _Prompt + CUtfStringView(_InputString).toUtf16(); + usTmp = CUtfStringView(_Prompt + _InputString).toUtf8(); } _ViewText->setText (usTmp); } @@ -1585,7 +1583,7 @@ namespace NLGUI addView( _ViewText ); sint32 w,h; - w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() ); + w = std::max( sint32( _ViewText->getFontWidth() * CUtfStringView(_ViewText->getText()).count() ), getW() ); h = std::max( sint32( _ViewText->getFontHeight() ), getH() ); setH( h ); @@ -1625,7 +1623,18 @@ namespace NLGUI // ---------------------------------------------------------------------------- - void CGroupEditBox::setInputString(const u32string &str) + void CGroupEditBox::setPrompt(const std::string &s) + { + _Prompt = CUtfStringView(s).toUtf32(); + } + + + // ---------------------------------------------------------------------------- + void CGroupEditBox::setInputString(const std::string &str) + { + setInputStringAsUtf32(CUtfStringView(str).toUtf32()); + } + void CGroupEditBox::setInputStringAsUtf32(const u32string &str) { _InputString = str; if (_CursorPos > (sint32) str.length()) @@ -1644,43 +1653,42 @@ namespace NLGUI void CGroupEditBox::setDefaultInputString(const ucstring &str) { _DefaultInputString= true; - setInputString(CUtfStringView(str).toUtf32()); + setInputStringAsUtf32(CUtfStringView(str).toUtf32()); } - // *************************************************************************** sint32 CGroupEditBox::getInputStringAsInt() const { sint32 value; - fromString(getInputStringAsUtf8(), value); + fromString(getInputString(), value); return value; } // *************************************************************************** void CGroupEditBox::setInputStringAsInt(sint32 val) { - setInputStringAsUtf8(NLMISC::toString(val)); + setInputString(NLMISC::toString(val)); } // *************************************************************************** sint64 CGroupEditBox::getInputStringAsInt64() const { sint64 value; - fromString(getInputStringAsUtf8(), value); + fromString(getInputString(), value); return value; } // *************************************************************************** void CGroupEditBox::setInputStringAsInt64(sint64 val) { - setInputStringAsUtf8(NLMISC::toString(val)); + setInputString(NLMISC::toString(val)); } // *************************************************************************** float CGroupEditBox::getInputStringAsFloat() const { float value; - fromString(getInputStringAsUtf8(), value); + fromString(getInputString(), value); return value; } @@ -1688,7 +1696,7 @@ namespace NLGUI void CGroupEditBox::setInputStringAsFloat(float val) { string fmt= "%." + NLMISC::toString(_MaxFloatPrec) + "f"; - setInputStringAsUtf8(NLMISC::toString(fmt.c_str(), val)); + setInputString(NLMISC::toString(fmt.c_str(), val)); } // *************************************************************************** @@ -1739,21 +1747,21 @@ namespace NLGUI } // *************************************************************************** - void CGroupEditBox::setInputStringAsUtf8(const std::string &str) + std::string CGroupEditBox::getPrompt() const { - setInputString(CUtfStringView(str).toUtf32()); + return NLMISC::CUtfStringView(_Prompt).toUtf8(); } // *************************************************************************** - std::string CGroupEditBox::getInputStringAsUtf8() const + std::string CGroupEditBox::getInputString() const { - return CUtfStringView(_InputString).toUtf8(); + return NLMISC::CUtfStringView(_InputString).toUtf8(); } // *************************************************************************** void CGroupEditBox::setInputStringAsUtf16(const ucstring &str) { - setInputString(CUtfStringView(str).toUtf32()); + setInputStringAsUtf32(CUtfStringView(str).toUtf32()); } // *************************************************************************** @@ -1770,7 +1778,7 @@ namespace NLGUI return; // set the string and maybe execute - setInputString(CUtfStringView((ucchar) '/' + command).toUtf32()); + setInputStringAsUtf16((ucchar) '/' + command); if (execute) { // stop selection @@ -1853,7 +1861,7 @@ namespace NLGUI f.serial(_PrevNumLine); if (f.isReading()) { - setInputString(_InputString); + setInputStringAsUtf32(_InputString); } // serial selection @@ -1870,7 +1878,7 @@ namespace NLGUI void CGroupEditBox::onQuit() { // clear the text and restore backup pos before final save - setInputString(u32string()); + setInputStringAsUtf32(u32string()); _CurrSelection = NULL; } @@ -1878,7 +1886,7 @@ namespace NLGUI void CGroupEditBox::onLoadConfig() { // config is not saved when there's an empty string, so restore that default state. - setInputString(u32string()); + setInputStringAsUtf32(u32string()); _CurrSelection = NULL; _PrevNumLine = 1; } @@ -1893,7 +1901,7 @@ namespace NLGUI if (_DefaultInputString) { _DefaultInputString= false; - setInputString(u32string()); + setInputStringAsUtf32(u32string()); } _CanRedo = false; _CanUndo = false; diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index 7f80405ce..e6b1ba473 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -2830,7 +2830,7 @@ namespace NLGUI // Number of child in this paragraph if (_CurrentViewLink) { - bool skipLine = !_CurrentViewLink->getText().empty() && *(_CurrentViewLink->getText().rbegin()) == (ucchar) '\n'; + bool skipLine = !_CurrentViewLink->getText().empty() && *(_CurrentViewLink->getText().rbegin()) == '\n'; bool sameShadow = style.TextShadow.Enabled && _CurrentViewLink->getShadow(); if (sameShadow && style.TextShadow.Enabled) { @@ -2853,7 +2853,7 @@ namespace NLGUI (style.GlobalColor == _CurrentViewLink->getModulateGlobalColor())) { // Concat the text - _CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr); + _CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr.toUtf8()); _CurrentViewLink->invalidateContent(); added = true; } @@ -2916,7 +2916,7 @@ namespace NLGUI newLink->setParamsOnLeftClick("name=" + getId() + "|url=" + newLink->Link); } } - newLink->setText(tmpStr); + newLink->setText(tmpStr.toUtf8()); newLink->setMultiLineSpace((uint)((float)(style.FontSize)*LineSpaceFontFactor)); newLink->setMultiLine(true); newLink->setModulateGlobalColor(style.GlobalColor); @@ -3024,7 +3024,7 @@ namespace NLGUI CGroupEditBox *eb = dynamic_cast(textArea->getGroup("eb")); if (eb) { - eb->setInputString(CUtfStringView(decodeHTMLEntities(content)).toUtf32()); + eb->setInputString(CUtfStringView(decodeHTMLEntities(content)).toUtf8()); if (style.hasStyle("background-color")) { CViewBitmap *bg = dynamic_cast(eb->getView("bg")); @@ -3306,11 +3306,11 @@ namespace NLGUI // *************************************************************************** - ucchar CGroupHTML::getLastChar() const + u32char CGroupHTML::getLastChar() const { if (_CurrentViewLink) { - const ucstring &str = _CurrentViewLink->getText(); + u32string str = CUtfStringView(_CurrentViewLink->getText()).toUtf32(); // FIXME: Optimize reverse UTF iteration if (!str.empty()) return str[str.length()-1]; } @@ -3710,7 +3710,7 @@ namespace NLGUI CGroupEditBox *editBox = dynamic_cast(group); if (editBox) { - entryData = editBox->getViewText()->getText(); + entryData = CUtfStringView(editBox->getViewText()->getText()).toUtf16(); addEntry = true; } } @@ -6437,7 +6437,7 @@ namespace NLGUI if (cb) { uint lineIndex = cb->getNumTexts(); - cb->addText(_SelectOptionStr); + cb->addText(_SelectOptionStr.toUtf8()); if (_Forms.back().Entries.back().sbOptionDisabled == lineIndex) { cb->setGrayed(lineIndex, true); diff --git a/nel/src/gui/group_list.cpp b/nel/src/gui/group_list.cpp index d619a8146..4e04501a8 100644 --- a/nel/src/gui/group_list.cpp +++ b/nel/src/gui/group_list.cpp @@ -548,7 +548,7 @@ namespace NLGUI view->setMultiLine (multiLine); view->setTextMode(_Templ.getTextMode()); if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line); + view->setText (line.toUtf8()); // Herit global-coloring view->setModulateGlobalColor(getModulateGlobalColor()); addChild(view); @@ -566,7 +566,7 @@ namespace NLGUI view->_Parent = this; view->setMultiLine (multiLine); if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line); + view->setText (line.toUtf8()); view->setColor (textColor); // Herit global-coloring view->setModulateGlobalColor(getModulateGlobalColor()); diff --git a/nel/src/gui/group_menu.cpp b/nel/src/gui/group_menu.cpp index 830b74fb9..109baf278 100644 --- a/nel/src/gui/group_menu.cpp +++ b/nel/src/gui/group_menu.cpp @@ -1231,11 +1231,11 @@ namespace NLGUI { pV->setMultiLine (true); pV->setMultiLineMaxWOnly (true); - pV->setTextFormatTaged (name); + pV->setTextFormatTaged (name.toUtf8()); } else { - pV->setText (name); + pV->setText (name.toUtf8()); } pV->setColor (_GroupMenu->_Color); pV->setFontSize (_GroupMenu->_FontSize, _GroupMenu->_FontSizeCoef); @@ -1319,11 +1319,11 @@ namespace NLGUI { pV->setMultiLine (true); pV->setMultiLineMaxWOnly (true); - pV->setTextFormatTaged (name); + pV->setTextFormatTaged (name.toUtf8()); } else { - pV->setText (name); + pV->setText (name.toUtf8()); } pV->setColor (_GroupMenu->_Color); @@ -1602,7 +1602,7 @@ namespace NLGUI texture = _Lines[k].ViewText->getCheckBox()->getTexture(); } CViewTextMenu *pV = NULL; - pV = copyMenu->addLine (_Lines[k].ViewText->getText(), _Lines[k].AHName, _Lines[k].AHParams, _Lines[k].Id, _Lines[k].Cond, + pV = copyMenu->addLine (CUtfStringView(_Lines[k].ViewText->getText()).toUtf16(), _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()); diff --git a/nel/src/gui/group_paragraph.cpp b/nel/src/gui/group_paragraph.cpp index f772309a6..f2027a404 100644 --- a/nel/src/gui/group_paragraph.cpp +++ b/nel/src/gui/group_paragraph.cpp @@ -503,7 +503,7 @@ namespace NLGUI view->setMultiLine (multiLine); view->setTextMode(_Templ.getTextMode()); if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line); + view->setText (line.toUtf8()); // Herit global-coloring view->setModulateGlobalColor(getModulateGlobalColor()); addChild (view); @@ -520,7 +520,7 @@ namespace NLGUI view->_Parent = this; view->setMultiLine (multiLine); if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line); + view->setText (line.toUtf8()); view->setColor (textColor); // Herit global-coloring view->setModulateGlobalColor(getModulateGlobalColor()); @@ -730,7 +730,7 @@ namespace NLGUI if (viewText) { changeLine = viewText->getNumLine() > 1; - if (!viewText->getText().empty() && *(viewText->getText().rbegin()) == (ucchar) '\n') + if (!viewText->getText().empty() && *(viewText->getText().rbegin()) == '\n') { changeLine = true; } diff --git a/nel/src/gui/group_tree.cpp b/nel/src/gui/group_tree.cpp index 9fad363f0..93e9880bb 100644 --- a/nel/src/gui/group_tree.cpp +++ b/nel/src/gui/group_tree.cpp @@ -1292,7 +1292,7 @@ namespace NLGUI CViewText *pVT = new CViewText(TCtorParam()); line.TextOrTemplate = pVT; pVT->setId("t"+toString(_Lines.size())); - pVT->setText(pNode->Text); + pVT->setText(pNode->Text.toUtf8()); pVT->setColor(pNode->Color); if(pNode->FontSize==-1) pVT->setFontSize(_FontSize); diff --git a/nel/src/gui/string_case.cpp b/nel/src/gui/string_case.cpp index c96e2cc7f..d970d1e03 100644 --- a/nel/src/gui/string_case.cpp +++ b/nel/src/gui/string_case.cpp @@ -19,6 +19,7 @@ #include "stdpch.h" #include "nel/gui/string_case.h" +#include "nel/misc/utf_string_view.h" #ifdef DEBUG_NEW #define new DEBUG_NEW @@ -26,13 +27,33 @@ namespace NLGUI { + inline bool isSeparator (u32char c) + { + return (c == (u32char)' ') || (c == (u32char)'\t') || (c == (u32char)'\n') || (c == (u32char)'\r'); + } + inline bool isSeparator (ucchar c) { return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'); } + inline bool isSeparator (char c) + { + return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'); + } + // *************************************************************************** + inline bool isEndSentence (u32char c, u32char lastChar) + { + // Ex: One sentence. Another sentence. + // ^ + // Counterexample: nevrax.com + // ^ + return ((c == (u32char)' ') || (c == (u32char)'\n')) + && (lastChar == (u32char)'.') || (lastChar == (u32char)'!') || (lastChar == (u32char)'?'); + } + inline bool isEndSentence (ucstring& str, uint index) { // Ex: One sentence. Another sentence. @@ -117,6 +138,109 @@ namespace NLGUI } } + void setCase(std::string &str, TCaseMode mode) + { + const uint length = (uint)str.length(); + uint i; + bool newString = true; + bool newSentence = true; + bool newWord = true; + switch (mode) + { + case CaseLower: + str = NLMISC::toLowerAsUtf8(str); + break; + case CaseUpper: + str = NLMISC::toUpperAsUtf8(str); + break; + case CaseFirstStringLetterUp: + { + NLMISC::CUtfStringView sv(str); + std::string res; + res.reserve(sv.largestSize()); + for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + { + u32char c = *it; + if (c < 0x10000) + { + if (!isSeparator(c)) + { + if (newString) + c = NLMISC::toUpper((ucchar)c); + else + c = NLMISC::toLower((ucchar)c); + newString = false; + } + } + NLMISC::CUtfStringView::append(res, c); + } + str = nlmove(res); + break; + } + case CaseFirstSentenceLetterUp: + { + NLMISC::CUtfStringView sv(str); + std::string res; + res.reserve(sv.largestSize()); + u32char lastChar = 0; + for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + { + u32char c = *it; + if (c < 0x10000) + { + if (isEndSentence(c, lastChar)) + newSentence = true; + else + { + if (newSentence) + c = NLMISC::toUpper((ucchar)c); + else + c = NLMISC::toLower((ucchar)c); + + if (!isSeparator(c)) + newSentence = false; + } + } + NLMISC::CUtfStringView::append(res, c); + lastChar = c; + } + str = nlmove(res); + break; + } + case CaseFirstWordLetterUp: + { + NLMISC::CUtfStringView sv(str); + std::string res; + res.reserve(sv.largestSize()); + u32char lastChar = 0; + for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + { + u32char c = *it; + if (c < 0x10000) + { + if (isSeparator(c) || isEndSentence(c, lastChar)) + newWord = true; + else + { + if (newWord) + c = NLMISC::toUpper((ucchar)c); + else + c = NLMISC::toLower((ucchar)c); + + newWord = false; + } + } + NLMISC::CUtfStringView::append(res, c); + lastChar = c; + } + str = nlmove(res); + break; + } + default: + break; + } + } + } diff --git a/nel/src/gui/view_pointer.cpp b/nel/src/gui/view_pointer.cpp index 82c0174f5..973708aa6 100644 --- a/nel/src/gui/view_pointer.cpp +++ b/nel/src/gui/view_pointer.cpp @@ -458,14 +458,14 @@ namespace NLGUI { CViewText *text = dynamic_cast (element); if (text) - text->setText(str); + text->setText(str.toUtf8()); } element = target->getView ("real_txt"); if (element) { CViewText *text = dynamic_cast (element); if (text) - text->setText(str); + text->setText(str.toUtf8()); } target->updateCoords(); target->updateCoords(); diff --git a/nel/src/gui/view_text_formated.cpp b/nel/src/gui/view_text_formated.cpp index aa948e986..87cfc12bb 100644 --- a/nel/src/gui/view_text_formated.cpp +++ b/nel/src/gui/view_text_formated.cpp @@ -87,7 +87,7 @@ namespace NLGUI formatedResult = formatString(_FormatString, ucstring("")); // - setText (formatedResult); + setText (formatedResult.toUtf8()); CViewText::checkCoords(); } diff --git a/nel/src/gui/view_text_id.cpp b/nel/src/gui/view_text_id.cpp index 562ba881a..065d02e71 100644 --- a/nel/src/gui/view_text_id.cpp +++ b/nel/src/gui/view_text_id.cpp @@ -233,9 +233,9 @@ namespace NLGUI // Set the Text if(_IsTextFormatTaged) - setTextFormatTaged(result); + setTextFormatTaged(result.toUtf8()); else - setText (result); + setText (result.toUtf8()); } CViewText::checkCoords(); } diff --git a/nel/src/gui/view_text_id_formated.cpp b/nel/src/gui/view_text_id_formated.cpp index 5304e9e5c..5b1dd2a14 100644 --- a/nel/src/gui/view_text_id_formated.cpp +++ b/nel/src/gui/view_text_id_formated.cpp @@ -106,7 +106,7 @@ namespace NLGUI } formatedResult = CViewTextFormated::formatString(_FormatString, result); // - setText (formatedResult); + setText (formatedResult.toUtf8()); // if (bValid) { diff --git a/nel/src/gui/widget_manager.cpp b/nel/src/gui/widget_manager.cpp index 135249ce9..4d783df7d 100644 --- a/nel/src/gui/widget_manager.cpp +++ b/nel/src/gui/widget_manager.cpp @@ -1531,7 +1531,7 @@ namespace NLGUI CViewText *pTxt = (CViewText*)groupContextHelp->getView("text"); if (pTxt != NULL) { - pTxt->setTextFormatTaged(_ContextHelpText); + pTxt->setTextFormatTaged(_ContextHelpText.toUtf8()); // update only to get correct W/H groupContextHelp->updateCoords (); diff --git a/nel/src/misc/diff_tool.cpp b/nel/src/misc/diff_tool.cpp index 2b2a490bc..3cbaea5a6 100644 --- a/nel/src/misc/diff_tool.cpp +++ b/nel/src/misc/diff_tool.cpp @@ -232,15 +232,15 @@ bool loadStringFile(const std::string filename, vector &stringInfos ucstring prepareStringFile(const vector &strings, bool removeDiffComments, bool noDiffInfo) { - ucstring diff; + string diff; vector::const_iterator first(strings.begin()), last(strings.end()); for (; first != last; ++first) { - ucstring str; + string str; const TStringInfo &si = *first; - string comment = si.Comments.toString(); - vector lines; + string comment = si.Comments.toUtf8(); + vector lines; explode(comment, string("\n"), lines, true); uint i; @@ -274,30 +274,29 @@ ucstring prepareStringFile(const vector &strings, bool removeDiffCo } si.Comments = ucstring(comment); - str = si.Comments; + str = comment; if (!si.Identifier.empty() || !si.Text.empty()) { // add hash value comment if needed // if (si.Comments.find(ucstring("// HASH_VALUE ")) == ucstring::npos) if (!noDiffInfo) { - str += ucstring("// HASH_VALUE ") + CI18N::hashToString(si.HashValue)+ nl; - str += ucstring("// INDEX ") + NLMISC::toString("%u", first-strings.begin())+ nl; + str += "// HASH_VALUE " + CI18N::hashToString(si.HashValue) + "\n"; + str += "// INDEX " + NLMISC::toString("%u", first-strings.begin()) + "\n"; } str += si.Identifier + '\t'; - ucstring text = CI18N::makeMarkedString('[', ']', si.Text);; - ucstring text2; + string text = CI18N::makeMarkedString('[', ']', si.Text).toUtf8(); + string text2; // add new line and tab after each \n tag - ucstring::size_type pos; - const ucstring nlTag("\\n"); - while ((pos = text.find(nlTag)) != ucstring::npos) + string::size_type pos; + while ((pos = text.find("\\n")) != string::npos) { - text2 += text.substr(0, pos+2) + nl + "\t"; + text2 += text.substr(0, pos+2) + "\n\t"; text = text.substr(pos+2); } text2 += text;//.substr(0, pos+2); - str += text2 + nl + nl; + str += text2 + "\n\n"; // str += CI18N::makeMarkedString('[', ']', si.Text) + nl + nl; } @@ -305,7 +304,7 @@ ucstring prepareStringFile(const vector &strings, bool removeDiffCo diff += str; } - return diff; + return ucstring::makeFromUtf8(diff); } diff --git a/nel/src/misc/ucstring.cpp b/nel/src/misc/ucstring.cpp index 79cf78f7e..05c0d24ab 100644 --- a/nel/src/misc/ucstring.cpp +++ b/nel/src/misc/ucstring.cpp @@ -20,14 +20,7 @@ void ucstring::toString(std::string &str) const { - str.resize(size()); - for (uint i = 0; i < str.size(); i++) - { - if (operator[](i) > 255) - str[i] = '?'; - else - str[i] = (char)operator[](i); - } + str = nlmove(NLMISC::CUtfStringView(*this).toUtf8()); } std::string ucstring::toUtf8() const @@ -40,17 +33,4 @@ void ucstring::fromUtf8(const std::string &stringUtf8) *this = NLMISC::CUtfStringView(stringUtf8).toUtf16(); } -void ucstring::rawCopy(const std::string &str) -{ - // We need to convert the char into 8bits unsigned int before promotion to 16 bits - // otherwise, as char are signed on some compiler (MSCV for ex), the sign bit is extended to 16 bits. - resize(str.size()); - std::string::const_iterator first(str.begin()), last(str.end()); - iterator dest(begin()); - for (; first != last; ++first, ++dest) - { - *dest = uint8(*first); - } -} - /* end of file */ diff --git a/nel/src/misc/unicode.cpp b/nel/src/misc/unicode.cpp index 47a4cdfde..6a0bf25c0 100644 --- a/nel/src/misc/unicode.cpp +++ b/nel/src/misc/unicode.cpp @@ -16,6 +16,7 @@ #include "stdmisc.h" #include "nel/misc/ucstring.h" +#include "nel/misc/utf_string_view.h" #ifdef DEBUG_NEW #define new DEBUG_NEW @@ -1949,6 +1950,39 @@ ucchar toLower (ucchar c) // *************************************************************************** +static std::string toLowerAsUtf8(CUtfStringView sv) +{ + std::string res; + res.reserve(sv.largestSize()); + for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + { + u32char c = *it; + if (c < 0x10000) + { + ucchar uc = c; + ucchar *result = toLowerUpperSearch(&uc, UnicodeUpperToLower); + if (result) + c = result[1]; + } + CUtfStringView::append(res, c); + } + return res; +} + +std::string toLowerAsUtf8(const char *str) +{ + return toLowerAsUtf8(CUtfStringView(str)); +} + +// *************************************************************************** + +std::string toLowerAsUtf8(const std::string &str) +{ + return toLowerAsUtf8(CUtfStringView(str)); +} + +// *************************************************************************** + ucstring toUpper (const ucstring &str) { uint i; @@ -1991,4 +2025,37 @@ ucchar toUpper (ucchar c) // *************************************************************************** +static std::string toUpperAsUtf8(CUtfStringView sv) +{ + std::string res; + res.reserve(sv.largestSize()); + for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + { + u32char c = *it; + if (c < 0x10000) + { + ucchar uc = c; + ucchar *result = toLowerUpperSearch(&uc, UnicodeLowerToUpper); + if (result) + c = result[1]; + } + CUtfStringView::append(res, c); + } + return res; +} + +std::string toUpperAsUtf8(const char *str) +{ + return toUpperAsUtf8(CUtfStringView(str)); +} + +// *************************************************************************** + +std::string toUpperAsUtf8(const std::string &str) +{ + return toUpperAsUtf8(CUtfStringView(str)); +} + +// *************************************************************************** + } // NLMISC diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp index db2ea7cec..9f4057b66 100644 --- a/nel/src/misc/utf_string_view.cpp +++ b/nel/src/misc/utf_string_view.cpp @@ -29,6 +29,41 @@ namespace NLMISC { +NL_FORCE_INLINE void appendUtf8(std::string &str, u32char c) +{ + if (c < 0x80) + { + // Encode as 1 byte + str += (char)c; + } + else if (c < 0x0800) + { + // Encode as 2 bytes + str += (char)((c & 0x07C0) >> 6) | 0xC0; + str += (char)(c & 0x3F) | 0x80; + } + else if (c < 0x010000) + { + // Encode as 3 bytes + str += (char)((c & 0xF000) >> 12) | 0xE0; + str += (char)((c & 0x0FC0) >> 6) | 0x80; + str += (char)(c & 0x3F) | 0x80; + } + else + { + // Encode as 4 bytes + str += (char)((c & 0x1C0000) >> 18) | 0xF0; + str += (char)((c & 0x03F000) >> 12) | 0x80; + str += (char)((c & 0x0FC0) >> 6) | 0x80; + str += (char)(c & 0x3F) | 0x80; + } +} + +void CUtfStringView::append(std::string &str, u32char c) +{ + appendUtf8(str, c); +} + std::string CUtfStringView::toUtf8(bool reEncode) const { // Decode UTF and encode UTF-8 @@ -39,33 +74,7 @@ std::string CUtfStringView::toUtf8(bool reEncode) const res.reserve(m_Size); for (iterator it(begin()), end(end()); it != end; ++it) { - u32char c = *it; - if (c < 0x80) - { - // Encode as 1 byte - res += (char)c; - } - else if (c < 0x0800) - { - // Encode as 2 bytes - res += (char)((c & 0x07C0) >> 6) | 0xC0; - res += (char)(c & 0x3F) | 0x80; - } - else if (c < 0x010000) - { - // Encode as 3 bytes - res += (char)((c & 0xF000) >> 12) | 0xE0; - res += (char)((c & 0x0FC0) >> 6) | 0x80; - res += (char)(c & 0x3F) | 0x80; - } - else - { - // Encode as 4 bytes - res += (char)((c & 0x1C0000) >> 18) | 0xF0; - res += (char)((c & 0x03F000) >> 12) | 0x80; - res += (char)((c & 0x0FC0) >> 6) | 0x80; - res += (char)(c & 0x3F) | 0x80; - } + appendUtf8(res, *it); } return res; } @@ -106,6 +115,21 @@ u32string CUtfStringView::toUtf32() const return res; } +std::string CUtfStringView::toAscii() const +{ + std::string res; + res.reserve(m_Size); + for (iterator it(begin()), end(end()); it != end; ++it) + { + u32char c = *it; + if (c < 0x80) + res += c; + else + res += '_'; + } + return res; +} + std::wstring CUtfStringView::toWide() const { #ifdef NL_OS_WINDOWS @@ -139,6 +163,14 @@ std::wstring CUtfStringView::toWide() const #endif } +size_t CUtfStringView::count() const +{ + size_t res = 0; + for (iterator it(begin()), end(end()); it != end; ++it) + ++res; + return res; +} + u32char CUtfStringView::utf8Iterator(const void **addr) { // Decode UTF-8 diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index a4da83f48..238b11331 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -1019,7 +1019,7 @@ TInterfaceState globalMenu() // Display the firewall alert string CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:outgame:connecting:title")); if (pVT != NULL) - pVT->setText(CI18N::get("uiFirewallAlert")+ucstring("...")); + pVT->setText(CI18N::get("uiFirewallAlert").toUtf8() + "..."); // The mouse and fullscreen mode should be unlocked for the user to set the firewall permission nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts @@ -1235,8 +1235,8 @@ TInterfaceState globalMenu() if (pVT != NULL) { pVT->setMultiLine( true ); - pVT->setText(CI18N::get("uiFirewallFail")+ucstring(".\n")+ - CI18N::get("uiFirewallAlert")+ucstring(".")); + pVT->setText(CI18N::get("uiFirewallFail").toUtf8()+".\n"+ + CI18N::get("uiFirewallAlert").toUtf8()+"."); } } } @@ -1317,16 +1317,16 @@ public: if (pVT == NULL) return; if (rCS.Name.empty()) - pVT->setText(CI18N::get("uiEmptySlot")); + pVT->setText(CI18N::get("uiEmptySlot").toUtf8()); else - pVT->setText(rCS.Name); + pVT->setText(rCS.Name.toUtf8()); } // 5 slots for (; i < 5; ++i) { CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i))); if (pVT == NULL) return; - pVT->setText(CI18N::get("uiEmptySlot")); + pVT->setText(CI18N::get("uiEmptySlot").toUtf8()); } } }; @@ -2168,8 +2168,8 @@ public: CViewText *pVT = dynamic_cast(pNewLine->getView("name")); if (pVT != NULL) { - ucstring ucstr = Mainlands[i].Name + ucstring(" ") + Mainlands[i].Description; - pVT->setText(ucstr); + std::string str = Mainlands[i].Name.toUtf8() + " " + Mainlands[i].Description.toUtf8(); + pVT->setText(str); } // Add to the list @@ -2309,7 +2309,7 @@ public: CViewText *pVT = dynamic_cast(pNewLine->getView("name")); if (pVT != NULL) { - pVT->setText(name); + pVT->setText(name.toUtf8()); } CCtrlBase *pBut = pNewLine->getCtrl("but"); @@ -2557,7 +2557,7 @@ static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName { CViewText* viewText = dynamic_cast(result); if(viewText) - viewText->setText(text); + viewText->setText(text.toUtf8()); CGroupEditBox* editBox = dynamic_cast(result); if(editBox) editBox->setInputStringAsUtf16(text); @@ -2680,7 +2680,7 @@ class CAHScenarioControl : public IActionHandler CViewText* viewText = dynamic_cast(result); if(viewText) { - viewText->setText(R2::getEditor().isInitialized()?CI18N::get("uiR2EDScenarioName"):CI18N::get("uiR2EDScenarioFileName")); + viewText->setText(R2::getEditor().isInitialized()?CI18N::get("uiR2EDScenarioName").toUtf8():CI18N::get("uiR2EDScenarioFileName").toUtf8()); } } @@ -2710,7 +2710,7 @@ class CAHScenarioControl : public IActionHandler CViewText* viewText= dynamic_cast(result); if(viewText) - viewText->setText(ucstring("")); + viewText->setText(""); } } setScenarioInformation(scenarioWnd, ""); @@ -2746,7 +2746,7 @@ class CAHScenarioControl : public IActionHandler CViewText *shardName = dynamic_cast(toggleGr->getView("button_text")); if (shardName) { - shardName->setText(Mainlands[i].Name); + shardName->setText(Mainlands[i].Name.toUtf8()); } } } @@ -2975,7 +2975,7 @@ class CAHLoadScenario : public IActionHandler { CGroupEditBox* editBox = dynamic_cast(result); if(editBox) - description = editBox->getInputStringAsUtf8(); + description = editBox->getInputString(); } // races @@ -3248,7 +3248,7 @@ class CAHLoadScenario : public IActionHandler { CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) - pVT->setText(CI18N::get("uiRingWarningFreeTrial")); + pVT->setText(CI18N::get("uiRingWarningFreeTrial").toUtf8()); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); return; @@ -3329,7 +3329,7 @@ class CAHLoadScenario : public IActionHandler { CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) - pVT->setText(CI18N::get("uiRingWarningFreeTrial")); + pVT->setText(CI18N::get("uiRingWarningFreeTrial").toUtf8()); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); } @@ -3358,7 +3358,7 @@ class CAHLoadScenario : public IActionHandler { CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) - pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial")); + pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial").toUtf8()); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); } } diff --git a/ryzom/client/src/entity_cl.cpp b/ryzom/client/src/entity_cl.cpp index dce5bda37..937cff69e 100644 --- a/ryzom/client/src/entity_cl.cpp +++ b/ryzom/client/src/entity_cl.cpp @@ -2349,7 +2349,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:player:header_opened:player_title")); - if (pVT != NULL) pVT->setText(_Title); + if (pVT != NULL) pVT->setText(_Title.toUtf8()); CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:player")); if (pGC != NULL) pGC->setUCTitle(_EntityName); diff --git a/ryzom/client/src/game_context_menu.cpp b/ryzom/client/src/game_context_menu.cpp index b14c5a4a6..354434031 100644 --- a/ryzom/client/src/game_context_menu.cpp +++ b/ryzom/client/src/game_context_menu.cpp @@ -712,18 +712,18 @@ void CGameContextMenu::updateContextMenuMissionsOptions( bool forceHide ) { result = NLMISC::CI18N::get("uiMissionOptionNotReceived"); } - pVTM->setText(result); + pVTM->setText(result.toUtf8()); pVTM->setActive(true); } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); pVTM->setActive(false); } } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); pVTM->setActive(false); } } @@ -753,16 +753,16 @@ void CGameContextMenu::updateContextMenuWebPage(uint options) { result = NLMISC::CI18N::get("uiWebPageNameNotReceived"); } - pVTM->setText(result); + pVTM->setText(result.toUtf8()); } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); } } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); } } @@ -791,7 +791,7 @@ void CGameContextMenu::updateContextMenuOutpostState(uint options) { CViewTextMenu *pVTM = _TextOutpostState; if (pVTM) - pVTM->setText(ucstring(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet))); + pVTM->setText(CUtfStringView(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)).toUtf8()); } // apply the active @@ -833,12 +833,12 @@ void CGameContextMenu::updateContextMenuMissionRing() { result = NLMISC::CI18N::get("uiMissionRingNameNotReceived"); } - pVTM->setText(result); + pVTM->setText(result.toUtf8()); pVTM->setActive(true); } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); pVTM->setActive(false); } } diff --git a/ryzom/client/src/interface_v3/action_handler_edit.cpp b/ryzom/client/src/interface_v3/action_handler_edit.cpp index 81837bf4a..bde8f5389 100644 --- a/ryzom/client/src/interface_v3/action_handler_edit.cpp +++ b/ryzom/client/src/interface_v3/action_handler_edit.cpp @@ -288,11 +288,11 @@ class CAHEditGotoLineBegin : public CAHEdit // go to the start of line if (_GroupEdit->getViewText()) { - sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length()); + sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length()); if (line == -1) return; - sint newPos = std::max(_GroupEdit->getViewText()->getLineStartIndex(line), (sint) _GroupEdit->getPrompt().length()); + sint newPos = std::max(_GroupEdit->getViewText()->getLineStartIndex(line), (sint) _GroupEdit->getPromptRef().length()); if (newPos == -1) return; - _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(false); } } @@ -310,20 +310,20 @@ class CAHEditGotoLineEnd : public CAHEdit { if (_GroupEdit->getViewText()->getMultiLine()) { - sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length(), _GroupEdit->isCursorAtPreviousLineEnd()); + sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length(), _GroupEdit->isCursorAtPreviousLineEnd()); if (line == -1) return; sint newPos; bool endOfPreviousLine; _GroupEdit->getViewText()->getLineEndIndex(line, newPos, endOfPreviousLine); if (newPos != -1) { - _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(endOfPreviousLine); } } else { - _GroupEdit->setCursorPos((sint32)_GroupEdit->getPrompt().length() + (sint32)_GroupEdit->getInputString().length()); + _GroupEdit->setCursorPos((sint32)_GroupEdit->getPromptRef().length() + (sint32)_GroupEdit->getInputString().length()); } } } @@ -378,7 +378,7 @@ class CAHEditPreviousLine : public CAHEdit } else if (_GroupEdit->getViewText()->getMultiLine()) { - uint cursorPosInText = _GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length(); + uint cursorPosInText = _GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length(); if ( (_GroupEdit->getCursorPos() == (sint32) _GroupEdit->getInputStringRef().length() && _GroupEdit->getViewText()->getNumLine() == 1) || _GroupEdit->getViewText()->getLineFromIndex(cursorPosInText, _GroupEdit->isCursorAtPreviousLineEnd()) == 0 @@ -396,7 +396,7 @@ class CAHEditPreviousLine : public CAHEdit _GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd); if (newLineEnd) { - _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(true); sint32 newPos = _GroupEdit->getCursorPos(); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); @@ -417,7 +417,7 @@ class CAHEditPreviousLine : public CAHEdit { _GroupEdit->setCursorPos(newCharIndex + 1); } - _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPromptRef().length()); sint32 newpos = _GroupEdit->getCursorPos(); clamp(newpos, (sint32) 0, (sint32)_GroupEdit->getInputStringRef().size()); _GroupEdit->setCursorPos(newpos); @@ -452,7 +452,7 @@ class CAHEditNextLine : public CAHEdit { float cx, cy; float height; - _GroupEdit->getViewText()->getCharacterPositionFromIndex(_GroupEdit->getCursorPos() + (sint)_GroupEdit->getPrompt().length(), _GroupEdit->isCursorAtPreviousLineEnd(), cx, cy, height); + _GroupEdit->getViewText()->getCharacterPositionFromIndex(_GroupEdit->getCursorPos() + (sint)_GroupEdit->getPromptRef().length(), _GroupEdit->isCursorAtPreviousLineEnd(), cx, cy, height); if (cy != 0) { cy -= height; @@ -461,7 +461,7 @@ class CAHEditNextLine : public CAHEdit _GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd); if (newLineEnd) { - _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(true); sint32 newPos = _GroupEdit->getCursorPos(); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); @@ -480,9 +480,9 @@ class CAHEditNextLine : public CAHEdit } else { - _GroupEdit->setCursorPos(min(sint32(newCharIndex + 1), sint32(_GroupEdit->getInputStringRef().length() + _GroupEdit->getPrompt().length()))); + _GroupEdit->setCursorPos(min(sint32(newCharIndex + 1), sint32(_GroupEdit->getInputStringRef().length() + _GroupEdit->getPromptRef().length()))); } - _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPromptRef().length()); sint32 newPos = _GroupEdit->getCursorPos(); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); _GroupEdit->setCursorPos(newPos); @@ -639,8 +639,7 @@ class CAHEditExpandOrCycleTell : public CAHEdit void actionPart () { // If the line starts with '/tell ', do not try to expand - static const u32string TELL_STR(CUtfStringView("/tell ").toUtf32()); - if (_GroupEdit->getInputString().substr(0, TELL_STR.length()) != TELL_STR) + if (!NLMISC::startsWith(_GroupEdit->getInputString(), "/tell ")) { if (_GroupEdit->expand()) return; } diff --git a/ryzom/client/src/interface_v3/action_handler_game.cpp b/ryzom/client/src/interface_v3/action_handler_game.cpp index c9911a224..07180919d 100644 --- a/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -3010,7 +3010,7 @@ void updateVRDevicesComboUI(bool enable) { std::stringstream displayname; displayname << std::string("[") << VRDeviceCache[i].first << "] [" << VRDeviceCache[i].second << "]"; - pCB->addText(ucstring(displayname.str())); + pCB->addText(displayname.str()); if (ClientCfg.VRDisplayDevice == VRDeviceCache[i].first) { if (selectedDevice == -1 || ClientCfg.VRDisplayDeviceId == VRDeviceCache[i].second) @@ -3024,7 +3024,7 @@ void updateVRDevicesComboUI(bool enable) // configured device not found, add a dummy std::stringstream displayname; displayname << std::string("[") << ClientCfg.VRDisplayDevice << "] [" << ClientCfg.VRDisplayDeviceId<< "] [DEVICE NOT FOUND]"; - pCB->addText(ucstring(displayname.str())); + pCB->addText(displayname.str()); selectedDevice = VRDeviceCache.size(); } NLGUI::CDBManager::getInstance()->getDbProp(GAME_CONFIG_VR_DEVICE_DB)->setValue32(-1); @@ -3059,7 +3059,7 @@ public: { pCB->resetTexts(); for (sint j = 0; j < (sint)stringModeList.size(); j++) - pCB->addText(ucstring(stringModeList[j])); + pCB->addText(stringModeList[j]); } // frequencies @@ -3068,7 +3068,7 @@ public: { pCB->resetTexts(); for (sint j = 0; j < (sint)stringFreqList.size(); j++) - pCB->addText(ucstring(stringFreqList[j])); + pCB->addText(stringFreqList[j]); } // -1 is important to indicate we set this value in edit mode @@ -3091,10 +3091,10 @@ public: if( pCB ) { pCB->resetTexts(); - pCB->addText(CI18N::get("uigcLowTextureMode")); - pCB->addText(CI18N::get("uigcNormalTextureMode")); + pCB->addText(CI18N::get("uigcLowTextureMode").toUtf8()); + pCB->addText(CI18N::get("uigcNormalTextureMode").toUtf8()); if(ClientCfg.HDTextureInstalled) - pCB->addText(CI18N::get("uigcHighTextureMode")); + pCB->addText(CI18N::get("uigcHighTextureMode").toUtf8()); } // Anisotropic Filtering @@ -3107,14 +3107,14 @@ public: sint maxAnisotropic = (sint)Driver->getAnisotropicFilterMaximum(); pCB->resetTexts(); - pCB->addText(CI18N::get("uigcFxAnisotropicFilterNone")); + pCB->addText(CI18N::get("uigcFxAnisotropicFilterNone").toUtf8()); sint anisotropic = 2; uint i = 1; while (anisotropic <= maxAnisotropic) { - pCB->addText(ucstring(NLMISC::toString("%dx", anisotropic))); + pCB->addText(NLMISC::toString("%dx", anisotropic)); if (ClientCfg.AnisotropicFilter == anisotropic) nAnisotropic = i; @@ -3219,7 +3219,7 @@ class CHandlerGameConfigMode : public IActionHandler // Get W, H sint w,h; { - string vidModeStr = pCB->getText(nVideModeNb).toString(); + string vidModeStr = pCB->getText(nVideModeNb); string tmp = vidModeStr.substr(0,vidModeStr.find('x')-1); fromString(tmp, w); tmp = vidModeStr.substr(vidModeStr.find('x')+2,vidModeStr.size()); @@ -3259,7 +3259,7 @@ class CHandlerGameConfigMode : public IActionHandler { pCB->resetTexts(); for (j = 0; j < (sint)stringFreqList.size(); j++) - pCB->addText(ucstring(stringFreqList[j]) + " Hz"); + pCB->addText(stringFreqList[j] + " Hz"); } NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(nFoundFreq); @@ -3461,7 +3461,7 @@ class CHandlerGameConfigApply : public IActionHandler CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); if( pCB != NULL ) { - string vidModeStr = pCB->getText(nVideModeNb).toString(); + string vidModeStr = pCB->getText(nVideModeNb); string tmp = vidModeStr.substr(0,vidModeStr.find('x')-1); fromString(tmp, w); tmp = vidModeStr.substr(vidModeStr.find('x')+2,vidModeStr.size()); @@ -3475,7 +3475,7 @@ class CHandlerGameConfigApply : public IActionHandler CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); if( pCB != NULL ) { - string vidFreqStr = pCB->getText(nVideoFreqNb).toString(); + string vidFreqStr = pCB->getText(nVideoFreqNb); fromString(vidFreqStr, freq); } } @@ -4594,7 +4594,7 @@ public: CViewText *pVT = dynamic_cast(pIG->getView("t")); if (!pVT) break; - names.push_back(toUpper(pVT->getText().toUtf8())); + names.push_back(toUpper(pVT->getText())); } if (names.size() != nbChilds) diff --git a/ryzom/client/src/interface_v3/action_handler_help.cpp b/ryzom/client/src/interface_v3/action_handler_help.cpp index 77f5f5552..6b699f8ee 100644 --- a/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -1167,7 +1167,7 @@ void setHelpText(CSheetHelpSetup &setup, const ucstring &text) CViewText *viewText= dynamic_cast(setup.HelpWindow->getView(setup.ViewText)); if(viewText) { - viewText->setTextFormatTaged(copyStr); + viewText->setTextFormatTaged(copyStr.toUtf8()); } CInterfaceGroup *viewTextGroup = setup.HelpWindow->getGroup(setup.ScrollTextGroup); if (viewTextGroup) viewTextGroup->setActive(true); @@ -2200,7 +2200,7 @@ static void setupRawMaterialStats(CSheetHelpSetup &setup) if(pIS->canBuildItemPart(faberType)) { - pCB->addText(RM_FABER_TYPE::toLocalString(faberType)); + pCB->addText(RM_FABER_TYPE::toLocalString(faberType).toUtf8()); } } @@ -3165,7 +3165,7 @@ void setupListBrickHeader(CSheetHelpSetup &setup) if(view) { view->setActive(true); - view->setTextFormatTaged(CI18N::get("uihelpPhraseHeaderBricks")); + view->setTextFormatTaged(CI18N::get("uihelpPhraseHeaderBricks").toUtf8()); } } @@ -3806,7 +3806,7 @@ static void onMpChangeItemPart(CInterfaceGroup *wnd, uint32 itemSheetId, const s string originFilterKey= "iompf" + ITEM_ORIGIN::enumToString((ITEM_ORIGIN::EItemOrigin)itemPart.OriginFilter); mpCraft+= CI18N::get(originFilterKey); - viewText->setText(mpCraft); + viewText->setText(mpCraft.toUtf8()); } @@ -3838,7 +3838,7 @@ static void onMpChangeItemPart(CInterfaceGroup *wnd, uint32 itemSheetId, const s CViewText *statTitle= dynamic_cast(groupStat->getElement(groupStat->getId()+":text" )); CDBViewBar *statValue= dynamic_cast(groupStat->getElement(groupStat->getId()+":bar" )); if(statTitle) - statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType)); + statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType).toUtf8()); if(statValue) statValue->setValue(itemPart.Stats[i]); } diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index f984fe898..99b9c290c 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -231,8 +231,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() closeButton->setActive(false); group->setActive(true); - editBoxShort->setInputString(u32string()); - editBoxLarge->setInputString(u32string()); + editBoxShort->setInputString(std::string()); + editBoxLarge->setInputString(std::string()); display->setTextFormatTaged(ucstring()); @@ -289,8 +289,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() closeButton->setActive(true); group->setActive(true); - editBoxShort->setInputString(u32string()); - editBoxLarge->setInputString(u32string()); + editBoxShort->setInputString(std::string()); + editBoxLarge->setInputString(std::string()); display->setTextFormatTaged(ucstring()); // Finish the display or add the waiter diff --git a/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/ryzom/client/src/interface_v3/action_phrase_faber.cpp index d039444f9..fcef685c5 100644 --- a/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -523,7 +523,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick { nlstop; } - viewText->setText( text ); + viewText->setText( text.toUtf8() ); } // Set as Icon the required MP FaberType / or Sheet Texture (directly...) @@ -718,7 +718,7 @@ void CActionPhraseFaber::startMpSelection(uint itemReqLine, uint mpSlot) if (eb) { CWidgetManager::getInstance()->setCaptureKeyboard(eb); - eb->setInputStringAsUtf8(toString(maxQuantity)); + eb->setInputString(toString(maxQuantity)); eb->setSelectionAll(); } } @@ -1724,7 +1724,7 @@ void CActionPhraseFaber::updateItemResult() + "@{FFFF})"; } strFindReplace(text, "%success", successStr ); - successView->setTextFormatTaged(text); + successView->setTextFormatTaged(text.toUtf8()); } @@ -1790,7 +1790,7 @@ void CActionPhraseFaber::updateItemResult() uint sv= uint(statArray[i]*100); if(statTitle) { - statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType)); + statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType).toUtf8()); statTitle->setColor(usageColor); } if(statValueBar) diff --git a/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp b/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp index 1e9d56dc3..0fc03124a 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp @@ -156,7 +156,7 @@ void CBotChatPageDynamicMission::update() { if (ClientCfg.Local) { - _ChoiceCB[k]->setText(l, ucstring(toString("Dynamic mission %d:%d", (int) k, (int) l))); + _ChoiceCB[k]->setText(l, toString("Dynamic mission %d:%d", (int) k, (int) l)); _TextReceived[k][l] = true; } else @@ -167,7 +167,7 @@ void CBotChatPageDynamicMission::update() bool received = CStringManagerClient::instance()->getDynString(textID, result); if (received) { - _ChoiceCB[k]->setText(l, result); + _ChoiceCB[k]->setText(l, result.toUtf8()); _TextReceived[k][l] = true; } } @@ -183,13 +183,13 @@ void CBotChatPageDynamicMission::update() bool received = CStringManagerClient::instance()->getDynString(textID, result); if (received) { - _ChoiceCB[k]->addText(result); + _ChoiceCB[k]->addText(result.toUtf8()); _TextReceived[k][l] = true; } else { // add a text to show the player that the text is being received - _ChoiceCB[k]->addText(NLMISC::CI18N::get("uiWaitingChoiceFromServer")); + _ChoiceCB[k]->addText(NLMISC::CI18N::get("uiWaitingChoiceFromServer").toUtf8()); } } } 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 64f19214f..352ff65f4 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -333,7 +333,7 @@ uint32 CBotChatPageTrade::getCurrItemQuantity() const CGroupEditBox *ed = dynamic_cast(ig->getGroup("header_opened:standard_price:quantity:edit:eb")); if (!ed) return std::numeric_limits::max(); uint32 intQuantity; - if (fromString(ed->getInputStringAsUtf8(), intQuantity)) + if (fromString(ed->getInputString(), intQuantity)) { return intQuantity; } @@ -865,7 +865,7 @@ void CBotChatPageTrade::startBuyDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCall CViewText *priceLabel = dynamic_cast(ig->getView( "standard_price:total_price_header" )); if ( _BuyMean == Money && priceLabel ) { - priceLabel->setText( CI18N::get( "uiPrice" ) ); + priceLabel->setText( CI18N::get( "uiPrice" ).toUtf8() ); priceLabel->setActive(true); } else @@ -977,7 +977,7 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal CViewText *priceLabel = dynamic_cast(ig->getView( "standard_price:total_price_header" )); if ( priceLabel ) { - priceLabel->setText( CI18N::get( "uiImmediatePrice" ) ); + priceLabel->setText( CI18N::get( "uiImmediatePrice" ).toUtf8() ); priceLabel->setActive(true); } @@ -1012,7 +1012,7 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal { ucstring itemName; itemName = sheet->getItemActualName(); - itemNameView->setText(itemName); + itemNameView->setText(itemName.toUtf8()); } // set help for item @@ -1465,7 +1465,7 @@ void CBotChatPageTrade::setupPriceGroupQuantity(CInterfaceGroup *priceGroup, sin CGroupEditBox *eb = dynamic_cast(quantityGroup->getGroup("edit:eb")); if (eb) { - eb->setInputStringAsUtf8(toString(defaultQuantity)); + eb->setInputString(toString(defaultQuantity)); } } } @@ -1569,7 +1569,7 @@ void CBotChatPageTrade::setupResellGroup(bool sellMode, uint defaultQuantity, CI { sint32 resaleMargin= NLGUI::CDBManager::getInstance()->getDbProp( "UI:SAVE:TRADE_ITEM:RESALE_MARGIN" )->getValue32(); clamp(resaleMargin, 0, (sint32)MaxResaleMargin); - eb->setInputStringAsUtf8( toString( resaleMargin ) ); + eb->setInputString( toString( resaleMargin ) ); eb->setPositiveIntegerMaxValue(MaxResaleMargin); } } @@ -1679,14 +1679,14 @@ void CBotChatPageTrade::setupFactionPointPrice(bool /* sellMode */, uint default { ucstring fmt= CI18N::get("uiUnitFPPrice"); strFindReplace(fmt, "%fac", factionName); - vt->setText(fmt); + vt->setText(fmt.toUtf8()); } vt= dynamic_cast(fpGroup->getView("total_price_header")); if(vt) { ucstring fmt= CI18N::get("uiTotalFPPrice"); strFindReplace(fmt, "%fac", factionName); - vt->setText(fmt); + vt->setText(fmt.toUtf8()); } // setup icon according to pvp clan @@ -1725,8 +1725,8 @@ void CBotChatPageTrade::startChangeBuyFilterDialog(const std::string &dbext, con sint rangeMax= 0; if(dbRangeMin) rangeMin= dbRangeMin->getValue32(); if(dbRangeMax) rangeMax= dbRangeMax->getValue32(); - if(edMin) edMin->setInputStringAsUtf8(toString(rangeMin)); - if(edMax) edMax->setInputStringAsUtf8(toString(rangeMax)); + if(edMin) edMin->setInputString(toString(rangeMin)); + if(edMax) edMax->setInputString(toString(rangeMax)); if(edMin) edMin->setPositiveIntegerMaxValue(maxValue); if(edMax) edMax->setPositiveIntegerMaxValue(maxValue); @@ -1754,8 +1754,8 @@ void CBotChatPageTrade::resetBuyFilterDialog() sint rangeMin= 0; sint rangeMax= _FilterBuyDlgMaxValue; // write result in EditBox, and in db - if(edMin) edMin->setInputStringAsUtf8(toString(rangeMin)); - if(edMax) edMax->setInputStringAsUtf8(toString(rangeMax)); + if(edMin) edMin->setInputString(toString(rangeMin)); + if(edMax) edMax->setInputString(toString(rangeMax)); if(dbRangeMin) dbRangeMin->setValue32(rangeMin); if(dbRangeMax) dbRangeMax->setValue32(rangeMax); diff --git a/ryzom/client/src/interface_v3/chat_text_manager.cpp b/ryzom/client/src/interface_v3/chat_text_manager.cpp index 3b11d17a5..6fae6a29b 100644 --- a/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -380,12 +380,12 @@ CViewBase *CChatTextManager::createMsgTextSimple(const ucstring &msg, NLMISC::CR // otherwise, set text normal and apply global color if (msg.find(ucstring("@{")) != ucstring::npos) { - vt->setTextFormatTaged(msg); + vt->setTextFormatTaged(msg.toUtf8()); vt->setColor(NLMISC::CRGBA::White); } else { - vt->setText(msg); + vt->setText(msg.toUtf8()); vt->setColor(col); } @@ -465,12 +465,12 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C if (title.size() > 0) { vt->LinkTitle = title.toUtf8(); - vt->setText(title); + vt->setText(vt->LinkTitle); } else { vt->LinkTitle = url.toUtf8(); - vt->setText(url); + vt->setText(vt->LinkTitle); } if (url.find_first_of('\'') != string::npos) diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp index bfac81212..72a877cb7 100644 --- a/ryzom/client/src/interface_v3/chat_window.cpp +++ b/ryzom/client/src/interface_v3/chat_window.cpp @@ -262,7 +262,7 @@ void CChatWindow::setPrompt(const ucstring &prompt) if (!_Chat) return; CGroupEditBox *eb = dynamic_cast(_Chat->getGroup("eb")); if (!eb) return; - eb->setPrompt(prompt); + eb->setPrompt(prompt.toUtf8()); } void CChatWindow::setPromptColor(NLMISC::CRGBA col) @@ -1289,7 +1289,7 @@ public: // Parse any tokens in the text if ( ! CInterfaceManager::parseTokens(text)) { - pEB->setInputString (u32string()); + pEB->setInputString(std::string()); return; } @@ -1329,7 +1329,7 @@ public: } } // Clear input string - pEB->setInputString (u32string()); + pEB->setInputString (std::string()); CGroupContainer *gc = static_cast< CGroupContainer* >( pEB->getEnclosingContainer() ); if (gc) diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index ad0da8e16..a6084fdbe 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -2084,7 +2084,7 @@ void CDBCtrlSheet::draw() _RegenText = new CViewText(CViewBase::TCtorParam()); _RegenText->setId(getId() + ":regen"); _RegenText->setParent(_Parent); - _RegenText->setOverflowText(ucstring("")); + _RegenText->setOverflowText(std::string()); _RegenText->setModulateGlobalColor(false); _RegenText->setMultiLine(false); _RegenText->setTextMode(CViewText::ClipWord); diff --git a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index 8ffa62530..c75dc3af3 100644 --- a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -279,7 +279,7 @@ void CDBGroupBuildPhrase::clearBuildingPhrase() // Empty the name if(_UserSentenceName) { - _UserSentenceName->setInputString(u32string()); + _UserSentenceName->setInputString(std::string()); } // update Display @@ -1074,7 +1074,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) float relative_cost; cost= pBM->getSabrinaCom().getPhraseBrickAndParamCost(phrase.Bricks, i); relative_cost = pBM->getSabrinaCom().getPhraseBrickAndParamRelativeCost(phrase.Bricks, i); - ucstring costText; + std::string costText; if( cost == 0 && relative_cost != 0.f ) { cost = (sint32)(relative_cost * 100.f); @@ -1119,10 +1119,10 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) { word.InfoView->setActive(true); if(i==0) - word.InfoView->setText( CI18N::get("uiTextHelpSelectRootBrick") ); + word.InfoView->setText( CI18N::get("uiTextHelpSelectRootBrick").toUtf8() ); else // start effect index at 1 (human readable :) ) - word.InfoView->setText( CI18N::get("uiTextHelpSelectEffectBrick") + toString(i) ); + word.InfoView->setText( CI18N::get("uiTextHelpSelectEffectBrick").toUtf8() + toString(i) ); } } @@ -1243,7 +1243,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) { ucstring text; pPM->buildPhraseDesc(text, phrase, 0, false, "composition"); - _TextPhraseDesc->setTextFormatTaged(text); + _TextPhraseDesc->setTextFormatTaged(text.toUtf8()); } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp index be89ead3d..9a8efa4ae 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp @@ -141,7 +141,7 @@ void CDBGroupListSheetIconPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel); strFindReplace(sectionText, "%min", toString(minLevel)); strFindReplace(sectionText, "%max", toString(maxLevel)); - name->setText (sectionText); + name->setText (sectionText.toUtf8()); } } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index f34053396..8483e9925 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -1086,7 +1086,7 @@ void CDBGroupListSheetText::CSheetChild::updateViewTextAsItem() } // set text - Text->setTextFormatTaged(text); + Text->setTextFormatTaged(text.toUtf8()); } } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index 2486bfc29..d9a495635 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -135,7 +135,7 @@ public: { ucstring text; Ctrl->getContextHelp(text); - Text->setText(text); + Text->setText(text.toUtf8()); } // create a CViewText object that is displayed next to the item. This is the opportunnity to create diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp index 490c36b85..8e21b7f26 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp @@ -137,11 +137,11 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::updateViewText(CDB // Temp if the Desc2 is empty, set Name ucstring desc2(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheetId)); if( !desc2.empty() && !hasOnlyBlankChars(desc2)) // tolerate Blank error in translation - Text->setText(desc2); + Text->setText(desc2.toUtf8()); else { desc2 = STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brickSheetId); - Text->setText(desc2); + Text->setText(desc2.toUtf8()); } @@ -159,7 +159,7 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::updateViewText(CDB { // Special Case for the "Remove Brick" brick. No Cost (not revelant) if( brick->Id==pBM->getInterfaceRemoveBrick() ) - CostView->setText( ucstring() ); + CostView->setText( std::string() ); else if( brick->SabrinaCost == 0 && brick->SabrinaRelativeCost != 0.f ) CostView->setText( toString("%+d", (sint32)(brick->SabrinaRelativeCost * 100.f) ) + string("%") ); else diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp index ec1bfbaed..3cdf24ca8 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp @@ -94,7 +94,7 @@ void CDBGroupListSheetTextPhrase::CSheetChildPhrase::updateViewText(CDBGroupList #endif // set - Text->setText(text); + Text->setText(text.toUtf8()); } @@ -173,7 +173,7 @@ void CDBGroupListSheetTextPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel); strFindReplace(sectionText, "%min", toString(minLevel)); strFindReplace(sectionText, "%max", toString(maxLevel)); - name->setText (sectionText); + name->setText (sectionText.toUtf8()); } } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp index 45a78980e..6e98afc5c 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp @@ -48,7 +48,7 @@ void CDBGroupListSheetTextPhraseId::CSheetChildPhrase::updateViewText(CDBGroupLi // Get the User Name of the phrase Ctrl->getContextHelp(text); - Text->setText(text); + Text->setText(text.toUtf8()); } // *************************************************************************** diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index ce7f2fcf5..b0924f0af 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -457,7 +457,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT // setup color and text text= colorTag + text; - Text->setTextFormatTaged(text); + Text->setTextFormatTaged(text.toUtf8()); } // *************************************************************************** diff --git a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index ec82b5c8d..6ab68522d 100644 --- a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -303,8 +303,8 @@ void CEncyclopediaManager::rebuildAlbumPage(uint32 albumName) if (pRBVT != NULL) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pAlbum->RewardBrick))); - pRBVT->setText(desc); + CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pAlbum->RewardBrick))); + pRBVT->setText(desc.toUtf8()); } } @@ -359,18 +359,18 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) { if (pES->type() == CEntitySheet::ITEM) { - const ucstring desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc); + CUtfStringView desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); + pRBVT->setText(desc.toUtf8()); } else if (pES->type() == CEntitySheet::SBRICK) { - const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc); + CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); + pRBVT->setText(desc.toUtf8()); } else if (pES->type() == CEntitySheet::SPHRASE) { - const ucstring desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc); + CUtfStringView desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); + pRBVT->setText(desc.toUtf8()); } } diff --git a/ryzom/client/src/interface_v3/flying_text_manager.cpp b/ryzom/client/src/interface_v3/flying_text_manager.cpp index 23e6e963e..f577d41e2 100644 --- a/ryzom/client/src/interface_v3/flying_text_manager.cpp +++ b/ryzom/client/src/interface_v3/flying_text_manager.cpp @@ -143,7 +143,7 @@ void CFlyingTextManager::addFlyingText(void *key, const ucstring &text, const NL gi.UsedThisFrame= true; // update infos - gi.ViewText->setText(text); + gi.ViewText->setText(text.toUtf8()); gi.ViewText->setColor(color); gi.GroupInScene->Position= pos; gi.GroupInScene->Scale= scale; diff --git a/ryzom/client/src/interface_v3/group_compas.cpp b/ryzom/client/src/interface_v3/group_compas.cpp index 87fcec6ce..3c18eb22c 100644 --- a/ryzom/client/src/interface_v3/group_compas.cpp +++ b/ryzom/client/src/interface_v3/group_compas.cpp @@ -414,7 +414,7 @@ void CGroupCompas::draw() } if (_DistViewText != distText) { - _DistView->setText(distText); + _DistView->setText(distText.toUtf8()); _DistViewText = distText; } } diff --git a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 86ccd8e95..f070d3224 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -530,10 +530,10 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t if (group) { // Skill name - const ucstring sSkillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); + CUtfStringView sSkillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); CViewText *pViewSkillName = dynamic_cast(group->getView("name")); if (pViewSkillName != NULL) - pViewSkillName->setText (sSkillName); + pViewSkillName->setText (sSkillName.toUtf8()); // Skill value CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false); @@ -599,7 +599,7 @@ void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA CViewText *pViewName = dynamic_cast(group->getView("name")); if (pViewName != NULL) { - pViewName->setText (message); + pViewName->setText (message.toUtf8()); pViewName->setColor (color); } @@ -648,7 +648,7 @@ void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message, CViewText *pViewName = dynamic_cast(group->getView("name")); if (pViewName != NULL) { - pViewName->setTextFormatTaged(message); + pViewName->setTextFormatTaged(message.toUtf8()); pViewName->setColor (color); } @@ -787,7 +787,7 @@ void CGroupInSceneBubbleManager::addContextHelp (const ucstring &message, const } } - text->setText(finalMessage); + text->setText(finalMessage.toUtf8()); } } context->Group->setActive(true); @@ -1080,7 +1080,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con if (pVT != NULL) { pVT->setActive(false); - pVT->setText(ucstring("")); + pVT->setText(std::string()); } pCL = dynamic_cast(bubble->getElement(id+"optb"+toString(j))); if (pCL != NULL) pCL->setActive(false); @@ -1094,7 +1094,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con pVT->setActive(true); ucstring optionText; optionText.fromUtf8(strs[j]); - pVT->setText(optionText); + pVT->setText(optionText.toUtf8()); pCL = dynamic_cast(bubble->getElement(id+"optb"+toString(j))); if (pCL != NULL) { @@ -1485,7 +1485,7 @@ void CGroupInSceneBubble::setRawText (const ucstring &text) CInterfaceElement *pVTIE = CWidgetManager::getInstance()->getElementFromId(getId()+":header_opened:window:text"); CViewText *pVT= dynamic_cast(pVTIE); if (pVT != NULL) - pVT->setText(text); + pVT->setText(text.toUtf8()); } // *************************************************************************** diff --git a/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index 8c853b191..fe846038c 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -780,19 +780,19 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) // Set player name if (info->_Name) { - info->_Name->setText(entityName); + info->_Name->setText(entityName.toUtf8()); info->_Name->setModulateGlobalColor(false); } // Set player title if (info->_Title) - info->_Title->setText(entityTitle); + info->_Title->setText(entityTitle.toUtf8()); // Set tribe name if (info->_TribeName) { nlassert(info->_GuildName == NULL); - info->_TribeName->setText(theTribeName); + info->_TribeName->setText(theTribeName.toUtf8()); } // Init user leaf nodes @@ -966,7 +966,7 @@ void CGroupInSceneUserInfo::updateDynamicData () if (pPlayer != NULL) if (pPlayer->isAFK()) entityName += CI18N::get("uiAFK"); - _Name->setText(entityName); + _Name->setText(entityName.toUtf8()); // Title color get the PVP color if (_Title) @@ -994,7 +994,7 @@ void CGroupInSceneUserInfo::updateDynamicData () STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); ucstring ucsTmp; if (pSMC->getString (_Entity->getGuildNameID(), ucsTmp)) - _GuildName->setText(ucsTmp); + _GuildName->setText(ucsTmp.toUtf8()); // guildname color is the pvp color _GuildName->setColor(entityColor); @@ -1020,7 +1020,7 @@ void CGroupInSceneUserInfo::updateDynamicData () STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); ucstring ucsTmp; if (pSMC->getString (_Entity->getEventFactionID(), ucsTmp)) - _EventFaction->setText(ucsTmp); + _EventFaction->setText(ucsTmp.toUtf8()); // guildname color depends of PVP faction or not _EventFaction->setColor(entityColor); diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp index 097d2d80c..ed91842f7 100644 --- a/ryzom/client/src/interface_v3/group_map.cpp +++ b/ryzom/client/src/interface_v3/group_map.cpp @@ -2430,7 +2430,7 @@ void CGroupMap::updateMatchedLandmarks() CViewText* t = dynamic_cast(g->getView("title")); if (t) { - t->setSingleLineTextFormatTaged(_MatchedLandmarks[k].Title); + t->setSingleLineTextFormatTaged(_MatchedLandmarks[k].Title.toUtf8()); } CViewBitmap* b = dynamic_cast(g->getView("icon")); @@ -2492,7 +2492,7 @@ void CGroupMap::createLMWidgets(const std::vector &lms) else // just add a text { CLandMarkText *pNewText = new CLandMarkText(CViewBase::TCtorParam()); - pNewText->setText(ucsTmp); + pNewText->setText(ucsTmp.toUtf8()); pNewText->Pos = mapPos; pNewText->setParent(this); pNewText->setParentPosRef(Hotspot_BL); @@ -3279,7 +3279,7 @@ CGroupMap::CLandMarkText* CGroupMap::findClosestLandmark(const CVector2f ¢er for(TLandMarkTextVect::const_iterator it = landmarks.begin(); it != landmarks.end(); ++it) { ucstring lc; - lc = (*it)->getText(); + lc = CUtfStringView((*it)->getText()).toUtf16(); if(filterLandmark(lc, keywords, startsWith)) { CVector2f pos; mapToWorld(pos, (*it)->Pos); @@ -3334,7 +3334,7 @@ bool CGroupMap::targetLandmarkByName(const ucstring &search, bool startsWith) co { ct.setType(CCompassTarget::ContinentLandMark); mapToWorld(ct.Pos, lmt->Pos); - ct.Name = lmt->getText(); + ct.Name = CUtfStringView(lmt->getText()).toUtf16(); closest = dist; found = true; } @@ -3650,7 +3650,7 @@ void CGroupMap::updateClosestLandMarkMenu(const std::string &menu, const NLMISC: CViewTextMenu* vt = rootMenu->addLine(ucstring(""), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false); if (!vt) break; - vt->setSingleLineTextFormatTaged(name); + vt->setSingleLineTextFormatTaged(name.toUtf8()); // TODO: should calculate from mouse pos and client width vt->setLineMaxW(800); @@ -3718,7 +3718,7 @@ class CAHLandMarkFilter : public IActionHandler CGroupEditBox* eb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(group)); if (!eb) return; - text = eb->getInputStringAsUtf8(); + text = eb->getInputString(); } map->setLandmarkFilter(text); diff --git a/ryzom/client/src/interface_v3/group_modal_get_key.cpp b/ryzom/client/src/interface_v3/group_modal_get_key.cpp index c2d29df78..e3791cf8e 100644 --- a/ryzom/client/src/interface_v3/group_modal_get_key.cpp +++ b/ryzom/client/src/interface_v3/group_modal_get_key.cpp @@ -89,7 +89,7 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) // Setup the text ! CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewText *pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( VIEW_TEXT_KEY )); - if (pVT != NULL) pVT->setText(Combo.toUCString()); + if (pVT != NULL) pVT->setText(Combo.toUCString().toUtf8()); // Check if in use CActionsManager *pCurAM = NULL; @@ -111,12 +111,12 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) if (baseAction && pCurAM->isActionPresentInContext(it->second)) { ucstring shortcutName = baseAction->getActionLocalizedText(it->second); - if (pVT != NULL) pVT->setText(shortcutName); + if (pVT != NULL) pVT->setText(shortcutName.toUtf8()); } } else { - if (pVT != NULL) pVT->setText(string("")); + if (pVT != NULL) pVT->setText(string()); } } diff --git a/ryzom/client/src/interface_v3/group_skills.cpp b/ryzom/client/src/interface_v3/group_skills.cpp index f2586401a..053bddf86 100644 --- a/ryzom/client/src/interface_v3/group_skills.cpp +++ b/ryzom/client/src/interface_v3/group_skills.cpp @@ -387,7 +387,7 @@ void CGroupSkills::createAllTreeNodes() // Set Skill Name CViewText *pViewSkillName = dynamic_cast(pIG->getView("name")); if (pViewSkillName != NULL) - pViewSkillName->setText (sSkillName); + pViewSkillName->setText (sSkillName.toUtf8()); // Set Skill Max Value CViewText *pViewSkillMax = dynamic_cast(pIG->getView("max")); if (pViewSkillMax != NULL) diff --git a/ryzom/client/src/interface_v3/guild_manager.cpp b/ryzom/client/src/interface_v3/guild_manager.cpp index d00661357..3a25c0198 100644 --- a/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/ryzom/client/src/interface_v3/guild_manager.cpp @@ -470,7 +470,7 @@ void CGuildManager::update() { CViewText *pJoinPropPhraseView = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_JOIN_PROPOSAL_PHRASE)); if (pJoinPropPhraseView != NULL) - pJoinPropPhraseView->setText(_JoinPropPhrase); + pJoinPropPhraseView->setText(_JoinPropPhrase.toUtf8()); pJoinProp->setActive(true); CWidgetManager::getInstance()->setTopWindow(pJoinProp); @@ -724,7 +724,7 @@ bool CDBGroupListAscensor::CSheetChildAscensor::isInvalidated(CDBGroupListSheetT ucstring name; if (nameID && pSMC->getDynString(nameID, name)) { - Text->setText(name); + Text->setText(name.toUtf8()); uint64 icon = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:" + toString(Index) + ":ICON")->getValue64(); @@ -830,20 +830,20 @@ class CAHGuildSheetOpen : public IActionHandler // Set name CViewText *pViewName = dynamic_cast(pLine->getView(TEMPLATE_GUILD_MEMBER_NAME)); if (pViewName != NULL) - pViewName->setText (rGuildMembers[i].Name); + pViewName->setText (rGuildMembers[i].Name.toUtf8()); // Set Grade CViewText *pViewGrade = dynamic_cast(pLine->getView(TEMPLATE_GUILD_MEMBER_GRADE)); if (pViewGrade != NULL) { if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::Leader) - pViewGrade->setText (CI18N::get("uiGuildLeader")); + pViewGrade->setText (CI18N::get("uiGuildLeader").toUtf8()); else if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::HighOfficer) - pViewGrade->setText (CI18N::get("uiGuildHighOfficer")); + pViewGrade->setText (CI18N::get("uiGuildHighOfficer").toUtf8()); else if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::Officer) - pViewGrade->setText (CI18N::get("uiGuildOfficer")); + pViewGrade->setText (CI18N::get("uiGuildOfficer").toUtf8()); else - pViewGrade->setText (CI18N::get("uiGuildMember")); + pViewGrade->setText (CI18N::get("uiGuildMember").toUtf8()); } // online? @@ -888,7 +888,7 @@ class CAHGuildSheetOpen : public IActionHandler str += toString("%01d", rt.getRyzomCycle()+1) +", "; str += CI18N::get("ui"+MONTH::toString( (MONTH::EMonth)rt.getRyzomMonthInCurrentCycle() )) + ", "; str += toString("%02d", rt.getRyzomDayOfMonth()+1); - pViewEnterDate->setText(str); + pViewEnterDate->setText(str.toUtf8()); } // Add to the list diff --git a/ryzom/client/src/interface_v3/interface_ddx.cpp b/ryzom/client/src/interface_v3/interface_ddx.cpp index 347a0d94d..caa394723 100644 --- a/ryzom/client/src/interface_v3/interface_ddx.cpp +++ b/ryzom/client/src/interface_v3/interface_ddx.cpp @@ -350,7 +350,7 @@ void CInterfaceDDX::CParam::updateScrollView(sint32 nVal) { if(ResultView) { - ResultView->setText(ucstring(toString(nVal)) + ResultUnit); + ResultView->setText(toString(nVal) + ResultUnit.toUtf8()); } } @@ -361,7 +361,7 @@ void CInterfaceDDX::CParam::updateScrollView(double nVal) { // allow N digits string fmt= toString("%%.%df", ResultDecimal); - ResultView->setText(ucstring(toString(fmt.c_str(), nVal)) + ResultUnit); + ResultView->setText(toString(fmt.c_str(), nVal) + ResultUnit.toUtf8()); } } diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index c6a75599a..3772ef176 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1532,7 +1532,7 @@ void CInterfaceManager::updateFrameEvents() CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather")); if (pVT != NULL) - pVT->setText(str); + pVT->setText(str.toUtf8()); CCtrlBase *pTooltip= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather_tt")); if (pTooltip != NULL) @@ -1566,7 +1566,7 @@ void CInterfaceManager::updateFrameEvents() pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:time")); if (pVT != NULL) - pVT->setText(str); + pVT->setText(str.toUtf8()); str.clear(); // Update the clock in the compass if enabled. @@ -1579,7 +1579,7 @@ void CInterfaceManager::updateFrameEvents() str = getTimestampHuman("%I:%M %p"); else str = getTimestampHuman("%H:%M"); - pVT->setText(str); + pVT->setText(str.toUtf8()); } } } @@ -2389,7 +2389,7 @@ void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const ucst if (group && viewText) { viewText->setCaseMode(caseMode); - viewText->setText(text); + viewText->setText(text.toUtf8()); CWidgetManager::getInstance()->enableModalWindow(NULL, group); // don't understand why but need to update coords here group->updateCoords(); @@ -2442,7 +2442,7 @@ void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const ucstring & CWidgetManager::getInstance()->setProcedureAction("proc_valid_message_box_cancel", 1, ahOnCancel, paramsOnCancel); // set text and icon - viewText->setText(text); + viewText->setText(text.toUtf8()); if(viewBitmap) { bool active= true; diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 040d14bbd..02ff7451b 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -866,7 +866,7 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) throw ELuaIHMException("setTextFormatTaged(): '%s' is not a CViewText", pIE->getId().c_str()); // Set the text as format - vt->setTextFormatTaged(text); + vt->setTextFormatTaged(text.toUtf8()); return 0; } diff --git a/ryzom/client/src/interface_v3/macrocmd_key.cpp b/ryzom/client/src/interface_v3/macrocmd_key.cpp index 241862ff1..9fce02ef8 100644 --- a/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -103,14 +103,14 @@ void addKeyLine (CGroupList *pParent, const ucstring &keyName, const ucstring &s CViewText *pViewKeyName = dynamic_cast(pKeysLine->getView(TEMPLATE_KEYS_KEY_NAME)); if (pViewKeyName != NULL) { - pViewKeyName->setText (keyName); + pViewKeyName->setText (keyName.toUtf8()); pViewKeyName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); } CViewText *pViewShortcutName = dynamic_cast(pKeysLine->getView(TEMPLATE_KEYS_SHORTCUT_NAME)); if (pViewShortcutName != NULL) { - pViewShortcutName->setText (shortcutName); + pViewShortcutName->setText (shortcutName.toUtf8()); pViewShortcutName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); } @@ -492,7 +492,7 @@ void CModalContainerEditCmd::activate() } if (found) { - pCB->addText( CI18N::get(rVCat[i].LocalizedName) ); + pCB->addText(CI18N::get(rVCat[i].LocalizedName).toUtf8()); CurrentEditCmdCategories.push_back(rVCat[i].Name); } } @@ -512,9 +512,9 @@ void CModalContainerEditCmd::activate() NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(-1); // reset name of params CViewText *pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); invalidCurrentCommand(); } @@ -679,7 +679,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std else sEditBox = WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_EDITBOX; CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sEditBox)); // sTmp is utf8 - pEB->setInputStringAsUtf8(sTmp); + pEB->setInputString(sTmp); } // Setup the param name if any @@ -689,7 +689,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std if (noParam == 0) sText = WinName+VIEW_EDITCMD_FIRST_PARAM_NAME; else sText = WinName+VIEW_EDITCMD_SECOND_PARAM_NAME; CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sText)); - if (pVT != NULL) pVT->setText(CI18N::get(pBA->Parameters[i].LocalizedName)); + if (pVT != NULL) pVT->setText(CI18N::get(pBA->Parameters[i].LocalizedName).toUtf8()); noParam++; } } @@ -711,7 +711,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); if (pVT != NULL) pVT->setActive(true); // setup the text of the key - pVT->setText(it->second.toUCString()); + pVT->setText(it->second.toUCString().toUtf8()); // There is already a shortcut so we can display ok button pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); @@ -778,7 +778,7 @@ void CModalContainerEditCmd::invalidCurrentCommand() { // Dont display key shortcut if we are in creation mode pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( WinName+VIEW_EDITCMD_TEXT_KEY )); - if (pVT != NULL) pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); + if (pVT != NULL) pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT).toUtf8()); // Deactivate the key definer text pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); @@ -863,7 +863,7 @@ void CModalContainerEditCmd::validCurrentCommand() CGroupEditBox *pEB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin )); // convert to utf8 if (pEB != NULL) - CurrentEditCmdLine.ActionName.Argu += pEB->getInputStringAsUtf8(); + CurrentEditCmdLine.ActionName.Argu += pEB->getInputString(); noParam++; } } @@ -887,7 +887,7 @@ void CModalContainerEditCmd::validCurrentCommand() { CurrentEditCmdLine.Combo = it->second; // Yes ok let setup the text of the key - pVT->setText(it->second.toUCString()); + pVT->setText(it->second.toUCString().toUtf8()); // There is already a shortcut so we can display ok button CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (false); @@ -897,7 +897,7 @@ void CModalContainerEditCmd::validCurrentCommand() CurrentEditCmdLine.Combo.Key = KeyCount; CurrentEditCmdLine.Combo.KeyButtons = noKeyButton; // Display not assigned text - pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); + pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT).toUtf8()); // Do not display the ok button CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (true); @@ -1033,7 +1033,7 @@ void CModalContainerEditCmd::onChangeCategory() { if (rBA.isUsableInCurrentContext()) { - pCB->addText( CI18N::get(rBA.LocalizedName) ); + pCB->addText(CI18N::get(rBA.LocalizedName).toUtf8()); } } } @@ -1048,9 +1048,9 @@ void CModalContainerEditCmd::onChangeCategory() // reset name of params CViewText *pViewParamName; pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); // Reset key invalidCurrentCommand(); } @@ -1086,9 +1086,9 @@ void CModalContainerEditCmd::onChangeAction() // reset name of params CViewText *pViewParamName; pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); uint noParam = 0; for (uint i = 0; i < rVParams.size(); ++i) @@ -1111,7 +1111,7 @@ void CModalContainerEditCmd::onChangeAction() pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sViewText)); if (pViewParamName != NULL) - pViewParamName->setText (CI18N::get(rP.LocalizedName)); + pViewParamName->setText (CI18N::get(rP.LocalizedName).toUtf8()); } if (rP.Type == CBaseAction::CParameter::Constant) @@ -1130,11 +1130,10 @@ void CModalContainerEditCmd::onChangeAction() if (ActionsContext.matchContext(rVal.Contexts)) { - if ((rVal.LocalizedValue.size() >= 2) && - (rVal.LocalizedValue[0] == 'u') && (rVal.LocalizedValue[1] == 'i')) - pCB->addText(CI18N::get(rVal.LocalizedValue)); + if (NLMISC::startsWith(rVal.LocalizedValue, "ui")) + pCB->addText(CI18N::get(rVal.LocalizedValue).toUtf8()); else - pCB->addText(ucstring(rVal.LocalizedValue)); + pCB->addText(rVal.LocalizedValue); } } } @@ -1148,7 +1147,7 @@ void CModalContainerEditCmd::onChangeAction() CGroupEditBox *pEB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin )); if( pEB ) { - pEB->setInputString(u32string()); + pEB->setInputString(std::string()); } NLGUI::CDBManager::getInstance()->getDbProp( sDB )->setValue32(1); } @@ -1354,7 +1353,7 @@ public: pMCM->NewKey->CurrentEditCmdLine.Combo = pGetKey->Combo; CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+VIEW_EDITCMD_TEXT_KEY)); - if (pVT != NULL) pVT->setText(pMCM->NewKey->CurrentEditCmdLine.Combo.toUCString()); + if (pVT != NULL) pVT->setText(pMCM->NewKey->CurrentEditCmdLine.Combo.toUCString().toUtf8()); CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (false); @@ -1366,7 +1365,7 @@ public: pMCM->EditCmd->CurrentEditCmdLine.Combo = pGetKey->Combo; pMCM->CurrentEditMacro.Combo = pMCM->EditCmd->CurrentEditCmdLine.Combo; CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NEWMACRO_KEY)); - if (pVT != NULL) pVT->setText(pMCM->EditCmd->CurrentEditCmdLine.Combo.toUCString()); + if (pVT != NULL) pVT->setText(pMCM->EditCmd->CurrentEditCmdLine.Combo.toUCString().toUtf8()); } } }; diff --git a/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 39b2aedde..12b066fff 100644 --- a/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -636,7 +636,7 @@ public: CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(Params)); if (pCS == NULL) return; - pCS->setMacroText(pEB->getInputStringAsUtf8()); + pCS->setMacroText(pEB->getInputString()); } }; REGISTER_ACTION_HANDLER( CHandlerEBUpdateMacroText, "eb_update_macro_text"); @@ -703,10 +703,10 @@ public: CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_EDITTEXT)); if (pEB != NULL) { - pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.DispText); + pEB->setInputString(pMCM->CurrentEditMacro.DispText); CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_ICON)); if (pCS != NULL) - pCS->setMacroText(pEB->getInputStringAsUtf8()); + pCS->setMacroText(pEB->getInputString()); } CAHManager::getInstance()->runActionHandler("set_macro_back", NULL, string("target=")+CTRL_MACROICONCREATION_ICON+"|value="+toString(back)); @@ -827,7 +827,7 @@ void addCommandLine (CGroupList *pParent, uint cmdNb, const ucstring &cmdName) if (pNewCmd == NULL) return; CViewText *pVT = dynamic_cast(pNewCmd->getView(TEMPLATE_NEWMACRO_COMMAND_TEXT)); - if (pVT != NULL) pVT->setText(cmdName); + if (pVT != NULL) pVT->setText(cmdName.toUtf8()); pNewCmd->setParent (pParent); pParent->addChild (pNewCmd); @@ -862,11 +862,11 @@ public: if (pEB == NULL) return; CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); - pMCM->CurrentEditMacro.Name = pEB->getInputStringAsUtf8(); + pMCM->CurrentEditMacro.Name = pEB->getInputString(); if ((pMCM->CurrentEditMacro.Name.size() >= 2) && (pMCM->CurrentEditMacro.Name[0] == 'u') && (pMCM->CurrentEditMacro.Name[1] == 'i')) pMCM->CurrentEditMacro.Name[0] = 'U'; - pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.Name); + pEB->setInputString(pMCM->CurrentEditMacro.Name); } }; REGISTER_ACTION_HANDLER( CHandlerNewMacroEnterName, "new_macro_enter_name"); @@ -886,7 +886,7 @@ public: if (pCS != NULL) pCS->readFromMacro(pMCM->CurrentEditMacro); // Name CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_EDIT_NAME)); - if (pEB != NULL) pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.Name); + if (pEB != NULL) pEB->setInputString(pMCM->CurrentEditMacro.Name); // Commands CGroupList *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_COMMANDS)); if (pList == NULL) return; @@ -895,9 +895,9 @@ public: if (pVT != NULL) { if (pMCM->CurrentEditMacro.Combo.Key == KeyCount) - pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); + pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT).toUtf8()); else - pVT->setText(pMCM->CurrentEditMacro.Combo.toUCString()); + pVT->setText(pMCM->CurrentEditMacro.Combo.toUCString().toUtf8()); } pList->clearGroups(); @@ -1003,9 +1003,9 @@ void addMacroLine (CGroupList *pParent, uint macNb, const CMacroCmd ¯o) if (pVT != NULL) { if (macro.Combo.Key != KeyCount) - pVT->setText(macro.Combo.toUCString()); + pVT->setText(macro.Combo.toUCString().toUtf8()); else - pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); + pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT).toUtf8()); } pNewMacro->setParent (pParent); diff --git a/ryzom/client/src/interface_v3/music_player.cpp b/ryzom/client/src/interface_v3/music_player.cpp index 56f97b554..a0a7aed66 100644 --- a/ryzom/client/src/interface_v3/music_player.cpp +++ b/ryzom/client/src/interface_v3/music_player.cpp @@ -328,7 +328,7 @@ void CMusicPlayer::rebuildPlaylist() { ucstring title; title.fromUtf8(_Songs[i].Title); - pVT->setText(title); + pVT->setText(title.toUtf8()); } pVT = dynamic_cast(pNew->getView(TEMPLATE_PLAYLIST_SONG_DURATION)); @@ -483,7 +483,7 @@ void CMusicPlayer::updatePlayingInfo(const std::string info) CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text")); if (pVT) { - pVT->setText(ucstring::makeFromUtf8(info)); + pVT->setText(info); } } diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp index 21cfb63cf..e285bbaf9 100644 --- a/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/ryzom/client/src/interface_v3/people_interraction.cpp @@ -2199,7 +2199,7 @@ public: if (gc) { CGroupEditBox *geb = dynamic_cast(gc->getGroup("add_contact_eb:eb")); - geb->setInputString(u32string()); + geb->setInputString(std::string()); } CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams); } @@ -2257,11 +2257,11 @@ public: else { PeopleInterraction.askAddContact(geb->getInputStringAsUtf16(), peopleList); - geb->setInputString(u32string()); + geb->setInputString(std::string()); } } } - geb->setInputString(u32string()); + geb->setInputString(std::string()); } } } @@ -2389,7 +2389,7 @@ public: if (eb) { CWidgetManager::getInstance()->setCaptureKeyboard(eb); - eb->setInputString(u32string()); + eb->setInputString(std::string()); } // if (gc->getActive()) @@ -2831,7 +2831,7 @@ class CHandlerSelectChatSource : public IActionHandler { ucstring title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); - pVTM->setText("["+s+"] " + title); + pVTM->setText("["+s+"] " + title.toUtf8()); } } } diff --git a/ryzom/client/src/interface_v3/people_list.cpp b/ryzom/client/src/interface_v3/people_list.cpp index 43ee1543c..1b4c7ea5e 100644 --- a/ryzom/client/src/interface_v3/people_list.cpp +++ b/ryzom/client/src/interface_v3/people_list.cpp @@ -884,7 +884,7 @@ class CHandlerContactEntry : public IActionHandler // Parse any tokens in the text if ( ! CInterfaceManager::parseTokens(text)) { - pEB->setInputString (u32string()); + pEB->setInputString (std::string()); return; } @@ -895,7 +895,7 @@ class CHandlerContactEntry : public IActionHandler // TODO : have NLMISC::ICommand accept unicode strings std::string str = text.toUtf8().substr(1); NLMISC::ICommand::execute( str, g_log ); - pEB->setInputString (u32string()); + pEB->setInputString (std::string()); return; } // Well, we could have used CChatWindow class to handle this, but CPeopleList was written earlier, so for now @@ -908,7 +908,7 @@ class CHandlerContactEntry : public IActionHandler // Simply do a tell on the player ChatMngr.tell(playerName.toString(), text); - pEB->setInputString (u32string()); + pEB->setInputString (std::string()); if (gc) { // Restore position of enclosing container if it hasn't been moved/scaled/poped by the user diff --git a/ryzom/client/src/interface_v3/skill_manager.cpp b/ryzom/client/src/interface_v3/skill_manager.cpp index bc8ff798a..505678f3d 100644 --- a/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/ryzom/client/src/interface_v3/skill_manager.cpp @@ -1097,7 +1097,7 @@ public: string titleStr = CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)i); bool womenTitle = (UserEntity && UserEntity->getGender() == GSGENDER::female); const ucstring s(CStringManagerClient::getTitleLocalizedName(titleStr,womenTitle)); - pCB->addText(s); + pCB->addText(s.toUtf8()); pSM->_UIUnblockedTitles.push_back((CHARACTER_TITLE::ECharacterTitle)i); } } diff --git a/ryzom/client/src/interface_v3/task_bar_manager.cpp b/ryzom/client/src/interface_v3/task_bar_manager.cpp index 70d2d9fe7..7c9bb2a45 100644 --- a/ryzom/client/src/interface_v3/task_bar_manager.cpp +++ b/ryzom/client/src/interface_v3/task_bar_manager.cpp @@ -180,9 +180,9 @@ public: if (pVT != NULL) { if (it != acmap.end()) - pVT->setText(it->second.toUCString()); + pVT->setText(it->second.toUCString().toUtf8()); else - pVT->setText(CI18N::get("uiNotAssigned")); + pVT->setText(CI18N::get("uiNotAssigned").toUtf8()); } } } diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp index 6f3617286..9e0fb7f12 100644 --- a/ryzom/client/src/login.cpp +++ b/ryzom/client/src/login.cpp @@ -243,7 +243,7 @@ void createOptionalCatUI() pVT = dynamic_cast(pNewLine->getView("size")); if (pVT != NULL) { - pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size)); + pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size).toUtf8()); } // Add to the list @@ -287,7 +287,7 @@ static void setDataScanLog(const ucstring &text) CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:log_txt:log")); if (pVT != NULL) { - pVT->setText(text); + pVT->setText(text.toUtf8()); } } @@ -296,10 +296,10 @@ static void setDataScanState(const ucstring &text, ucstring progress= ucstring() { CInterfaceManager *pIM= CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:state")); - if (pVT != NULL) pVT->setText(text); + if (pVT != NULL) pVT->setText(text.toUtf8()); pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:progress")); - if (pVT != NULL) pVT->setText(progress); + if (pVT != NULL) pVT->setText(progress.toUtf8()); } void initCatDisplay() @@ -338,7 +338,7 @@ static void setPatcherStateText(const std::string &baseUIPath, const ucstring &s CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:state")); if (pVT != NULL) { - pVT->setText(str); + pVT->setText(str.toUtf8()); } } @@ -349,7 +349,7 @@ static void setPatcherProgressText(const std::string &baseUIPath, const ucstring CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:progress")); if (pVT != NULL) { - pVT->setText(str); + pVT->setText(str.toUtf8()); } } @@ -717,7 +717,7 @@ void loginMainLoop() ucstring sTmp; sTmp = BGDownloader::getWrittenSize(currentPatchingSize); sTmp += " / " + BGDownloader::getWrittenSize(totalPatchSize); - if (pVT != NULL) pVT->setText(sTmp); + if (pVT != NULL) pVT->setText(sTmp.toUtf8()); } // else if (screen == UI_VARIABLES_SCREEN_CATDISP) // If we are displaying patch info else if (LoginSM.getCurrentState() == CLoginStateMachine::st_display_cat) @@ -766,10 +766,10 @@ void loginMainLoop() // Total size of the patches is optional cats + required cat (f(optCat)) + non opt cat CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TOTAL_SIZE)); - if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(TotalPatchSize)); + if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(TotalPatchSize).toUtf8()); pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NON_OPTIONAL_SIZE)); - if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(nNonOptSize)); + if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(nNonOptSize).toUtf8()); } } } @@ -808,7 +808,7 @@ void initLoginScreen() CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); if (pGEB != NULL && (pGEB->getInputString().empty())) { - pGEB->setInputStringAsUtf8(l); + pGEB->setInputString(l); } CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false"); } @@ -830,8 +830,8 @@ void initAutoLogin() CInterfaceManager *pIM = CInterfaceManager::getInstance(); CGroupEditBox *pGEBLog = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); CGroupEditBox *pGEBPwd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD)); - pGEBLog->setInputStringAsUtf8(LoginLogin); - pGEBPwd->setInputStringAsUtf8(LoginPassword); + pGEBLog->setInputString(LoginLogin); + pGEBPwd->setInputString(LoginPassword); CAHManager::getInstance()->runActionHandler("on_login", NULL, ""); if (ClientCfg.R2Mode) @@ -1379,8 +1379,8 @@ class CAHOnLogin : public IActionHandler return; } - LoginLogin = pGEBLog->getInputStringAsUtf8(); - LoginPassword = pGEBPwd->getInputStringAsUtf8(); + LoginLogin = pGEBLog->getInputString(); + LoginPassword = pGEBPwd->getInputString(); onlogin(); } @@ -2394,7 +2394,7 @@ bool initCreateAccount() { CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId(editBoxes[i] + ":eb")); if(eb) - eb->setInputString(u32string()); + eb->setInputString(std::string()); } // conditions button @@ -2581,7 +2581,7 @@ class CAHOnCreateAccountSubmit : public IActionHandler { CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId(editBoxes[i] + ":eb")); if(eb) - results[i] = eb->getInputStringAsUtf8(); + results[i] = eb->getInputString(); } // text @@ -2735,11 +2735,11 @@ class CAHCreateAccountLogin : public IActionHandler { CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId("eb_login:eb")); if(eb) - LoginLogin = eb->getInputStringAsUtf8(); + LoginLogin = eb->getInputString(); eb = dynamic_cast(createAccountUI->findFromShortId("eb_password:eb")); if(eb) - LoginPassword = eb->getInputStringAsUtf8(); + LoginPassword = eb->getInputString(); onlogin(false); } diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index 3e2126b8d..afbc26a63 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -3373,7 +3373,7 @@ private: // must set the text by hand CViewText *vt= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CWidgetManager::getInstance()->getParser()->getDefine("server_message_box_content_view_text"))); if(vt) - vt->setTextFormatTaged(contentStr); + vt->setTextFormatTaged(contentStr.toUtf8()); // open CWidgetManager::getInstance()->setTopWindow(pGC); diff --git a/ryzom/client/src/player_cl.cpp b/ryzom/client/src/player_cl.cpp index 6cf6eda9b..8bead7c2d 100644 --- a/ryzom/client/src/player_cl.cpp +++ b/ryzom/client/src/player_cl.cpp @@ -712,7 +712,7 @@ void CPlayerCL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle * if (_Slot == 0) { CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:player:header_opened:player_title")); - if (pVT != NULL) pVT->setText(_Title); + if (pVT != NULL) pVT->setText(_Title.toUtf8()); } // rebuild in scene interface diff --git a/ryzom/client/src/r2/editor.cpp b/ryzom/client/src/r2/editor.cpp index e903785e7..e863d27ff 100644 --- a/ryzom/client/src/r2/editor.cpp +++ b/ryzom/client/src/r2/editor.cpp @@ -1761,7 +1761,7 @@ void CEditor::waitScenarioScreen() // Display the firewall alert string CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_connecting:title")); if (pVT != NULL) - pVT->setText(CI18N::get("uiFirewallAlert")+ucstring("...")); + pVT->setText(CI18N::get("uiFirewallAlert").toUtf8()+"..."); // The mouse and fullscreen mode should be unlocked for the user to set the firewall permission nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts @@ -1853,8 +1853,8 @@ void CEditor::waitScenarioScreen() if (pVT != NULL) { pVT->setMultiLine( true ); - pVT->setText(CI18N::get("uiFirewallFail")+ucstring(".\n")+ - CI18N::get("uiFirewallAlert")+ucstring(".")); + pVT->setText(CI18N::get("uiFirewallFail").toUtf8()+".\n"+ + CI18N::get("uiFirewallAlert").toUtf8()+"."); } } } @@ -6468,7 +6468,7 @@ void CEditor::connectionMsg(const std::string &stringId) CViewText *vt = dynamic_cast(r2ConnectWindow->getView("connexionMsg")); if (vt) { - vt->setText(CI18N::get(stringId)); + vt->setText(CI18N::get(stringId).toUtf8()); } } } @@ -7484,7 +7484,7 @@ class CAHInviteCharacter : public IActionHandler CGroupEditBox *geb = dynamic_cast(fatherGC->getGroup("add_contact_eb:eb")); if (geb && !geb->getInputString().empty()) { - string charName = geb->getInputStringAsUtf8(); + string charName = geb->getInputString(); CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance(); sessionBrowser.inviteCharacterByName(sessionBrowser.getCharId(), charName); @@ -7497,7 +7497,7 @@ class CAHInviteCharacter : public IActionHandler { CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) - pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial")); + pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial").toUtf8()); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); } @@ -7506,7 +7506,7 @@ class CAHInviteCharacter : public IActionHandler CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_newcomer"); } - geb->setInputString(u32string()); + geb->setInputString(std::string()); } } } diff --git a/ryzom/client/src/session_browser_impl.cpp b/ryzom/client/src/session_browser_impl.cpp index 9f3cc77a9..f11c24a54 100644 --- a/ryzom/client/src/session_browser_impl.cpp +++ b/ryzom/client/src/session_browser_impl.cpp @@ -230,7 +230,7 @@ int CSessionBrowserImpl::luaJoinRingSession(CLuaState &ls) { CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) - pVT->setText(CI18N::get("uiRingWarningFreeTrial")); + pVT->setText(CI18N::get("uiRingWarningFreeTrial").toUtf8()); CAHManager::getInstance()->runActionHandler("enter_modal", NULL, "group=ui:interface:warning_free_trial"); }