diff --git a/nel/include/nel/gui/ctrl_base.h b/nel/include/nel/gui/ctrl_base.h index 9c80e7f7a..55983bfbb 100644 --- a/nel/include/nel/gui/ctrl_base.h +++ b/nel/include/nel/gui/ctrl_base.h @@ -87,7 +87,9 @@ namespace NLGUI /// Get the ContextHelp for this control. Default is to return _ContextHelp virtual void getContextHelp(std::string &help) const {help= _ContextHelp;} - virtual void getContextHelpAsUtf16(ucstring &help) const {help.fromUtf8(_ContextHelp);} +#ifdef RYZOM_LUA_UCSTRING + virtual void getContextHelpAsUtf16(ucstring &help) const {help.fromUtf8(_ContextHelp);} // Compatibility +#endif /// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp. virtual void getContextHelpToolTip(std::string &help) const { getContextHelp(help); } // Get the name of the context help window. Default to "context_help" @@ -127,8 +129,10 @@ namespace NLGUI /// replace the default contextHelp std::string getDefaultContextHelp() const {return _ContextHelp;} void setDefaultContextHelp(const std::string &help) {_ContextHelp= help;} - ucstring getDefaultContextHelpAsUtf16() const {return ucstring::makeFromUtf8(_ContextHelp);} - void setDefaultContextHelpAsUtf16(const ucstring &help) {_ContextHelp= help.toUtf8();} +#ifdef RYZOM_LUA_UCSTRING + ucstring getDefaultContextHelpAsUtf16() const {return ucstring::makeFromUtf8(_ContextHelp);} // Compatibility + void setDefaultContextHelpAsUtf16(const ucstring &help) {_ContextHelp= help.toUtf8();} // Compatibility +#endif void setOnContextHelp(const std::string &help) {_OnContextHelp= help;} void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;} @@ -158,12 +162,18 @@ namespace NLGUI // called when keyboard capture has been lost virtual void onKeyboardCaptureLost() {} +#ifdef RYZOM_LUA_UCSTRING // 'tooltip' property expects string to be ucstring or latin1 which is not possible from html page - int luaSetTooltipUtf8(CLuaState &ls); + int luaSetTooltipUtf8(CLuaState &ls); // Compatibility +#endif REFLECT_EXPORT_START(CCtrlBase, CViewBase) - REFLECT_UCSTRING("tooltip", getDefaultContextHelpAsUtf16, setDefaultContextHelpAsUtf16); // FIXME: Lua UTF-8 - REFLECT_LUA_METHOD("setTooltipUtf8", luaSetTooltipUtf8); +#ifdef RYZOM_LUA_UCSTRING + REFLECT_UCSTRING("tooltip", getDefaultContextHelpAsUtf16, setDefaultContextHelpAsUtf16); // Compatibility + REFLECT_LUA_METHOD("setTooltipUtf8", luaSetTooltipUtf8); // Compatibility +#else + REFLECT_STRING("tooltip", getDefaultContextHelp, setDefaultContextHelp); +#endif REFLECT_EXPORT_END // special for mouse over : return true and fill the name of the cursor to display diff --git a/nel/include/nel/gui/ctrl_text_button.h b/nel/include/nel/gui/ctrl_text_button.h index 4773a25e9..98223a802 100644 --- a/nel/include/nel/gui/ctrl_text_button.h +++ b/nel/include/nel/gui/ctrl_text_button.h @@ -99,8 +99,12 @@ namespace NLGUI // Set text (noop if text id) void setText (const std::string &text); std::string getText () const; - void setTextAsUtf16 (const ucstring &text); - ucstring getTextAsUtf16 () const; +#ifdef RYZOM_LUA_UCSTRING + void setTextAsUtf16 (const ucstring &text); // Compatibility + ucstring getTextAsUtf16 () const; // Compatibility +#endif + void setLocalize (bool localize); + bool isLocalized () const; void setHardText (const std::string &text); std::string getHardText () const; @@ -133,8 +137,12 @@ namespace NLGUI int luaGetViewText(CLuaState &ls); REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton) - REFLECT_UCSTRING("uc_hardtext", getTextAsUtf16, setTextAsUtf16); +#ifdef RYZOM_LUA_UCSTRING + REFLECT_UCSTRING("uc_hardtext", getTextAsUtf16, setTextAsUtf16); // Compatibility +#endif + REFLECT_BOOL("localize", isLocalized, setLocalize); REFLECT_STRING("hardtext", getHardText, setHardText); + REFLECT_STRING("text", getText, setText); REFLECT_SINT32("text_x", getTextX, setTextX) REFLECT_SINT32("wmargin", getWMargin, setWMargin) REFLECT_SINT32("wmin", getWMin, setWMin) diff --git a/nel/include/nel/gui/dbgroup_combo_box.h b/nel/include/nel/gui/dbgroup_combo_box.h index ddf84cbef..3826bf00f 100644 --- a/nel/include/nel/gui/dbgroup_combo_box.h +++ b/nel/include/nel/gui/dbgroup_combo_box.h @@ -64,11 +64,15 @@ namespace NLGUI void setText(uint i, const std::string &text); void insertText(uint i, const std::string &text); const std::string &getText(uint i) const; - ucstring getTextAsUtf16(uint i) const; +#ifdef RYZOM_LUA_UCSTRING + ucstring getTextAsUtf16(uint i) const; // Compatibility +#endif uint getTextId(uint i) const; uint getTextPos(uint nId) const; const std::string &getTexture(uint i) const; - ucstring getTextureAsUtf16(uint i) const; +#ifdef RYZOM_LUA_UCSTRING + ucstring getTextureAsUtf16(uint i) const; // Compatibility +#endif void setGrayed(uint i, bool g); bool getGrayed(uint i) const; void removeText(uint nPos); @@ -91,8 +95,10 @@ namespace NLGUI // view text void setViewText(const std::string & text); std::string getViewText() const; - void setViewTextAsUtf16(const ucstring &text) { setViewText(text.toUtf8()); } - ucstring getViewTextAsUtf16() const; +#ifdef RYZOM_LUA_UCSTRING + void setViewTextAsUtf16(const ucstring &text) { setViewText(text.toUtf8()); } // Compatibility + ucstring getViewTextAsUtf16() const; // Compatibility +#endif CViewText *getViewText(); void setTexture(uint i, const std::string &texture); @@ -126,7 +132,11 @@ namespace NLGUI REFLECT_LUA_METHOD("resetTexts", luaResetTexts) REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb) REFLECT_STRING ("selection_text", getSelectionText, setSelectionText) - REFLECT_UCSTRING ("view_text", getViewTextAsUtf16, setViewTextAsUtf16) // FIXME: Better to have UTF-8 +#ifdef RYZOM_LUA_UCSTRING + REFLECT_UCSTRING ("view_text", getViewTextAsUtf16, setViewTextAsUtf16) // Compatibility +#else + REFLECT_STRING ("view_text", getViewText, setViewText) +#endif REFLECT_EXPORT_END diff --git a/nel/include/nel/gui/group_container.h b/nel/include/nel/gui/group_container.h index d7c489e5f..5157c22b1 100644 --- a/nel/include/nel/gui/group_container.h +++ b/nel/include/nel/gui/group_container.h @@ -249,12 +249,14 @@ namespace NLGUI // Get the header color draw. NB: depends if grayed, and if active. NLMISC::CRGBA getDrawnHeaderColor () const; - ucstring getUCTitleOpened () const; - void setUCTitleOpened (const ucstring &title); - ucstring getUCTitleClosed () const; - void setUCTitleClosed (const ucstring &title); - ucstring getUCTitle () const; - void setUCTitle (const ucstring &title); +#ifdef RYZOM_LUA_UCSTRING + ucstring getUCTitleOpened () const; // Compatibility + void setUCTitleOpened (const ucstring &title); // Compatibility + ucstring getUCTitleClosed () const; // Compatibility + void setUCTitleClosed (const ucstring &title); // Compatibility + ucstring getUCTitle () const; // Compatibility + void setUCTitle (const ucstring &title); // Compatibility +#endif void setPopable(bool popable) { _Popable = popable; } bool isPopable() const { return _Popable; } @@ -289,9 +291,11 @@ namespace NLGUI REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened); REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed); - 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 +#ifdef RYZOM_LUA_UCSTRING + REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); // Compatibility + REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); // Compatibility + REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); // Compatibility +#endif REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString); REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH); diff --git a/nel/include/nel/gui/group_editbox.h b/nel/include/nel/gui/group_editbox.h index 4bf200df8..ebd9aeeaf 100644 --- a/nel/include/nel/gui/group_editbox.h +++ b/nel/include/nel/gui/group_editbox.h @@ -74,17 +74,19 @@ namespace NLGUI */ void setPrompt(const std::string &s); void setInputString(const std::string &str); - void setInputStringRef(const ::u32string &str) {_InputString = str; }; + void setInputStringRef(const ::u32string &str); void setInputStringAsInt(sint32 val); sint32 getInputStringAsInt() const; void setInputStringAsInt64(sint64 val); sint64 getInputStringAsInt64() const; void setInputStringAsFloat(float val); float getInputStringAsFloat() const; - void setInputStringAsUtf16(const ucstring &str); - ucstring getInputStringAsUtf16() const; - void setInputStringAsUtf32(const ::u32string &str); - ::u32string getInputStringAsUtf32() const { return _InputString; } +#ifdef RYZOM_LUA_UCSTRING + void setInputStringAsUtf16(const ucstring &str); // Compatibility + ucstring getInputStringAsUtf16() const; // Compatibility + void setInputStringAsUtf32(const ::u32string &str) { setInputStringRef(str); } // Compatibility + ::u32string getInputStringAsUtf32() const { return _InputString; } // Compatibility +#endif void setColor(NLMISC::CRGBA col); @@ -192,7 +194,9 @@ namespace NLGUI REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText); REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText); REFLECT_STRING("input_string", getInputString, setInputString); - REFLECT_UCSTRING("uc_input_string", getInputStringAsUtf16, setInputStringAsUtf16); +#ifdef RYZOM_LUA_UCSTRING + REFLECT_UCSTRING("uc_input_string", getInputStringAsUtf16, setInputStringAsUtf16); // Compatibility +#endif REFLECT_EXPORT_END /** Restore the original value of the edit box. @@ -217,6 +221,7 @@ namespace NLGUI float _BlinkTime; sint32 _CursorPos; uint32 _MaxNumChar; + uint32 _MaxNumBytes; uint32 _MaxNumReturn; uint32 _MaxFloatPrec; // used in setInputStringAsFloat() only sint32 _MaxCharsSize; diff --git a/nel/include/nel/gui/group_tree.h b/nel/include/nel/gui/group_tree.h index 835a305e1..7a39ccfea 100644 --- a/nel/include/nel/gui/group_tree.h +++ b/nel/include/nel/gui/group_tree.h @@ -115,8 +115,10 @@ namespace NLGUI bool getOpened() const { return Opened; } void setText(const std::string &text) { Text = text; } const std::string& getText() const { return Text; } - void setTextAsUtf16(const ucstring &text) { Text = text.toUtf8(); } - ucstring getTextAsUtf16() const { return ucstring::makeFromUtf8(Text); } +#ifdef RYZOM_LUA_UCSTRING + void setTextAsUtf16(const ucstring &text) { Text = text.toUtf8(); } // Compatibility + ucstring getTextAsUtf16() const { return ucstring::makeFromUtf8(Text); } // Compatibility +#endif sint32 getFontSize() const { return FontSize; } void setFontSize(sint32 value) { FontSize = value; } sint32 getYDecal() const { return YDecal; } @@ -184,7 +186,11 @@ namespace NLGUI REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose); REFLECT_BOOL("Opened", getOpened, setOpened); REFLECT_BOOL("Show", getShow, setShow); - REFLECT_UCSTRING("Text", getTextAsUtf16, setTextAsUtf16); // FIXME: Lua UTF-8 +#ifdef RYZOM_LUA_UCSTRING + REFLECT_UCSTRING("Text", getTextAsUtf16, setTextAsUtf16); // Compatibility +#else + REFLECT_STRING_REF("Text", getText, setText); +#endif // lua REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren); REFLECT_LUA_METHOD("getChild", luaGetChild); diff --git a/nel/include/nel/gui/lua_ihm.h b/nel/include/nel/gui/lua_ihm.h index cc1051e62..ec047e69a 100644 --- a/nel/include/nel/gui/lua_ihm.h +++ b/nel/include/nel/gui/lua_ihm.h @@ -86,10 +86,12 @@ namespace NLGUI // ucstring +#ifdef RYZOM_LUA_UCSTRING static bool pop(CLuaState &ls, ucstring &dest); static void push(CLuaState &ls, const ucstring &value); static bool isUCStringOnStack(CLuaState &ls, sint index); static bool getUCStringOnStack(CLuaState &ls, sint index, ucstring &dest); +#endif // RGBA @@ -108,7 +110,9 @@ namespace NLGUI static void check(CLuaState &ls, bool ok, const std::string &failReason); static void checkArgType(CLuaState &ls, const char *funcName, uint index, int argType); static void checkArgTypeRGBA(CLuaState &ls, const char *funcName, uint index); +#ifdef RYZOM_LUA_UCSTRING static void checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index); +#endif /** throw a lua expection (inside a C function called from lua) with the given reason, and the current call stack * The various check... function call this function when their test fails */ @@ -154,10 +158,12 @@ namespace NLGUI static uint32 getLocalTime(); static double getPreciseLocalTime(); static std::string findReplaceAll(const std::string &str, const std::string &search, const std::string &replace); +#ifdef RYZOM_LUA_UCSTRING static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace); static ucstring findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace); static ucstring findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace); static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace); +#endif ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -183,8 +189,10 @@ namespace NLGUI static int runExpr(CLuaState &ls); // params: "expr". return: any of: nil,bool,string,number, RGBA, UCString static int runFct(CLuaState &ls); // params: "expr", param1, param2.... return: any of: nil,bool,string,number, RGBA, UCString static int runCommand(CLuaState &ls); // params: "command name", param1, param2 ... return true or false +#ifdef RYZOM_LUA_UCSTRING static int isUCString(CLuaState &ls); static int concatUCString(CLuaState &ls); // workaround for + operator that don't work in luabind for ucstrings ... +#endif static int concatString(CLuaState &ls); // speedup concatenation of several strings static int tableToString(CLuaState &ls); // concat element of a table to build a string static int getPathContent(CLuaState &ls); diff --git a/nel/include/nel/gui/reflect.h b/nel/include/nel/gui/reflect.h index 7da0b3529..579a9418b 100644 --- a/nel/include/nel/gui/reflect.h +++ b/nel/include/nel/gui/reflect.h @@ -298,6 +298,7 @@ namespace NLGUI props.push_back(prop); \ } +#ifdef RYZOM_LUA_UCSTRING // export a unicode string value, by giving the name of the get and the set method #define REFLECT_UCSTRING(exportName, getMethod, setMethod) \ { \ @@ -308,6 +309,7 @@ namespace NLGUI prop.SetMethod.SetUCString = (CReflectedProperty::TSetUCString) static_cast(&A::setMethod); \ props.push_back(prop); \ } +#endif // export a string value, by giving the name of the get and the set method #define REFLECT_STRING_REF(exportName, getMethod, setMethod) \ @@ -320,6 +322,7 @@ namespace NLGUI props.push_back(prop); \ } +#ifdef RYZOM_LUA_UCSTRING // export a unicode string value, by giving the name of the get and the set method #define REFLECT_UCSTRING_REF(exportName, getMethod, setMethod) \ { \ @@ -330,7 +333,7 @@ namespace NLGUI prop.SetMethod.SetUCString = (CReflectedProperty::TSetUCString) static_cast(&A::setMethod); \ props.push_back(prop); \ } - +#endif // export a color value, by giving the name of the get and the set method #define REFLECT_RGBA(exportName, getMethod, setMethod) \ diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index 69f9efca7..3fb92f88c 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -86,7 +86,9 @@ namespace NLGUI void setText(const std::string &text); void setTextLocalized(const std::string &text, bool localized); - void setTextAsUtf16 (const ucstring &text); +#ifdef RYZOM_LUA_UCSTRING + void setTextAsUtf16 (const ucstring &text); // Compatibility +#endif void setLocalized(bool localized); void setFontName (const std::string &name); void setFontSize (sint nFontSize, bool coef = true); @@ -99,7 +101,9 @@ namespace NLGUI void setShadowOffset (sint x, sint y); void setLineMaxW (sint nMaxW, bool invalidate=true); void setOverflowText(const std::string &text) { _OverflowText = text; } - void setOverflowTextAsUtf16(const ucstring &text) { _OverflowText = text.toUtf8(); } +#ifdef RYZOM_LUA_UCSTRING + void setOverflowTextAsUtf16(const ucstring &text) { _OverflowText = text.toUtf8(); } // Compatibility +#endif void setMultiLine (bool bMultiLine); void setMultiLineSpace (sint nMultiLineSpace); void setMultiLineMaxWOnly (bool state); @@ -117,8 +121,10 @@ namespace NLGUI /// Get std::string getText() const { return _HardText.empty() ? _Text : _HardText; } - ucstring getTextAsUtf16() const; - ucstring getHardTextAsUtf16() const; +#ifdef RYZOM_LUA_UCSTRING + ucstring getTextAsUtf16() const; // Compatibility + ucstring getHardTextAsUtf16() const; // Compatibility +#endif bool isLocalized() const { return _Localized; } sint getFontSize() const; std::string getFontName() const { return _FontName; } @@ -130,7 +136,9 @@ namespace NLGUI NLMISC::CRGBA getShadowColor() { return _ShadowColor; } void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; } sint getLineMaxW() const { return _LineMaxW; } - ucstring getOverflowTextAsUtf16() const { return _OverflowText; } +#ifdef RYZOM_LUA_UCSTRING + ucstring getOverflowTextAsUtf16() const { return _OverflowText; } // Compatibility +#endif bool getMultiLine() const { return _MultiLine; } sint getMultiLineSpace() const { return _MultiLineSpace; } bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; } @@ -182,7 +190,9 @@ namespace NLGUI std::string getHardText() const { return _HardText.empty() ? _Text : _HardText; } void setHardText (const std::string &ht); //< Localizes strings starting with "ui" - void setHardTextAsUtf16(const ucstring &ht); +#ifdef RYZOM_LUA_UCSTRING + void setHardTextAsUtf16(const ucstring &ht); // Compatibility +#endif std::string getColorAsString() const; void setColorAsString(const std::string &ht); @@ -196,10 +206,14 @@ namespace NLGUI /** Setup a Text with Format Tags. Text is store without color/format tags, and special array is allocated for Format association */ void setTextFormatTaged(const std::string &text); - void setTextFormatTagedAsUtf16(const ucstring &text); +#ifdef RYZOM_LUA_UCSTRING + void setTextFormatTagedAsUtf16(const ucstring &text); // Compatibility +#endif void setSingleLineTextFormatTaged(const std::string &text); - void setSingleLineTextFormatTagedAsUtf16(const ucstring &text); +#ifdef RYZOM_LUA_UCSTRING + void setSingleLineTextFormatTagedAsUtf16(const ucstring &text); // Compatibility +#endif // Remove end space void removeEndSpaces(); @@ -225,13 +239,17 @@ namespace NLGUI int luaSetLineMaxW(CLuaState &ls); REFLECT_EXPORT_START(CViewText, CViewBase) - REFLECT_STRING("text_raw", getText, setText); - REFLECT_STRING("hardtext", getHardText, setHardText); - REFLECT_BOOL ("localize", isLocalized, setLocalized); + REFLECT_BOOL("localize", isLocalized, setLocalized); + REFLECT_STRING("hardtext", getHardText, setHardText); // Same as text, but localize is implicitly set true + REFLECT_STRING("text", getText, setText); + REFLECT_STRING("text_format", getText, setTextFormatTaged); + REFLECT_STRING("text_single_line_format", getText, setSingleLineTextFormatTaged); +#ifdef RYZOM_LUA_UCSTRING // REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions - REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16); - REFLECT_UCSTRING("uc_hardtext_format", getTextAsUtf16, setTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense - REFLECT_UCSTRING("uc_hardtext_single_line_format", getTextAsUtf16, setSingleLineTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense + REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16); // Compatibility + REFLECT_UCSTRING("uc_hardtext_format", getTextAsUtf16, setTextFormatTagedAsUtf16); // Compatibility + REFLECT_UCSTRING("uc_hardtext_single_line_format", getTextAsUtf16, setSingleLineTextFormatTagedAsUtf16); // Compatibility +#endif REFLECT_STRING ("color", getColorAsString, setColorAsString); REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA); REFLECT_SINT32 ("alpha", getAlpha, setAlpha); @@ -452,7 +470,7 @@ namespace NLGUI void setStringSelectionSkipingSpace(uint stringId, const std::string &text, sint charStart, sint charEnd); - // void pushString(const ucstring &str, bool deleteSpaceAtStart = false); + // void pushString(const ucstring &str, bool deleteSpaceAtStart = false); // OLD /// \from CInterfaceElement void onInvalidateContent(); diff --git a/nel/include/nel/gui/view_text_id.h b/nel/include/nel/gui/view_text_id.h index d29721481..5f8ccb14f 100644 --- a/nel/include/nel/gui/view_text_id.h +++ b/nel/include/nel/gui/view_text_id.h @@ -145,7 +145,7 @@ namespace NLGUI // If true, setTextFormatted() is used instead of setText() bool _IsTextFormatTaged; - // Optional ucstring modifier + // Optional utf-8 string modifier IOnReceiveTextId *_StringModifier; std::string _DBPath; static IViewTextProvider* getTextProvider(){ return textProvider; } diff --git a/nel/include/nel/misc/ucstring.h b/nel/include/nel/misc/ucstring.h index 5b95c33c2..17f87e66a 100644 --- a/nel/include/nel/misc/ucstring.h +++ b/nel/include/nel/misc/ucstring.h @@ -20,6 +20,8 @@ #ifndef NL_UCSTRING_H #define NL_UCSTRING_H +#define RYZOM_LUA_UCSTRING + #include "types_nl.h" #include "debug.h" diff --git a/nel/src/gui/ctrl_base.cpp b/nel/src/gui/ctrl_base.cpp index e120c5d4e..fa790d9d4 100644 --- a/nel/src/gui/ctrl_base.cpp +++ b/nel/src/gui/ctrl_base.cpp @@ -573,6 +573,7 @@ namespace NLGUI return itr2->second; } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** int CCtrlBase::luaSetTooltipUtf8(CLuaState &ls) { @@ -585,5 +586,6 @@ namespace NLGUI return 0; } +#endif } diff --git a/nel/src/gui/ctrl_text_button.cpp b/nel/src/gui/ctrl_text_button.cpp index e7689704f..8697fb212 100644 --- a/nel/src/gui/ctrl_text_button.cpp +++ b/nel/src/gui/ctrl_text_button.cpp @@ -1051,6 +1051,20 @@ namespace NLGUI return std::string(); } + void CCtrlTextButton::setLocalize(bool localize) + { + if (_ViewText && !_IsViewTextId) + _ViewText->setLocalized(localize); + } + + bool CCtrlTextButton::isLocalized() const + { + if (_ViewText && !_IsViewTextId) + return _ViewText->isLocalized(); + return true; + } + +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CCtrlTextButton::setTextAsUtf16 (const ucstring &text) { @@ -1065,6 +1079,7 @@ namespace NLGUI return CUtfStringView(_ViewText->getText()).toUtf16(); return ucstring(""); } +#endif // *************************************************************************** void CCtrlTextButton::setHardText (const std::string &text) diff --git a/nel/src/gui/dbgroup_combo_box.cpp b/nel/src/gui/dbgroup_combo_box.cpp index 1e5f18b4d..b54d33e8f 100644 --- a/nel/src/gui/dbgroup_combo_box.cpp +++ b/nel/src/gui/dbgroup_combo_box.cpp @@ -361,11 +361,13 @@ namespace NLGUI return empty; } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** ucstring CDBGroupComboBox::getTextAsUtf16(uint i) const { return ucstring::makeFromUtf8(getText(i)); } +#endif // *************************************************************************** uint CDBGroupComboBox::getTextId(uint i) const @@ -402,12 +404,14 @@ namespace NLGUI else return empty; } - + +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** ucstring CDBGroupComboBox::getTextureAsUtf16(uint i) const { return ucstring::makeFromUtf8(getTexture(i)); } +#endif // *************************************************************************** void CDBGroupComboBox::setSelection(sint32 val) @@ -489,11 +493,13 @@ namespace NLGUI return _ViewText->getText(); } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** ucstring CDBGroupComboBox::getViewTextAsUtf16() const { return CUtfStringView(_ViewText->getText()).toUtf16(); } +#endif // *************************************************************************** CViewText *CDBGroupComboBox::getViewText() @@ -576,10 +582,16 @@ namespace NLGUI { const char *funcName = "addText"; CLuaIHM::checkArgCount(ls, funcName, 1); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 1); - ucstring text; + ucstring text; // Compatibility nlverify(CLuaIHM::pop(ls, text)); - addText(text.toUtf8()); // FIXME: Lua should just do UTF-8! + addText(text.toUtf8()); +#else + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + string text = ls.toString(1); + addText(text); +#endif return 0; } @@ -589,10 +601,16 @@ namespace NLGUI const char *funcName = "setText"; CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 2); - ucstring text; + ucstring text; // Compatibility nlverify(CLuaIHM::pop(ls, text)); - setText((uint) ls.toInteger(1), text.toUtf8()); // FIXME: Lua should just do UTF-8! + setText((uint) ls.toInteger(1), text.toUtf8()); +#else + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + string text = ls.toString(2); + setText((uint)ls.toInteger(1), text); +#endif return 0; } @@ -602,10 +620,16 @@ namespace NLGUI const char *funcName = "insertText"; CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 2); ucstring text; nlverify(CLuaIHM::pop(ls, text)); insertText((uint) ls.toInteger(1), text.toUtf8()); // FIXME: Lua should just do UTF-8! +#else + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + string text = ls.toString(2); + insertText((uint)ls.toInteger(1), text); +#endif return 0; } @@ -615,20 +639,30 @@ namespace NLGUI const char *funcName = "setTexture"; CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 2); ucstring texture; nlverify(CLuaIHM::pop(ls, texture)); setTexture((uint) ls.toInteger(1), texture.toUtf8()); // FIXME: Lua should just do UTF-8! +#else + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + string texture = ls.toString(2); + setTexture((uint)ls.toInteger(1), texture); +#endif return 0; } // *************************************************************************** int CDBGroupComboBox::luaGetText(CLuaState &ls) { - const char *funcName = "setText"; + const char *funcName = "getText"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHM::push(ls, getText((uint) ls.toInteger(1))); +#ifdef RYZOM_LUA_UCSTRING + CLuaIHM::push(ls, getTextAsUtf16((uint) ls.toInteger(1))); +#else + ls.push(getText((uint)ls.toInteger(1))); +#endif return 1; } diff --git a/nel/src/gui/group_container.cpp b/nel/src/gui/group_container.cpp index 0740bd80f..9047fbfcb 100644 --- a/nel/src/gui/group_container.cpp +++ b/nel/src/gui/group_container.cpp @@ -4016,6 +4016,7 @@ namespace NLGUI } } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CGroupContainer::setUCTitleOpened(const ucstring &title) { @@ -4051,6 +4052,7 @@ namespace NLGUI { return ucstring::makeFromUtf8(getTitleClosed()); } +#endif // *************************************************************************** void CGroupContainer::launch () diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp index f90eb424f..64390bf24 100644 --- a/nel/src/gui/group_editbox.cpp +++ b/nel/src/gui/group_editbox.cpp @@ -63,6 +63,7 @@ namespace NLGUI _BlinkTime(0.f), _CursorPos(0), _MaxNumChar(std::numeric_limits::max()), + _MaxNumBytes(0), _MaxNumReturn(std::numeric_limits::max()), _MaxFloatPrec(20), _MaxCharsSize(32768), @@ -149,6 +150,11 @@ namespace NLGUI return toString( _MaxNumChar ); } else + if( name == "max_num_bytes" ) + { + return toString( _MaxNumBytes ); + } + else if( name == "max_num_return" ) { return toString( _MaxNumReturn ); @@ -321,6 +327,14 @@ namespace NLGUI return; } else + if( name == "max_num_bytes" ) + { + uint32 i; + if( fromString( value, i ) ) + _MaxNumBytes = i; + return; + } + else if( name == "max_num_return" ) { uint32 i; @@ -474,6 +488,7 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "on_focus", BAD_CAST _AHOnFocus.c_str() ); xmlSetProp( node, BAD_CAST "on_focus_params", BAD_CAST _AHOnFocusParams.c_str() ); xmlSetProp( node, BAD_CAST "max_num_chars", BAD_CAST toString( _MaxNumChar ).c_str() ); + xmlSetProp( node, BAD_CAST "max_num_bytes", BAD_CAST toString( _MaxNumBytes ).c_str() ); xmlSetProp( node, BAD_CAST "max_num_return", BAD_CAST toString( _MaxNumReturn ).c_str() ); xmlSetProp( node, BAD_CAST "max_chars_size", BAD_CAST toString( _MaxCharsSize ).c_str() ); xmlSetProp( node, BAD_CAST "enter_loose_focus", BAD_CAST toString( _LooseFocusOnEnter ).c_str() ); @@ -591,6 +606,9 @@ namespace NLGUI prop = (char*) xmlGetProp( cur, (xmlChar*)"max_num_chars" ); if (prop) fromString((const char*)prop, _MaxNumChar); + prop = (char*) xmlGetProp( cur, (xmlChar*)"max_num_bytes" ); + if (prop) fromString((const char*)prop, _MaxNumBytes); + prop = (char*) xmlGetProp( cur, (xmlChar*)"max_num_return" ); if (prop) fromString((const char*)prop, _MaxNumReturn); @@ -969,6 +987,17 @@ namespace NLGUI length = _MaxNumChar - (sint)_InputString.length(); } ::u32string toAdd = toAppend.substr(0, length); + if (_MaxNumBytes && length) + { + sint baseBytes = CUtfStringView(_InputString).toUtf8().length(); + sint bytes = baseBytes + CUtfStringView(toAdd).toUtf8().length(); + while (bytes > _MaxNumBytes) + { + length -= std::max((int)(bytes - _MaxNumBytes) >> 2, 1); + toAdd = toAdd.substr(0, length); + bytes = baseBytes + CUtfStringView(toAdd).toUtf8().length(); + } + } sint32 minPos; sint32 maxPos; if (_CurrSelection == this) @@ -1018,7 +1047,7 @@ namespace NLGUI _CursorAtPreviousLineEnd = false; if (_ClearOnEscape) { - setInputStringAsUtf32(::u32string()); + setInputStringRef(::u32string()); triggerOnChangeAH(); } CWidgetManager::getInstance()->setCaptureKeyboard(NULL); @@ -1064,7 +1093,7 @@ namespace NLGUI { if (isKeyRETURN) { - //ucstring copyStr= _InputString; + //u32string copyStr= _InputString; //if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn) if ((uint)std::count(_InputString.begin(), _InputString.end(), '\n') >= _MaxNumReturn) break; @@ -1153,11 +1182,14 @@ namespace NLGUI // verify max num char if ((uint) _InputString.length() < _MaxNumChar) { - makeTopWindow(); - ::u32string::iterator it = _InputString.begin() + _CursorPos; - _InputString.insert(it, c); - ++ _CursorPos; - triggerOnChangeAH(); + if (!_MaxNumBytes || CUtfStringView(_InputString + c).toUtf8().size() <= _MaxNumBytes) + { + makeTopWindow(); + ::u32string::iterator it = _InputString.begin() + _CursorPos; + _InputString.insert(it, c); + ++_CursorPos; + triggerOnChangeAH(); + } } if (isKeyRETURN) { @@ -1182,7 +1214,7 @@ namespace NLGUI if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (!_CanUndo) return false; _ModifiedInputString = _InputString; - setInputStringAsUtf32(_StartInputString); + setInputStringRef(_StartInputString); _CanUndo = false; _CanRedo = true; setCursorPos((sint32)_InputString.length()); @@ -1195,7 +1227,7 @@ namespace NLGUI { if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (!_CanRedo) return false; - setInputStringAsUtf32(_ModifiedInputString); + setInputStringRef(_ModifiedInputString); _CanUndo = true; _CanRedo = false; setCursorPos((sint32)_InputString.length()); @@ -1306,7 +1338,7 @@ namespace NLGUI default: break; } // update the text - setInputStringAsUtf32(_InputString); + setInputStringRef(_InputString); // if event of type char or string, consider handle all of them if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring ) @@ -1635,9 +1667,9 @@ namespace NLGUI // ---------------------------------------------------------------------------- void CGroupEditBox::setInputString(const std::string &str) { - setInputStringAsUtf32(CUtfStringView(str).toUtf32()); + setInputStringRef(CUtfStringView(str).toUtf32()); } - void CGroupEditBox::setInputStringAsUtf32(const ::u32string &str) + void CGroupEditBox::setInputStringRef(const ::u32string &str) { _InputString = str; if (_CursorPos > (sint32) str.length()) @@ -1761,6 +1793,7 @@ namespace NLGUI return NLMISC::CUtfStringView(_InputString).toUtf8(); } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CGroupEditBox::setInputStringAsUtf16(const ucstring &str) { @@ -1772,6 +1805,7 @@ namespace NLGUI { return CUtfStringView(_InputString).toUtf16(); } +#endif // *************************************************************************** void CGroupEditBox::setCommand(const std::string &command, bool execute) @@ -1844,7 +1878,7 @@ namespace NLGUI } if (version < 1) { - ucstring str; + ucstring str; // Compatibility if (!f.isReading()) str = CUtfStringView(_InputString).toUtf16(); f.serial(str); @@ -1864,7 +1898,7 @@ namespace NLGUI f.serial(_PrevNumLine); if (f.isReading()) { - setInputStringAsUtf32(_InputString); + setInputStringRef(_InputString); } // serial selection @@ -1881,7 +1915,7 @@ namespace NLGUI void CGroupEditBox::onQuit() { // clear the text and restore backup pos before final save - setInputStringAsUtf32(::u32string()); + setInputStringRef(::u32string()); _CurrSelection = NULL; } @@ -1889,7 +1923,7 @@ namespace NLGUI void CGroupEditBox::onLoadConfig() { // config is not saved when there's an empty string, so restore that default state. - setInputStringAsUtf32(::u32string()); + setInputStringRef(::u32string()); _CurrSelection = NULL; _PrevNumLine = 1; } @@ -1904,7 +1938,7 @@ namespace NLGUI if (_DefaultInputString) { _DefaultInputString= false; - setInputStringAsUtf32(::u32string()); + setInputStringRef(::u32string()); } _CanRedo = false; _CanUndo = false; diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index 04c083c20..6694200bf 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -1272,7 +1272,6 @@ namespace NLGUI return; } - // TODO: use ucstring / ucchar as content is utf8 chars std::string::size_type pos = 0; while(pos < content.size()) { @@ -3695,7 +3694,7 @@ namespace NLGUI { // Text area ? bool addEntry = false; - ucstring entryData; + string entryData; if (form.Entries[i].TextArea) { // Get the edit box view @@ -3706,7 +3705,7 @@ namespace NLGUI CGroupEditBox *editBox = dynamic_cast(group); if (editBox) { - entryData = CUtfStringView(editBox->getViewText()->getText()).toUtf16(); + entryData = editBox->getViewText()->getText(); addEntry = true; } } @@ -3723,7 +3722,7 @@ namespace NLGUI else if (form.Entries[i].ComboBox) { CDBGroupComboBox *cb = form.Entries[i].ComboBox; - entryData.fromUtf8(form.Entries[i].SelectValues[cb->getSelection()]); + entryData = form.Entries[i].SelectValues[cb->getSelection()]; addEntry = true; } else if (form.Entries[i].SelectBox) @@ -3754,7 +3753,7 @@ namespace NLGUI // Add this entry if (addEntry) { - formfields.add(form.Entries[i].Name, CI18N::encodeUTF8(entryData)); + formfields.add(form.Entries[i].Name, entryData); } } diff --git a/nel/src/gui/group_list.cpp b/nel/src/gui/group_list.cpp index c65d759ba..b21784836 100644 --- a/nel/src/gui/group_list.cpp +++ b/nel/src/gui/group_list.cpp @@ -1286,12 +1286,18 @@ namespace NLGUI // ---------------------------------------------------------------------------- int CGroupList::luaAddTextChild(CLuaState &ls) { - CLuaIHM::checkArgCount(ls, "addTextChild", 1); - ucstring text; + const char *funcName = "addTextChild"; + CLuaIHM::checkArgCount(ls, funcName, 1); +#ifdef RYZOM_LUA_UCSTRING + ucstring text; // Compatibility if(CLuaIHM::pop(ls, text)) { - addTextChild(text.toUtf8()); // FIXME: Lua UTF-8 + addTextChild(text.toUtf8()); } +#else + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + addTextChild(ls.toString(1)); +#endif return 0; } @@ -1306,15 +1312,13 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 4, LUA_TNUMBER); CLuaIHM::checkArgType(ls, funcName, 5, LUA_TNUMBER); string text = ls.toString(1); - ucstring ucText; - ucText.fromUtf8(text); uint r = (uint) ls.toInteger(2); uint g = (uint) ls.toInteger(3); uint b = (uint) ls.toInteger(4); uint a = (uint) ls.toInteger(5); - addTextChild(ucText.toUtf8(), CRGBA(r, g, b, a)); // FIXME: Lua UTF-8 + addTextChild(text, CRGBA(r, g, b, a)); return 0; } diff --git a/nel/src/gui/group_menu.cpp b/nel/src/gui/group_menu.cpp index 8db402540..41c153c36 100644 --- a/nel/src/gui/group_menu.cpp +++ b/nel/src/gui/group_menu.cpp @@ -1823,8 +1823,13 @@ namespace NLGUI const char *funcName = "getLineId"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - std::string id = getLineId((uint) ls.toInteger(1)); +#ifdef RYZOM_LUA_UCSTRING + ucstring id = getLineId((uint) ls.toInteger(1)); // Compatibility CLuaIHM::push(ls, id); +#else + std::string id = getLineId((uint)ls.toInteger(1)); + ls.push(id); +#endif return 1; } @@ -1853,13 +1858,21 @@ namespace NLGUI { const char *funcName = "addLine"; CLuaIHM::checkArgCount(ls, funcName, 4); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 1); +#else + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); +#endif CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); - ucstring arg1; - nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); // FIXME: Lua UTF-8 +#ifdef RYZOM_LUA_UCSTRING + ucstring arg1; // Compatibility + nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); addLine(arg1.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4)); +#else + addLine(ls.toString(1), ls.toString(2), ls.toString(3), ls.toString(4)); +#endif return 0; } @@ -1868,14 +1881,22 @@ namespace NLGUI { const char *funcName = "addIconLine"; CLuaIHM::checkArgCount(ls, funcName, 5); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 1); +#else + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); +#endif CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); - ucstring arg1; - nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); // FIXME: Lua UTF-8 +#ifdef RYZOM_LUA_UCSTRING + ucstring arg1; // Compatibility + nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); addLine(arg1.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5)); +#else + addLine(ls.toString(1), ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5)); +#endif return 0; } @@ -1885,13 +1906,21 @@ namespace NLGUI const char *funcName = "addLineAtIndex"; CLuaIHM::checkArgCount(ls, funcName, 5); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 2); +#else + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); +#endif CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); +#ifdef RYZOM_LUA_UCSTRING ucstring arg2; - nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); // FIXME: Lua UTF-8 + nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); addLineAtIndex((uint) ls.toInteger(1), arg2.toUtf8(), ls.toString(3), ls.toString(4), ls.toString(5)); +#else + addLineAtIndex((uint)ls.toInteger(1), ls.toString(2), ls.toString(3), ls.toString(4), ls.toString(5)); +#endif return 0; } diff --git a/nel/src/gui/interface_link.cpp b/nel/src/gui/interface_link.cpp index 6fbe3a3ec..c320f8c51 100644 --- a/nel/src/gui/interface_link.cpp +++ b/nel/src/gui/interface_link.cpp @@ -119,13 +119,14 @@ namespace NLGUI break; case CReflectedProperty::UCString: case CReflectedProperty::UCStringRef: +#ifdef RYZOM_LUA_UCSTRING if (valueToAffect.toString()) { (destElem.*(property.SetMethod.SetUCString))(ucstring::makeFromUtf8(valueToAffect.getString())); } else +#endif { - return false; } break; diff --git a/nel/src/gui/lua_ihm.cpp b/nel/src/gui/lua_ihm.cpp index 9b00026d7..9a6bacc3c 100644 --- a/nel/src/gui/lua_ihm.cpp +++ b/nel/src/gui/lua_ihm.cpp @@ -100,11 +100,13 @@ using namespace NLMISC; #define new DEBUG_NEW #endif +#ifdef RYZOM_LUA_UCSTRING // declare ostream << operator for ucstring -> registration of ucstring iin luabind will build a 'tostring' function from it std::ostream &operator<<(std::ostream &str, const ucstring &value) { return str << value.toString(); } +#endif namespace NLGUI { @@ -172,6 +174,7 @@ namespace NLGUI return true; } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** bool CLuaIHM::pop(CLuaState &ls, ucstring &dest) { @@ -224,6 +227,7 @@ namespace NLGUI obj.pushvalue(); #endif } +#endif // *************************************************************************** // *************************************************************************** @@ -689,6 +693,7 @@ namespace NLGUI .def_readwrite("A", &NLMISC::CRGBA::A) ]; +#ifdef RYZOM_LUA_UCSTRING // ucstring module(L) [ @@ -709,6 +714,7 @@ namespace NLGUI .def("toString", (std::string(ucstring::*)()const)&ucstring::toString) //.def(self + other()) ]; +#endif // CVector2f module(L) @@ -1279,6 +1285,7 @@ namespace NLGUI return 1; } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** int CLuaIHM::isUCString(CLuaState &ls) { @@ -1313,6 +1320,7 @@ namespace NLGUI CLuaIHM::push(ls, result); return 1; } +#endif // *************************************************************************** int CLuaIHM::concatString(CLuaState &ls) @@ -1511,6 +1519,7 @@ namespace NLGUI ls.toString(stackIndex, str); val= str; } +#ifdef RYZOM_LUA_UCSTRING else { // else this should be a ucstring @@ -1519,6 +1528,7 @@ namespace NLGUI throw ELuaIHMException("You must set a string, number or ucstring to UI property '%s'", property.Name.c_str()); } } +#endif (target.*(property.SetMethod.SetUCString))(val); return; } @@ -1631,8 +1641,10 @@ namespace NLGUI ls.registerFunc("getWindowSize", getWindowSize); ls.registerFunc("getTextureSize", getTextureSize); ls.registerFunc("disableModalWindow", disableModalWindow); +#ifdef RYZOM_LUA_UCSTRING ls.registerFunc("isUCString", isUCString); ls.registerFunc("concatUCString", concatUCString); +#endif ls.registerFunc("concatString", concatString); ls.registerFunc("tableToString", tableToString); ls.registerFunc("getCurrentWindowUnder", getCurrentWindowUnder); @@ -1665,7 +1677,11 @@ namespace NLGUI // inside i18n table luabind::module(L, "i18n") [ - luabind::def("get", &CI18N::getAsUtf16), // FIXME: Lua UTF-8 +#ifdef RYZOM_LUA_UCSTRING + luabind::def("get", &CI18N::getAsUtf16), // Compatibility +#else + luabind::def("get", &CI18N::get), +#endif luabind::def("hasTranslation", &CI18N::hasTranslation) ]; // inside 'nlfile' table @@ -1843,6 +1859,7 @@ namespace NLGUI return ret; } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** ucstring CLuaIHM::findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace) { @@ -1870,7 +1887,7 @@ namespace NLGUI //H_AUTO(Lua_CLuaIHM_findReplaceAll) return findReplaceAll(str, search, ucstring::makeFromUtf8(replace)); } - +#endif // *************************************************************************** void CLuaIHM::fails(CLuaState &ls, const char *format, ...) @@ -1957,6 +1974,7 @@ namespace NLGUI } } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CLuaIHM::checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index) { @@ -1973,7 +1991,7 @@ namespace NLGUI fails(ls, "%s : argument %d of expected type ucstring has bad type : %s", funcName, index, ls.getTypename(ls.type(index)), ls.type(index)); } } - +#endif // *************************************************************************** diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp index 5e2e2215c..db379b415 100644 --- a/nel/src/gui/view_text.cpp +++ b/nel/src/gui/view_text.cpp @@ -1422,11 +1422,13 @@ namespace NLGUI } } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CViewText::setTextAsUtf16(const ucstring &text) { setText(text.toUtf8()); } +#endif // *************************************************************************** void CViewText::setTextLocalized(const std::string &text, bool localized) @@ -2449,11 +2451,13 @@ namespace NLGUI endOfPreviousLine = !_Lines[line]->getLF(); } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CViewText::setHardTextAsUtf16(const ucstring &ht) { setHardText(ht.toUtf8()); } +#endif // *************************************************************************** void CViewText::setHardText (const std::string &ht) @@ -2466,6 +2470,7 @@ namespace NLGUI setText(ht); } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** ucstring CViewText::getTextAsUtf16() const { @@ -2477,6 +2482,7 @@ namespace NLGUI { return CUtfStringView(getHardText()).toUtf16(); } +#endif // *************************************************************************** string CViewText::getColorAsString() const @@ -3383,11 +3389,13 @@ namespace NLGUI } } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CViewText::setTextFormatTagedAsUtf16(const ucstring &text) { setTextFormatTaged(text.toUtf8()); } +#endif // *************************************************************************** void CViewText::setTextFormatTaged(const std::string &text) @@ -3481,10 +3489,12 @@ namespace NLGUI nlwarning("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.c_str()); } +#ifdef RYZOM_LUA_UCSTRING void CViewText::setSingleLineTextFormatTagedAsUtf16(const ucstring &text) { setSingleLineTextFormatTaged(text.toUtf8()); } +#endif void CViewText::setSingleLineTextFormatTaged(const std::string &text) { diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp index 5fedc5328..39bf3b92f 100644 --- a/nel/src/misc/utf_string_view.cpp +++ b/nel/src/misc/utf_string_view.cpp @@ -76,7 +76,7 @@ void CUtfStringView::append(IStream &s, u32char c) std::string tmp; tmp.reserve(4); append(tmp, c); - s.serialBuffer((uint8_t *)&tmp[0], tmp.size()); + s.serialBuffer((uint8 *)&tmp[0], tmp.size()); } u32char CUtfStringView::get(IStream &s) @@ -85,7 +85,7 @@ u32char CUtfStringView::get(IStream &s) std::string tmp; tmp.reserve(4); - uint8_t c; + uint8 c; s.serial(c); // Single byte @@ -101,7 +101,7 @@ u32char CUtfStringView::get(IStream &s) // Read from stream tmp.resize(len); - s.serialBuffer((uint8_t *)&tmp[1], len - 1); + s.serialBuffer((uint8 *)&tmp[1], len - 1); // Decode const void *str = tmp.c_str(); diff --git a/nel/src/web/curl_certificates.cpp b/nel/src/web/curl_certificates.cpp index ecb202b76..ac88792bb 100644 --- a/nel/src/web/curl_certificates.cpp +++ b/nel/src/web/curl_certificates.cpp @@ -340,7 +340,7 @@ namespace NLWEB } else { - nldebug("Added certificate %s", entry.name.c_str()); + // nldebug("Added certificate %s", entry.name.c_str()); } } } diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index 618fb5d0c..3cde75dd9 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -2833,7 +2833,7 @@ class CAHScenarioControl : public IActionHandler { CGroupEditBox* editBox = dynamic_cast(result); if(editBox) - editBox->setInputStringAsUtf16(description); + editBox->setInputString(description); } } } diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 748dea81f..d62998a46 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -130,7 +130,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() { if ( pIS->Family == ITEMFAMILY::SCROLL) { - editBoxLarge->setInputStringAsUtf16(itemInfo.CustomText); + editBoxLarge->setInputString(itemInfo.CustomText.toUtf8()); // TODO: UTF-8 (serial) editLarge->setActive(true); editBoxLarge->setActive(true); @@ -244,7 +244,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() // If we already have item info if ( pIS->Family == ITEMFAMILY::SCROLL) { - editBoxLarge->setInputStringAsUtf16(itemInfo.CustomText); + editBoxLarge->setInputString(itemInfo.CustomText.toUtf8()); // TODO: UTF-8 (serial) editLarge->setActive(true); editBoxLarge->setActive(true); diff --git a/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp b/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp index 649f2bd16..4da27749b 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp @@ -71,10 +71,10 @@ class CHandlerGuildCreate : public IActionHandler CGroupEditBox *pDesc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(guildDescWin)); - ucstring guildName = pGEB->getInputStringAsUtf16(); // FIXME: UTF-8 (serial) + ucstring guildName = ucstring::makeFromUtf8(pGEB->getInputString()); // FIXME: UTF-8 (serial) ucstring guildDesc; // FIXME: UTF-8 (serial) - if (pDesc != NULL) guildDesc = pDesc->getInputStringAsUtf16(); // FIXME: UTF-8 (serial) + if (pDesc != NULL) guildDesc.fromUtf8(pDesc->getInputString()); // FIXME: UTF-8 (serial) uint64 icon = CGuildManager::iconMake((uint8)pCS->getGuildBack(), (uint8)pCS->getGuildSymbol(), pCS->getInvertGuildSymbol(), pCS->getGuildColor1(), pCS->getGuildColor2()); diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 27d36adec..3a265b0e2 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -104,7 +104,11 @@ void CControlSheetInfoWaiter::infoReceived() string CControlSheetInfoWaiter::infoValidated() const { - ucstring help; // FIXME: Lua UTF-8 +#ifdef RYZOM_LUA_UCSTRING + ucstring help; // Compatibility +#else + string help; +#endif if (CtrlSheet && !LuaMethodName.empty()) { // delegate setup of context he help ( & window ) to lua @@ -122,7 +126,12 @@ string CControlSheetInfoWaiter::infoValidated() const // retrieve result from stack if (!ls->empty()) { +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::pop(*ls, help); +#else + help = ls->toString(-1); + ls->pop(); +#endif } else { @@ -131,7 +140,11 @@ string CControlSheetInfoWaiter::infoValidated() const } } +#ifdef RYZOM_LUA_UCSTRING return help.toUtf8(); +#else + return help; +#endif } // *************************************************************************** @@ -179,7 +192,11 @@ int CDBCtrlSheet::luaGetItemInfo(CLuaState &ls) // *************************************************************************** int CDBCtrlSheet::luaGetName(CLuaState &ls) { - CLuaIHM::push(ls, getItemActualName()); +#ifdef RYZOM_LUA_UCSTRING + CLuaIHM::push(ls, ucstring::makeFromUtf8(getItemActualName())); +#else + ls.push(getItemActualName()); +#endif return 1; } @@ -209,7 +226,11 @@ int CDBCtrlSheet::luaGetCreatorName(CLuaState &ls) CClientItemInfo itemInfo = getInventory().getItemInfo(itemSlotId); string creatorName; STRING_MANAGER::CStringManagerClient::instance()->getString(itemInfo.CreatorName, creatorName); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::push(ls, ucstring::makeFromUtf8(creatorName)); // FIXME: Lua UTF-8 +#else + ls.push(creatorName); +#endif return 1; } @@ -3507,11 +3528,16 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const game = game["game"]; game.callMethodByNameNoThrow("updatePhraseTooltip", 1, 1); // retrieve result from stack - ucstring tmpHelp; // FIXME: Lua UTF-8 if (!ls->empty()) { - CLuaIHM::pop(*ls, tmpHelp); // FIXME: Lua UTF-8 - help = tmpHelp.toUtf8(); // FIXME: Lua UTF-8 +#ifdef RYZOM_LUA_UCSTRING + ucstring tmpHelp; // Compatibility + CLuaIHM::pop(*ls, tmpHelp); + help = tmpHelp.toUtf8(); +#else + help = ls->toString(); + ls->pop(); +#endif } else { diff --git a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index cbc183f35..43c03d5fc 100644 --- a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -374,7 +374,7 @@ void CDBGroupBuildPhrase::startComposition(const CSPhraseCom &phrase) // set the editable name. if(_UserSentenceName) - _UserSentenceName->setInputStringAsUtf16(name); + _UserSentenceName->setInputString(name); } @@ -1791,7 +1791,7 @@ void CDBGroupBuildPhrase::buildCurrentPhrase(CSPhraseCom &newPhrase) // Set the Name if(_UserSentenceName) { - newPhrase.Name= _UserSentenceName->getInputStringAsUtf16(); + newPhrase.Name= ucstring::makeFromUtf8(_UserSentenceName->getInputString()); } } diff --git a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index 8de31a438..7d435b64f 100644 --- a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -399,7 +399,7 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) // setup task NPC name CStringPostProcessNPCRemoveTitle *pSPPRT = new CStringPostProcessNPCRemoveTitle; - pIM->addServerID (sTmp+":npc:uc_hardtext", pThema->TaskNPCName[i], pSPPRT); + pIM->addServerID (sTmp+":npc:hardtext", pThema->TaskNPCName[i], pSPPRT); // If the task is not known gray it if (pThema->getTaskState((uint8)i) == 0) diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp index 52178cb9c..f7048d193 100644 --- a/ryzom/client/src/interface_v3/group_map.cpp +++ b/ryzom/client/src/interface_v3/group_map.cpp @@ -141,7 +141,7 @@ static void popupLandMarkNameDialog() const CUserLandMark userLM = map->getUserLandMark(LastSelectedLandMark); NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(userLM.Type)); - eb->setInputStringAsUtf16(userLM.Title); + eb->setInputString(userLM.Title.toUtf8()); } else { @@ -3245,9 +3245,10 @@ CGroupMap::CLandMarkButton* CGroupMap::findClosestLandmark(const CVector2f ¢ closest = std::numeric_limits::max(); for(TLandMarkButtonVect::const_iterator it = landmarks.begin(); it != landmarks.end(); ++it) { - ucstring lc; - (*it)->getContextHelpAsUtf16(lc); - if(filterLandmark(lc, keywords, startsWith)) { + std::string lc; + (*it)->getContextHelp(lc); + ucstring ulc = ucstring::makeFromUtf8(lc); + if(filterLandmark(ulc, keywords, startsWith)) { CVector2f pos; mapToWorld(pos, (*it)->Pos); float dist = distsqr(center, pos); @@ -3822,7 +3823,7 @@ class CAHValidateUserLandMarkName : public IActionHandler CGroupMap *map = dynamic_cast(LastSelectedLandMark->getParent()); if (!map) return; // update existing landmark - map->updateUserLandMark(LastSelectedLandMark, eb->getInputStringAsUtf16(), landMarkType); + map->updateUserLandMark(LastSelectedLandMark, ucstring::makeFromUtf8(eb->getInputString()), landMarkType); } else { @@ -3830,11 +3831,11 @@ class CAHValidateUserLandMarkName : public IActionHandler if (!LastClickedMap) return; if( UseUserPositionForLandMark ) { - LastClickedMap->addUserLandMark(LastClickedMap->getPlayerPos(), eb->getInputStringAsUtf16(), landMarkType); + LastClickedMap->addUserLandMark(LastClickedMap->getPlayerPos(), ucstring::makeFromUtf8(eb->getInputString()), landMarkType); } else { - LastClickedMap->addUserLandMark(LastClickedMap->getRightClickLastPos(), eb->getInputStringAsUtf16(), landMarkType); + LastClickedMap->addUserLandMark(LastClickedMap->getRightClickLastPos(), ucstring::makeFromUtf8(eb->getInputString()), landMarkType); } LastClickedMap->invalidateCoords(); } diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 585641fc7..179f782d9 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -262,6 +262,7 @@ static DECLARE_INTERFACE_USER_FCT(lua) // NB: the value is poped in obj.set() (no need to do ls.pop()); // try with ucstring +#ifdef RYZOM_LUA_UCSTRING ucstring ucstrVal; if (CLuaIHM::pop(ls, ucstrVal)) @@ -270,9 +271,10 @@ static DECLARE_INTERFACE_USER_FCT(lua) ok = true; } - // try with RGBA if (!ok) +#endif { + // try with RGBA NLMISC::CRGBA rgbaVal; if (CLuaIHM::pop(ls, rgbaVal)) @@ -508,13 +510,17 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) LUABIND_FUNC(dumpCallStack), LUABIND_FUNC(getDefine), LUABIND_FUNC(setContextHelpText), +#ifdef RYZOM_LUA_UCSTRING luabind::def("messageBox", (void(*)(const ucstring &)) &messageBox), luabind::def("messageBox", (void(*)(const ucstring &, const std::string &)) &messageBox), luabind::def("messageBox", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox), +#endif luabind::def("messageBox", (void(*)(const std::string &)) &messageBox), +#ifdef RYZOM_LUA_UCSTRING luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp), // TODO: Lua UTF-8 luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp), // TODO: Lua UTF-8 luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp), // TODO: Lua UTF-8 +#endif luabind::def("messageBoxWithHelp", (void(*)(const std::string &)) &messageBoxWithHelp), LUABIND_FUNC(replacePvpEffectParam), LUABIND_FUNC(secondsSince1970ToHour), @@ -798,16 +804,24 @@ int CLuaIHMRyzom::validMessageBox(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_validMessageBox) const char *funcName = "validMessageBox"; CLuaIHM::checkArgCount(ls, funcName, 6); +#ifdef RYZOM_LUA_UCSTRING ucstring msg; ls.pushValue(1); // copy ucstring at the end of stack to pop it CLuaIHM::check(ls, CLuaIHM::pop(ls, msg), "validMessageBox : ucstring wanted as first parameter"); +#else + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); +#endif CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 6, LUA_TSTRING); CInterfaceManager *im = CInterfaceManager::getInstance(); +#ifdef RYZOM_LUA_UCSTRING im->validMessageBox(CInterfaceManager::QuestionIconMsg, msg.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4), ls.toString(5), ls.toString(6)); +#else + im->validMessageBox(CInterfaceManager::QuestionIconMsg, ls.toString(1), ls.toString(2), ls.toString(3), ls.toString(4), ls.toString(5), ls.toString(6)); +#endif return 0; } @@ -843,6 +857,7 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1); // *** check and retrieve param 2. must be a string or a ucstring +#ifdef RYZOM_LUA_UCSTRING ucstring text; if (ls.isString(2)) @@ -860,6 +875,13 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) CLuaIHM::check(ls, false, "setTextFormatTaged() requires a string or a ucstring in param 2"); } } +#else + string text; + if (ls.isString(2)) + { + ls.toString(2, text); + } +#endif // must be a view text CViewText *vt = dynamic_cast(pIE); @@ -868,7 +890,11 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) throw ELuaIHMException("setTextFormatTaged(): '%s' is not a CViewText", pIE->getId().c_str()); // Set the text as format +#ifdef RYZOM_LUA_UCSTRING vt->setTextFormatTaged(text.toUtf8()); +#else + vt->setTextFormatTaged(text); +#endif return 0; } @@ -891,8 +917,8 @@ struct CEmoteStruct string::size_type pos1 = path1.find('|'); string::size_type pos2 = path2.find('|'); - ucstring s1 = toUpper(CI18N::get(path1.substr(0, pos1))); - ucstring s2 = toUpper(CI18N::get(path2.substr(0, pos2))); + std::string s1 = toUpper(CI18N::get(path1.substr(0, pos1))); + std::string s2 = toUpper(CI18N::get(path2.substr(0, pos2))); sint result = s1.compare(s2); @@ -1664,12 +1690,22 @@ int CLuaIHMRyzom::displaySystemInfo(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_displaySystemInfo) const char *funcName = "displaySystemInfo"; CLuaIHM::checkArgCount(ls, funcName, 2); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 1); +#else + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); +#endif CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); +#ifdef RYZOM_LUA_UCSTRING ucstring msg; nlverify(CLuaIHM::getUCStringOnStack(ls, 1, msg)); +#endif CInterfaceManager *pIM = CInterfaceManager::getInstance(); +#ifdef RYZOM_LUA_UCSTRING pIM->displaySystemInfo(msg.toUtf8(), ls.toString(2)); +#else + pIM->displaySystemInfo(ls.toString(1), ls.toString(2)); +#endif return 0; } @@ -2836,12 +2872,21 @@ std::string CLuaIHMRyzom::getDefine(const std::string &def) return CWidgetManager::getInstance()->getParser()->getDefine(def); } +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CLuaIHMRyzom::setContextHelpText(const ucstring &text) { CWidgetManager::getInstance()->setContextHelpText(text.toUtf8()); } +#else +// *************************************************************************** +void CLuaIHMRyzom::setContextHelpText(const std::string &text) +{ + CWidgetManager::getInstance()->setContextHelpText(text); +} +#endif +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CLuaIHMRyzom::messageBox(const ucstring &text) { @@ -2870,6 +2915,7 @@ void CLuaIHMRyzom::messageBox(const ucstring &text, const std::string &masterGr CInterfaceManager *pIM = CInterfaceManager::getInstance(); pIM->messageBox(text.toUtf8(), masterGroup, (TCaseMode) caseMode); } +#endif // *************************************************************************** void CLuaIHMRyzom::messageBox(const std::string &text) @@ -2886,6 +2932,28 @@ void CLuaIHMRyzom::messageBox(const std::string &text) pIM->messageBox(text); } +// *************************************************************************** +void CLuaIHMRyzom::messageBox(const std::string &text, const std::string &masterGroup) +{ + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->messageBox(text, masterGroup); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBox(const std::string &text, const std::string &masterGroup, int caseMode) +{ + if (caseMode < 0 || caseMode >= CaseCount) + { + throw ELuaIHMException("messageBox: case mode value is invalid."); + } + + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->messageBox(text, masterGroup, (TCaseMode) caseMode); +} + +#ifdef RYZOM_LUA_UCSTRING // *************************************************************************** void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text) // TODO: Lua UTF-8 { @@ -2914,6 +2982,7 @@ void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string & CInterfaceManager *pIM = CInterfaceManager::getInstance(); pIM->messageBoxWithHelp(text.toUtf8(), masterGroup, "" , "", (TCaseMode) caseMode); } +#endif // *************************************************************************** void CLuaIHMRyzom::messageBoxWithHelp(const std::string &text) @@ -2930,6 +2999,27 @@ void CLuaIHMRyzom::messageBoxWithHelp(const std::string &text) pIM->messageBoxWithHelp(text); } +// *************************************************************************** +void CLuaIHMRyzom::messageBoxWithHelp(const std::string &text, const std::string &masterGroup) +{ + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->messageBoxWithHelp(text, masterGroup); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBoxWithHelp(const std::string &text, const std::string &masterGroup, int caseMode) +{ + if (caseMode < 0 || caseMode >= CaseCount) + { + throw ELuaIHMException("messageBoxWithHelp: case mode value is invalid."); + } + + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->messageBoxWithHelp(text, masterGroup, "" , "", (TCaseMode) caseMode); +} + // *************************************************************************** bool CLuaIHMRyzom::executeFunctionOnStack(CLuaState &ls, int numArgs, int numRet) { @@ -2972,11 +3062,20 @@ bool CLuaIHMRyzom::executeFunctionOnStack(CLuaState &ls, int numArgs, int nu } // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING ucstring CLuaIHMRyzom::replacePvpEffectParam(const ucstring &str, sint32 parameter) +#else +std::string CLuaIHMRyzom::replacePvpEffectParam(const std::string &str, sint32 parameter) +#endif { //H_AUTO(Lua_CLuaIHM_replacePvpEffectParam) +#ifdef RYZOM_LUA_UCSTRING ucstring result = str; CSString s = str.toString(); +#else + std::string result = str; + CSString s = str; +#endif std::string p, paramString; // Locate parameter and store it @@ -3014,7 +3113,11 @@ ucstring CLuaIHMRyzom::replacePvpEffectParam(const ucstring &str, sint32 paramet break; default: +#ifdef RYZOM_LUA_UCSTRING debugInfo("Bad arguments in " + str.toString() + " : " + paramString); +#else + debugInfo("Bad arguments in " + str + " : " + paramString); +#endif } strFindReplace(result, paramString.c_str(), p); @@ -3080,7 +3183,11 @@ void CLuaIHMRyzom::loadBackground(const std::string &bg) // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING ucstring CLuaIHMRyzom::getPatchLastErrorMessage() +#else +std::string CLuaIHMRyzom::getPatchLastErrorMessage() +#endif { #ifdef RYZOM_BG_DOWNLOADER if (isBGDownloadEnabled()) @@ -3133,11 +3240,19 @@ sint32 CLuaIHMRyzom::getSkillIdFromName(const std::string &def) } // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING ucstring CLuaIHMRyzom::getSkillLocalizedName(sint32 skillId) { //H_AUTO(Lua_CLuaIHM_getSkillLocalizedName) return ucstring(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); } +#else +std::string CLuaIHMRyzom::getSkillLocalizedName(sint32 skillId) +{ + //H_AUTO(Lua_CLuaIHM_getSkillLocalizedName) + return STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId); +} +#endif // *************************************************************************** sint32 CLuaIHMRyzom::getMaxSkillValue(sint32 skillId) @@ -3274,13 +3389,23 @@ void CLuaIHMRyzom::clearHtmlUndoRedo(const std::string &htmlId) } // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING ucstring CLuaIHMRyzom::getDynString(sint32 dynStringId) { //H_AUTO(Lua_CLuaIHM_getDynString) string result; STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynStringId, result); - return ucstring::makeFromUtf8(result); // TODO: Lua UTF-8 + return ucstring::makeFromUtf8(result); // Compatibility +} +#else +std::string CLuaIHMRyzom::getDynString(sint32 dynStringId) +{ + //H_AUTO(Lua_CLuaIHM_getDynString) + string result; + STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynStringId, result); + return result; } +#endif // *************************************************************************** bool CLuaIHMRyzom::isDynStringAvailable(sint32 dynStringId) @@ -3560,7 +3685,11 @@ void setMouseCursor(const std::string &texture) } // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) +#else +void CLuaIHMRyzom::tell(const std::string &player, const std::string &msg) +#endif { //H_AUTO(Lua_CLuaIHM_tell) // display a /tell command in the main chat @@ -3569,7 +3698,11 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) if (!msg.empty()) { // Parse any tokens in the message. +#ifdef RYZOM_LUA_UCSTRING string msg_modified = msg.toUtf8(); +#else + string msg_modified = msg; +#endif // Parse any tokens in the text if (! CInterfaceManager::parseTokens(msg_modified)) @@ -3577,7 +3710,11 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) return; } +#ifdef RYZOM_LUA_UCSTRING ChatMngr.tell(player.toUtf8(), msg_modified); +#else + ChatMngr.tell(player, msg_modified); +#endif } else { @@ -3588,7 +3725,11 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) CInterfaceManager *im = CInterfaceManager::getInstance(); w->setKeyboardFocus(); w->enableBlink(1); +#ifdef RYZOM_LUA_UCSTRING w->setCommand("tell " + CEntityCL::removeTitleFromName(player.toUtf8()) + " ", false); +#else + w->setCommand("tell " + CEntityCL::removeTitleFromName(player) + " ", false); +#endif CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) @@ -3638,11 +3779,19 @@ bool CLuaIHMRyzom::isCtrlKeyDown() } // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING std::string CLuaIHMRyzom::encodeURLUnicodeParam(const ucstring &text) { //H_AUTO(Lua_CLuaIHM_encodeURLUnicodeParam) return convertToHTML(text.toUtf8()); } +#else +std::string CLuaIHMRyzom::encodeURLUnicodeParam(const std::string &text) +{ + //H_AUTO(Lua_CLuaIHM_encodeURLUnicodeParam) + return convertToHTML(text); +} +#endif // *************************************************************************** sint32 CLuaIHMRyzom::getPlayerLevel() @@ -3709,6 +3858,7 @@ sint32 CLuaIHMRyzom::getTargetLevel() } // *************************************************************************** +#ifdef RYZOM_LUA_UCSTRING ucstring CLuaIHMRyzom::getTargetSheet() { CEntityCL *target = getTargetEntity(); @@ -3716,6 +3866,15 @@ ucstring CLuaIHMRyzom::getTargetSheet() return target->sheetId().toString(); } +#else +std::string CLuaIHMRyzom::getTargetSheet() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return std::string(); + + return target->sheetId().toString(); +} +#endif // *************************************************************************** sint64 CLuaIHMRyzom::getTargetVpa() diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 978935826..9d82d87ed 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -156,19 +156,35 @@ private: static void getCallStackAsString(int startStackLevel, std::string &result); static std::string getDefine(const std::string &def); +#ifdef RYZOM_LUA_UCSTRING static void setContextHelpText(const ucstring &text); +#else + static void setContextHelpText(const std::string &text); +#endif +#ifdef RYZOM_LUA_UCSTRING static void messageBox(const ucstring &text); static void messageBox(const ucstring &text, const std::string &masterGroup); static void messageBox(const ucstring &text, const std::string &masterGroup, int caseMode); +#endif static void messageBox(const std::string &text); + static void messageBox(const std::string &text, const std::string &masterGroup); + static void messageBox(const std::string &text, const std::string &masterGroup, int caseMode); +#ifdef RYZOM_LUA_UCSTRING static void messageBoxWithHelp(const ucstring &text); static void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup); static void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode); +#endif static void messageBoxWithHelp(const std::string &text); + static void messageBoxWithHelp(const std::string &text, const std::string &masterGroup); + static void messageBoxWithHelp(const std::string &text, const std::string &masterGroup, int caseMode); +#ifdef RYZOM_LUA_UCSTRING static ucstring replacePvpEffectParam(const ucstring &str, sint32 parameter); // TODO: UTF-8 Lua +#else + static std::string replacePvpEffectParam(const std::string &str, sint32 parameter); // TODO: UTF-8 Lua +#endif static sint32 secondsSince1970ToHour(sint32 seconds); #ifdef RYZOM_BG_DOWNLOADER static void pauseBGDownloader(); @@ -177,21 +193,33 @@ private: static sint getBGDownloaderPriority(); #endif static void loadBackground(const std::string &bg); +#ifdef RYZOM_LUA_UCSTRING static ucstring getPatchLastErrorMessage(); +#else + static std::string getPatchLastErrorMessage(); +#endif static bool isInGame(); static uint32 getPlayerSelectedSlot(); static bool isPlayerSlotNewbieLand(uint32 slot); // test if one of the player slot is a newbieland one, if not so, client must be patched in order to continue // GameInfo static sint32 getSkillIdFromName(const std::string &def); +#ifdef RYZOM_LUA_UCSTRING static ucstring getSkillLocalizedName(sint32 skillId); +#else + static std::string getSkillLocalizedName(sint32 skillId); +#endif static sint32 getMaxSkillValue(sint32 skillId); static sint32 getBaseSkillValueMaxChildren(sint32 skillId); static sint32 getMagicResistChance(bool elementalSpell, sint32 casterSpellLvl, sint32 victimResistLvl); static sint32 getDodgeParryChance(sint32 attLvl, sint32 defLvl); static void browseNpcWebPage(const std::string &htmlId, const std::string &url, bool addParameters, double timeout); static void clearHtmlUndoRedo(const std::string &htmlId); +#ifdef RYZOM_LUA_UCSTRING static ucstring getDynString(sint32 dynStringId); +#else + static std::string getDynString(sint32 dynStringId); +#endif static bool isDynStringAvailable(sint32 dynStringId); static bool isFullyPatched(); static std::string getSheetType(const std::string &sheet); @@ -232,13 +260,21 @@ private: static void setMouseCursor(const std::string &texture); // open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly // else, current command of the chat window will be replaced with tell 'player' +#ifdef RYZOM_LUA_UCSTRING static void tell(const ucstring &player, const ucstring &msg); +#else + static void tell(const std::string &player, const std::string &msg); +#endif static bool isRingAccessPointInReach(); static void updateTooltipCoords(); // test if the ctrl key is down (NB nico : I didn't add other key, // because it would be too easy to write a key recorder ...) static bool isCtrlKeyDown(); +#ifdef RYZOM_LUA_UCSTRING static std::string encodeURLUnicodeParam(const ucstring &text); +#else + static std::string encodeURLUnicodeParam(const std::string &text); +#endif static sint32 getPlayerLevel(); // get max level among player skills (magi, combat, crafting ,foraging) static sint64 getPlayerVpa(); @@ -246,8 +282,12 @@ private: static sint64 getPlayerVpc(); static sint32 getTargetLevel(); // get current, precise level of the selected target, or -1 if there's no such selected target static sint32 getTargetForceRegion(); // get 'force region' for current target, or -1 if there's no selected target - static sint32 getTargetLevelForce(); // get 'level force' for current target, or -1 if there's no selected target + static sint32 getTargetLevelForce(); // get 'level force' for current target, or -1 if there's no selected target +#ifdef RYZOM_LUA_UCSTRING static ucstring getTargetSheet(); // get the name of the target sheet (like 'zoha2old.creature') +#else + static std::string getTargetSheet(); // get the name of the target sheet (like 'zoha2old.creature') +#endif static sint64 getTargetVpa(); static sint64 getTargetVpb(); static sint64 getTargetVpc(); diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp index 196ce69f4..0128791a2 100644 --- a/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/ryzom/client/src/interface_v3/people_interraction.cpp @@ -1677,7 +1677,10 @@ bool CPeopleInterraction::saveUserChatsInfos(NLMISC::IStream &f) if (ver>=2) { CChatGroupWindow *pCGW = PeopleInterraction.getChatGroupWindow(); - pCGW->saveFreeTeller(f); + if (pCGW) + { + pCGW->saveFreeTeller(f); + } } } catch(const NLMISC::EStream &e) diff --git a/ryzom/client/src/interface_v3/people_list.cpp b/ryzom/client/src/interface_v3/people_list.cpp index 8c43de2eb..d99089a69 100644 --- a/ryzom/client/src/interface_v3/people_list.cpp +++ b/ryzom/client/src/interface_v3/people_list.cpp @@ -895,7 +895,7 @@ class CHandlerContactEntry : public IActionHandler CGroupContainer *gc = static_cast< CGroupContainer* >( pCaller->getParent()->getEnclosingContainer() ); // title gives the name of the player - string playerName = gc->getUCTitle().toUtf8(); + string playerName = gc->getTitle(); // Simply do a tell on the player ChatMngr.tell(playerName, text); diff --git a/ryzom/client/src/interface_v3/sphrase_manager.cpp b/ryzom/client/src/interface_v3/sphrase_manager.cpp index 379d34c00..94f2b3d84 100644 --- a/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -4675,7 +4675,11 @@ int CSPhraseComAdpater::luaGetStaCost(CLuaState &ls) // *************************************************************************** int CSPhraseComAdpater::luaGetName(CLuaState &ls) { +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::push(ls, this->Phrase.Name); +#else + ls.push(this->Phrase.Name.toUtf8()); +#endif return 1; } @@ -4688,11 +4692,15 @@ int CSPhraseComAdpater::luaGetDesc(CLuaState &ls) if (phraseSheetID != 0) { // is it a built-in phrase? - ucstring desc; // FIXME: UTF-8 Lua - desc.fromUtf8(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId(phraseSheetID))); - if (!desc.empty()) + const char *desc = STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId(phraseSheetID)); + if (*desc) { +#ifdef RYZOM_LUA_UCSTRING + ucstring desc = ucstring::makeFromUtf8(desc); // Compatibility CLuaIHM::push(ls, desc); +#else + ls.push(desc); +#endif return 1; } } diff --git a/ryzom/client/src/r2/dmc/action_historic.cpp b/ryzom/client/src/r2/dmc/action_historic.cpp index 19cab7384..cab232895 100644 --- a/ryzom/client/src/r2/dmc/action_historic.cpp +++ b/ryzom/client/src/r2/dmc/action_historic.cpp @@ -586,7 +586,11 @@ void CActionHistoric::CRequestEraseNode::undo(IDynamicMapClient *dmc, CScenario dmc->doRequestInsertNode(_ParentInstanceId, _AttrNameInParent, _PositionInParent, "", _OldValue); _OldValue = NULL; - CLuaIHM::push(getEditor().getLua(), _InstanceId); +#ifdef RYZOM_LUA_UCSTRING + CLuaIHM::push(getEditor().getLua(), ucstring::makeFromUtf8(_InstanceId)); +#else + getEditor().getLua().push(_InstanceId); +#endif getEditor().callEnvMethod("setUndoRedoInstances", 1, 0); } //==================================================================================== @@ -616,7 +620,11 @@ void CActionHistoric::CRequestInsertNode::redo(IDynamicMapClient *dmc, CScenario dmc->doRequestInsertNode(_InstanceId, _AttrName, _Position, _Key, _Value); CObject* nodeId = _Value->findAttr("InstanceId"); - CLuaIHM::push(getEditor().getLua(), nodeId->toString()); +#ifdef RYZOM_LUA_UCSTRING + CLuaIHM::push(getEditor().getLua(), ucstring::makeFromUtf8(nodeId->toString())); +#else + getEditor().getLua().push(nodeId->toString()); +#endif getEditor().callEnvMethod("setUndoRedoInstances", 1, 0); } // @@ -641,7 +649,11 @@ void CActionHistoric::CRequestInsertNode::undo(IDynamicMapClient *dmc, CScenario // send to network dmc->doRequestEraseNode(instanceId, attrName, position); - CLuaIHM::push(getEditor().getLua(), instanceId); +#ifdef RYZOM_LUA_UCSTRING + CLuaIHM::push(getEditor().getLua(), ucstring::makeFromUtf8(instanceId)); +#else + getEditor().getLua().push(instanceId); +#endif getEditor().callEnvMethod("setUndoRedoInstances", 1, 0); } else diff --git a/ryzom/client/src/r2/dmc/com_lua_module.cpp b/ryzom/client/src/r2/dmc/com_lua_module.cpp index aaa8410ab..789884c76 100644 --- a/ryzom/client/src/r2/dmc/com_lua_module.cpp +++ b/ryzom/client/src/r2/dmc/com_lua_module.cpp @@ -903,6 +903,7 @@ int CComLuaModule::luaRequestNewAction(lua_State* state, bool pending, uint coun } else { +#ifdef RYZOM_LUA_UCSTRING // try with ucstring CLuaState &ls = getEditor().getLua(); nlassert(ls.getStatePointer() == state); @@ -911,6 +912,9 @@ int CComLuaModule::luaRequestNewAction(lua_State* state, bool pending, uint coun nlwarning(" : ucstring or string expected as action name", funcName); return 0; } +#else + return 0; +#endif } } else diff --git a/ryzom/client/src/r2/editor.cpp b/ryzom/client/src/r2/editor.cpp index 0fbce4de7..a46bdfa4a 100644 --- a/ryzom/client/src/r2/editor.cpp +++ b/ryzom/client/src/r2/editor.cpp @@ -1191,10 +1191,15 @@ int CEditor::luaGenInstanceName(CLuaState &ls) CHECK_EDITOR const char *funcName = "genInstanceName"; CLuaIHM::checkArgCount(ls, funcName, 2); // this is a method +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 2); // name ucstring baseName; nlverify(CLuaIHM::getUCStringOnStack(ls, 2, baseName)); CLuaIHM::push(ls, getEditor().genInstanceName(baseName)); +#else + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + ls.push(getEditor().genInstanceName(ucstring::makeFromUtf8(ls.toString(2))).toUtf8()); // FIXME: Ring UTF-8 +#endif return 1; } @@ -1205,10 +1210,15 @@ int CEditor::luaIsPostFixedByNumber(CLuaState &ls) CHECK_EDITOR const char *funcName = "isPostFixedByNumber"; CLuaIHM::checkArgCount(ls, funcName, 2); // this is a method +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 2); // name ucstring baseName; nlverify(CLuaIHM::getUCStringOnStack(ls, 2, baseName)); ls.push(getEditor().isPostFixedByNumber(baseName)); +#else + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + ls.push(getEditor().isPostFixedByNumber(ucstring::makeFromUtf8(ls.toString(2)))); // FIXME: Ring UTF-8 +#endif return 1; } @@ -1326,9 +1336,15 @@ int CEditor::luaSetPlotItemInfos(CLuaState &ls) const char *funcName = "setPlotItemInfos"; CLuaIHM::checkArgCount(ls, funcName, 5); // a method with 4 args CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::checkArgTypeUCString(ls, funcName, 3); CLuaIHM::checkArgTypeUCString(ls, funcName, 4); CLuaIHM::checkArgTypeUCString(ls, funcName, 5); +#else + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); +#endif CItemSheet *item = dynamic_cast(SheetMngr.get(CSheetId((uint32) ls.toInteger(2)))); if (!item || item->Family != ITEMFAMILY::SCROLL_R2) { @@ -1336,9 +1352,15 @@ int CEditor::luaSetPlotItemInfos(CLuaState &ls) } R2::TMissionItem mi; mi.SheetId = (uint32) ls.toInteger(2); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::getUCStringOnStack(ls, 3, mi.Name); CLuaIHM::getUCStringOnStack(ls, 4, mi.Description); CLuaIHM::getUCStringOnStack(ls, 5, mi.Comment); +#else + mi.Name = ucstring::makeFromUtf8(ls.toString(3)); + mi.Description = ucstring::makeFromUtf8(ls.toString(4)); + mi.Comment = ucstring::makeFromUtf8(ls.toString(5)); +#endif getEditor().setPlotItemInfos(mi); return 0; } @@ -7622,7 +7644,11 @@ class CAHR2Undo : public IActionHandler getEditor().setCurrentTool(NULL); const ucstring *actionName = historic.getPreviousActionName(); nlassert(actionName); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::push(getEditor().getLua(), *actionName); +#else + getEditor().getLua().push((*actionName).toUtf8()); +#endif historic.undo(); getEditor().callEnvMethod("onUndo", 1, 0); } @@ -7651,7 +7677,11 @@ class CAHR2Redo : public IActionHandler getEditor().setCurrentTool(NULL); const ucstring *actionName = historic.getNextActionName(); nlassert(actionName); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::push(getEditor().getLua(), *actionName); +#else + getEditor().getLua().push((*actionName).toUtf8()); +#endif historic.redo(); getEditor().callEnvMethod("onRedo", 1, 0); } diff --git a/ryzom/client/src/r2/instance.cpp b/ryzom/client/src/r2/instance.cpp index 6f3d04a2f..78845fb66 100644 --- a/ryzom/client/src/r2/instance.cpp +++ b/ryzom/client/src/r2/instance.cpp @@ -120,8 +120,14 @@ ucstring CInstance::getDisplayName() } if (getLuaProjection().callMethodByNameNoThrow("getDisplayName", 0, 1)) { +#ifdef RYZOM_LUA_UCSTRING ucstring result; if (CLuaIHM::pop(ls, result)) return result; +#else + std::string res = ls.toString(); + ls.pop(); + if (!res.empty()) return res; +#endif } TEST_LUA_PROJ; return ucstring("Can't find display name"); diff --git a/ryzom/client/src/r2/tool.cpp b/ryzom/client/src/r2/tool.cpp index 8620341d8..756ca5de1 100644 --- a/ryzom/client/src/r2/tool.cpp +++ b/ryzom/client/src/r2/tool.cpp @@ -938,7 +938,11 @@ void CTool::setContextHelp(const ucstring &contextHelp) // forward the call to lua (all ui handling done bye lua) CLuaState &ls = getEditor().getLua(); CLuaStackChecker lsc(&ls); +#ifdef RYZOM_LUA_UCSTRING CLuaIHM::push(ls, contextHelp); +#else + ls.push(contextHelp.toUtf8()); +#endif getEditor().callEnvMethod("setToolContextHelp", 1, 0); }