Merge branch 'develop' into ryzomclassic-develop

ryzomclassic-develop
kaetemi 4 years ago
commit 46020d345c

@ -182,6 +182,7 @@ public:
CMaterial *Material; CMaterial *Material;
CRGBA Color; CRGBA Color;
std::string Text; std::string Text;
size_t Length;
uint32 CacheVersion; uint32 CacheVersion;

@ -104,8 +104,11 @@ public:
*/ */
float StringLine; float StringLine;
CStringInfo() {StringWidth= StringHeight= StringLine= 0;} /// The length in characters
CStringInfo(float w, float h, float l) {StringWidth= w; StringHeight= h; StringLine = l;} 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 * Get the string's origin

@ -60,13 +60,15 @@ namespace NLGUI
// Combo Texts // Combo Texts
void resetTexts(); void resetTexts();
void addText(const ucstring &text); void addText(const std::string &text);
void setText(uint i, const ucstring &text); void setText(uint i, const std::string &text);
void insertText(uint i, const ucstring &text); void insertText(uint i, const std::string &text);
const ucstring &getText(uint i) const; const std::string &getText(uint i) const;
ucstring getTextAsUtf16(uint i) const;
uint getTextId(uint i) const; uint getTextId(uint i) const;
uint getTextPos(uint nId) 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); void setGrayed(uint i, bool g);
bool getGrayed(uint i) const; bool getGrayed(uint i) const;
void removeText(uint nPos); void removeText(uint nPos);
@ -87,11 +89,13 @@ namespace NLGUI
std::string getSelectionText() const; std::string getSelectionText() const;
// view text // view text
void setViewText(const ucstring & text); void setViewText(const std::string & text);
ucstring getViewText() const; std::string getViewText() const;
void setViewTextAsUtf16(const ucstring &text) { setViewText(text.toUtf8()); }
ucstring getViewTextAsUtf16() const;
CViewText *getViewText(); CViewText *getViewText();
void setTexture(uint i, const ucstring &texture); void setTexture(uint i, const std::string &texture);
sint32 evalContentWidth() const; sint32 evalContentWidth() const;
@ -122,7 +126,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("resetTexts", luaResetTexts) REFLECT_LUA_METHOD("resetTexts", luaResetTexts)
REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb) REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb)
REFLECT_STRING ("selection_text", getSelectionText, setSelectionText) 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 REFLECT_EXPORT_END
@ -137,8 +141,8 @@ namespace NLGUI
// sint32 // sint32
CInterfaceProperty _Selection; CInterfaceProperty _Selection;
sint32 _NotLinkedToDBSelection; sint32 _NotLinkedToDBSelection;
std::vector<std::pair<uint, ucstring> > _Texts; std::vector<std::pair<uint, std::string> > _Texts;
std::vector<ucstring> _Textures; std::vector<std::string> _Textures;
std::vector<bool> _Grayed; std::vector<bool> _Grayed;
// Action Handler called on combo click // Action Handler called on combo click
@ -155,7 +159,7 @@ namespace NLGUI
CCtrlBaseButton *_SelectButton; CCtrlBaseButton *_SelectButton;
bool _IsExternViewText; bool _IsExternViewText;
ucstring _ExternViewText; std::string _ExternViewText;
private: private:

@ -57,7 +57,7 @@ namespace NLGUI
CInterfaceProperty _NumberMax; CInterfaceProperty _NumberMax;
sint32 _Cache; sint32 _Cache;
sint32 _CacheMax; sint32 _CacheMax;
ucstring _EmptyText; std::string _EmptyText;
void buildTextFromCache(); void buildTextFromCache();
}; };

@ -63,15 +63,16 @@ namespace NLGUI
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
/// Accessors /// Accessors
u32string getInputString() const { return _InputString; } std::string getInputString() const;
std::string getPrompt() const;
const u32string &getInputStringRef() const { return _InputString; } const u32string &getInputStringRef() const { return _InputString; }
const ucstring &getPrompt() const { return _Prompt; } const u32string &getPromptRef() const { return _Prompt; }
/** Set the prompt /** Set the prompt
* NB : line returns are encoded as '\n', not '\r\n' * NB : line returns are encoded as '\n', not '\r\n'
*/ */
void setPrompt(const ucstring &s) { _Prompt = s; } void setPrompt(const std::string &s);
void setInputString(const u32string &str); void setInputString(const std::string &str);
void setInputStringRef(const u32string &str) {_InputString = str; }; void setInputStringRef(const u32string &str) {_InputString = str; };
void setInputStringAsInt(sint32 val); void setInputStringAsInt(sint32 val);
sint32 getInputStringAsInt() const; sint32 getInputStringAsInt() const;
@ -79,10 +80,10 @@ namespace NLGUI
sint64 getInputStringAsInt64() const; sint64 getInputStringAsInt64() const;
void setInputStringAsFloat(float val); void setInputStringAsFloat(float val);
float getInputStringAsFloat() const; float getInputStringAsFloat() const;
void setInputStringAsUtf8(const std::string &str);
std::string getInputStringAsUtf8() const;
void setInputStringAsUtf16(const ucstring &str); void setInputStringAsUtf16(const ucstring &str);
ucstring getInputStringAsUtf16() const; ucstring getInputStringAsUtf16() const;
void setInputStringAsUtf32(const u32string &str);
u32string getInputStringAsUtf32() const { return _InputString; }
void setColor(NLMISC::CRGBA col); void setColor(NLMISC::CRGBA col);
@ -189,7 +190,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll); REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll);
REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText); REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText);
REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText); 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_UCSTRING("uc_input_string", getInputStringAsUtf16, setInputStringAsUtf16);
REFLECT_EXPORT_END REFLECT_EXPORT_END
@ -228,7 +229,7 @@ namespace NLGUI
NLMISC::CRGBA _BackSelectColor; NLMISC::CRGBA _BackSelectColor;
// Text info // Text info
ucstring _Prompt; u32string _Prompt;
u32string _InputString; u32string _InputString;
CViewText *_ViewText; CViewText *_ViewText;

@ -765,7 +765,7 @@ namespace NLGUI
std::string _TextAreaScript; std::string _TextAreaScript;
// Get last char // Get last char
ucchar getLastChar() const; u32char getLastChar() const;
// Current link view // Current link view
class CViewLink *_CurrentViewLink; class CViewLink *_CurrentViewLink;

@ -39,6 +39,7 @@ namespace NLGUI
void setCase( ucstring &str, TCaseMode mode ); void setCase( ucstring &str, TCaseMode mode );
void setCase( std::string &str, TCaseMode mode );
} }

@ -84,7 +84,8 @@ namespace NLGUI
/// Set /// Set
void setText (const ucstring &text); void setText(const std::string &text);
void setTextAsUtf16 (const ucstring &text);
void setFontName (const std::string &name); void setFontName (const std::string &name);
void setFontSize (sint nFontSize, bool coef = true); void setFontSize (sint nFontSize, bool coef = true);
void setEmbolden (bool nEmbolden); void setEmbolden (bool nEmbolden);
@ -95,7 +96,8 @@ namespace NLGUI
void setShadowColor (const NLMISC::CRGBA &color); void setShadowColor (const NLMISC::CRGBA &color);
void setShadowOffset (sint x, sint y); void setShadowOffset (sint x, sint y);
void setLineMaxW (sint nMaxW, bool invalidate=true); 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 setMultiLine (bool bMultiLine);
void setMultiLineSpace (sint nMultiLineSpace); void setMultiLineSpace (sint nMultiLineSpace);
void setMultiLineMaxWOnly (bool state); void setMultiLineMaxWOnly (bool state);
@ -112,8 +114,9 @@ namespace NLGUI
void disableStringSelection(); void disableStringSelection();
/// Get /// Get
std::string getText() const { return _Text; }
ucstring getText() const { return _Text; } ucstring getTextAsUtf16() const;
ucstring getHardTextAsUtf16() const;
sint getFontSize() const; sint getFontSize() const;
std::string getFontName() const { return _FontName; } std::string getFontName() const { return _FontName; }
bool getEmbolden() { return _Embolden; } bool getEmbolden() { return _Embolden; }
@ -124,7 +127,7 @@ namespace NLGUI
NLMISC::CRGBA getShadowColor() { return _ShadowColor; } NLMISC::CRGBA getShadowColor() { return _ShadowColor; }
void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; } void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; }
sint getLineMaxW() const { return _LineMaxW; } sint getLineMaxW() const { return _LineMaxW; }
ucstring getOverflowText() const { return _OverflowText; } ucstring getOverflowTextAsUtf16() const { return _OverflowText; }
bool getMultiLine() const { return _MultiLine; } bool getMultiLine() const { return _MultiLine; }
sint getMultiLineSpace() const { return _MultiLineSpace; } sint getMultiLineSpace() const { return _MultiLineSpace; }
bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; } 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 /// 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; 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 setHardText (const std::string &ht);
void setHardTextAsUtf16(const ucstring &ht);
std::string getColorAsString() const; std::string getColorAsString() const;
void setColorAsString(const std::string &ht); 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 /** 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 // Remove end space
void removeEndSpaces(); void removeEndSpaces();
@ -216,10 +222,12 @@ namespace NLGUI
int luaSetLineMaxW(CLuaState &ls); int luaSetLineMaxW(CLuaState &ls);
REFLECT_EXPORT_START(CViewText, CViewBase) REFLECT_EXPORT_START(CViewText, CViewBase)
REFLECT_STRING("text", getText, setText);
REFLECT_STRING("hardtext", getHardText, setHardText); REFLECT_STRING("hardtext", getHardText, setHardText);
REFLECT_UCSTRING("uc_hardtext", getText, setText); // REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions
REFLECT_UCSTRING("uc_hardtext_format", getText, setTextFormatTaged); REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16);
REFLECT_UCSTRING("uc_hardtext_single_line_format", getText, setSingleLineTextFormatTaged); 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_STRING ("color", getColorAsString, setColorAsString);
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA); REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
REFLECT_SINT32 ("alpha", getAlpha, setAlpha); REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
@ -228,7 +236,6 @@ namespace NLGUI
REFLECT_LUA_METHOD("setLineMaxW", luaSetLineMaxW); REFLECT_LUA_METHOD("setLineMaxW", luaSetLineMaxW);
REFLECT_EXPORT_END REFLECT_EXPORT_END
virtual void serial(NLMISC::IStream &f); virtual void serial(NLMISC::IStream &f);
// Sets the parent element // Sets the parent element
@ -236,9 +243,11 @@ namespace NLGUI
void setParentElm( CInterfaceElement *parent ){ _ParentElm = parent; } void setParentElm( CInterfaceElement *parent ){ _ParentElm = parent; }
protected: protected:
std::string _HardtextFormat;
/// Text to display. /// 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 /// index of the computed String associated to this text control
uint _Index; uint _Index;
/// info on the computed String associated to this text control /// info on the computed String associated to this text control
@ -278,7 +287,7 @@ namespace NLGUI
sint32 _LineMaxW; sint32 _LineMaxW;
/// For single line, true if the text is clamped (ie displayed with "...") /// For single line, true if the text is clamped (ie displayed with "...")
bool _SingleLineTextClamped; bool _SingleLineTextClamped;
ucstring _OverflowText; std::string _OverflowText;
/// Multiple lines handling /// Multiple lines handling
bool _MultiLine; bool _MultiLine;
@ -339,7 +348,7 @@ namespace NLGUI
public: public:
// default ctor // default ctor
CWord(uint numSpaces = 0) : Index(0), NumSpaces(numSpaces) {} CWord(uint numSpaces = 0) : Index(0), NumSpaces(numSpaces) {}
ucstring Text; std::string Text;
uint Index; // index of the info for this word uint Index; // index of the info for this word
NL3D::UTextContext::CStringInfo Info; NL3D::UTextContext::CStringInfo Info;
uint NumSpaces; // number of spaces before this word uint NumSpaces; // number of spaces before this word
@ -347,7 +356,7 @@ namespace NLGUI
CFormatInfo Format; CFormatInfo Format;
public: public:
// build from a string, using the current text context // 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<CWord> TWordVect; typedef std::vector<CWord> TWordVect;
@ -360,7 +369,7 @@ namespace NLGUI
// Clear the line & remove text contexts // Clear the line & remove text contexts
void clear(NL3D::UTextContext &textContext); 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 // 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); void addWord(const CWord &word, float fontWidth);
uint getNumWords() const { return (uint)_Words.size(); } uint getNumWords() const { return (uint)_Words.size(); }
CWord &getWord(uint index) { return _Words[index]; } CWord &getWord(uint index) { return _Words[index]; }
@ -434,7 +443,7 @@ namespace NLGUI
void setup (); void setup ();
void setupDefault (); 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); // void pushString(const ucstring &str, bool deleteSpaceAtStart = false);
@ -442,7 +451,7 @@ namespace NLGUI
void onInvalidateContent(); void onInvalidateContent();
// may append a new line, and append a word to the last line (no spaces) // 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 // Clear all the lines and free their datas
void clearLines(); void clearLines();
// Update in the case of a multiline text // Update in the case of a multiline text
@ -456,7 +465,7 @@ namespace NLGUI
void addDontClipWordLine(std::vector<CWord> &currLine); void addDontClipWordLine(std::vector<CWord> &currLine);
// FormatTag build. // FormatTag build.
static void buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector<CFormatTag> &formatTags, std::vector<ucstring> &tooltips); static void buildFormatTagText(const std::string &text, std::string &textBuild, std::vector<CFormatTag> &formatTags, std::vector<ucstring> &tooltips);
// FormatTag parsing. // FormatTag parsing.
bool isFormatTagChange(uint textIndex, uint ctIndex) const; bool isFormatTagChange(uint textIndex, uint ctIndex) const;
void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const; void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const;

@ -227,17 +227,18 @@ inline double isValidDouble (double v)
* \param str a string to transform to lower case * \param str a string to transform to lower case
*/ */
std::string toLower ( const char *str ); std::string toLower ( const char *str ); // Ascii only
std::string toLower ( const std::string &str ); std::string toLower ( const std::string &str ); // Ascii only
void toLower ( char *str ); void toLower ( char *str ); // Ascii only
char toLower ( const char ch ); // convert only one character char toLower ( const char ch ); // convert only one character
/** Convert a string in upper case. /** Convert a string in upper case.
* \param a string to transform to upper case * \param a string to transform to upper case
*/ */
std::string toUpper ( const std::string &str); // std::string toUpper ( const char *str ); // Ascii only
void toUpper ( char *str); std::string toUpper ( const std::string &str); // Ascii only
void toUpper ( char *str); // Ascii only
/** /**

@ -50,7 +50,7 @@ public:
ucstring(const std::string &str) ucstring(const std::string &str)
: ucstringbase() : ucstringbase()
{ {
rawCopy(str); fromUtf8(str);
} }
~ucstring() { } ~ucstring() { }
@ -171,8 +171,6 @@ public:
return ret; return ret;
} }
private:
void rawCopy(const std::string &str);
}; };
inline ucstring operator+(const ucstringbase &ucstr, ucchar c) inline ucstring operator+(const ucstringbase &ucstr, ucchar c)
@ -262,6 +260,12 @@ ucstring toUpper(const ucstring &str);
void toUpper(ucchar *str); void toUpper(ucchar *str);
ucchar toUpper(ucchar c); 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 #endif // NL_UCSTRING_H

@ -26,12 +26,13 @@ namespace NLMISC {
/// String view for UTF-8 and UTF-32 iteration as 32-bit codepoints. /// 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. /// This string view keeps the string as a reference, it does not make a copy.
/// Only use this for iterating a string's codepoints. /// 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 class CUtfStringView
{ {
public: public:
inline CUtfStringView() : m_Str(NULL), m_Size(0), m_Iterator(utf32Iterator) {} 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) : 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) inline CUtfStringView(const char *utf8Str, size_t len): m_Str(utf8Str), m_Size(len), m_Iterator(utf8Iterator)
{ {
@ -51,8 +52,8 @@ public:
} }
#endif #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 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) {} 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 std::string toUtf8(bool reEncode = false) const; // Makes a copy
@ -60,6 +61,7 @@ public:
u32string toUtf32() const; // Makes a copy u32string toUtf32() const; // Makes a copy
std::wstring toWide() const; // Platform dependent, UTF-16 or UTF-32. 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 isUtf8() const { return m_Iterator == utf8Iterator; }
inline bool isUtf16() const { return m_Iterator == utf16Iterator; } inline bool isUtf16() const { return m_Iterator == utf16Iterator; }
@ -95,9 +97,18 @@ public:
this->~const_iterator(); this->~const_iterator();
return *new(this) const_iterator(other); return *new(this) const_iterator(other);
} }
const void *ptr() const { return m_Addr; }
private: private:
friend class CUtfStringView; 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 CUtfStringView &m_View;
const void *m_Addr; // Next address const void *m_Addr; // Next address
u32char m_Char; u32char m_Char;
@ -115,6 +126,8 @@ public:
inline bool empty() const { return !m_Size; } inline bool empty() const { return !m_Size; }
const void *ptr() const { return m_Str; } 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 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); 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); return *new(this) CUtfStringView(other);
} }
static void append(std::string &str, u32char c);
private: private:
typedef u32char (*TIterator)(const void **addr); typedef u32char (*TIterator)(const void **addr);
static u32char utf8Iterator(const void **addr); static u32char utf8Iterator(const void **addr);

@ -130,6 +130,7 @@ void CFontManager::computeString (NLMISC::CUtfStringView sv,
output.CacheVersion = getCacheVersion(); output.CacheVersion = getCacheVersion();
uint j = 0; uint j = 0;
size_t idx = 0;
{ {
CVertexBufferReadWrite vba; CVertexBufferReadWrite vba;
output.Vertices.lock (vba); output.Vertices.lock (vba);
@ -138,8 +139,7 @@ void CFontManager::computeString (NLMISC::CUtfStringView sv,
hlfPixScrH = 0.f; hlfPixScrH = 0.f;
// For all chars // For all chars
//for (uint i = 0; i < s.size(); i++) for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++idx)
for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it)
{ {
// Creating font // Creating font
k.Char = *it; k.Char = *it;
@ -211,6 +211,8 @@ void CFontManager::computeString (NLMISC::CUtfStringView sv,
} }
} }
output.Vertices.setNumVertices (j); output.Vertices.setNumVertices (j);
output.Length = idx;
nlassert(output.Length == NLMISC::CUtfStringView(output.Text).count());
// compile string info // compile string info
output.StringWidth = (float)penx; output.StringWidth = (float)penx;
@ -314,6 +316,8 @@ void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv,
penx += pLI->AdvX; penx += pLI->AdvX;
} }
} }
output.Length = idx;
nlassert(output.Length == std::min(len, NLMISC::CUtfStringView(output.Text).count()));
// compile string info // compile string info
output.StringWidth = (float)penx; output.StringWidth = (float)penx;

@ -275,23 +275,23 @@ UTextContext::CStringInfo CTextContextUser::getStringInfo(uint32 i)
CComputedString *cstr= _TextContext.getComputedString(i); CComputedString *cstr= _TextContext.getComputedString(i);
if(!cstr) if(!cstr)
return CStringInfo(0, 0, 0); return CStringInfo(0, 0, 0, 0);
else 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) UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringView sv)
{ {
H_AUTO2; H_AUTO2;
_TextContext.computeStringInfo(sv, _CacheString); _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) UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringView sv, size_t len)
{ {
H_AUTO2; H_AUTO2;
_TextContext.computeStringInfo(sv, _CacheString, len); _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() void CTextContextUser::clear()
{ {

@ -1,8 +1,7 @@
FILE(GLOB SRC *.cpp *.h) FILE(GLOB SRC *.cpp *.h)
FILE(GLOB HEADERS ../../include/nel/gui/*.h) FILE(GLOB HEADERS ../../include/nel/gui/*.h)
SOURCE_GROUP("include" FILES ${HEADERS}) SOURCE_GROUP("" FILES ${HEADERS} ${SRC})
SOURCE_GROUP("src" FILES ${SRC})
NL_TARGET_LIB(nelgui ${SRC} ${HEADERS}) NL_TARGET_LIB(nelgui ${SRC} ${HEADERS})

@ -136,7 +136,7 @@ namespace NLGUI
if( name == "hardtext" ) if( name == "hardtext" )
{ {
if( _ViewText != NULL ) if( _ViewText != NULL )
return _ViewText->getText().toString(); return _ViewText->getText();
else else
return std::string( "" ); return std::string( "" );
} }
@ -316,7 +316,7 @@ namespace NLGUI
if( name == "hardtext" ) if( name == "hardtext" )
{ {
if( _ViewText != NULL ) if( _ViewText != NULL )
_ViewText->setText( value ); _ViewText->setHardText( value );
return; return;
} }
else else
@ -487,7 +487,7 @@ namespace NLGUI
xmlNewProp( node, BAD_CAST "wmargin", BAD_CAST toString( _WMargin ).c_str() ); 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 "wmin", BAD_CAST toString( _WMin ).c_str() );
xmlNewProp( node, BAD_CAST "hmin", BAD_CAST toString( _HMin ).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_y", BAD_CAST toString( _TextY ).c_str() );
xmlNewProp( node, BAD_CAST "text_x", BAD_CAST toString( _TextX ).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() ); xmlNewProp( node, BAD_CAST "text_underlined", BAD_CAST toString( _ViewText->getUnderlined() ).c_str() );
@ -596,11 +596,11 @@ namespace NLGUI
if (prop) if (prop)
{ {
const char *propPtr = prop; const char *propPtr = prop;
ucstring text; std::string text;
if (NLMISC::startsWith(propPtr, "ui")) if (NLMISC::startsWith(propPtr, "ui"))
text = CI18N::get(propPtr); text = CI18N::get(propPtr).toUtf8();
else else
text.fromUtf8(propPtr); text = propPtr;
_ViewText->setText(text); _ViewText->setText(text);
} }
} }
@ -990,7 +990,7 @@ namespace NLGUI
nlassert( v != NULL ); nlassert( v != NULL );
_ViewText = dynamic_cast< CViewText* >( v ); _ViewText = dynamic_cast< CViewText* >( v );
_ViewText->setId( _Id + "_text" ); _ViewText->setId( _Id + "_text" );
_ViewText->setText( ucstring( "text" ) ); _ViewText->setText( "text" );
_ViewText->setSerializable( false ); _ViewText->setSerializable( false );
} }
@ -1044,14 +1044,14 @@ namespace NLGUI
void CCtrlTextButton::setText (const ucstring &text) void CCtrlTextButton::setText (const ucstring &text)
{ {
if (_ViewText && !_IsViewTextId) if (_ViewText && !_IsViewTextId)
_ViewText->setText(text); _ViewText->setText(text.toUtf8());
} }
// *************************************************************************** // ***************************************************************************
ucstring CCtrlTextButton::getText () const ucstring CCtrlTextButton::getText () const
{ {
if (_ViewText && !_IsViewTextId) if (_ViewText && !_IsViewTextId)
return _ViewText->getText(); return CUtfStringView(_ViewText->getText()).toUtf16();
return ucstring(""); return ucstring("");
} }

@ -43,9 +43,9 @@ namespace NLGUI
void force_link_dbgroup_combo_box_cpp() { } void force_link_dbgroup_combo_box_cpp() { }
// Compare strings // Compare strings
static inline bool lt_text(const std::pair<int,ucstring> &s1, const std::pair<int,ucstring> &s2) static inline bool lt_text(const std::pair<int,std::string> &s1, const std::pair<int,std::string> &s2)
{ {
return toLower(s1.second) < toLower(s2.second); return toLowerAsUtf8(s1.second) < toLowerAsUtf8(s2.second);
} }
std::string CDBGroupComboBox::measureMenu; std::string CDBGroupComboBox::measureMenu;
@ -183,10 +183,10 @@ namespace NLGUI
if (name) if (name)
{ {
const char *propPtr = name; const char *propPtr = name;
ucstring Text = ucstring::makeFromUtf8(propPtr); if (NLMISC::startsWith(propPtr, "ui"))
if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) addText(CI18N::get(propPtr).toUtf8());
Text = CI18N::get (propPtr); else
addText(Text); addText(propPtr);
} }
} }
child = child->next; child = child->next;
@ -236,7 +236,7 @@ namespace NLGUI
// change selected text // change selected text
if(_CacheSelection<0 || _CacheSelection>=(sint32)_Texts.size() ) if(_CacheSelection<0 || _CacheSelection>=(sint32)_Texts.size() )
{ {
_ViewText->setText(ucstring()); _ViewText->setText(std::string());
} }
else if(_IsExternViewText) else if(_IsExternViewText)
{ {
@ -274,7 +274,7 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
void CDBGroupComboBox::addText(const ucstring &text) void CDBGroupComboBox::addText(const std::string &text)
{ {
dirt(); dirt();
_Texts.push_back(make_pair((uint)_Texts.size(), text)); _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(); dirt();
if(i<_Texts.size()) 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(); dirt();
if(i<_Texts.size()) 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(); dirt();
if(i<_Textures.size()) 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; static const std::string empty;
if(i<_Texts.size()) if (i < _Texts.size())
return _Texts[i].second; return _Texts[i].second;
else 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); 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; static const std::string empty;
if(i<_Textures.size()) if (i < _Textures.size())
return _Textures[i]; return _Textures[i];
else else
return null; return empty;
}
// ***************************************************************************
ucstring CDBGroupComboBox::getTextureAsUtf16(uint i) const
{
return ucstring::makeFromUtf8(getTexture(i));
} }
// *************************************************************************** // ***************************************************************************
@ -452,8 +464,7 @@ namespace NLGUI
sint32 value; sint32 value;
for(uint i=0; i<getNumTexts(); i++) for(uint i=0; i<getNumTexts(); i++)
{ {
std::string sText; std::string sText = getText(i);
getText(i).toString(sText);
if(sText == val) if(sText == val)
{ {
value = i; value = i;
@ -464,7 +475,7 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
void CDBGroupComboBox::setViewText(const ucstring & text) void CDBGroupComboBox::setViewText(const std::string &text)
{ {
_IsExternViewText = true; _IsExternViewText = true;
_ExternViewText = text; _ExternViewText = text;
@ -472,9 +483,15 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
ucstring CDBGroupComboBox::getViewText() const std::string CDBGroupComboBox::getViewText() const
{ {
return _ViewText->getText(); return _ViewText->getText();
}
// ***************************************************************************
ucstring CDBGroupComboBox::getViewTextAsUtf16() const
{
return CUtfStringView(_ViewText->getText()).toUtf16();
} }
// *************************************************************************** // ***************************************************************************
@ -486,18 +503,14 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
std::string CDBGroupComboBox::getSelectionText() const std::string CDBGroupComboBox::getSelectionText() const
{ {
ucstring text;
if (_LinkedToDB) if (_LinkedToDB)
{ {
text = getText(_Selection.getSInt32()); return getText(_Selection.getSInt32());
} }
else else
{ {
text = getText(_NotLinkedToDBSelection); return getText(_NotLinkedToDBSelection);
} }
std::string texteS;
text.toString(texteS);
return texteS;
} }
// *************************************************************************** // ***************************************************************************
@ -538,8 +551,7 @@ namespace NLGUI
sint32 value; sint32 value;
for(uint i=0; i<getNumTexts(); i++) for(uint i=0; i<getNumTexts(); i++)
{ {
std::string sText; std::string sText = getText(i);
getText(i).toString(sText);
if(sText == text) if(sText == text)
{ {
value = i; value = i;
@ -566,7 +578,7 @@ namespace NLGUI
CLuaIHM::checkArgTypeUCString(ls, funcName, 1); CLuaIHM::checkArgTypeUCString(ls, funcName, 1);
ucstring text; ucstring text;
nlverify(CLuaIHM::pop(ls, text)); nlverify(CLuaIHM::pop(ls, text));
addText(text); addText(text.toUtf8()); // FIXME: Lua should just do UTF-8!
return 0; return 0;
} }
@ -579,7 +591,7 @@ namespace NLGUI
CLuaIHM::checkArgTypeUCString(ls, funcName, 2); CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring text; ucstring text;
nlverify(CLuaIHM::pop(ls, text)); nlverify(CLuaIHM::pop(ls, text));
setText((uint) ls.toInteger(1), text); setText((uint) ls.toInteger(1), text.toUtf8()); // FIXME: Lua should just do UTF-8!
return 0; return 0;
} }
@ -592,7 +604,7 @@ namespace NLGUI
CLuaIHM::checkArgTypeUCString(ls, funcName, 2); CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring text; ucstring text;
nlverify(CLuaIHM::pop(ls, text)); nlverify(CLuaIHM::pop(ls, text));
insertText((uint) ls.toInteger(1), text); insertText((uint) ls.toInteger(1), text.toUtf8()); // FIXME: Lua should just do UTF-8!
return 0; return 0;
} }
@ -605,7 +617,7 @@ namespace NLGUI
CLuaIHM::checkArgTypeUCString(ls, funcName, 2); CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring texture; ucstring texture;
nlverify(CLuaIHM::pop(ls, texture)); nlverify(CLuaIHM::pop(ls, texture));
setTexture((uint) ls.toInteger(1), texture); setTexture((uint) ls.toInteger(1), texture.toUtf8()); // FIXME: Lua should just do UTF-8!
return 0; return 0;
} }
@ -625,7 +637,7 @@ namespace NLGUI
const char *funcName = "removeText"; const char *funcName = "removeText";
CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
removeText((uint) ls.toInteger(1)); removeText((uint)ls.toInteger(1));
return 0; return 0;
} }
@ -652,12 +664,12 @@ namespace NLGUI
{ {
// set the id as the parameter // set the id as the parameter
bool checkable = false; bool checkable = false;
if(getTexture(i).toString() != std::string()) if (getTexture(i) != std::string())
{ {
checkable = true; checkable = true;
} }
groupMenu->addLine(getText(i), "combo_box_select_end", toString(i), groupMenu->addLine(ucstring::makeFromUtf8(getText(i)), "combo_box_select_end", toString(i),
"", std::string(), getTexture(i).toString(), checkable); "", std::string(), getTexture(i), checkable);
groupMenu->setGrayedLine(i, getGrayed(i)); groupMenu->setGrayedLine(i, getGrayed(i));
} }

@ -43,7 +43,7 @@ namespace NLGUI
{ {
_Positive = false; _Positive = false;
_Cache= 0; _Cache= 0;
setText(ucstring("0")); setText(std::string("0"));
_Divisor = 1; _Divisor = 1;
_Modulo = 0; _Modulo = 0;
} }
@ -225,7 +225,7 @@ namespace NLGUI
// init cache. // init cache.
_Cache= 0; _Cache= 0;
setText(ucstring("0")); setText(std::string("0"));
return true; return true;
} }
@ -238,9 +238,9 @@ namespace NLGUI
if (_Cache != val) if (_Cache != val)
{ {
_Cache= val; _Cache= val;
ucstring value = _Format ? NLMISC::formatThousands(toString(val)) : toString(val); std::string value = _Format ? NLMISC::formatThousands(toString(val)) : toString(val);
if (_Positive) setText(val >= 0 ? ( ucstring(_Prefix) + value + ucstring(_Suffix) ) : ucstring("?")); if (_Positive) setText(val >= 0 ? ( _Prefix.toString() + value + _Suffix.toString() ) : "?");
else setText( ucstring(_Prefix) + value + ucstring(_Suffix) ); else setText( _Prefix.toString() + value + _Suffix.toString() );
} }
} }

@ -63,7 +63,7 @@ namespace NLGUI
else else
if( name == "emptytext" ) if( name == "emptytext" )
{ {
return _EmptyText.toString(); return _EmptyText;
} }
else else
return CViewText::getProperty( name ); return CViewText::getProperty( name );
@ -112,7 +112,7 @@ namespace NLGUI
else else
xmlSetProp( node, BAD_CAST "valuemax", BAD_CAST "" ); 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; return node;
} }
@ -148,9 +148,9 @@ namespace NLGUI
{ {
const char *propPtr = ptr; const char *propPtr = ptr;
if (NLMISC::startsWith(propPtr, "ui")) if (NLMISC::startsWith(propPtr, "ui"))
_EmptyText = CI18N::get(propPtr); _EmptyText = CI18N::get(propPtr).toUtf8();
else else
_EmptyText.fromUtf8(propPtr); _EmptyText = propPtr;
} }
// init cache. // init cache.

@ -3744,7 +3744,7 @@ namespace NLGUI
_TitleOpened->setY (pLayer->getValSInt32 ("title_offset_y")); _TitleOpened->setY (pLayer->getValSInt32 ("title_offset_y"));
} }
_TitleOpened->setFontSize (pLayer->getValSInt32 ("title_font_size")); _TitleOpened->setFontSize (pLayer->getValSInt32 ("title_font_size"));
if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened); if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened.toUtf8());
_TitleOpened->setActive (_Opened); _TitleOpened->setActive (_Opened);
// Title when the container is closed // Title when the container is closed
@ -3796,7 +3796,7 @@ namespace NLGUI
_TitleClosed->setY (pLayer->getValSInt32 ("title_offset_y")); _TitleClosed->setY (pLayer->getValSInt32 ("title_offset_y"));
} }
_TitleClosed->setFontSize (pLayer->getValSInt32 ("title_font_size")); _TitleClosed->setFontSize (pLayer->getValSInt32 ("title_font_size"));
if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed); if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed.toUtf8());
_TitleClosed->setActive(!_Opened); _TitleClosed->setActive(!_Opened);
@ -3990,7 +3990,7 @@ namespace NLGUI
{ {
_TitleTextOpened = title; _TitleTextOpened = title;
if (_TitleOpened != NULL) if (_TitleOpened != NULL)
_TitleOpened->setText (title); _TitleOpened->setText (title.toUtf8());
invalidateCoords(); invalidateCoords();
} }
@ -3999,7 +3999,7 @@ namespace NLGUI
{ {
_TitleTextClosed = title; _TitleTextClosed = title;
if (_TitleClosed != NULL) if (_TitleClosed != NULL)
_TitleClosed->setText (_TitleTextClosed); _TitleClosed->setText (_TitleTextClosed.toUtf8());
invalidateCoords(); invalidateCoords();
} }

@ -96,7 +96,7 @@ namespace NLGUI
_ViewTextDeltaX(0) _ViewTextDeltaX(0)
{ {
_Prompt = ">"; _Prompt = u32string(1, (u32char)'>');
_BackSelectColor= CRGBA::White; _BackSelectColor= CRGBA::White;
_TextSelectColor= CRGBA::Black; _TextSelectColor= CRGBA::Black;
} }
@ -170,7 +170,7 @@ namespace NLGUI
else else
if( name == "prompt" ) if( name == "prompt" )
{ {
return _Prompt.toString(); return CUtfStringView(_Prompt).toUtf8();
} }
else else
if( name == "enter_type" ) if( name == "enter_type" )
@ -354,7 +354,7 @@ namespace NLGUI
else else
if( name == "prompt" ) if( name == "prompt" )
{ {
_Prompt = value; _Prompt = CUtfStringView(value).toUtf32();
return; return;
} }
else else
@ -477,7 +477,7 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "max_chars_size", BAD_CAST toString( _MaxCharsSize ).c_str() ); 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_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 "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; std::string e;
switch( _EntryType ) switch( _EntryType )
@ -606,7 +606,7 @@ namespace NLGUI
if (prop) _ResetFocusOnHide = convertBool(prop); if (prop) _ResetFocusOnHide = convertBool(prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"prompt" ); 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" ); prop = (char*) xmlGetProp( cur, (xmlChar*)"entry_type" );
_EntryType = Text; _EntryType = Text;
@ -1015,7 +1015,7 @@ namespace NLGUI
_CursorAtPreviousLineEnd = false; _CursorAtPreviousLineEnd = false;
if (_ClearOnEscape) if (_ClearOnEscape)
{ {
setInputString(u32string()); setInputStringAsUtf32(u32string());
triggerOnChangeAH(); triggerOnChangeAH();
} }
CWidgetManager::getInstance()->setCaptureKeyboard(NULL); CWidgetManager::getInstance()->setCaptureKeyboard(NULL);
@ -1179,7 +1179,7 @@ namespace NLGUI
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
if (!_CanUndo) return false; if (!_CanUndo) return false;
_ModifiedInputString = _InputString; _ModifiedInputString = _InputString;
setInputString(_StartInputString); setInputStringAsUtf32(_StartInputString);
_CanUndo = false; _CanUndo = false;
_CanRedo = true; _CanRedo = true;
setCursorPos((sint32)_InputString.length()); setCursorPos((sint32)_InputString.length());
@ -1192,7 +1192,7 @@ namespace NLGUI
{ {
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
if (!_CanRedo) return false; if (!_CanRedo) return false;
setInputString(_ModifiedInputString); setInputStringAsUtf32(_ModifiedInputString);
_CanUndo = true; _CanUndo = true;
_CanRedo = false; _CanRedo = false;
setCursorPos((sint32)_InputString.length()); setCursorPos((sint32)_InputString.length());
@ -1303,7 +1303,7 @@ namespace NLGUI
default: break; default: break;
} }
// update the text // update the text
setInputString(_InputString); setInputStringAsUtf32(_InputString);
// if event of type char or string, consider handle all of them // if event of type char or string, consider handle all of them
if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring ) if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring )
@ -1433,16 +1433,14 @@ namespace NLGUI
{ {
if (_ViewText) if (_ViewText)
{ {
ucstring usTmp; std::string usTmp;
if (_EntryType == Password) if (_EntryType == Password)
{ {
usTmp = _Prompt; usTmp = CUtfStringView(_Prompt + u32string(_InputString.size(), 0x2022)).toUtf8();
for (uint32 i = 0; i < _InputString.size(); ++i)
usTmp += "*";
} }
else else
{ {
usTmp = _Prompt + CUtfStringView(_InputString).toUtf16(); usTmp = CUtfStringView(_Prompt + _InputString).toUtf8();
} }
_ViewText->setText (usTmp); _ViewText->setText (usTmp);
} }
@ -1585,7 +1583,7 @@ namespace NLGUI
addView( _ViewText ); addView( _ViewText );
sint32 w,h; 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() ); h = std::max( sint32( _ViewText->getFontHeight() ), getH() );
setH( h ); 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; _InputString = str;
if (_CursorPos > (sint32) str.length()) if (_CursorPos > (sint32) str.length())
@ -1644,43 +1653,42 @@ namespace NLGUI
void CGroupEditBox::setDefaultInputString(const ucstring &str) void CGroupEditBox::setDefaultInputString(const ucstring &str)
{ {
_DefaultInputString= true; _DefaultInputString= true;
setInputString(CUtfStringView(str).toUtf32()); setInputStringAsUtf32(CUtfStringView(str).toUtf32());
} }
// *************************************************************************** // ***************************************************************************
sint32 CGroupEditBox::getInputStringAsInt() const sint32 CGroupEditBox::getInputStringAsInt() const
{ {
sint32 value; sint32 value;
fromString(getInputStringAsUtf8(), value); fromString(getInputString(), value);
return value; return value;
} }
// *************************************************************************** // ***************************************************************************
void CGroupEditBox::setInputStringAsInt(sint32 val) void CGroupEditBox::setInputStringAsInt(sint32 val)
{ {
setInputStringAsUtf8(NLMISC::toString(val)); setInputString(NLMISC::toString(val));
} }
// *************************************************************************** // ***************************************************************************
sint64 CGroupEditBox::getInputStringAsInt64() const sint64 CGroupEditBox::getInputStringAsInt64() const
{ {
sint64 value; sint64 value;
fromString(getInputStringAsUtf8(), value); fromString(getInputString(), value);
return value; return value;
} }
// *************************************************************************** // ***************************************************************************
void CGroupEditBox::setInputStringAsInt64(sint64 val) void CGroupEditBox::setInputStringAsInt64(sint64 val)
{ {
setInputStringAsUtf8(NLMISC::toString(val)); setInputString(NLMISC::toString(val));
} }
// *************************************************************************** // ***************************************************************************
float CGroupEditBox::getInputStringAsFloat() const float CGroupEditBox::getInputStringAsFloat() const
{ {
float value; float value;
fromString(getInputStringAsUtf8(), value); fromString(getInputString(), value);
return value; return value;
} }
@ -1688,7 +1696,7 @@ namespace NLGUI
void CGroupEditBox::setInputStringAsFloat(float val) void CGroupEditBox::setInputStringAsFloat(float val)
{ {
string fmt= "%." + NLMISC::toString(_MaxFloatPrec) + "f"; 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) void CGroupEditBox::setInputStringAsUtf16(const ucstring &str)
{ {
setInputString(CUtfStringView(str).toUtf32()); setInputStringAsUtf32(CUtfStringView(str).toUtf32());
} }
// *************************************************************************** // ***************************************************************************
@ -1770,7 +1778,7 @@ namespace NLGUI
return; return;
// set the string and maybe execute // set the string and maybe execute
setInputString(CUtfStringView((ucchar) '/' + command).toUtf32()); setInputStringAsUtf16((ucchar) '/' + command);
if (execute) if (execute)
{ {
// stop selection // stop selection
@ -1853,7 +1861,7 @@ namespace NLGUI
f.serial(_PrevNumLine); f.serial(_PrevNumLine);
if (f.isReading()) if (f.isReading())
{ {
setInputString(_InputString); setInputStringAsUtf32(_InputString);
} }
// serial selection // serial selection
@ -1870,7 +1878,7 @@ namespace NLGUI
void CGroupEditBox::onQuit() void CGroupEditBox::onQuit()
{ {
// clear the text and restore backup pos before final save // clear the text and restore backup pos before final save
setInputString(u32string()); setInputStringAsUtf32(u32string());
_CurrSelection = NULL; _CurrSelection = NULL;
} }
@ -1878,7 +1886,7 @@ namespace NLGUI
void CGroupEditBox::onLoadConfig() void CGroupEditBox::onLoadConfig()
{ {
// config is not saved when there's an empty string, so restore that default state. // config is not saved when there's an empty string, so restore that default state.
setInputString(u32string()); setInputStringAsUtf32(u32string());
_CurrSelection = NULL; _CurrSelection = NULL;
_PrevNumLine = 1; _PrevNumLine = 1;
} }
@ -1893,7 +1901,7 @@ namespace NLGUI
if (_DefaultInputString) if (_DefaultInputString)
{ {
_DefaultInputString= false; _DefaultInputString= false;
setInputString(u32string()); setInputStringAsUtf32(u32string());
} }
_CanRedo = false; _CanRedo = false;
_CanUndo = false; _CanUndo = false;

@ -2830,7 +2830,7 @@ namespace NLGUI
// Number of child in this paragraph // Number of child in this paragraph
if (_CurrentViewLink) 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(); bool sameShadow = style.TextShadow.Enabled && _CurrentViewLink->getShadow();
if (sameShadow && style.TextShadow.Enabled) if (sameShadow && style.TextShadow.Enabled)
{ {
@ -2853,7 +2853,7 @@ namespace NLGUI
(style.GlobalColor == _CurrentViewLink->getModulateGlobalColor())) (style.GlobalColor == _CurrentViewLink->getModulateGlobalColor()))
{ {
// Concat the text // Concat the text
_CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr); _CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr.toUtf8());
_CurrentViewLink->invalidateContent(); _CurrentViewLink->invalidateContent();
added = true; added = true;
} }
@ -2916,7 +2916,7 @@ namespace NLGUI
newLink->setParamsOnLeftClick("name=" + getId() + "|url=" + newLink->Link); newLink->setParamsOnLeftClick("name=" + getId() + "|url=" + newLink->Link);
} }
} }
newLink->setText(tmpStr); newLink->setText(tmpStr.toUtf8());
newLink->setMultiLineSpace((uint)((float)(style.FontSize)*LineSpaceFontFactor)); newLink->setMultiLineSpace((uint)((float)(style.FontSize)*LineSpaceFontFactor));
newLink->setMultiLine(true); newLink->setMultiLine(true);
newLink->setModulateGlobalColor(style.GlobalColor); newLink->setModulateGlobalColor(style.GlobalColor);
@ -3024,7 +3024,7 @@ namespace NLGUI
CGroupEditBox *eb = dynamic_cast<CGroupEditBox*>(textArea->getGroup("eb")); CGroupEditBox *eb = dynamic_cast<CGroupEditBox*>(textArea->getGroup("eb"));
if (eb) if (eb)
{ {
eb->setInputString(CUtfStringView(decodeHTMLEntities(content)).toUtf32()); eb->setInputString(CUtfStringView(decodeHTMLEntities(content)).toUtf8());
if (style.hasStyle("background-color")) if (style.hasStyle("background-color"))
{ {
CViewBitmap *bg = dynamic_cast<CViewBitmap*>(eb->getView("bg")); CViewBitmap *bg = dynamic_cast<CViewBitmap*>(eb->getView("bg"));
@ -3306,11 +3306,11 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
ucchar CGroupHTML::getLastChar() const u32char CGroupHTML::getLastChar() const
{ {
if (_CurrentViewLink) if (_CurrentViewLink)
{ {
const ucstring &str = _CurrentViewLink->getText(); u32string str = CUtfStringView(_CurrentViewLink->getText()).toUtf32(); // FIXME: Optimize reverse UTF iteration
if (!str.empty()) if (!str.empty())
return str[str.length()-1]; return str[str.length()-1];
} }
@ -3710,7 +3710,7 @@ namespace NLGUI
CGroupEditBox *editBox = dynamic_cast<CGroupEditBox*>(group); CGroupEditBox *editBox = dynamic_cast<CGroupEditBox*>(group);
if (editBox) if (editBox)
{ {
entryData = editBox->getViewText()->getText(); entryData = CUtfStringView(editBox->getViewText()->getText()).toUtf16();
addEntry = true; addEntry = true;
} }
} }
@ -6437,7 +6437,7 @@ namespace NLGUI
if (cb) if (cb)
{ {
uint lineIndex = cb->getNumTexts(); uint lineIndex = cb->getNumTexts();
cb->addText(_SelectOptionStr); cb->addText(_SelectOptionStr.toUtf8());
if (_Forms.back().Entries.back().sbOptionDisabled == lineIndex) if (_Forms.back().Entries.back().sbOptionDisabled == lineIndex)
{ {
cb->setGrayed(lineIndex, true); cb->setGrayed(lineIndex, true);

@ -548,7 +548,7 @@ namespace NLGUI
view->setMultiLine (multiLine); view->setMultiLine (multiLine);
view->setTextMode(_Templ.getTextMode()); view->setTextMode(_Templ.getTextMode());
if (multiLine) view->setMultiLineSpace (_Space); if (multiLine) view->setMultiLineSpace (_Space);
view->setText (line); view->setText (line.toUtf8());
// Herit global-coloring // Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor()); view->setModulateGlobalColor(getModulateGlobalColor());
addChild(view); addChild(view);
@ -566,7 +566,7 @@ namespace NLGUI
view->_Parent = this; view->_Parent = this;
view->setMultiLine (multiLine); view->setMultiLine (multiLine);
if (multiLine) view->setMultiLineSpace (_Space); if (multiLine) view->setMultiLineSpace (_Space);
view->setText (line); view->setText (line.toUtf8());
view->setColor (textColor); view->setColor (textColor);
// Herit global-coloring // Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor()); view->setModulateGlobalColor(getModulateGlobalColor());

@ -1231,11 +1231,11 @@ namespace NLGUI
{ {
pV->setMultiLine (true); pV->setMultiLine (true);
pV->setMultiLineMaxWOnly (true); pV->setMultiLineMaxWOnly (true);
pV->setTextFormatTaged (name); pV->setTextFormatTaged (name.toUtf8());
} }
else else
{ {
pV->setText (name); pV->setText (name.toUtf8());
} }
pV->setColor (_GroupMenu->_Color); pV->setColor (_GroupMenu->_Color);
pV->setFontSize (_GroupMenu->_FontSize, _GroupMenu->_FontSizeCoef); pV->setFontSize (_GroupMenu->_FontSize, _GroupMenu->_FontSizeCoef);
@ -1319,11 +1319,11 @@ namespace NLGUI
{ {
pV->setMultiLine (true); pV->setMultiLine (true);
pV->setMultiLineMaxWOnly (true); pV->setMultiLineMaxWOnly (true);
pV->setTextFormatTaged (name); pV->setTextFormatTaged (name.toUtf8());
} }
else else
{ {
pV->setText (name); pV->setText (name.toUtf8());
} }
pV->setColor (_GroupMenu->_Color); pV->setColor (_GroupMenu->_Color);
@ -1602,7 +1602,7 @@ namespace NLGUI
texture = _Lines[k].ViewText->getCheckBox()->getTexture(); texture = _Lines[k].ViewText->getCheckBox()->getTexture();
} }
CViewTextMenu *pV = NULL; 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 ()); texture, _Lines[k].ViewText->getCheckable(), _Lines[k].ViewText->getChecked(), _Lines[k].ViewText->getFormatted ());
copyMenu->_Lines[k].Selectable = _Lines[k].Selectable; copyMenu->_Lines[k].Selectable = _Lines[k].Selectable;
pV->setGrayed(_Lines[k].ViewText->getGrayed()); pV->setGrayed(_Lines[k].ViewText->getGrayed());

@ -503,7 +503,7 @@ namespace NLGUI
view->setMultiLine (multiLine); view->setMultiLine (multiLine);
view->setTextMode(_Templ.getTextMode()); view->setTextMode(_Templ.getTextMode());
if (multiLine) view->setMultiLineSpace (_Space); if (multiLine) view->setMultiLineSpace (_Space);
view->setText (line); view->setText (line.toUtf8());
// Herit global-coloring // Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor()); view->setModulateGlobalColor(getModulateGlobalColor());
addChild (view); addChild (view);
@ -520,7 +520,7 @@ namespace NLGUI
view->_Parent = this; view->_Parent = this;
view->setMultiLine (multiLine); view->setMultiLine (multiLine);
if (multiLine) view->setMultiLineSpace (_Space); if (multiLine) view->setMultiLineSpace (_Space);
view->setText (line); view->setText (line.toUtf8());
view->setColor (textColor); view->setColor (textColor);
// Herit global-coloring // Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor()); view->setModulateGlobalColor(getModulateGlobalColor());
@ -730,7 +730,7 @@ namespace NLGUI
if (viewText) if (viewText)
{ {
changeLine = viewText->getNumLine() > 1; changeLine = viewText->getNumLine() > 1;
if (!viewText->getText().empty() && *(viewText->getText().rbegin()) == (ucchar) '\n') if (!viewText->getText().empty() && *(viewText->getText().rbegin()) == '\n')
{ {
changeLine = true; changeLine = true;
} }

@ -1292,7 +1292,7 @@ namespace NLGUI
CViewText *pVT = new CViewText(TCtorParam()); CViewText *pVT = new CViewText(TCtorParam());
line.TextOrTemplate = pVT; line.TextOrTemplate = pVT;
pVT->setId("t"+toString(_Lines.size())); pVT->setId("t"+toString(_Lines.size()));
pVT->setText(pNode->Text); pVT->setText(pNode->Text.toUtf8());
pVT->setColor(pNode->Color); pVT->setColor(pNode->Color);
if(pNode->FontSize==-1) if(pNode->FontSize==-1)
pVT->setFontSize(_FontSize); pVT->setFontSize(_FontSize);

@ -19,6 +19,7 @@
#include "stdpch.h" #include "stdpch.h"
#include "nel/gui/string_case.h" #include "nel/gui/string_case.h"
#include "nel/misc/utf_string_view.h"
#ifdef DEBUG_NEW #ifdef DEBUG_NEW
#define new DEBUG_NEW #define new DEBUG_NEW
@ -26,13 +27,33 @@
namespace NLGUI namespace NLGUI
{ {
inline bool isSeparator (u32char c)
{
return (c == (u32char)' ') || (c == (u32char)'\t') || (c == (u32char)'\n') || (c == (u32char)'\r');
}
inline bool isSeparator (ucchar c) inline bool isSeparator (ucchar c)
{ {
return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'); 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) inline bool isEndSentence (ucstring& str, uint index)
{ {
// Ex: One sentence. Another sentence. // 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;
}
}
} }

@ -458,14 +458,14 @@ namespace NLGUI
{ {
CViewText *text = dynamic_cast<CViewText*> (element); CViewText *text = dynamic_cast<CViewText*> (element);
if (text) if (text)
text->setText(str); text->setText(str.toUtf8());
} }
element = target->getView ("real_txt"); element = target->getView ("real_txt");
if (element) if (element)
{ {
CViewText *text = dynamic_cast<CViewText*> (element); CViewText *text = dynamic_cast<CViewText*> (element);
if (text) if (text)
text->setText(str); text->setText(str.toUtf8());
} }
target->updateCoords(); target->updateCoords();
target->updateCoords(); target->updateCoords();

@ -87,7 +87,7 @@ namespace NLGUI
formatedResult = formatString(_FormatString, ucstring("")); formatedResult = formatString(_FormatString, ucstring(""));
// //
setText (formatedResult); setText (formatedResult.toUtf8());
CViewText::checkCoords(); CViewText::checkCoords();
} }

@ -233,9 +233,9 @@ namespace NLGUI
// Set the Text // Set the Text
if(_IsTextFormatTaged) if(_IsTextFormatTaged)
setTextFormatTaged(result); setTextFormatTaged(result.toUtf8());
else else
setText (result); setText (result.toUtf8());
} }
CViewText::checkCoords(); CViewText::checkCoords();
} }

@ -106,7 +106,7 @@ namespace NLGUI
} }
formatedResult = CViewTextFormated::formatString(_FormatString, result); formatedResult = CViewTextFormated::formatString(_FormatString, result);
// //
setText (formatedResult); setText (formatedResult.toUtf8());
// //
if (bValid) if (bValid)
{ {

@ -1531,7 +1531,7 @@ namespace NLGUI
CViewText *pTxt = (CViewText*)groupContextHelp->getView("text"); CViewText *pTxt = (CViewText*)groupContextHelp->getView("text");
if (pTxt != NULL) if (pTxt != NULL)
{ {
pTxt->setTextFormatTaged(_ContextHelpText); pTxt->setTextFormatTaged(_ContextHelpText.toUtf8());
// update only to get correct W/H // update only to get correct W/H
groupContextHelp->updateCoords (); groupContextHelp->updateCoords ();

@ -232,15 +232,15 @@ bool loadStringFile(const std::string filename, vector<TStringInfo> &stringInfos
ucstring prepareStringFile(const vector<TStringInfo> &strings, bool removeDiffComments, bool noDiffInfo) ucstring prepareStringFile(const vector<TStringInfo> &strings, bool removeDiffComments, bool noDiffInfo)
{ {
ucstring diff; string diff;
vector<TStringInfo>::const_iterator first(strings.begin()), last(strings.end()); vector<TStringInfo>::const_iterator first(strings.begin()), last(strings.end());
for (; first != last; ++first) for (; first != last; ++first)
{ {
ucstring str; string str;
const TStringInfo &si = *first; const TStringInfo &si = *first;
string comment = si.Comments.toString(); string comment = si.Comments.toUtf8();
vector<string> lines; vector<string> lines;
explode(comment, string("\n"), lines, true); explode(comment, string("\n"), lines, true);
uint i; uint i;
@ -274,30 +274,29 @@ ucstring prepareStringFile(const vector<TStringInfo> &strings, bool removeDiffCo
} }
si.Comments = ucstring(comment); si.Comments = ucstring(comment);
str = si.Comments; str = comment;
if (!si.Identifier.empty() || !si.Text.empty()) if (!si.Identifier.empty() || !si.Text.empty())
{ {
// add hash value comment if needed // add hash value comment if needed
// if (si.Comments.find(ucstring("// HASH_VALUE ")) == ucstring::npos) // if (si.Comments.find(ucstring("// HASH_VALUE ")) == ucstring::npos)
if (!noDiffInfo) if (!noDiffInfo)
{ {
str += ucstring("// HASH_VALUE ") + CI18N::hashToString(si.HashValue)+ nl; str += "// HASH_VALUE " + CI18N::hashToString(si.HashValue) + "\n";
str += ucstring("// INDEX ") + NLMISC::toString("%u", first-strings.begin())+ nl; str += "// INDEX " + NLMISC::toString("%u", first-strings.begin()) + "\n";
} }
str += si.Identifier + '\t'; str += si.Identifier + '\t';
ucstring text = CI18N::makeMarkedString('[', ']', si.Text);; string text = CI18N::makeMarkedString('[', ']', si.Text).toUtf8();
ucstring text2; string text2;
// add new line and tab after each \n tag // add new line and tab after each \n tag
ucstring::size_type pos; string::size_type pos;
const ucstring nlTag("\\n"); while ((pos = text.find("\\n")) != string::npos)
while ((pos = text.find(nlTag)) != ucstring::npos)
{ {
text2 += text.substr(0, pos+2) + nl + "\t"; text2 += text.substr(0, pos+2) + "\n\t";
text = text.substr(pos+2); text = text.substr(pos+2);
} }
text2 += text;//.substr(0, pos+2); text2 += text;//.substr(0, pos+2);
str += text2 + nl + nl; str += text2 + "\n\n";
// str += CI18N::makeMarkedString('[', ']', si.Text) + nl + nl; // str += CI18N::makeMarkedString('[', ']', si.Text) + nl + nl;
} }
@ -305,7 +304,7 @@ ucstring prepareStringFile(const vector<TStringInfo> &strings, bool removeDiffCo
diff += str; diff += str;
} }
return diff; return ucstring::makeFromUtf8(diff);
} }

@ -20,14 +20,7 @@
void ucstring::toString(std::string &str) const void ucstring::toString(std::string &str) const
{ {
str.resize(size()); str = nlmove(NLMISC::CUtfStringView(*this).toUtf8());
for (uint i = 0; i < str.size(); i++)
{
if (operator[](i) > 255)
str[i] = '?';
else
str[i] = (char)operator[](i);
}
} }
std::string ucstring::toUtf8() const std::string ucstring::toUtf8() const
@ -40,17 +33,4 @@ void ucstring::fromUtf8(const std::string &stringUtf8)
*this = NLMISC::CUtfStringView(stringUtf8).toUtf16(); *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 */ /* end of file */

@ -16,6 +16,7 @@
#include "stdmisc.h" #include "stdmisc.h"
#include "nel/misc/ucstring.h" #include "nel/misc/ucstring.h"
#include "nel/misc/utf_string_view.h"
#ifdef DEBUG_NEW #ifdef DEBUG_NEW
#define new 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) ucstring toUpper (const ucstring &str)
{ {
uint i; 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 } // NLMISC

@ -29,6 +29,41 @@
namespace NLMISC 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 std::string CUtfStringView::toUtf8(bool reEncode) const
{ {
// Decode UTF and encode UTF-8 // Decode UTF and encode UTF-8
@ -39,33 +74,7 @@ std::string CUtfStringView::toUtf8(bool reEncode) const
res.reserve(m_Size); res.reserve(m_Size);
for (iterator it(begin()), end(end()); it != end; ++it) for (iterator it(begin()), end(end()); it != end; ++it)
{ {
u32char c = *it; appendUtf8(res, *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;
}
} }
return res; return res;
} }
@ -106,6 +115,21 @@ u32string CUtfStringView::toUtf32() const
return res; 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 std::wstring CUtfStringView::toWide() const
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
@ -139,6 +163,14 @@ std::wstring CUtfStringView::toWide() const
#endif #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) u32char CUtfStringView::utf8Iterator(const void **addr)
{ {
// Decode UTF-8 // Decode UTF-8

@ -1019,7 +1019,7 @@ TInterfaceState globalMenu()
// Display the firewall alert string // Display the firewall alert string
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:outgame:connecting:title")); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:outgame:connecting:title"));
if (pVT != NULL) 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 // 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 nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts
@ -1235,8 +1235,8 @@ TInterfaceState globalMenu()
if (pVT != NULL) if (pVT != NULL)
{ {
pVT->setMultiLine( true ); pVT->setMultiLine( true );
pVT->setText(CI18N::get("uiFirewallFail")+ucstring(".\n")+ pVT->setText(CI18N::get("uiFirewallFail").toUtf8()+".\n"+
CI18N::get("uiFirewallAlert")+ucstring(".")); CI18N::get("uiFirewallAlert").toUtf8()+".");
} }
} }
} }
@ -1317,16 +1317,16 @@ public:
if (pVT == NULL) return; if (pVT == NULL) return;
if (rCS.Name.empty()) if (rCS.Name.empty())
pVT->setText(CI18N::get("uiEmptySlot")); pVT->setText(CI18N::get("uiEmptySlot").toUtf8());
else else
pVT->setText(rCS.Name); pVT->setText(rCS.Name.toUtf8());
} }
// 5 slots // 5 slots
for (; i < 5; ++i) for (; i < 5; ++i)
{ {
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i))); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i)));
if (pVT == NULL) return; if (pVT == NULL) return;
pVT->setText(CI18N::get("uiEmptySlot")); pVT->setText(CI18N::get("uiEmptySlot").toUtf8());
} }
} }
}; };
@ -2168,8 +2168,8 @@ public:
CViewText *pVT = dynamic_cast<CViewText*>(pNewLine->getView("name")); CViewText *pVT = dynamic_cast<CViewText*>(pNewLine->getView("name"));
if (pVT != NULL) if (pVT != NULL)
{ {
ucstring ucstr = Mainlands[i].Name + ucstring(" ") + Mainlands[i].Description; std::string str = Mainlands[i].Name.toUtf8() + " " + Mainlands[i].Description.toUtf8();
pVT->setText(ucstr); pVT->setText(str);
} }
// Add to the list // Add to the list
@ -2309,7 +2309,7 @@ public:
CViewText *pVT = dynamic_cast<CViewText*>(pNewLine->getView("name")); CViewText *pVT = dynamic_cast<CViewText*>(pNewLine->getView("name"));
if (pVT != NULL) if (pVT != NULL)
{ {
pVT->setText(name); pVT->setText(name.toUtf8());
} }
CCtrlBase *pBut = pNewLine->getCtrl("but"); CCtrlBase *pBut = pNewLine->getCtrl("but");
@ -2557,7 +2557,7 @@ static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName
{ {
CViewText* viewText = dynamic_cast<CViewText*>(result); CViewText* viewText = dynamic_cast<CViewText*>(result);
if(viewText) if(viewText)
viewText->setText(text); viewText->setText(text.toUtf8());
CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result); CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result);
if(editBox) if(editBox)
editBox->setInputStringAsUtf16(text); editBox->setInputStringAsUtf16(text);
@ -2680,7 +2680,7 @@ class CAHScenarioControl : public IActionHandler
CViewText* viewText = dynamic_cast<CViewText*>(result); CViewText* viewText = dynamic_cast<CViewText*>(result);
if(viewText) 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<CViewText*>(result); CViewText* viewText= dynamic_cast<CViewText*>(result);
if(viewText) if(viewText)
viewText->setText(ucstring("")); viewText->setText("");
} }
} }
setScenarioInformation(scenarioWnd, ""); setScenarioInformation(scenarioWnd, "");
@ -2746,7 +2746,7 @@ class CAHScenarioControl : public IActionHandler
CViewText *shardName = dynamic_cast<CViewText *>(toggleGr->getView("button_text")); CViewText *shardName = dynamic_cast<CViewText *>(toggleGr->getView("button_text"));
if (shardName) 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<CGroupEditBox*>(result); CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result);
if(editBox) if(editBox)
description = editBox->getInputStringAsUtf8(); description = editBox->getInputString();
} }
// races // races
@ -3248,7 +3248,7 @@ class CAHLoadScenario : public IActionHandler
{ {
CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL) 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"); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
return; return;
@ -3329,7 +3329,7 @@ class CAHLoadScenario : public IActionHandler
{ {
CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL) 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"); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
} }
@ -3358,7 +3358,7 @@ class CAHLoadScenario : public IActionHandler
{ {
CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL) 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"); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
} }
} }

@ -2349,7 +2349,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value)
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:player:header_opened:player_title")); CViewText *pVT = dynamic_cast<CViewText*>(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<CGroupContainer*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:player")); CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:player"));
if (pGC != NULL) pGC->setUCTitle(_EntityName); if (pGC != NULL) pGC->setUCTitle(_EntityName);

@ -712,18 +712,18 @@ void CGameContextMenu::updateContextMenuMissionsOptions( bool forceHide )
{ {
result = NLMISC::CI18N::get("uiMissionOptionNotReceived"); result = NLMISC::CI18N::get("uiMissionOptionNotReceived");
} }
pVTM->setText(result); pVTM->setText(result.toUtf8());
pVTM->setActive(true); pVTM->setActive(true);
} }
else else
{ {
pVTM->setText(ucstring("")); pVTM->setText("");
pVTM->setActive(false); pVTM->setActive(false);
} }
} }
else else
{ {
pVTM->setText(ucstring("")); pVTM->setText("");
pVTM->setActive(false); pVTM->setActive(false);
} }
} }
@ -753,16 +753,16 @@ void CGameContextMenu::updateContextMenuWebPage(uint options)
{ {
result = NLMISC::CI18N::get("uiWebPageNameNotReceived"); result = NLMISC::CI18N::get("uiWebPageNameNotReceived");
} }
pVTM->setText(result); pVTM->setText(result.toUtf8());
} }
else else
{ {
pVTM->setText(ucstring("")); pVTM->setText("");
} }
} }
else else
{ {
pVTM->setText(ucstring("")); pVTM->setText("");
} }
} }
@ -791,7 +791,7 @@ void CGameContextMenu::updateContextMenuOutpostState(uint options)
{ {
CViewTextMenu *pVTM = _TextOutpostState; CViewTextMenu *pVTM = _TextOutpostState;
if (pVTM) if (pVTM)
pVTM->setText(ucstring(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet))); pVTM->setText(CUtfStringView(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)).toUtf8());
} }
// apply the active // apply the active
@ -833,12 +833,12 @@ void CGameContextMenu::updateContextMenuMissionRing()
{ {
result = NLMISC::CI18N::get("uiMissionRingNameNotReceived"); result = NLMISC::CI18N::get("uiMissionRingNameNotReceived");
} }
pVTM->setText(result); pVTM->setText(result.toUtf8());
pVTM->setActive(true); pVTM->setActive(true);
} }
else else
{ {
pVTM->setText(ucstring("")); pVTM->setText("");
pVTM->setActive(false); pVTM->setActive(false);
} }
} }

@ -288,11 +288,11 @@ class CAHEditGotoLineBegin : public CAHEdit
// go to the start of line // go to the start of line
if (_GroupEdit->getViewText()) 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; 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; if (newPos == -1) return;
_GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPrompt().length()); _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPromptRef().length());
_GroupEdit->setCursorAtPreviousLineEnd(false); _GroupEdit->setCursorAtPreviousLineEnd(false);
} }
} }
@ -310,20 +310,20 @@ class CAHEditGotoLineEnd : public CAHEdit
{ {
if (_GroupEdit->getViewText()->getMultiLine()) 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; if (line == -1) return;
sint newPos; sint newPos;
bool endOfPreviousLine; bool endOfPreviousLine;
_GroupEdit->getViewText()->getLineEndIndex(line, newPos, endOfPreviousLine); _GroupEdit->getViewText()->getLineEndIndex(line, newPos, endOfPreviousLine);
if (newPos != -1) if (newPos != -1)
{ {
_GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPrompt().length()); _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPromptRef().length());
_GroupEdit->setCursorAtPreviousLineEnd(endOfPreviousLine); _GroupEdit->setCursorAtPreviousLineEnd(endOfPreviousLine);
} }
} }
else 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()) else if (_GroupEdit->getViewText()->getMultiLine())
{ {
uint cursorPosInText = _GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length(); uint cursorPosInText = _GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length();
if ( if (
(_GroupEdit->getCursorPos() == (sint32) _GroupEdit->getInputStringRef().length() && _GroupEdit->getViewText()->getNumLine() == 1) || (_GroupEdit->getCursorPos() == (sint32) _GroupEdit->getInputStringRef().length() && _GroupEdit->getViewText()->getNumLine() == 1) ||
_GroupEdit->getViewText()->getLineFromIndex(cursorPosInText, _GroupEdit->isCursorAtPreviousLineEnd()) == 0 _GroupEdit->getViewText()->getLineFromIndex(cursorPosInText, _GroupEdit->isCursorAtPreviousLineEnd()) == 0
@ -396,7 +396,7 @@ class CAHEditPreviousLine : public CAHEdit
_GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd); _GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd);
if (newLineEnd) if (newLineEnd)
{ {
_GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPrompt().length()); _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPromptRef().length());
_GroupEdit->setCursorAtPreviousLineEnd(true); _GroupEdit->setCursorAtPreviousLineEnd(true);
sint32 newPos = _GroupEdit->getCursorPos(); sint32 newPos = _GroupEdit->getCursorPos();
clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size());
@ -417,7 +417,7 @@ class CAHEditPreviousLine : public CAHEdit
{ {
_GroupEdit->setCursorPos(newCharIndex + 1); _GroupEdit->setCursorPos(newCharIndex + 1);
} }
_GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPrompt().length()); _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPromptRef().length());
sint32 newpos = _GroupEdit->getCursorPos(); sint32 newpos = _GroupEdit->getCursorPos();
clamp(newpos, (sint32) 0, (sint32)_GroupEdit->getInputStringRef().size()); clamp(newpos, (sint32) 0, (sint32)_GroupEdit->getInputStringRef().size());
_GroupEdit->setCursorPos(newpos); _GroupEdit->setCursorPos(newpos);
@ -452,7 +452,7 @@ class CAHEditNextLine : public CAHEdit
{ {
float cx, cy; float cx, cy;
float height; 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) if (cy != 0)
{ {
cy -= height; cy -= height;
@ -461,7 +461,7 @@ class CAHEditNextLine : public CAHEdit
_GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd); _GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd);
if (newLineEnd) if (newLineEnd)
{ {
_GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPrompt().length()); _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPromptRef().length());
_GroupEdit->setCursorAtPreviousLineEnd(true); _GroupEdit->setCursorAtPreviousLineEnd(true);
sint32 newPos = _GroupEdit->getCursorPos(); sint32 newPos = _GroupEdit->getCursorPos();
clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size());
@ -480,9 +480,9 @@ class CAHEditNextLine : public CAHEdit
} }
else 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(); sint32 newPos = _GroupEdit->getCursorPos();
clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size());
_GroupEdit->setCursorPos(newPos); _GroupEdit->setCursorPos(newPos);
@ -639,8 +639,7 @@ class CAHEditExpandOrCycleTell : public CAHEdit
void actionPart () void actionPart ()
{ {
// If the line starts with '/tell ', do not try to expand // If the line starts with '/tell ', do not try to expand
static const u32string TELL_STR(CUtfStringView("/tell ").toUtf32()); if (!NLMISC::startsWith(_GroupEdit->getInputString(), "/tell "))
if (_GroupEdit->getInputString().substr(0, TELL_STR.length()) != TELL_STR)
{ {
if (_GroupEdit->expand()) return; if (_GroupEdit->expand()) return;
} }

@ -3010,7 +3010,7 @@ void updateVRDevicesComboUI(bool enable)
{ {
std::stringstream displayname; std::stringstream displayname;
displayname << std::string("[") << VRDeviceCache[i].first << "] [" << VRDeviceCache[i].second << "]"; 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 (ClientCfg.VRDisplayDevice == VRDeviceCache[i].first)
{ {
if (selectedDevice == -1 || ClientCfg.VRDisplayDeviceId == VRDeviceCache[i].second) if (selectedDevice == -1 || ClientCfg.VRDisplayDeviceId == VRDeviceCache[i].second)
@ -3024,7 +3024,7 @@ void updateVRDevicesComboUI(bool enable)
// configured device not found, add a dummy // configured device not found, add a dummy
std::stringstream displayname; std::stringstream displayname;
displayname << std::string("[") << ClientCfg.VRDisplayDevice << "] [" << ClientCfg.VRDisplayDeviceId<< "] [DEVICE NOT FOUND]"; displayname << std::string("[") << ClientCfg.VRDisplayDevice << "] [" << ClientCfg.VRDisplayDeviceId<< "] [DEVICE NOT FOUND]";
pCB->addText(ucstring(displayname.str())); pCB->addText(displayname.str());
selectedDevice = VRDeviceCache.size(); selectedDevice = VRDeviceCache.size();
} }
NLGUI::CDBManager::getInstance()->getDbProp(GAME_CONFIG_VR_DEVICE_DB)->setValue32(-1); NLGUI::CDBManager::getInstance()->getDbProp(GAME_CONFIG_VR_DEVICE_DB)->setValue32(-1);
@ -3059,7 +3059,7 @@ public:
{ {
pCB->resetTexts(); pCB->resetTexts();
for (sint j = 0; j < (sint)stringModeList.size(); j++) for (sint j = 0; j < (sint)stringModeList.size(); j++)
pCB->addText(ucstring(stringModeList[j])); pCB->addText(stringModeList[j]);
} }
// frequencies // frequencies
@ -3068,7 +3068,7 @@ public:
{ {
pCB->resetTexts(); pCB->resetTexts();
for (sint j = 0; j < (sint)stringFreqList.size(); j++) 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 // -1 is important to indicate we set this value in edit mode
@ -3091,10 +3091,10 @@ public:
if( pCB ) if( pCB )
{ {
pCB->resetTexts(); pCB->resetTexts();
pCB->addText(CI18N::get("uigcLowTextureMode")); pCB->addText(CI18N::get("uigcLowTextureMode").toUtf8());
pCB->addText(CI18N::get("uigcNormalTextureMode")); pCB->addText(CI18N::get("uigcNormalTextureMode").toUtf8());
if(ClientCfg.HDTextureInstalled) if(ClientCfg.HDTextureInstalled)
pCB->addText(CI18N::get("uigcHighTextureMode")); pCB->addText(CI18N::get("uigcHighTextureMode").toUtf8());
} }
// Anisotropic Filtering // Anisotropic Filtering
@ -3107,14 +3107,14 @@ public:
sint maxAnisotropic = (sint)Driver->getAnisotropicFilterMaximum(); sint maxAnisotropic = (sint)Driver->getAnisotropicFilterMaximum();
pCB->resetTexts(); pCB->resetTexts();
pCB->addText(CI18N::get("uigcFxAnisotropicFilterNone")); pCB->addText(CI18N::get("uigcFxAnisotropicFilterNone").toUtf8());
sint anisotropic = 2; sint anisotropic = 2;
uint i = 1; uint i = 1;
while (anisotropic <= maxAnisotropic) while (anisotropic <= maxAnisotropic)
{ {
pCB->addText(ucstring(NLMISC::toString("%dx", anisotropic))); pCB->addText(NLMISC::toString("%dx", anisotropic));
if (ClientCfg.AnisotropicFilter == anisotropic) if (ClientCfg.AnisotropicFilter == anisotropic)
nAnisotropic = i; nAnisotropic = i;
@ -3219,7 +3219,7 @@ class CHandlerGameConfigMode : public IActionHandler
// Get W, H // Get W, H
sint 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); string tmp = vidModeStr.substr(0,vidModeStr.find('x')-1);
fromString(tmp, w); fromString(tmp, w);
tmp = vidModeStr.substr(vidModeStr.find('x')+2,vidModeStr.size()); tmp = vidModeStr.substr(vidModeStr.find('x')+2,vidModeStr.size());
@ -3259,7 +3259,7 @@ class CHandlerGameConfigMode : public IActionHandler
{ {
pCB->resetTexts(); pCB->resetTexts();
for (j = 0; j < (sint)stringFreqList.size(); j++) 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); NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(nFoundFreq);
@ -3461,7 +3461,7 @@ class CHandlerGameConfigApply : public IActionHandler
CDBGroupComboBox *pCB = dynamic_cast<CDBGroupComboBox*>(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); CDBGroupComboBox *pCB = dynamic_cast<CDBGroupComboBox*>(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO ));
if( pCB != NULL ) if( pCB != NULL )
{ {
string vidModeStr = pCB->getText(nVideModeNb).toString(); string vidModeStr = pCB->getText(nVideModeNb);
string tmp = vidModeStr.substr(0,vidModeStr.find('x')-1); string tmp = vidModeStr.substr(0,vidModeStr.find('x')-1);
fromString(tmp, w); fromString(tmp, w);
tmp = vidModeStr.substr(vidModeStr.find('x')+2,vidModeStr.size()); tmp = vidModeStr.substr(vidModeStr.find('x')+2,vidModeStr.size());
@ -3475,7 +3475,7 @@ class CHandlerGameConfigApply : public IActionHandler
CDBGroupComboBox *pCB = dynamic_cast<CDBGroupComboBox*>(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); CDBGroupComboBox *pCB = dynamic_cast<CDBGroupComboBox*>(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO ));
if( pCB != NULL ) if( pCB != NULL )
{ {
string vidFreqStr = pCB->getText(nVideoFreqNb).toString(); string vidFreqStr = pCB->getText(nVideoFreqNb);
fromString(vidFreqStr, freq); fromString(vidFreqStr, freq);
} }
} }
@ -4594,7 +4594,7 @@ public:
CViewText *pVT = dynamic_cast<CViewText *>(pIG->getView("t")); CViewText *pVT = dynamic_cast<CViewText *>(pIG->getView("t"));
if (!pVT) break; if (!pVT) break;
names.push_back(toUpper(pVT->getText().toUtf8())); names.push_back(toUpper(pVT->getText()));
} }
if (names.size() != nbChilds) if (names.size() != nbChilds)

@ -1167,7 +1167,7 @@ void setHelpText(CSheetHelpSetup &setup, const ucstring &text)
CViewText *viewText= dynamic_cast<CViewText *>(setup.HelpWindow->getView(setup.ViewText)); CViewText *viewText= dynamic_cast<CViewText *>(setup.HelpWindow->getView(setup.ViewText));
if(viewText) if(viewText)
{ {
viewText->setTextFormatTaged(copyStr); viewText->setTextFormatTaged(copyStr.toUtf8());
} }
CInterfaceGroup *viewTextGroup = setup.HelpWindow->getGroup(setup.ScrollTextGroup); CInterfaceGroup *viewTextGroup = setup.HelpWindow->getGroup(setup.ScrollTextGroup);
if (viewTextGroup) viewTextGroup->setActive(true); if (viewTextGroup) viewTextGroup->setActive(true);
@ -2200,7 +2200,7 @@ static void setupRawMaterialStats(CSheetHelpSetup &setup)
if(pIS->canBuildItemPart(faberType)) 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) if(view)
{ {
view->setActive(true); 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); string originFilterKey= "iompf" + ITEM_ORIGIN::enumToString((ITEM_ORIGIN::EItemOrigin)itemPart.OriginFilter);
mpCraft+= CI18N::get(originFilterKey); 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<CViewText*>(groupStat->getElement(groupStat->getId()+":text" )); CViewText *statTitle= dynamic_cast<CViewText*>(groupStat->getElement(groupStat->getId()+":text" ));
CDBViewBar *statValue= dynamic_cast<CDBViewBar*>(groupStat->getElement(groupStat->getId()+":bar" )); CDBViewBar *statValue= dynamic_cast<CDBViewBar*>(groupStat->getElement(groupStat->getId()+":bar" ));
if(statTitle) if(statTitle)
statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType)); statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType).toUtf8());
if(statValue) if(statValue)
statValue->setValue(itemPart.Stats[i]); statValue->setValue(itemPart.Stats[i]);
} }

@ -231,8 +231,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
closeButton->setActive(false); closeButton->setActive(false);
group->setActive(true); group->setActive(true);
editBoxShort->setInputString(u32string()); editBoxShort->setInputString(std::string());
editBoxLarge->setInputString(u32string()); editBoxLarge->setInputString(std::string());
display->setTextFormatTaged(ucstring()); display->setTextFormatTaged(ucstring());
@ -289,8 +289,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
closeButton->setActive(true); closeButton->setActive(true);
group->setActive(true); group->setActive(true);
editBoxShort->setInputString(u32string()); editBoxShort->setInputString(std::string());
editBoxLarge->setInputString(u32string()); editBoxLarge->setInputString(std::string());
display->setTextFormatTaged(ucstring()); display->setTextFormatTaged(ucstring());
// Finish the display or add the waiter // Finish the display or add the waiter

@ -523,7 +523,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick
{ {
nlstop; nlstop;
} }
viewText->setText( text ); viewText->setText( text.toUtf8() );
} }
// Set as Icon the required MP FaberType / or Sheet Texture (directly...) // Set as Icon the required MP FaberType / or Sheet Texture (directly...)
@ -718,7 +718,7 @@ void CActionPhraseFaber::startMpSelection(uint itemReqLine, uint mpSlot)
if (eb) if (eb)
{ {
CWidgetManager::getInstance()->setCaptureKeyboard(eb); CWidgetManager::getInstance()->setCaptureKeyboard(eb);
eb->setInputStringAsUtf8(toString(maxQuantity)); eb->setInputString(toString(maxQuantity));
eb->setSelectionAll(); eb->setSelectionAll();
} }
} }
@ -1724,7 +1724,7 @@ void CActionPhraseFaber::updateItemResult()
+ "@{FFFF})"; + "@{FFFF})";
} }
strFindReplace(text, "%success", successStr ); strFindReplace(text, "%success", successStr );
successView->setTextFormatTaged(text); successView->setTextFormatTaged(text.toUtf8());
} }
@ -1790,7 +1790,7 @@ void CActionPhraseFaber::updateItemResult()
uint sv= uint(statArray[i]*100); uint sv= uint(statArray[i]*100);
if(statTitle) if(statTitle)
{ {
statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType)); statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType).toUtf8());
statTitle->setColor(usageColor); statTitle->setColor(usageColor);
} }
if(statValueBar) if(statValueBar)

@ -156,7 +156,7 @@ void CBotChatPageDynamicMission::update()
{ {
if (ClientCfg.Local) 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; _TextReceived[k][l] = true;
} }
else else
@ -167,7 +167,7 @@ void CBotChatPageDynamicMission::update()
bool received = CStringManagerClient::instance()->getDynString(textID, result); bool received = CStringManagerClient::instance()->getDynString(textID, result);
if (received) if (received)
{ {
_ChoiceCB[k]->setText(l, result); _ChoiceCB[k]->setText(l, result.toUtf8());
_TextReceived[k][l] = true; _TextReceived[k][l] = true;
} }
} }
@ -183,13 +183,13 @@ void CBotChatPageDynamicMission::update()
bool received = CStringManagerClient::instance()->getDynString(textID, result); bool received = CStringManagerClient::instance()->getDynString(textID, result);
if (received) if (received)
{ {
_ChoiceCB[k]->addText(result); _ChoiceCB[k]->addText(result.toUtf8());
_TextReceived[k][l] = true; _TextReceived[k][l] = true;
} }
else else
{ {
// add a text to show the player that the text is being received // 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());
} }
} }
} }

@ -333,7 +333,7 @@ uint32 CBotChatPageTrade::getCurrItemQuantity() const
CGroupEditBox *ed = dynamic_cast<CGroupEditBox *>(ig->getGroup("header_opened:standard_price:quantity:edit:eb")); CGroupEditBox *ed = dynamic_cast<CGroupEditBox *>(ig->getGroup("header_opened:standard_price:quantity:edit:eb"));
if (!ed) return std::numeric_limits<uint32>::max(); if (!ed) return std::numeric_limits<uint32>::max();
uint32 intQuantity; uint32 intQuantity;
if (fromString(ed->getInputStringAsUtf8(), intQuantity)) if (fromString(ed->getInputString(), intQuantity))
{ {
return intQuantity; return intQuantity;
} }
@ -865,7 +865,7 @@ void CBotChatPageTrade::startBuyDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCall
CViewText *priceLabel = dynamic_cast<CViewText*>(ig->getView( "standard_price:total_price_header" )); CViewText *priceLabel = dynamic_cast<CViewText*>(ig->getView( "standard_price:total_price_header" ));
if ( _BuyMean == Money && priceLabel ) if ( _BuyMean == Money && priceLabel )
{ {
priceLabel->setText( CI18N::get( "uiPrice" ) ); priceLabel->setText( CI18N::get( "uiPrice" ).toUtf8() );
priceLabel->setActive(true); priceLabel->setActive(true);
} }
else else
@ -977,7 +977,7 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal
CViewText *priceLabel = dynamic_cast<CViewText*>(ig->getView( "standard_price:total_price_header" )); CViewText *priceLabel = dynamic_cast<CViewText*>(ig->getView( "standard_price:total_price_header" ));
if ( priceLabel ) if ( priceLabel )
{ {
priceLabel->setText( CI18N::get( "uiImmediatePrice" ) ); priceLabel->setText( CI18N::get( "uiImmediatePrice" ).toUtf8() );
priceLabel->setActive(true); priceLabel->setActive(true);
} }
@ -1012,7 +1012,7 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal
{ {
ucstring itemName; ucstring itemName;
itemName = sheet->getItemActualName(); itemName = sheet->getItemActualName();
itemNameView->setText(itemName); itemNameView->setText(itemName.toUtf8());
} }
// set help for item // set help for item
@ -1465,7 +1465,7 @@ void CBotChatPageTrade::setupPriceGroupQuantity(CInterfaceGroup *priceGroup, sin
CGroupEditBox *eb = dynamic_cast<CGroupEditBox *>(quantityGroup->getGroup("edit:eb")); CGroupEditBox *eb = dynamic_cast<CGroupEditBox *>(quantityGroup->getGroup("edit:eb"));
if (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(); sint32 resaleMargin= NLGUI::CDBManager::getInstance()->getDbProp( "UI:SAVE:TRADE_ITEM:RESALE_MARGIN" )->getValue32();
clamp(resaleMargin, 0, (sint32)MaxResaleMargin); clamp(resaleMargin, 0, (sint32)MaxResaleMargin);
eb->setInputStringAsUtf8( toString( resaleMargin ) ); eb->setInputString( toString( resaleMargin ) );
eb->setPositiveIntegerMaxValue(MaxResaleMargin); eb->setPositiveIntegerMaxValue(MaxResaleMargin);
} }
} }
@ -1679,14 +1679,14 @@ void CBotChatPageTrade::setupFactionPointPrice(bool /* sellMode */, uint default
{ {
ucstring fmt= CI18N::get("uiUnitFPPrice"); ucstring fmt= CI18N::get("uiUnitFPPrice");
strFindReplace(fmt, "%fac", factionName); strFindReplace(fmt, "%fac", factionName);
vt->setText(fmt); vt->setText(fmt.toUtf8());
} }
vt= dynamic_cast<CViewText*>(fpGroup->getView("total_price_header")); vt= dynamic_cast<CViewText*>(fpGroup->getView("total_price_header"));
if(vt) if(vt)
{ {
ucstring fmt= CI18N::get("uiTotalFPPrice"); ucstring fmt= CI18N::get("uiTotalFPPrice");
strFindReplace(fmt, "%fac", factionName); strFindReplace(fmt, "%fac", factionName);
vt->setText(fmt); vt->setText(fmt.toUtf8());
} }
// setup icon according to pvp clan // setup icon according to pvp clan
@ -1725,8 +1725,8 @@ void CBotChatPageTrade::startChangeBuyFilterDialog(const std::string &dbext, con
sint rangeMax= 0; sint rangeMax= 0;
if(dbRangeMin) rangeMin= dbRangeMin->getValue32(); if(dbRangeMin) rangeMin= dbRangeMin->getValue32();
if(dbRangeMax) rangeMax= dbRangeMax->getValue32(); if(dbRangeMax) rangeMax= dbRangeMax->getValue32();
if(edMin) edMin->setInputStringAsUtf8(toString(rangeMin)); if(edMin) edMin->setInputString(toString(rangeMin));
if(edMax) edMax->setInputStringAsUtf8(toString(rangeMax)); if(edMax) edMax->setInputString(toString(rangeMax));
if(edMin) edMin->setPositiveIntegerMaxValue(maxValue); if(edMin) edMin->setPositiveIntegerMaxValue(maxValue);
if(edMax) edMax->setPositiveIntegerMaxValue(maxValue); if(edMax) edMax->setPositiveIntegerMaxValue(maxValue);
@ -1754,8 +1754,8 @@ void CBotChatPageTrade::resetBuyFilterDialog()
sint rangeMin= 0; sint rangeMin= 0;
sint rangeMax= _FilterBuyDlgMaxValue; sint rangeMax= _FilterBuyDlgMaxValue;
// write result in EditBox, and in db // write result in EditBox, and in db
if(edMin) edMin->setInputStringAsUtf8(toString(rangeMin)); if(edMin) edMin->setInputString(toString(rangeMin));
if(edMax) edMax->setInputStringAsUtf8(toString(rangeMax)); if(edMax) edMax->setInputString(toString(rangeMax));
if(dbRangeMin) dbRangeMin->setValue32(rangeMin); if(dbRangeMin) dbRangeMin->setValue32(rangeMin);
if(dbRangeMax) dbRangeMax->setValue32(rangeMax); if(dbRangeMax) dbRangeMax->setValue32(rangeMax);

@ -380,12 +380,12 @@ CViewBase *CChatTextManager::createMsgTextSimple(const ucstring &msg, NLMISC::CR
// otherwise, set text normal and apply global color // otherwise, set text normal and apply global color
if (msg.find(ucstring("@{")) != ucstring::npos) if (msg.find(ucstring("@{")) != ucstring::npos)
{ {
vt->setTextFormatTaged(msg); vt->setTextFormatTaged(msg.toUtf8());
vt->setColor(NLMISC::CRGBA::White); vt->setColor(NLMISC::CRGBA::White);
} }
else else
{ {
vt->setText(msg); vt->setText(msg.toUtf8());
vt->setColor(col); vt->setColor(col);
} }
@ -465,12 +465,12 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C
if (title.size() > 0) if (title.size() > 0)
{ {
vt->LinkTitle = title.toUtf8(); vt->LinkTitle = title.toUtf8();
vt->setText(title); vt->setText(vt->LinkTitle);
} }
else else
{ {
vt->LinkTitle = url.toUtf8(); vt->LinkTitle = url.toUtf8();
vt->setText(url); vt->setText(vt->LinkTitle);
} }
if (url.find_first_of('\'') != string::npos) if (url.find_first_of('\'') != string::npos)

@ -262,7 +262,7 @@ void CChatWindow::setPrompt(const ucstring &prompt)
if (!_Chat) return; if (!_Chat) return;
CGroupEditBox *eb = dynamic_cast<CGroupEditBox *>(_Chat->getGroup("eb")); CGroupEditBox *eb = dynamic_cast<CGroupEditBox *>(_Chat->getGroup("eb"));
if (!eb) return; if (!eb) return;
eb->setPrompt(prompt); eb->setPrompt(prompt.toUtf8());
} }
void CChatWindow::setPromptColor(NLMISC::CRGBA col) void CChatWindow::setPromptColor(NLMISC::CRGBA col)
@ -1289,7 +1289,7 @@ public:
// Parse any tokens in the text // Parse any tokens in the text
if ( ! CInterfaceManager::parseTokens(text)) if ( ! CInterfaceManager::parseTokens(text))
{ {
pEB->setInputString (u32string()); pEB->setInputString(std::string());
return; return;
} }
@ -1329,7 +1329,7 @@ public:
} }
} }
// Clear input string // Clear input string
pEB->setInputString (u32string()); pEB->setInputString (std::string());
CGroupContainer *gc = static_cast< CGroupContainer* >( pEB->getEnclosingContainer() ); CGroupContainer *gc = static_cast< CGroupContainer* >( pEB->getEnclosingContainer() );
if (gc) if (gc)

@ -2084,7 +2084,7 @@ void CDBCtrlSheet::draw()
_RegenText = new CViewText(CViewBase::TCtorParam()); _RegenText = new CViewText(CViewBase::TCtorParam());
_RegenText->setId(getId() + ":regen"); _RegenText->setId(getId() + ":regen");
_RegenText->setParent(_Parent); _RegenText->setParent(_Parent);
_RegenText->setOverflowText(ucstring("")); _RegenText->setOverflowText(std::string());
_RegenText->setModulateGlobalColor(false); _RegenText->setModulateGlobalColor(false);
_RegenText->setMultiLine(false); _RegenText->setMultiLine(false);
_RegenText->setTextMode(CViewText::ClipWord); _RegenText->setTextMode(CViewText::ClipWord);

@ -279,7 +279,7 @@ void CDBGroupBuildPhrase::clearBuildingPhrase()
// Empty the name // Empty the name
if(_UserSentenceName) if(_UserSentenceName)
{ {
_UserSentenceName->setInputString(u32string()); _UserSentenceName->setInputString(std::string());
} }
// update Display // update Display
@ -1074,7 +1074,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase)
float relative_cost; float relative_cost;
cost= pBM->getSabrinaCom().getPhraseBrickAndParamCost(phrase.Bricks, i); cost= pBM->getSabrinaCom().getPhraseBrickAndParamCost(phrase.Bricks, i);
relative_cost = pBM->getSabrinaCom().getPhraseBrickAndParamRelativeCost(phrase.Bricks, i); relative_cost = pBM->getSabrinaCom().getPhraseBrickAndParamRelativeCost(phrase.Bricks, i);
ucstring costText; std::string costText;
if( cost == 0 && relative_cost != 0.f ) if( cost == 0 && relative_cost != 0.f )
{ {
cost = (sint32)(relative_cost * 100.f); cost = (sint32)(relative_cost * 100.f);
@ -1119,10 +1119,10 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase)
{ {
word.InfoView->setActive(true); word.InfoView->setActive(true);
if(i==0) if(i==0)
word.InfoView->setText( CI18N::get("uiTextHelpSelectRootBrick") ); word.InfoView->setText( CI18N::get("uiTextHelpSelectRootBrick").toUtf8() );
else else
// start effect index at 1 (human readable :) ) // 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; ucstring text;
pPM->buildPhraseDesc(text, phrase, 0, false, "composition"); pPM->buildPhraseDesc(text, phrase, 0, false, "composition");
_TextPhraseDesc->setTextFormatTaged(text); _TextPhraseDesc->setTextFormatTaged(text.toUtf8());
} }

@ -141,7 +141,7 @@ void CDBGroupListSheetIconPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin
pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel); pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel);
strFindReplace(sectionText, "%min", toString(minLevel)); strFindReplace(sectionText, "%min", toString(minLevel));
strFindReplace(sectionText, "%max", toString(maxLevel)); strFindReplace(sectionText, "%max", toString(maxLevel));
name->setText (sectionText); name->setText (sectionText.toUtf8());
} }
} }

@ -1086,7 +1086,7 @@ void CDBGroupListSheetText::CSheetChild::updateViewTextAsItem()
} }
// set text // set text
Text->setTextFormatTaged(text); Text->setTextFormatTaged(text.toUtf8());
} }
} }

@ -135,7 +135,7 @@ public:
{ {
ucstring text; ucstring text;
Ctrl->getContextHelp(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 // create a CViewText object that is displayed next to the item. This is the opportunnity to create

@ -137,11 +137,11 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::updateViewText(CDB
// Temp if the Desc2 is empty, set Name // Temp if the Desc2 is empty, set Name
ucstring desc2(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheetId)); ucstring desc2(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheetId));
if( !desc2.empty() && !hasOnlyBlankChars(desc2)) // tolerate Blank error in translation if( !desc2.empty() && !hasOnlyBlankChars(desc2)) // tolerate Blank error in translation
Text->setText(desc2); Text->setText(desc2.toUtf8());
else else
{ {
desc2 = STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brickSheetId); 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) // Special Case for the "Remove Brick" brick. No Cost (not revelant)
if( brick->Id==pBM->getInterfaceRemoveBrick() ) if( brick->Id==pBM->getInterfaceRemoveBrick() )
CostView->setText( ucstring() ); CostView->setText( std::string() );
else if( brick->SabrinaCost == 0 && brick->SabrinaRelativeCost != 0.f ) else if( brick->SabrinaCost == 0 && brick->SabrinaRelativeCost != 0.f )
CostView->setText( toString("%+d", (sint32)(brick->SabrinaRelativeCost * 100.f) ) + string("%") ); CostView->setText( toString("%+d", (sint32)(brick->SabrinaRelativeCost * 100.f) ) + string("%") );
else else

@ -94,7 +94,7 @@ void CDBGroupListSheetTextPhrase::CSheetChildPhrase::updateViewText(CDBGroupList
#endif #endif
// set // set
Text->setText(text); Text->setText(text.toUtf8());
} }
@ -173,7 +173,7 @@ void CDBGroupListSheetTextPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin
pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel); pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel);
strFindReplace(sectionText, "%min", toString(minLevel)); strFindReplace(sectionText, "%min", toString(minLevel));
strFindReplace(sectionText, "%max", toString(maxLevel)); strFindReplace(sectionText, "%max", toString(maxLevel));
name->setText (sectionText); name->setText (sectionText.toUtf8());
} }
} }

@ -48,7 +48,7 @@ void CDBGroupListSheetTextPhraseId::CSheetChildPhrase::updateViewText(CDBGroupLi
// Get the User Name of the phrase // Get the User Name of the phrase
Ctrl->getContextHelp(text); Ctrl->getContextHelp(text);
Text->setText(text); Text->setText(text.toUtf8());
} }
// *************************************************************************** // ***************************************************************************

@ -457,7 +457,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT
// setup color and text // setup color and text
text= colorTag + text; text= colorTag + text;
Text->setTextFormatTaged(text); Text->setTextFormatTaged(text.toUtf8());
} }
// *************************************************************************** // ***************************************************************************

@ -303,8 +303,8 @@ void CEncyclopediaManager::rebuildAlbumPage(uint32 albumName)
if (pRBVT != NULL) if (pRBVT != NULL)
{ {
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pAlbum->RewardBrick))); CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pAlbum->RewardBrick)));
pRBVT->setText(desc); pRBVT->setText(desc.toUtf8());
} }
} }
@ -359,18 +359,18 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName)
{ {
if (pES->type() == CEntitySheet::ITEM) if (pES->type() == CEntitySheet::ITEM)
{ {
const ucstring desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); CUtfStringView desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet)));
pRBVT->setText(desc); pRBVT->setText(desc.toUtf8());
} }
else if (pES->type() == CEntitySheet::SBRICK) else if (pES->type() == CEntitySheet::SBRICK)
{ {
const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet)));
pRBVT->setText(desc); pRBVT->setText(desc.toUtf8());
} }
else if (pES->type() == CEntitySheet::SPHRASE) else if (pES->type() == CEntitySheet::SPHRASE)
{ {
const ucstring desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); CUtfStringView desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet)));
pRBVT->setText(desc); pRBVT->setText(desc.toUtf8());
} }
} }

@ -143,7 +143,7 @@ void CFlyingTextManager::addFlyingText(void *key, const ucstring &text, const NL
gi.UsedThisFrame= true; gi.UsedThisFrame= true;
// update infos // update infos
gi.ViewText->setText(text); gi.ViewText->setText(text.toUtf8());
gi.ViewText->setColor(color); gi.ViewText->setColor(color);
gi.GroupInScene->Position= pos; gi.GroupInScene->Position= pos;
gi.GroupInScene->Scale= scale; gi.GroupInScene->Scale= scale;

@ -414,7 +414,7 @@ void CGroupCompas::draw()
} }
if (_DistViewText != distText) if (_DistViewText != distText)
{ {
_DistView->setText(distText); _DistView->setText(distText.toUtf8());
_DistViewText = distText; _DistViewText = distText;
} }
} }

@ -530,10 +530,10 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t
if (group) if (group)
{ {
// Skill name // 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<CViewText*>(group->getView("name")); CViewText *pViewSkillName = dynamic_cast<CViewText*>(group->getView("name"));
if (pViewSkillName != NULL) if (pViewSkillName != NULL)
pViewSkillName->setText (sSkillName); pViewSkillName->setText (sSkillName.toUtf8());
// Skill value // Skill value
CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false); CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false);
@ -599,7 +599,7 @@ void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA
CViewText *pViewName = dynamic_cast<CViewText*>(group->getView("name")); CViewText *pViewName = dynamic_cast<CViewText*>(group->getView("name"));
if (pViewName != NULL) if (pViewName != NULL)
{ {
pViewName->setText (message); pViewName->setText (message.toUtf8());
pViewName->setColor (color); pViewName->setColor (color);
} }
@ -648,7 +648,7 @@ void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message,
CViewText *pViewName = dynamic_cast<CViewText*>(group->getView("name")); CViewText *pViewName = dynamic_cast<CViewText*>(group->getView("name"));
if (pViewName != NULL) if (pViewName != NULL)
{ {
pViewName->setTextFormatTaged(message); pViewName->setTextFormatTaged(message.toUtf8());
pViewName->setColor (color); 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); context->Group->setActive(true);
@ -1080,7 +1080,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con
if (pVT != NULL) if (pVT != NULL)
{ {
pVT->setActive(false); pVT->setActive(false);
pVT->setText(ucstring("")); pVT->setText(std::string());
} }
pCL = dynamic_cast<CCtrlLink*>(bubble->getElement(id+"optb"+toString(j))); pCL = dynamic_cast<CCtrlLink*>(bubble->getElement(id+"optb"+toString(j)));
if (pCL != NULL) pCL->setActive(false); if (pCL != NULL) pCL->setActive(false);
@ -1094,7 +1094,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con
pVT->setActive(true); pVT->setActive(true);
ucstring optionText; ucstring optionText;
optionText.fromUtf8(strs[j]); optionText.fromUtf8(strs[j]);
pVT->setText(optionText); pVT->setText(optionText.toUtf8());
pCL = dynamic_cast<CCtrlLink*>(bubble->getElement(id+"optb"+toString(j))); pCL = dynamic_cast<CCtrlLink*>(bubble->getElement(id+"optb"+toString(j)));
if (pCL != NULL) if (pCL != NULL)
{ {
@ -1485,7 +1485,7 @@ void CGroupInSceneBubble::setRawText (const ucstring &text)
CInterfaceElement *pVTIE = CWidgetManager::getInstance()->getElementFromId(getId()+":header_opened:window:text"); CInterfaceElement *pVTIE = CWidgetManager::getInstance()->getElementFromId(getId()+":header_opened:window:text");
CViewText *pVT= dynamic_cast<CViewText*>(pVTIE); CViewText *pVT= dynamic_cast<CViewText*>(pVTIE);
if (pVT != NULL) if (pVT != NULL)
pVT->setText(text); pVT->setText(text.toUtf8());
} }
// *************************************************************************** // ***************************************************************************

@ -780,19 +780,19 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity)
// Set player name // Set player name
if (info->_Name) if (info->_Name)
{ {
info->_Name->setText(entityName); info->_Name->setText(entityName.toUtf8());
info->_Name->setModulateGlobalColor(false); info->_Name->setModulateGlobalColor(false);
} }
// Set player title // Set player title
if (info->_Title) if (info->_Title)
info->_Title->setText(entityTitle); info->_Title->setText(entityTitle.toUtf8());
// Set tribe name // Set tribe name
if (info->_TribeName) if (info->_TribeName)
{ {
nlassert(info->_GuildName == NULL); nlassert(info->_GuildName == NULL);
info->_TribeName->setText(theTribeName); info->_TribeName->setText(theTribeName.toUtf8());
} }
// Init user leaf nodes // Init user leaf nodes
@ -966,7 +966,7 @@ void CGroupInSceneUserInfo::updateDynamicData ()
if (pPlayer != NULL) if (pPlayer != NULL)
if (pPlayer->isAFK()) if (pPlayer->isAFK())
entityName += CI18N::get("uiAFK"); entityName += CI18N::get("uiAFK");
_Name->setText(entityName); _Name->setText(entityName.toUtf8());
// Title color get the PVP color // Title color get the PVP color
if (_Title) if (_Title)
@ -994,7 +994,7 @@ void CGroupInSceneUserInfo::updateDynamicData ()
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
ucstring ucsTmp; ucstring ucsTmp;
if (pSMC->getString (_Entity->getGuildNameID(), ucsTmp)) if (pSMC->getString (_Entity->getGuildNameID(), ucsTmp))
_GuildName->setText(ucsTmp); _GuildName->setText(ucsTmp.toUtf8());
// guildname color is the pvp color // guildname color is the pvp color
_GuildName->setColor(entityColor); _GuildName->setColor(entityColor);
@ -1020,7 +1020,7 @@ void CGroupInSceneUserInfo::updateDynamicData ()
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
ucstring ucsTmp; ucstring ucsTmp;
if (pSMC->getString (_Entity->getEventFactionID(), ucsTmp)) if (pSMC->getString (_Entity->getEventFactionID(), ucsTmp))
_EventFaction->setText(ucsTmp); _EventFaction->setText(ucsTmp.toUtf8());
// guildname color depends of PVP faction or not // guildname color depends of PVP faction or not
_EventFaction->setColor(entityColor); _EventFaction->setColor(entityColor);

@ -2430,7 +2430,7 @@ void CGroupMap::updateMatchedLandmarks()
CViewText* t = dynamic_cast<CViewText *>(g->getView("title")); CViewText* t = dynamic_cast<CViewText *>(g->getView("title"));
if (t) if (t)
{ {
t->setSingleLineTextFormatTaged(_MatchedLandmarks[k].Title); t->setSingleLineTextFormatTaged(_MatchedLandmarks[k].Title.toUtf8());
} }
CViewBitmap* b = dynamic_cast<CViewBitmap *>(g->getView("icon")); CViewBitmap* b = dynamic_cast<CViewBitmap *>(g->getView("icon"));
@ -2492,7 +2492,7 @@ void CGroupMap::createLMWidgets(const std::vector<CContLandMark> &lms)
else // just add a text else // just add a text
{ {
CLandMarkText *pNewText = new CLandMarkText(CViewBase::TCtorParam()); CLandMarkText *pNewText = new CLandMarkText(CViewBase::TCtorParam());
pNewText->setText(ucsTmp); pNewText->setText(ucsTmp.toUtf8());
pNewText->Pos = mapPos; pNewText->Pos = mapPos;
pNewText->setParent(this); pNewText->setParent(this);
pNewText->setParentPosRef(Hotspot_BL); pNewText->setParentPosRef(Hotspot_BL);
@ -3279,7 +3279,7 @@ CGroupMap::CLandMarkText* CGroupMap::findClosestLandmark(const CVector2f &center
for(TLandMarkTextVect::const_iterator it = landmarks.begin(); it != landmarks.end(); ++it) for(TLandMarkTextVect::const_iterator it = landmarks.begin(); it != landmarks.end(); ++it)
{ {
ucstring lc; ucstring lc;
lc = (*it)->getText(); lc = CUtfStringView((*it)->getText()).toUtf16();
if(filterLandmark(lc, keywords, startsWith)) { if(filterLandmark(lc, keywords, startsWith)) {
CVector2f pos; CVector2f pos;
mapToWorld(pos, (*it)->Pos); mapToWorld(pos, (*it)->Pos);
@ -3334,7 +3334,7 @@ bool CGroupMap::targetLandmarkByName(const ucstring &search, bool startsWith) co
{ {
ct.setType(CCompassTarget::ContinentLandMark); ct.setType(CCompassTarget::ContinentLandMark);
mapToWorld(ct.Pos, lmt->Pos); mapToWorld(ct.Pos, lmt->Pos);
ct.Name = lmt->getText(); ct.Name = CUtfStringView(lmt->getText()).toUtf16();
closest = dist; closest = dist;
found = true; 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); CViewTextMenu* vt = rootMenu->addLine(ucstring(""), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false);
if (!vt) break; if (!vt) break;
vt->setSingleLineTextFormatTaged(name); vt->setSingleLineTextFormatTaged(name.toUtf8());
// TODO: should calculate from mouse pos and client width // TODO: should calculate from mouse pos and client width
vt->setLineMaxW(800); vt->setLineMaxW(800);
@ -3718,7 +3718,7 @@ class CAHLandMarkFilter : public IActionHandler
CGroupEditBox* eb = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(group)); CGroupEditBox* eb = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(group));
if (!eb) return; if (!eb) return;
text = eb->getInputStringAsUtf8(); text = eb->getInputString();
} }
map->setLandmarkFilter(text); map->setLandmarkFilter(text);

@ -89,7 +89,7 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event)
// Setup the text ! // Setup the text !
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewText *pVT= dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId( VIEW_TEXT_KEY )); CViewText *pVT= dynamic_cast<CViewText*>(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 // Check if in use
CActionsManager *pCurAM = NULL; CActionsManager *pCurAM = NULL;
@ -111,12 +111,12 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event)
if (baseAction && pCurAM->isActionPresentInContext(it->second)) if (baseAction && pCurAM->isActionPresentInContext(it->second))
{ {
ucstring shortcutName = baseAction->getActionLocalizedText(it->second); ucstring shortcutName = baseAction->getActionLocalizedText(it->second);
if (pVT != NULL) pVT->setText(shortcutName); if (pVT != NULL) pVT->setText(shortcutName.toUtf8());
} }
} }
else else
{ {
if (pVT != NULL) pVT->setText(string("")); if (pVT != NULL) pVT->setText(string());
} }
} }

@ -387,7 +387,7 @@ void CGroupSkills::createAllTreeNodes()
// Set Skill Name // Set Skill Name
CViewText *pViewSkillName = dynamic_cast<CViewText*>(pIG->getView("name")); CViewText *pViewSkillName = dynamic_cast<CViewText*>(pIG->getView("name"));
if (pViewSkillName != NULL) if (pViewSkillName != NULL)
pViewSkillName->setText (sSkillName); pViewSkillName->setText (sSkillName.toUtf8());
// Set Skill Max Value // Set Skill Max Value
CViewText *pViewSkillMax = dynamic_cast<CViewText*>(pIG->getView("max")); CViewText *pViewSkillMax = dynamic_cast<CViewText*>(pIG->getView("max"));
if (pViewSkillMax != NULL) if (pViewSkillMax != NULL)

@ -470,7 +470,7 @@ void CGuildManager::update()
{ {
CViewText *pJoinPropPhraseView = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(VIEW_JOIN_PROPOSAL_PHRASE)); CViewText *pJoinPropPhraseView = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(VIEW_JOIN_PROPOSAL_PHRASE));
if (pJoinPropPhraseView != NULL) if (pJoinPropPhraseView != NULL)
pJoinPropPhraseView->setText(_JoinPropPhrase); pJoinPropPhraseView->setText(_JoinPropPhrase.toUtf8());
pJoinProp->setActive(true); pJoinProp->setActive(true);
CWidgetManager::getInstance()->setTopWindow(pJoinProp); CWidgetManager::getInstance()->setTopWindow(pJoinProp);
@ -724,7 +724,7 @@ bool CDBGroupListAscensor::CSheetChildAscensor::isInvalidated(CDBGroupListSheetT
ucstring name; ucstring name;
if (nameID && pSMC->getDynString(nameID, 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(); uint64 icon = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:" + toString(Index) + ":ICON")->getValue64();
@ -830,20 +830,20 @@ class CAHGuildSheetOpen : public IActionHandler
// Set name // Set name
CViewText *pViewName = dynamic_cast<CViewText*>(pLine->getView(TEMPLATE_GUILD_MEMBER_NAME)); CViewText *pViewName = dynamic_cast<CViewText*>(pLine->getView(TEMPLATE_GUILD_MEMBER_NAME));
if (pViewName != NULL) if (pViewName != NULL)
pViewName->setText (rGuildMembers[i].Name); pViewName->setText (rGuildMembers[i].Name.toUtf8());
// Set Grade // Set Grade
CViewText *pViewGrade = dynamic_cast<CViewText*>(pLine->getView(TEMPLATE_GUILD_MEMBER_GRADE)); CViewText *pViewGrade = dynamic_cast<CViewText*>(pLine->getView(TEMPLATE_GUILD_MEMBER_GRADE));
if (pViewGrade != NULL) if (pViewGrade != NULL)
{ {
if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::Leader) 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) 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) else if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::Officer)
pViewGrade->setText (CI18N::get("uiGuildOfficer")); pViewGrade->setText (CI18N::get("uiGuildOfficer").toUtf8());
else else
pViewGrade->setText (CI18N::get("uiGuildMember")); pViewGrade->setText (CI18N::get("uiGuildMember").toUtf8());
} }
// online? // online?
@ -888,7 +888,7 @@ class CAHGuildSheetOpen : public IActionHandler
str += toString("%01d", rt.getRyzomCycle()+1) +", "; str += toString("%01d", rt.getRyzomCycle()+1) +", ";
str += CI18N::get("ui"+MONTH::toString( (MONTH::EMonth)rt.getRyzomMonthInCurrentCycle() )) + ", "; str += CI18N::get("ui"+MONTH::toString( (MONTH::EMonth)rt.getRyzomMonthInCurrentCycle() )) + ", ";
str += toString("%02d", rt.getRyzomDayOfMonth()+1); str += toString("%02d", rt.getRyzomDayOfMonth()+1);
pViewEnterDate->setText(str); pViewEnterDate->setText(str.toUtf8());
} }
// Add to the list // Add to the list

@ -350,7 +350,7 @@ void CInterfaceDDX::CParam::updateScrollView(sint32 nVal)
{ {
if(ResultView) 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 // allow N digits
string fmt= toString("%%.%df", ResultDecimal); string fmt= toString("%%.%df", ResultDecimal);
ResultView->setText(ucstring(toString(fmt.c_str(), nVal)) + ResultUnit); ResultView->setText(toString(fmt.c_str(), nVal) + ResultUnit.toUtf8());
} }
} }

@ -1532,7 +1532,7 @@ void CInterfaceManager::updateFrameEvents()
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather")); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather"));
if (pVT != NULL) if (pVT != NULL)
pVT->setText(str); pVT->setText(str.toUtf8());
CCtrlBase *pTooltip= dynamic_cast<CCtrlBase*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather_tt")); CCtrlBase *pTooltip= dynamic_cast<CCtrlBase*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather_tt"));
if (pTooltip != NULL) if (pTooltip != NULL)
@ -1566,7 +1566,7 @@ void CInterfaceManager::updateFrameEvents()
pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:time")); pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:time"));
if (pVT != NULL) if (pVT != NULL)
pVT->setText(str); pVT->setText(str.toUtf8());
str.clear(); str.clear();
// Update the clock in the compass if enabled. // Update the clock in the compass if enabled.
@ -1579,7 +1579,7 @@ void CInterfaceManager::updateFrameEvents()
str = getTimestampHuman("%I:%M %p"); str = getTimestampHuman("%I:%M %p");
else else
str = getTimestampHuman("%H:%M"); 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) if (group && viewText)
{ {
viewText->setCaseMode(caseMode); viewText->setCaseMode(caseMode);
viewText->setText(text); viewText->setText(text.toUtf8());
CWidgetManager::getInstance()->enableModalWindow(NULL, group); CWidgetManager::getInstance()->enableModalWindow(NULL, group);
// don't understand why but need to update coords here // don't understand why but need to update coords here
group->updateCoords(); group->updateCoords();
@ -2442,7 +2442,7 @@ void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const ucstring &
CWidgetManager::getInstance()->setProcedureAction("proc_valid_message_box_cancel", 1, ahOnCancel, paramsOnCancel); CWidgetManager::getInstance()->setProcedureAction("proc_valid_message_box_cancel", 1, ahOnCancel, paramsOnCancel);
// set text and icon // set text and icon
viewText->setText(text); viewText->setText(text.toUtf8());
if(viewBitmap) if(viewBitmap)
{ {
bool active= true; bool active= true;

@ -866,7 +866,7 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls)
throw ELuaIHMException("setTextFormatTaged(): '%s' is not a CViewText", pIE->getId().c_str()); throw ELuaIHMException("setTextFormatTaged(): '%s' is not a CViewText", pIE->getId().c_str());
// Set the text as format // Set the text as format
vt->setTextFormatTaged(text); vt->setTextFormatTaged(text.toUtf8());
return 0; return 0;
} }

@ -103,14 +103,14 @@ void addKeyLine (CGroupList *pParent, const ucstring &keyName, const ucstring &s
CViewText *pViewKeyName = dynamic_cast<CViewText*>(pKeysLine->getView(TEMPLATE_KEYS_KEY_NAME)); CViewText *pViewKeyName = dynamic_cast<CViewText*>(pKeysLine->getView(TEMPLATE_KEYS_KEY_NAME));
if (pViewKeyName != NULL) if (pViewKeyName != NULL)
{ {
pViewKeyName->setText (keyName); pViewKeyName->setText (keyName.toUtf8());
pViewKeyName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); pViewKeyName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White);
} }
CViewText *pViewShortcutName = dynamic_cast<CViewText*>(pKeysLine->getView(TEMPLATE_KEYS_SHORTCUT_NAME)); CViewText *pViewShortcutName = dynamic_cast<CViewText*>(pKeysLine->getView(TEMPLATE_KEYS_SHORTCUT_NAME));
if (pViewShortcutName != NULL) if (pViewShortcutName != NULL)
{ {
pViewShortcutName->setText (shortcutName); pViewShortcutName->setText (shortcutName.toUtf8());
pViewShortcutName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); pViewShortcutName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White);
} }
@ -492,7 +492,7 @@ void CModalContainerEditCmd::activate()
} }
if (found) if (found)
{ {
pCB->addText( CI18N::get(rVCat[i].LocalizedName) ); pCB->addText(CI18N::get(rVCat[i].LocalizedName).toUtf8());
CurrentEditCmdCategories.push_back(rVCat[i].Name); CurrentEditCmdCategories.push_back(rVCat[i].Name);
} }
} }
@ -512,9 +512,9 @@ void CModalContainerEditCmd::activate()
NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(-1); NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(-1);
// reset name of params // reset name of params
CViewText *pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); CViewText *pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME));
if (pViewParamName != NULL) pViewParamName->setText (string("")); if (pViewParamName != NULL) pViewParamName->setText (string());
pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME));
if (pViewParamName != NULL) pViewParamName->setText (string("")); if (pViewParamName != NULL) pViewParamName->setText (string());
invalidCurrentCommand(); invalidCurrentCommand();
} }
@ -679,7 +679,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std
else sEditBox = WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_EDITBOX; else sEditBox = WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_EDITBOX;
CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(sEditBox)); CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(sEditBox));
// sTmp is utf8 // sTmp is utf8
pEB->setInputStringAsUtf8(sTmp); pEB->setInputString(sTmp);
} }
// Setup the param name if any // 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; if (noParam == 0) sText = WinName+VIEW_EDITCMD_FIRST_PARAM_NAME;
else sText = WinName+VIEW_EDITCMD_SECOND_PARAM_NAME; else sText = WinName+VIEW_EDITCMD_SECOND_PARAM_NAME;
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(sText)); CViewText *pVT = dynamic_cast<CViewText*>(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++; noParam++;
} }
} }
@ -711,7 +711,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY));
if (pVT != NULL) pVT->setActive(true); if (pVT != NULL) pVT->setActive(true);
// setup the text of the key // 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 // There is already a shortcut so we can display ok button
pBut = dynamic_cast<CCtrlBaseButton*>(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); pBut = dynamic_cast<CCtrlBaseButton*>(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 // Dont display key shortcut if we are in creation mode
pVT= dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId( WinName+VIEW_EDITCMD_TEXT_KEY )); pVT= dynamic_cast<CViewText*>(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 // Deactivate the key definer text
pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY));
@ -863,7 +863,7 @@ void CModalContainerEditCmd::validCurrentCommand()
CGroupEditBox *pEB= dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId( sWin )); CGroupEditBox *pEB= dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId( sWin ));
// convert to utf8 // convert to utf8
if (pEB != NULL) if (pEB != NULL)
CurrentEditCmdLine.ActionName.Argu += pEB->getInputStringAsUtf8(); CurrentEditCmdLine.ActionName.Argu += pEB->getInputString();
noParam++; noParam++;
} }
} }
@ -887,7 +887,7 @@ void CModalContainerEditCmd::validCurrentCommand()
{ {
CurrentEditCmdLine.Combo = it->second; CurrentEditCmdLine.Combo = it->second;
// Yes ok let setup the text of the key // 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 // There is already a shortcut so we can display ok button
CCtrlBaseButton *pCB = dynamic_cast<CCtrlBaseButton*>(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); CCtrlBaseButton *pCB = dynamic_cast<CCtrlBaseButton*>(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK));
if (pCB != NULL) pCB->setFrozen (false); if (pCB != NULL) pCB->setFrozen (false);
@ -897,7 +897,7 @@ void CModalContainerEditCmd::validCurrentCommand()
CurrentEditCmdLine.Combo.Key = KeyCount; CurrentEditCmdLine.Combo.Key = KeyCount;
CurrentEditCmdLine.Combo.KeyButtons = noKeyButton; CurrentEditCmdLine.Combo.KeyButtons = noKeyButton;
// Display not assigned text // 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 // Do not display the ok button
CCtrlBaseButton *pCB = dynamic_cast<CCtrlBaseButton*>(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); CCtrlBaseButton *pCB = dynamic_cast<CCtrlBaseButton*>(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK));
if (pCB != NULL) pCB->setFrozen (true); if (pCB != NULL) pCB->setFrozen (true);
@ -1033,7 +1033,7 @@ void CModalContainerEditCmd::onChangeCategory()
{ {
if (rBA.isUsableInCurrentContext()) 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 // reset name of params
CViewText *pViewParamName; CViewText *pViewParamName;
pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME));
if (pViewParamName != NULL) pViewParamName->setText (string("")); if (pViewParamName != NULL) pViewParamName->setText (string());
pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME));
if (pViewParamName != NULL) pViewParamName->setText (string("")); if (pViewParamName != NULL) pViewParamName->setText (string());
// Reset key // Reset key
invalidCurrentCommand(); invalidCurrentCommand();
} }
@ -1086,9 +1086,9 @@ void CModalContainerEditCmd::onChangeAction()
// reset name of params // reset name of params
CViewText *pViewParamName; CViewText *pViewParamName;
pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME));
if (pViewParamName != NULL) pViewParamName->setText (string("")); if (pViewParamName != NULL) pViewParamName->setText (string());
pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME));
if (pViewParamName != NULL) pViewParamName->setText (string("")); if (pViewParamName != NULL) pViewParamName->setText (string());
uint noParam = 0; uint noParam = 0;
for (uint i = 0; i < rVParams.size(); ++i) for (uint i = 0; i < rVParams.size(); ++i)
@ -1111,7 +1111,7 @@ void CModalContainerEditCmd::onChangeAction()
pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(sViewText)); pViewParamName = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(sViewText));
if (pViewParamName != NULL) if (pViewParamName != NULL)
pViewParamName->setText (CI18N::get(rP.LocalizedName)); pViewParamName->setText (CI18N::get(rP.LocalizedName).toUtf8());
} }
if (rP.Type == CBaseAction::CParameter::Constant) if (rP.Type == CBaseAction::CParameter::Constant)
@ -1130,11 +1130,10 @@ void CModalContainerEditCmd::onChangeAction()
if (ActionsContext.matchContext(rVal.Contexts)) if (ActionsContext.matchContext(rVal.Contexts))
{ {
if ((rVal.LocalizedValue.size() >= 2) && if (NLMISC::startsWith(rVal.LocalizedValue, "ui"))
(rVal.LocalizedValue[0] == 'u') && (rVal.LocalizedValue[1] == 'i')) pCB->addText(CI18N::get(rVal.LocalizedValue).toUtf8());
pCB->addText(CI18N::get(rVal.LocalizedValue));
else else
pCB->addText(ucstring(rVal.LocalizedValue)); pCB->addText(rVal.LocalizedValue);
} }
} }
} }
@ -1148,7 +1147,7 @@ void CModalContainerEditCmd::onChangeAction()
CGroupEditBox *pEB= dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId( sWin )); CGroupEditBox *pEB= dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId( sWin ));
if( pEB ) if( pEB )
{ {
pEB->setInputString(u32string()); pEB->setInputString(std::string());
} }
NLGUI::CDBManager::getInstance()->getDbProp( sDB )->setValue32(1); NLGUI::CDBManager::getInstance()->getDbProp( sDB )->setValue32(1);
} }
@ -1354,7 +1353,7 @@ public:
pMCM->NewKey->CurrentEditCmdLine.Combo = pGetKey->Combo; pMCM->NewKey->CurrentEditCmdLine.Combo = pGetKey->Combo;
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+VIEW_EDITCMD_TEXT_KEY)); CViewText *pVT = dynamic_cast<CViewText*>(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<CCtrlBaseButton*>(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+CTRL_EDITCMD_BUTTON_OK)); CCtrlBaseButton *pCB = dynamic_cast<CCtrlBaseButton*>(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+CTRL_EDITCMD_BUTTON_OK));
if (pCB != NULL) pCB->setFrozen (false); if (pCB != NULL) pCB->setFrozen (false);
@ -1366,7 +1365,7 @@ public:
pMCM->EditCmd->CurrentEditCmdLine.Combo = pGetKey->Combo; pMCM->EditCmd->CurrentEditCmdLine.Combo = pGetKey->Combo;
pMCM->CurrentEditMacro.Combo = pMCM->EditCmd->CurrentEditCmdLine.Combo; pMCM->CurrentEditMacro.Combo = pMCM->EditCmd->CurrentEditCmdLine.Combo;
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(VIEW_NEWMACRO_KEY)); CViewText *pVT = dynamic_cast<CViewText*>(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());
} }
} }
}; };

@ -636,7 +636,7 @@ public:
CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(Params)); CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(Params));
if (pCS == NULL) return; if (pCS == NULL) return;
pCS->setMacroText(pEB->getInputStringAsUtf8()); pCS->setMacroText(pEB->getInputString());
} }
}; };
REGISTER_ACTION_HANDLER( CHandlerEBUpdateMacroText, "eb_update_macro_text"); REGISTER_ACTION_HANDLER( CHandlerEBUpdateMacroText, "eb_update_macro_text");
@ -703,10 +703,10 @@ public:
CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_EDITTEXT)); CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_EDITTEXT));
if (pEB != NULL) if (pEB != NULL)
{ {
pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.DispText); pEB->setInputString(pMCM->CurrentEditMacro.DispText);
CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_ICON)); CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_ICON));
if (pCS != NULL) 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)); 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; if (pNewCmd == NULL) return;
CViewText *pVT = dynamic_cast<CViewText*>(pNewCmd->getView(TEMPLATE_NEWMACRO_COMMAND_TEXT)); CViewText *pVT = dynamic_cast<CViewText*>(pNewCmd->getView(TEMPLATE_NEWMACRO_COMMAND_TEXT));
if (pVT != NULL) pVT->setText(cmdName); if (pVT != NULL) pVT->setText(cmdName.toUtf8());
pNewCmd->setParent (pParent); pNewCmd->setParent (pParent);
pParent->addChild (pNewCmd); pParent->addChild (pNewCmd);
@ -862,11 +862,11 @@ public:
if (pEB == NULL) return; if (pEB == NULL) return;
CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); CMacroCmdManager *pMCM = CMacroCmdManager::getInstance();
pMCM->CurrentEditMacro.Name = pEB->getInputStringAsUtf8(); pMCM->CurrentEditMacro.Name = pEB->getInputString();
if ((pMCM->CurrentEditMacro.Name.size() >= 2) && if ((pMCM->CurrentEditMacro.Name.size() >= 2) &&
(pMCM->CurrentEditMacro.Name[0] == 'u') && (pMCM->CurrentEditMacro.Name[1] == 'i')) (pMCM->CurrentEditMacro.Name[0] == 'u') && (pMCM->CurrentEditMacro.Name[1] == 'i'))
pMCM->CurrentEditMacro.Name[0] = 'U'; pMCM->CurrentEditMacro.Name[0] = 'U';
pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.Name); pEB->setInputString(pMCM->CurrentEditMacro.Name);
} }
}; };
REGISTER_ACTION_HANDLER( CHandlerNewMacroEnterName, "new_macro_enter_name"); REGISTER_ACTION_HANDLER( CHandlerNewMacroEnterName, "new_macro_enter_name");
@ -886,7 +886,7 @@ public:
if (pCS != NULL) pCS->readFromMacro(pMCM->CurrentEditMacro); if (pCS != NULL) pCS->readFromMacro(pMCM->CurrentEditMacro);
// Name // Name
CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_EDIT_NAME)); CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_EDIT_NAME));
if (pEB != NULL) pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.Name); if (pEB != NULL) pEB->setInputString(pMCM->CurrentEditMacro.Name);
// Commands // Commands
CGroupList *pList = dynamic_cast<CGroupList*>(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_COMMANDS)); CGroupList *pList = dynamic_cast<CGroupList*>(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_COMMANDS));
if (pList == NULL) return; if (pList == NULL) return;
@ -895,9 +895,9 @@ public:
if (pVT != NULL) if (pVT != NULL)
{ {
if (pMCM->CurrentEditMacro.Combo.Key == KeyCount) 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 else
pVT->setText(pMCM->CurrentEditMacro.Combo.toUCString()); pVT->setText(pMCM->CurrentEditMacro.Combo.toUCString().toUtf8());
} }
pList->clearGroups(); pList->clearGroups();
@ -1003,9 +1003,9 @@ void addMacroLine (CGroupList *pParent, uint macNb, const CMacroCmd &macro)
if (pVT != NULL) if (pVT != NULL)
{ {
if (macro.Combo.Key != KeyCount) if (macro.Combo.Key != KeyCount)
pVT->setText(macro.Combo.toUCString()); pVT->setText(macro.Combo.toUCString().toUtf8());
else else
pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT).toUtf8());
} }
pNewMacro->setParent (pParent); pNewMacro->setParent (pParent);

@ -328,7 +328,7 @@ void CMusicPlayer::rebuildPlaylist()
{ {
ucstring title; ucstring title;
title.fromUtf8(_Songs[i].Title); title.fromUtf8(_Songs[i].Title);
pVT->setText(title); pVT->setText(title.toUtf8());
} }
pVT = dynamic_cast<CViewText *>(pNew->getView(TEMPLATE_PLAYLIST_SONG_DURATION)); pVT = dynamic_cast<CViewText *>(pNew->getView(TEMPLATE_PLAYLIST_SONG_DURATION));
@ -483,7 +483,7 @@ void CMusicPlayer::updatePlayingInfo(const std::string info)
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text")); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text"));
if (pVT) if (pVT)
{ {
pVT->setText(ucstring::makeFromUtf8(info)); pVT->setText(info);
} }
} }

@ -2199,7 +2199,7 @@ public:
if (gc) if (gc)
{ {
CGroupEditBox *geb = dynamic_cast<CGroupEditBox *>(gc->getGroup("add_contact_eb:eb")); CGroupEditBox *geb = dynamic_cast<CGroupEditBox *>(gc->getGroup("add_contact_eb:eb"));
geb->setInputString(u32string()); geb->setInputString(std::string());
} }
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams);
} }
@ -2257,11 +2257,11 @@ public:
else else
{ {
PeopleInterraction.askAddContact(geb->getInputStringAsUtf16(), peopleList); 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) if (eb)
{ {
CWidgetManager::getInstance()->setCaptureKeyboard(eb); CWidgetManager::getInstance()->setCaptureKeyboard(eb);
eb->setInputString(u32string()); eb->setInputString(std::string());
} }
// //
if (gc->getActive()) if (gc->getActive())
@ -2831,7 +2831,7 @@ class CHandlerSelectChatSource : public IActionHandler
{ {
ucstring title; ucstring title;
STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title);
pVTM->setText("["+s+"] " + title); pVTM->setText("["+s+"] " + title.toUtf8());
} }
} }
} }

@ -884,7 +884,7 @@ class CHandlerContactEntry : public IActionHandler
// Parse any tokens in the text // Parse any tokens in the text
if ( ! CInterfaceManager::parseTokens(text)) if ( ! CInterfaceManager::parseTokens(text))
{ {
pEB->setInputString (u32string()); pEB->setInputString (std::string());
return; return;
} }
@ -895,7 +895,7 @@ class CHandlerContactEntry : public IActionHandler
// TODO : have NLMISC::ICommand accept unicode strings // TODO : have NLMISC::ICommand accept unicode strings
std::string str = text.toUtf8().substr(1); std::string str = text.toUtf8().substr(1);
NLMISC::ICommand::execute( str, g_log ); NLMISC::ICommand::execute( str, g_log );
pEB->setInputString (u32string()); pEB->setInputString (std::string());
return; return;
} }
// Well, we could have used CChatWindow class to handle this, but CPeopleList was written earlier, so for now // 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 // Simply do a tell on the player
ChatMngr.tell(playerName.toString(), text); ChatMngr.tell(playerName.toString(), text);
pEB->setInputString (u32string()); pEB->setInputString (std::string());
if (gc) if (gc)
{ {
// Restore position of enclosing container if it hasn't been moved/scaled/poped by the user // Restore position of enclosing container if it hasn't been moved/scaled/poped by the user

@ -1097,7 +1097,7 @@ public:
string titleStr = CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)i); string titleStr = CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)i);
bool womenTitle = (UserEntity && UserEntity->getGender() == GSGENDER::female); bool womenTitle = (UserEntity && UserEntity->getGender() == GSGENDER::female);
const ucstring s(CStringManagerClient::getTitleLocalizedName(titleStr,womenTitle)); const ucstring s(CStringManagerClient::getTitleLocalizedName(titleStr,womenTitle));
pCB->addText(s); pCB->addText(s.toUtf8());
pSM->_UIUnblockedTitles.push_back((CHARACTER_TITLE::ECharacterTitle)i); pSM->_UIUnblockedTitles.push_back((CHARACTER_TITLE::ECharacterTitle)i);
} }
} }

@ -180,9 +180,9 @@ public:
if (pVT != NULL) if (pVT != NULL)
{ {
if (it != acmap.end()) if (it != acmap.end())
pVT->setText(it->second.toUCString()); pVT->setText(it->second.toUCString().toUtf8());
else else
pVT->setText(CI18N::get("uiNotAssigned")); pVT->setText(CI18N::get("uiNotAssigned").toUtf8());
} }
} }
} }

@ -243,7 +243,7 @@ void createOptionalCatUI()
pVT = dynamic_cast<CViewText*>(pNewLine->getView("size")); pVT = dynamic_cast<CViewText*>(pNewLine->getView("size"));
if (pVT != NULL) if (pVT != NULL)
{ {
pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size)); pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size).toUtf8());
} }
// Add to the list // Add to the list
@ -287,7 +287,7 @@ static void setDataScanLog(const ucstring &text)
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:log_txt:log")); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:log_txt:log"));
if (pVT != NULL) 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(); CInterfaceManager *pIM= CInterfaceManager::getInstance();
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:state")); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:state"));
if (pVT != NULL) pVT->setText(text); if (pVT != NULL) pVT->setText(text.toUtf8());
pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:progress")); pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:progress"));
if (pVT != NULL) pVT->setText(progress); if (pVT != NULL) pVT->setText(progress.toUtf8());
} }
void initCatDisplay() void initCatDisplay()
@ -338,7 +338,7 @@ static void setPatcherStateText(const std::string &baseUIPath, const ucstring &s
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:state")); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:state"));
if (pVT != NULL) 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<CViewText*>(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:progress")); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:progress"));
if (pVT != NULL) if (pVT != NULL)
{ {
pVT->setText(str); pVT->setText(str.toUtf8());
} }
} }
@ -717,7 +717,7 @@ void loginMainLoop()
ucstring sTmp; ucstring sTmp;
sTmp = BGDownloader::getWrittenSize(currentPatchingSize); sTmp = BGDownloader::getWrittenSize(currentPatchingSize);
sTmp += " / " + BGDownloader::getWrittenSize(totalPatchSize); 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 (screen == UI_VARIABLES_SCREEN_CATDISP) // If we are displaying patch info
else if (LoginSM.getCurrentState() == CLoginStateMachine::st_display_cat) 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 // Total size of the patches is optional cats + required cat (f(optCat)) + non opt cat
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(VIEW_TOTAL_SIZE)); CViewText *pVT = dynamic_cast<CViewText*>(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<CViewText*>(CWidgetManager::getInstance()->getElementFromId(VIEW_NON_OPTIONAL_SIZE)); pVT = dynamic_cast<CViewText*>(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<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); CGroupEditBox *pGEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN));
if (pGEB != NULL && (pGEB->getInputString().empty())) 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"); CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false");
} }
@ -830,8 +830,8 @@ void initAutoLogin()
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
CGroupEditBox *pGEBLog = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); CGroupEditBox *pGEBLog = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN));
CGroupEditBox *pGEBPwd = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD)); CGroupEditBox *pGEBPwd = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD));
pGEBLog->setInputStringAsUtf8(LoginLogin); pGEBLog->setInputString(LoginLogin);
pGEBPwd->setInputStringAsUtf8(LoginPassword); pGEBPwd->setInputString(LoginPassword);
CAHManager::getInstance()->runActionHandler("on_login", NULL, ""); CAHManager::getInstance()->runActionHandler("on_login", NULL, "");
if (ClientCfg.R2Mode) if (ClientCfg.R2Mode)
@ -1379,8 +1379,8 @@ class CAHOnLogin : public IActionHandler
return; return;
} }
LoginLogin = pGEBLog->getInputStringAsUtf8(); LoginLogin = pGEBLog->getInputString();
LoginPassword = pGEBPwd->getInputStringAsUtf8(); LoginPassword = pGEBPwd->getInputString();
onlogin(); onlogin();
} }
@ -2394,7 +2394,7 @@ bool initCreateAccount()
{ {
CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId(editBoxes[i] + ":eb")); CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId(editBoxes[i] + ":eb"));
if(eb) if(eb)
eb->setInputString(u32string()); eb->setInputString(std::string());
} }
// conditions button // conditions button
@ -2581,7 +2581,7 @@ class CAHOnCreateAccountSubmit : public IActionHandler
{ {
CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId(editBoxes[i] + ":eb")); CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId(editBoxes[i] + ":eb"));
if(eb) if(eb)
results[i] = eb->getInputStringAsUtf8(); results[i] = eb->getInputString();
} }
// text // text
@ -2735,11 +2735,11 @@ class CAHCreateAccountLogin : public IActionHandler
{ {
CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId("eb_login:eb")); CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId("eb_login:eb"));
if(eb) if(eb)
LoginLogin = eb->getInputStringAsUtf8(); LoginLogin = eb->getInputString();
eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId("eb_password:eb")); eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId("eb_password:eb"));
if(eb) if(eb)
LoginPassword = eb->getInputStringAsUtf8(); LoginPassword = eb->getInputString();
onlogin(false); onlogin(false);
} }

@ -3373,7 +3373,7 @@ private:
// must set the text by hand // must set the text by hand
CViewText *vt= dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(CWidgetManager::getInstance()->getParser()->getDefine("server_message_box_content_view_text"))); CViewText *vt= dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(CWidgetManager::getInstance()->getParser()->getDefine("server_message_box_content_view_text")));
if(vt) if(vt)
vt->setTextFormatTaged(contentStr); vt->setTextFormatTaged(contentStr.toUtf8());
// open // open
CWidgetManager::getInstance()->setTopWindow(pGC); CWidgetManager::getInstance()->setTopWindow(pGC);

@ -712,7 +712,7 @@ void CPlayerCL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle *
if (_Slot == 0) if (_Slot == 0)
{ {
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:player:header_opened:player_title")); CViewText *pVT = dynamic_cast<CViewText*>(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 // rebuild in scene interface

@ -1761,7 +1761,7 @@ void CEditor::waitScenarioScreen()
// Display the firewall alert string // Display the firewall alert string
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_connecting:title")); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_connecting:title"));
if (pVT != NULL) 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 // 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 nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts
@ -1853,8 +1853,8 @@ void CEditor::waitScenarioScreen()
if (pVT != NULL) if (pVT != NULL)
{ {
pVT->setMultiLine( true ); pVT->setMultiLine( true );
pVT->setText(CI18N::get("uiFirewallFail")+ucstring(".\n")+ pVT->setText(CI18N::get("uiFirewallFail").toUtf8()+".\n"+
CI18N::get("uiFirewallAlert")+ucstring(".")); CI18N::get("uiFirewallAlert").toUtf8()+".");
} }
} }
} }
@ -6468,7 +6468,7 @@ void CEditor::connectionMsg(const std::string &stringId)
CViewText *vt = dynamic_cast<CViewText *>(r2ConnectWindow->getView("connexionMsg")); CViewText *vt = dynamic_cast<CViewText *>(r2ConnectWindow->getView("connexionMsg"));
if (vt) 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<CGroupEditBox *>(fatherGC->getGroup("add_contact_eb:eb")); CGroupEditBox *geb = dynamic_cast<CGroupEditBox *>(fatherGC->getGroup("add_contact_eb:eb"));
if (geb && !geb->getInputString().empty()) if (geb && !geb->getInputString().empty())
{ {
string charName = geb->getInputStringAsUtf8(); string charName = geb->getInputString();
CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance(); CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance();
sessionBrowser.inviteCharacterByName(sessionBrowser.getCharId(), charName); sessionBrowser.inviteCharacterByName(sessionBrowser.getCharId(), charName);
@ -7497,7 +7497,7 @@ class CAHInviteCharacter : public IActionHandler
{ {
CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL) 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"); 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"); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_newcomer");
} }
geb->setInputString(u32string()); geb->setInputString(std::string());
} }
} }
} }

@ -230,7 +230,7 @@ int CSessionBrowserImpl::luaJoinRingSession(CLuaState &ls)
{ {
CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL) 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"); CAHManager::getInstance()->runActionHandler("enter_modal", NULL, "group=ui:interface:warning_free_trial");
} }

Loading…
Cancel
Save