Merge branch 'develop' into ryzomclassic-develop

ryzomclassic-develop
kaetemi 4 years ago
commit fa086ea4b9

@ -38,7 +38,7 @@ namespace NLGUI
private: private:
// stylesheet currently parsed // stylesheet currently parsed
ucstring _Style; std::string _Style;
// keep track of current position in _Style // keep track of current position in _Style
size_t _Position; size_t _Position;
@ -70,49 +70,49 @@ namespace NLGUI
void preprocess(); void preprocess();
// parse selectors + combinators // parse selectors + combinators
std::vector<CCssSelector> parse_selector(const ucstring &sel, std::string &pseudoElement) const; std::vector<CCssSelector> parse_selector(const std::string &sel, std::string &pseudoElement) const;
// parse selector and style // parse selector and style
void parseRule(const ucstring &selectorString, const ucstring &styleString); void parseRule(const std::string &selectorString, const std::string &styleString);
inline bool is_eof() const inline bool is_eof() const
{ {
return _Position >= _Style.size(); return _Position >= _Style.size();
} }
inline bool is_whitespace(ucchar ch) const inline bool is_whitespace(char ch) const
{ {
return (ch == (ucchar)' ' || ch == (ucchar)'\t' || ch == (ucchar)'\n'); return (ch == ' ' || ch == '\t' || ch == '\n');
} }
inline bool is_hex(ucchar ch) const inline bool is_hex(char ch) const
{ {
return ((ch >= (ucchar)'0' && ch <= (ucchar)'9') || return ((ch >= '0' && ch <= '9') ||
(ch >= (ucchar)'a' && ch <= (ucchar)'f') || (ch >= 'a' && ch <= 'f') ||
(ch >= (ucchar)'A' && ch <= (ucchar)'F')); (ch >= 'A' && ch <= 'F'));
} }
inline bool maybe_escape() const inline bool maybe_escape() const
{ {
// escaping newline (\n) only allowed inside strings // escaping newline (\n) only allowed inside strings
return (_Style.size() - _Position) >= 1 && _Style[_Position] == (ucchar)'\\' && _Style[_Position+1] != '\n'; return (_Style.size() - _Position) >= 1 && _Style[_Position] == '\\' && _Style[_Position+1] != '\n';
} }
inline bool is_quote(ucchar ch) const inline bool is_quote(char ch) const
{ {
return ch== (ucchar)'"' || ch == (ucchar)'\''; return ch== '"' || ch == '\'';
} }
inline bool is_block_open(ucchar ch) const inline bool is_block_open(char ch) const
{ {
return ch == (ucchar)'{' || ch == (ucchar)'[' || ch == (ucchar)'('; return ch == (char)'{' || ch == (char)'[' || ch == (char)'(';
} }
inline bool is_block_close(ucchar ch, ucchar open) const inline bool is_block_close(char ch, char open) const
{ {
return ((open == '{' && ch == (ucchar)'}') || return ((open == '{' && ch == (char)'}') ||
(open == '[' && ch == (ucchar)']') || (open == '[' && ch == (char)']') ||
(open == '(' && ch == (ucchar)')')); (open == '(' && ch == (char)')'));
} }
inline bool is_comment_open() const inline bool is_comment_open() const
@ -120,25 +120,25 @@ namespace NLGUI
if (_Position+1 > _Style.size()) if (_Position+1 > _Style.size())
return false; return false;
return _Style[_Position] == (ucchar)'/' && _Style[_Position+1] == (ucchar)'*'; return _Style[_Position] == (char)'/' && _Style[_Position+1] == (char)'*';
} }
inline bool is_nonascii(ucchar ch) const inline bool is_nonascii(char ch) const
{ {
return ch >= 0x80 /*&& ch <= 255*/; return ch >= 0x80 /*&& ch <= 255*/;
} }
inline bool is_alpha(ucchar ch) const inline bool is_alpha(char ch) const
{ {
return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'); return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
} }
inline bool is_digit(ucchar ch) const inline bool is_digit(char ch) const
{ {
return ch >= '0' && ch <= '9'; return ch >= '0' && ch <= '9';
} }
inline bool is_nmchar(ucchar ch) const inline bool is_nmchar(char ch) const
{ {
// checking escape here does not check if next char is '\n' or not // checking escape here does not check if next char is '\n' or not
return ch == '_' || ch == '-' || is_alpha(ch) || is_digit(ch) || is_nonascii(ch) || ch == '\\'/*is_escape(ch)*/; return ch == '_' || ch == '-' || is_alpha(ch) || is_digit(ch) || is_nonascii(ch) || ch == '\\'/*is_escape(ch)*/;

@ -85,9 +85,10 @@ namespace NLGUI
/// Get the ContextHelp for this control. Default is to return _ContextHelp /// Get the ContextHelp for this control. Default is to return _ContextHelp
virtual void getContextHelp(ucstring &help) const {help= _ContextHelp;} virtual void getContextHelp(std::string &help) const {help= _ContextHelp;}
virtual void getContextHelpAsUtf16(ucstring &help) const {help.fromUtf8(_ContextHelp);}
/// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp. /// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp.
virtual void getContextHelpToolTip(ucstring &help) const { getContextHelp(help); } virtual void getContextHelpToolTip(std::string &help) const { getContextHelp(help); }
// Get the name of the context help window. Default to "context_help" // Get the name of the context help window. Default to "context_help"
virtual std::string getContextHelpWindowName() const; virtual std::string getContextHelpWindowName() const;
/// Get the ContextHelp ActionHandler. If "", noop /// Get the ContextHelp ActionHandler. If "", noop
@ -123,8 +124,10 @@ namespace NLGUI
void setToolTipPosRef(THotSpot pos) { _ToolTipPosRef = pos;} void setToolTipPosRef(THotSpot pos) { _ToolTipPosRef = pos;}
/// replace the default contextHelp /// replace the default contextHelp
ucstring getDefaultContextHelp() const {return _ContextHelp;} std::string getDefaultContextHelp() const {return _ContextHelp;}
void setDefaultContextHelp(const ucstring &help) {_ContextHelp= help;} void setDefaultContextHelp(const std::string &help) {_ContextHelp= help;}
ucstring getDefaultContextHelpAsUtf16() const {return ucstring::makeFromUtf8(_ContextHelp);}
void setDefaultContextHelpAsUtf16(const ucstring &help) {_ContextHelp= help.toUtf8();}
void setOnContextHelp(const std::string &help) {_OnContextHelp= help;} void setOnContextHelp(const std::string &help) {_OnContextHelp= help;}
void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;} void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;}
@ -158,7 +161,7 @@ namespace NLGUI
int luaSetTooltipUtf8(CLuaState &ls); int luaSetTooltipUtf8(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlBase, CViewBase) REFLECT_EXPORT_START(CCtrlBase, CViewBase)
REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp); REFLECT_UCSTRING("tooltip", getDefaultContextHelpAsUtf16, setDefaultContextHelpAsUtf16); // FIXME: Lua UTF-8
REFLECT_LUA_METHOD("setTooltipUtf8", luaSetTooltipUtf8); REFLECT_LUA_METHOD("setTooltipUtf8", luaSetTooltipUtf8);
REFLECT_EXPORT_END REFLECT_EXPORT_END
@ -171,7 +174,7 @@ namespace NLGUI
protected: protected:
// This is the ContextHelp filled by default in parse() // This is the ContextHelp filled by default in parse()
ucstring _ContextHelp; std::string _ContextHelp;
CStringShared _OnContextHelp; CStringShared _OnContextHelp;
CStringShared _OnContextHelpParams; CStringShared _OnContextHelpParams;
CStringShared _ToolTipSpecialParent; CStringShared _ToolTipSpecialParent;

@ -96,8 +96,10 @@ namespace NLGUI
bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;} bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;}
void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;} void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;}
// Set text (noop if text id) // Set text (noop if text id)
void setText (const ucstring &text); void setText (const std::string &text);
ucstring getText () const; std::string getText () const;
void setTextAsUtf16 (const ucstring &text);
ucstring getTextAsUtf16 () const;
void setHardText (const std::string &text); void setHardText (const std::string &text);
std::string getHardText () const; std::string getHardText () const;
@ -130,7 +132,7 @@ namespace NLGUI
int luaGetViewText(CLuaState &ls); int luaGetViewText(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton) REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton)
REFLECT_UCSTRING("uc_hardtext", getText, setText); REFLECT_UCSTRING("uc_hardtext", getTextAsUtf16, setTextAsUtf16);
REFLECT_STRING("hardtext", getHardText, setHardText); REFLECT_STRING("hardtext", getHardText, setHardText);
REFLECT_SINT32("text_x", getTextX, setTextX) REFLECT_SINT32("text_x", getTextX, setTextX)
REFLECT_SINT32("wmargin", getWMargin, setWMargin) REFLECT_SINT32("wmargin", getWMargin, setWMargin)

@ -82,13 +82,13 @@ public:
return _Key; return _Key;
} }
// return the char that has been pressed. The key event type MUST be 'keychar', else => assert // return the char that has been pressed. The key event type MUST be 'keychar', else => assert
ucchar getChar() const u32char getChar() const
{ {
nlassert(_KeyEvent == keychar); nlassert(_KeyEvent == keychar);
return _Char; return _Char;
} }
// return the string that has been sent. The key event type MUST be 'keystring', else => assert // return the string that has been sent. The key event type MUST be 'keystring', else => assert
ucstring getString() const std::string getString() const
{ {
nlassert(_KeyEvent == keystring); nlassert(_KeyEvent == keystring);
return _String; return _String;
@ -141,9 +141,9 @@ private:
union union
{ {
NLMISC::TKey _Key; NLMISC::TKey _Key;
ucchar _Char; u32char _Char;
}; };
ucstring _String; std::string _String;
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

@ -248,6 +248,13 @@ namespace NLGUI
// Get the header color draw. NB: depends if grayed, and if active. // Get the header color draw. NB: depends if grayed, and if active.
NLMISC::CRGBA getDrawnHeaderColor () const; NLMISC::CRGBA getDrawnHeaderColor () const;
std::string getTitleRaw () const;
void setTitleRaw (const std::string &title);
std::string getTitleOpenedRaw () const;
void setTitleOpenedRaw (const std::string &title);
std::string getTitleClosedRaw () const;
void setTitleClosedRaw (const std::string &title);
ucstring getUCTitleOpened () const; ucstring getUCTitleOpened () const;
void setUCTitleOpened (const ucstring &title); void setUCTitleOpened (const ucstring &title);
ucstring getUCTitleClosed () const; ucstring getUCTitleClosed () const;
@ -287,9 +294,15 @@ namespace NLGUI
REFLECT_STRING("title", getTitle, setTitle); REFLECT_STRING("title", getTitle, setTitle);
REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened); REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened);
REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed); REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed);
REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened);
REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); REFLECT_STRING("title_raw", getTitleRaw, setTitleRaw);
REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); REFLECT_STRING("title_opened_raw", getTitleOpenedRaw, setTitleOpenedRaw);
REFLECT_STRING("title_closed_raw", getTitleClosedRaw, setTitleClosedRaw);
REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); // FIXME: Lua UTF-8
REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); // FIXME: Lua UTF-8
REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); // FIXME: Lua UTF-8
REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString); REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString);
REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH); REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH);
REFLECT_SINT32("pop_max_h", getPopupMaxH, setPopupMaxH); REFLECT_SINT32("pop_max_h", getPopupMaxH, setPopupMaxH);
@ -477,8 +490,8 @@ namespace NLGUI
float _CurrentRolloverAlphaContainer; float _CurrentRolloverAlphaContainer;
float _CurrentRolloverAlphaContent; float _CurrentRolloverAlphaContent;
sint32 _LayerSetup; sint32 _LayerSetup;
ucstring _TitleTextOpened; std::string _TitleTextOpened;
ucstring _TitleTextClosed; std::string _TitleTextClosed;
CViewText *_TitleOpened; CViewText *_TitleOpened;
CViewText *_TitleClosed; CViewText *_TitleClosed;
sint32 _TitleDeltaMaxW; sint32 _TitleDeltaMaxW;

@ -65,15 +65,15 @@ namespace NLGUI
/// Accessors /// Accessors
std::string getInputString() const; std::string getInputString() const;
std::string getPrompt() const; std::string getPrompt() const;
const u32string &getInputStringRef() const { return _InputString; } const ::u32string &getInputStringRef() const { return _InputString; }
const u32string &getPromptRef() 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 std::string &s); void setPrompt(const std::string &s);
void setInputString(const std::string &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;
void setInputStringAsInt64(sint64 val); void setInputStringAsInt64(sint64 val);
@ -82,8 +82,8 @@ namespace NLGUI
float getInputStringAsFloat() const; float getInputStringAsFloat() const;
void setInputStringAsUtf16(const ucstring &str); void setInputStringAsUtf16(const ucstring &str);
ucstring getInputStringAsUtf16() const; ucstring getInputStringAsUtf16() const;
void setInputStringAsUtf32(const u32string &str); void setInputStringAsUtf32(const ::u32string &str);
u32string getInputStringAsUtf32() const { return _InputString; } ::u32string getInputStringAsUtf32() const { return _InputString; }
void setColor(NLMISC::CRGBA col); void setColor(NLMISC::CRGBA col);
@ -98,7 +98,7 @@ namespace NLGUI
static CGroupEditBox *getMenuFather() { return _MenuFather; } static CGroupEditBox *getMenuFather() { return _MenuFather; }
void setCommand(const ucstring &command, bool execute); void setCommand(const std::string &command, bool execute);
// Stop parent from blinking // Stop parent from blinking
void stopParentBlink() { if (_Parent) _Parent->disableBlink(); } void stopParentBlink() { if (_Parent) _Parent->disableBlink(); }
@ -122,7 +122,7 @@ namespace NLGUI
sint32 getMaxHistoric() const {return _MaxHistoric;} sint32 getMaxHistoric() const {return _MaxHistoric;}
sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;} sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;}
void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;} void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;}
const u32string &getHistoric(uint32 index) const {return _Historic[index];} const ::u32string &getHistoric(uint32 index) const {return _Historic[index];}
uint32 getNumHistoric() const {return (uint32)_Historic.size ();} uint32 getNumHistoric() const {return (uint32)_Historic.size ();}
// Get on change action handler // Get on change action handler
@ -140,7 +140,7 @@ namespace NLGUI
// Paste the selection into buffer // Paste the selection into buffer
void paste(); void paste();
// Write the string into buffer // Write the string into buffer
void writeString(const ucstring &str, bool replace = true, bool atEnd = true); void writeString(const ucstring &str, bool replace = true, bool atEnd = true); // UTF-16 because of Clipboard implementation
// Expand the expression (true if there was a '/' at the start of the line) // Expand the expression (true if there was a '/' at the start of the line)
bool expand(); bool expand();
@ -171,7 +171,7 @@ namespace NLGUI
virtual void onKeyboardCaptureLost(); virtual void onKeyboardCaptureLost();
// set the input string as "default". will be reseted at first click (used for user information) // set the input string as "default". will be reseted at first click (used for user information)
void setDefaultInputString(const ucstring &str); void setDefaultInputString(const std::string &str);
// For Interger and PositiveInteger, can specify min and max values // For Interger and PositiveInteger, can specify min and max values
void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;} void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;}
@ -229,17 +229,17 @@ namespace NLGUI
NLMISC::CRGBA _BackSelectColor; NLMISC::CRGBA _BackSelectColor;
// Text info // Text info
u32string _Prompt; ::u32string _Prompt;
u32string _InputString; ::u32string _InputString;
CViewText *_ViewText; CViewText *_ViewText;
// undo / redo // undo / redo
u32string _StartInputString; // value of the input string when focus was acuired first ::u32string _StartInputString; // value of the input string when focus was acuired first
u32string _ModifiedInputString; ::u32string _ModifiedInputString;
// Historic info // Historic info
typedef std::deque<u32string> THistoric; typedef std::deque<::u32string> THistoric;
THistoric _Historic; THistoric _Historic;
uint32 _MaxHistoric; uint32 _MaxHistoric;
sint32 _CurrentHistoricIndex; sint32 _CurrentHistoricIndex;
@ -276,7 +276,7 @@ namespace NLGUI
bool _CanRedo : 1; bool _CanRedo : 1;
bool _CanUndo : 1; bool _CanUndo : 1;
std::vector<char> _NegativeFilter; std::vector<u32char> _NegativeFilter;
sint _CursorTexID; sint _CursorTexID;
sint32 _CursorWidth; sint32 _CursorWidth;
@ -299,13 +299,13 @@ namespace NLGUI
void handleEventString(const NLGUI::CEventDescriptorKey &event); void handleEventString(const NLGUI::CEventDescriptorKey &event);
void setup(); void setup();
void triggerOnChangeAH(); void triggerOnChangeAH();
void appendStringFromClipboard(const ucstring &str); void appendStringFromClipboard(const ucstring &str); // UTF-16 because of Clipboard implementation
ucstring getSelection(); ucstring getSelection(); // UTF-16 because of Clipboard implementation
static CGroupEditBox *_MenuFather; static CGroupEditBox *_MenuFather;
static bool isValidAlphaNumSpace(ucchar c) static bool isValidAlphaNumSpace(u32char c)
{ {
if (c > 255) return false; if (c > 255) return false;
char ac = (char) c; char ac = (char) c;
@ -315,7 +315,7 @@ namespace NLGUI
ac==' '; ac==' ';
} }
static bool isValidAlphaNum(ucchar c) static bool isValidAlphaNum(u32char c)
{ {
if (c > 255) return false; if (c > 255) return false;
char ac = (char) c; char ac = (char) c;
@ -324,7 +324,7 @@ namespace NLGUI
(ac >= 'A' && ac <= 'Z'); (ac >= 'A' && ac <= 'Z');
} }
static bool isValidAlpha(ucchar c) static bool isValidAlpha(u32char c)
{ {
if (c > 255) return false; if (c > 255) return false;
char ac = (char) c; char ac = (char) c;
@ -332,13 +332,13 @@ namespace NLGUI
(ac >= 'A' && ac <= 'Z'); (ac >= 'A' && ac <= 'Z');
} }
static bool isValidPlayerNameChar(ucchar c) static bool isValidPlayerNameChar(u32char c)
{ {
// valid player name (with possible shard prefix / suffix format // valid player name (with possible shard prefix / suffix format
return isValidAlpha(c) || c=='.' || c=='(' || c==')'; return isValidAlpha(c) || c=='.' || c=='(' || c==')';
} }
static bool isValidFilenameChar(ucchar c) static bool isValidFilenameChar(u32char c)
{ {
if (c == '\\' || if (c == '\\' ||
c == '/' || c == '/' ||
@ -352,12 +352,12 @@ namespace NLGUI
return true; return true;
} }
// //
bool isFiltered(ucchar c) bool isFiltered(u32char c)
{ {
uint length = (uint)_NegativeFilter.size(); ptrdiff_t length = _NegativeFilter.size();
for (uint k = 0; k < length; ++k) for (ptrdiff_t k = 0; k < length; ++k)
{ {
if ((ucchar) _NegativeFilter[k] == c) return true; if (_NegativeFilter[k] == c) return true;
} }
return false; return false;
} }

@ -320,16 +320,16 @@ namespace NLGUI
void clearContext(); void clearContext();
// Translate a char // Translate a char
bool translateChar(ucchar &output, ucchar input, ucchar lastChar) const; bool translateChar(u32char &output, u32char input, u32char lastChar) const;
// Add a string in the current paragraph // Add a string in the current paragraph
void addString(const ucstring &str); void addString(const std::string &str);
// Add an image in the current paragraph // Add an image in the current paragraph
void addImage(const std::string &id, const std::string &img, bool reloadImg=false, const CStyleParams &style = CStyleParams()); void addImage(const std::string &id, const std::string &img, bool reloadImg=false, const CStyleParams &style = CStyleParams());
// Add a text area in the current paragraph // Add a text area in the current paragraph
CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength); CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const std::string &content, uint maxlength);
// Add a combo box in the current paragraph // Add a combo box in the current paragraph
CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name); CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name);
@ -350,9 +350,9 @@ namespace NLGUI
void flushString(); void flushString();
// Set the title // Set the title
void setTitle (const ucstring &title);
void setTitle (const std::string &title); void setTitle (const std::string &title);
std::string getTitle() const; std::string getTitle() const;
void setTitleRaw (const std::string &title);
// Lookup a url in local file system // Lookup a url in local file system
bool lookupLocalFile (std::string &result, const char *url, bool isUrl); bool lookupLocalFile (std::string &result, const char *url, bool isUrl);
@ -392,10 +392,10 @@ namespace NLGUI
bool _TrustedDomain; bool _TrustedDomain;
// Title prefix // Title prefix
ucstring _TitlePrefix; std::string _TitlePrefix;
// Title string // Title string
ucstring _TitleString; std::string _TitleString;
// Need to browse next update coords.. // Need to browse next update coords..
bool _BrowseNextTime; bool _BrowseNextTime;
@ -644,7 +644,7 @@ namespace NLGUI
std::string Name; std::string Name;
// Variable value // Variable value
ucstring Value; std::string Value;
// Text area group // Text area group
CInterfaceGroup *TextArea; CInterfaceGroup *TextArea;
@ -747,7 +747,7 @@ namespace NLGUI
// Current node is a text area // Current node is a text area
bool _TextArea; bool _TextArea;
std::string _TextAreaTemplate; std::string _TextAreaTemplate;
ucstring _TextAreaContent; std::string _TextAreaContent;
std::string _TextAreaName; std::string _TextAreaName;
uint _TextAreaRow; uint _TextAreaRow;
uint _TextAreaCols; uint _TextAreaCols;
@ -755,7 +755,7 @@ namespace NLGUI
// current mode is in select option // current mode is in select option
bool _SelectOption; bool _SelectOption;
ucstring _SelectOptionStr; std::string _SelectOptionStr;
// Current node is a object // Current node is a object
std::string _ObjectType; std::string _ObjectType;
@ -826,7 +826,7 @@ namespace NLGUI
void spliceFragment(std::list<CHtmlElement>::iterator src); void spliceFragment(std::list<CHtmlElement>::iterator src);
// decode all HTML entities // decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str); static std::string decodeHTMLEntities(const std::string &str);
struct CDataImageDownload struct CDataImageDownload
{ {

@ -67,13 +67,13 @@ namespace NLGUI
* \param line : text to be added * \param line : text to be added
* \param color : text color * \param color : text color
*/ */
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true); void addTextChild (const std::string& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
/** /**
* add a text child element to the group, using the text template * add a text child element to the group, using the text template
* \param line : text to be added * \param line : text to be added
*/ */
void addTextChild (const ucstring& line, bool multiLine = true); void addTextChild (const std::string& line, bool multiLine = true);
/// Same as adding a text child but the text will be taken from the string manager /// Same as adding a text child but the text will be taken from the string manager
void addTextChildID (uint32 id, bool multiLine = true); void addTextChildID (uint32 id, bool multiLine = true);

@ -122,12 +122,12 @@ namespace NLGUI
// retrieve the index of a line from its id (-1 if not found) // retrieve the index of a line from its id (-1 if not found)
sint getLineFromId(const std::string &id); sint getLineFromId(const std::string &id);
CViewTextMenu* addLine (const ucstring &name, const std::string &ah, CViewTextMenu* addLine (const std::string &name, const std::string &ah,
const std::string &params, const std::string &id="", const std::string &params, const std::string &id="",
const std::string &cond = std::string(), const std::string &texture="", const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false, bool formatted = false bool checkable = false, bool checked = false, bool formatted = false
); );
CViewTextMenu* addLineAtIndex(uint index, const ucstring &name, const std::string &ah, CViewTextMenu* addLineAtIndex(uint index, const std::string &name, const std::string &ah,
const std::string &params, const std::string &id="", const std::string &params, const std::string &id="",
const std::string &cond = std::string(), const std::string &texture="", const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false, bool formatted = false bool checkable = false, bool checked = false, bool formatted = false
@ -333,11 +333,6 @@ namespace NLGUI
virtual bool isWindowUnder (sint32 x, sint32 y); virtual bool isWindowUnder (sint32 x, sint32 y);
// add line with a string, for backward compatibility
void addLine (const std::string &name, const std::string &ah, const std::string &params,
const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false);
uint getNumLine() const; uint getNumLine() const;
void deleteLine(uint index); void deleteLine(uint index);
const std::string getActionHandler(uint lineIndex) const; const std::string getActionHandler(uint lineIndex) const;
@ -350,12 +345,12 @@ namespace NLGUI
void setRightClickHandler(uint lineIndex, const std::string &ah = ""); void setRightClickHandler(uint lineIndex, const std::string &ah = "");
void setRightClickHandlerParam(uint lineIndex, const std::string &params = ""); void setRightClickHandlerParam(uint lineIndex, const std::string &params = "");
void addLine (const ucstring &name, const std::string &ah = "", const std::string &params = "", void addLine (const std::string &name, const std::string &ah = "", const std::string &params = "",
const std::string &id = std::string(), const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="", const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false bool checkable = false, bool checked = false
); );
void addLineAtIndex (uint index, const ucstring &name, const std::string &ah = "", const std::string &params = "", void addLineAtIndex (uint index, const std::string &name, const std::string &ah = "", const std::string &params = "",
const std::string &id = std::string(), const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="", const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false bool checkable = false, bool checked = false

@ -84,13 +84,13 @@ namespace NLGUI
* \param line : text to be added * \param line : text to be added
* \param color : text color * \param color : text color
*/ */
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true); void addTextChild (const std::string& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
/** /**
* add a text child element to the group, using the text template * add a text child element to the group, using the text template
* \param line : text to be added * \param line : text to be added
*/ */
void addTextChild (const ucstring& line, bool multiLine = true); void addTextChild (const std::string& line, bool multiLine = true);
/// Same as adding a text child but the text will be taken from the string manager /// Same as adding a text child but the text will be taken from the string manager
void addTextChildID (uint32 id, bool multiLine = true); void addTextChildID (uint32 id, bool multiLine = true);

@ -60,7 +60,7 @@ namespace NLGUI
bool Show; // If false, the node is not displayed (true default, Root ignored) bool Show; // If false, the node is not displayed (true default, Root ignored)
sint32 YDecal; sint32 YDecal;
// Text // Text
ucstring Text; // Internationalized displayed text std::string Text; // Internationalized displayed text
sint32 FontSize; // If -1 (default), then take the groupTree one sint32 FontSize; // If -1 (default), then take the groupTree one
NLMISC::CRGBA Color; NLMISC::CRGBA Color;
// Template // Template
@ -112,8 +112,10 @@ namespace NLGUI
std::string getBitmap() const { return Bitmap; } std::string getBitmap() const { return Bitmap; }
void setOpened(bool opened) { Opened = opened; } void setOpened(bool opened) { Opened = opened; }
bool getOpened() const { return Opened; } bool getOpened() const { return Opened; }
void setText(const ucstring &text) { Text = text; } void setText(const std::string &text) { Text = text; }
const ucstring& getText() const { return Text; } const std::string& getText() const { return Text; }
void setTextAsUtf16(const ucstring &text) { Text = text.toUtf8(); }
ucstring getTextAsUtf16() const { return ucstring::makeFromUtf8(Text); }
sint32 getFontSize() const { return FontSize; } sint32 getFontSize() const { return FontSize; }
void setFontSize(sint32 value) { FontSize = value; } void setFontSize(sint32 value) { FontSize = value; }
sint32 getYDecal() const { return YDecal; } sint32 getYDecal() const { return YDecal; }
@ -181,7 +183,7 @@ namespace NLGUI
REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose); REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose);
REFLECT_BOOL("Opened", getOpened, setOpened); REFLECT_BOOL("Opened", getOpened, setOpened);
REFLECT_BOOL("Show", getShow, setShow); REFLECT_BOOL("Show", getShow, setShow);
REFLECT_UCSTRING_REF("Text", getText, setText); REFLECT_UCSTRING("Text", getTextAsUtf16, setTextAsUtf16); // FIXME: Lua UTF-8
// lua // lua
REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren); REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren);
REFLECT_LUA_METHOD("getChild", luaGetChild); REFLECT_LUA_METHOD("getChild", luaGetChild);

@ -59,16 +59,14 @@ namespace NLGUI
bool getBool() const; bool getBool() const;
sint64 getInteger() const; sint64 getInteger() const;
double getDouble() const; double getDouble() const;
std::string getString() const; const std::string &getString() const;
NLMISC::CRGBA getRGBA() const; NLMISC::CRGBA getRGBA() const;
const ucstring &getUCString() const;
CInterfaceExprUserType *getUserType() const; CInterfaceExprUserType *getUserType() const;
// set // set
void setBool(bool value) { clean(); _Type = Boolean; _BoolValue = value; } void setBool(bool value) { clean(); _Type = Boolean; _BoolValue = value; }
void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; } void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; }
void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; } void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; }
void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; } void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; }
void setUCString(const ucstring &value) { clean(); _Type = String; _StringValue = value; }
void setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); } void setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); }
void setUserType(CInterfaceExprUserType *value); void setUserType(CInterfaceExprUserType *value);
// reset this object to initial state (no type) // reset this object to initial state (no type)
@ -99,7 +97,7 @@ namespace NLGUI
CInterfaceExprUserType *_UserTypeValue; CInterfaceExprUserType *_UserTypeValue;
uint32 _RGBAValue; uint32 _RGBAValue;
}; };
ucstring _StringValue; // well, can't fit in union, unless we do some horrible hack.. std::string _StringValue; // well, can't fit in union, unless we do some horrible hack..
private: private:
const char *evalBoolean(const char *expr); const char *evalBoolean(const char *expr);
const char *evalNumber(const char *expr); const char *evalNumber(const char *expr);

@ -25,7 +25,6 @@
namespace NLGUI namespace NLGUI
{ {
enum TCaseMode enum TCaseMode
{ {
CaseNormal = 0, // Nothing done CaseNormal = 0, // Nothing done
@ -37,11 +36,7 @@ namespace NLGUI
CaseCount CaseCount
}; };
void setCase( ucstring &str, TCaseMode mode );
void setCase( std::string &str, TCaseMode mode ); void setCase( std::string &str, TCaseMode mode );
} }
#endif #endif

@ -55,7 +55,7 @@ namespace NLGUI
bool getStringMode() const {return _StringMode;} bool getStringMode() const {return _StringMode;}
// Set cursor string // Set cursor string
void setString (const ucstring &str); void setString (const std::string &str);
// TEMP PATCH // TEMP PATCH
void setCursor (const std::string &name) void setCursor (const std::string &name)
@ -126,14 +126,14 @@ namespace NLGUI
bool _ForceStringMode; bool _ForceStringMode;
CInterfaceGroup *_StringCursor; CInterfaceGroup *_StringCursor;
CInterfaceGroup *_StringCursorHardware; CInterfaceGroup *_StringCursorHardware;
ucstring _ContextString; std::string _ContextString;
// draw current cursor with the given texture, or, if in hardware mode, change the hardware cursor shape // draw current cursor with the given texture, or, if in hardware mode, change the hardware cursor shape
void drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot); void drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot);
private: private:
// set the string into frame for software or hardware version // set the string into frame for software or hardware version
void setString (const ucstring &str, CInterfaceGroup *target); void setString(const std::string &str, CInterfaceGroup *target);
static bool hwMouse; static bool hwMouse;

@ -222,7 +222,7 @@ 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("text_raw", getText, setText);
REFLECT_STRING("hardtext", getHardText, setHardText); REFLECT_STRING("hardtext", getHardText, setHardText);
// REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions // REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions
REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16); REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16);
@ -262,8 +262,8 @@ namespace NLGUI
// width of the font in pixel. Just a Hint for tabing format (computed with '_') // width of the font in pixel. Just a Hint for tabing format (computed with '_')
float _FontWidth; float _FontWidth;
// strings to use when computing font size // strings to use when computing font size
ucstring _FontSizingChars; ::u32string _FontSizingChars;
ucstring _FontSizingFallback; ::u32string _FontSizingFallback;
// height of the font in pixel. // height of the font in pixel.
// use getFontHeight // use getFontHeight
float _FontHeight; float _FontHeight;
@ -465,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 std::string &text, std::string &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<std::string> &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;

@ -45,7 +45,7 @@ namespace NLGUI
{ {
public: public:
virtual ~IViewTextFormatter(){} virtual ~IViewTextFormatter(){}
virtual ucstring formatString( const ucstring &inputString, const ucstring &paramString ) = 0; virtual std::string formatString( const std::string &inputString, const std::string &paramString ) = 0;
}; };
CViewTextFormated (const TCtorParam &param) : CViewText(param) CViewTextFormated (const TCtorParam &param) : CViewText(param)
@ -55,15 +55,15 @@ namespace NLGUI
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void checkCoords(); virtual void checkCoords();
const ucstring &getFormatString() const { return _FormatString; } const std::string &getFormatString() const { return _FormatString; }
void setFormatString(const ucstring &format); void setFormatString(const std::string &format);
static ucstring formatString(const ucstring &inputString, const ucstring &paramString); static std::string formatString(const std::string &inputString, const std::string &paramString);
static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; } static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; }
private: private:
ucstring _FormatString; std::string _FormatString;
static IViewTextFormatter *textFormatter; static IViewTextFormatter *textFormatter;
}; };

@ -58,8 +58,10 @@ namespace NLGUI
{ {
public: public:
virtual ~IViewTextProvider(){} virtual ~IViewTextProvider(){}
virtual bool getString( uint32 stringId, ucstring &result ) = 0; bool getString(uint32 stringId, std::string &result) { ucstring temp; bool res = getString(stringId, temp); result = temp.toUtf8(); return res; }
virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0; bool getDynString(uint32 dynStringId, std::string &result) { ucstring temp; bool res = getDynString(dynStringId, temp); result = temp.toUtf8(); return res; }
virtual bool getString( uint32 stringId, ucstring &result ) = 0; // TODO: UTF-8
virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0; // TODO: UTF-8
}; };
CViewTextID(const TCtorParam &param) : CViewText(param) CViewTextID(const TCtorParam &param) : CViewText(param)

@ -49,10 +49,10 @@ namespace NLGUI
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void checkCoords(); virtual void checkCoords();
const ucstring &getFormatString() const { return _FormatString; } const std::string &getFormatString() const { return _FormatString; }
void setFormatString(const ucstring &format); void setFormatString(const std::string &format);
private: private:
ucstring _FormatString; std::string _FormatString;
}; };
} }

@ -333,8 +333,8 @@ namespace NLGUI
void updateTooltipCoords(CCtrlBase *newCtrl); void updateTooltipCoords(CCtrlBase *newCtrl);
/// for ContextHelp action handler only: set the result name /// for ContextHelp action handler only: set the result name
void setContextHelpText( const ucstring &text ){ _ContextHelpText = text; } void setContextHelpText( const std::string &text ){ _ContextHelpText = text; }
ucstring& getContextHelpText(){ return _ContextHelpText; } std::string& getContextHelpText(){ return _ContextHelpText; }
/// force disable the context help /// force disable the context help
void disableContextHelp(); void disableContextHelp();
@ -626,7 +626,7 @@ namespace NLGUI
SInterfaceTimes interfaceTimes; SInterfaceTimes interfaceTimes;
ucstring _ContextHelpText; std::string _ContextHelpText;
bool _ContextHelpActive; bool _ContextHelpActive;
bool inGame; bool inGame;

@ -227,8 +227,8 @@ 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 ); // Ascii only std::string toLower ( const char *str ); // UTF-8
std::string toLower ( const std::string &str ); // Ascii only std::string toLower ( const std::string &str ); // UTF-8
void toLower ( char *str ); // Ascii only void toLower ( char *str ); // Ascii only
char toLower ( const char ch ); // convert only one character char toLower ( const char ch ); // convert only one character
@ -236,8 +236,8 @@ char toLower ( const char ch ); // convert only one character
* \param a string to transform to upper case * \param a string to transform to upper case
*/ */
// std::string toUpper ( const char *str ); // Ascii only std::string toUpper ( const char *str ); // UTF-8
std::string toUpper ( const std::string &str); // Ascii only std::string toUpper ( const std::string &str); // UTF-8
void toUpper ( char *str); // Ascii only void toUpper ( char *str); // Ascii only

@ -320,11 +320,11 @@ public:
class CEventChar : public CEventKey class CEventChar : public CEventKey
{ {
public: public:
CEventChar (ucchar c, TKeyButton button, IEventEmitter* emitter) : CEventKey (button, emitter, EventCharId), _Raw(true) CEventChar (u32char c, TKeyButton button, IEventEmitter* emitter) : CEventKey (button, emitter, EventCharId), _Raw(true)
{ {
Char=c; Char=c;
} }
ucchar Char; u32char Char;
virtual CEvent *clone() const {return new CEventChar(*this);} virtual CEvent *clone() const {return new CEventChar(*this);}
void setRaw( bool raw ) { _Raw = raw; } void setRaw( bool raw ) { _Raw = raw; }
@ -341,11 +341,11 @@ private:
class CEventString : public CEventKey class CEventString : public CEventKey
{ {
public: public:
CEventString (const ucstring &str, IEventEmitter* emitter) : CEventKey (noKeyButton, emitter, EventStringId) CEventString (const std::string &str, IEventEmitter* emitter) : CEventKey (noKeyButton, emitter, EventStringId)
{ {
String = str; String = str;
} }
ucstring String; std::string String;
virtual CEvent *clone() const {return new CEventString(*this);} virtual CEvent *clone() const {return new CEventString(*this);}
}; };

@ -99,7 +99,7 @@ public:
/// Return a vector with all language available. The vector contains the name of the language. /// Return a vector with all language available. The vector contains the name of the language.
/// The index in the vector is used in \c load() function /// The index in the vector is used in \c load() function
static const std::vector<ucstring> &getLanguageNames(); static const std::vector<std::string> &getLanguageNames();
/** Return a vector with all language code available. /** Return a vector with all language code available.
* Code are ISO 639-2 compliant. * Code are ISO 639-2 compliant.
@ -122,7 +122,7 @@ public:
static void loadFromFilename (const std::string &filename, bool reload); static void loadFromFilename (const std::string &filename, bool reload);
/// Returns the name of the language in the language name (English, Francais, ...) /// Returns the name of the language in the language name (English, Francais, ...)
static ucstring getCurrentLanguageName (); static std::string getCurrentLanguageName ();
/// Returns the code of the language ("fr", "en", ...) /// Returns the code of the language ("fr", "en", ...)
static std::string getCurrentLanguageCode (); static std::string getCurrentLanguageCode ();
@ -134,7 +134,10 @@ public:
static bool setSystemLanguageCode (const std::string &languageCode); static bool setSystemLanguageCode (const std::string &languageCode);
/// Find a string in the selected language and return his association. /// Find a string in the selected language and return his association.
static const ucstring &get (const std::string &label); static const ucstring &getAsUtf16 (const std::string &label);
/// Find a string in the selected language and return his association.
static const std::string &get (const std::string &label);
// Test if a string has a translation in the selected language. // Test if a string has a translation in the selected language.
// NB : The empty string is considered to have a translation // NB : The empty string is considered to have a translation
@ -219,24 +222,28 @@ public:
private: private:
typedef std::map<std::string, ucstring> StrMapContainer; typedef std::map<std::string, std::string> StrMapContainer;
typedef std::map<std::string, ucstring> StrMapContainer16;
static ILoadProxy *_LoadProxy; static ILoadProxy *_LoadProxy;
static StrMapContainer _StrMap; static StrMapContainer _StrMap;
static StrMapContainer16 _StrMap16;
static bool _StrMapLoaded; static bool _StrMapLoaded;
// the alternative language that will be used if the sentence is not found in the original language // the alternative language that will be used if the sentence is not found in the original language
static StrMapContainer _StrMapFallback; static StrMapContainer _StrMapFallback;
static StrMapContainer16 _StrMapFallback16;
static std::vector<std::string> _LanguageCodes; static std::vector<std::string> _LanguageCodes;
static std::vector<ucstring> _LanguageNames; static std::vector<std::string> _LanguageNames;
static std::string _SystemLanguageCode; static std::string _SystemLanguageCode;
static bool _LanguagesNamesLoaded; static bool _LanguagesNamesLoaded;
static std::string _SelectedLanguageCode; static std::string _SelectedLanguageCode;
static const ucstring _NotTranslatedValue; static const ucstring _NotTranslatedValue16;
static const std::string _NotTranslatedValue;
/** Structure to hold contextual info during /** Structure to hold contextual info during
* read of preprocessed file * read of preprocessed file
@ -256,7 +263,7 @@ private:
/// Init _LanguageCodes and _LanguageNames /// Init _LanguageCodes and _LanguageNames
static void initLanguages(); static void initLanguages();
static bool loadFileIntoMap(const std::string &filename, StrMapContainer &dest); static bool loadFileIntoMap(const std::string &filename, StrMapContainer &dest, StrMapContainer16 &dest16);
/// The internal read function, it does the real job of readTextFile /// The internal read function, it does the real job of readTextFile
static void _readTextFile(const std::string &filename, static void _readTextFile(const std::string &filename,

@ -260,12 +260,6 @@ 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

@ -54,11 +54,11 @@ public:
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 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
ucstring toUtf16(bool reEncode = false) const; // Makes a copy ucstring toUtf16(bool reEncode = false) const; // Makes a copy
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. std::string toAscii() const; // Returns only values 0-127, 7-bit ASCII. Makes a copy.

@ -44,9 +44,9 @@ int main (int argc, char **argv)
// load the language // load the language
CI18N::load(langName); CI18N::load(langName);
InfoLog->displayRawNL(CI18N::get("Hi").toString().c_str()); InfoLog->displayRawNL(CI18N::get("Hi").c_str());
InfoLog->displayRawNL(CI18N::get("PresentI18N").toString().c_str(), "Nevrax"); InfoLog->displayRawNL(CI18N::get("PresentI18N").c_str(), "Nevrax");
InfoLog->displayRawNL(CI18N::get("ExitStr").toString().c_str()); InfoLog->displayRawNL(CI18N::get("ExitStr").c_str());
getchar(); getchar();
return EXIT_SUCCESS; return EXIT_SUCCESS;

@ -1265,6 +1265,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
return 0; return 0;
} }
// https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-unichar
if (message == WM_UNICHAR)
return (wParam == UNICODE_NOCHAR);
return DefWindowProcW(hWnd, message, wParam, lParam); return DefWindowProcW(hWnd, message, wParam, lParam);
} }

@ -183,6 +183,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
return 0; return 0;
} }
// https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-unichar
if (message == WM_UNICHAR)
return (wParam == UNICODE_NOCHAR);
return trapMessage ? 0 : DefWindowProcW(hWnd, message, wParam, lParam); return trapMessage ? 0 : DefWindowProcW(hWnd, message, wParam, lParam);
} }

@ -29,6 +29,7 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/XKBlib.h> #include <X11/XKBlib.h>
#include "nel/misc/debug.h" #include "nel/misc/debug.h"
#include "nel/misc/utf_string_view.h"
#ifdef DEBUG_NEW #ifdef DEBUG_NEW
#define new DEBUG_NEW #define new DEBUG_NEW
@ -537,8 +538,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
if (c > 0) if (c > 0)
{ {
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
ucstring ucstr; ::u32string ucstr = NLMISC::CUtfStringView(Text).toUtf32();
ucstr.fromUtf8(Text);
CEventChar *charEvent = new CEventChar (ucstr[0], getKeyButton(event.xbutton.state), this); CEventChar *charEvent = new CEventChar (ucstr[0], getKeyButton(event.xbutton.state), this);
@ -549,7 +549,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
#else #else
for (int i = 0; i < c; i++) for (int i = 0; i < c; i++)
{ {
CEventChar *charEvent = new CEventChar ((ucchar)(unsigned char)Text[i], getKeyButton(event.xbutton.state), this); CEventChar *charEvent = new CEventChar ((u32char)(unsigned char)Text[i], getKeyButton(event.xbutton.state), this);
// raw if not processed by IME // raw if not processed by IME
charEvent->setRaw(keyCode != 0); charEvent->setRaw(keyCode != 0);

@ -77,7 +77,7 @@ uint32 CTextContext::textPush (const char *format, ...)
char *str; char *str;
NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize); NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize);
return textPush(str); return textPush(NLMISC::CUtfStringView(str));
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

@ -65,7 +65,7 @@ namespace NLGUI
_Rules.clear(); _Rules.clear();
_Style.clear(); _Style.clear();
_Style.fromUtf8(cssString); _Style = cssString;
preprocess(); preprocess();
_Position = 0; _Position = 0;
@ -73,7 +73,7 @@ namespace NLGUI
{ {
skipWhitespace(); skipWhitespace();
if (_Style[_Position] == (ucchar)'@') if (_Style[_Position] == '@')
readAtRule(); readAtRule();
else else
readRule(); readRule();
@ -89,13 +89,13 @@ namespace NLGUI
// style: "color: red; font-size: 10px;" // style: "color: red; font-size: 10px;"
// //
// @internal // @internal
void CCssParser::parseRule(const ucstring &selectorString, const ucstring &styleString) void CCssParser::parseRule(const std::string &selectorString, const std::string &styleString)
{ {
std::vector<ucstring> selectors; std::vector<std::string> selectors;
NLMISC::explode(selectorString, ucstring(","), selectors); NLMISC::explode(selectorString, std::string(","), selectors);
TStyleVec props; TStyleVec props;
props = parseDecls(styleString.toUtf8()); props = parseDecls(styleString);
// duplicate props to each selector in selector list, // duplicate props to each selector in selector list,
// example 'div > p, h1' creates 'div>p' and 'h1' // example 'div > p, h1' creates 'div>p' and 'h1'
@ -129,7 +129,7 @@ namespace NLGUI
skipIdentifier(); skipIdentifier();
// skip at-rule statement // skip at-rule statement
while(!is_eof() && _Style[_Position] != (ucchar)';') while(!is_eof() && _Style[_Position] != ';')
{ {
if (maybe_escape()) if (maybe_escape())
{ {
@ -174,9 +174,9 @@ namespace NLGUI
_Position++; _Position++;
else if (is_quote(_Style[_Position])) else if (is_quote(_Style[_Position]))
skipString(); skipString();
else if (_Style[_Position] == (ucchar)'[') else if (_Style[_Position] == '[')
skipBlock(); skipBlock();
else if (_Style[_Position] == (ucchar)'{') else if (_Style[_Position] == '{')
break; break;
else else
_Position++; _Position++;
@ -184,7 +184,7 @@ namespace NLGUI
if (!is_eof()) if (!is_eof())
{ {
ucstring selector; std::string selector;
selector.append(_Style, start, _Position - start); selector.append(_Style, start, _Position - start);
skipWhitespace(); skipWhitespace();
@ -194,7 +194,7 @@ namespace NLGUI
skipBlock(); skipBlock();
if (_Position <= _Style.size()) if (_Position <= _Style.size())
{ {
ucstring rules; std::string rules;
rules.append(_Style, start + 1, _Position - start - 2); rules.append(_Style, start + 1, _Position - start - 2);
parseRule(selector, rules); parseRule(selector, rules);
@ -215,7 +215,7 @@ namespace NLGUI
for(uint i=0; i<6 && is_hex(_Style[_Position]); i++) for(uint i=0; i<6 && is_hex(_Style[_Position]); i++)
_Position++; _Position++;
if (_Style[_Position] == (ucchar)' ') if (_Style[_Position] == ' ')
_Position++; _Position++;
} }
else if (_Style[_Position] != 0x0A) else if (_Style[_Position] != 0x0A)
@ -246,23 +246,23 @@ namespace NLGUI
// cannot start with digit // cannot start with digit
valid = false; valid = false;
} }
else if ((_Position - start) == 0 && _Style[_Position-1] == (ucchar)'-') else if ((_Position - start) == 0 && _Style[_Position-1] == '-')
{ {
// cannot start with -# // cannot start with -#
valid = false; valid = false;
} }
} }
else if (_Style[_Position] == (ucchar)'_') else if (_Style[_Position] == '_')
{ {
// valid // valid
} }
else if (_Style[_Position] >= 0x0080) else if (_Style[_Position] >= 0x80)
{ {
// valid // valid
} }
else if (_Style[_Position] == (ucchar)'-') else if (_Style[_Position] == '-')
{ {
if ((_Position - start) == 1 && _Style[_Position-1] == (ucchar)'-') if ((_Position - start) == 1 && _Style[_Position-1] == '-')
{ {
// cannot start with -- // cannot start with --
valid = false; valid = false;
@ -285,7 +285,7 @@ namespace NLGUI
// @internal // @internal
void CCssParser::skipBlock() void CCssParser::skipBlock()
{ {
ucchar startChar = _Style[_Position]; char startChar = _Style[_Position];
// block start // block start
_Position++; _Position++;
@ -311,7 +311,7 @@ namespace NLGUI
// @internal // @internal
void CCssParser::skipString() void CCssParser::skipString()
{ {
ucchar endChar = _Style[_Position]; char endChar = _Style[_Position];
// quote start // quote start
_Position++; _Position++;
@ -338,7 +338,7 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
// parse selector list // parse selector list
// @internal // @internal
std::vector<CCssSelector> CCssParser::parse_selector(const ucstring &sel, std::string &pseudoElement) const std::vector<CCssSelector> CCssParser::parse_selector(const std::string &sel, std::string &pseudoElement) const
{ {
std::vector<CCssSelector> result; std::vector<CCssSelector> result;
CCssSelector current; CCssSelector current;
@ -346,10 +346,10 @@ namespace NLGUI
pseudoElement.clear(); pseudoElement.clear();
bool failed = false; bool failed = false;
ucstring::size_type start = 0, pos = 0; std::string::size_type start = 0, pos = 0;
while(pos < sel.size()) while(pos < sel.size())
{ {
ucstring uc; std::string uc;
uc = sel[pos]; uc = sel[pos];
if (is_nmchar(sel[pos]) && current.empty()) if (is_nmchar(sel[pos]) && current.empty())
{ {
@ -358,7 +358,7 @@ namespace NLGUI
while(pos < sel.size() && is_nmchar(sel[pos])) while(pos < sel.size() && is_nmchar(sel[pos]))
pos++; pos++;
current.Element = toLower(sel.substr(start, pos - start).toUtf8()); current.Element = toLower(sel.substr(start, pos - start));
start = pos; start = pos;
continue; continue;
} }
@ -371,7 +371,7 @@ namespace NLGUI
while(pos < sel.size() && is_nmchar(sel[pos])) while(pos < sel.size() && is_nmchar(sel[pos]))
pos++; pos++;
current.Id = toLower(sel.substr(start, pos - start).toUtf8()); current.Id = toLower(sel.substr(start, pos - start));
start = pos; start = pos;
} }
else if (sel[pos] == '.') else if (sel[pos] == '.')
@ -383,7 +383,7 @@ namespace NLGUI
while(pos < sel.size() && (is_nmchar(sel[pos]) || sel[pos] == '.')) while(pos < sel.size() && (is_nmchar(sel[pos]) || sel[pos] == '.'))
pos++; pos++;
current.setClass(toLower(sel.substr(start, pos - start).toUtf8())); current.setClass(toLower(sel.substr(start, pos - start)));
start = pos; start = pos;
} }
else if (sel[pos] == '[') else if (sel[pos] == '[')
@ -399,9 +399,9 @@ namespace NLGUI
start = pos; start = pos;
} }
ucstring key; std::string key;
ucstring value; std::string value;
ucchar op = ' '; char op = ' ';
// key // key
while(pos < sel.size() && is_nmchar(sel[pos])) while(pos < sel.size() && is_nmchar(sel[pos]))
@ -420,7 +420,7 @@ namespace NLGUI
if (sel[pos] == ']') if (sel[pos] == ']')
{ {
current.addAttribute(key.toUtf8()); current.addAttribute(key);
} }
else else
{ {
@ -496,14 +496,14 @@ namespace NLGUI
// [value="attr" i] // [value="attr" i]
if (value.size() > 2 && value[value.size()-2] == ' ') if (value.size() > 2 && value[value.size()-2] == ' ')
{ {
ucchar lastChar = value[value.size()-1]; char lastChar = value[value.size()-1];
if (lastChar == 'i' || lastChar == 'I' || lastChar == 's' || lastChar == 'S') if (lastChar == 'i' || lastChar == 'I' || lastChar == 's' || lastChar == 'S')
{ {
value = value.substr(0, value.size()-2); value = value.substr(0, value.size()-2);
cs = !((lastChar == 'i' || lastChar == 'I')); cs = !((lastChar == 'i' || lastChar == 'I'));
} }
} }
current.addAttribute(key.toUtf8(), trimQuotes(value).toUtf8(), (char)op, cs); current.addAttribute(key, trimQuotes(value), (char)op, cs);
} // op error } // op error
} // no value } // no value
@ -549,7 +549,7 @@ namespace NLGUI
} }
} }
std::string key = toLower(sel.substr(start, pos - start).toUtf8()); std::string key = toLower(sel.substr(start, pos - start));
if (key.empty()) if (key.empty())
{ {
failed = true; failed = true;
@ -647,7 +647,7 @@ namespace NLGUI
size_t start; size_t start;
size_t charsLeft; size_t charsLeft;
bool quote = false; bool quote = false;
ucchar quoteChar; char quoteChar;
while(!is_eof()) while(!is_eof())
{ {
charsLeft = _Style.size() - _Position - 1; charsLeft = _Style.size() - _Position - 1;
@ -660,8 +660,8 @@ namespace NLGUI
if (charsLeft >= 1 && _Style[_Position] == 0x0D && _Style[_Position+1] == 0x0A) if (charsLeft >= 1 && _Style[_Position] == 0x0D && _Style[_Position+1] == 0x0A)
len++; len++;
ucstring tmp; std::string tmp;
tmp += 0x000A; tmp += 0x0A;
_Style.replace(_Position, 1, tmp); _Style.replace(_Position, 1, tmp);
} }
else if (_Style[_Position] == 0x00) else if (_Style[_Position] == 0x00)
@ -686,12 +686,12 @@ namespace NLGUI
} }
else if (!quote && is_comment_open()) else if (!quote && is_comment_open())
{ {
size_t pos = _Style.find(ucstring("*/"), _Position + 2); size_t pos = _Style.find("*/", _Position + 2);
if (pos == std::string::npos) if (pos == std::string::npos)
pos = _Style.size(); pos = _Style.size();
_Style.erase(_Position, pos - _Position + 2); _Style.erase(_Position, pos - _Position + 2);
ucstring uc; std::string uc;
uc = _Style[_Position]; uc = _Style[_Position];
// _Position is already at correct place // _Position is already at correct place

@ -129,7 +129,7 @@ namespace NLGUI
if (!editorMode) if (!editorMode)
_ContextHelp = CI18N::get((const char *)prop); _ContextHelp = CI18N::get((const char *)prop);
else else
_ContextHelp.fromUtf8((const char *)prop); _ContextHelp = (const char *)prop;
} }
else else
{ {
@ -140,7 +140,7 @@ namespace NLGUI
if (!editorMode && NLMISC::startsWith((const char *)prop, "ui")) if (!editorMode && NLMISC::startsWith((const char *)prop, "ui"))
_ContextHelp = CI18N::get((const char *)prop); _ContextHelp = CI18N::get((const char *)prop);
else else
_ContextHelp.fromUtf8((const char *)prop); _ContextHelp = (const char *)prop;
} }
} }
@ -197,12 +197,12 @@ namespace NLGUI
{ {
if( name == "tooltip" ) if( name == "tooltip" )
{ {
return _ContextHelp.toUtf8(); return _ContextHelp;
} }
else else
if( name == "tooltip_i18n" ) if( name == "tooltip_i18n" )
{ {
return _ContextHelp.toUtf8(); return _ContextHelp;
} }
else else
if( name == "on_tooltip" ) if( name == "on_tooltip" )
@ -261,7 +261,7 @@ namespace NLGUI
if (!editorMode && NLMISC::startsWith(value, "ui")) if (!editorMode && NLMISC::startsWith(value, "ui"))
_ContextHelp = CI18N::get(value); _ContextHelp = CI18N::get(value);
else else
_ContextHelp.fromUtf8(value); _ContextHelp = value;
return; return;
} }
else else
@ -270,7 +270,7 @@ namespace NLGUI
if (!editorMode) if (!editorMode)
_ContextHelp = CI18N::get(value); _ContextHelp = CI18N::get(value);
else else
_ContextHelp.fromUtf8(value); _ContextHelp = value;
return; return;
} }
else else
@ -382,8 +382,8 @@ namespace NLGUI
if( node == NULL ) if( node == NULL )
return NULL; return NULL;
xmlNewProp( node, BAD_CAST "tooltip", BAD_CAST _ContextHelp.toString().c_str() ); xmlNewProp( node, BAD_CAST "tooltip", BAD_CAST _ContextHelp.c_str() );
xmlNewProp( node, BAD_CAST "tooltip_i18n", BAD_CAST _ContextHelp.toString().c_str() ); xmlNewProp( node, BAD_CAST "tooltip_i18n", BAD_CAST _ContextHelp.c_str() );
xmlNewProp( node, BAD_CAST "on_tooltip", BAD_CAST _OnContextHelp.toString().c_str() ); xmlNewProp( node, BAD_CAST "on_tooltip", BAD_CAST _OnContextHelp.toString().c_str() );
xmlNewProp( node, BAD_CAST "on_tooltip_params", BAD_CAST _OnContextHelpParams.toString().c_str() ); xmlNewProp( node, BAD_CAST "on_tooltip_params", BAD_CAST _OnContextHelpParams.toString().c_str() );
xmlNewProp( node, BAD_CAST "tooltip_parent", BAD_CAST tooltipParentToString( _ToolTipParent ).c_str() ); xmlNewProp( node, BAD_CAST "tooltip_parent", BAD_CAST tooltipParentToString( _ToolTipParent ).c_str() );
@ -476,7 +476,7 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
bool CCtrlBase::emptyContextHelp() const bool CCtrlBase::emptyContextHelp() const
{ {
ucstring help; std::string help;
getContextHelp(help); getContextHelp(help);
std::string sTmp = _OnContextHelp; std::string sTmp = _OnContextHelp;
return help.empty() && sTmp.empty(); return help.empty() && sTmp.empty();
@ -494,12 +494,15 @@ namespace NLGUI
void CCtrlBase::serial(NLMISC::IStream &f) void CCtrlBase::serial(NLMISC::IStream &f)
{ {
CViewBase::serial(f); CViewBase::serial(f);
uint version = f.serialVersion(1);
nlassert(version);
f.serial(_ContextHelp); f.serial(_ContextHelp);
f.serial(_OnContextHelp); f.serial(_OnContextHelp);
f.serial(_OnContextHelpParams); f.serial(_OnContextHelpParams);
f.serial(_ToolTipSpecialParent); f.serial(_ToolTipSpecialParent);
f.serialEnum(_ToolTipParent); f.serialEnum(_ToolTipParent);
//
THotSpot tmpToolTipParentPosRef = _ToolTipParentPosRef; THotSpot tmpToolTipParentPosRef = _ToolTipParentPosRef;
THotSpot tmpToolTipPosRef = _ToolTipPosRef; THotSpot tmpToolTipPosRef = _ToolTipPosRef;
@ -515,7 +518,7 @@ namespace NLGUI
_ToolTipPosRef = tmpToolTipPosRef; _ToolTipPosRef = tmpToolTipPosRef;
_ToolTipParentPosRefAlt = tmpToolTipParentPosRefAlt; _ToolTipParentPosRefAlt = tmpToolTipParentPosRefAlt;
_ToolTipPosRefAlt = tmpToolTipPosRefAlt; _ToolTipPosRefAlt = tmpToolTipPosRefAlt;
//
nlSerialBitBool(f, _ToolTipInstant); nlSerialBitBool(f, _ToolTipInstant);
} }
@ -577,7 +580,7 @@ namespace NLGUI
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
std::string tooltip = ls.toString(1); std::string tooltip = ls.toString(1);
setDefaultContextHelp(ucstring::makeFromUtf8(tooltip)); setDefaultContextHelp(tooltip);
return 0; return 0;
} }

@ -598,7 +598,7 @@ namespace NLGUI
const char *propPtr = prop; const char *propPtr = prop;
std::string text; std::string text;
if (NLMISC::startsWith(propPtr, "ui")) if (NLMISC::startsWith(propPtr, "ui"))
text = CI18N::get(propPtr).toUtf8(); text = CI18N::get(propPtr);
else else
text = propPtr; text = propPtr;
_ViewText->setText(text); _ViewText->setText(text);
@ -1041,14 +1041,29 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CCtrlTextButton::setText (const ucstring &text) void CCtrlTextButton::setText (const std::string &text)
{
if (_ViewText && !_IsViewTextId)
_ViewText->setText(text);
}
// ***************************************************************************
std::string CCtrlTextButton::getText () const
{
if (_ViewText && !_IsViewTextId)
return _ViewText->getText();
return std::string();
}
// ***************************************************************************
void CCtrlTextButton::setTextAsUtf16 (const ucstring &text)
{ {
if (_ViewText && !_IsViewTextId) if (_ViewText && !_IsViewTextId)
_ViewText->setText(text.toUtf8()); _ViewText->setText(text.toUtf8());
} }
// *************************************************************************** // ***************************************************************************
ucstring CCtrlTextButton::getText () const ucstring CCtrlTextButton::getTextAsUtf16 () const
{ {
if (_ViewText && !_IsViewTextId) if (_ViewText && !_IsViewTextId)
return CUtfStringView(_ViewText->getText()).toUtf16(); return CUtfStringView(_ViewText->getText()).toUtf16();

@ -45,7 +45,7 @@ namespace NLGUI
// Compare strings // Compare strings
static inline bool lt_text(const std::pair<int,std::string> &s1, const std::pair<int,std::string> &s2) static inline bool lt_text(const std::pair<int,std::string> &s1, const std::pair<int,std::string> &s2)
{ {
return toLowerAsUtf8(s1.second) < toLowerAsUtf8(s2.second); return toLower(s1.second) < toLower(s2.second);
} }
std::string CDBGroupComboBox::measureMenu; std::string CDBGroupComboBox::measureMenu;
@ -184,7 +184,7 @@ namespace NLGUI
{ {
const char *propPtr = name; const char *propPtr = name;
if (NLMISC::startsWith(propPtr, "ui")) if (NLMISC::startsWith(propPtr, "ui"))
addText(CI18N::get(propPtr).toUtf8()); addText(CI18N::get(propPtr));
else else
addText(propPtr); addText(propPtr);
} }
@ -668,7 +668,7 @@ namespace NLGUI
{ {
checkable = true; checkable = true;
} }
groupMenu->addLine(ucstring::makeFromUtf8(getText(i)), "combo_box_select_end", toString(i), groupMenu->addLine(getText(i), "combo_box_select_end", toString(i),
"", std::string(), getTexture(i), checkable); "", std::string(), getTexture(i), checkable);
groupMenu->setGrayedLine(i, getGrayed(i)); groupMenu->setGrayedLine(i, getGrayed(i));
} }

@ -148,7 +148,7 @@ namespace NLGUI
{ {
const char *propPtr = ptr; const char *propPtr = ptr;
if (NLMISC::startsWith(propPtr, "ui")) if (NLMISC::startsWith(propPtr, "ui"))
_EmptyText = CI18N::get(propPtr).toUtf8(); _EmptyText = CI18N::get(propPtr);
else else
_EmptyText = propPtr; _EmptyText = propPtr;
} }

@ -1338,19 +1338,19 @@ namespace NLGUI
if( name == "title" ) if( name == "title" )
{ {
if( _TitleTextOpened == _TitleTextClosed ) if( _TitleTextOpened == _TitleTextClosed )
return _TitleTextOpened.toString(); return _TitleTextOpened;
else else
return ""; return "";
} }
else else
if( name == "title_opened" ) if( name == "title_opened" )
{ {
return _TitleTextOpened.toString(); return _TitleTextOpened;
} }
else else
if( name == "title_closed" ) if( name == "title_closed" )
{ {
return _TitleTextClosed.toString(); return _TitleTextClosed;
} }
else else
if( name == "header_active" ) if( name == "header_active" )
@ -1997,12 +1997,12 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "content_y_offset", BAD_CAST toString( _ContentYOffset ).c_str() ); xmlSetProp( node, BAD_CAST "content_y_offset", BAD_CAST toString( _ContentYOffset ).c_str() );
if( _TitleTextOpened == _TitleTextClosed ) if( _TitleTextOpened == _TitleTextClosed )
xmlSetProp( node, BAD_CAST "title", BAD_CAST _TitleTextOpened.toString().c_str() ); xmlSetProp( node, BAD_CAST "title", BAD_CAST _TitleTextOpened.c_str() );
else else
xmlSetProp( node, BAD_CAST "title", BAD_CAST "" ); xmlSetProp( node, BAD_CAST "title", BAD_CAST "" );
xmlSetProp( node, BAD_CAST "title_opened", BAD_CAST _TitleTextOpened.toString().c_str() ); xmlSetProp( node, BAD_CAST "title_opened", BAD_CAST _TitleTextOpened.c_str() );
xmlSetProp( node, BAD_CAST "title_closed", BAD_CAST _TitleTextClosed.toString().c_str() ); xmlSetProp( node, BAD_CAST "title_closed", BAD_CAST _TitleTextClosed.c_str() );
xmlSetProp( node, BAD_CAST "header_active", BAD_CAST toString( _HeaderActive ).c_str() ); xmlSetProp( node, BAD_CAST "header_active", BAD_CAST toString( _HeaderActive ).c_str() );
if( _HeaderColor.getNodePtr() != NULL ) if( _HeaderColor.getNodePtr() != NULL )
@ -3712,7 +3712,7 @@ namespace NLGUI
{ {
CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam()); CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam());
// the title here is actually the DB path // the title here is actually the DB path
vti->setDBTextID(_TitleTextOpened.toString()); vti->setDBTextID(_TitleTextOpened);
vti->setDynamicString(_TitleClass==TitleTextDynString); vti->setDynamicString(_TitleClass==TitleTextDynString);
_TitleOpened = vti; _TitleOpened = vti;
} }
@ -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.toUtf8()); if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened);
_TitleOpened->setActive (_Opened); _TitleOpened->setActive (_Opened);
// Title when the container is closed // Title when the container is closed
@ -3764,7 +3764,7 @@ namespace NLGUI
{ {
CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam()); CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam());
// the title here is actually the DB path // the title here is actually the DB path
vti->setDBTextID(_TitleTextClosed.toString()); vti->setDBTextID(_TitleTextClosed);
vti->setDynamicString(_TitleClass==TitleTextDynString); vti->setDynamicString(_TitleClass==TitleTextDynString);
_TitleClosed = vti; _TitleClosed = vti;
} }
@ -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.toUtf8()); if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed);
_TitleClosed->setActive(!_Opened); _TitleClosed->setActive(!_Opened);
@ -3949,83 +3949,119 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
std::string CGroupContainer::getTitle () const std::string CGroupContainer::getTitle () const
{ {
return _TitleTextOpened.toString(); return _TitleTextOpened;
} }
// *************************************************************************** // ***************************************************************************
void CGroupContainer::setTitle (const std::string &title) void CGroupContainer::setTitle (const std::string &title)
{ {
if (_Localize) setUCTitle (CI18N::get(title)); if (_Localize) setTitleRaw (CI18N::get(title));
else setUCTitle (title); else setTitleRaw (title);
} }
// *************************************************************************** // ***************************************************************************
std::string CGroupContainer::getTitleOpened () const std::string CGroupContainer::getTitleOpened () const
{ {
return _TitleTextOpened.toString(); return _TitleTextOpened;
} }
// *************************************************************************** // ***************************************************************************
void CGroupContainer::setTitleOpened (const std::string &title) void CGroupContainer::setTitleOpened (const std::string &title)
{ {
if (_Localize) setUCTitleOpened (CI18N::get(title)); if (_Localize) setTitleOpenedRaw (CI18N::get(title));
else setUCTitleOpened (title); else setTitleOpenedRaw (title);
} }
// *************************************************************************** // ***************************************************************************
std::string CGroupContainer::getTitleClosed () const std::string CGroupContainer::getTitleClosed () const
{ {
return _TitleTextClosed.toString(); return _TitleTextClosed;
} }
// *************************************************************************** // ***************************************************************************
void CGroupContainer::setTitleClosed (const std::string &title) void CGroupContainer::setTitleClosed (const std::string &title)
{ {
if (_Localize) setUCTitleClosed (CI18N::get(title)); if (_Localize) setTitleClosedRaw (CI18N::get(title));
else setUCTitleClosed (title); else setTitleClosedRaw (title);
} }
// *************************************************************************** // ***************************************************************************
void CGroupContainer::setUCTitleOpened(const ucstring &title) void CGroupContainer::setTitleOpenedRaw(const std::string &title)
{ {
_TitleTextOpened = title; _TitleTextOpened = title;
if (_TitleOpened != NULL) if (_TitleOpened != NULL)
_TitleOpened->setText (title.toUtf8()); _TitleOpened->setText (title);
invalidateCoords(); invalidateCoords();
} }
// *************************************************************************** // ***************************************************************************
void CGroupContainer::setUCTitleClosed(const ucstring &title) void CGroupContainer::setTitleClosedRaw(const std::string &title)
{ {
_TitleTextClosed = title; _TitleTextClosed = title;
if (_TitleClosed != NULL) if (_TitleClosed != NULL)
_TitleClosed->setText (_TitleTextClosed.toUtf8()); _TitleClosed->setText (_TitleTextClosed);
invalidateCoords(); invalidateCoords();
} }
// ***************************************************************************
void CGroupContainer::setTitleRaw(const std::string &title)
{
setTitleOpenedRaw(title);
setTitleClosedRaw(title);
}
// ***************************************************************************
std::string CGroupContainer::getTitleRaw () const
{
return getTitleOpened();
}
// ***************************************************************************
std::string CGroupContainer::getTitleOpenedRaw () const
{
return _TitleTextOpened;
}
// ***************************************************************************
std::string CGroupContainer::getTitleClosedRaw () const
{
return _TitleTextClosed;
}
// ***************************************************************************
void CGroupContainer::setUCTitleOpened(const ucstring &title)
{
setTitleOpenedRaw(title.toUtf8());
}
// ***************************************************************************
void CGroupContainer::setUCTitleClosed(const ucstring &title)
{
setTitleClosedRaw(title.toUtf8());
}
// *************************************************************************** // ***************************************************************************
void CGroupContainer::setUCTitle(const ucstring &title) void CGroupContainer::setUCTitle(const ucstring &title)
{ {
setUCTitleOpened(title); setTitleRaw(title.toUtf8());
setUCTitleClosed(title);
} }
// *************************************************************************** // ***************************************************************************
ucstring CGroupContainer::getUCTitle () const ucstring CGroupContainer::getUCTitle () const
{ {
return getUCTitleOpened(); return ucstring::makeFromUtf8(getTitleRaw());
} }
// *************************************************************************** // ***************************************************************************
ucstring CGroupContainer::getUCTitleOpened () const ucstring CGroupContainer::getUCTitleOpened () const
{ {
return _TitleTextOpened; return ucstring::makeFromUtf8(getTitleOpenedRaw());
} }
// *************************************************************************** // ***************************************************************************
ucstring CGroupContainer::getUCTitleClosed () const ucstring CGroupContainer::getUCTitleClosed () const
{ {
return _TitleTextClosed; return ucstring::makeFromUtf8(getTitleClosedRaw());
} }
// *************************************************************************** // ***************************************************************************

@ -96,7 +96,7 @@ namespace NLGUI
_ViewTextDeltaX(0) _ViewTextDeltaX(0)
{ {
_Prompt = u32string(1, (u32char)'>'); _Prompt = ::u32string(1, (u32char)'>');
_BackSelectColor= CRGBA::White; _BackSelectColor= CRGBA::White;
_TextSelectColor= CRGBA::Black; _TextSelectColor= CRGBA::Black;
} }
@ -264,9 +264,9 @@ namespace NLGUI
std::string s; std::string s;
s.reserve( _NegativeFilter.size() ); s.reserve( _NegativeFilter.size() );
std::vector< char >::const_iterator itr; std::vector< u32char >::const_iterator itr;
for( itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr ) for (itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr)
s.push_back( *itr ); CUtfStringView::append(s, *itr);
return s; return s;
} }
@ -450,10 +450,10 @@ namespace NLGUI
if( name == "negative_filter" ) if( name == "negative_filter" )
{ {
_NegativeFilter.clear(); _NegativeFilter.clear();
::u32string::size_type i;
std::string::size_type i; ::u32string ustr = CUtfStringView(value).toUtf32();
for( i = 0; i < value.size(); i++ ) for( i = 0; i < ustr.size(); i++ )
_NegativeFilter.push_back( value[ i ] ); _NegativeFilter.push_back(ustr[i]);
} }
else else
CInterfaceGroup::setProperty( name, value ); CInterfaceGroup::setProperty( name, value );
@ -539,9 +539,9 @@ namespace NLGUI
std::string s; std::string s;
s.reserve( _NegativeFilter.size() ); s.reserve( _NegativeFilter.size() );
std::vector< char >::const_iterator itr; std::vector< u32char >::const_iterator itr;
for( itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr ) for( itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr )
s.push_back( *itr ); CUtfStringView::append(s, *itr);
xmlSetProp( node, BAD_CAST "negative_filter", BAD_CAST s.c_str() ); xmlSetProp( node, BAD_CAST "negative_filter", BAD_CAST s.c_str() );
@ -657,9 +657,11 @@ namespace NLGUI
prop = (char*) xmlGetProp( cur, (xmlChar*)"negative_filter" ); prop = (char*) xmlGetProp( cur, (xmlChar*)"negative_filter" );
if (prop) if (prop)
{ {
uint length = (uint)strlen(prop); _NegativeFilter.clear();
_NegativeFilter.resize(length); ::u32string::size_type i;
std::copy((const char *) prop, (const char *) prop + length, _NegativeFilter.begin()); ::u32string ustr = CUtfStringView(prop).toUtf32();
for( i = 0; i < ustr.size(); i++ )
_NegativeFilter.push_back(ustr[i]);
} }
return true; return true;
@ -829,10 +831,10 @@ namespace NLGUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupEditBox::writeString(const ucstring &str16, bool replace, bool atEnd) void CGroupEditBox::writeString(const ucstring &str16, bool replace, bool atEnd)
{ {
u32string str = CUtfStringView(str16).toUtf32(); ::u32string str = CUtfStringView(str16).toUtf32();
sint length = (sint)str.length(); sint length = (sint)str.length();
u32string toAppend; ::u32string toAppend;
// filter character depending on the entry type // filter character depending on the entry type
switch (_EntryType) switch (_EntryType)
{ {
@ -854,7 +856,7 @@ namespace NLGUI
} }
} }
// remove '\r' characters // remove '\r' characters
toAppend.erase(std::remove(toAppend.begin(), toAppend.end(), (ucchar) '\r'), toAppend.end()); toAppend.erase(std::remove(toAppend.begin(), toAppend.end(), (u32char) '\r'), toAppend.end());
} }
break; break;
@ -965,7 +967,7 @@ namespace NLGUI
{ {
length = _MaxNumChar - (sint)_InputString.length(); length = _MaxNumChar - (sint)_InputString.length();
} }
u32string toAdd = toAppend.substr(0, length); ::u32string toAdd = toAppend.substr(0, length);
sint32 minPos; sint32 minPos;
sint32 maxPos; sint32 maxPos;
if (_CurrSelection == this) if (_CurrSelection == this)
@ -1015,7 +1017,7 @@ namespace NLGUI
_CursorAtPreviousLineEnd = false; _CursorAtPreviousLineEnd = false;
if (_ClearOnEscape) if (_ClearOnEscape)
{ {
setInputStringAsUtf32(u32string()); setInputStringAsUtf32(::u32string());
triggerOnChangeAH(); triggerOnChangeAH();
} }
CWidgetManager::getInstance()->setCaptureKeyboard(NULL); CWidgetManager::getInstance()->setCaptureKeyboard(NULL);
@ -1077,7 +1079,7 @@ namespace NLGUI
cutSelection(); cutSelection();
} }
ucchar c = isKeyRETURN ? '\n' : rEDK.getChar(); u32char c = isKeyRETURN ? '\n' : rEDK.getChar();
if (isFiltered(c)) return; if (isFiltered(c)) return;
switch(_EntryType) switch(_EntryType)
{ {
@ -1124,8 +1126,8 @@ namespace NLGUI
if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX)) if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX))
{ {
// estimate new string // estimate new string
u32string copyStr= _InputString; ::u32string copyStr= _InputString;
u32string::iterator it = copyStr.begin() + _CursorPos; ::u32string::iterator it = copyStr.begin() + _CursorPos;
copyStr.insert(it, c); copyStr.insert(it, c);
sint32 value; sint32 value;
fromString(CUtfStringView(copyStr).toUtf8(), value); fromString(CUtfStringView(copyStr).toUtf8(), value);
@ -1137,8 +1139,8 @@ namespace NLGUI
if(_EntryType==PositiveInteger && (_PositiveIntegerMinValue!=0 || _PositiveIntegerMaxValue!=UINT_MAX)) if(_EntryType==PositiveInteger && (_PositiveIntegerMinValue!=0 || _PositiveIntegerMaxValue!=UINT_MAX))
{ {
// estimate new string // estimate new string
u32string copyStr= _InputString; ::u32string copyStr= _InputString;
u32string::iterator it = copyStr.begin() + _CursorPos; ::u32string::iterator it = copyStr.begin() + _CursorPos;
copyStr.insert(it, c); copyStr.insert(it, c);
// \todo yoyo: this doesn't really work i think.... // \todo yoyo: this doesn't really work i think....
uint32 value; uint32 value;
@ -1151,7 +1153,7 @@ namespace NLGUI
if ((uint) _InputString.length() < _MaxNumChar) if ((uint) _InputString.length() < _MaxNumChar)
{ {
makeTopWindow(); makeTopWindow();
u32string::iterator it = _InputString.begin() + _CursorPos; ::u32string::iterator it = _InputString.begin() + _CursorPos;
_InputString.insert(it, c); _InputString.insert(it, c);
++ _CursorPos; ++ _CursorPos;
triggerOnChangeAH(); triggerOnChangeAH();
@ -1263,7 +1265,7 @@ namespace NLGUI
// else delete last character // else delete last character
else if(_InputString.size () > 0 && _CursorPos != 0) else if(_InputString.size () > 0 && _CursorPos != 0)
{ {
u32string::iterator it = _InputString.begin() + (_CursorPos - 1); ::u32string::iterator it = _InputString.begin() + (_CursorPos - 1);
_InputString.erase(it); _InputString.erase(it);
-- _CursorPos; -- _CursorPos;
_CursorAtPreviousLineEnd = false; _CursorAtPreviousLineEnd = false;
@ -1436,7 +1438,7 @@ namespace NLGUI
std::string usTmp; std::string usTmp;
if (_EntryType == Password) if (_EntryType == Password)
{ {
usTmp = CUtfStringView(_Prompt + u32string(_InputString.size(), 0x2022)).toUtf8(); usTmp = CUtfStringView(_Prompt + ::u32string(_InputString.size(), 0x2022)).toUtf8();
} }
else else
{ {
@ -1634,7 +1636,7 @@ namespace NLGUI
{ {
setInputStringAsUtf32(CUtfStringView(str).toUtf32()); setInputStringAsUtf32(CUtfStringView(str).toUtf32());
} }
void CGroupEditBox::setInputStringAsUtf32(const u32string &str) void CGroupEditBox::setInputStringAsUtf32(const ::u32string &str)
{ {
_InputString = str; _InputString = str;
if (_CursorPos > (sint32) str.length()) if (_CursorPos > (sint32) str.length())
@ -1650,10 +1652,10 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupEditBox::setDefaultInputString(const ucstring &str) void CGroupEditBox::setDefaultInputString(const std::string &str)
{ {
_DefaultInputString= true; _DefaultInputString= true;
setInputStringAsUtf32(CUtfStringView(str).toUtf32()); setInputString(str);
} }
// *************************************************************************** // ***************************************************************************
@ -1771,14 +1773,14 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
void CGroupEditBox::setCommand(const ucstring &command, bool execute) void CGroupEditBox::setCommand(const std::string &command, bool execute)
{ {
// do nothing if frozen // do nothing if frozen
if(_Frozen) if(_Frozen)
return; return;
// set the string and maybe execute // set the string and maybe execute
setInputStringAsUtf16((ucchar) '/' + command); setInputString('/' + command);
if (execute) if (execute)
{ {
// stop selection // stop selection
@ -1878,7 +1880,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
setInputStringAsUtf32(u32string()); setInputStringAsUtf32(::u32string());
_CurrSelection = NULL; _CurrSelection = NULL;
} }
@ -1886,7 +1888,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.
setInputStringAsUtf32(u32string()); setInputStringAsUtf32(::u32string());
_CurrSelection = NULL; _CurrSelection = NULL;
_PrevNumLine = 1; _PrevNumLine = 1;
} }
@ -1901,7 +1903,7 @@ namespace NLGUI
if (_DefaultInputString) if (_DefaultInputString)
{ {
_DefaultInputString= false; _DefaultInputString= false;
setInputStringAsUtf32(u32string()); setInputStringAsUtf32(::u32string());
} }
_CanRedo = false; _CanRedo = false;
_CanUndo = false; _CanUndo = false;

@ -1034,7 +1034,7 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupHTML::addText (const char * buf, int len) void CGroupHTML::addText (const char *buf, int len)
{ {
if (_Browsing) if (_Browsing)
{ {
@ -1042,44 +1042,43 @@ namespace NLGUI
return; return;
// Build a UTF8 string // Build a UTF8 string
string inputString(buf, buf+len);
if (_ParsingLua && _TrustedDomain) if (_ParsingLua && _TrustedDomain)
{ {
// we are parsing a lua script // we are parsing a lua script
_LuaScript += inputString; _LuaScript += string(buf, buf + len);
// no more to do // no more to do
return; return;
} }
// Build a unicode string // Build a unicode string
ucstring inputUCString; CUtfStringView inputStringView(buf, len);
inputUCString.fromUtf8(inputString);
// Build the final unicode string // Build the final unicode string
ucstring tmp; string tmp;
tmp.reserve(len); tmp.reserve(len);
uint ucLen = (uint)inputUCString.size(); u32char lastChar = 0;
for (uint i=0; i<ucLen; i++) u32char inputStringView0 = *inputStringView.begin();
for (CUtfStringView::iterator it(inputStringView.begin()), end(inputStringView.end()); it != end; ++it)
{ {
ucchar output; u32char output;
bool keep; bool keep;
// special treatment for 'nbsp' (which is returned as a discreet space) // special treatment for 'nbsp' (which is returned as a discreet space)
if (inputString.size() == 1 && inputString[0] == 32) if (len == 1 && inputStringView0 == 32)
{ {
// this is a nbsp entity // this is a nbsp entity
output = inputUCString[i]; output = *it;
keep = true; keep = true;
} }
else else
{ {
// not nbsp, use normal white space removal routine // not nbsp, use normal white space removal routine
keep = translateChar (output, inputUCString[i], (tmp.empty())?0:tmp[tmp.size()-1]); keep = translateChar (output, *it, lastChar);
} }
if (keep) if (keep)
{ {
tmp.push_back(output); CUtfStringView::append(tmp, output);
lastChar = output;
} }
} }
@ -1293,7 +1292,7 @@ namespace NLGUI
pos++; pos++;
} }
token = content.substr(start, pos - start); token = content.substr(start, pos - start);
addString(ucstring::makeFromUtf8(token)); addString(token);
// skip closing quote // skip closing quote
pos++; pos++;
@ -1376,7 +1375,7 @@ namespace NLGUI
if (elm.hasAttribute(token)) if (elm.hasAttribute(token))
{ {
addString(ucstring::makeFromUtf8(elm.getAttribute(token))); addString(elm.getAttribute(token));
} }
} }
else else
@ -1562,7 +1561,7 @@ namespace NLGUI
else else
if( name == "title_prefix" ) if( name == "title_prefix" )
{ {
return _TitlePrefix.toString(); return _TitlePrefix;
} }
else else
if( name == "background_color" ) if( name == "background_color" )
@ -2224,7 +2223,7 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "type", BAD_CAST "html" ); xmlSetProp( node, BAD_CAST "type", BAD_CAST "html" );
xmlSetProp( node, BAD_CAST "url", BAD_CAST _URL.c_str() ); xmlSetProp( node, BAD_CAST "url", BAD_CAST _URL.c_str() );
xmlSetProp( node, BAD_CAST "title_prefix", BAD_CAST _TitlePrefix.toString().c_str() ); xmlSetProp( node, BAD_CAST "title_prefix", BAD_CAST _TitlePrefix.c_str() );
xmlSetProp( node, BAD_CAST "background_color", BAD_CAST toString( BgColor ).c_str() ); xmlSetProp( node, BAD_CAST "background_color", BAD_CAST toString( BgColor ).c_str() );
xmlSetProp( node, BAD_CAST "error_color", BAD_CAST toString( ErrorColor ).c_str() ); xmlSetProp( node, BAD_CAST "error_color", BAD_CAST toString( ErrorColor ).c_str() );
xmlSetProp( node, BAD_CAST "link_color", BAD_CAST toString( LinkColor ).c_str() ); xmlSetProp( node, BAD_CAST "link_color", BAD_CAST toString( LinkColor ).c_str() );
@ -2669,7 +2668,7 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
bool CGroupHTML::translateChar(ucchar &output, ucchar input, ucchar lastCharParam) const bool CGroupHTML::translateChar(u32char &output, u32char input, u32char lastCharParam) const
{ {
// Keep this char ? // Keep this char ?
bool keep = true; bool keep = true;
@ -2691,13 +2690,13 @@ namespace NLGUI
else else
{ {
// Get the last char // Get the last char
ucchar lastChar = lastCharParam; u32char lastChar = lastCharParam;
if (lastChar == 0) if (lastChar == 0)
lastChar = getLastChar(); lastChar = getLastChar();
keep = ((lastChar != (ucchar)' ') && keep = ((lastChar != (u32char)' ') &&
(lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0));
if(!getPRE()) if(!getPRE())
input = ' '; input = (u32char)' ';
} }
} }
break; break;
@ -2710,11 +2709,11 @@ namespace NLGUI
else else
{ {
// Get the last char // Get the last char
ucchar lastChar = lastCharParam; u32char lastChar = lastCharParam;
if (lastChar == 0) if (lastChar == 0)
lastChar = getLastChar(); lastChar = getLastChar();
keep = ((lastChar != (ucchar)' ') && keep = ((lastChar != (u32char)' ') &&
(lastChar != (ucchar)'\n') && (lastChar != (u32char)'\n') &&
(lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0));
} }
} }
@ -2753,13 +2752,13 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupHTML::addString(const ucstring &str) void CGroupHTML::addString(const std::string &str)
{ {
ucstring tmpStr = str; string tmpStr = str;
if (_Localize) if (_Localize)
{ {
string _str = tmpStr.toString(); string _str = tmpStr;
string::size_type p = _str.find('#'); string::size_type p = _str.find('#');
if (p == string::npos) if (p == string::npos)
{ {
@ -2800,7 +2799,7 @@ namespace NLGUI
} }
else if (_Object) else if (_Object)
{ {
_ObjectScript += tmpStr.toString(); _ObjectScript += tmpStr;
} }
else if (_SelectOption) else if (_SelectOption)
{ {
@ -2853,7 +2852,7 @@ namespace NLGUI
(style.GlobalColor == _CurrentViewLink->getModulateGlobalColor())) (style.GlobalColor == _CurrentViewLink->getModulateGlobalColor()))
{ {
// Concat the text // Concat the text
_CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr.toUtf8()); _CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr);
_CurrentViewLink->invalidateContent(); _CurrentViewLink->invalidateContent();
added = true; added = true;
} }
@ -2888,7 +2887,7 @@ namespace NLGUI
ctrlButton->setModulateGlobalColorAll (false); ctrlButton->setModulateGlobalColorAll (false);
// Translate the tooltip // Translate the tooltip
ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(getLinkTitle())); ctrlButton->setDefaultContextHelp(getLinkTitle());
ctrlButton->setText(tmpStr); ctrlButton->setText(tmpStr);
// empty url / button disabled // empty url / button disabled
bool disabled = string(getLink()).empty(); bool disabled = string(getLink()).empty();
@ -2916,7 +2915,7 @@ namespace NLGUI
newLink->setParamsOnLeftClick("name=" + getId() + "|url=" + newLink->Link); newLink->setParamsOnLeftClick("name=" + getId() + "|url=" + newLink->Link);
} }
} }
newLink->setText(tmpStr.toUtf8()); newLink->setText(tmpStr);
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);
@ -2968,7 +2967,7 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength) CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const std::string &content, uint maxlength)
{ {
// In a paragraph ? // In a paragraph ?
if (!_Paragraph) if (!_Paragraph)
@ -3024,7 +3023,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)).toUtf8()); eb->setInputString(decodeHTMLEntities(content));
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"));
@ -3234,7 +3233,7 @@ namespace NLGUI
} }
else else
{ {
ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(tooltip)); ctrlButton->setDefaultContextHelp(tooltip);
//ctrlButton->setOnContextHelp(string(tooltip)); //ctrlButton->setOnContextHelp(string(tooltip));
} }
@ -3310,7 +3309,7 @@ namespace NLGUI
{ {
if (_CurrentViewLink) if (_CurrentViewLink)
{ {
u32string str = CUtfStringView(_CurrentViewLink->getText()).toUtf32(); // FIXME: Optimize reverse UTF iteration ::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];
} }
@ -3402,7 +3401,7 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupHTML::setTitle (const ucstring &title) void CGroupHTML::setTitleRaw (const std::string &title)
{ {
CInterfaceElement *parent = getParent(); CInterfaceElement *parent = getParent();
if (parent) if (parent)
@ -3412,7 +3411,7 @@ namespace NLGUI
CGroupContainer *container = dynamic_cast<CGroupContainer*>(parent); CGroupContainer *container = dynamic_cast<CGroupContainer*>(parent);
if (container) if (container)
{ {
container->setUCTitle (title); container->setTitleRaw (title);
} }
} }
} }
@ -3420,21 +3419,18 @@ namespace NLGUI
void CGroupHTML::setTitle(const std::string &title) void CGroupHTML::setTitle(const std::string &title)
{ {
ucstring uctitle;
uctitle.fromUtf8(title);
_TitleString.clear(); _TitleString.clear();
if(!_TitlePrefix.empty()) if(!_TitlePrefix.empty())
{ {
_TitleString = _TitlePrefix + " - "; _TitleString = _TitlePrefix + " - ";
} }
_TitleString += uctitle; _TitleString += title;
setTitle(_TitleString); setTitleRaw(_TitleString);
} }
std::string CGroupHTML::getTitle() const { std::string CGroupHTML::getTitle() const {
return _TitleString.toUtf8(); return _TitleString;
}; };
// *************************************************************************** // ***************************************************************************
@ -4685,9 +4681,7 @@ namespace NLGUI
CLuaIHM::checkArgType(ls, funcName, 3, LUA_TBOOLEAN); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TBOOLEAN);
string name = ls.toString(1); string name = ls.toString(1);
string text = ls.toString(2);
ucstring text;
text.fromUtf8(ls.toString(2));
if (!_Forms.empty()) if (!_Forms.empty())
{ {
@ -4717,7 +4711,7 @@ namespace NLGUI
const char *funcName = "addString"; const char *funcName = "addString";
CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
addString(ucstring::makeFromUtf8(ls.toString(1))); addString(ls.toString(1));
return 0; return 0;
} }
@ -4945,7 +4939,7 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
inline bool isDigit(ucchar c, uint base = 16) inline bool isDigit(char c, uint base = 16)
{ {
if (c>='0' && c<='9') return true; if (c>='0' && c<='9') return true;
if (base != 16) return false; if (base != 16) return false;
@ -4955,7 +4949,7 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
inline ucchar convertHexDigit(ucchar c) inline char convertHexDigit(char c)
{ {
if (c>='0' && c<='9') return c-'0'; if (c>='0' && c<='9') return c-'0';
if (c>='A' && c<='F') return c-'A'+10; if (c>='A' && c<='F') return c-'A'+10;
@ -4964,9 +4958,10 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
ucstring CGroupHTML::decodeHTMLEntities(const ucstring &str) std::string CGroupHTML::decodeHTMLEntities(const std::string &str)
{ {
ucstring result; std::string result;
result.reserve(str.size() + (str.size() >> 2));
uint last, pos; uint last, pos;
for (uint i=0; i<str.length(); ++i) for (uint i=0; i<str.length(); ++i)
@ -5002,13 +4997,13 @@ namespace NLGUI
continue; continue;
} }
ucchar c = 0; u32char c = 0;
// convert digits to unicode character // convert digits to unicode character
while (pos<last) c = convertHexDigit(str[pos++]) + c*ucchar(base); while (pos < last) c = convertHexDigit(str[pos++]) + (c * u32char(base));
// append our new character to the result string // append our new character to the result string
result += c; CUtfStringView::append(result, c);
// move 'i' forward to point at the ';' .. the for(...) will increment i to point to next char // move 'i' forward to point at the ';' .. the for(...) will increment i to point to next char
i = last; i = last;
@ -5017,10 +5012,10 @@ namespace NLGUI
} }
// special xml characters // special xml characters
if (str.substr(i+1,5)==ucstring("quot;")) { i+=5; result+='\"'; continue; } if (str.substr(i+1,5)=="quot;") { i+=5; result+='\"'; continue; }
if (str.substr(i+1,4)==ucstring("amp;")) { i+=4; result+='&'; continue; } if (str.substr(i+1,4)=="amp;") { i+=4; result+='&'; continue; }
if (str.substr(i+1,3)==ucstring("lt;")) { i+=3; result+='<'; continue; } if (str.substr(i+1,3)=="lt;") { i+=3; result+='<'; continue; }
if (str.substr(i+1,3)==ucstring("gt;")) { i+=3; result+='>'; continue; } if (str.substr(i+1,3)=="gt;") { i+=3; result+='>'; continue; }
} }
// all the special cases are catered for... treat this as a normal character // all the special cases are catered for... treat this as a normal character
@ -5471,11 +5466,11 @@ namespace NLGUI
} }
else else
{ {
ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(tooltip)); ctrlButton->setDefaultContextHelp(tooltip);
} }
} }
ctrlButton->setText(ucstring::makeFromUtf8(value)); ctrlButton->setText(value);
setTextButtonStyle(ctrlButton, _Style.Current); setTextButtonStyle(ctrlButton, _Style.Current);
} }
@ -5563,8 +5558,7 @@ namespace NLGUI
{ {
if (!_Paragraph || _Paragraph->getNumChildren() == 0) if (!_Paragraph || _Paragraph->getNumChildren() == 0)
{ {
ucstring tmp("\n"); addString("\n");
addString(tmp);
} }
else else
{ {
@ -6086,8 +6080,7 @@ namespace NLGUI
{ {
// Get the string name // Get the string name
string name = elm.getAttribute("name"); string name = elm.getAttribute("name");
ucstring ucValue; string ucValue = elm.getAttribute("value");
ucValue.fromUtf8(elm.getAttribute("value"));
uint size = 20; uint size = 20;
uint maxlength = 1024; uint maxlength = 1024;
@ -6121,12 +6114,12 @@ namespace NLGUI
string normal = elm.getAttribute("src"); string normal = elm.getAttribute("src");
string pushed; string pushed;
string over; string over;
ucstring ucValue = ucstring("on"); string ucValue = "on";
bool checked = elm.hasAttribute("checked"); bool checked = elm.hasAttribute("checked");
// TODO: unknown if empty attribute should override or not // TODO: unknown if empty attribute should override or not
if (elm.hasNonEmptyAttribute("value")) if (elm.hasNonEmptyAttribute("value"))
ucValue.fromUtf8(elm.getAttribute("value")); ucValue = elm.getAttribute("value");
if (type == "radio") if (type == "radio")
{ {
@ -6191,8 +6184,7 @@ namespace NLGUI
string name = elm.getAttribute("name"); string name = elm.getAttribute("name");
// Get the value // Get the value
ucstring ucValue; string ucValue = elm.getAttribute("value");
ucValue.fromUtf8(elm.getAttribute("value"));
// Add an entry // Add an entry
CGroupHTML::CForm::CEntry entry; CGroupHTML::CForm::CEntry entry;
@ -6224,8 +6216,7 @@ namespace NLGUI
if (elm.hasNonEmptyAttribute("value")) if (elm.hasNonEmptyAttribute("value"))
fromString(elm.getAttribute("value"), _UL.back().Value); fromString(elm.getAttribute("value"), _UL.back().Value);
ucstring str; string str = _UL.back().getListMarkerText();
str.fromUtf8(_UL.back().getListMarkerText());
addString (str); addString (str);
// list-style-type: outside // list-style-type: outside
@ -6429,7 +6420,7 @@ namespace NLGUI
// use option text as value // use option text as value
if (!elm.hasAttribute("value")) if (!elm.hasAttribute("value"))
{ {
_Forms.back().Entries.back().SelectValues.back() = _SelectOptionStr.toUtf8(); _Forms.back().Entries.back().SelectValues.back() = _SelectOptionStr;
} }
// insert the parsed text into the select control // insert the parsed text into the select control
@ -6437,7 +6428,7 @@ namespace NLGUI
if (cb) if (cb)
{ {
uint lineIndex = cb->getNumTexts(); uint lineIndex = cb->getNumTexts();
cb->addText(_SelectOptionStr.toUtf8()); cb->addText(_SelectOptionStr);
if (_Forms.back().Entries.back().sbOptionDisabled == lineIndex) if (_Forms.back().Entries.back().sbOptionDisabled == lineIndex)
{ {
cb->setGrayed(lineIndex, true); cb->setGrayed(lineIndex, true);

@ -521,7 +521,7 @@ namespace NLGUI
if (NLMISC::startsWith(propPtr, "ui")) if (NLMISC::startsWith(propPtr, "ui"))
addTextChild(CI18N::get(propPtr)); addTextChild(CI18N::get(propPtr));
else else
addTextChild(ucstring::makeFromUtf8(propPtr)); addTextChild(propPtr);
} }
else else
{ {
@ -539,7 +539,7 @@ namespace NLGUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupList::addTextChild(const ucstring& line, bool multiLine /*= true*/) void CGroupList::addTextChild(const std::string& line, bool multiLine /*= true*/)
{ {
const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter;
CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow());
@ -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.toUtf8()); view->setText (line);
// Herit global-coloring // Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor()); view->setModulateGlobalColor(getModulateGlobalColor());
addChild(view); addChild(view);
@ -558,7 +558,7 @@ namespace NLGUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupList::addTextChild(const ucstring& line, const CRGBA& textColor, bool multiLine /*= true*/) void CGroupList::addTextChild(const std::string& line, const CRGBA& textColor, bool multiLine /*= true*/)
{ {
const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter;
CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow());
@ -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.toUtf8()); view->setText (line);
view->setColor (textColor); view->setColor (textColor);
// Herit global-coloring // Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor()); view->setModulateGlobalColor(getModulateGlobalColor());
@ -1289,7 +1289,7 @@ namespace NLGUI
ucstring text; ucstring text;
if(CLuaIHM::pop(ls, text)) if(CLuaIHM::pop(ls, text))
{ {
addTextChild(text); addTextChild(text.toUtf8()); // FIXME: Lua UTF-8
} }
return 0; return 0;
} }
@ -1313,7 +1313,7 @@ namespace NLGUI
uint b = (uint) ls.toInteger(4); uint b = (uint) ls.toInteger(4);
uint a = (uint) ls.toInteger(5); uint a = (uint) ls.toInteger(5);
addTextChild(ucText, CRGBA(r, g, b, a)); addTextChild(ucText.toUtf8(), CRGBA(r, g, b, a)); // FIXME: Lua UTF-8
return 0; return 0;
} }

@ -275,7 +275,7 @@ namespace NLGUI
if (stricmp((char*)cur->name, "action") == 0) if (stricmp((char*)cur->name, "action") == 0)
{ {
string strId, strAh, strParams, strCond, strTexture; string strId, strAh, strParams, strCond, strTexture;
ucstring ucstrName; string ucstrName;
if (id) strId = (const char*)id; if (id) strId = (const char*)id;
CXMLAutoPtr name((const char*) xmlGetProp (cur, (xmlChar*)"name")); CXMLAutoPtr name((const char*) xmlGetProp (cur, (xmlChar*)"name"));
@ -286,7 +286,7 @@ namespace NLGUI
if (NLMISC::startsWith(ptrName, "ui")) if (NLMISC::startsWith(ptrName, "ui"))
ucstrName = CI18N::get(ptrName); ucstrName = CI18N::get(ptrName);
else else
ucstrName.fromUtf8(ptrName); ucstrName = ptrName;
} }
CXMLAutoPtr ah((const char*) xmlGetProp (cur, (xmlChar*)"handler")); CXMLAutoPtr ah((const char*) xmlGetProp (cur, (xmlChar*)"handler"));
@ -1215,7 +1215,7 @@ namespace NLGUI
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
CViewTextMenu* CGroupSubMenu::addLine (const ucstring &name, const std::string &ah, CViewTextMenu* CGroupSubMenu::addLine (const std::string &name, const std::string &ah,
const std::string &params, const std::string &id, const std::string &params, const std::string &id,
const std::string &cond, const std::string &texture, const std::string &cond, const std::string &texture,
bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */ bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */
@ -1231,11 +1231,11 @@ namespace NLGUI
{ {
pV->setMultiLine (true); pV->setMultiLine (true);
pV->setMultiLineMaxWOnly (true); pV->setMultiLineMaxWOnly (true);
pV->setTextFormatTaged (name.toUtf8()); pV->setTextFormatTaged (name);
} }
else else
{ {
pV->setText (name.toUtf8()); pV->setText (name);
} }
pV->setColor (_GroupMenu->_Color); pV->setColor (_GroupMenu->_Color);
pV->setFontSize (_GroupMenu->_FontSize, _GroupMenu->_FontSizeCoef); pV->setFontSize (_GroupMenu->_FontSize, _GroupMenu->_FontSizeCoef);
@ -1296,7 +1296,7 @@ namespace NLGUI
return pV; return pV;
} }
CViewTextMenu* CGroupSubMenu::addLineAtIndex(uint index, const ucstring &name, const std::string &ah, CViewTextMenu* CGroupSubMenu::addLineAtIndex(uint index, const std::string &name, const std::string &ah,
const std::string &params, const std::string &id /*=""*/, const std::string &params, const std::string &id /*=""*/,
const std::string &cond /*=std::string()*/, const std::string &texture, const std::string &cond /*=std::string()*/, const std::string &texture,
bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */ bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */
@ -1319,11 +1319,11 @@ namespace NLGUI
{ {
pV->setMultiLine (true); pV->setMultiLine (true);
pV->setMultiLineMaxWOnly (true); pV->setMultiLineMaxWOnly (true);
pV->setTextFormatTaged (name.toUtf8()); pV->setTextFormatTaged (name);
} }
else else
{ {
pV->setText (name.toUtf8()); pV->setText (name);
} }
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 (CUtfStringView(_Lines[k].ViewText->getText()).toUtf16(), _Lines[k].AHName, _Lines[k].AHParams, _Lines[k].Id, _Lines[k].Cond, pV = copyMenu->addLine (_Lines[k].ViewText->getText(), _Lines[k].AHName, _Lines[k].AHParams, _Lines[k].Id, _Lines[k].Cond,
texture, _Lines[k].ViewText->getCheckable(), _Lines[k].ViewText->getChecked(), _Lines[k].ViewText->getFormatted ()); 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());
@ -1858,8 +1858,8 @@ namespace NLGUI
CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING);
ucstring arg1; ucstring arg1;
nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); // FIXME: Lua UTF-8
addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4)); addLine(arg1.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4));
return 0; return 0;
} }
@ -1874,8 +1874,8 @@ namespace NLGUI
CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING);
ucstring arg1; ucstring arg1;
nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); // FIXME: Lua UTF-8
addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5)); addLine(arg1.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5));
return 0; return 0;
} }
@ -1890,8 +1890,8 @@ namespace NLGUI
CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING);
ucstring arg2; ucstring arg2;
nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); // FIXME: Lua UTF-8
addLineAtIndex((uint) ls.toInteger(1), arg2, ls.toString(3), ls.toString(4), ls.toString(5)); addLineAtIndex((uint) ls.toInteger(1), arg2.toUtf8(), ls.toString(3), ls.toString(4), ls.toString(5));
return 0; return 0;
} }
@ -2532,25 +2532,7 @@ namespace NLGUI
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CGroupMenu::addLine (const string &name, const string &ah, const string &params, void CGroupMenu::addLine(const std::string &name, const std::string &ah, const std::string &params,
const std::string &id/*=std::string()*/,
const std::string &cond /*= std::string()*/, const std::string &texture,
bool checkable /*= false*/, bool checked /*= false*/
)
{
if (_RootMenu == NULL)
{
_RootMenu = new CGroupSubMenu(CViewText::TCtorParam());
_RootMenu->_GroupMenu = this;
_RootMenu->setSerializable( false );
addGroup (_RootMenu);
}
_RootMenu->addLine (name, ah, params, id, cond, texture, checkable, checked, _Formatted);
}
// ------------------------------------------------------------------------------------------------
void CGroupMenu::addLine(const ucstring &name, const std::string &ah, const std::string &params,
const std::string &id /* = std::string()*/, const std::string &id /* = std::string()*/,
const std::string &cond /*= std::string()*/, const std::string &texture, const std::string &cond /*= std::string()*/, const std::string &texture,
bool checkable /*= false*/, bool checked /*= false*/ bool checkable /*= false*/, bool checked /*= false*/
@ -2566,7 +2548,7 @@ namespace NLGUI
_RootMenu->addLine (name, ah, params, id, cond, texture, checkable, checked, _Formatted); _RootMenu->addLine (name, ah, params, id, cond, texture, checkable, checked, _Formatted);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CGroupMenu::addLineAtIndex(uint index, const ucstring &name, const std::string &ah, void CGroupMenu::addLineAtIndex(uint index, const std::string &name, const std::string &ah,
const std::string &params, const std::string &id /*=std::string()*/, const std::string &params, const std::string &id /*=std::string()*/,
const std::string &cond /*=std::string()*/, const std::string &texture, const std::string &cond /*=std::string()*/, const std::string &texture,
bool checkable /*=false*/, bool checked /*=false*/) bool checkable /*=false*/, bool checked /*=false*/)

@ -479,7 +479,7 @@ namespace NLGUI
if (NLMISC::startsWith(propPtr, "ui")) if (NLMISC::startsWith(propPtr, "ui"))
addTextChild(CI18N::get(propPtr)); addTextChild(CI18N::get(propPtr));
else else
addTextChild(ucstring::makeFromUtf8(propPtr)); addTextChild(propPtr);
} }
else else
{ {
@ -495,7 +495,7 @@ namespace NLGUI
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupParagraph::addTextChild(const ucstring& line, bool multiLine /*= true*/) void CGroupParagraph::addTextChild(const std::string& line, bool multiLine /*= true*/)
{ {
const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter;
CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow());
@ -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.toUtf8()); view->setText (line);
// Herit global-coloring // Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor()); view->setModulateGlobalColor(getModulateGlobalColor());
addChild (view); addChild (view);
@ -513,14 +513,14 @@ namespace NLGUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupParagraph::addTextChild(const ucstring& line, const CRGBA& textColor, bool multiLine /*= true*/) void CGroupParagraph::addTextChild(const std::string& line, const CRGBA& textColor, bool multiLine /*= true*/)
{ {
const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter;
CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow());
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.toUtf8()); view->setText (line);
view->setColor (textColor); view->setColor (textColor);
// Herit global-coloring // Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor()); view->setModulateGlobalColor(getModulateGlobalColor());

@ -309,7 +309,7 @@ namespace NLGUI
if (NLMISC::startsWith(ptrName, "ui")) if (NLMISC::startsWith(ptrName, "ui"))
Text = CI18N::get(ptrName); Text = CI18N::get(ptrName);
else else
ucstring::makeFromUtf8(ptrName); Text = ptrName;
} }
CXMLAutoPtr color((const char*) xmlGetProp (cur, (xmlChar*)"color")); CXMLAutoPtr color((const char*) xmlGetProp (cur, (xmlChar*)"color"));
@ -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.toUtf8()); pVT->setText(pNode->Text);
pVT->setColor(pNode->Color); pVT->setColor(pNode->Color);
if(pNode->FontSize==-1) if(pNode->FontSize==-1)
pVT->setFontSize(_FontSize); pVT->setFontSize(_FontSize);

@ -548,7 +548,7 @@ namespace NLGUI
case Boolean: return true; case Boolean: return true;
case Integer: setBool(_IntegerValue != 0); return true; case Integer: setBool(_IntegerValue != 0); return true;
case Double: setBool(_DoubleValue != 0); return true; case Double: setBool(_DoubleValue != 0); return true;
case String: return evalBoolean(_StringValue.toString().c_str()) != NULL; case String: return evalBoolean(_StringValue.c_str()) != NULL;
default: break; default: break;
} }
return false; return false;
@ -564,7 +564,7 @@ namespace NLGUI
case Integer: return true; case Integer: return true;
case Double: setInteger((sint64) _DoubleValue); return true; case Double: setInteger((sint64) _DoubleValue); return true;
case String: case String:
if (evalNumber(_StringValue.toString().c_str())) return toInteger(); if (evalNumber(_StringValue.c_str())) return toInteger();
return false; return false;
case RGBA: setInteger((sint64) _RGBAValue); return true; case RGBA: setInteger((sint64) _RGBAValue); return true;
default: break; default: break;
@ -581,7 +581,7 @@ namespace NLGUI
case Integer: setDouble((double) _IntegerValue); return true; case Integer: setDouble((double) _IntegerValue); return true;
case Double: return true; case Double: return true;
case String: case String:
if (evalNumber(_StringValue.toString().c_str())) return toBool(); if (evalNumber(_StringValue.c_str())) return toBool();
return false; return false;
case RGBA: setDouble((double) _RGBAValue); return true; case RGBA: setDouble((double) _RGBAValue); return true;
default: break; default: break;
@ -627,7 +627,7 @@ namespace NLGUI
return true; return true;
case String: case String:
setRGBA( NLMISC::CRGBA::stringToRGBA(_StringValue.toString().c_str())); setRGBA( NLMISC::CRGBA::stringToRGBA(_StringValue.c_str()));
return true; return true;
default: default:
@ -869,14 +869,15 @@ namespace NLGUI
} }
//================================================================== //==================================================================
std::string CInterfaceExprValue::getString() const const std::string &CInterfaceExprValue::getString() const
{ {
if (_Type != String) if (_Type != String)
{ {
nlwarning("<CInterfaceExprValue::getString> bad type!"); nlwarning("<CInterfaceExprValue::getString> bad type!");
return ""; static const std::string empty;
return empty;
} }
return _StringValue.toString(); return _StringValue;
} }
//================================================================== //==================================================================
@ -895,19 +896,6 @@ namespace NLGUI
return col; return col;
} }
//==================================================================
const ucstring &CInterfaceExprValue::getUCString() const
{
if (_Type != String)
{
nlwarning("<CInterfaceExprValue::getString> bad type!");
static ucstring emptyString;
return emptyString;
}
return _StringValue;
}
//================================================================== //==================================================================
CInterfaceExprUserType *CInterfaceExprValue::getUserType() const CInterfaceExprUserType *CInterfaceExprValue::getUserType() const
{ {

@ -359,13 +359,13 @@ namespace NLGUI
{ {
if (!args.empty()) if (!args.empty())
{ {
ucstring res; string res;
for (uint32 i = 0; i < args.size(); ++i) for (uint32 i = 0; i < args.size(); ++i)
{ {
args[i].toString(); args[i].toString();
res += args[i].getUCString(); res += args[i].getString();
} }
result.setUCString (res); result.setString (res);
return true; return true;
} }
@ -553,13 +553,13 @@ namespace NLGUI
result.setString ((elem->*(pRP->GetMethod.GetString))()); result.setString ((elem->*(pRP->GetMethod.GetString))());
break; break;
case CReflectedProperty::UCString: case CReflectedProperty::UCString:
result.setUCString ((elem->*(pRP->GetMethod.GetUCString))()); result.setString ((elem->*(pRP->GetMethod.GetUCString))().toUtf8());
break; break;
case CReflectedProperty::StringRef: case CReflectedProperty::StringRef:
result.setString ((elem->*(pRP->GetMethod.GetStringRef))()); result.setString ((elem->*(pRP->GetMethod.GetStringRef))());
break; break;
case CReflectedProperty::UCStringRef: case CReflectedProperty::UCStringRef:
result.setUCString ((elem->*(pRP->GetMethod.GetUCStringRef))()); result.setString ((elem->*(pRP->GetMethod.GetUCStringRef))().toUtf8());
break; break;
case CReflectedProperty::RGBA: case CReflectedProperty::RGBA:
result.setRGBA ((elem->*(pRP->GetMethod.GetRGBA))()); result.setRGBA ((elem->*(pRP->GetMethod.GetRGBA))());
@ -1072,7 +1072,7 @@ namespace NLGUI
} }
sint64 nVal = args[0].getInteger(); sint64 nVal = args[0].getInteger();
ucstring sTmp; string sTmp;
if (nVal < 0) nVal = 0; if (nVal < 0) nVal = 0;
@ -1099,7 +1099,7 @@ namespace NLGUI
} }
} }
result.setUCString(sTmp); result.setString(sTmp);
return true; return true;
} }
@ -1121,7 +1121,7 @@ namespace NLGUI
} }
sint64 nVal = args[0].getInteger(); sint64 nVal = args[0].getInteger();
ucstring sTmp; string sTmp;
if (nVal < 0) nVal = 0; if (nVal < 0) nVal = 0;
@ -1150,7 +1150,7 @@ namespace NLGUI
} }
} }
result.setUCString(sTmp); result.setString(sTmp);
return true; return true;
} }
@ -1186,7 +1186,7 @@ namespace NLGUI
nlwarning("localize : 1 arg required"); nlwarning("localize : 1 arg required");
return false; return false;
} }
result.setUCString(CI18N::get(args[0].getString())); result.setString(CI18N::get(args[0].getString()));
return true; return true;
} }
REGISTER_INTERFACE_USER_FCT("localize", localize); REGISTER_INTERFACE_USER_FCT("localize", localize);

@ -121,7 +121,7 @@ namespace NLGUI
case CReflectedProperty::UCStringRef: case CReflectedProperty::UCStringRef:
if (valueToAffect.toString()) if (valueToAffect.toString())
{ {
(destElem.*(property.SetMethod.SetUCString))(valueToAffect.getUCString()); (destElem.*(property.SetMethod.SetUCString))(ucstring::makeFromUtf8(valueToAffect.getString()));
} }
else else
{ {

@ -1145,34 +1145,8 @@ namespace NLGUI
ls.push(value.getDouble()); ls.push(value.getDouble());
break; break;
case CInterfaceExprValue::String: case CInterfaceExprValue::String:
{ ls.push(value.getString());
ucstring ucstr= value.getUCString(); break;
// Yoyo: dynamically decide whether must return a string or a ucstring
bool mustUseUCString= false;
for (uint i = 0; i < ucstr.size (); i++)
{
if (ucstr[i] > 255)
{
mustUseUCString= true;
break;
}
}
// push a ucstring?
if(mustUseUCString)
{
#if LUABIND_VERSION > 600
luabind::detail::push(ls.getStatePointer(), ucstr);
#else
luabind::object obj(ls.getStatePointer(), ucstr);
obj.pushvalue();
#endif
}
else
{
ls.push(ucstr.toString());
}
break;
}
case CInterfaceExprValue::RGBA: case CInterfaceExprValue::RGBA:
{ {
CRGBA color = value.getRGBA(); CRGBA color = value.getRGBA();
@ -1691,7 +1665,7 @@ namespace NLGUI
// inside i18n table // inside i18n table
luabind::module(L, "i18n") luabind::module(L, "i18n")
[ [
luabind::def("get", &CI18N::get), luabind::def("get", &CI18N::getAsUtf16), // FIXME: Lua UTF-8
luabind::def("hasTranslation", &CI18N::hasTranslation) luabind::def("hasTranslation", &CI18N::hasTranslation)
]; ];
// inside 'nlfile' table // inside 'nlfile' table

@ -32,18 +32,6 @@ namespace NLGUI
return (c == (u32char)' ') || (c == (u32char)'\t') || (c == (u32char)'\n') || (c == (u32char)'\r'); return (c == (u32char)' ') || (c == (u32char)'\t') || (c == (u32char)'\n') || (c == (u32char)'\r');
} }
inline bool isSeparator (ucchar c)
{
return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r');
}
inline bool isSeparator (char c)
{
return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r');
}
// ***************************************************************************
inline bool isEndSentence (u32char c, u32char lastChar) inline bool isEndSentence (u32char c, u32char lastChar)
{ {
// Ex: One sentence. Another sentence. // Ex: One sentence. Another sentence.
@ -54,90 +42,6 @@ namespace NLGUI
&& (lastChar == (u32char)'.') || (lastChar == (u32char)'!') || (lastChar == (u32char)'?'); && (lastChar == (u32char)'.') || (lastChar == (u32char)'!') || (lastChar == (u32char)'?');
} }
inline bool isEndSentence (ucstring& str, uint index)
{
// Ex: One sentence. Another sentence.
// ^
// Counterexample: nevrax.com
// ^
ucchar c = str[index];
if ((str[index] == ' ') || (str[index] == '\n'))
{
if (index < 1)
return false;
c = str[index-1];
return (c == '.') || (c == '!') || (c == '?');
}
return false;
}
void setCase( ucstring &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::toLower (str);
break;
case CaseUpper:
str = NLMISC::toUpper (str);
break;
case CaseFirstStringLetterUp:
for (i=0; i<length; i++)
{
if (!isSeparator (str[i]))
{
if (newString)
str[i] = NLMISC::toUpper (str[i]);
else
str[i] = NLMISC::toLower (str[i]);
newString = false;
}
}
break;
case CaseFirstSentenceLetterUp:
for (i=0; i<length; i++)
{
if (isEndSentence (str, i))
newSentence = true;
else
{
if (newSentence)
str[i] = NLMISC::toUpper (str[i]);
else
str[i] = NLMISC::toLower (str[i]);
if (!isSeparator (str[i]))
newSentence = false;
}
}
break;
case CaseFirstWordLetterUp:
for (i=0; i<length; i++)
{
if (isSeparator (str[i]) || isEndSentence (str, i))
newWord = true;
else
{
if (newWord)
str[i] = NLMISC::toUpper (str[i]);
else
str[i] = NLMISC::toLower (str[i]);
newWord = false;
}
}
break;
default:
break;
}
}
void setCase(std::string &str, TCaseMode mode) void setCase(std::string &str, TCaseMode mode)
{ {
const uint length = (uint)str.length(); const uint length = (uint)str.length();
@ -148,10 +52,10 @@ namespace NLGUI
switch (mode) switch (mode)
{ {
case CaseLower: case CaseLower:
str = NLMISC::toLowerAsUtf8(str); str = NLMISC::toLower(str);
break; break;
case CaseUpper: case CaseUpper:
str = NLMISC::toUpperAsUtf8(str); str = NLMISC::toUpper(str);
break; break;
case CaseFirstStringLetterUp: case CaseFirstStringLetterUp:
{ {
@ -240,8 +144,6 @@ namespace NLGUI
break; break;
} }
} }
} }
/* end of file */

@ -250,7 +250,7 @@ namespace NLGUI
if (vLink->getMouseOverShape(tooltip, rot, col)) if (vLink->getMouseOverShape(tooltip, rot, col))
{ {
setString(ucstring::makeFromUtf8(tooltip)); setString(tooltip);
sint32 texId = rVR.getTextureIdFromName ("curs_pick.tga"); sint32 texId = rVR.getTextureIdFromName ("curs_pick.tga");
CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor;
@ -406,7 +406,7 @@ namespace NLGUI
splitString(tooltipInfos, "@", tooltipInfosList); splitString(tooltipInfos, "@", tooltipInfosList);
texName = tooltipInfosList[0]; texName = tooltipInfosList[0];
tooltip = tooltipInfosList[1]; tooltip = tooltipInfosList[1];
setString(ucstring::makeFromUtf8(tooltip)); setString(tooltip);
CViewRenderer &rVR = *CViewRenderer::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 texId = rVR.getTextureIdFromName (texName); sint32 texId = rVR.getTextureIdFromName (texName);
@ -449,7 +449,7 @@ namespace NLGUI
} }
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void CViewPointer::setString (const ucstring &str, CInterfaceGroup *target) void CViewPointer::setString(const std::string &str, CInterfaceGroup *target)
{ {
if (target) if (target)
{ {
@ -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.toUtf8()); text->setText(str);
} }
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.toUtf8()); text->setText(str);
} }
target->updateCoords(); target->updateCoords();
target->updateCoords(); target->updateCoords();
@ -475,7 +475,7 @@ namespace NLGUI
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
void CViewPointer::setString (const ucstring &str) void CViewPointer::setString (const std::string &str)
{ {
if (_ContextString != str) if (_ContextString != str)
{ {

@ -118,9 +118,10 @@ namespace NLGUI
// Letter size // Letter size
// - "_" that should be the character with the lowest part // - "_" that should be the character with the lowest part
// - A with an accent for the highest part // - A with an accent for the highest part
_FontSizingChars.fromUtf8("_\xc3\x84"); // https://www.compart.com/en/unicode/U+00C4
_FontSizingChars = { (u32char)'_', 0x000000C4 };
// fallback if SizingChars are not supported by font // fallback if SizingChars are not supported by font
_FontSizingFallback.fromUtf8("|"); _FontSizingFallback = { (u32char)'|' };
computeFontSize (); computeFontSize ();
} }
@ -396,12 +397,12 @@ namespace NLGUI
else else
if ( name == "sizing_chars" ) if ( name == "sizing_chars" )
{ {
return _FontSizingChars.toUtf8(); return CUtfStringView(_FontSizingChars).toUtf8();
} }
else else
if ( name == "sizing_fallback" ) if ( name == "sizing_fallback" )
{ {
return _FontSizingFallback.toUtf8(); return CUtfStringView(_FontSizingFallback).toUtf8();
} }
else else
return ""; return "";
@ -653,7 +654,7 @@ namespace NLGUI
#if 1 #if 1
if (NLMISC::startsWith(value, "ui")) if (NLMISC::startsWith(value, "ui"))
{ {
_Text = CI18N::get(value).toUtf8(); _Text = CI18N::get(value);
_TextLength = 0; _TextLength = 0;
_HardText = value; _HardText = value;
} }
@ -688,13 +689,13 @@ namespace NLGUI
else else
if( name == "sizing_chars" ) if( name == "sizing_chars" )
{ {
_FontSizingChars.fromUtf8(value); _FontSizingChars = CUtfStringView(value).toUtf32();
return true; return true;
} }
else else
if( name == "sizing_fallback" ) if( name == "sizing_fallback" )
{ {
_FontSizingFallback.fromUtf8(value); _FontSizingFallback = CUtfStringView(value).toUtf32();
return true; return true;
} }
else else
@ -766,8 +767,8 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "clamp_right", BAD_CAST toString( _ClampRight ).c_str() ); xmlSetProp( node, BAD_CAST "clamp_right", BAD_CAST toString( _ClampRight ).c_str() );
xmlSetProp( node, BAD_CAST "auto_clamp_offset", BAD_CAST toString( _AutoClampOffset ).c_str() ); xmlSetProp( node, BAD_CAST "auto_clamp_offset", BAD_CAST toString( _AutoClampOffset ).c_str() );
xmlSetProp( node, BAD_CAST "continuous_update", BAD_CAST toString( _ContinuousUpdate ).c_str() ); xmlSetProp( node, BAD_CAST "continuous_update", BAD_CAST toString( _ContinuousUpdate ).c_str() );
xmlSetProp( node, BAD_CAST "sizing_chars", BAD_CAST _FontSizingChars.toUtf8().c_str() ); xmlSetProp( node, BAD_CAST "sizing_chars", BAD_CAST CUtfStringView(_FontSizingChars).toUtf8().c_str() );
xmlSetProp( node, BAD_CAST "sizing_fallback", BAD_CAST _FontSizingFallback.toUtf8().c_str() ); xmlSetProp( node, BAD_CAST "sizing_fallback", BAD_CAST CUtfStringView(_FontSizingFallback).toUtf8().c_str() );
return true; return true;
} }
@ -953,16 +954,16 @@ namespace NLGUI
} }
// "_Ä" lowest/highest chars (underscore, A+diaeresis) // "_Ä" lowest/highest chars (underscore, A+diaeresis)
_FontSizingChars.fromUtf8("_\xc3\x84"); _FontSizingChars = { (u32char)'_', 0x000000C4 };
prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_chars" ); prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_chars" );
if (prop) if (prop)
_FontSizingChars.fromUtf8((const char*)prop); _FontSizingChars = CUtfStringView((const char*)prop).toUtf32();
// fallback if SizingChars are not supported by font // fallback if SizingChars are not supported by font
_FontSizingFallback.fromUtf8("|"); _FontSizingFallback = { (u32char)'|' };
prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_fallback" ); prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_fallback" );
if (prop) if (prop)
_FontSizingFallback.fromUtf8((const char*)prop); _FontSizingFallback = CUtfStringView((const char*)prop).toUtf32();
computeFontSize (); computeFontSize ();
} }
@ -1000,7 +1001,7 @@ namespace NLGUI
if (NLMISC::startsWith(propPtr, "ui")) if (NLMISC::startsWith(propPtr, "ui"))
{ {
_HardText = propPtr; _HardText = propPtr;
_Text = CI18N::get(propPtr).toUtf8(); _Text = CI18N::get(propPtr);
_TextLength = 0; _TextLength = 0;
} }
else else
@ -1021,11 +1022,11 @@ namespace NLGUI
if (_MultiLine) if (_MultiLine)
{ {
setTextFormatTaged(CI18N::get(propPtr).toUtf8()); setTextFormatTaged(CI18N::get(propPtr));
} }
else else
{ {
setSingleLineTextFormatTaged(CI18N::get(propPtr).toUtf8()); setSingleLineTextFormatTaged(CI18N::get(propPtr));
} }
} }
@ -1468,9 +1469,9 @@ namespace NLGUI
void CViewText::setFontSizing(const std::string &chars, const std::string &fallback) void CViewText::setFontSizing(const std::string &chars, const std::string &fallback)
{ {
_FontSizingChars.clear(); _FontSizingChars.clear();
_FontSizingChars.fromUtf8(chars); _FontSizingChars = CUtfStringView(chars).toUtf32();
_FontSizingFallback.clear(); _FontSizingFallback.clear();
_FontSizingFallback.fromUtf8(fallback); _FontSizingFallback = CUtfStringView(fallback).toUtf32();
} }
// *************************************************************************** // ***************************************************************************
@ -1683,7 +1684,7 @@ namespace NLGUI
nMaxWidth *= _Scale; nMaxWidth *= _Scale;
//for (i = 0; i < textSize; ++i) //for (i = 0; i < textSize; ++i)
CUtfStringView sv(_Text); CUtfStringView sv(_Text);
u32string ucStrLetter(1, ' '); ::u32string ucStrLetter(1, ' ');
for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++i) for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++i)
{ {
if(isFormatTagChange(i, formatTagIndex)) if(isFormatTagChange(i, formatTagIndex))
@ -1863,7 +1864,7 @@ namespace NLGUI
uint i; uint i;
for(i= (uint)spaceEnd;i<(uint)_Text.length();i++) for(i= (uint)spaceEnd;i<(uint)_Text.length();i++)
{ {
ucchar c= _Text[i]; char c= _Text[i];
if(c==' ' || c=='\n') if(c==' ' || c=='\n')
break; break;
// If change of color tag, stop the word, but don't take the new color now. // If change of color tag, stop the word, but don't take the new color now.
@ -1950,7 +1951,7 @@ namespace NLGUI
else else
{ {
float px = numSpaces * _SpaceWidth; float px = numSpaces * _SpaceWidth;
u32string oneChar(1, ' '); ::u32string oneChar(1, ' ');
CUtfStringView wsv(wordValue); CUtfStringView wsv(wordValue);
CUtfStringView::iterator wit(wsv.begin()), wend(wsv.end()); CUtfStringView::iterator wit(wsv.begin()), wend(wsv.end());
for (; wit != wend; ++wit) for (; wit != wend; ++wit)
@ -2198,7 +2199,7 @@ namespace NLGUI
if (_ClampRight) if (_ClampRight)
{ {
CUtfStringView sv(_Text); CUtfStringView sv(_Text);
u32string ucStrLetter = u32string(1, (u32char)' '); ::u32string ucStrLetter = u32string(1, (u32char)' ');
for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it)
{ {
ucStrLetter[0] = *it; ucStrLetter[0] = *it;
@ -2224,8 +2225,8 @@ namespace NLGUI
else else
{ {
// FIXME: Optimize reverse UTF iteration // FIXME: Optimize reverse UTF iteration
u32string uctext = CUtfStringView(_Text).toUtf32(); ::u32string uctext = CUtfStringView(_Text).toUtf32();
u32string ucStrLetter = u32string(1, (u32char)' '); ::u32string ucStrLetter = u32string(1, (u32char)' ');
for (sint i = (sint)uctext.size() - 1; i >= 0; --i) for (sint i = (sint)uctext.size() - 1; i >= 0; --i)
{ {
ucStrLetter[0] = uctext[i]; ucStrLetter[0] = uctext[i];
@ -2358,7 +2359,7 @@ namespace NLGUI
charIndex += currLine.getNumChars() + currLine.getEndSpaces() + (currLine.getLF() ? 1 : 0); charIndex += currLine.getNumChars() + currLine.getEndSpaces() + (currLine.getLF() ? 1 : 0);
} }
// skip all spaces at start of line (unless there are only spaces in the line) // skip all spaces at start of line (unless there are only spaces in the line)
std::string::size_type nextPos = _Text.find_first_not_of((ucchar) ' ', charIndex); std::string::size_type nextPos = _Text.find_first_not_of(' ', charIndex);
if (nextPos != std::string::npos) if (nextPos != std::string::npos)
{ {
if (getLineFromIndex(charIndex) == (sint) line) if (getLineFromIndex(charIndex) == (sint) line)
@ -2394,7 +2395,7 @@ namespace NLGUI
{ {
if (NLMISC::startsWith(ht, "ui")) if (NLMISC::startsWith(ht, "ui"))
{ {
setText(CI18N::get(ht).toUtf8()); setText(CI18N::get(ht));
_HardText = ht; _HardText = ht;
} }
else else
@ -2567,7 +2568,7 @@ namespace NLGUI
float px = 0.f; float px = 0.f;
UTextContext::CStringInfo si; UTextContext::CStringInfo si;
u32string singleChar(1, ' '); ::u32string singleChar(1, ' ');
uint i = 0; uint i = 0;
NLMISC::CUtfStringView sv(textValue); NLMISC::CUtfStringView sv(textValue);
for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++i) for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++i)
@ -3207,7 +3208,7 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CViewText::buildFormatTagText(const std::string &text, std::string &textBuild, std::vector<CViewText::CFormatTag> &formatTags, std::vector<ucstring> &tooltips) void CViewText::buildFormatTagText(const std::string &text, std::string &textBuild, std::vector<CViewText::CFormatTag> &formatTags, std::vector<std::string> &tooltips)
{ {
formatTags.clear(); formatTags.clear();
tooltips.clear(); tooltips.clear();
@ -3243,7 +3244,7 @@ namespace NLGUI
// get old tag. // get old tag.
CViewText::CFormatTag ct= precTag; CViewText::CFormatTag ct= precTag;
// get new Tab and skip tag. // get new Tab and skip tag.
ucstring uitt = getTooltipTag(text, i); string uitt = getTooltipTag(text, i);
if (uitt.empty()) if (uitt.empty())
{ {
ct.IndexTt= -1; ct.IndexTt= -1;
@ -3296,7 +3297,7 @@ namespace NLGUI
std::string tempText; std::string tempText;
// static to avoid reallocation // static to avoid reallocation
static std::vector<CFormatTag> tempFormatTags; static std::vector<CFormatTag> tempFormatTags;
static std::vector<ucstring> tempTooltips; static std::vector<std::string> tempTooltips;
buildFormatTagText(text, tempText, tempFormatTags, tempTooltips); buildFormatTagText(text, tempText, tempFormatTags, tempTooltips);
setCase (tempText, _CaseMode); setCase (tempText, _CaseMode);
@ -3344,9 +3345,9 @@ namespace NLGUI
pTooltip->setId(_Id+"_tt"+toString(i)); pTooltip->setId(_Id+"_tt"+toString(i));
pTooltip->setAvoidResizeParent(avoidResizeParent()); pTooltip->setAvoidResizeParent(avoidResizeParent());
pTooltip->setRenderLayer(getRenderLayer()); pTooltip->setRenderLayer(getRenderLayer());
std::string tempTooltipStr = tempTooltips[i].toUtf8(); std::string tempTooltipStr = tempTooltips[i];
bool isI18N = NLMISC::startsWith(tempTooltipStr, "ui"); bool isI18N = NLMISC::startsWith(tempTooltipStr, "ui");
pTooltip->setDefaultContextHelp(isI18N ? CI18N::get(tempTooltipStr) : ucstring::makeFromUtf8(tempTooltipStr)); pTooltip->setDefaultContextHelp(isI18N ? CI18N::get(tempTooltipStr) : tempTooltipStr);
pTooltip->setParentPos(this); pTooltip->setParentPos(this);
pTooltip->setParentPosRef(Hotspot_BR); pTooltip->setParentPosRef(Hotspot_BR);
pTooltip->setPosRef(Hotspot_BR); pTooltip->setPosRef(Hotspot_BR);
@ -3390,7 +3391,7 @@ namespace NLGUI
// to allow cache (avoid infinite recurse in updateCoords() in some case), compute in temp // to allow cache (avoid infinite recurse in updateCoords() in some case), compute in temp
std::string tempText; std::string tempText;
static std::vector<CFormatTag> tempLetterColors; static std::vector<CFormatTag> tempLetterColors;
static std::vector<ucstring> tempTooltips; static std::vector<std::string> tempTooltips;
// parse text // parse text
buildFormatTagText(text, tempText, tempLetterColors, tempTooltips); buildFormatTagText(text, tempText, tempLetterColors, tempTooltips);
@ -3405,7 +3406,7 @@ namespace NLGUI
while(textIndex<formatTag.Index) while(textIndex<formatTag.Index)
{ {
if(tempText[textIndex] == ucchar(' ')) if(tempText[textIndex] == ' ')
spacesNb++; spacesNb++;
textIndex++; textIndex++;

@ -38,7 +38,7 @@ namespace NLGUI
{ {
if (name == "format") if (name == "format")
{ {
return getFormatString().toUtf8(); return getFormatString();
} }
else else
return CViewText::getProperty(name); return CViewText::getProperty(name);
@ -48,7 +48,7 @@ namespace NLGUI
{ {
if (name == "format") if (name == "format")
{ {
setFormatString(ucstring::makeFromUtf8(value)); setFormatString(value);
return; return;
} }
else else
@ -62,7 +62,7 @@ namespace NLGUI
return NULL; return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_formated" ); xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_formated" );
xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().toUtf8().c_str() ); xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().c_str() );
return NULL; return NULL;
} }
@ -73,9 +73,9 @@ namespace NLGUI
if (!CViewText::parse(cur, parentGroup)) return false; if (!CViewText::parse(cur, parentGroup)) return false;
CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" ));
if (prop) if (prop)
setFormatString(ucstring::makeFromUtf8((const char *)prop)); setFormatString((const char *)prop);
else else
setFormatString(ucstring("$t")); setFormatString("$t");
return true; return true;
} }
@ -83,26 +83,27 @@ namespace NLGUI
void CViewTextFormated::checkCoords() void CViewTextFormated::checkCoords()
{ {
if (!getActive()) return; if (!getActive()) return;
ucstring formatedResult; std::string formatedResult;
formatedResult = formatString(_FormatString, ucstring("")); formatedResult = formatString(_FormatString, std::string());
// //
setText (formatedResult.toUtf8()); setText (formatedResult);
CViewText::checkCoords(); CViewText::checkCoords();
} }
// **************************************************************************** // ****************************************************************************
void CViewTextFormated::setFormatString(const ucstring &format) void CViewTextFormated::setFormatString(const std::string &format)
{ {
_FormatString = format; if (NLMISC::startsWith(format, "ui"))
if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) _FormatString = NLMISC::CI18N::get(format);
_FormatString = NLMISC::CI18N::get (format.toString()); else
_FormatString = format;
} }
// **************************************************************************** // ****************************************************************************
ucstring CViewTextFormated::formatString(const ucstring &inputString, const ucstring &paramString) std::string CViewTextFormated::formatString(const std::string &inputString, const std::string &paramString)
{ {
ucstring formatedResult; std::string formatedResult;
if( textFormatter == NULL ) if( textFormatter == NULL )
formatedResult = inputString; formatedResult = inputString;

@ -204,7 +204,7 @@ namespace NLGUI
if (!_Initialized) if (!_Initialized)
{ {
// String result // String result
ucstring result; string result;
if( textProvider != NULL ) if( textProvider != NULL )
{ {
@ -218,8 +218,8 @@ namespace NLGUI
// Remove all {break} // Remove all {break}
for(;;) for(;;)
{ {
ucstring::size_type index = result.find (ucstring("{break}")); string::size_type index = result.find("{break}");
if (index == ucstring::npos) break; if (index == string::npos) break;
result = result.substr (0, index) + result.substr(index+7, result.size()); result = result.substr (0, index) + result.substr(index+7, result.size());
} }
@ -229,13 +229,13 @@ namespace NLGUI
// Modify the text? // Modify the text?
if(_StringModifier) if(_StringModifier)
_StringModifier->onReceiveTextId(result); _StringModifier->onReceiveTextId(ucstring::makeFromUtf8(result));
// Set the Text // Set the Text
if(_IsTextFormatTaged) if(_IsTextFormatTaged)
setTextFormatTaged(result.toUtf8()); setTextFormatTaged(result);
else else
setText (result.toUtf8()); setText(result);
} }
CViewText::checkCoords(); CViewText::checkCoords();
} }

@ -37,7 +37,7 @@ namespace NLGUI
{ {
if (name == "format") if (name == "format")
{ {
return getFormatString().toUtf8(); return getFormatString();
} }
else else
return CViewTextID::getProperty(name); return CViewTextID::getProperty(name);
@ -47,7 +47,7 @@ namespace NLGUI
{ {
if (name == "format") if (name == "format")
{ {
setFormatString(ucstring::makeFromUtf8(value)); setFormatString(value);
return; return;
} }
else else
@ -61,7 +61,7 @@ namespace NLGUI
return NULL; return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_id_formated" ); xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_id_formated" );
xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().toUtf8().c_str() ); xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().c_str() );
return node; return node;
} }
@ -72,9 +72,9 @@ namespace NLGUI
if (!CViewTextID::parse(cur, parentGroup)) return false; if (!CViewTextID::parse(cur, parentGroup)) return false;
CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" ));
if (prop) if (prop)
setFormatString(ucstring::makeFromUtf8((const char *)prop)); setFormatString((const char *)prop);
else else
setFormatString(ucstring("$t")); setFormatString("$t");
return true; return true;
} }
@ -89,15 +89,15 @@ namespace NLGUI
if (!_Initialized) if (!_Initialized)
{ {
ucstring result, formatedResult; std::string result, formatedResult;
bool bValid; bool bValid;
if( CViewTextID::getTextProvider() == NULL ) if( CViewTextID::getTextProvider() == NULL )
{ {
if(!_DBPath.empty()) if(!_DBPath.empty())
result = ucstring(_DBPath); result = _DBPath;
else else
result = ucstring("Text ID = " + NLMISC::toString(_TextId)); result = "Text ID = " + NLMISC::toString(_TextId);
bValid = true; bValid = true;
} }
else else
@ -106,7 +106,7 @@ namespace NLGUI
} }
formatedResult = CViewTextFormated::formatString(_FormatString, result); formatedResult = CViewTextFormated::formatString(_FormatString, result);
// //
setText (formatedResult.toUtf8()); setText (formatedResult);
// //
if (bValid) if (bValid)
{ {
@ -117,12 +117,13 @@ namespace NLGUI
} }
// **************************************************************************** // ****************************************************************************
void CViewTextIDFormated::setFormatString(const ucstring &format) void CViewTextIDFormated::setFormatString(const std::string &format)
{ {
_Initialized = false; _Initialized = false;
_FormatString = format; if (NLMISC::startsWith(format, "ui"))
if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) _FormatString = NLMISC::CI18N::get(format);
_FormatString = NLMISC::CI18N::get (format.toString()); else
_FormatString = format;
} }
} }

@ -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.toUtf8()); pTxt->setTextFormatTaged(_ContextHelpText);
// update only to get correct W/H // update only to get correct W/H
groupContextHelp->updateCoords (); groupContextHelp->updateCoords ();

@ -594,6 +594,8 @@ NLMISC_CATEGORISED_COMMAND(nel,stohr, "Convert a second number into an human rea
return true; return true;
} }
#if 0
std::string toLower(const char *str) std::string toLower(const char *str)
{ {
if (!str) return ""; if (!str) return "";
@ -625,6 +627,8 @@ std::string toLower(const std::string &str)
return res; return res;
} }
#endif
char toLower(const char ch) char toLower(const char ch)
{ {
if( (ch >= 'A') && (ch <= 'Z') ) if( (ch >= 'A') && (ch <= 'Z') )
@ -652,6 +656,8 @@ void toLower(char *str)
} }
} }
#if 0
std::string toUpper(const std::string &str) std::string toUpper(const std::string &str)
{ {
string res; string res;
@ -666,6 +672,8 @@ std::string toUpper(const std::string &str)
return res; return res;
} }
#endif
void toUpper(char *str) void toUpper(char *str)
{ {
if (str == 0) if (str == 0)
@ -876,7 +884,7 @@ std::string formatThousands(const std::string& s)
{ {
sint i, k; sint i, k;
sint remaining = (sint)s.length() - 1; sint remaining = (sint)s.length() - 1;
static std::string separator = NLMISC::CI18N::get("uiThousandsSeparator").toUtf8(); static std::string separator = NLMISC::CI18N::get("uiThousandsSeparator");
// Don't add separator if the number is < 10k // Don't add separator if the number is < 10k
if (remaining < 4) return s; if (remaining < 4) return s;

@ -38,15 +38,18 @@ using namespace std;
namespace NLMISC { namespace NLMISC {
CI18N::StrMapContainer CI18N::_StrMap; CI18N::StrMapContainer CI18N::_StrMap;
CI18N::StrMapContainer CI18N::_StrMapFallback; CI18N::StrMapContainer CI18N::_StrMapFallback;
bool CI18N::_StrMapLoaded = false; CI18N::StrMapContainer16 CI18N::_StrMap16;
const ucstring CI18N::_NotTranslatedValue("<Not Translated>"); CI18N::StrMapContainer16 CI18N::_StrMapFallback16;
bool CI18N::_StrMapLoaded = false;
const ucstring CI18N::_NotTranslatedValue16("<Not Translated>");
const std::string CI18N::_NotTranslatedValue("<Not Translated>");
bool CI18N::_LanguagesNamesLoaded = false; bool CI18N::_LanguagesNamesLoaded = false;
string CI18N::_SelectedLanguageCode; string CI18N::_SelectedLanguageCode;
CI18N::ILoadProxy *CI18N::_LoadProxy = 0; CI18N::ILoadProxy *CI18N::_LoadProxy = 0;
vector<string> CI18N::_LanguageCodes; vector<string> CI18N::_LanguageCodes;
vector<ucstring> CI18N::_LanguageNames; vector<std::string> CI18N::_LanguageNames;
std::string CI18N::_SystemLanguageCode; std::string CI18N::_SystemLanguageCode;
bool CI18N::noResolution = false; bool CI18N::noResolution = false;
@ -65,17 +68,17 @@ void CI18N::initLanguages()
_LanguageCodes.push_back("ru"); _LanguageCodes.push_back("ru");
_LanguageCodes.push_back("es"); _LanguageCodes.push_back("es");
_LanguageNames.push_back(ucstring("English")); _LanguageNames.push_back("English");
_LanguageNames.push_back(ucstring("French")); _LanguageNames.push_back("French");
_LanguageNames.push_back(ucstring("German")); _LanguageNames.push_back("German");
_LanguageNames.push_back(ucstring("Russian")); _LanguageNames.push_back("Russian");
_LanguageNames.push_back(ucstring("Spanish")); _LanguageNames.push_back("Spanish");
_LanguagesNamesLoaded = true; _LanguagesNamesLoaded = true;
} }
} }
const std::vector<ucstring> &CI18N::getLanguageNames() const std::vector<std::string> &CI18N::getLanguageNames()
{ {
initLanguages(); initLanguages();
@ -91,19 +94,27 @@ const std::vector<std::string> &CI18N::getLanguageCodes()
void CI18N::load (const string &languageCode, const string &fallbackLanguageCode) void CI18N::load (const string &languageCode, const string &fallbackLanguageCode)
{ {
if (_StrMapLoaded) _StrMap.clear (); if (_StrMapLoaded)
else _StrMapLoaded = true; {
_StrMap.clear();
_StrMap16.clear();
}
else
{
_StrMapLoaded = true;
}
_SelectedLanguageCode = languageCode; _SelectedLanguageCode = languageCode;
loadFileIntoMap(languageCode + ".uxt", _StrMap); loadFileIntoMap(languageCode + ".uxt", _StrMap, _StrMap16);
_StrMapFallback.clear(); _StrMapFallback.clear();
_StrMapFallback16.clear();
if(!fallbackLanguageCode.empty()) if(!fallbackLanguageCode.empty())
{ {
loadFileIntoMap(fallbackLanguageCode + ".uxt", _StrMapFallback); loadFileIntoMap(fallbackLanguageCode + ".uxt", _StrMapFallback, _StrMapFallback16);
} }
} }
bool CI18N::loadFileIntoMap(const string &fileName, StrMapContainer &destMap) bool CI18N::loadFileIntoMap(const string &fileName, StrMapContainer &destMap, StrMapContainer16 &destMap16)
{ {
ucstring text; ucstring text;
// read in the text // read in the text
@ -138,11 +149,12 @@ bool CI18N::loadFileIntoMap(const string &fileName, StrMapContainer &destMap)
// ok, a line read. // ok, a line read.
pair<map<string, ucstring>::iterator, bool> ret; pair<map<string, ucstring>::iterator, bool> ret;
ret = destMap.insert(make_pair(label, ucs)); ret = destMap16.insert(make_pair(label, ucs));
if (!ret.second) if (!ret.second)
{ {
nlwarning("I18N: Error in %s, the label %s exists twice !", fileName.c_str(), label.c_str()); nlwarning("I18N: Error in %s, the label %s exists twice !", fileName.c_str(), label.c_str());
} }
destMap.insert(make_pair(label, ucs.toUtf8()));
skipWhiteSpace(first, last); skipWhiteSpace(first, last);
} }
@ -152,13 +164,15 @@ bool CI18N::loadFileIntoMap(const string &fileName, StrMapContainer &destMap)
{ {
nlwarning("I18N: In file %s, missing LanguageName translation (should be first in file)", fileName.c_str()); nlwarning("I18N: In file %s, missing LanguageName translation (should be first in file)", fileName.c_str());
} }
nlassert(destMap.size() == destMap16.size());
return true; return true;
} }
void CI18N::loadFromFilename(const string &filename, bool reload) void CI18N::loadFromFilename(const string &filename, bool reload)
{ {
StrMapContainer destMap; StrMapContainer destMap;
if (!loadFileIntoMap(filename, destMap)) StrMapContainer16 destMap16;
if (!loadFileIntoMap(filename, destMap, destMap16))
{ {
return; return;
} }
@ -167,16 +181,52 @@ void CI18N::loadFromFilename(const string &filename, bool reload)
{ {
if (!reload) if (!reload)
{ {
if (_StrMap.count(it->first)) if (_StrMap16.count(it->first))
{ {
nlwarning("I18N: Error in %s, the label %s exist twice !", filename.c_str(), it->first.c_str()); nlwarning("I18N: Error in %s, the label %s exist twice !", filename.c_str(), it->first.c_str());
} }
} }
_StrMap16[it->first] = ucstring::makeFromUtf8(it->second);
_StrMap[it->first] = it->second; _StrMap[it->first] = it->second;
} }
} }
const ucstring &CI18N::get (const string &label) const std::string &CI18N::get(const string &label)
{
if (noResolution)
{
return label;
}
if (label.empty())
{
static const std::string empty;
return empty;
}
StrMapContainer::iterator it(_StrMap.find(label));
if (it != _StrMap.end())
return it->second;
static CHashSet<string> missingStrings;
if (missingStrings.find(label) == missingStrings.end())
{
nlwarning("I18N: The string %s did not exist in language %s (display once)", label.c_str(), _SelectedLanguageCode.c_str());
missingStrings.insert(label);
}
// use the fall back language if it exists
it = _StrMapFallback.find(label);
if (it != _StrMapFallback.end())
return it->second;
static std::string badString;
badString = string("<NotExist:") + label + ">";
return badString;
}
const ucstring &CI18N::getAsUtf16 (const string &label)
{ {
if( noResolution ) if( noResolution )
{ {
@ -187,13 +237,13 @@ const ucstring &CI18N::get (const string &label)
if (label.empty()) if (label.empty())
{ {
static ucstring emptyString; static const ucstring emptyString;
return emptyString; return emptyString;
} }
StrMapContainer::iterator it(_StrMap.find(label)); StrMapContainer16::iterator it(_StrMap16.find(label));
if (it != _StrMap.end()) if (it != _StrMap16.end())
return it->second; return it->second;
static CHashSet<string> missingStrings; static CHashSet<string> missingStrings;
@ -204,8 +254,8 @@ const ucstring &CI18N::get (const string &label)
} }
// use the fall back language if it exists // use the fall back language if it exists
it = _StrMapFallback.find(label); it = _StrMapFallback16.find(label);
if (it != _StrMapFallback.end()) if (it != _StrMapFallback16.end())
return it->second; return it->second;
static ucstring badString; static ucstring badString;
@ -229,7 +279,7 @@ bool CI18N::hasTranslation(const string &label)
return false; return false;
} }
ucstring CI18N::getCurrentLanguageName () std::string CI18N::getCurrentLanguageName ()
{ {
return get("LanguageName"); return get("LanguageName");
} }
@ -379,7 +429,7 @@ std::string CI18N::getSystemLanguageCode ()
// locales names are different under Windows, for example: French_France.1252 // locales names are different under Windows, for example: French_France.1252
for(uint i = 0; i < _LanguageNames.size(); ++i) for(uint i = 0; i < _LanguageNames.size(); ++i)
{ {
std::string name = _LanguageNames[i].toUtf8(); std::string name = _LanguageNames[i];
// so we compare the language name with the supported ones // so we compare the language name with the supported ones
if (lang.compare(0, name.length(), name) == 0) if (lang.compare(0, name.length(), name) == 0)
@ -439,7 +489,7 @@ bool CI18N::setSystemLanguageCode (const std::string &languageCode)
// check if language name is supported // check if language name is supported
for(uint i = 0; i < _LanguageNames.size(); ++i) for(uint i = 0; i < _LanguageNames.size(); ++i)
{ {
std::string name = NLMISC::toLower(_LanguageNames[i].toUtf8()); std::string name = NLMISC::toLower(_LanguageNames[i]);
if (name == lang) if (name == lang)
{ {

@ -459,6 +459,9 @@ namespace NLMISC
{ {
return handleWMCopyData(hwnd, (COPYDATASTRUCT *) lParam); return handleWMCopyData(hwnd, (COPYDATASTRUCT *) lParam);
} }
// https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-unichar
if (uMsg == WM_UNICHAR)
return (wParam == UNICODE_NOCHAR);
return DefWindowProc(hwnd, uMsg, wParam, lParam); return DefWindowProc(hwnd, uMsg, wParam, lParam);
} }

File diff suppressed because it is too large Load Diff

@ -72,7 +72,7 @@ std::string CUtfStringView::toUtf8(bool reEncode) const
return std::string((const char *)m_Str, (const char *)((ptrdiff_t)m_Str + m_Size)); return std::string((const char *)m_Str, (const char *)((ptrdiff_t)m_Str + m_Size));
std::string res; std::string res;
res.reserve(m_Size); res.reserve(m_Size);
for (iterator it(begin()), end(end()); it != end; ++it) for (iterator it(begin()), end(this->end()); it != end; ++it)
{ {
appendUtf8(res, *it); appendUtf8(res, *it);
} }
@ -85,7 +85,7 @@ ucstring CUtfStringView::toUtf16(bool reEncode) const
return ucstring((const ucchar *)m_Str, (const ucchar *)((ptrdiff_t)m_Str + m_Size)); return ucstring((const ucchar *)m_Str, (const ucchar *)((ptrdiff_t)m_Str + m_Size));
ucstring res; ucstring res;
res.reserve(m_Size << 1); res.reserve(m_Size << 1);
for (iterator it(begin()), end(end()); it != end; ++it) for (iterator it(begin()), end(this->end()); it != end; ++it)
{ {
u32char c = *it; u32char c = *it;
if (c < 0x10000) if (c < 0x10000)
@ -102,15 +102,15 @@ ucstring CUtfStringView::toUtf16(bool reEncode) const
return res; return res;
} }
u32string CUtfStringView::toUtf32() const ::u32string CUtfStringView::toUtf32() const
{ {
// Decode any UTF // Decode any UTF
// This implementation makes no attempt at fixing bad encoding // This implementation makes no attempt at fixing bad encoding
if (m_Iterator == utf32Iterator) if (m_Iterator == utf32Iterator)
return u32string((const u32char *)m_Str, (const u32char *)((ptrdiff_t)m_Str + m_Size)); return ::u32string((const u32char *)m_Str, (const u32char *)((ptrdiff_t)m_Str + m_Size));
u32string res; ::u32string res;
res.reserve(m_Size << 2); res.reserve(m_Size << 2);
for (iterator it(begin()), end(end()); it != end; ++it) for (iterator it(begin()), end(this->end()); it != end; ++it)
res += *it; res += *it;
return res; return res;
} }
@ -119,7 +119,7 @@ std::string CUtfStringView::toAscii() const
{ {
std::string res; std::string res;
res.reserve(m_Size); res.reserve(m_Size);
for (iterator it(begin()), end(end()); it != end; ++it) for (iterator it(begin()), end(this->end()); it != end; ++it)
{ {
u32char c = *it; u32char c = *it;
if (c < 0x80) if (c < 0x80)
@ -137,7 +137,7 @@ std::wstring CUtfStringView::toWide() const
return std::wstring((const wchar_t *)m_Str, (const wchar_t *)((ptrdiff_t)m_Str + m_Size)); return std::wstring((const wchar_t *)m_Str, (const wchar_t *)((ptrdiff_t)m_Str + m_Size));
std::wstring res; std::wstring res;
res.reserve(m_Size << 1); res.reserve(m_Size << 1);
for (iterator it(begin()), end(end()); it != end; ++it) for (iterator it(begin()), end(this->end()); it != end; ++it)
{ {
u32char c = *it; u32char c = *it;
if (c < 0x10000) if (c < 0x10000)
@ -157,7 +157,7 @@ std::wstring CUtfStringView::toWide() const
return std::wstring((const wchar_t *)m_Str, (const wchar_t *)((ptrdiff_t)m_Str + m_Size)); return std::wstring((const wchar_t *)m_Str, (const wchar_t *)((ptrdiff_t)m_Str + m_Size));
std::wstring res; std::wstring res;
res.reserve(m_Size << 2); res.reserve(m_Size << 2);
for (iterator it(begin()), end(end()); it != end; ++it) for (iterator it(begin()), end(this->end()); it != end; ++it)
res += *it; res += *it;
return res; return res;
#endif #endif
@ -166,7 +166,7 @@ std::wstring CUtfStringView::toWide() const
size_t CUtfStringView::count() const size_t CUtfStringView::count() const
{ {
size_t res = 0; size_t res = 0;
for (iterator it(begin()), end(end()); it != end; ++it) for (iterator it(begin()), end(this->end()); it != end; ++it)
++res; ++res;
return res; return res;
} }

@ -162,6 +162,14 @@ bool CWinEventEmitter::processMessage (HWND hWnd, uint32 msg, WPARAM wParam, LPA
server->postEvent (new CEventKeyUp ((NLMISC::TKey)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this)); server->postEvent (new CEventKeyUp ((NLMISC::TKey)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this));
} }
break; break;
case WM_UNICHAR:
if (wParam != UNICODE_NOCHAR && _KeyboardEventsEnabled)
{
//if (wParam < KeyCount)
//nlinfo("WM_UNICHAR with %u", wParam);
server->postEvent (new CEventChar ((u32char)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this));
}
break;
case WM_CHAR: case WM_CHAR:
if (_KeyboardEventsEnabled) if (_KeyboardEventsEnabled)
{ {

@ -499,9 +499,9 @@ void CCombo::init (NLMISC::TKey key, NLMISC::TKeyButton keyButtons)
} }
// *************************************************************************** // ***************************************************************************
ucstring CCombo::toUCString() const string CCombo::toString() const
{ {
ucstring ret; string ret;
if ((KeyButtons & shiftKeyButton) && (Key != 0x10)) if ((KeyButtons & shiftKeyButton) && (Key != 0x10))
ret += CI18N::get("uiKeySHIFT") + "+"; ret += CI18N::get("uiKeySHIFT") + "+";
if ((KeyButtons & ctrlKeyButton) && (Key != 0x11)) if ((KeyButtons & ctrlKeyButton) && (Key != 0x11))

@ -66,7 +66,7 @@ public:
void init (NLMISC::TKey key, NLMISC::TKeyButton keyButtons); void init (NLMISC::TKey key, NLMISC::TKeyButton keyButtons);
/// Get the combo in human readable form /// Get the combo in human readable form
ucstring toUCString() const; std::string toString() const;
// For maps // For maps
bool operator<(const CCombo &other) const bool operator<(const CCombo &other) const

@ -230,7 +230,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run()
// that the downloader is still running and in slave mode // that the downloader is still running and in slave mode
if (!isDownloaderProcessRunning() && getDownloaderMode() != DownloaderMode_Slave) if (!isDownloaderProcessRunning() && getDownloaderMode() != DownloaderMode_Slave)
{ {
throw EDownloadException(CI18N::get("uiBGD_DownloaderStopped").toUtf8()); throw EDownloadException(CI18N::get("uiBGD_DownloaderStopped"));
} }
} }
else else
@ -429,7 +429,7 @@ void CBGDownloaderAccess::CDownloadCoTask::createDownloaderProcess()
BOOL ok = NLMISC::launchProgram(BGDownloaderName, Parent->_CommandLine); BOOL ok = NLMISC::launchProgram(BGDownloaderName, Parent->_CommandLine);
if (!ok) if (!ok)
{ {
throw EDownloadException(CI18N::get("uiBGD_LaunchError").toUtf8()); throw EDownloadException(CI18N::get("uiBGD_LaunchError"));
} }
} }
else else
@ -458,7 +458,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader()
{ {
nlwarning("CBGDownloaderAccess::CDownloadCoTask : detected shared memory segment, with NULL pid"); nlwarning("CBGDownloaderAccess::CDownloadCoTask : detected shared memory segment, with NULL pid");
// some problem here ... // some problem here ...
throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance").toUtf8()); throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance"));
} }
} }
bool ok = NLMISC::CWinProcess::terminateProcess(*(DWORD *) ryzomInstPIDPtr); bool ok = NLMISC::CWinProcess::terminateProcess(*(DWORD *) ryzomInstPIDPtr);
@ -467,7 +467,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader()
{ {
nlwarning("CBGDownloaderAccess::CDownloadCoTask : detected shared memory segment, with good pid, but couldn't stop the process"); nlwarning("CBGDownloaderAccess::CDownloadCoTask : detected shared memory segment, with good pid, but couldn't stop the process");
// couldn't stop the other client ... // couldn't stop the other client ...
throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance").toUtf8()); throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance"));
} }
} }
// write our pid into shared mem // write our pid into shared mem
@ -475,7 +475,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader()
if (!Parent->_RyzomInstPIDPtr) if (!Parent->_RyzomInstPIDPtr)
{ {
// really, really bad luck ... // really, really bad luck ...
throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance").toUtf8()); throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance"));
} }
*(uint32 *) Parent->_RyzomInstPIDPtr = (uint32) GetCurrentProcessId(); *(uint32 *) Parent->_RyzomInstPIDPtr = (uint32) GetCurrentProcessId();
@ -514,7 +514,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader()
const uint32 totalTries = 7; const uint32 totalTries = 7;
while (waitTime <= 32000) while (waitTime <= 32000)
{ {
Parent->_CurrentMessage.fromUtf8(toString(CI18N::get("uiBGD_HandShaking").toUtf8().c_str(), tryIndex, totalTries)); Parent->_CurrentMessage.fromUtf8(toString(CI18N::get("uiBGD_HandShaking").c_str(), tryIndex, totalTries));
sendSimpleMsg(CL_Probe); sendSimpleMsg(CL_Probe);
NLMISC::CMemStream dummyMsg; NLMISC::CMemStream dummyMsg;
@ -758,7 +758,7 @@ void CBGDownloaderAccess::CDownloadCoTask::waitMsg(BGDownloader::TMsgType wanted
if (msgType != wantedMsgType) if (msgType != wantedMsgType)
{ {
nlwarning("BG DOWNLOADER PROTOCOL ERROR ! Bad message type received. Expected type is '%d', received type is '%d'", (int) wantedMsgType, (int) msgType); nlwarning("BG DOWNLOADER PROTOCOL ERROR ! Bad message type received. Expected type is '%d', received type is '%d'", (int) wantedMsgType, (int) msgType);
throw EDownloadException(CI18N::get("uiBGD_ProtocolError").toUtf8()); throw EDownloadException(CI18N::get("uiBGD_ProtocolError"));
} }
} }
@ -816,7 +816,7 @@ void CBGDownloaderAccess::CDownloadCoTask::checkDownloaderAlive()
{ {
if (!Parent->_DownloaderMsgQueue.connected() || !isDownloaderProcessRunning()) if (!Parent->_DownloaderMsgQueue.connected() || !isDownloaderProcessRunning())
{ {
throw EDownloadException(CI18N::get("uiBGD_DownloaderDisconnected").toUtf8()); throw EDownloadException(CI18N::get("uiBGD_DownloaderDisconnected"));
} }
} }

@ -1175,9 +1175,9 @@ class CHandlerTell : public IActionHandler
void execute (CCtrlBase *pCaller, const std::string &sParams) void execute (CCtrlBase *pCaller, const std::string &sParams)
{ {
string receiver = getParam (sParams, "player"); string receiver = getParam (sParams, "player");
ucstring message; string message;
message.fromUtf8(getParam (sParams, "text")); message = getParam (sParams, "text");
// message = getParam (sParams, "text");
if (receiver.empty() || message.empty()) if (receiver.empty() || message.empty())
return; return;
@ -1193,10 +1193,10 @@ class CHandlerTell : public IActionHandler
// display in the good window // display in the good window
CInterfaceProperty prop; CInterfaceProperty prop;
prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," ");
ucstring finalMsg; string finalMsg;
CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, false); CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, false);
ucstring csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); string csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : "");
finalMsg += csr + CI18N::get("youTell") + ": "; finalMsg += csr + CI18N::get("youTell") + ": ";
prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," ");
CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, true); CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, true);
@ -1205,7 +1205,7 @@ class CHandlerTell : public IActionHandler
// TDataSetIndex dsi; // not used .... // TDataSetIndex dsi; // not used ....
PeopleInterraction.ChatInput.Tell.displayTellMessage(/*dsi, */finalMsg, receiver, prop.getRGBA()); PeopleInterraction.ChatInput.Tell.displayTellMessage(/*dsi, */finalMsg, receiver, prop.getRGBA());
ucstring s = CI18N::get("youTellPlayer"); string s = CI18N::get("youTellPlayer");
strFindReplace(s, "%name", receiver); strFindReplace(s, "%name", receiver);
strFindReplace(finalMsg, CI18N::get("youTell"), s); strFindReplace(finalMsg, CI18N::get("youTell"), s);
CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell)); CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell));
@ -1340,9 +1340,7 @@ class CHandlerTalk : public IActionHandler
// Param // Param
uint mode; uint mode;
fromString(getParam (sParams, "mode"), mode); fromString(getParam (sParams, "mode"), mode);
ucstring text; string text = getParam (sParams, "text");
text.fromUtf8 (getParam (sParams, "text"));
// text = getParam (sParams, "text");
// Parse any tokens in the text // Parse any tokens in the text
if ( ! CInterfaceManager::parseTokens(text)) if ( ! CInterfaceManager::parseTokens(text))
@ -1355,7 +1353,7 @@ class CHandlerTalk : public IActionHandler
{ {
if(text[0] == '/') if(text[0] == '/')
{ {
string str = text.toUtf8(); string str = text;
string cmdWithArgs = str.substr(1); string cmdWithArgs = str.substr(1);
// Get the command name from the string, can contain spaces // Get the command name from the string, can contain spaces

@ -906,7 +906,7 @@ bool CItemSheet::canExchangeOrGive(bool botChatGift) const
} }
// *************************************************************************** // ***************************************************************************
void CItemSheet::getItemPartListAsText(ucstring &ipList) const void CItemSheet::getItemPartListAsText(std::string &ipList) const
{ {
bool all= true; bool all= true;
for(uint i=0;i<RM_FABER_TYPE::NUM_FABER_TYPE;i++) for(uint i=0;i<RM_FABER_TYPE::NUM_FABER_TYPE;i++)

@ -436,7 +436,7 @@ public:
bool canExchangeOrGive(bool botChatGift) const; bool canExchangeOrGive(bool botChatGift) const;
// MP only. return translated text of all item part this MP can build. empty, if can't build anything // MP only. return translated text of all item part this MP can build. empty, if can't build anything
void getItemPartListAsText(ucstring &ipList) const; void getItemPartListAsText(std::string &ipList) const;
// get craft plan // get craft plan
const NLMISC::CSheetId &getCraftPlan() const { return CraftPlan; } const NLMISC::CSheetId &getCraftPlan() const { return CraftPlan; }

@ -853,7 +853,7 @@ NLMISC_COMMAND(bugReport, "Call the bug report tool with dump", "<AddScreenshot>
string sys; string sys;
sys = "Language "+CI18N::getCurrentLanguageName().toString() +" "; sys = "Language "+CI18N::getCurrentLanguageName() +" ";
if (!args.empty()) if (!args.empty())
{ {
@ -1306,9 +1306,9 @@ NLMISC_COMMAND(execScript, "Execute a script file (.cmd)","<FileName>")
inComment++; inComment++;
if(inComment<=0) if(inComment<=0)
{ {
ucstring ucline(line); string ucline(line);
CInterfaceManager::parseTokens(ucline); CInterfaceManager::parseTokens(ucline);
ICommand::execute(ucline.toUtf8(), g_log); ICommand::execute(ucline, g_log);
} }
if(strncmp(line, "*/", 2)==0) if(strncmp(line, "*/", 2)==0)
inComment--; inComment--;

@ -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").toUtf8() + "..."); pVT->setText(CI18N::get("uiFirewallAlert") + "...");
// 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").toUtf8()+".\n"+ pVT->setText(CI18N::get("uiFirewallFail")+".\n"+
CI18N::get("uiFirewallAlert").toUtf8()+"."); CI18N::get("uiFirewallAlert")+".");
} }
} }
} }
@ -1317,7 +1317,7 @@ public:
if (pVT == NULL) return; if (pVT == NULL) return;
if (rCS.Name.empty()) if (rCS.Name.empty())
pVT->setText(CI18N::get("uiEmptySlot").toUtf8()); pVT->setText(CI18N::get("uiEmptySlot"));
else else
pVT->setText(rCS.Name.toUtf8()); pVT->setText(rCS.Name.toUtf8());
} }
@ -1326,7 +1326,7 @@ public:
{ {
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").toUtf8()); pVT->setText(CI18N::get("uiEmptySlot"));
} }
} }
}; };
@ -1348,7 +1348,7 @@ void setTarget(CCtrlBase *ctrl, const string &targetName, ucstring &value)
if (ig) if (ig)
{ {
CInterfaceExprValue exprValue; CInterfaceExprValue exprValue;
exprValue.setUCString(value); exprValue.setString(value.toUtf8());
CInterfaceLink::splitLinkTargets(targetName, ig, targets); CInterfaceLink::splitLinkTargets(targetName, ig, targets);
for(uint k = 0; k < targets.size(); ++k) for(uint k = 0; k < targets.size(); ++k)
@ -2315,7 +2315,7 @@ public:
CCtrlBase *pBut = pNewLine->getCtrl("but"); CCtrlBase *pBut = pNewLine->getCtrl("but");
if (pBut != NULL) if (pBut != NULL)
{ {
pBut->setDefaultContextHelp(tooltip); pBut->setDefaultContextHelp(tooltip.toUtf8());
} }
addGroupInList(pNewLine); addGroupInList(pNewLine);
} }
@ -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").toUtf8():CI18N::get("uiR2EDScenarioFileName").toUtf8()); viewText->setText(R2::getEditor().isInitialized()?CI18N::get("uiR2EDScenarioName"):CI18N::get("uiR2EDScenarioFileName"));
} }
} }
@ -2692,9 +2692,9 @@ class CAHScenarioControl : public IActionHandler
if(okButton) if(okButton)
{ {
if(R2::getEditor().getAccessMode()!=R2::CEditor::AccessDM) if(R2::getEditor().getAccessMode()!=R2::CEditor::AccessDM)
okButton->setHardText(CI18N::get("uiR2EDLaunchScenario").toString()); okButton->setHardText(CI18N::get("uiR2EDLaunchScenario"));
else else
okButton->setHardText(CI18N::get("uiR2EDApplyScenarioFilters").toString()); okButton->setHardText(CI18N::get("uiR2EDApplyScenarioFilters"));
} }
} }
@ -3182,9 +3182,9 @@ class CAHLoadScenario : public IActionHandler
// -------------------------- // --------------------------
TRuleType ruleType(TRuleType::rt_strict); TRuleType ruleType(TRuleType::rt_strict);
if(rules==CI18N::get("uiR2EDliberal").toString()) if(rules==CI18N::get("uiR2EDliberal"))
ruleType = TRuleType(TRuleType::rt_liberal); ruleType = TRuleType(TRuleType::rt_liberal);
else if(rules == CI18N::get("uiR2EDstrict").toString()) else if(rules == CI18N::get("uiR2EDstrict"))
ruleType = TRuleType(TRuleType::rt_strict); ruleType = TRuleType(TRuleType::rt_strict);
volatile static bool override = false; volatile static bool override = false;
if (override) if (override)
@ -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").toUtf8()); pVT->setText(CI18N::get("uiRingWarningFreeTrial"));
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").toUtf8()); pVT->setText(CI18N::get("uiRingWarningFreeTrial"));
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").toUtf8()); pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial"));
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
} }
} }

@ -162,7 +162,7 @@ bool CContextualCursor::context(const std::string &contextName, float dist, cons
if(cursName.empty()) if(cursName.empty())
cursor->setString(CI18N::get(functions.cursor)); cursor->setString(CI18N::get(functions.cursor));
else else
cursor->setString(cursName); cursor->setString(cursName.toUtf8());
} }
} }
} }

@ -529,7 +529,7 @@ string getDebugInformation()
str += toString("ServerTick: %u\n", NetMngr.getCurrentServerTick()); str += toString("ServerTick: %u\n", NetMngr.getCurrentServerTick());
str += toString("ConnectState: %s\n", NetMngr.getConnectionStateCStr()); str += toString("ConnectState: %s\n", NetMngr.getConnectionStateCStr());
str += toString("LocalAddress: %s\n", NetMngr.getAddress().asString().c_str()); str += toString("LocalAddress: %s\n", NetMngr.getAddress().asString().c_str());
str += toString("Language: %s\n", CI18N::getCurrentLanguageName().toString().c_str()); str += toString("Language: %s\n", CI18N::getCurrentLanguageName().c_str());
str += toString("ClientVersion: %s\n", getDebugVersion().c_str()); str += toString("ClientVersion: %s\n", getDebugVersion().c_str());
if (ClientCfg.R2Mode) if (ClientCfg.R2Mode)
{ {

@ -578,7 +578,7 @@ void checkDriverDepth ()
#else #else
if (mode.Depth != 16 && mode.Depth != 24 && mode.Depth != 32) if (mode.Depth != 16 && mode.Depth != 24 && mode.Depth != 32)
#endif #endif
ExitClientError (CI18N::get ("uiDesktopNotIn32").toUtf8().c_str ()); ExitClientError (CI18N::get ("uiDesktopNotIn32").c_str ());
} }
} }
@ -1060,7 +1060,7 @@ void prelogInit()
if(Driver == NULL) if(Driver == NULL)
{ {
ExitClientError (CI18N::get ("Can_t_load_the_display_driver").toUtf8().c_str ()); ExitClientError (CI18N::get ("Can_t_load_the_display_driver").c_str ());
// ExitClientError() call exit() so the code after is never called // ExitClientError() call exit() so the code after is never called
return; return;
} }
@ -1151,14 +1151,14 @@ void prelogInit()
string msg; string msg;
if (mode.Windowed) if (mode.Windowed)
{ {
msg = CI18N::get ("can_t_create_a_window_display").toUtf8(); msg = CI18N::get ("can_t_create_a_window_display");
} }
else else
{ {
msg = CI18N::get ("can_t_create_a_fullscreen_display").toUtf8(); msg = CI18N::get ("can_t_create_a_fullscreen_display");
} }
msg += " (%dx%d %d "; msg += " (%dx%d %d ";
msg += CI18N::get ("bits").toUtf8 (); msg += CI18N::get ("bits");
msg += ")"; msg += ")";
ExitClientError (msg.c_str (), mode.Width, mode.Height, mode.Depth); ExitClientError (msg.c_str (), mode.Width, mode.Height, mode.Depth);
// ExitClientError() call exit() so the code after is never called // ExitClientError() call exit() so the code after is never called

@ -1714,6 +1714,6 @@ void initBloomConfigUI()
else else
{ {
if(group) if(group)
group->setDefaultContextHelp(ucstring("")); group->setDefaultContextHelp(std::string());
} }
} }

@ -70,7 +70,7 @@ static inline uint getCharacterCategory(u32char c)
/** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed) /** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed)
* It returns the new index * It returns the new index
*/ */
static uint skipUCCharsRight(uint startPos, const u32string &str) static uint skipUCCharsRight(uint startPos, const ::u32string &str)
{ {
uint pos = startPos; uint pos = startPos;
uint endIndex = (uint)str.length(); uint endIndex = (uint)str.length();
@ -87,7 +87,7 @@ static uint skipUCCharsRight(uint startPos, const u32string &str)
/** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed) /** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed)
* It returns the new index * It returns the new index
*/ */
static uint skipUCCharsLeft(uint startPos, const u32string &str) static uint skipUCCharsLeft(uint startPos, const ::u32string &str)
{ {
uint pos = startPos; uint pos = startPos;
-- pos; -- pos;
@ -363,7 +363,7 @@ class CAHEditPreviousLine : public CAHEdit
if (_GroupEdit->getMaxHistoric() && (! _GroupEdit->getViewText()->getMultiLine())) if (_GroupEdit->getMaxHistoric() && (! _GroupEdit->getViewText()->getMultiLine()))
{ {
// Get the start of the string. // Get the start of the string.
u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); ::u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos());
// Search all historic string that match startStr. // Search all historic string that match startStr.
for(sint i=_GroupEdit->getCurrentHistoricIndex()+1;i<(sint)_GroupEdit->getNumHistoric();i++) for(sint i=_GroupEdit->getCurrentHistoricIndex()+1;i<(sint)_GroupEdit->getNumHistoric();i++)
@ -435,7 +435,7 @@ class CAHEditNextLine : public CAHEdit
if( (! _GroupEdit->getViewText()->getMultiLine()) && _GroupEdit->getMaxHistoric() && _GroupEdit->getCurrentHistoricIndex()>0) if( (! _GroupEdit->getViewText()->getMultiLine()) && _GroupEdit->getMaxHistoric() && _GroupEdit->getCurrentHistoricIndex()>0)
{ {
// Get the start of the string. // Get the start of the string.
u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); ::u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos());
// Search all historic string that match startStr. // Search all historic string that match startStr.
for(sint i=_GroupEdit->getCurrentHistoricIndex()-1;i>=0;i--) for(sint i=_GroupEdit->getCurrentHistoricIndex()-1;i>=0;i--)
@ -521,8 +521,8 @@ protected:
// else cut forwards // else cut forwards
else if(_GroupEdit->getCursorPos() < (sint32) _GroupEdit->getInputStringRef().length()) else if(_GroupEdit->getCursorPos() < (sint32) _GroupEdit->getInputStringRef().length())
{ {
u32string inputString = _GroupEdit->getInputStringRef(); ::u32string inputString = _GroupEdit->getInputStringRef();
u32string::iterator it = inputString.begin() + _GroupEdit->getCursorPos(); ::u32string::iterator it = inputString.begin() + _GroupEdit->getCursorPos();
inputString.erase(it); inputString.erase(it);
_GroupEdit->setInputStringRef (inputString); _GroupEdit->setInputStringRef (inputString);
if (!_GroupEdit->getAHOnChange().empty()) if (!_GroupEdit->getAHOnChange().empty())
@ -660,7 +660,7 @@ class CAHEditExpandOrCycleTell : public CAHEdit
else else
{ {
// it is not a filtered chat, display 'tell' (must be ingame) // it is not a filtered chat, display 'tell' (must be ingame)
_GroupEdit->setCommand(ucstring("tell ") + *lastTellPeople + (ucchar) ' ', false); _GroupEdit->setCommand("tell " + (*lastTellPeople).toUtf8() + ' ', false);
} }
} }
}; };

@ -2071,9 +2071,9 @@ class CActionHandlerSetTargetName : public IActionHandler
} }
// Set to target // Set to target
CInterfaceExprValue evUCStr; CInterfaceExprValue evUCStr;
evUCStr.setUCString(TargetName); evUCStr.setString(TargetName.toUtf8());
CInterfaceLink::setTargetProperty(sNameTarget, evUCStr); CInterfaceLink::setTargetProperty(sNameTarget, evUCStr);
evUCStr.setUCString(TargetTitle); evUCStr.setString(TargetTitle.toUtf8());
CInterfaceLink::setTargetProperty(sTitleTarget, evUCStr); CInterfaceLink::setTargetProperty(sTitleTarget, evUCStr);
} }
} }
@ -2113,7 +2113,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler
pVBR->setColor(CRGBA(0,0,0,0)); pVBR->setColor(CRGBA(0,0,0,0));
if (pTooltip) if (pTooltip)
pTooltip->setDefaultContextHelp(ucstring("")); pTooltip->setDefaultContextHelp(std::string());
return; return;
} }
@ -2166,7 +2166,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler
pVBR->setColor(CRGBA(0,0,0,0)); pVBR->setColor(CRGBA(0,0,0,0));
if (pTooltip) if (pTooltip)
pTooltip->setDefaultContextHelp(ucstring("")); pTooltip->setDefaultContextHelp(std::string());
return; return;
} }
@ -2191,7 +2191,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler
CCtrlBase *tooltip = dynamic_cast<CCtrlBase*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:target:header_opened:force")); CCtrlBase *tooltip = dynamic_cast<CCtrlBase*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:target:header_opened:force"));
if (tooltip) if (tooltip)
{ {
ucstring str; string str;
if (nForceRegion == 1) if (nForceRegion == 1)
nForceRegion = 2; nForceRegion = 2;
@ -3091,10 +3091,10 @@ public:
if( pCB ) if( pCB )
{ {
pCB->resetTexts(); pCB->resetTexts();
pCB->addText(CI18N::get("uigcLowTextureMode").toUtf8()); pCB->addText(CI18N::get("uigcLowTextureMode"));
pCB->addText(CI18N::get("uigcNormalTextureMode").toUtf8()); pCB->addText(CI18N::get("uigcNormalTextureMode"));
if(ClientCfg.HDTextureInstalled) if(ClientCfg.HDTextureInstalled)
pCB->addText(CI18N::get("uigcHighTextureMode").toUtf8()); pCB->addText(CI18N::get("uigcHighTextureMode"));
} }
// Anisotropic Filtering // Anisotropic Filtering
@ -3107,7 +3107,7 @@ public:
sint maxAnisotropic = (sint)Driver->getAnisotropicFilterMaximum(); sint maxAnisotropic = (sint)Driver->getAnisotropicFilterMaximum();
pCB->resetTexts(); pCB->resetTexts();
pCB->addText(CI18N::get("uigcFxAnisotropicFilterNone").toUtf8()); pCB->addText(CI18N::get("uigcFxAnisotropicFilterNone"));
sint anisotropic = 2; sint anisotropic = 2;
uint i = 1; uint i = 1;
@ -4047,7 +4047,7 @@ public:
ucstring str; ucstring str;
fillPlayerBarText(str, "HP", SCORES::hit_points, "uittPlayerLifeFormat"); fillPlayerBarText(str, "HP", SCORES::hit_points, "uittPlayerLifeFormat");
CWidgetManager::getInstance()->setContextHelpText(str); CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
} }
}; };
REGISTER_ACTION_HANDLER(CHandlerPlayerTTLife, "player_tt_life"); REGISTER_ACTION_HANDLER(CHandlerPlayerTTLife, "player_tt_life");
@ -4064,7 +4064,7 @@ public:
ucstring str; ucstring str;
fillPlayerBarText(str, "STA", SCORES::stamina, "uittPlayerStaminaFormat"); fillPlayerBarText(str, "STA", SCORES::stamina, "uittPlayerStaminaFormat");
CWidgetManager::getInstance()->setContextHelpText(str); CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
} }
}; };
REGISTER_ACTION_HANDLER(CHandlerPlayerTTStamina, "player_tt_stamina"); REGISTER_ACTION_HANDLER(CHandlerPlayerTTStamina, "player_tt_stamina");
@ -4081,7 +4081,7 @@ public:
ucstring str; ucstring str;
fillPlayerBarText(str, "SAP", SCORES::sap, "uittPlayerSapFormat"); fillPlayerBarText(str, "SAP", SCORES::sap, "uittPlayerSapFormat");
CWidgetManager::getInstance()->setContextHelpText(str); CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
} }
}; };
REGISTER_ACTION_HANDLER(CHandlerPlayerTTSap, "player_tt_sap"); REGISTER_ACTION_HANDLER(CHandlerPlayerTTSap, "player_tt_sap");
@ -4098,7 +4098,7 @@ public:
ucstring str; ucstring str;
fillPlayerBarText(str, "FOCUS", SCORES::focus, "uittPlayerFocusFormat"); fillPlayerBarText(str, "FOCUS", SCORES::focus, "uittPlayerFocusFormat");
CWidgetManager::getInstance()->setContextHelpText(str); CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
} }
}; };
REGISTER_ACTION_HANDLER(CHandlerPlayerTTFocus, "player_tt_focus"); REGISTER_ACTION_HANDLER(CHandlerPlayerTTFocus, "player_tt_focus");
@ -4128,7 +4128,7 @@ public:
ucstring str= CI18N::get("uittBulkFormat"); ucstring str= CI18N::get("uittBulkFormat");
strFindReplace(str, "%v", toString("%.2f", val) ); strFindReplace(str, "%v", toString("%.2f", val) );
strFindReplace(str, "%m", toString(maxVal) ); strFindReplace(str, "%m", toString(maxVal) );
CWidgetManager::getInstance()->setContextHelpText(str); CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
} }
}; };
REGISTER_ACTION_HANDLER(CHandlerGetTTBulk, "get_tt_bulk"); REGISTER_ACTION_HANDLER(CHandlerGetTTBulk, "get_tt_bulk");

@ -992,9 +992,7 @@ class CHandlerBrowse : public IActionHandler
} }
} }
ucstring ucparams(params); CInterfaceManager::parseTokens(params);
CInterfaceManager::parseTokens(ucparams);
params = ucparams.toUtf8();
// go. NB: the action handler himself may translate params from utf8 // go. NB: the action handler himself may translate params from utf8
CAHManager::getInstance()->runActionHandler(action, elementGroup, params); CAHManager::getInstance()->runActionHandler(action, elementGroup, params);
@ -2014,7 +2012,7 @@ void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS)
if(pIS->canBuildSomeItemPart()) if(pIS->canBuildSomeItemPart())
{ {
ucstring fmt= CI18N::get("uihelpItemMPCraft"); ucstring fmt= CI18N::get("uihelpItemMPCraft");
ucstring ipList; std::string ipList;
pIS->getItemPartListAsText(ipList); pIS->getItemPartListAsText(ipList);
strFindReplace(fmt, "%ip", ipList); strFindReplace(fmt, "%ip", ipList);
strFindReplace(itemText, "%craft", fmt); strFindReplace(itemText, "%craft", fmt);
@ -2200,7 +2198,7 @@ static void setupRawMaterialStats(CSheetHelpSetup &setup)
if(pIS->canBuildItemPart(faberType)) if(pIS->canBuildItemPart(faberType))
{ {
pCB->addText(RM_FABER_TYPE::toLocalString(faberType).toUtf8()); pCB->addText(RM_FABER_TYPE::toLocalString(faberType));
} }
} }
@ -3165,7 +3163,7 @@ void setupListBrickHeader(CSheetHelpSetup &setup)
if(view) if(view)
{ {
view->setActive(true); view->setActive(true);
view->setTextFormatTaged(CI18N::get("uihelpPhraseHeaderBricks").toUtf8()); view->setTextFormatTaged(CI18N::get("uihelpPhraseHeaderBricks"));
} }
} }
@ -3473,7 +3471,7 @@ void setConsoModSuccessTooltip( CDBCtrlSheet *cs )
CInterfaceManager * pIM = CInterfaceManager::getInstance(); CInterfaceManager * pIM = CInterfaceManager::getInstance();
CCDBNodeLeaf * nodeSM = NULL; CCDBNodeLeaf * nodeSM = NULL;
ucstring ustr; string ustr;
if( CSheetId(cs->getSheetId()).toString() == "mod_melee_success.sbrick" ) if( CSheetId(cs->getSheetId()).toString() == "mod_melee_success.sbrick" )
{ {
ustr = CI18N::get("uittModMeleeSuccess"); ustr = CI18N::get("uittModMeleeSuccess");
@ -3588,7 +3586,7 @@ public:
CCDBNodeLeaf * node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:DEATH_XP_MALUS", false); CCDBNodeLeaf * node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:DEATH_XP_MALUS", false);
if( node ) if( node )
{ {
ucstring txt = CI18N::get("uittDeathPenalty"); string txt = CI18N::get("uittDeathPenalty");
strFindReplace(txt, "%dp", toString((100*node->getValue16())/254)); strFindReplace(txt, "%dp", toString((100*node->getValue16())/254));
CWidgetManager::getInstance()->setContextHelpText(txt); CWidgetManager::getInstance()->setContextHelpText(txt);
} }
@ -3597,7 +3595,7 @@ public:
else if( getAuraDisabledState(cs) ) else if( getAuraDisabledState(cs) )
{ {
// get the normal string, and append a short info. // get the normal string, and append a short info.
ucstring str; std::string str;
cs->getContextHelp(str); cs->getContextHelp(str);
str+= CI18N::get("uittAuraDisabled"); str+= CI18N::get("uittAuraDisabled");
@ -3630,7 +3628,7 @@ public:
CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:NAME", index)); CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:NAME", index));
if (node && CStringManagerClient::instance()->getDynString(node->getValue32(), txt)) if (node && CStringManagerClient::instance()->getDynString(node->getValue32(), txt))
{ {
CWidgetManager::getInstance()->setContextHelpText(CEntityCL::removeTitleFromName(txt)); CWidgetManager::getInstance()->setContextHelpText(CEntityCL::removeTitleFromName(txt).toUtf8());
} }
} }
}; };
@ -3676,7 +3674,7 @@ public:
str += toString(minTimeRemaining); str += toString(minTimeRemaining);
// replace the context help that is required. // replace the context help that is required.
CWidgetManager::getInstance()->setContextHelpText(str); CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
} }
}; };
REGISTER_ACTION_HANDLER( CHandlerAnimalDeadPopupTooltip, "animal_dead_popup_tooltip"); REGISTER_ACTION_HANDLER( CHandlerAnimalDeadPopupTooltip, "animal_dead_popup_tooltip");
@ -3838,7 +3836,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).toUtf8()); statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType));
if(statValue) if(statValue)
statValue->setValue(itemPart.Stats[i]); statValue->setValue(itemPart.Stats[i]);
} }

@ -2046,9 +2046,7 @@ class CHandlerItemMenuCheck : public IActionHandler
std::string name = groupNames[i]; std::string name = groupNames[i];
std::string ahParams = "name=" + name; std::string ahParams = "name=" + name;
//Use ucstring because group name can contain accentued characters (and stuff like that) //Use ucstring because group name can contain accentued characters (and stuff like that)
ucstring nameUC; pGroupMenu->addLine(name, "", "", name);
nameUC.fromUtf8(name);
pGroupMenu->addLine(nameUC, "", "", name);
CGroupSubMenu* pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam()); CGroupSubMenu* pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam());
pGroupMenu->setSubMenu(pGroupMenu->getNumLine()-1, pNewSubMenu); pGroupMenu->setSubMenu(pGroupMenu->getNumLine()-1, pNewSubMenu);
if(pNewSubMenu) if(pNewSubMenu)
@ -2074,7 +2072,7 @@ class CHandlerItemMenuCheck : public IActionHandler
{ {
//there is an offset of 1 because TInventory names are pet_animal1/2/3/4 //there is an offset of 1 because TInventory names are pet_animal1/2/3/4
std::string dst = toString("destination=pet_animal%d|", j + 1); std::string dst = toString("destination=pet_animal%d|", j + 1);
CViewTextMenu* tmp = pNewSubMenu->addLine(ucstring(pMoveToPa[j]->getHardText()),"item_group_move", dst + ahParams, name + toString("_pa%d", j + 1)); CViewTextMenu* tmp = pNewSubMenu->addLine(pMoveToPa[j]->getHardText(),"item_group_move", dst + ahParams, name + toString("_pa%d", j + 1));
if(tmp) tmp->setGrayed(pMoveToPa[j]->getGrayed()); if(tmp) tmp->setGrayed(pMoveToPa[j]->getGrayed());
} }
} }

@ -1668,7 +1668,7 @@ static DECLARE_INTERFACE_USER_FCT(getSPhraseName)
return false; return false;
sint sphraseId= (sint)args[0].getInteger(); sint sphraseId= (sint)args[0].getInteger();
CSPhraseManager *pPM= CSPhraseManager::getInstance(); CSPhraseManager *pPM= CSPhraseManager::getInstance();
result.setUCString(pPM->getPhrase(sphraseId).Name); result.setString(pPM->getPhrase(sphraseId).Name.toUtf8());
return true; return true;
} }
else else
@ -1699,7 +1699,7 @@ public:
else else
strFindReplace(str, "%comp", CI18N::get("uittPhraseCombatRestrictOK")); strFindReplace(str, "%comp", CI18N::get("uittPhraseCombatRestrictOK"));
CWidgetManager::getInstance()->setContextHelpText(str); CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
} }
}; };
REGISTER_ACTION_HANDLER( CHandlerCombatRestrictTooltip, "phrase_combat_restrict_tooltip"); REGISTER_ACTION_HANDLER( CHandlerCombatRestrictTooltip, "phrase_combat_restrict_tooltip");

@ -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).toUtf8()); statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType));
statTitle->setColor(usageColor); statTitle->setColor(usageColor);
} }
if(statValueBar) if(statValueBar)
@ -1812,7 +1812,7 @@ void CActionPhraseFaber::updateItemResult()
RM_FABER_STAT_TYPE::isMagicProtectStat(RM_FABER_STAT_TYPE::TRMStatType(i)) ) RM_FABER_STAT_TYPE::isMagicProtectStat(RM_FABER_STAT_TYPE::TRMStatType(i)) )
statToolTip->setDefaultContextHelp(CI18N::get("uiFaberStatActive")); statToolTip->setDefaultContextHelp(CI18N::get("uiFaberStatActive"));
else else
statToolTip->setDefaultContextHelp(ucstring()); statToolTip->setDefaultContextHelp(std::string());
} }
else else
statToolTip->setDefaultContextHelp(CI18N::get("uiFaberStatGrayed")); statToolTip->setDefaultContextHelp(CI18N::get("uiFaberStatGrayed"));

@ -189,7 +189,7 @@ void CBotChatPageDynamicMission::update()
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").toUtf8()); _ChoiceCB[k]->addText(NLMISC::CI18N::get("uiWaitingChoiceFromServer"));
} }
} }
} }

@ -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" ).toUtf8() ); priceLabel->setText( CI18N::get( "uiPrice" ) );
priceLabel->setActive(true); priceLabel->setActive(true);
} }
else else
@ -893,7 +893,7 @@ void CBotChatPageTrade::startBuyDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCall
{ {
confirmButton->setActive( true ); confirmButton->setActive( true );
// no need any context help because too simple // no need any context help because too simple
confirmButton->setDefaultContextHelp(ucstring()); confirmButton->setDefaultContextHelp(std::string());
if(isItem) if(isItem)
{ {
CItemSheet * itemSheet = dynamic_cast<CItemSheet*> ( SheetMngr.get( CSheetId( sheet->getSheetId() ) ) ); CItemSheet * itemSheet = dynamic_cast<CItemSheet*> ( SheetMngr.get( CSheetId( sheet->getSheetId() ) ) );
@ -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" ).toUtf8() ); priceLabel->setText( CI18N::get( "uiImmediatePrice" ) );
priceLabel->setActive(true); priceLabel->setActive(true);
} }
@ -2428,7 +2428,7 @@ public:
void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{ {
// \todo yoyo: for now disable tooltip // \todo yoyo: for now disable tooltip
CWidgetManager::getInstance()->setContextHelpText(ucstring()); CWidgetManager::getInstance()->setContextHelpText(std::string());
} }
}; };
REGISTER_ACTION_HANDLER(CHandlerBotChatTTItemType, "botchat_tt_item_type"); REGISTER_ACTION_HANDLER(CHandlerBotChatTTItemType, "botchat_tt_item_type");
@ -2575,11 +2575,11 @@ static DECLARE_INTERFACE_USER_FCT(getPriceWithFame)
sint value= (sint)args[0].getInteger(); sint value= (sint)args[0].getInteger();
sint valueFame= (sint)args[1].getInteger(); sint valueFame= (sint)args[1].getInteger();
if(value==-1) if(value==-1)
result.setUCString(CI18N::get("uiBadPrice")); result.setString(CI18N::get("uiBadPrice"));
else if(value==valueFame) else if(value==valueFame)
result.setUCString(NLMISC::formatThousands(toString(value))); result.setString(NLMISC::formatThousands(toString(value)));
else else
result.setUCString(NLMISC::formatThousands(toString(valueFame)) + " (" + NLMISC::formatThousands(toString(value)) + ")"); result.setString(NLMISC::formatThousands(toString(valueFame)) + " (" + NLMISC::formatThousands(toString(value)) + ")");
return true; return true;
} }
@ -2595,7 +2595,7 @@ static DECLARE_INTERFACE_USER_FCT(getBonusOnResale)
sint valueHigh= (sint)args[0].getInteger(); sint valueHigh= (sint)args[0].getInteger();
sint valueLow= (sint)args[1].getInteger(); sint valueLow= (sint)args[1].getInteger();
sint diff = valueHigh - valueLow; sint diff = valueHigh - valueLow;
result.setUCString("+" + NLMISC::formatThousands(toString(diff))); result.setString("+" + NLMISC::formatThousands(toString(diff)));
return true; return true;
} }

@ -349,13 +349,13 @@ void CChatWindow::enableBlink(uint numBlinks)
void CChatWindow::setCommand(const std::string &command, bool execute) void CChatWindow::setCommand(const std::string &command, bool execute)
{ {
if (!_EB) return; if (!_EB) return;
_EB->setCommand(ucstring(command), execute); _EB->setCommand(command, execute);
} }
void CChatWindow::setCommand(const ucstring &command,bool execute) void CChatWindow::setCommand(const ucstring &command,bool execute)
{ {
if (!_EB) return; if (!_EB) return;
_EB->setCommand(command, execute); _EB->setCommand(command.toUtf8(), execute);
} }
@ -472,25 +472,25 @@ void CChatWindow::setHeaderColor(const std::string &n)
//================================================================================= //=================================================================================
void CChatWindow::displayLocalPlayerTell(const ucstring &receiver, const ucstring &msg, uint numBlinks /*= 0*/) void CChatWindow::displayLocalPlayerTell(const ucstring &receiver, const ucstring &msg, uint numBlinks /*= 0*/)
{ {
ucstring finalMsg; string finalMsg;
CInterfaceProperty prop; CInterfaceProperty prop;
prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," ");
encodeColorTag(prop.getRGBA(), finalMsg, false); encodeColorTag(prop.getRGBA(), finalMsg, false);
ucstring csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); string csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : "");
finalMsg += csr + CI18N::get("youTell") + ": "; finalMsg += csr + CI18N::get("youTell") + ": ";
prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," ");
encodeColorTag(prop.getRGBA(), finalMsg, true); encodeColorTag(prop.getRGBA(), finalMsg, true);
finalMsg += msg; finalMsg += msg.toUtf8();
ucstring s = CI18N::get("youTellPlayer"); string s = CI18N::get("youTellPlayer");
strFindReplace(s, "%name", receiver); strFindReplace(s, "%name", receiver.toUtf8());
strFindReplace(finalMsg, CI18N::get("youTell"), s); strFindReplace(finalMsg, CI18N::get("youTell"), s);
displayMessage(finalMsg, prop.getRGBA(), CChatGroup::tell, 0, numBlinks); displayMessage(finalMsg, prop.getRGBA(), CChatGroup::tell, 0, numBlinks);
CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell)); CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell));
} }
void CChatWindow::encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, bool append) void CChatWindow::encodeColorTag(const NLMISC::CRGBA &color, std::string &text, bool append)
{ {
// WARNING : The lookup table MUST contains 17 element (with the last doubled) // WARNING : The lookup table MUST contains 17 element (with the last doubled)
// because we add 7 to the 8 bit color before shifting to right in order to match color // because we add 7 to the 8 bit color before shifting to right in order to match color
@ -498,8 +498,8 @@ void CChatWindow::encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, boo
// Have 17 entry remove the need for a %16 for each color component. // Have 17 entry remove the need for a %16 for each color component.
// By the way, this comment is more longer to type than to add the %16... // By the way, this comment is more longer to type than to add the %16...
// //
static ucchar ConvTable[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'F'}; static char ConvTable[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'F'};
ucstring str; string str;
if (append) if (append)
{ {
str.reserve(7 + str.size()); str.reserve(7 + str.size());
@ -1273,7 +1273,7 @@ public:
{ {
CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(pCaller); CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(pCaller);
if (pEB == NULL) return; if (pEB == NULL) return;
ucstring text = pEB->getInputStringAsUtf16(); string text = pEB->getInputString();
// If the line is empty, do nothing // If the line is empty, do nothing
if(text.empty()) if(text.empty())
return; return;
@ -1297,7 +1297,7 @@ public:
if(text[0] == '/') if(text[0] == '/')
{ {
CChatWindow::_ChatWindowLaunchingCommand = chat; CChatWindow::_ChatWindowLaunchingCommand = chat;
string str = text.toUtf8(); string str = text;
string cmdWithArgs = str.substr(1); string cmdWithArgs = str.substr(1);
// Get the command name from the string, can contain spaces // Get the command name from the string, can contain spaces

@ -156,7 +156,7 @@ public:
void displayLocalPlayerTell(const ucstring &receiver, const ucstring &msg, uint numBlinks = 0); void displayLocalPlayerTell(const ucstring &receiver, const ucstring &msg, uint numBlinks = 0);
/// Encode a color tag '@{RGBA}' in the text. If append is true, append at end of text, otherwise, replace the text /// Encode a color tag '@{RGBA}' in the text. If append is true, append at end of text, otherwise, replace the text
static void encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, bool append=true); static void encodeColorTag(const NLMISC::CRGBA &color, std::string &text, bool append=true);
/////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////
protected: protected:

@ -3373,13 +3373,13 @@ void CDBCtrlSheet::setupItemInfoWaiter()
} }
// *************************************************************************** // ***************************************************************************
void CDBCtrlSheet::getContextHelp(ucstring &help) const void CDBCtrlSheet::getContextHelp(std::string &help) const
{ {
if (getType() == CCtrlSheetInfo::SheetType_Skill) if (getType() == CCtrlSheetInfo::SheetType_Skill)
{ {
// just show the name of the skill // just show the name of the skill
// the sheet id is interpreted as a skill enum // the sheet id is interpreted as a skill enum
help= STRING_MANAGER::CStringManagerClient::getSkillLocalizedName( (SKILLS::ESkills)_SheetId.getSInt32() ); help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName( (SKILLS::ESkills)_SheetId.getSInt32() )).toUtf8();
} }
else if(getType() == CCtrlSheetInfo::SheetType_Macro) else if(getType() == CCtrlSheetInfo::SheetType_Macro)
{ {
@ -3392,7 +3392,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const
if (macroName.empty()) if (macroName.empty())
macroName = CI18N::get("uiNotAssigned"); macroName = CI18N::get("uiNotAssigned");
ucstring assignedTo = macro->Combo.toUCString(); ucstring assignedTo = macro->Combo.toString();
if (assignedTo.empty()) if (assignedTo.empty())
assignedTo = CI18N::get("uiNotAssigned"); assignedTo = CI18N::get("uiNotAssigned");
@ -3426,7 +3426,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const
strFindReplace(dispText, ucstring("%n"), macroName); strFindReplace(dispText, ucstring("%n"), macroName);
strFindReplace(dispText, ucstring("%k"), assignedTo); strFindReplace(dispText, ucstring("%k"), assignedTo);
strFindReplace(dispText, ucstring("%c"), dispCommands); strFindReplace(dispText, ucstring("%c"), dispCommands);
help = dispText; help = dispText.toUtf8();
} }
else if(getType() == CCtrlSheetInfo::SheetType_Item) else if(getType() == CCtrlSheetInfo::SheetType_Item)
{ {
@ -3437,10 +3437,10 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const
{ {
// call lua function to update tooltip window // call lua function to update tooltip window
_ItemInfoWaiter.sendRequest(); _ItemInfoWaiter.sendRequest();
help = _ItemInfoWaiter.infoValidated(); help = _ItemInfoWaiter.infoValidated().toUtf8();
// its expected to get at least item name back // its expected to get at least item name back
if (help.empty()) if (help.empty())
help = getItemActualName(); help = getItemActualName().toUtf8();
} }
else if (!_ContextHelp.empty()) else if (!_ContextHelp.empty())
{ {
@ -3448,7 +3448,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const
} }
else else
{ {
help = getItemActualName(); help = getItemActualName().toUtf8();;
} }
} }
else else
@ -3479,7 +3479,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const
CSBrickManager *pBM= CSBrickManager::getInstance(); CSBrickManager *pBM= CSBrickManager::getInstance();
CSBrickSheet *brick= pBM->getBrick(CSheetId(getSheetId())); CSBrickSheet *brick= pBM->getBrick(CSheetId(getSheetId()));
if(brick) if(brick)
help= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id); help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id)).toUtf8();
else else
help= _ContextHelp; help= _ContextHelp;
} }
@ -3488,7 +3488,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const
sint32 phraseId= getSheetId(); sint32 phraseId= getSheetId();
if (phraseId == 0) if (phraseId == 0)
{ {
help = ucstring(); help = std::string();
} }
else else
{ {
@ -3506,10 +3506,11 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const
game = game["game"]; game = game["game"];
game.callMethodByNameNoThrow("updatePhraseTooltip", 1, 1); game.callMethodByNameNoThrow("updatePhraseTooltip", 1, 1);
// retrieve result from stack // retrieve result from stack
help = ucstring(); ucstring tmpHelp;
if (!ls->empty()) if (!ls->empty())
{ {
CLuaIHM::pop(*ls, help); CLuaIHM::pop(*ls, tmpHelp); // FIXME: Lua UTF-8
help = tmpHelp.toUtf8();
} }
else else
{ {
@ -3542,7 +3543,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const
{ {
CSPhraseSheet *phrase= dynamic_cast<CSPhraseSheet*>(SheetMngr.get(CSheetId(getSheetId()))); CSPhraseSheet *phrase= dynamic_cast<CSPhraseSheet*>(SheetMngr.get(CSheetId(getSheetId())));
if(phrase) if(phrase)
help= STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id); help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id)).toUtf8();
else else
help= _ContextHelp; help= _ContextHelp;
} }
@ -3550,14 +3551,14 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const
{ {
const COutpostBuildingSheet *outpost = asOutpostBuildingSheet(); const COutpostBuildingSheet *outpost = asOutpostBuildingSheet();
if (outpost) if (outpost)
help = CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32())); help = CUtfStringView(CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32()))).toUtf8();
else else
help = _ContextHelp; help = _ContextHelp;
} }
} }
// *************************************************************************** // ***************************************************************************
void CDBCtrlSheet::getContextHelpToolTip(ucstring &help) const void CDBCtrlSheet::getContextHelpToolTip(std::string &help) const
{ {
// Special case for buff items and spell crystals, only for tooltips // Special case for buff items and spell crystals, only for tooltips
if (getType() == CCtrlSheetInfo::SheetType_Item) if (getType() == CCtrlSheetInfo::SheetType_Item)
@ -3568,7 +3569,7 @@ void CDBCtrlSheet::getContextHelpToolTip(ucstring &help) const
if (useItemInfoForFamily(item->Family)) if (useItemInfoForFamily(item->Family))
{ {
_ItemInfoWaiter.sendRequest(); _ItemInfoWaiter.sendRequest();
help = _ItemInfoWaiter.infoValidated(); help = _ItemInfoWaiter.infoValidated().toUtf8();
return; return;
} }
} }

@ -393,9 +393,9 @@ public:
NLMISC::CRGBA getSheetColor() const {return _SheetColor;} NLMISC::CRGBA getSheetColor() const {return _SheetColor;}
/// Special ContextHelp for ctrl sheet. /// Special ContextHelp for ctrl sheet.
virtual void getContextHelp(ucstring &help) const; virtual void getContextHelp(std::string &help) const;
virtual void getContextHelpToolTip(ucstring &help) const; virtual void getContextHelpToolTip(std::string &help) const;
/** true if an item of another ctrlSheet can be dropped on this slot. /** true if an item of another ctrlSheet can be dropped on this slot.

@ -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").toUtf8() ); word.InfoView->setText( CI18N::get("uiTextHelpSelectRootBrick") );
else else
// start effect index at 1 (human readable :) ) // start effect index at 1 (human readable :) )
word.InfoView->setText( CI18N::get("uiTextHelpSelectEffectBrick").toUtf8() + toString(i) ); word.InfoView->setText( CI18N::get("uiTextHelpSelectEffectBrick") + toString(i) );
} }
} }

@ -56,7 +56,7 @@ CViewText *CDBGroupListSheetMission::CSheetChildMission::createViewText() const
CViewTextIDFormated *vti = new CViewTextIDFormated(CViewBase::TCtorParam()); CViewTextIDFormated *vti = new CViewTextIDFormated(CViewBase::TCtorParam());
if (Ctrl) vti->setDBLeaf(dynamic_cast<CCDBNodeLeaf *>(Ctrl->getRootBranch()->getNode(ICDBNode::CTextId("TEXT")))); if (Ctrl) vti->setDBLeaf(dynamic_cast<CCDBNodeLeaf *>(Ctrl->getRootBranch()->getNode(ICDBNode::CTextId("TEXT"))));
else vti->setDBLeaf(NULL); else vti->setDBLeaf(NULL);
vti->setFormatString(ucstring("$t")); vti->setFormatString("$t");
return vti; return vti;
} }

@ -1051,7 +1051,7 @@ void CDBGroupListSheetText::CSheetChild::updateViewTextAsItem()
if(Ctrl && Text && Ctrl->getSheetCategory() == CDBCtrlSheet::Item) if(Ctrl && Text && Ctrl->getSheetCategory() == CDBCtrlSheet::Item)
{ {
// get the text // get the text
ucstring text; std::string text;
Ctrl->getContextHelp(text); Ctrl->getContextHelp(text);
// Text color red if requirement not met // Text color red if requirement not met
@ -1070,7 +1070,7 @@ void CDBGroupListSheetText::CSheetChild::updateViewTextAsItem()
// Add craft info for MP // Add craft info for MP
if(pIS->Family==ITEMFAMILY::RAW_MATERIAL) if(pIS->Family==ITEMFAMILY::RAW_MATERIAL)
{ {
ucstring ipList; string ipList;
pIS->getItemPartListAsText(ipList); pIS->getItemPartListAsText(ipList);
if(ipList.empty()) if(ipList.empty())
{ {
@ -1086,7 +1086,7 @@ void CDBGroupListSheetText::CSheetChild::updateViewTextAsItem()
} }
// set text // set text
Text->setTextFormatTaged(text.toUtf8()); Text->setTextFormatTaged(text);
} }
} }

@ -133,9 +133,9 @@ public:
// Called at updateCoords to remake the text // Called at updateCoords to remake the text
virtual void updateViewText(CDBGroupListSheetText * /* pFather */) virtual void updateViewText(CDBGroupListSheetText * /* pFather */)
{ {
ucstring text; std::string text;
Ctrl->getContextHelp(text); Ctrl->getContextHelp(text);
Text->setText(text.toUtf8()); Text->setText(text);
} }
// 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

@ -77,7 +77,7 @@ void CDBGroupListSheetTextPhrase::CSheetChildPhrase::init(CDBGroupListSheetText
// *************************************************************************** // ***************************************************************************
void CDBGroupListSheetTextPhrase::CSheetChildPhrase::updateViewText(CDBGroupListSheetText * /* pFather */) void CDBGroupListSheetTextPhrase::CSheetChildPhrase::updateViewText(CDBGroupListSheetText * /* pFather */)
{ {
ucstring text; std::string text;
if(Ctrl->getType()!=CCtrlSheetInfo::SheetType_SPhrase) if(Ctrl->getType()!=CCtrlSheetInfo::SheetType_SPhrase)
return; return;
@ -87,14 +87,14 @@ void CDBGroupListSheetTextPhrase::CSheetChildPhrase::updateViewText(CDBGroupList
// append the level if possible // append the level if possible
if(LevelDB) if(LevelDB)
{ {
ucstring fmt= CI18N::get("uiPhraseLevelFmt"); std::string fmt= CI18N::get("uiPhraseLevelFmt").toUtf8();
strFindReplace(fmt, "%d", toString(LevelCache)); strFindReplace(fmt, "%d", toString(LevelCache));
text+= "\n" + fmt; text+= "\n" + fmt;
} }
#endif #endif
// set // set
Text->setText(text.toUtf8()); Text->setText(text);
} }

@ -41,14 +41,14 @@ CDBGroupListSheetTextPhraseId::CSheetChildPhrase::CSheetChildPhrase()
// *************************************************************************** // ***************************************************************************
void CDBGroupListSheetTextPhraseId::CSheetChildPhrase::updateViewText(CDBGroupListSheetText * /* pFather */) void CDBGroupListSheetTextPhraseId::CSheetChildPhrase::updateViewText(CDBGroupListSheetText * /* pFather */)
{ {
ucstring text; std::string text;
if(Ctrl->getType()!=CCtrlSheetInfo::SheetType_SPhraseId) if(Ctrl->getType()!=CCtrlSheetInfo::SheetType_SPhraseId)
return; return;
// Get the User Name of the phrase // Get the User Name of the phrase
Ctrl->getContextHelp(text); Ctrl->getContextHelp(text);
Text->setText(text.toUtf8()); Text->setText(text);
} }
// *************************************************************************** // ***************************************************************************

@ -248,7 +248,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::update(CDBGroupListSheetText *pFa
void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetText *pFather) void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetText *pFather)
{ {
H_AUTO(CDBGroupListSheetTrade_updateViewText); H_AUTO(CDBGroupListSheetTrade_updateViewText);
ucstring text; std::string text;
Ctrl->getContextHelp(text); Ctrl->getContextHelp(text);
// Append first the type of the sheet to select // Append first the type of the sheet to select
switch ( Ctrl->getSheetCategory() ) switch ( Ctrl->getSheetCategory() )
@ -268,7 +268,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT
if (pOBS != NULL) if (pOBS != NULL)
{ {
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
text += string("\n") + pSMC->getOutpostBuildingLocalizedDescription(CSheetId(Ctrl->getSheetId())); text += string("\n") + CUtfStringView(pSMC->getOutpostBuildingLocalizedDescription(CSheetId(Ctrl->getSheetId()))).toUtf8();
text += "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(pOBS->CostDapper)); text += "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(pOBS->CostDapper));
text += CI18N::get("uiBotChatTime") + toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute"); text += CI18N::get("uiBotChatTime") + toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute");
if ((pOBS->CostTime % 60) != 0) if ((pOBS->CostTime % 60) != 0)
@ -285,15 +285,15 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT
bool melee,range; bool melee,range;
pPM->getCombatWeaponRestriction(weaponRestriction, Ctrl->getSheetId(),melee,range); pPM->getCombatWeaponRestriction(weaponRestriction, Ctrl->getSheetId(),melee,range);
// don't add also if no combat restriction // don't add also if no combat restriction
if(!weaponRestriction.empty() && weaponRestriction!=CI18N::get("uiawrSF")) if(!weaponRestriction.empty() && weaponRestriction!=CI18N::getAsUtf16("uiawrSF"))
{ {
weaponRestriction= CI18N::get("uiPhraseWRHeader") + weaponRestriction; weaponRestriction= CI18N::get("uiPhraseWRHeader") + weaponRestriction;
text+= "\n" + weaponRestriction; text+= "\n" + weaponRestriction.toUtf8();
} }
} }
// Get the Text color // Get the Text color
ucstring colorTag("@{FFFF}"); std::string colorTag("@{FFFF}");
if(Ctrl->getType() == CCtrlSheetInfo::SheetType_Item) if(Ctrl->getType() == CCtrlSheetInfo::SheetType_Item)
{ {
if(!Ctrl->checkItemRequirement()) if(!Ctrl->checkItemRequirement())
@ -309,7 +309,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT
// Add craft info for MP // Add craft info for MP
if(pIS->Family==ITEMFAMILY::RAW_MATERIAL) if(pIS->Family==ITEMFAMILY::RAW_MATERIAL)
{ {
ucstring ipList; string ipList;
pIS->getItemPartListAsText(ipList); pIS->getItemPartListAsText(ipList);
if(ipList.empty()) if(ipList.empty())
{ {
@ -412,7 +412,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT
else else
text+= CI18N::get("uiBotChatRetirePrice") + NLMISC::formatThousands(toString(factor * LastPriceRetire)); text+= CI18N::get("uiBotChatRetirePrice") + NLMISC::formatThousands(toString(factor * LastPriceRetire));
// set resale time left // set resale time left
ucstring fmt= CI18N::get("uiBotChatResaleTimeLeft"); std::string fmt= CI18N::get("uiBotChatResaleTimeLeft");
strFindReplace(fmt, "%d", toString(LastResaleTimeLeft/RYZOM_DAY_IN_HOUR)); strFindReplace(fmt, "%d", toString(LastResaleTimeLeft/RYZOM_DAY_IN_HOUR));
strFindReplace(fmt, "%h", toString(LastResaleTimeLeft%RYZOM_DAY_IN_HOUR)); strFindReplace(fmt, "%h", toString(LastResaleTimeLeft%RYZOM_DAY_IN_HOUR));
text+= "\n" + fmt; text+= "\n" + fmt;
@ -431,7 +431,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT
// else display the name of the vendor (not if this is the player himself, to avoid flood) // else display the name of the vendor (not if this is the player himself, to avoid flood)
else if (LastSellerType == BOTCHATTYPE::Resale) else if (LastSellerType == BOTCHATTYPE::Resale)
{ {
text+= "\n" + CI18N::get("uiBotChatVendorTag") + VendorNameString; text+= "\n" + CI18N::get("uiBotChatVendorTag") + VendorNameString.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.toUtf8()); Text->setTextFormatTaged(text);
} }
// *************************************************************************** // ***************************************************************************

@ -205,7 +205,7 @@ void CEncyclopediaManager::rebuildAlbumList()
if (_Albums[i].Name == _AlbumNameSelected) if (_Albums[i].Name == _AlbumNameSelected)
pAlb->Opened = true; pAlb->Opened = true;
if (pSMC->getDynString(_Albums[i].Name, res)) if (pSMC->getDynString(_Albums[i].Name, res))
pAlb->Text = res; pAlb->Text = res.toUtf8();
else else
nlwarning("try to construct album without name"); nlwarning("try to construct album without name");
@ -217,7 +217,7 @@ void CEncyclopediaManager::rebuildAlbumList()
pThm->AHName = "ency_click_thema"; pThm->AHName = "ency_click_thema";
pThm->AHParams = toString(_Albums[i].Themas[j].Name); pThm->AHParams = toString(_Albums[i].Themas[j].Name);
if (pSMC->getDynString(_Albums[i].Themas[j].Name, res)) if (pSMC->getDynString(_Albums[i].Themas[j].Name, res))
pThm->Text = res; pThm->Text = res.toUtf8();
else else
nlwarning("try to construct thema without name"); nlwarning("try to construct thema without name");

@ -424,11 +424,10 @@ void CGroupCompas::draw()
CCtrlBase *toolTip = getCtrl("tt"); CCtrlBase *toolTip = getCtrl("tt");
if (toolTip) if (toolTip)
{ {
ucstring text;
if (displayedTarget.getType() != CCompassTarget::North) if (displayedTarget.getType() != CCompassTarget::North)
toolTip->setDefaultContextHelp(CI18N::get("uittCompassDistance")); toolTip->setDefaultContextHelp(CI18N::get("uittCompassDistance"));
else else
toolTip->setDefaultContextHelp(text); toolTip->setDefaultContextHelp(std::string());
} }
if (displayedTarget.Name != _CurrTargetName) if (displayedTarget.Name != _CurrTargetName)
@ -711,7 +710,7 @@ void CGroupCompasMenu::setActive (bool state)
ct.setType(CCompassTarget::North); ct.setType(CCompassTarget::North);
ct.Name = CI18N::get("uiNorth"); ct.Name = CI18N::get("uiNorth");
Targets.push_back(ct); Targets.push_back(ct);
getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name, "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name.toUtf8(), "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str()));
// Home // Home
CCDBNodeLeaf *pos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":HOME_POINT"); CCDBNodeLeaf *pos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":HOME_POINT");
sint32 px = (sint32) (pos->getValue64() >> 32); sint32 px = (sint32) (pos->getValue64() >> 32);
@ -721,7 +720,7 @@ void CGroupCompasMenu::setActive (bool state)
ct.setType(CCompassTarget::Home); ct.setType(CCompassTarget::Home);
ct.Name = CI18N::get("uiHome"); ct.Name = CI18N::get("uiHome");
Targets.push_back(ct); Targets.push_back(ct);
getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name, "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name.toUtf8(), "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str()));
} }
// Respawn // Respawn
pos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":BIND_POINT"); pos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":BIND_POINT");
@ -732,7 +731,7 @@ void CGroupCompasMenu::setActive (bool state)
ct.setType(CCompassTarget::Respawn); ct.setType(CCompassTarget::Respawn);
ct.Name = CI18N::get("uiRespawn"); ct.Name = CI18N::get("uiRespawn");
Targets.push_back(ct); Targets.push_back(ct);
getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name, "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name.toUtf8(), "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str()));
} }
// As of 6/5/2007 : The option to point the selection is always proposed even if no slot is currently targeted // As of 6/5/2007 : The option to point the selection is always proposed even if no slot is currently targeted
@ -742,7 +741,7 @@ void CGroupCompasMenu::setActive (bool state)
if (entity != NULL) if (entity != NULL)
{*/ {*/
//ucstring targetName = CI18N::get("uiTargetTwoPoint") + entity->removeTitleAndShardFromName(entity->getEntityName()); //ucstring targetName = CI18N::get("uiTargetTwoPoint") + entity->removeTitleAndShardFromName(entity->getEntityName());
ucstring targetName = CI18N::get("uiTarget"); std::string targetName = CI18N::get("uiTarget");
ct.setType(CCompassTarget::Selection); ct.setType(CCompassTarget::Selection);
ct.Name = targetName; ct.Name = targetName;
Targets.push_back(ct); Targets.push_back(ct);
@ -790,7 +789,7 @@ void CGroupCompasMenu::setActive (bool state)
ct.setPositionState(tracker); ct.setPositionState(tracker);
ct.Name = name; ct.Name = name;
Targets.push_back(ct); Targets.push_back(ct);
missionSubMenu->addLine(ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); missionSubMenu->addLine(ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str()));
selectable= true; selectable= true;
} }
} }
@ -847,7 +846,7 @@ void CGroupCompasMenu::setActive (bool state)
ct.Pos = currCont->ContLandMarks[k].Pos; ct.Pos = currCont->ContLandMarks[k].Pos;
ct.Name = CStringManagerClient::getPlaceLocalizedName(currCont->ContLandMarks[k].TitleTextID); ct.Name = CStringManagerClient::getPlaceLocalizedName(currCont->ContLandMarks[k].TitleTextID);
Targets.push_back(ct); Targets.push_back(ct);
landMarkSubMenu->addLineAtIndex(contLandMarkIndex++, ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); landMarkSubMenu->addLineAtIndex(contLandMarkIndex++, ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str()));
selectable= true; selectable= true;
} }
// separator? // separator?
@ -870,7 +869,7 @@ void CGroupCompasMenu::setActive (bool state)
ct.Pos = sortedLandmarks[k].Pos; ct.Pos = sortedLandmarks[k].Pos;
ct.Name = sortedLandmarks[k].Title; ct.Name = sortedLandmarks[k].Title;
Targets.push_back(ct); Targets.push_back(ct);
landMarkSubMenus[sortedLandmarks[k].Type]->addLine(ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); landMarkSubMenus[sortedLandmarks[k].Type]->addLine(ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str()));
selectable= true; selectable= true;
} }
} }
@ -901,7 +900,7 @@ void CGroupCompasMenu::setActive (bool state)
if (buildCompassTargetFromTeamMember(ct, k)) if (buildCompassTargetFromTeamMember(ct, k))
{ {
Targets.push_back(ct); Targets.push_back(ct);
teamSubMenu->addLine(ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); teamSubMenu->addLine(ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str()));
selectable= true; selectable= true;
} }
} }
@ -924,7 +923,7 @@ void CGroupCompasMenu::setActive (bool state)
if (buildCompassTargetFromAnimalMember(ct, k)) if (buildCompassTargetFromAnimalMember(ct, k))
{ {
Targets.push_back(ct); Targets.push_back(ct);
animalSubMenu->addLine(ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); animalSubMenu->addLine(ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str()));
selectable= true; selectable= true;
} }
} }
@ -952,7 +951,7 @@ void CGroupCompasMenu::setActive (bool state)
CSmartPtr<CDialogEntityPositionState> tracker = new CDialogEntityPositionState( i ); CSmartPtr<CDialogEntityPositionState> tracker = new CDialogEntityPositionState( i );
ct.setPositionState(tracker); ct.setPositionState(tracker);
Targets.push_back(ct); Targets.push_back(ct);
dialogsSubMenu->addLine(ct.Name, "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); dialogsSubMenu->addLine(ct.Name.toUtf8(), "set_compas", toString("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str()));
selectable= true; selectable= true;
} }
} }

@ -759,7 +759,7 @@ CGroupInSceneBubbleManager::CPopupContext *CGroupInSceneBubbleManager::buildCont
void CGroupInSceneBubbleManager::addContextHelp (const ucstring &message, const string &targetName, uint time) void CGroupInSceneBubbleManager::addContextHelp (const ucstring &message, const string &targetName, uint time)
{ {
ucstring finalMessage = message; std::string finalMessage = message.toUtf8();
CInterfaceElement *target; CInterfaceElement *target;
CPopupContext *context = CGroupInSceneBubbleManager::buildContextHelp ("context_help_", targetName, target, time); CPopupContext *context = CGroupInSceneBubbleManager::buildContextHelp ("context_help_", targetName, target, time);
if (context) if (context)
@ -787,7 +787,7 @@ void CGroupInSceneBubbleManager::addContextHelp (const ucstring &message, const
} }
} }
text->setText(finalMessage.toUtf8()); text->setText(finalMessage);
} }
} }
context->Group->setActive(true); context->Group->setActive(true);

@ -1122,7 +1122,7 @@ void CGroupInSceneUserInfo::updateDynamicData ()
{ {
CInterfaceGroup *group = getGroup ("right"); CInterfaceGroup *group = getGroup ("right");
CForageSourceCL *forageSource = static_cast<CForageSourceCL*>(_Entity); CForageSourceCL *forageSource = static_cast<CForageSourceCL*>(_Entity);
ucstring txt( CI18N::get( "uittForageContent" ) + toString( ": %u", forageSource->getCurrentQuantity() ) ); string txt( CI18N::get( "uittForageContent" ) + toString( ": %u", forageSource->getCurrentQuantity() ) );
CCtrlBase *toolTip = group->getCtrl ("tt1"); CCtrlBase *toolTip = group->getCtrl ("tt1");
if ( toolTip ) if ( toolTip )
toolTip->setDefaultContextHelp( txt ); toolTip->setDefaultContextHelp( txt );

@ -1179,7 +1179,7 @@ void CGroupMap::checkCoords()
ucstring result; ucstring result;
if (STRING_MANAGER::CStringManagerClient::instance()->getDynString(_MissionTargetTextIDs[k], result)) if (STRING_MANAGER::CStringManagerClient::instance()->getDynString(_MissionTargetTextIDs[k], result))
{ {
_MissionLM[k]->setDefaultContextHelp(result); _MissionLM[k]->setDefaultContextHelp(result.toUtf8());
_MissionTargetTextReceived[k] = true; _MissionTargetTextReceived[k] = true;
} }
} }
@ -1201,7 +1201,7 @@ void CGroupMap::checkCoords()
CEntityCL *sel = EntitiesMngr.entity(UserEntity->selection()); CEntityCL *sel = EntitiesMngr.entity(UserEntity->selection());
if (sel) if (sel)
{ {
_TargetLM->setDefaultContextHelp(NLMISC::CI18N::get("uiTargetTwoPoint") + sel->removeTitleAndShardFromName(sel->getEntityName())); _TargetLM->setDefaultContextHelp(NLMISC::CI18N::get("uiTargetTwoPoint") + sel->removeTitleAndShardFromName(sel->getEntityName()).toUtf8());
} }
} }
} }
@ -1368,7 +1368,7 @@ void CGroupMap::checkCoords()
if (pSMC->getString(val,res)) if (pSMC->getString(val,res))
{ {
res = CEntityCL::removeTitleAndShardFromName(res); res = CEntityCL::removeTitleAndShardFromName(res);
_TeammateLM[i]->setDefaultContextHelp(res); _TeammateLM[i]->setDefaultContextHelp(res.toUtf8());
} }
} }
updateLMPosFromDBPos(_TeammateLM[i], px, py); updateLMPosFromDBPos(_TeammateLM[i], px, py);
@ -2723,7 +2723,7 @@ void CGroupMap::addLandMark(TLandMarkButtonVect &destList, const NLMISC::CVector
CLandMarkButton *lmb = createLandMarkButton(options); CLandMarkButton *lmb = createLandMarkButton(options);
lmb->setParent(this); lmb->setParent(this);
lmb->Pos = pos; lmb->Pos = pos;
lmb->setDefaultContextHelp(title); lmb->setDefaultContextHelp(title.toUtf8());
destList.push_back(lmb); destList.push_back(lmb);
addCtrl(lmb); addCtrl(lmb);
} }
@ -2805,7 +2805,7 @@ void CGroupMap::updateUserLandMark(CCtrlButton *button, const ucstring &newTitle
_CurContinent->UserLandMarks[k].Type = (uint8)lmType; _CurContinent->UserLandMarks[k].Type = (uint8)lmType;
updateLandMarkButton(_UserLM[k], getUserLandMarkOptions(k)); updateLandMarkButton(_UserLM[k], getUserLandMarkOptions(k));
button->setDefaultContextHelp(newTitle); button->setDefaultContextHelp(newTitle.toUtf8());
CInterfaceManager::getInstance()->saveLandmarks(); CInterfaceManager::getInstance()->saveLandmarks();
return; return;
@ -3067,7 +3067,7 @@ void CGroupMap::targetLandmark(CCtrlButton *lm)
if (it != _ContinentLM.end()) if (it != _ContinentLM.end())
{ {
ct.setType(CCompassTarget::ContinentLandMark); ct.setType(CCompassTarget::ContinentLandMark);
(*it)->getContextHelp(ct.Name); (*it)->getContextHelpAsUtf16(ct.Name);
mapToWorld(ct.Pos, (*it)->Pos); mapToWorld(ct.Pos, (*it)->Pos);
found = true; found = true;
} }
@ -3080,7 +3080,7 @@ void CGroupMap::targetLandmark(CCtrlButton *lm)
if (it != _MissionLM.end()) if (it != _MissionLM.end())
{ {
ct.setPositionState(_MissionPosStates[it - _MissionLM.begin()]); ct.setPositionState(_MissionPosStates[it - _MissionLM.begin()]);
(*it)->getContextHelp(ct.Name); (*it)->getContextHelpAsUtf16(ct.Name);
mapToWorld(ct.Pos, (*it)->Pos); mapToWorld(ct.Pos, (*it)->Pos);
found = true; found = true;
} }
@ -3094,7 +3094,7 @@ void CGroupMap::targetLandmark(CCtrlButton *lm)
if (it != _UserLM.end()) if (it != _UserLM.end())
{ {
ct.setType(CCompassTarget::UserLandMark); ct.setType(CCompassTarget::UserLandMark);
(*it)->getContextHelp(ct.Name); (*it)->getContextHelpAsUtf16(ct.Name);
mapToWorld(ct.Pos, (*it)->Pos); mapToWorld(ct.Pos, (*it)->Pos);
found = true; found = true;
} }
@ -3122,7 +3122,7 @@ void CGroupMap::targetLandmark(CCtrlButton *lm)
if (!isIsland()) if (!isIsland())
{ {
ct.setType(CCompassTarget::Respawn); ct.setType(CCompassTarget::Respawn);
(*it)->getContextHelp(ct.Name); (*it)->getContextHelpAsUtf16(ct.Name);
mapToWorld(ct.Pos, (*it)->Pos); mapToWorld(ct.Pos, (*it)->Pos);
found = true; found = true;
} }
@ -3168,7 +3168,7 @@ void CGroupMap::targetLandmark(CCtrlButton *lm)
{ {
if(_AnimalLM[i]==lm) if(_AnimalLM[i]==lm)
{ {
_AnimalLM[i]->getContextHelp(ct.Name); _AnimalLM[i]->getContextHelpAsUtf16(ct.Name);
// copy The Animal Pos retriever into the compass // copy The Animal Pos retriever into the compass
ct.setPositionState(_AnimalPosStates[i]); ct.setPositionState(_AnimalPosStates[i]);
found = true; found = true;
@ -3186,7 +3186,7 @@ void CGroupMap::targetLandmark(CCtrlButton *lm)
{ {
if(_TeammateLM[i]==lm) if(_TeammateLM[i]==lm)
{ {
_TeammateLM[i]->getContextHelp(ct.Name); _TeammateLM[i]->getContextHelpAsUtf16(ct.Name);
// copy The Animal Pos retriever into the compass // copy The Animal Pos retriever into the compass
ct.setPositionState(_TeammatePosStates[i]); ct.setPositionState(_TeammatePosStates[i]);
found = true; found = true;
@ -3248,7 +3248,7 @@ CGroupMap::CLandMarkButton* CGroupMap::findClosestLandmark(const CVector2f &cent
for(TLandMarkButtonVect::const_iterator it = landmarks.begin(); it != landmarks.end(); ++it) for(TLandMarkButtonVect::const_iterator it = landmarks.begin(); it != landmarks.end(); ++it)
{ {
ucstring lc; ucstring lc;
(*it)->getContextHelp(lc); (*it)->getContextHelpAsUtf16(lc);
if(filterLandmark(lc, keywords, startsWith)) { if(filterLandmark(lc, keywords, startsWith)) {
CVector2f pos; CVector2f pos;
mapToWorld(pos, (*it)->Pos); mapToWorld(pos, (*it)->Pos);
@ -3310,7 +3310,7 @@ bool CGroupMap::targetLandmarkByName(const ucstring &search, bool startsWith) co
{ {
ct.setType(CCompassTarget::UserLandMark); ct.setType(CCompassTarget::UserLandMark);
mapToWorld(ct.Pos, lm->Pos); mapToWorld(ct.Pos, lm->Pos);
lm->getContextHelp(ct.Name); lm->getContextHelpAsUtf16(ct.Name);
closest = dist; closest = dist;
found = true; found = true;
} }
@ -3323,7 +3323,7 @@ bool CGroupMap::targetLandmarkByName(const ucstring &search, bool startsWith) co
{ {
ct.setType(CCompassTarget::ContinentLandMark); ct.setType(CCompassTarget::ContinentLandMark);
mapToWorld(ct.Pos, lm->Pos); mapToWorld(ct.Pos, lm->Pos);
lm->getContextHelp(ct.Name); lm->getContextHelpAsUtf16(ct.Name);
closest = dist; closest = dist;
found = true; found = true;
} }
@ -3647,7 +3647,7 @@ void CGroupMap::updateClosestLandMarkMenu(const std::string &menu, const NLMISC:
std::string lineId = toString("%s:lmcosest%d", menu.c_str(), i); std::string lineId = toString("%s:lmcosest%d", menu.c_str(), i);
std::string ahParams = toString("type=user|map=%s|index=%d", _Id.c_str(), index); std::string ahParams = toString("type=user|map=%s|index=%d", _Id.c_str(), index);
CViewTextMenu* vt = rootMenu->addLine(ucstring(""), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false); CViewTextMenu* vt = rootMenu->addLine(std::string(), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false);
if (!vt) break; if (!vt) break;
vt->setSingleLineTextFormatTaged(name.toUtf8()); vt->setSingleLineTextFormatTaged(name.toUtf8());

@ -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().toUtf8()); if (pVT != NULL) pVT->setText(Combo.toString());
// Check if in use // Check if in use
CActionsManager *pCurAM = NULL; CActionsManager *pCurAM = NULL;

@ -224,7 +224,7 @@ void CGroupPhraseSkillFilter::rebuild()
// just text // just text
pNode->DisplayText = true; pNode->DisplayText = true;
pNode->Template = NULL; pNode->Template = NULL;
pNode->Text= STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i);; pNode->Text = CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i)).toUtf8();
// Action handler? // Action handler?
if(!_AHCtrlNode.empty()) if(!_AHCtrlNode.empty())

@ -244,7 +244,7 @@ void CGroupQuickHelp::beginElement(CHtmlElement &elm)
CActionsManager::TActionComboMap::const_iterator ite = actionCombo.find (CAction::CName (elm.getAttribute("z_action_shortcut").c_str(), params.c_str())); CActionsManager::TActionComboMap::const_iterator ite = actionCombo.find (CAction::CName (elm.getAttribute("z_action_shortcut").c_str(), params.c_str()));
if (ite != actionCombo.end()) if (ite != actionCombo.end())
{ {
addString (ite->second.toUCString()); addString (ite->second.toString());
} }
} }
} }

@ -245,11 +245,11 @@ static DECLARE_INTERFACE_USER_FCT(getSkillBaseText)
if(skillValue!=skillBase) if(skillValue!=skillBase)
{ {
result.setUCString( toString("(%d)", skillBase) ); result.setString( toString("(%d)", skillBase) );
} }
else else
{ {
result.setUCString( ucstring() ); result.setString( std::string() );
} }
return true; return true;
@ -335,7 +335,7 @@ void CGroupSkills::createAllTreeNodes()
// local variable (avoid realloc in loop) // local variable (avoid realloc in loop)
vector< pair<string, string> > tempVec(2); vector< pair<string, string> > tempVec(2);
ucstring sSkillName; string sSkillName;
while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop
{ {
@ -365,7 +365,7 @@ void CGroupSkills::createAllTreeNodes()
pNode->Id = NLMISC::toString(i); pNode->Id = NLMISC::toString(i);
// get Skill Name // get Skill Name
sSkillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i); sSkillName = CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i)).toUtf8();
// just text or template? // just text or template?
if(_TemplateSkill.empty()) if(_TemplateSkill.empty())
@ -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.toUtf8()); pViewSkillName->setText (sSkillName);
// 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)

@ -837,13 +837,13 @@ class CAHGuildSheetOpen : public IActionHandler
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").toUtf8()); pViewGrade->setText (CI18N::get("uiGuildLeader"));
else if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::HighOfficer) else if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::HighOfficer)
pViewGrade->setText (CI18N::get("uiGuildHighOfficer").toUtf8()); pViewGrade->setText (CI18N::get("uiGuildHighOfficer"));
else if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::Officer) else if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::Officer)
pViewGrade->setText (CI18N::get("uiGuildOfficer").toUtf8()); pViewGrade->setText (CI18N::get("uiGuildOfficer"));
else else
pViewGrade->setText (CI18N::get("uiGuildMember").toUtf8()); pViewGrade->setText (CI18N::get("uiGuildMember"));
} }
// online? // online?

@ -176,7 +176,7 @@ static DECLARE_INTERFACE_USER_FCT(getCompassText)
"uiWNW", "uiWNW",
}; };
result.setUCString( CI18N::get(txts[direction]) ); result.setString( CI18N::get(txts[direction]) );
return true; return true;
} }
REGISTER_INTERFACE_USER_FCT("getCompassText", getCompassText); REGISTER_INTERFACE_USER_FCT("getCompassText", getCompassText);
@ -251,7 +251,7 @@ static DECLARE_INTERFACE_USER_FCT(getDifficultyText)
} }
SENTENCE_APPRAISAL::ESentenceAppraisal sa = (SENTENCE_APPRAISAL::ESentenceAppraisal)args[0].getInteger(); SENTENCE_APPRAISAL::ESentenceAppraisal sa = (SENTENCE_APPRAISAL::ESentenceAppraisal)args[0].getInteger();
result.setUCString (CI18N::get(SENTENCE_APPRAISAL::toString(sa))); result.setString (CI18N::get(SENTENCE_APPRAISAL::toString(sa)));
return true; return true;
} }
@ -665,14 +665,14 @@ static DECLARE_INTERFACE_USER_FCT(getKey)
CActionsManager::TActionComboMap::const_iterator it = acmap.find(CAction::CName(name.c_str(),param.c_str())); CActionsManager::TActionComboMap::const_iterator it = acmap.find(CAction::CName(name.c_str(),param.c_str()));
if (it != acmap.end()) if (it != acmap.end())
{ {
result.setUCString (it->second.toUCString()); result.setString (it->second.toString());
} }
else else
{ {
if (notna) if (notna)
result.setUCString (ucstring("")); result.setString (std::string());
else else
result.setUCString (CI18N::get("uiNotAssigned")); result.setString (CI18N::get("uiNotAssigned"));
} }
return true; return true;
@ -1008,9 +1008,9 @@ static DECLARE_INTERFACE_USER_FCT(getBotChatBuyFilterMPText)
RM_FABER_TYPE::TRMFType faberType= (RM_FABER_TYPE::TRMFType)args[0].getInteger(); RM_FABER_TYPE::TRMFType faberType= (RM_FABER_TYPE::TRMFType)args[0].getInteger();
if(faberType>=RM_FABER_TYPE::Unknown) if(faberType>=RM_FABER_TYPE::Unknown)
result.setUCString(CI18N::get("uittBCNoItemPartFilter")); result.setString(CI18N::get("uittBCNoItemPartFilter"));
else else
result.setUCString(RM_FABER_TYPE::toLocalString(faberType)); result.setString(RM_FABER_TYPE::toLocalString(faberType));
return true; return true;
} }
@ -1059,15 +1059,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostName)
uint32 nSheet = (uint32)args[0].getInteger(); uint32 nSheet = (uint32)args[0].getInteger();
if (nSheet == 0) if (nSheet == 0)
{ {
result.setUCString(string("")); result.setString(string());
return true; return true;
} }
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
const ucstring name(pSMC->getOutpostLocalizedName(CSheetId(nSheet))); const std::string name = CUtfStringView(pSMC->getOutpostLocalizedName(CSheetId(nSheet))).toUtf8();
result.setUCString(name); result.setString(name);
return true; return true;
} }
@ -1086,15 +1086,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostDesc)
uint32 nSheet = (uint32)args[0].getInteger(); uint32 nSheet = (uint32)args[0].getInteger();
if (nSheet == 0) if (nSheet == 0)
{ {
result.setUCString(string("")); result.setString(string());
return true; return true;
} }
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
const ucstring name(pSMC->getOutpostLocalizedDescription(CSheetId(nSheet))); const string name = CUtfStringView(pSMC->getOutpostLocalizedDescription(CSheetId(nSheet))).toUtf8();
result.setUCString(name); result.setString(name);
return true; return true;
} }
@ -1113,15 +1113,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingName)
uint32 nSheet = (uint32)args[0].getInteger(); uint32 nSheet = (uint32)args[0].getInteger();
if (nSheet == 0) if (nSheet == 0)
{ {
result.setUCString(string("")); result.setString(string());
return true; return true;
} }
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
const ucstring name(pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet))); const string name = CUtfStringView(pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet))).toUtf8();
result.setUCString(name); result.setString(name);
return true; return true;
} }
@ -1140,12 +1140,12 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc)
uint32 nSheet = (uint32)args[0].getInteger(); uint32 nSheet = (uint32)args[0].getInteger();
if (nSheet == 0) if (nSheet == 0)
{ {
result.setUCString(string("")); result.setString(string());
return true; return true;
} }
// get sheet name // get sheet name
ucstring name; string name;
CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet)); CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet));
COutpostBuildingSheet *pOBS = dynamic_cast<COutpostBuildingSheet*>(pSheet); COutpostBuildingSheet *pOBS = dynamic_cast<COutpostBuildingSheet*>(pSheet);
if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty) if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty)
@ -1156,11 +1156,11 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc)
else else
{ {
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
name = pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet)); name = CUtfStringView(pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet))).toUtf8();
} }
result.setUCString(name); result.setString(name);
return true; return true;
} }
@ -1179,15 +1179,15 @@ static DECLARE_INTERFACE_USER_FCT(getSquadName)
uint32 nSheet = (uint32)args[0].getInteger(); uint32 nSheet = (uint32)args[0].getInteger();
if (nSheet == 0) if (nSheet == 0)
{ {
result.setUCString(string("")); result.setString(string());
return true; return true;
} }
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
const ucstring name(pSMC->getSquadLocalizedName(CSheetId(nSheet))); const string name = CUtfStringView(pSMC->getSquadLocalizedName(CSheetId(nSheet))).toUtf8();
result.setUCString(name); result.setString(name);
return true; return true;
} }
@ -1206,15 +1206,15 @@ static DECLARE_INTERFACE_USER_FCT(getSquadDesc)
uint32 nSheet = (uint32)args[0].getInteger(); uint32 nSheet = (uint32)args[0].getInteger();
if (nSheet == 0) if (nSheet == 0)
{ {
result.setUCString(string("")); result.setString(string());
return true; return true;
} }
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
const ucstring name(pSMC->getSquadLocalizedDescription(CSheetId(nSheet))); const string name = CUtfStringView(pSMC->getSquadLocalizedDescription(CSheetId(nSheet))).toUtf8();
result.setUCString(name); result.setString(name);
return true; return true;
} }
@ -1267,7 +1267,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod)
// if status wanted is peace or unknow, then "N/A", because there is no attack period in peace mode // if status wanted is peace or unknow, then "N/A", because there is no attack period in peace mode
if( status==OUTPOSTENUMS::Peace || status==OUTPOSTENUMS::UnknownOutpostState ) if( status==OUTPOSTENUMS::Peace || status==OUTPOSTENUMS::UnknownOutpostState )
{ {
result.setUCString(string(" - ")); result.setString(string(" - "));
return true; return true;
} }
@ -1275,7 +1275,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod)
if( (isAttackPeriod && status>OUTPOSTENUMS::AttackRound) || if( (isAttackPeriod && status>OUTPOSTENUMS::AttackRound) ||
(!isAttackPeriod && status>OUTPOSTENUMS::DefenseRound) ) (!isAttackPeriod && status>OUTPOSTENUMS::DefenseRound) )
{ {
result.setUCString(CI18N::get("uiOutpostPeriodEnded")); result.setString(CI18N::get("uiOutpostPeriodEnded"));
return true; return true;
} }
@ -1295,7 +1295,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod)
tstruct= gmtime(&tval); tstruct= gmtime(&tval);
if(!tstruct) if(!tstruct)
{ {
result.setUCString(string("Bad Date Received")); result.setString(string("Bad Date Received"));
return true; return true;
} }
dname= tstruct->tm_wday; // 0-6 (Sunday==0!!) dname= tstruct->tm_wday; // 0-6 (Sunday==0!!)
@ -1308,21 +1308,21 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod)
tstruct= gmtime(&tval); tstruct= gmtime(&tval);
if(!tstruct) if(!tstruct)
{ {
result.setUCString(string("Bad Date Received")); result.setString(string("Bad Date Received"));
return true; return true;
} }
hend= tstruct->tm_hour; // 0-23 hend= tstruct->tm_hour; // 0-23
mend= tstruct->tm_min; // 0-59 mend= tstruct->tm_min; // 0-59
// translate // translate
ucstring res= CI18N::get("uiOutpostPeriodFormat"); string res= CI18N::get("uiOutpostPeriodFormat");
strFindReplace( res, "%dayname", CI18N::get(toString("uiDay%d", dname)) ); strFindReplace( res, "%dayname", CI18N::get(toString("uiDay%d", dname)) );
strFindReplace( res, "%daynumber", toString(dnumber) ); strFindReplace( res, "%daynumber", toString(dnumber) );
strFindReplace( res, "%month", CI18N::get(toString("uiMonth%02d", month+1)) ); strFindReplace( res, "%month", CI18N::get(toString("uiMonth%02d", month+1)) );
strFindReplace( res, "%timestart", toString("%02d:%02d", hstart, mstart) ); strFindReplace( res, "%timestart", toString("%02d:%02d", hstart, mstart) );
strFindReplace( res, "%timeend", toString("%02d:%02d", hend, mend) ); strFindReplace( res, "%timeend", toString("%02d:%02d", hend, mend) );
result.setUCString(res); result.setString(res);
return true; return true;
} }
REGISTER_INTERFACE_USER_FCT("getOutpostPeriod", getOutpostPeriod) REGISTER_INTERFACE_USER_FCT("getOutpostPeriod", getOutpostPeriod)

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save