diff --git a/CMakeLists.txt b/CMakeLists.txt index 3225dc1b8..07fe11c8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,8 +54,8 @@ ENDIF() CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(RyzomCore CXX C) SET(NL_VERSION_MAJOR 1) -SET(NL_VERSION_MINOR 0) -SET(NL_VERSION_PATCH 2) +SET(NL_VERSION_MINOR 1) +SET(NL_VERSION_PATCH 0 CACHE STRING "Patch version") SET(YEAR "2001-${CURRENT_YEAR}") SET(AUTHOR "Winch Gate and The Ryzom Core Community") diff --git a/nel/include/nel/3d/computed_string.h b/nel/include/nel/3d/computed_string.h index 3f27a2879..c0ae90578 100644 --- a/nel/include/nel/3d/computed_string.h +++ b/nel/include/nel/3d/computed_string.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -181,7 +181,8 @@ public: CVertexBuffer Vertices; CMaterial *Material; CRGBA Color; - ucstring Text; + std::string Text; + size_t Length; uint32 CacheVersion; diff --git a/nel/include/nel/3d/driver.h b/nel/include/nel/3d/driver.h index 75472df37..1892aace0 100644 --- a/nel/include/nel/3d/driver.h +++ b/nel/include/nel/3d/driver.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -262,10 +262,10 @@ public: virtual NLMISC::IEventEmitter *getEventEmitter() = 0; /// Copy a string to system clipboard. - virtual bool copyTextToClipboard(const ucstring &text) = 0; + virtual bool copyTextToClipboard(const std::string &text) = 0; /// Paste a string from system clipboard. - virtual bool pasteTextFromClipboard(ucstring &text) = 0;/// Return the depth of the driver after init(). + virtual bool pasteTextFromClipboard(std::string &text) = 0;/// Return the depth of the driver after init(). virtual uint8 getBitPerPixel() = 0; diff --git a/nel/include/nel/3d/driver_user.h b/nel/include/nel/3d/driver_user.h index c3564975f..a59d167a4 100644 --- a/nel/include/nel/3d/driver_user.h +++ b/nel/include/nel/3d/driver_user.h @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -558,10 +558,10 @@ public: // @} // Copy a string to system clipboard. - virtual bool copyTextToClipboard(const ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); // Paste a string from system clipboard. - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool pasteTextFromClipboard(std::string &text); virtual uint64 getSwapBufferCounter(); diff --git a/nel/include/nel/3d/font_generator.h b/nel/include/nel/3d/font_generator.h index b69249d58..eca05d456 100644 --- a/nel/include/nel/3d/font_generator.h +++ b/nel/include/nel/3d/font_generator.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -64,17 +67,17 @@ public: * \param height height of the generated bitmap, this value is set by this function * \param pitch pitch of the generated bitmap (+ or - the number of bytes per row), this value is set by this function */ - uint8 *getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex); + uint8 *getBitmap (u32char c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex); /** returns the width and height of a character using a specific size and * * \warning this function is not very fast (but faster than getBitmap()) because it has to load the char before. */ - void getSizes (ucchar c, uint32 size, uint32 &width, uint32 &height); + void getSizes (u32char c, uint32 size, uint32 &width, uint32 &height); - void getKerning (ucchar left, ucchar right, sint32 &kernx); + void getKerning (u32char left, u32char right, sint32 &kernx); - uint32 getCharIndex (ucchar c); + uint32 getCharIndex (u32char c); uint32 getUID() { return _UID; } diff --git a/nel/include/nel/3d/font_manager.h b/nel/include/nel/3d/font_manager.h index 663e9d23a..620b2164f 100644 --- a/nel/include/nel/3d/font_manager.h +++ b/nel/include/nel/3d/font_manager.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -19,6 +22,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/smart_ptr.h" +#include "nel/misc/utf_string_view.h" #include "nel/3d/texture.h" #include "nel/3d/material.h" #include "nel/3d/texture_font.h" @@ -111,6 +115,7 @@ public: * \param output computed string * \param keep800x600Ratio true if you want that CFontManager look at Driver window size, and resize fontSize so it keeps same size... */ + /* void computeString (const std::string& s, CFontGenerator *fontGen, const NLMISC::CRGBA &color, @@ -120,11 +125,12 @@ public: IDriver *driver, CComputedString& output, bool keep800x600Ratio= true); + */ /** * Same as computeString but works with a unicode string (ucstring) */ - void computeString (const ucstring &s, + void computeString (NLMISC::CUtfStringView sv, CFontGenerator *fontGen, const NLMISC::CRGBA &color, uint32 fontSize, @@ -137,7 +143,21 @@ public: /** * Same as computeString but do not make vertex buffers and primitives */ - void computeStringInfo (const ucstring &s, + void computeStringInfo (NLMISC::CUtfStringView sv, + size_t len, + CFontGenerator *fontGen, + const NLMISC::CRGBA &color, + uint32 fontSize, + bool embolden, + bool oblique, + IDriver *driver, + CComputedString &output, + bool keep800x600Ratio= true); + + /** + * Same as computeString but do not make vertex buffers and primitives + */ + void computeStringInfo (NLMISC::CUtfStringView sv, CFontGenerator *fontGen, const NLMISC::CRGBA &color, uint32 fontSize, diff --git a/nel/include/nel/3d/landscape.h b/nel/include/nel/3d/landscape.h index f6e1a5861..cf05f6c9a 100644 --- a/nel/include/nel/3d/landscape.h +++ b/nel/include/nel/3d/landscape.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/include/nel/3d/text_context.h b/nel/include/nel/3d/text_context.h index 1eb256855..a8d4188a8 100644 --- a/nel/include/nel/3d/text_context.h +++ b/nel/include/nel/3d/text_context.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -134,7 +134,7 @@ public: uint32 textPush (const char *format, ...); /// computes an ucstring and adds the result to the cache (return the index) - uint32 textPush (const ucstring &str); + uint32 textPush (NLMISC::CUtfStringView sv); /// remove a string from the cache void erase (uint32 index); @@ -262,12 +262,12 @@ public: } /// Directly print a string - void printAt (float x, float z, const ucstring &ucstr) + void printAt (float x, float z, NLMISC::CUtfStringView sv) { nlassert(_FontGen); // compute the string just one time - _FontManager->computeString (ucstr, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, _TempString, _Keep800x600Ratio); + _FontManager->computeString (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, _TempString, _Keep800x600Ratio); // draw shaded if (_Shaded) @@ -372,14 +372,19 @@ public: * \param an ucstring * \param the computed string */ - void computeString (const ucstring& s, CComputedString& output) + void computeString (NLMISC::CUtfStringView sv, CComputedString& output) { - _FontManager->computeString (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio); + _FontManager->computeString (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio); + } + + void computeStringInfo (NLMISC::CUtfStringView sv, CComputedString& output) + { + _FontManager->computeStringInfo (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio); } - void computeStringInfo (const ucstring& s, CComputedString& output) + void computeStringInfo (NLMISC::CUtfStringView sv, CComputedString& output, size_t len) { - _FontManager->computeStringInfo (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio); + _FontManager->computeStringInfo (sv, len, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio); } /// Debug : write to the disk the texture cache diff --git a/nel/include/nel/3d/text_context_user.h b/nel/include/nel/3d/text_context_user.h index 2a167b2e9..b673bfa8f 100644 --- a/nel/include/nel/3d/text_context_user.h +++ b/nel/include/nel/3d/text_context_user.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -97,13 +97,14 @@ public: */ // @{ uint32 textPush(const char *format, ...) ; - uint32 textPush(const ucstring &str) ; + uint32 textPush(NLMISC::CUtfStringView sv) ; void setStringColor(uint32 i, CRGBA newCol); void setStringSelection(uint32 i, uint32 selectStart, uint32 selectSize); void resetStringSelection(uint32 i); void erase(uint32 i) ; virtual CStringInfo getStringInfo (uint32 i); - virtual CStringInfo getStringInfo (const ucstring &ucstr); + virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv); + virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv, size_t len); void clear() ; void printAt(float x, float y, uint32 i) ; @@ -111,10 +112,10 @@ public: void printClipAtUnProjected(URenderStringBuffer &renderBuffer, class NL3D::CFrustum &frustum, const NLMISC::CMatrix &scaleMatrix, float x, float y, float depth, uint32 i, float xmin, float ymin, float xmax, float ymax); void printClipAtOld (float x, float y, uint32 i, float xmin, float ymin, float xmax, float ymax); - void printAt(float x, float y, const ucstring &ucstr) ; + void printAt(float x, float y, NLMISC::CUtfStringView sv) ; void printfAt(float x, float y, const char * format, ...) ; - void render3D(const CMatrix &mat, const ucstring &ucstr) ; + void render3D(const CMatrix &mat, NLMISC::CUtfStringView sv) ; void render3D(const CMatrix &mat, const char *format, ...) ; float getLastXBound() const ; diff --git a/nel/include/nel/3d/texture.h b/nel/include/nel/3d/texture.h index f74af29d9..6016917d2 100644 --- a/nel/include/nel/3d/texture.h +++ b/nel/include/nel/3d/texture.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/include/nel/3d/texture_font.h b/nel/include/nel/3d/texture_font.h index 865615b63..b250fecd8 100644 --- a/nel/include/nel/3d/texture_font.h +++ b/nel/include/nel/3d/texture_font.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -69,7 +72,7 @@ public: // Holds info for glyphs displayed on screen struct SLetterInfo { - ucchar Char; + u32char Char; sint Size; bool Embolden; bool Oblique; @@ -94,7 +97,7 @@ public: struct SLetterKey { - ucchar Char; + u32char Char; sint Size; bool Embolden; bool Oblique; diff --git a/nel/include/nel/3d/u_driver.h b/nel/include/nel/3d/u_driver.h index f4f78e2cb..24e3d6482 100644 --- a/nel/include/nel/3d/u_driver.h +++ b/nel/include/nel/3d/u_driver.h @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -835,10 +835,10 @@ public: /// \name Clipboard management // @{ // Copy a string to system clipboard. - virtual bool copyTextToClipboard(const ucstring &text) =0; + virtual bool copyTextToClipboard(const std::string &text) =0; // Paste a string from system clipboard. - virtual bool pasteTextFromClipboard(ucstring &text) =0; + virtual bool pasteTextFromClipboard(std::string &text) =0; // @} public: diff --git a/nel/include/nel/3d/u_text_context.h b/nel/include/nel/3d/u_text_context.h index cdde02f82..f7f833c47 100644 --- a/nel/include/nel/3d/u_text_context.h +++ b/nel/include/nel/3d/u_text_context.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -24,7 +24,7 @@ #include "nel/misc/rgba.h" #include "nel/misc/ucstring.h" #include "nel/misc/matrix.h" - +#include "nel/misc/utf_string_view.h" namespace NL3D { @@ -104,8 +104,11 @@ public: */ float StringLine; - CStringInfo() {StringWidth= StringHeight= StringLine= 0;} - CStringInfo(float w, float h, float l) {StringWidth= w; StringHeight= h; StringLine = l;} + /// The length in characters + size_t StringLength; + + CStringInfo() { StringWidth = StringHeight = StringLine = 0; StringLength = 0; } + CStringInfo(float w, float h, float l, size_t len) { StringWidth = w; StringHeight = h; StringLine = l; StringLength = len; } /** * Get the string's origin @@ -248,7 +251,7 @@ public: * \param an ucstring * \return the index where computed string has been inserted */ - virtual uint32 textPush (const ucstring &str) = 0; + virtual uint32 textPush (NLMISC::CUtfStringView sv) = 0; /** * set the color of a string. */ @@ -274,7 +277,12 @@ public: * Get a string information from the ucstring * The returned string info is in pixel size per default. */ - virtual CStringInfo getStringInfo (const ucstring &ucstr) = 0; + virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv) = 0; + /** + * Get a string information from the ucstring + * The returned string info is in pixel size per default. + */ + virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv, size_t len) = 0; /** * empty the map */ @@ -299,7 +307,7 @@ public: /** * compute and print a ucstring at the location (2D method) x/y E [0,1] */ - virtual void printAt (float x, float y, const ucstring &ucstr) = 0; + virtual void printAt (float x, float y, NLMISC::CUtfStringView sv) = 0; /** * compute and print a string at the location (2D method) x/y E [0,1] */ @@ -309,7 +317,7 @@ public: * compute and render a ucstring at the location (3D method) * render3D() use UDriver Matrix context for Frustum/ViewMatrix, but use its own modelmatrix (mat). */ - virtual void render3D (const NLMISC::CMatrix &mat, const ucstring &ucstr) = 0; + virtual void render3D (const NLMISC::CMatrix &mat, NLMISC::CUtfStringView sv) = 0; /** * compute and render a string at the location (3D method) * render3D() use UDriver Matrix context for Frustum/ViewMatrix, but use its own modelmatrix (mat). diff --git a/nel/include/nel/gui/css_parser.h b/nel/include/nel/gui/css_parser.h index a6dc92022..c3a426ee7 100644 --- a/nel/include/nel/gui/css_parser.h +++ b/nel/include/nel/gui/css_parser.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -38,7 +41,7 @@ namespace NLGUI private: // stylesheet currently parsed - ucstring _Style; + std::string _Style; // keep track of current position in _Style size_t _Position; @@ -70,49 +73,49 @@ namespace NLGUI void preprocess(); // parse selectors + combinators - std::vector parse_selector(const ucstring &sel, std::string &pseudoElement) const; + std::vector parse_selector(const std::string &sel, std::string &pseudoElement) const; // 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 { 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') || - (ch >= (ucchar)'a' && ch <= (ucchar)'f') || - (ch >= (ucchar)'A' && ch <= (ucchar)'F')); + return ((ch >= '0' && ch <= '9') || + (ch >= 'a' && ch <= 'f') || + (ch >= 'A' && ch <= 'F')); } inline bool maybe_escape() const { // 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)'}') || - (open == '[' && ch == (ucchar)']') || - (open == '(' && ch == (ucchar)')')); + return ((open == '{' && ch == (char)'}') || + (open == '[' && ch == (char)']') || + (open == '(' && ch == (char)')')); } inline bool is_comment_open() const @@ -120,25 +123,25 @@ namespace NLGUI if (_Position+1 > _Style.size()) 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*/; } - inline bool is_alpha(ucchar ch) const + inline bool is_alpha(char ch) const { 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'; } - 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 return ch == '_' || ch == '-' || is_alpha(ch) || is_digit(ch) || is_nonascii(ch) || ch == '\\'/*is_escape(ch)*/; diff --git a/nel/include/nel/gui/ctrl_base.h b/nel/include/nel/gui/ctrl_base.h index a8bdef85f..9c80e7f7a 100644 --- a/nel/include/nel/gui/ctrl_base.h +++ b/nel/include/nel/gui/ctrl_base.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -85,9 +86,10 @@ namespace NLGUI /// 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. - 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" virtual std::string getContextHelpWindowName() const; /// Get the ContextHelp ActionHandler. If "", noop @@ -123,8 +125,10 @@ namespace NLGUI void setToolTipPosRef(THotSpot pos) { _ToolTipPosRef = pos;} /// replace the default contextHelp - ucstring getDefaultContextHelp() const {return _ContextHelp;} - void setDefaultContextHelp(const ucstring &help) {_ContextHelp= help;} + 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();} void setOnContextHelp(const std::string &help) {_OnContextHelp= help;} void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;} @@ -158,7 +162,7 @@ namespace NLGUI int luaSetTooltipUtf8(CLuaState &ls); 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_EXPORT_END @@ -171,7 +175,7 @@ namespace NLGUI protected: // This is the ContextHelp filled by default in parse() - ucstring _ContextHelp; + std::string _ContextHelp; CStringShared _OnContextHelp; CStringShared _OnContextHelpParams; CStringShared _ToolTipSpecialParent; diff --git a/nel/include/nel/gui/ctrl_text_button.h b/nel/include/nel/gui/ctrl_text_button.h index 9bae24ad5..a49d426ae 100644 --- a/nel/include/nel/gui/ctrl_text_button.h +++ b/nel/include/nel/gui/ctrl_text_button.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -96,8 +97,10 @@ namespace NLGUI bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;} void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;} // Set text (noop if text id) - void setText (const ucstring &text); - ucstring getText () const; + void setText (const std::string &text); + std::string getText () const; + void setTextAsUtf16 (const ucstring &text); + ucstring getTextAsUtf16 () const; void setHardText (const std::string &text); std::string getHardText () const; @@ -140,7 +143,7 @@ namespace NLGUI int luaGetViewText(CLuaState &ls); REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton) - REFLECT_UCSTRING("uc_hardtext", getText, setText); + REFLECT_UCSTRING("uc_hardtext", getTextAsUtf16, setTextAsUtf16); REFLECT_STRING("hardtext", getHardText, setHardText); REFLECT_SINT32("text_x", getTextX, setTextX) REFLECT_SINT32("wmargin", getWMargin, setWMargin) diff --git a/nel/include/nel/gui/dbgroup_combo_box.h b/nel/include/nel/gui/dbgroup_combo_box.h index 6f42572bb..ddf84cbef 100644 --- a/nel/include/nel/gui/dbgroup_combo_box.h +++ b/nel/include/nel/gui/dbgroup_combo_box.h @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -60,13 +60,15 @@ namespace NLGUI // Combo Texts void resetTexts(); - void addText(const ucstring &text); - void setText(uint i, const ucstring &text); - void insertText(uint i, const ucstring &text); - const ucstring &getText(uint i) const; + void addText(const std::string &text); + void setText(uint i, const std::string &text); + void insertText(uint i, const std::string &text); + const std::string &getText(uint i) const; + ucstring getTextAsUtf16(uint i) const; uint getTextId(uint i) const; uint getTextPos(uint nId) const; - const ucstring &getTexture(uint i) const; + const std::string &getTexture(uint i) const; + ucstring getTextureAsUtf16(uint i) const; void setGrayed(uint i, bool g); bool getGrayed(uint i) const; void removeText(uint nPos); @@ -87,11 +89,13 @@ namespace NLGUI std::string getSelectionText() const; // view text - void setViewText(const ucstring & text); - ucstring getViewText() const; + void setViewText(const std::string & text); + std::string getViewText() const; + void setViewTextAsUtf16(const ucstring &text) { setViewText(text.toUtf8()); } + ucstring getViewTextAsUtf16() const; CViewText *getViewText(); - void setTexture(uint i, const ucstring &texture); + void setTexture(uint i, const std::string &texture); sint32 evalContentWidth() const; @@ -122,7 +126,7 @@ namespace NLGUI REFLECT_LUA_METHOD("resetTexts", luaResetTexts) REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb) REFLECT_STRING ("selection_text", getSelectionText, setSelectionText) - REFLECT_UCSTRING ("view_text", getViewText, setViewText) + REFLECT_UCSTRING ("view_text", getViewTextAsUtf16, setViewTextAsUtf16) // FIXME: Better to have UTF-8 REFLECT_EXPORT_END @@ -137,8 +141,8 @@ namespace NLGUI // sint32 CInterfaceProperty _Selection; sint32 _NotLinkedToDBSelection; - std::vector > _Texts; - std::vector _Textures; + std::vector > _Texts; + std::vector _Textures; std::vector _Grayed; // Action Handler called on combo click @@ -155,7 +159,7 @@ namespace NLGUI CCtrlBaseButton *_SelectButton; bool _IsExternViewText; - ucstring _ExternViewText; + std::string _ExternViewText; private: diff --git a/nel/include/nel/gui/dbview_quantity.h b/nel/include/nel/gui/dbview_quantity.h index 16a11f5a0..e172624d7 100644 --- a/nel/include/nel/gui/dbview_quantity.h +++ b/nel/include/nel/gui/dbview_quantity.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -57,7 +58,7 @@ namespace NLGUI CInterfaceProperty _NumberMax; sint32 _Cache; sint32 _CacheMax; - ucstring _EmptyText; + std::string _EmptyText; void buildTextFromCache(); }; diff --git a/nel/include/nel/gui/event_descriptor.h b/nel/include/nel/gui/event_descriptor.h index 95bdad212..69c90ff5d 100644 --- a/nel/include/nel/gui/event_descriptor.h +++ b/nel/include/nel/gui/event_descriptor.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -60,7 +61,7 @@ public: keydown = 0, // a key has been press down. The key value is stored as a TKey keyup, // a key has been released. The key value is stored as a TKey keychar, // a key has been stroke. The key is a ucchar - keystring, // a string has been sent. The string is a ucstring + keystring, // a string has been sent. The string is a utf-8 string unknown, // uninitialized event }; CEventDescriptorKey() : _KeyEvent(unknown), _CtrlState(false), _ShiftState(false), _AltState(false), _Char(0) @@ -82,13 +83,13 @@ public: return _Key; } // 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); return _Char; } // 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); return _String; @@ -141,9 +142,9 @@ private: union { NLMISC::TKey _Key; - ucchar _Char; + u32char _Char; }; - ucstring _String; + std::string _String; }; // ---------------------------------------------------------------------------- diff --git a/nel/include/nel/gui/group_container.h b/nel/include/nel/gui/group_container.h index 742dfcfb2..d7c489e5f 100644 --- a/nel/include/nel/gui/group_container.h +++ b/nel/include/nel/gui/group_container.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -287,9 +288,11 @@ namespace NLGUI REFLECT_STRING("title", getTitle, setTitle); REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened); REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed); - REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); - REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); - REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); + + 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_SINT32("pop_min_h", getPopupMinH, setPopupMinH); REFLECT_SINT32("pop_max_h", getPopupMaxH, setPopupMaxH); @@ -302,6 +305,8 @@ namespace NLGUI REFLECT_BOOL("lockable", isLockable, setLockable); REFLECT_BOOL("locked", isLocked, setLocked); + REFLECT_BOOL("localize", isLocalize, setLocalize); + REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive); REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled); REFLECT_EXPORT_END @@ -364,7 +369,7 @@ namespace NLGUI bool isActiveSavable() const { return _ActiveSavable; } bool isLocalize() const { return _Localize; } - void setLocalize(bool localize) { _Localize = localize; } + void setLocalize(bool localize); void setPopupX(sint32 x) { _PopupX = x; } void setPopupY(sint32 y) { _PopupY = y; } @@ -477,8 +482,8 @@ namespace NLGUI float _CurrentRolloverAlphaContainer; float _CurrentRolloverAlphaContent; sint32 _LayerSetup; - ucstring _TitleTextOpened; - ucstring _TitleTextClosed; + std::string _TitleTextOpened; + std::string _TitleTextClosed; CViewText *_TitleOpened; CViewText *_TitleClosed; sint32 _TitleDeltaMaxW; @@ -636,6 +641,9 @@ namespace NLGUI TTileClass convertTitleClass(const char *ptr); + void setTitledOpenedViewText(); + void setTitledClosedViewText(); + static COptionsContainerMove *getMoveOptions(); COptionsLayer *getContainerOptions(sint32 ls=-1); // Depends if overload by OptionsName or default used diff --git a/nel/include/nel/gui/group_editbox.h b/nel/include/nel/gui/group_editbox.h index 096f3daa0..4bf200df8 100644 --- a/nel/include/nel/gui/group_editbox.h +++ b/nel/include/nel/gui/group_editbox.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -63,26 +64,27 @@ namespace NLGUI virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); /// Accessors - ucstring getInputString() const { return _InputString; } - const ucstring &getInputStringRef() const { return _InputString; } - const ucstring &getPrompt() const { return _Prompt; } + std::string getInputString() const; + std::string getPrompt() const; + const ::u32string &getInputStringRef() const { return _InputString; } + const ::u32string &getPromptRef() const { return _Prompt; } /** Set the prompt * NB : line returns are encoded as '\n', not '\r\n' */ - void setPrompt(const ucstring &s) { _Prompt = s; } - void setInputString(const ucstring &str); - void setInputStringRef(const ucstring &str) {_InputString = str; }; + void setPrompt(const std::string &s); + void setInputString(const std::string &str); + void setInputStringRef(const ::u32string &str) {_InputString = str; }; void setInputStringAsInt(sint32 val); sint32 getInputStringAsInt() const; void setInputStringAsInt64(sint64 val); sint64 getInputStringAsInt64() const; void setInputStringAsFloat(float val); float getInputStringAsFloat() const; - void setInputStringAsStdString(const std::string &str); - std::string getInputStringAsStdString() const; - void setInputStringAsUtf8(const std::string &str); - std::string getInputStringAsUtf8() const; + void setInputStringAsUtf16(const ucstring &str); + ucstring getInputStringAsUtf16() const; + void setInputStringAsUtf32(const ::u32string &str); + ::u32string getInputStringAsUtf32() const { return _InputString; } void setColor(NLMISC::CRGBA col); @@ -97,7 +99,7 @@ namespace NLGUI static CGroupEditBox *getMenuFather() { return _MenuFather; } - void setCommand(const ucstring &command, bool execute); + void setCommand(const std::string &command, bool execute); // Stop parent from blinking void stopParentBlink() { if (_Parent) _Parent->disableBlink(); } @@ -121,7 +123,7 @@ namespace NLGUI sint32 getMaxHistoric() const {return _MaxHistoric;} sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;} void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;} - const ucstring &getHistoric(uint32 index) const {return _Historic[index];} + const ::u32string &getHistoric(uint32 index) const {return _Historic[index];} uint32 getNumHistoric() const {return (uint32)_Historic.size ();} // Get on change action handler @@ -139,7 +141,7 @@ namespace NLGUI // Paste the selection into buffer void paste(); // Write the string into buffer - void writeString(const ucstring &str, bool replace = true, bool atEnd = true); + void writeString(const std::string &str, bool replace = true, bool atEnd = true); // Expand the expression (true if there was a '/' at the start of the line) bool expand(); @@ -170,7 +172,7 @@ namespace NLGUI virtual void onKeyboardCaptureLost(); // 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 void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;} @@ -189,8 +191,8 @@ namespace NLGUI REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll); REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText); REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText); - REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString); - REFLECT_UCSTRING("uc_input_string", getInputString, setInputString); + REFLECT_STRING("input_string", getInputString, setInputString); + REFLECT_UCSTRING("uc_input_string", getInputStringAsUtf16, setInputStringAsUtf16); REFLECT_EXPORT_END /** Restore the original value of the edit box. @@ -228,17 +230,17 @@ namespace NLGUI NLMISC::CRGBA _BackSelectColor; // Text info - ucstring _Prompt; - ucstring _InputString; + ::u32string _Prompt; + ::u32string _InputString; CViewText *_ViewText; // undo / redo - ucstring _StartInputString; // value of the input string when focus was acuired first - ucstring _ModifiedInputString; + ::u32string _StartInputString; // value of the input string when focus was acuired first + ::u32string _ModifiedInputString; // Historic info - typedef std::deque THistoric; + typedef std::deque<::u32string> THistoric; THistoric _Historic; uint32 _MaxHistoric; sint32 _CurrentHistoricIndex; @@ -275,7 +277,7 @@ namespace NLGUI bool _CanRedo : 1; bool _CanUndo : 1; - std::vector _NegativeFilter; + std::vector _NegativeFilter; sint _CursorTexID; sint32 _CursorWidth; @@ -298,13 +300,13 @@ namespace NLGUI void handleEventString(const NLGUI::CEventDescriptorKey &event); void setup(); void triggerOnChangeAH(); - void appendStringFromClipboard(const ucstring &str); + void appendStringFromClipboard(const std::string &str); - ucstring getSelection(); + std::string getSelection(); static CGroupEditBox *_MenuFather; - static bool isValidAlphaNumSpace(ucchar c) + static bool isValidAlphaNumSpace(u32char c) { if (c > 255) return false; char ac = (char) c; @@ -314,7 +316,7 @@ namespace NLGUI ac==' '; } - static bool isValidAlphaNum(ucchar c) + static bool isValidAlphaNum(u32char c) { if (c > 255) return false; char ac = (char) c; @@ -323,7 +325,7 @@ namespace NLGUI (ac >= 'A' && ac <= 'Z'); } - static bool isValidAlpha(ucchar c) + static bool isValidAlpha(u32char c) { if (c > 255) return false; char ac = (char) c; @@ -331,13 +333,13 @@ namespace NLGUI (ac >= 'A' && ac <= 'Z'); } - static bool isValidPlayerNameChar(ucchar c) + static bool isValidPlayerNameChar(u32char c) { // valid player name (with possible shard prefix / suffix format return isValidAlpha(c) || c=='.' || c=='(' || c==')'; } - static bool isValidFilenameChar(ucchar c) + static bool isValidFilenameChar(u32char c) { if (c == '\\' || c == '/' || @@ -351,12 +353,12 @@ namespace NLGUI return true; } // - bool isFiltered(ucchar c) + bool isFiltered(u32char c) { - uint length = (uint)_NegativeFilter.size(); - for (uint k = 0; k < length; ++k) + ptrdiff_t length = _NegativeFilter.size(); + for (ptrdiff_t k = 0; k < length; ++k) { - if ((ucchar) _NegativeFilter[k] == c) return true; + if (_NegativeFilter[k] == c) return true; } return false; } diff --git a/nel/include/nel/gui/group_html.h b/nel/include/nel/gui/group_html.h index 590c43a89..a96f0180a 100644 --- a/nel/include/nel/gui/group_html.h +++ b/nel/include/nel/gui/group_html.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -320,16 +321,16 @@ namespace NLGUI void clearContext(); // 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 - void addString(const ucstring &str); + void addString(const std::string &str); // Add an image in the current paragraph 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 - 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 CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name); @@ -350,9 +351,9 @@ namespace NLGUI void flushString(); // Set the title - void setTitle (const ucstring &title); void setTitle (const std::string &title); std::string getTitle() const; + void setContainerTitle (const std::string &title); // Lookup a url in local file system bool lookupLocalFile (std::string &result, const char *url, bool isUrl); @@ -392,10 +393,10 @@ namespace NLGUI bool _TrustedDomain; // Title prefix - ucstring _TitlePrefix; + std::string _TitlePrefix; // Title string - ucstring _TitleString; + std::string _TitleString; // Need to browse next update coords.. bool _BrowseNextTime; @@ -644,7 +645,7 @@ namespace NLGUI std::string Name; // Variable value - ucstring Value; + std::string Value; // Text area group CInterfaceGroup *TextArea; @@ -747,7 +748,7 @@ namespace NLGUI // Current node is a text area bool _TextArea; std::string _TextAreaTemplate; - ucstring _TextAreaContent; + std::string _TextAreaContent; std::string _TextAreaName; uint _TextAreaRow; uint _TextAreaCols; @@ -755,7 +756,7 @@ namespace NLGUI // current mode is in select option bool _SelectOption; - ucstring _SelectOptionStr; + std::string _SelectOptionStr; // Current node is a object std::string _ObjectType; @@ -765,7 +766,7 @@ namespace NLGUI std::string _TextAreaScript; // Get last char - ucchar getLastChar() const; + u32char getLastChar() const; // Current link view class CViewLink *_CurrentViewLink; @@ -826,7 +827,7 @@ namespace NLGUI void spliceFragment(std::list::iterator src); // decode all HTML entities - static ucstring decodeHTMLEntities(const ucstring &str); + static std::string decodeHTMLEntities(const std::string &str); struct CDataImageDownload { diff --git a/nel/include/nel/gui/group_list.h b/nel/include/nel/gui/group_list.h index 58af530b5..e7fda6eb3 100644 --- a/nel/include/nel/gui/group_list.h +++ b/nel/include/nel/gui/group_list.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -67,13 +68,13 @@ namespace NLGUI * \param line : text to be added * \param color : text color */ - void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true); + void addTextChild (const std::string& line,const NLMISC::CRGBA &textColor, bool multiLine = true); /** * add a text child element to the group, using the text template * \param line : text to be added */ - void addTextChild (const ucstring& line, bool multiLine = true); + void addTextChild (const std::string& line, bool multiLine = true); /// Same as adding a text child but the text will be taken from the string manager void addTextChildID (uint32 id, bool multiLine = true); diff --git a/nel/include/nel/gui/group_menu.h b/nel/include/nel/gui/group_menu.h index 21a740d84..fb5f9af88 100644 --- a/nel/include/nel/gui/group_menu.h +++ b/nel/include/nel/gui/group_menu.h @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -122,12 +122,12 @@ namespace NLGUI // retrieve the index of a line from its id (-1 if not found) sint getLineFromId(const std::string &id); - CViewTextMenu* addLine (const ucstring &name, const std::string &ah, + CViewTextMenu* addLine (const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id="", const std::string &cond = std::string(), const std::string &texture="", bool checkable = false, bool checked = false, bool formatted = false ); - CViewTextMenu* addLineAtIndex(uint index, const ucstring &name, const std::string &ah, + CViewTextMenu* addLineAtIndex(uint index, const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id="", const std::string &cond = std::string(), const std::string &texture="", bool checkable = false, bool checked = false, bool formatted = false @@ -332,12 +332,7 @@ namespace NLGUI virtual void setActive (bool state); virtual bool isWindowUnder (sint32 x, sint32 y); - - // add line with a string, for backward compatibility - void addLine (const std::string &name, const std::string &ah, const std::string ¶ms, - const std::string &id = std::string(), - const std::string &cond = std::string(), const std::string &texture="", - bool checkable = false, bool checked = false); + uint getNumLine() const; void deleteLine(uint index); const std::string getActionHandler(uint lineIndex) const; @@ -350,12 +345,12 @@ namespace NLGUI void setRightClickHandler(uint lineIndex, const std::string &ah = ""); void setRightClickHandlerParam(uint lineIndex, const std::string ¶ms = ""); - void addLine (const ucstring &name, const std::string &ah = "", const std::string ¶ms = "", + void addLine (const std::string &name, const std::string &ah = "", const std::string ¶ms = "", const std::string &id = std::string(), const std::string &cond = std::string(), const std::string &texture="", bool checkable = false, bool checked = false ); - void addLineAtIndex (uint index, const ucstring &name, const std::string &ah = "", const std::string ¶ms = "", + void addLineAtIndex (uint index, const std::string &name, const std::string &ah = "", const std::string ¶ms = "", const std::string &id = std::string(), const std::string &cond = std::string(), const std::string &texture="", bool checkable = false, bool checked = false diff --git a/nel/include/nel/gui/group_paragraph.h b/nel/include/nel/gui/group_paragraph.h index 6142bc33b..20bc50585 100644 --- a/nel/include/nel/gui/group_paragraph.h +++ b/nel/include/nel/gui/group_paragraph.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -84,13 +85,13 @@ namespace NLGUI * \param line : text to be added * \param color : text color */ - void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true); + void addTextChild (const std::string& line,const NLMISC::CRGBA &textColor, bool multiLine = true); /** * add a text child element to the group, using the text template * \param line : text to be added */ - void addTextChild (const ucstring& line, bool multiLine = true); + void addTextChild (const std::string& line, bool multiLine = true); /// Same as adding a text child but the text will be taken from the string manager void addTextChildID (uint32 id, bool multiLine = true); diff --git a/nel/include/nel/gui/group_tree.h b/nel/include/nel/gui/group_tree.h index 266e7e23f..835a305e1 100644 --- a/nel/include/nel/gui/group_tree.h +++ b/nel/include/nel/gui/group_tree.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -60,7 +61,7 @@ namespace NLGUI bool Show; // If false, the node is not displayed (true default, Root ignored) sint32 YDecal; // Text - ucstring Text; // Internationalized displayed text + std::string Text; // Internationalized displayed text sint32 FontSize; // If -1 (default), then take the groupTree one NLMISC::CRGBA Color; // Template @@ -112,8 +113,10 @@ namespace NLGUI std::string getBitmap() const { return Bitmap; } void setOpened(bool opened) { Opened = opened; } bool getOpened() const { return Opened; } - void setText(const ucstring &text) { Text = text; } - const ucstring& getText() const { return Text; } + void setText(const std::string &text) { Text = text; } + const std::string& getText() const { return Text; } + void setTextAsUtf16(const ucstring &text) { Text = text.toUtf8(); } + ucstring getTextAsUtf16() const { return ucstring::makeFromUtf8(Text); } sint32 getFontSize() const { return FontSize; } void setFontSize(sint32 value) { FontSize = value; } sint32 getYDecal() const { return YDecal; } @@ -181,7 +184,7 @@ namespace NLGUI REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose); REFLECT_BOOL("Opened", getOpened, setOpened); REFLECT_BOOL("Show", getShow, setShow); - REFLECT_UCSTRING_REF("Text", getText, setText); + REFLECT_UCSTRING("Text", getTextAsUtf16, setTextAsUtf16); // FIXME: Lua UTF-8 // lua REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren); REFLECT_LUA_METHOD("getChild", luaGetChild); diff --git a/nel/include/nel/gui/interface_element.h b/nel/include/nel/gui/interface_element.h index 47025f155..42fa1de2f 100644 --- a/nel/include/nel/gui/interface_element.h +++ b/nel/include/nel/gui/interface_element.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/include/nel/gui/interface_expr.h b/nel/include/nel/gui/interface_expr.h index b967ef7ab..b4474ac22 100644 --- a/nel/include/nel/gui/interface_expr.h +++ b/nel/include/nel/gui/interface_expr.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -59,16 +60,15 @@ namespace NLGUI bool getBool() const; sint64 getInteger() const; double getDouble() const; - std::string getString() const; + const std::string &getString() const; NLMISC::CRGBA getRGBA() const; - const ucstring &getUCString() const; CInterfaceExprUserType *getUserType() const; // set void setBool(bool value) { clean(); _Type = Boolean; _BoolValue = value; } void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; } void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; } void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; } - void setUCString(const ucstring &value) { clean(); _Type = String; _StringValue = value; } + void setString(const char *value) { clean(); _Type = String; _StringValue = value; } void setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); } void setUserType(CInterfaceExprUserType *value); // reset this object to initial state (no type) @@ -99,7 +99,7 @@ namespace NLGUI CInterfaceExprUserType *_UserTypeValue; uint32 _RGBAValue; }; - ucstring _StringValue; // well, can't fit in union, unless we do some horrible hack.. + std::string _StringValue; // well, can't fit in union, unless we do some horrible hack.. private: const char *evalBoolean(const char *expr); const char *evalNumber(const char *expr); diff --git a/nel/include/nel/gui/interface_group.h b/nel/include/nel/gui/interface_group.h index 9f1e5562b..672e52e6a 100644 --- a/nel/include/nel/gui/interface_group.h +++ b/nel/include/nel/gui/interface_group.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/include/nel/gui/lua_helper.h b/nel/include/nel/gui/lua_helper.h index da5c33e6a..fa941f79a 100644 --- a/nel/include/nel/gui/lua_helper.h +++ b/nel/include/nel/gui/lua_helper.h @@ -2,8 +2,8 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -379,6 +379,10 @@ namespace NLGUI TSmallScriptCache _SmallScriptCache; static const char * _NELSmallScriptTableName; +#ifdef _WIN32 + HMODULE m_LuaSocket; +#endif + private: // this object isn't intended to be copied CLuaState(const CLuaState &/* other */):NLMISC::CRefCount() { nlassert(0); } diff --git a/nel/include/nel/gui/lua_helper_inline.h b/nel/include/nel/gui/lua_helper_inline.h index 0d380bbf1..d50455880 100644 --- a/nel/include/nel/gui/lua_helper_inline.h +++ b/nel/include/nel/gui/lua_helper_inline.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -263,8 +263,8 @@ inline lua_Integer CLuaState::toInteger(int index) if (!isnum) { lua_Number d = lua_tonumber(_State, index); - nlwarning("Lua: Unable to convert Lua number %lf to integer", d); res = (lua_Integer)d; + nlwarning("Lua: Converting lua_Number %lf to lua_Integer %i", d, (int)res); } return res; #else diff --git a/nel/include/nel/gui/reflect.h b/nel/include/nel/gui/reflect.h index 8bd3b4781..7da0b3529 100644 --- a/nel/include/nel/gui/reflect.h +++ b/nel/include/nel/gui/reflect.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/include/nel/gui/string_case.h b/nel/include/nel/gui/string_case.h index ec8fa2925..44e38651f 100644 --- a/nel/include/nel/gui/string_case.h +++ b/nel/include/nel/gui/string_case.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -21,11 +22,9 @@ #define STRING_CASE_H #include "nel/misc/types_nl.h" -#include "nel/misc/ucstring.h" namespace NLGUI { - enum TCaseMode { CaseNormal = 0, // Nothing done @@ -37,10 +36,7 @@ namespace NLGUI CaseCount }; - - void setCase( ucstring &str, TCaseMode mode ); - - + void setCase( std::string &str, TCaseMode mode ); } #endif diff --git a/nel/include/nel/gui/view_pointer.h b/nel/include/nel/gui/view_pointer.h index cb550e44a..db7355465 100644 --- a/nel/include/nel/gui/view_pointer.h +++ b/nel/include/nel/gui/view_pointer.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -55,13 +56,16 @@ namespace NLGUI bool getStringMode() const {return _StringMode;} // Set cursor string - void setString (const ucstring &str); + void setString (const std::string &str); // TEMP PATCH void setCursor (const std::string &name) { - _TxDefault = name; - _TxIdDefault = -2; + if (_TxDefault != name) + { + _TxDefault = name; + _TxIdDefault = -2; + } } // TEMP PATCH @@ -126,14 +130,14 @@ namespace NLGUI bool _ForceStringMode; CInterfaceGroup *_StringCursor; CInterfaceGroup *_StringCursorHardware; - ucstring _ContextString; + std::string _ContextString; // draw current cursor with the given texture, or, if in hardware mode, change the hardware cursor shape void drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot); private: // set the string into frame for software or hardware version - void setString (const ucstring &str, CInterfaceGroup *target); + void setString(const std::string &str, CInterfaceGroup *target); static bool hwMouse; diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index 57ab6a096..69f9efca7 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -84,7 +84,10 @@ namespace NLGUI /// Set - void setText (const ucstring &text); + void setText(const std::string &text); + void setTextLocalized(const std::string &text, bool localized); + void setTextAsUtf16 (const ucstring &text); + void setLocalized(bool localized); void setFontName (const std::string &name); void setFontSize (sint nFontSize, bool coef = true); void setEmbolden (bool nEmbolden); @@ -95,7 +98,8 @@ namespace NLGUI void setShadowColor (const NLMISC::CRGBA &color); void setShadowOffset (sint x, sint y); void setLineMaxW (sint nMaxW, bool invalidate=true); - void setOverflowText(const ucstring &text) { _OverflowText = text; } + void setOverflowText(const std::string &text) { _OverflowText = text; } + void setOverflowTextAsUtf16(const ucstring &text) { _OverflowText = text.toUtf8(); } void setMultiLine (bool bMultiLine); void setMultiLineSpace (sint nMultiLineSpace); void setMultiLineMaxWOnly (bool state); @@ -112,8 +116,10 @@ namespace NLGUI void disableStringSelection(); /// Get - - ucstring getText() const { return _Text; } + std::string getText() const { return _HardText.empty() ? _Text : _HardText; } + ucstring getTextAsUtf16() const; + ucstring getHardTextAsUtf16() const; + bool isLocalized() const { return _Localized; } sint getFontSize() const; std::string getFontName() const { return _FontName; } bool getEmbolden() { return _Embolden; } @@ -124,7 +130,7 @@ namespace NLGUI NLMISC::CRGBA getShadowColor() { return _ShadowColor; } void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; } sint getLineMaxW() const { return _LineMaxW; } - ucstring getOverflowText() const { return _OverflowText; } + ucstring getOverflowTextAsUtf16() const { return _OverflowText; } bool getMultiLine() const { return _MultiLine; } sint getMultiLineSpace() const { return _MultiLineSpace; } bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; } @@ -174,8 +180,9 @@ namespace NLGUI /// From a line number, get the character at which it ends (not including any '\n' ), or -1 if invalid void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const; - std::string getHardText() const { std::string result; _Text.toString (result); return result; } - void setHardText (const std::string &ht); + 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); std::string getColorAsString() const; void setColorAsString(const std::string &ht); @@ -188,9 +195,11 @@ namespace NLGUI /** Setup a Text with Format Tags. Text is store without color/format tags, and special array is allocated for Format association */ - void setTextFormatTaged(const ucstring &text); + void setTextFormatTaged(const std::string &text); + void setTextFormatTagedAsUtf16(const ucstring &text); - void setSingleLineTextFormatTaged(const ucstring &text); + void setSingleLineTextFormatTaged(const std::string &text); + void setSingleLineTextFormatTagedAsUtf16(const ucstring &text); // Remove end space void removeEndSpaces(); @@ -216,10 +225,13 @@ namespace NLGUI int luaSetLineMaxW(CLuaState &ls); REFLECT_EXPORT_START(CViewText, CViewBase) + REFLECT_STRING("text_raw", getText, setText); REFLECT_STRING("hardtext", getHardText, setHardText); - REFLECT_UCSTRING("uc_hardtext", getText, setText); - REFLECT_UCSTRING("uc_hardtext_format", getText, setTextFormatTaged); - REFLECT_UCSTRING("uc_hardtext_single_line_format", getText, setSingleLineTextFormatTaged); + REFLECT_BOOL ("localize", isLocalized, setLocalized); + // REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions + REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16); + REFLECT_UCSTRING("uc_hardtext_format", getTextAsUtf16, setTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense + REFLECT_UCSTRING("uc_hardtext_single_line_format", getTextAsUtf16, setSingleLineTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense REFLECT_STRING ("color", getColorAsString, setColorAsString); REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA); REFLECT_SINT32 ("alpha", getAlpha, setAlpha); @@ -228,7 +240,6 @@ namespace NLGUI REFLECT_LUA_METHOD("setLineMaxW", luaSetLineMaxW); REFLECT_EXPORT_END - virtual void serial(NLMISC::IStream &f); // Sets the parent element @@ -236,9 +247,12 @@ namespace NLGUI void setParentElm( CInterfaceElement *parent ){ _ParentElm = parent; } protected: - std::string _HardtextFormat; /// Text to display. - ucstring _Text; + std::string _HardTextFormat; + std::string _HardText; + std::string _Text; + mutable sint _TextLength; + bool _Localized; /// index of the computed String associated to this text control uint _Index; /// info on the computed String associated to this text control @@ -253,8 +267,8 @@ namespace NLGUI // width of the font in pixel. Just a Hint for tabing format (computed with '_') float _FontWidth; // strings to use when computing font size - ucstring _FontSizingChars; - ucstring _FontSizingFallback; + std::string _FontSizingChars; + std::string _FontSizingFallback; // height of the font in pixel. // use getFontHeight float _FontHeight; @@ -278,7 +292,7 @@ namespace NLGUI sint32 _LineMaxW; /// For single line, true if the text is clamped (ie displayed with "...") bool _SingleLineTextClamped; - ucstring _OverflowText; + std::string _OverflowText; /// Multiple lines handling bool _MultiLine; @@ -339,7 +353,7 @@ namespace NLGUI public: // default ctor CWord(uint numSpaces = 0) : Index(0), NumSpaces(numSpaces) {} - ucstring Text; + std::string Text; uint Index; // index of the info for this word NL3D::UTextContext::CStringInfo Info; uint NumSpaces; // number of spaces before this word @@ -347,7 +361,7 @@ namespace NLGUI CFormatInfo Format; public: // build from a string, using the current text context - void build(const ucstring &text, NL3D::UTextContext &textContext, uint numSpaces= 0); + void build(const std::string &text, NL3D::UTextContext &textContext, uint numSpaces= 0); }; typedef std::vector TWordVect; @@ -360,7 +374,7 @@ namespace NLGUI // Clear the line & remove text contexts void clear(NL3D::UTextContext &textContext); // Add a new word (and its context) in the line + a number of spaces to append at the end of the line - void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, float fontWidth, NL3D::UTextContext &textContext); + void addWord(const std::string &word, uint numSpaces, const CFormatInfo &wordFormat, float fontWidth, NL3D::UTextContext &textContext); void addWord(const CWord &word, float fontWidth); uint getNumWords() const { return (uint)_Words.size(); } CWord &getWord(uint index) { return _Words[index]; } @@ -434,7 +448,9 @@ namespace NLGUI void setup (); void setupDefault (); - void setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd); + void setTextLocalized(const std::string &text); + + void setStringSelectionSkipingSpace(uint stringId, const std::string &text, sint charStart, sint charEnd); // void pushString(const ucstring &str, bool deleteSpaceAtStart = false); @@ -442,7 +458,7 @@ namespace NLGUI void onInvalidateContent(); // may append a new line, and append a word to the last line (no spaces) - void flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat); + void flushWordInLine(std::string &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat); // Clear all the lines and free their datas void clearLines(); // Update in the case of a multiline text @@ -456,7 +472,7 @@ namespace NLGUI void addDontClipWordLine(std::vector &currLine); // FormatTag build. - static void buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector &formatTags, std::vector &tooltips); + static void buildFormatTagText(const std::string &text, std::string &textBuild, std::vector &formatTags, std::vector &tooltips); // FormatTag parsing. bool isFormatTagChange(uint textIndex, uint ctIndex) const; void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const; diff --git a/nel/include/nel/gui/view_text_formated.h b/nel/include/nel/gui/view_text_formated.h index 43a7eb9a8..1b7146b8b 100644 --- a/nel/include/nel/gui/view_text_formated.h +++ b/nel/include/nel/gui/view_text_formated.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -45,7 +46,7 @@ namespace NLGUI { public: virtual ~IViewTextFormatter(){} - virtual ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) = 0; + virtual std::string formatString( const std::string &inputString, const std::string ¶mString ) = 0; }; CViewTextFormated (const TCtorParam ¶m) : CViewText(param) @@ -55,15 +56,15 @@ namespace NLGUI xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual void checkCoords(); - const ucstring &getFormatString() const { return _FormatString; } - void setFormatString(const ucstring &format); + const std::string &getFormatString() const { return _FormatString; } + void setFormatString(const std::string &format); - static ucstring formatString(const ucstring &inputString, const ucstring ¶mString); + static std::string formatString(const std::string &inputString, const std::string ¶mString); static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; } private: - ucstring _FormatString; + std::string _FormatString; static IViewTextFormatter *textFormatter; }; diff --git a/nel/include/nel/gui/view_text_id.h b/nel/include/nel/gui/view_text_id.h index 1e46de062..292f1728a 100644 --- a/nel/include/nel/gui/view_text_id.h +++ b/nel/include/nel/gui/view_text_id.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -58,8 +59,8 @@ namespace NLGUI { public: virtual ~IViewTextProvider(){} - virtual bool getString( uint32 stringId, ucstring &result ) = 0; - virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0; + virtual bool getString(uint32 stringId, std::string &result) = 0; + virtual bool getDynString(uint32 dynStringId, std::string &result) = 0; }; CViewTextID(const TCtorParam ¶m) : CViewText(param) diff --git a/nel/include/nel/gui/view_text_id_formated.h b/nel/include/nel/gui/view_text_id_formated.h index cbc494dc1..428bca035 100644 --- a/nel/include/nel/gui/view_text_id_formated.h +++ b/nel/include/nel/gui/view_text_id_formated.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -49,10 +50,10 @@ namespace NLGUI xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual void checkCoords(); - const ucstring &getFormatString() const { return _FormatString; } - void setFormatString(const ucstring &format); + const std::string &getFormatString() const { return _FormatString; } + void setFormatString(const std::string &format); private: - ucstring _FormatString; + std::string _FormatString; }; } diff --git a/nel/include/nel/gui/widget_manager.h b/nel/include/nel/gui/widget_manager.h index fced74024..dc1d75063 100644 --- a/nel/include/nel/gui/widget_manager.h +++ b/nel/include/nel/gui/widget_manager.h @@ -2,8 +2,8 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -333,8 +333,8 @@ namespace NLGUI void updateTooltipCoords(CCtrlBase *newCtrl); /// for ContextHelp action handler only: set the result name - void setContextHelpText( const ucstring &text ){ _ContextHelpText = text; } - ucstring& getContextHelpText(){ return _ContextHelpText; } + void setContextHelpText( const std::string &text ){ _ContextHelpText = text; } + std::string& getContextHelpText(){ return _ContextHelpText; } /// force disable the context help void disableContextHelp(); @@ -626,7 +626,7 @@ namespace NLGUI SInterfaceTimes interfaceTimes; - ucstring _ContextHelpText; + std::string _ContextHelpText; bool _ContextHelpActive; bool inGame; diff --git a/nel/include/nel/misc/common.h b/nel/include/nel/misc/common.h index a5d1b2f27..bca3372bd 100644 --- a/nel/include/nel/misc/common.h +++ b/nel/include/nel/misc/common.h @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2015-2019 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -227,17 +227,33 @@ inline double isValidDouble (double v) * \param str a string to transform to lower case */ -std::string toLower ( const char *str ); -std::string toLower ( const std::string &str ); -void toLower ( char *str ); +std::string toLower ( const char *str ); // UTF-8 +std::string toLower ( const std::string &str ); // UTF-8 +void toLower ( char *str ); // Ascii only char toLower ( const char ch ); // convert only one character /** Convert a string in upper case. * \param a string to transform to upper case */ -std::string toUpper ( const std::string &str); -void toUpper ( char *str); +std::string toUpper ( const char *str ); // UTF-8 +std::string toUpper ( const std::string &str); // UTF-8 +void toUpper ( char *str); // Ascii only + +/** Convert a single character in UTF-8 to upper or lowercase. +* \param res Character is appended in UTF-8 into this string. +* \param src Character is sourced from this UTF-8 string. +* \param i Index in `str`, incremented by the number of bytes read. +*/ +void appendToLower(std::string &res, const char *str, ptrdiff_t &i); +void appendToLower(std::string &res, const std::string &str, ptrdiff_t &i); +void appendToUpper(std::string &res, const char *str, ptrdiff_t &i); +void appendToUpper(std::string &res, const std::string &str, ptrdiff_t &i); + +/** UTF-8 case insensitive compare */ +int compareCaseInsensitive(const char *a, const char *b); +int compareCaseInsensitive(const char *a, size_t lenA, const char *b, size_t lenB); +inline int compareCaseInsensitive(const std::string &a, const std::string &b) { return compareCaseInsensitive(&a[0], a.size(), &b[0], b.size()); } /** diff --git a/nel/include/nel/misc/debug.h b/nel/include/nel/misc/debug.h index 1d533c149..9b6e48376 100644 --- a/nel/include/nel/misc/debug.h +++ b/nel/include/nel/misc/debug.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/include/nel/misc/event_emitter_multi.h b/nel/include/nel/misc/event_emitter_multi.h index e41ee2055..cb41d023f 100644 --- a/nel/include/nel/misc/event_emitter_multi.h +++ b/nel/include/nel/misc/event_emitter_multi.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -48,8 +51,8 @@ public: /// From IEventEmitter. This call submitEvents on all the emitters virtual void submitEvents(CEventServer &server, bool allWindows); - virtual bool copyTextToClipboard(const ucstring &text); - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); + virtual bool pasteTextFromClipboard(std::string &text); private: typedef std::vector > TEmitterCont; diff --git a/nel/include/nel/misc/events.h b/nel/include/nel/misc/events.h index c783a85eb..b75d72ca2 100644 --- a/nel/include/nel/misc/events.h +++ b/nel/include/nel/misc/events.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -320,11 +323,11 @@ public: class CEventChar : public CEventKey { 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; } - ucchar Char; + u32char Char; virtual CEvent *clone() const {return new CEventChar(*this);} void setRaw( bool raw ) { _Raw = raw; } @@ -341,11 +344,11 @@ private: class CEventString : public CEventKey { public: - CEventString (const ucstring &str, IEventEmitter* emitter) : CEventKey (noKeyButton, emitter, EventStringId) + CEventString (const std::string &str, IEventEmitter* emitter) : CEventKey (noKeyButton, emitter, EventStringId) { String = str; } - ucstring String; + std::string String; virtual CEvent *clone() const {return new CEventString(*this);} }; diff --git a/nel/include/nel/misc/file.h b/nel/include/nel/misc/file.h index f634f4378..6f0584dd7 100644 --- a/nel/include/nel/misc/file.h +++ b/nel/include/nel/misc/file.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/include/nel/misc/i18n.h b/nel/include/nel/misc/i18n.h index e8b00385b..86499eae5 100644 --- a/nel/include/nel/misc/i18n.h +++ b/nel/include/nel/misc/i18n.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -99,7 +100,7 @@ public: /// 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 - static const std::vector &getLanguageNames(); + static const std::vector &getLanguageNames(); /** Return a vector with all language code available. * Code are ISO 639-2 compliant. @@ -122,7 +123,7 @@ public: static void loadFromFilename (const std::string &filename, bool reload); /// 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", ...) static std::string getCurrentLanguageCode (); @@ -134,7 +135,10 @@ public: static bool setSystemLanguageCode (const std::string &languageCode); /// 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. // NB : The empty string is considered to have a translation @@ -219,24 +223,28 @@ public: private: - typedef std::map StrMapContainer; + typedef std::map StrMapContainer; + typedef std::map StrMapContainer16; static ILoadProxy *_LoadProxy; static StrMapContainer _StrMap; + static StrMapContainer16 _StrMap16; static bool _StrMapLoaded; // the alternative language that will be used if the sentence is not found in the original language static StrMapContainer _StrMapFallback; + static StrMapContainer16 _StrMapFallback16; static std::vector _LanguageCodes; - static std::vector _LanguageNames; + static std::vector _LanguageNames; static std::string _SystemLanguageCode; static bool _LanguagesNamesLoaded; static std::string _SelectedLanguageCode; - static const ucstring _NotTranslatedValue; + static const ucstring _NotTranslatedValue16; + static const std::string _NotTranslatedValue; /** Structure to hold contextual info during * read of preprocessed file @@ -256,7 +264,7 @@ private: /// Init _LanguageCodes and _LanguageNames 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 static void _readTextFile(const std::string &filename, diff --git a/nel/include/nel/misc/sha1.h b/nel/include/nel/misc/sha1.h index d458c6f8f..8c046fca1 100644 --- a/nel/include/nel/misc/sha1.h +++ b/nel/include/nel/misc/sha1.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/include/nel/misc/sheet_id.h b/nel/include/nel/misc/sheet_id.h index 856dbf330..c1fc7070f 100644 --- a/nel/include/nel/misc/sheet_id.h +++ b/nel/include/nel/misc/sheet_id.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2012 Jan BOON (Kaetemi) +// Copyright (C) 2012-2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/include/nel/misc/stream.h b/nel/include/nel/misc/stream.h index 89db78a1c..9b18d575c 100644 --- a/nel/include/nel/misc/stream.h +++ b/nel/include/nel/misc/stream.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/include/nel/misc/string_common.h b/nel/include/nel/misc/string_common.h index 9f6d59aae..71ab05a30 100644 --- a/nel/include/nel/misc/string_common.h +++ b/nel/include/nel/misc/string_common.h @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2016-2019 Jan BOON (Kaetemi) +// Copyright (C) 2016-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -193,6 +193,10 @@ inline std::string toString(const sint32 &val) { return toString("%d", val); } inline std::string toString(const uint64 &val) { return toString("%" NL_I64 "u", val); } inline std::string toString(const sint64 &val) { return toString("%" NL_I64 "d", val); } +#ifdef NL_OS_WINDOWS +inline std::string toString(const wchar_t &val) { return toString(reinterpret_cast(val)); } +#endif + #ifdef NL_COMP_GCC # if GCC_VERSION == 40102 @@ -246,9 +250,14 @@ inline bool fromString(const std::string &str, sint64 &val) { bool ret = sscanf( inline bool fromString(const std::string &str, float &val) { bool ret = sscanf(str.c_str(), "%f", &val) == 1; if (!ret) val = 0.0f; return ret; } inline bool fromString(const std::string &str, double &val) { bool ret = sscanf(str.c_str(), "%lf", &val) == 1; if (!ret) val = 0.0; return ret; } -// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, anything else is undefined. -// (str[0] == '1' || (str[0] & 0xD2) == 0x50) -// - Kaetemi +#ifdef NL_OS_WINDOWS +inline bool fromString(const std::string &str, wchar_t &val) { return fromString(str, reinterpret_cast(val)); } +#endif + +/// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, and empty strings, anything else is undefined. +/// - Kaetemi +inline bool toBool(const char *str) { return str[0] == '1' || (str[0] & 0xD2) == 0x50; } +inline bool toBool(const std::string &str) { return toBool(str.c_str()); } // Safe because first byte may be null bool fromString(const std::string &str, bool &val); diff --git a/nel/include/nel/misc/system_utils.h b/nel/include/nel/misc/system_utils.h index 426e38b73..5cec22af2 100644 --- a/nel/include/nel/misc/system_utils.h +++ b/nel/include/nel/misc/system_utils.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2015-2019 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -49,10 +49,10 @@ public: static bool updateProgressBar(uint value, uint total); /// Copy a string to system clipboard. - static bool copyTextToClipboard(const ucstring &text); + static bool copyTextToClipboard(const std::string &text); /// Paste a string from system clipboard. - static bool pasteTextFromClipboard(ucstring &text); + static bool pasteTextFromClipboard(std::string &text); /// Check if system supports unicode. static bool supportUnicode(); diff --git a/nel/include/nel/misc/types_nl.h b/nel/include/nel/misc/types_nl.h index 445882c34..a257eb293 100644 --- a/nel/include/nel/misc/types_nl.h +++ b/nel/include/nel/misc/types_nl.h @@ -2,7 +2,7 @@ // Copyright (C) 2010-2011 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -548,6 +548,14 @@ template<> struct hash */ typedef uint16 ucchar; +#ifdef NL_CPP14 +typedef char32_t u32char; +typedef std::u32string u32string; +#else +typedef uint32 u32char; +typedef std::basic_string u32string; +#endif + #ifndef NL_OVERRIDE #define NL_OVERRIDE override #endif diff --git a/nel/include/nel/misc/ucstring.h b/nel/include/nel/misc/ucstring.h index b3dc1294f..5b95c33c2 100644 --- a/nel/include/nel/misc/ucstring.h +++ b/nel/include/nel/misc/ucstring.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -35,113 +35,111 @@ typedef std::basic_string ucstringbase; class ucstring : public ucstringbase { public: + ucstring() { } - ucstring () {} + ucstring(const ucstringbase &str) + : ucstringbase(str) + { + } - ucstring (const ucstringbase &str) : ucstringbase (str) {} + ucstring(const ucchar *begin, const ucchar *end) + : ucstringbase(begin, end) + { + } - ucstring (const std::string &str) : ucstringbase () + ucstring(const std::string &str) + : ucstringbase() { - rawCopy(str); + fromUtf8(str); } - ~ucstring () {} + ~ucstring() { } - ucstring &operator= (ucchar c) + ucstring &operator=(ucchar c) { - resize (1); + resize(1); operator[](0) = c; return *this; } - ucstring &operator= (const char *str) + ucstring &operator=(const char *str) { - resize (strlen (str)); - for (uint i = 0; i < strlen (str); i++) + resize(strlen(str)); + for (uint i = 0; i < strlen(str); i++) { operator[](i) = uint8(str[i]); } return *this; } - ucstring &operator= (const std::string &str) + ucstring &operator=(const std::string &str) { - resize (str.size ()); - for (uint i = 0; i < str.size (); i++) + resize(str.size()); + for (uint i = 0; i < str.size(); i++) { operator[](i) = uint8(str[i]); } return *this; } - ucstring &operator= (const ucstringbase &str) + ucstring &operator=(const ucstringbase &str) { - ucstringbase::operator =(str); + ucstringbase::operator=(str); return *this; } - ucstring& operator= (const ucchar *str) + ucstring &operator=(const ucchar *str) { - ucstringbase::operator =(str); + ucstringbase::operator=(str); return *this; } - ucstring &operator+= (ucchar c) + ucstring &operator+=(ucchar c) { - resize (size() + 1); - operator[](size()-1) = c; + resize(size() + 1); + operator[](size() - 1) = c; return *this; } - ucstring &operator+= (const char *str) + ucstring &operator+=(const char *str) { size_t s = size(); - resize (s + strlen(str)); + resize(s + strlen(str)); for (uint i = 0; i < strlen(str); i++) { - operator[](s+i) = uint8(str[i]); + operator[](s + i) = uint8(str[i]); } return *this; } - ucstring &operator+= (const std::string &str) + ucstring &operator+=(const std::string &str) { size_t s = size(); - resize (s + str.size()); + resize(s + str.size()); for (uint i = 0; i < str.size(); i++) { - operator[](s+i) = uint8(str[i]); + operator[](s + i) = uint8(str[i]); } return *this; } - ucstring &operator+= (const ucstringbase &str) + ucstring &operator+=(const ucstringbase &str) { - ucstringbase::operator +=(str); + ucstringbase::operator+=(str); return *this; } const ucchar *c_str() const { const ucchar *tmp = ucstringbase::c_str(); - const_cast(tmp)[size()] = 0; + const_cast(tmp)[size()] = 0; return tmp; } /// Converts the controlled ucstring to a string str - void toString (std::string &str) const - { - str.resize (size ()); - for (uint i = 0; i < str.size (); i++) - { - if (operator[](i) > 255) - str[i] = '?'; - else - str[i] = (char) operator[](i); - } - } + void toString(std::string &str) const; /// Converts the controlled ucstring and returns the resulting string - std::string toString () const + std::string toString() const { std::string str; toString(str); @@ -149,43 +147,7 @@ public: } /// Convert this ucstring (16bits char) into a utf8 string - std::string toUtf8() const - { - std::string res; - ucstring::const_iterator first(begin()), last(end()); - for (; first != last; ++first) - { - //ucchar c = *first; - uint nbLoop = 0; - if (*first < 0x80) - res += char(*first); - else if (*first < 0x800) - { - ucchar c = *first; - c = c >> 6; - c = c & 0x1F; - res += char(c) | 0xC0; - nbLoop = 1; - } - else /*if (*first < 0x10000)*/ - { - ucchar c = *first; - c = c >> 12; - c = c & 0x0F; - res += char(c) | 0xE0; - nbLoop = 2; - } - - for (uint i=0; i> ((nbLoop - i - 1) * 6); - c = c & 0x3F; - res += char(c) | 0x80; - } - } - return res; - } + std::string toUtf8() const; ucstring substr(size_type pos = 0, size_type n = npos) const { @@ -199,86 +161,7 @@ public: } /// Convert the utf8 string into this ucstring (16 bits char) - void fromUtf8(const std::string &stringUtf8) - { - // clear the string - erase(); - - uint8 c; - ucchar code; - sint iterations = 0; - - std::string::const_iterator first(stringUtf8.begin()), last(stringUtf8.end()); - for (; first != last; ) - { - c = *first++; - code = c; - - if ((code & 0xFE) == 0xFC) - { - code &= 0x01; - iterations = 5; - } - else if ((code & 0xFC) == 0xF8) - { - code &= 0x03; - iterations = 4; - } - else if ((code & 0xF8) == 0xF0) - { - code &= 0x07; - iterations = 3; - } - else if ((code & 0xF0) == 0xE0) - { - code &= 0x0F; - iterations = 2; - } - else if ((code & 0xE0) == 0xC0) - { - code &= 0x1F; - iterations = 1; - } - else if ((code & 0x80) == 0x80) - { - // If it's not a valid UTF8 string, just copy the line without utf8 conversion - rawCopy(stringUtf8); - return; - } - else - { - push_back(code); - iterations = 0; - } - - if (iterations) - { - for (sint i = 0; i < iterations; i++) - { - if (first == last) - { - // If it's not a valid UTF8 string, just copy the line without utf8 conversion - rawCopy(stringUtf8); - return; - } - - uint8 ch; - ch = *first ++; - - if ((ch & 0xC0) != 0x80) - { - // If it's not a valid UTF8 string, just copy the line without utf8 conversion - rawCopy(stringUtf8); - return; - } - - code <<= 6; - code |= (ucchar)(ch & 0x3F); - } - push_back(code); - } - } - } + void fromUtf8(const std::string &stringUtf8); static ucstring makeFromUtf8(const std::string &stringUtf8) { @@ -288,83 +171,72 @@ public: return ret; } -private: - - void rawCopy(const std::string &str) - { - // We need to convert the char into 8bits unsigned int before promotion to 16 bits - // otherwise, as char are signed on some compiler (MSCV for ex), the sign bit is extended to 16 bits. - resize(str.size()); - std::string::const_iterator first(str.begin()), last(str.end()); - iterator dest(begin()); - for (;first != last; ++first, ++dest) - { - *dest = uint8(*first); - } - } }; inline ucstring operator+(const ucstringbase &ucstr, ucchar c) { - ucstring ret; - ret= ucstr; - ret+= c; + ucstring ret; + ret = ucstr; + ret += c; return ret; } inline ucstring operator+(const ucstringbase &ucstr, const char *c) { - ucstring ret; - ret= ucstr; - ret+= c; + ucstring ret; + ret = ucstr; + ret += c; return ret; } inline ucstring operator+(const ucstringbase &ucstr, const std::string &c) { - ucstring ret; - ret= ucstr; - ret+= c; + ucstring ret; + ret = ucstr; + ret += c; return ret; } inline ucstring operator+(ucchar c, const ucstringbase &ucstr) { - ucstring ret; - ret= c; + ucstring ret; + ret = c; ret += ucstr; return ret; } inline ucstring operator+(const char *c, const ucstringbase &ucstr) { - ucstring ret; - ret= c; + ucstring ret; + ret = c; ret += ucstr; return ret; } inline ucstring operator+(const std::string &c, const ucstringbase &ucstr) { - ucstring ret; - ret= c; + ucstring ret; + ret = c; ret += ucstr; return ret; } -namespace NLMISC -{ +namespace NLMISC { // Traits for hash_map using CEntityId struct CUCStringHashMapTraits { - enum { bucket_size = 4, min_buckets = 8 }; + enum + { + bucket_size = 4, + min_buckets = 8 + }; CUCStringHashMapTraits() { } - size_t operator() (const ucstring &id ) const + size_t operator()(const ucstring &id) const { return id.size(); } - bool operator() (const ucstring &id1, const ucstring &id2) const + bool operator()(const ucstring &id1, const ucstring &id2) const { return id1 < id2; } @@ -375,18 +247,18 @@ struct CUCStringHashMapTraits * \param a string or a char to transform to lower case */ -ucstring toLower (const ucstring &str); -void toLower (ucchar *str); -ucchar toLower (ucchar c); +ucstring toLower(const ucstring &str); +void toLower(ucchar *str); +ucchar toLower(ucchar c); /** Convert an unicode string in upper case. * Characters with accent are converted in a uppercase character without accent * \param a string or a char to transform to upper case */ -ucstring toUpper (const ucstring &str); -void toUpper (ucchar *str); -ucchar toUpper (ucchar c); +ucstring toUpper(const ucstring &str); +void toUpper(ucchar *str); +ucchar toUpper(ucchar c); }; diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h new file mode 100644 index 000000000..0aac8d2c3 --- /dev/null +++ b/nel/include/nel/misc/utf_string_view.h @@ -0,0 +1,162 @@ +// NeL - MMORPG Framework +// Copyright (C) 2020 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef NLMISC_UTF_STRING_VIEW_H +#define NLMISC_UTF_STRING_VIEW_H + +#include +#include +#include + +namespace NLMISC { + +/// String view for UTF-8 and UTF-32 iteration as 32-bit codepoints. +/// This string view keeps the string as a reference, it does not make a copy. +/// Only use this for iterating a string's codepoints. +/// String must be NUL terminated, but its size may specify a substring. +class CUtfStringView +{ +public: + inline CUtfStringView() : m_Str(NULL), m_Size(0), m_Iterator(utf32Iterator) {} + + inline CUtfStringView(const std::string &utf8Str) : m_Str(utf8Str.c_str()), m_Size(utf8Str.size()), m_Iterator(utf8Iterator) {} + inline CUtfStringView(const char *utf8Str) : m_Str(utf8Str), m_Size(strlen(utf8Str)), m_Iterator(utf8Iterator) {} + inline CUtfStringView(const char *utf8Str, size_t len): m_Str(utf8Str), m_Size(len), m_Iterator(utf8Iterator) + { + nlassert(len <= strlen(utf8Str)); + } +#if defined(NL_OS_WINDOWS) + inline CUtfStringView(const wchar_t *utf16Str) : m_Str(utf16Str), m_Size(wcslen(utf16Str)), m_Iterator(utf16Iterator) {} + inline CUtfStringView(const wchar_t *utf16Str, size_t len): m_Str(utf16Str), m_Size(len), m_Iterator(utf16Iterator) + { + nlassert(len <= wcslen(utf16Str)); + } +#else + inline CUtfStringView(const wchar_t *utf32Str) : m_Str(utf32Str), m_Size(wcslen(utf32Str)), m_Iterator(utf32Iterator) {} + inline CUtfStringView(const wchar_t *utf32Str, size_t len): m_Str(utf32Str), m_Size(len), m_Iterator(utf32Iterator) + { + nlassert(len <= wcslen(utf32Str)); + } +#endif + + inline CUtfStringView(const ucstring &utf16Str) : m_Str(utf16Str.c_str()), m_Size(utf16Str.size() << 1), m_Iterator(utf16Iterator) {} + inline CUtfStringView(const ucchar *utf16Str) : m_Str(utf16Str), m_Size(strlen((const char *)utf16Str) & (ptrdiff_t)(-2)), m_Iterator(utf16Iterator) {} + inline CUtfStringView(const ::u32string &utf32Str) : m_Str(utf32Str.c_str()), m_Size(utf32Str.size() << 2), m_Iterator(utf32Iterator) {} + + std::string toUtf8(bool reEncode = false) const; // Makes a copy + ucstring toUtf16(bool reEncode = false) 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::string toAscii() const; // Returns only values 0-127, 7-bit ASCII. Makes a copy. + + inline bool isUtf8() const { return m_Iterator == utf8Iterator; } + inline bool isUtf16() const { return m_Iterator == utf16Iterator; } + inline bool isUtf32() const { return m_Iterator == utf32Iterator; } + + struct const_iterator + { + public: + inline void operator++() + { + if ((ptrdiff_t)m_Next > ((ptrdiff_t)m_View.m_Str + m_View.m_Size)) + m_Next = (void *)((ptrdiff_t)m_View.m_Str + m_View.m_Size); + m_Addr = m_Next; + m_Char = m_View.m_Iterator(&m_Next); + } + inline void operator+=(ptrdiff_t a) + { + while ((ptrdiff_t)m_Addr < ((ptrdiff_t)m_View.m_Str + m_View.m_Size)) + { + ++(*this); + } + } + inline bool operator!=(const const_iterator &o) const { return m_Addr != o.m_Addr; } + inline bool operator==(const const_iterator &o) const { return m_Addr == o.m_Addr; } + inline const u32char &operator*() const { return m_Char; } + const_iterator() : m_View(*(CUtfStringView *)NULL), m_Addr(NULL), m_Char(0) { } + + const_iterator &operator=(const const_iterator &other) + { + if (this == &other) return *this; + this->~const_iterator(); + return *new(this) const_iterator(other); + } + + const void *ptr() const { return m_Addr; } + private: + friend class CUtfStringView; + inline const_iterator(const CUtfStringView &view, const void *addr) : m_View(view), m_Addr(addr), m_Next(addr), m_Char(view.m_Iterator(&m_Next)) + { + if ((ptrdiff_t)m_Next > ((ptrdiff_t)m_View.m_Str + m_View.m_Size)) + m_Next = (void *)((ptrdiff_t)m_View.m_Str + m_View.m_Size); + } + inline const_iterator(const CUtfStringView &view) : m_View(view), m_Addr((char *)view.m_Str + view.m_Size), m_Next((char *)view.m_Str + view.m_Size + 1), m_Char(0) { } + const CUtfStringView &m_View; + const void *m_Addr; // Current address + const void *m_Next; // Next address + u32char m_Char; + }; + + typedef const_iterator iterator; + + iterator begin() const { return iterator(*this, m_Str); } + inline iterator end() const { return iterator(*this); } + + /// Largest possible number of characters in this string. + /// Number of actual characters may be less or equal. + inline size_t largestSize() const { return m_Size; } + + inline bool empty() const { return !m_Size; } + const void *ptr() const { return m_Str; } + + size_t count() const; // Slow count of UTF-32 characters + + inline CUtfStringView substr(const iterator &begin, const iterator &end) const + { + return CUtfStringView(begin.m_Addr, (ptrdiff_t)end.m_Addr - (ptrdiff_t)begin.m_Addr, m_Iterator); + } + + inline bool endsWith(char c) { nlassert(c < 0x80); return *((char *)m_Str + m_Size - 1) == c; } + + CUtfStringView &operator=(const CUtfStringView &other) + { + if(this == &other) return *this; + this->~CUtfStringView(); + return *new(this) CUtfStringView(other); + } + + static void append(std::string &str, u32char c); + +private: + typedef u32char (*TIterator)(const void **addr); + static u32char utf8Iterator(const void **addr); + static u32char utf16Iterator(const void **addr); + static u32char utf32Iterator(const void **addr); + + inline CUtfStringView(const void *str, size_t len, TIterator it) : m_Str(str), m_Size(len), m_Iterator(it) { } + + const void *const m_Str; // String + const size_t m_Size; // Size in bytes + const TIterator m_Iterator; + +}; /* class CUtfStringView */ + +} /* namespace NLMISC */ + +#endif /* #ifndef NLMISC_STREAMED_PACKAGE_PROVIDER_H */ + +/* end of file */ diff --git a/nel/include/nel/net/unified_network.h b/nel/include/nel/net/unified_network.h index d380427b6..094ff7390 100644 --- a/nel/include/nel/net/unified_network.h +++ b/nel/include/nel/net/unified_network.h @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -662,6 +665,7 @@ private: std::vector _UpUniCallback; TNameMappedCallback _DownCallbacks; std::vector _DownUniCallback; + std::set> _NotifiedUpCallbacks; /// Recording state CCallbackNetBase::TRecordingState _RecordingState; diff --git a/nel/include/nel/sound/music_channel_fader.h b/nel/include/nel/sound/music_channel_fader.h index 577d23949..bacbbe837 100644 --- a/nel/include/nel/sound/music_channel_fader.h +++ b/nel/include/nel/sound/music_channel_fader.h @@ -7,7 +7,7 @@ */ // NeL - MMORPG Framework -// Copyright (C) 2008-2012 Jan BOON (Kaetemi) +// Copyright (C) 2008-2020 Jan BOON (Kaetemi) // // This source file has been modified by the following contributors: // Copyright (C) 2010 Winch Gate Property Limited diff --git a/nel/include/nel/sound/stream_file_source.h b/nel/include/nel/sound/stream_file_source.h index c8cf91cf5..1ade68572 100644 --- a/nel/include/nel/sound/stream_file_source.h +++ b/nel/include/nel/sound/stream_file_source.h @@ -7,7 +7,7 @@ */ // NeL - MMORPG Framework -// Copyright (C) 2012 Jan BOON (Kaetemi) +// Copyright (C) 2012-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/include/nel/web/http_client_curl.h b/nel/include/nel/web/http_client_curl.h index e130cd768..cfb1ac38a 100644 --- a/nel/include/nel/web/http_client_curl.h +++ b/nel/include/nel/web/http_client_curl.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/samples/misc/i18n/main.cpp b/nel/samples/misc/i18n/main.cpp index 1c8ddabb9..5b1c73123 100644 --- a/nel/samples/misc/i18n/main.cpp +++ b/nel/samples/misc/i18n/main.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -44,9 +47,9 @@ int main (int argc, char **argv) // load the language CI18N::load(langName); - InfoLog->displayRawNL(CI18N::get("Hi").toString().c_str()); - InfoLog->displayRawNL(CI18N::get("PresentI18N").toString().c_str(), "Nevrax"); - InfoLog->displayRawNL(CI18N::get("ExitStr").toString().c_str()); + InfoLog->displayRawNL(CI18N::get("Hi").c_str()); + InfoLog->displayRawNL(CI18N::get("PresentI18N").c_str(), "Nevrax"); + InfoLog->displayRawNL(CI18N::get("ExitStr").c_str()); getchar(); return EXIT_SUCCESS; diff --git a/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 3a4f67aee..f8a678957 100644 --- a/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2013-2019 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // Copyright (C) 2014 Matthew LAGOE (Botanic) // // This program is free software: you can redistribute it and/or modify @@ -1173,7 +1173,7 @@ void D3DWndProc(CDriverD3D *driver, HWND hWnd, UINT message, WPARAM wParam, LPAR } } - if (driver->_EventEmitter.getNumEmitters() > 0) + if (driver && driver->_EventEmitter.getNumEmitters() > 0) { CWinEventEmitter *we = NLMISC::safe_cast(driver->_EventEmitter.getEmitter(0)); // Process the message by the emitter @@ -1225,12 +1225,29 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l D3DWndProc (pDriver, hWnd, message, wParam, lParam); } + if (message == WM_SYSCOMMAND) + { + switch (wParam) + { #ifdef NL_DISABLE_MENU - // disable menu (F10, ALT and ALT+SPACE key doesn't freeze or open the menu) - if(message == WM_SYSCOMMAND && wParam == SC_KEYMENU) - return 0; + // disable menu (F10, ALT and ALT+SPACE key doesn't freeze or open the menu) + case SC_KEYMENU: #endif // NL_DISABLE_MENU + // Screensaver Trying To Start? + case SC_SCREENSAVE: + + // Monitor Trying To Enter Powersave? + case SC_MONITORPOWER: + + // Prevent From Happening + return 0; + + default: + break; + } + } + // ace: if we receive close, exit now or it'll assert after if(message == WM_CLOSE) { @@ -1248,6 +1265,12 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l return 0; } +#ifdef WM_UNICHAR + // https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-unichar + if (message == WM_UNICHAR) + return (wParam == UNICODE_NOCHAR); +#endif + return DefWindowProcW(hWnd, message, wParam, lParam); } @@ -3995,12 +4018,12 @@ void CDriverD3D::findNearestFullscreenVideoMode() } } } -bool CDriverD3D::copyTextToClipboard(const ucstring &text) +bool CDriverD3D::copyTextToClipboard(const std::string &text) { return _EventEmitter.copyTextToClipboard(text); } -bool CDriverD3D::pasteTextFromClipboard(ucstring &text) +bool CDriverD3D::pasteTextFromClipboard(std::string &text) { return _EventEmitter.pasteTextFromClipboard(text); } diff --git a/nel/src/3d/driver/direct3d/driver_direct3d.h b/nel/src/3d/driver/direct3d/driver_direct3d.h index c021f052d..9a434cab2 100644 --- a/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2013-2019 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -2748,8 +2748,8 @@ public: bool convertBitmapToIcon(const NLMISC::CBitmap &bitmap, HICON &icon, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col = NLMISC::CRGBA::White, sint hotSpotX = 0, sint hotSpotY = 0, bool cursor = false); - virtual bool copyTextToClipboard(const ucstring &text); - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); + virtual bool pasteTextFromClipboard(std::string &text); public: #ifdef NL_DEBUG diff --git a/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp b/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp index 2285688d4..1436e5aa4 100644 --- a/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp +++ b/nel/src/3d/driver/direct3d/driver_direct3d_material.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp b/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp index 15dcb7768..71af20f00 100644 --- a/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp +++ b/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2012-2014 Jan BOON (Kaetemi) +// Copyright (C) 2012-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/3d/driver/opengl/driver_opengl.h b/nel/src/3d/driver/opengl/driver_opengl.h index e1ee968a5..5be157403 100644 --- a/nel/src/3d/driver/opengl/driver_opengl.h +++ b/nel/src/3d/driver/opengl/driver_opengl.h @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) // Copyright (C) 2010 Thibaut GIRKA (ThibG) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -354,8 +354,8 @@ public: return _win; } - virtual bool copyTextToClipboard(const ucstring &text); - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); + virtual bool pasteTextFromClipboard(std::string &text); virtual uint32 getAvailableVertexAGPMemory (); virtual uint32 getAvailableVertexVRAMMemory (); diff --git a/nel/src/3d/driver/opengl/driver_opengl_extension.cpp b/nel/src/3d/driver/opengl/driver_opengl_extension.cpp index 4bdd7ca97..6d4d6427b 100644 --- a/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp b/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp index 689c37ba5..8c86f4c7e 100644 --- a/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp +++ b/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -1373,10 +1373,11 @@ CVertexBufferHardARB::~CVertexBufferHardARB() } } #ifdef NL_DEBUG - if (_VertexPtr) - { - _VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList); - } + if (_VertexPtr) + { + nlassert(_VertexArrayRange); + _VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList); + } #endif #ifdef USE_OPENGLES diff --git a/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 6537c289f..163f64843 100644 --- a/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -183,6 +183,12 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l return 0; } +#ifdef WM_UNICHAR + // https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-unichar + if (message == WM_UNICHAR) + return (wParam == UNICODE_NOCHAR); +#endif + return trapMessage ? 0 : DefWindowProcW(hWnd, message, wParam, lParam); } @@ -1074,7 +1080,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re // Set context as thread context CGLSetCurrentContext((CGLContextObj)[_ctx CGLContextObj]); - + _EventEmitter.init(this, _glView, _DestroyWindow); #elif defined(NL_OS_UNIX) @@ -3014,12 +3020,12 @@ void CDriverGL::setupApplicationMenu() } #endif -bool CDriverGL::copyTextToClipboard(const ucstring &text) +bool CDriverGL::copyTextToClipboard(const std::string &text) { return _EventEmitter.copyTextToClipboard(text); } -bool CDriverGL::pasteTextFromClipboard(ucstring &text) +bool CDriverGL::pasteTextFromClipboard(std::string &text) { return _EventEmitter.pasteTextFromClipboard(text); } diff --git a/nel/src/3d/driver/opengl/unix_event_emitter.cpp b/nel/src/3d/driver/opengl/unix_event_emitter.cpp index d4153dde5..e8e8ae99f 100644 --- a/nel/src/3d/driver/opengl/unix_event_emitter.cpp +++ b/nel/src/3d/driver/opengl/unix_event_emitter.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -29,6 +29,7 @@ #include #include #include "nel/misc/debug.h" +#include "nel/misc/utf_string_view.h" #ifdef DEBUG_NEW #define new DEBUG_NEW @@ -537,8 +538,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) if (c > 0) { #ifdef X_HAVE_UTF8_STRING - ucstring ucstr; - ucstr.fromUtf8(Text); + ::u32string ucstr = NLMISC::CUtfStringView(Text).toUtf32(); CEventChar *charEvent = new CEventChar (ucstr[0], getKeyButton(event.xbutton.state), this); @@ -547,9 +547,10 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) server->postEvent (charEvent); #else + // FIXME: Convert locale to UTF-32 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 charEvent->setRaw(keyCode != 0); @@ -610,14 +611,13 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) else if (req.target == XA_STRING) { respond.xselection.property = req.property; - std::string str = _CopiedString.toString(); + std::string str = _CopiedString; // NLMISC::CUtfStringView(_CopiedString).toAscii(); // FIXME: Convert UTF-8 to local XChangeProperty(req.display, req.requestor, req.property, XA_STRING, 8, PropModeReplace, (const unsigned char*)str.c_str(), str.length()); } else if (req.target == XA_UTF8_STRING) { respond.xselection.property = req.property; - std::string str = _CopiedString.toUtf8(); - XChangeProperty(req.display, req.requestor, respond.xselection.property, XA_UTF8_STRING, 8, PropModeReplace, (const unsigned char*)str.c_str(), str.length()); + XChangeProperty(req.display, req.requestor, respond.xselection.property, XA_UTF8_STRING, 8, PropModeReplace, (const unsigned char*)_CopiedString.c_str(), _CopiedString.length()); } else { @@ -699,22 +699,22 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) if (XGetWindowProperty(_dpy, _win, XA_NEL_SEL, 0, XMaxRequestSize(_dpy), False, AnyPropertyType, &actualType, &actualFormat, &nitems, &bytesLeft, (unsigned char**)&data) != Success) return false; - ucstring text; - std::string tmpData = (const char*)data; + std::string text = (const char*)data; XFree(data); // convert buffer to ucstring if (target == XA_UTF8_STRING) { - text = ucstring::makeFromUtf8(tmpData); + // OK } else if (target == XA_STRING) { - text = tmpData; + // FIXME: Convert local to UTF-8 + // text = NLMISC::CUtfStringView(text).toAscii(); } else { - nlwarning("Unknow format %u", (uint)target); + nlwarning("Unknown format %u", (uint)target); } // sent string event to event server @@ -768,7 +768,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) return true; } -bool CUnixEventEmitter::copyTextToClipboard(const ucstring &text) +bool CUnixEventEmitter::copyTextToClipboard(const std::string &text) { _CopiedString = text; @@ -787,7 +787,7 @@ bool CUnixEventEmitter::copyTextToClipboard(const ucstring &text) return true; } -bool CUnixEventEmitter::pasteTextFromClipboard(ucstring &text) +bool CUnixEventEmitter::pasteTextFromClipboard(std::string &text) { // check if we own the selection if (_SelectionOwned) diff --git a/nel/src/3d/driver/opengl/unix_event_emitter.h b/nel/src/3d/driver/opengl/unix_event_emitter.h index bbee65e5e..297fdcb5a 100644 --- a/nel/src/3d/driver/opengl/unix_event_emitter.h +++ b/nel/src/3d/driver/opengl/unix_event_emitter.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -66,12 +67,12 @@ public: /** * Copy a string to system clipboard. */ - virtual bool copyTextToClipboard(const ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); /* * Paste a string from system clipboard. */ - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool pasteTextFromClipboard(std::string &text); void createIM(); void closeIM(); @@ -105,7 +106,7 @@ private: XIC _ic; NL3D::IDriver* _driver; CUnixEventServer _InternalServer; - ucstring _CopiedString; + std::string _CopiedString; bool _SelectionOwned; }; diff --git a/nel/src/3d/driver_user.cpp b/nel/src/3d/driver_user.cpp index b44a64737..a7bd7a332 100644 --- a/nel/src/3d/driver_user.cpp +++ b/nel/src/3d/driver_user.cpp @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // Copyright (C) 2015 Laszlo KIS-ADAM (dfighter) // // This program is free software: you can redistribute it and/or modify @@ -1971,12 +1971,12 @@ bool CDriverUser::setRenderTarget(class UTexture & uTex, uint32 x, uint32 y, uin return result; } -bool CDriverUser::copyTextToClipboard(const ucstring &text) +bool CDriverUser::copyTextToClipboard(const std::string &text) { return _Driver->copyTextToClipboard(text); } -bool CDriverUser::pasteTextFromClipboard(ucstring &text) +bool CDriverUser::pasteTextFromClipboard(std::string &text) { return _Driver->pasteTextFromClipboard(text); } diff --git a/nel/src/3d/font_generator.cpp b/nel/src/3d/font_generator.cpp index 44d8f5ab0..06ccd3a8b 100644 --- a/nel/src/3d/font_generator.cpp +++ b/nel/src/3d/font_generator.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -256,7 +256,7 @@ CFontGenerator::~CFontGenerator () } } -void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &height) +void CFontGenerator::getSizes (u32char c, uint32 size, uint32 &width, uint32 &height) { FT_Error error; @@ -272,7 +272,7 @@ void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &hei if (glyph_index == 0) { // no glyph available, replace with a dot - glyph_index = FT_Get_Char_Index (_Face, ucchar('.')); + glyph_index = FT_Get_Char_Index (_Face, u32char('.')); } // load glyph image into the slot (erase previous one) @@ -294,7 +294,7 @@ void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &hei height = _Face->glyph->metrics.height >> 6; } -uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex) +uint8 *CFontGenerator::getBitmap (u32char c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex) { FT_Error error; @@ -307,11 +307,13 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl // retrieve glyph index from character code FT_UInt glyph_index = FT_Get_Char_Index (_Face, c); + /* if (glyph_index == 0) { // no glyph available, replace with a dot - glyph_index = FT_Get_Char_Index (_Face, ucchar('.')); + glyph_index = FT_Get_Char_Index (_Face, u32char('.')); } + */ // load glyph image into the slot (erase previous one) error = FT_Load_Glyph (_Face, glyph_index, FT_LOAD_DEFAULT); @@ -372,7 +374,7 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl -void CFontGenerator::getKerning (ucchar left, ucchar right, sint32 &kernx) +void CFontGenerator::getKerning (u32char left, u32char right, sint32 &kernx) { if (!FT_HAS_KERNING(_Face)) { @@ -392,14 +394,14 @@ void CFontGenerator::getKerning (ucchar left, ucchar right, sint32 &kernx) -uint32 CFontGenerator::getCharIndex (ucchar c) +uint32 CFontGenerator::getCharIndex (u32char c) { uint32 ret = FT_Get_Char_Index(_Face, c); if (ret == 0) { // no glyph available, replace with a dot - ret = FT_Get_Char_Index (_Face, ucchar('.')); + ret = FT_Get_Char_Index (_Face, u32char('.')); } return ret; @@ -473,14 +475,14 @@ CFontGenerator::~CFontGenerator () DeleteDC (hdcDib); } -void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &height) +void CFontGenerator::getSizes (u32char c, uint32 size, uint32 &width, uint32 &height) { } HFONT hFont = NULL; uint32 CurrentFontSize = 0; -uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex) +uint8 *CFontGenerator::getBitmap (u32char c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex) { if (size == 0) { @@ -527,7 +529,7 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl SelectObject (hdcDib, hFont); SelectObject (hdcDib, Dib); - const ucchar cc = /*(char)*/ c; + const u32char cc = /*(char)*/ c; // prevent outputing white glyph if char is not available in font DWORD glyphIndex; @@ -637,13 +639,13 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl -void CFontGenerator::getKerning (ucchar left, ucchar right, sint32 &kernx) +void CFontGenerator::getKerning (u32char left, u32char right, sint32 &kernx) { } -uint32 CFontGenerator::getCharIndex (ucchar c) +uint32 CFontGenerator::getCharIndex (u32char c) { return 0; } diff --git a/nel/src/3d/font_manager.cpp b/nel/src/3d/font_manager.cpp index d00ebb8f5..da8573ef7 100644 --- a/nel/src/3d/font_manager.cpp +++ b/nel/src/3d/font_manager.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -63,27 +66,8 @@ CMaterial* CFontManager::getFontMaterial() return _MatFont; } - -// *************************************************************************** -void CFontManager::computeString (const std::string &s, - CFontGenerator *fontGen, - const NLMISC::CRGBA &color, - uint32 fontSize, - bool embolden, - bool oblique, - IDriver *driver, - CComputedString &output, - bool keep800x600Ratio) -{ - // static to avoid reallocation - static ucstring ucs; - ucs= s; - computeString(ucs, fontGen, color, fontSize, embolden, oblique, driver, output, keep800x600Ratio); -} - - // *************************************************************************** -void CFontManager::computeString (const ucstring &s, +void CFontManager::computeString (NLMISC::CUtfStringView sv, CFontGenerator *fontGen, const NLMISC::CRGBA &color, uint32 fontSize, @@ -109,7 +93,7 @@ void CFontManager::computeString (const ucstring &s, } // Setting vertices format - output.Vertices.setNumVertices (4 * (uint32)s.size()); + output.Vertices.setNumVertices (4 * (uint32)sv.largestSize()); // 1 character <-> 1 quad sint32 penx = 0, dx; @@ -144,10 +128,12 @@ void CFontManager::computeString (const ucstring &s, output.StringHeight = 0; // save string info for later rebuild as needed - output.Text = s; + if (sv.ptr() != output.Text.c_str()) // don't resave if rebuilding + output.Text = sv.toUtf8(); output.CacheVersion = getCacheVersion(); uint j = 0; + size_t idx = 0; { CVertexBufferReadWrite vba; output.Vertices.lock (vba); @@ -156,10 +142,12 @@ void CFontManager::computeString (const ucstring &s, hlfPixScrH = 0.f; // For all chars - for (uint i = 0; i < s.size(); i++) + for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++idx) { // Creating font - k.Char = s[i]; + k.Char = *it; + if (k.Char < 0x20) + k.Char += 0x2400; k.FontGenerator = fontGen; k.Size = fontSize; k.Embolden = embolden; @@ -228,6 +216,8 @@ void CFontManager::computeString (const ucstring &s, } } output.Vertices.setNumVertices (j); + output.Length = idx; + nlassert(output.Length == NLMISC::CUtfStringView(output.Text).count()); // compile string info output.StringWidth = (float)penx; @@ -245,7 +235,23 @@ void CFontManager::computeString (const ucstring &s, // *************************************************************************** -void CFontManager::computeStringInfo ( const ucstring &s, +void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv, + CFontGenerator *fontGen, + const NLMISC::CRGBA &color, + uint32 fontSize, + bool embolden, + bool oblique, + IDriver *driver, + CComputedString &output, + bool keep800x600Ratio ) +{ + computeStringInfo(sv, sv.largestSize(), fontGen, color, fontSize, embolden, oblique, driver, output, keep800x600Ratio); +} + + +// *************************************************************************** +void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv, + size_t len, CFontGenerator *fontGen, const NLMISC::CRGBA &color, uint32 fontSize, @@ -258,10 +264,11 @@ void CFontManager::computeStringInfo ( const ucstring &s, output.Color = color; // save string info for later rebuild as needed - output.Text = s; + if (sv.ptr() != output.Text.c_str()) // don't resave if rebuilding + output.Text = sv.toUtf8(); output.CacheVersion = 0; - if (s.empty()) + if (sv.empty()) { output.StringWidth = 0.f; output.StringHeight = 0; @@ -290,10 +297,13 @@ void CFontManager::computeStringInfo ( const ucstring &s, CTextureFont::SLetterKey k; CTextureFont::SLetterInfo *pLI; - for (uint i = 0; i < s.size(); i++) + size_t idx = 0; + for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end && idx < len; ++it, ++idx) { // Creating font - k.Char = s[i]; + k.Char = *it; + if (k.Char < 0x20) + k.Char += 0x2400; k.FontGenerator = fontGen; k.Size = fontSize; k.Embolden = embolden; @@ -313,6 +323,8 @@ void CFontManager::computeStringInfo ( const ucstring &s, penx += pLI->AdvX; } } + output.Length = idx; + nlassert(output.Length == std::min(len, NLMISC::CUtfStringView(output.Text).count())); // compile string info output.StringWidth = (float)penx; diff --git a/nel/src/3d/fxaa.cpp b/nel/src/3d/fxaa.cpp index 6478abf8e..2dfd58d37 100644 --- a/nel/src/3d/fxaa.cpp +++ b/nel/src/3d/fxaa.cpp @@ -7,7 +7,7 @@ */ // NeL - MMORPG Framework -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/3d/lod_character_manager.cpp b/nel/src/3d/lod_character_manager.cpp index f5d6a23c5..8e062bf07 100644 --- a/nel/src/3d/lod_character_manager.cpp +++ b/nel/src/3d/lod_character_manager.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/src/3d/packed_zone.cpp b/nel/src/3d/packed_zone.cpp index 72866ea78..f1cb7426b 100644 --- a/nel/src/3d/packed_zone.cpp +++ b/nel/src/3d/packed_zone.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/src/3d/render_trav.cpp b/nel/src/3d/render_trav.cpp index 0a071303f..1b7e8e84e 100644 --- a/nel/src/3d/render_trav.cpp +++ b/nel/src/3d/render_trav.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2012-2014 Jan BOON (Kaetemi) +// Copyright (C) 2012-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -921,7 +921,7 @@ void CRenderTrav::changeVPLightSetupMaterial(const CMaterial &mat, bool exclude Driver->setUniform4f(IDriver::VertexProgram, program->idxLighted().Diffuse[i], color); } - + nlassert(_VPNumLights < MaxVPLight); if (i != _VPNumLights) { color= _VPLightDiffuse[i] * matDiff; diff --git a/nel/src/3d/scene.cpp b/nel/src/3d/scene.cpp index 7f1263ea1..15173d7d9 100644 --- a/nel/src/3d/scene.cpp +++ b/nel/src/3d/scene.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -775,9 +775,9 @@ CTransformShape *CScene::createInstance(const string &shapeName) // Look if this instance get lightmap information #if defined(__GNUC__) && __GNUC__ < 3 - CMeshBase *pMB = (CMeshBase*)((IShape*)(pTShp->Shape)); + CMeshBase *pMB = pTShp ? (CMeshBase*)((IShape*)(pTShp->Shape)) : NULL; #else // not GNUC - CMeshBase *pMB = dynamic_cast((IShape*)(pTShp->Shape)); + CMeshBase *pMB = pTShp ? dynamic_cast((IShape*)(pTShp->Shape)) : NULL; #endif // not GNUC CMeshBaseInstance *pMBI = dynamic_cast( pTShp ); if( ( pMB != NULL ) && ( pMBI != NULL ) ) diff --git a/nel/src/3d/shadow_map_manager.cpp b/nel/src/3d/shadow_map_manager.cpp index a8400ce0b..174ecd580 100644 --- a/nel/src/3d/shadow_map_manager.cpp +++ b/nel/src/3d/shadow_map_manager.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -256,14 +256,14 @@ void CShadowMapManager::renderGenerate(CScene *scene) garbageShadowTextures(scene); IDriver *driverForShadowGeneration= scene->getRenderTrav().getAuxDriver(); + nlassert(driverForShadowGeneration); CSmartPtr previousRenderTarget = driverForShadowGeneration->getRenderTarget(); // Init // ******** uint32 wndW= _BlurTextureW, wndH= _BlurTextureH; // get some text/screen size. - if(driverForShadowGeneration) - driverForShadowGeneration->getWindowSize(wndW, wndH); + driverForShadowGeneration->getWindowSize(wndW, wndH); uint baseTextureSize= scene->getShadowMapTextureSize(); // Minimize the Dest Texture size, so the blurTexture don't get too heavy in VRAM. uint32 textDestW= min(wndW, (uint32)NL3D_SMM_MAX_TEXTDEST_SIZE); diff --git a/nel/src/3d/shape_bank.cpp b/nel/src/3d/shape_bank.cpp index 61a65c423..71bdb79e2 100644 --- a/nel/src/3d/shape_bank.cpp +++ b/nel/src/3d/shape_bank.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -683,8 +686,7 @@ void CShapeBank::reset() while( scmIt != ShapeCacheNameToShapeCache.end() ) { CShapeCache *pShpCache = getShapeCachePtrFromShapeCacheName( scmIt->first ); - if( pShpCache == NULL ) - nlstop; // Should never happen + nlassert(pShpCache); pShpCache->MaxSize = 0; checkShapeCache( pShpCache ); diff --git a/nel/src/3d/surface_light_grid.cpp b/nel/src/3d/surface_light_grid.cpp index deec090a4..d85422869 100644 --- a/nel/src/3d/surface_light_grid.cpp +++ b/nel/src/3d/surface_light_grid.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -121,17 +124,20 @@ void CSurfaceLightGrid::getStaticLightSetup(NLMISC::CRGBA sunAmbient, const CVe CLightInfluenceInterpolator::CCorner &corner= interp.Corners[y*2 + x]; // For all lights uint lid; - for(lid= 0; lid leave color and alpha To 0. - if(cellCorner.LocalAmbientId!=0xFF) + if(igPointLights && cellCorner.LocalAmbientId!=0xFF) { CPointLight &pl= igPointLights[cellCorner.LocalAmbientId]; // take current ambient from pointLight diff --git a/nel/src/3d/tessellation.cpp b/nel/src/3d/tessellation.cpp index 451e1013b..88c0fa26e 100644 --- a/nel/src/3d/tessellation.cpp +++ b/nel/src/3d/tessellation.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -2678,6 +2681,8 @@ void CTessFace::updateBindAndSplit() } else { + nlassert(f0); + nlassert(f1); // multipatch face case are detected when face->Patch==NULL !!! if(f0->FLeft && f0->FLeft->Patch==NULL) { @@ -2710,6 +2715,8 @@ void CTessFace::updateBindAndSplit() } else { + nlassert(f0); + nlassert(f1); if(f0->FLeft) { while(f0->FLeft->isLeaf()) @@ -2781,6 +2788,8 @@ void CTessFace::updateBindAndSplit() { CTessFace *f; sint i; + nlassert(f0); + nlassert(f1); // Same reasoning for rectangular patchs, as above. for(i=0;i<2;i++) diff --git a/nel/src/3d/text_context.cpp b/nel/src/3d/text_context.cpp index 1ccb920e4..4549622da 100644 --- a/nel/src/3d/text_context.cpp +++ b/nel/src/3d/text_context.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -77,13 +77,11 @@ uint32 CTextContext::textPush (const char *format, ...) char *str; NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize); - ucstring uc; - uc.fromUtf8((const char *)str); - return textPush(uc); + return textPush(NLMISC::CUtfStringView(str)); } // ------------------------------------------------------------------------------------------------ -uint32 CTextContext::textPush (const ucstring &str) +uint32 CTextContext::textPush (NLMISC::CUtfStringView sv) { nlassert(_FontGen); @@ -103,7 +101,7 @@ uint32 CTextContext::textPush (const ucstring &str) nlassert (index < _CacheStrings.size()); CComputedString &strToFill = _CacheStrings[index]; - _FontManager->computeString (str, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio); + _FontManager->computeString (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio); // just compute letters, glyphs are rendered on demand before first draw //_FontManager->computeStringInfo(str, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio); diff --git a/nel/src/3d/text_context_user.cpp b/nel/src/3d/text_context_user.cpp index 0430eae1a..f32fd175d 100644 --- a/nel/src/3d/text_context_user.cpp +++ b/nel/src/3d/text_context_user.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -231,11 +231,11 @@ uint32 CTextContextUser::textPush(const char *format, ...) return _TextContext.textPush(ucstring(str)) ; } -uint32 CTextContextUser::textPush(const ucstring &str) +uint32 CTextContextUser::textPush(NLMISC::CUtfStringView sv) { H_AUTO2; - return _TextContext.textPush(str) ; + return _TextContext.textPush(sv) ; } void CTextContextUser::setStringColor(uint32 i, CRGBA newCol) { @@ -275,16 +275,23 @@ UTextContext::CStringInfo CTextContextUser::getStringInfo(uint32 i) CComputedString *cstr= _TextContext.getComputedString(i); if(!cstr) - return CStringInfo(0, 0, 0); + return CStringInfo(0, 0, 0, 0); else - return CStringInfo(cstr->StringWidth, cstr->StringHeight, cstr->StringLine); + return CStringInfo(cstr->StringWidth, cstr->StringHeight, cstr->StringLine, cstr->Length); } -UTextContext::CStringInfo CTextContextUser::getStringInfo(const ucstring &str) +UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringView sv) { H_AUTO2; - _TextContext.computeStringInfo(str, _CacheString); - return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine); + _TextContext.computeStringInfo(sv, _CacheString); + return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine, _CacheString.Length); +} +UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringView sv, size_t len) +{ + H_AUTO2; + + _TextContext.computeStringInfo(sv, _CacheString, len); + return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine, _CacheString.Length); } void CTextContextUser::clear() { @@ -319,11 +326,11 @@ void CTextContextUser::printClipAtOld (float x, float y, uint32 i, float xmin, f printClipAt(rdrBuffer, x, y ,i, xmin, ymin, xmax, ymax); flushRenderBuffer(&rdrBuffer); } -void CTextContextUser::printAt(float x, float y, const ucstring &ucstr) +void CTextContextUser::printAt(float x, float y, NLMISC::CUtfStringView sv) { H_AUTO2; - _TextContext.printAt(x, y, ucstr); + _TextContext.printAt(x, y, sv); _DriverUser->restoreMatrixContext(); } void CTextContextUser::printfAt(float x, float y, const char * format, ...) @@ -337,12 +344,12 @@ void CTextContextUser::printfAt(float x, float y, const char * format, ...) _DriverUser->restoreMatrixContext(); } -void CTextContextUser::render3D(const CMatrix &mat, const ucstring &ucstr) +void CTextContextUser::render3D(const CMatrix &mat, NLMISC::CUtfStringView sv) { NL3D_HAUTO_RENDER_3D_TEXTCONTEXT; CComputedString computedStr; - _TextContext.computeString(ucstr,computedStr); + _TextContext.computeString(sv,computedStr); computedStr.render3D(*_Driver,mat); @@ -355,7 +362,7 @@ void CTextContextUser::render3D(const CMatrix &mat, const char *format, ...) char *str; NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize); - render3D(mat, ucstring(str)); + render3D(mat, str); _DriverUser->restoreMatrixContext(); } diff --git a/nel/src/3d/texture_bump.cpp b/nel/src/3d/texture_bump.cpp index 7705a58fa..fc1fe4139 100644 --- a/nel/src/3d/texture_bump.cpp +++ b/nel/src/3d/texture_bump.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/src/georges/form.cpp b/nel/src/georges/form.cpp index c3fea6e0a..40f374b8d 100644 --- a/nel/src/georges/form.cpp +++ b/nel/src/georges/form.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/georges/type.cpp b/nel/src/georges/type.cpp index 1055313dd..9c65acae7 100644 --- a/nel/src/georges/type.cpp +++ b/nel/src/georges/type.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/gui/CMakeLists.txt b/nel/src/gui/CMakeLists.txt index bb5a0b7f2..4dd53e857 100644 --- a/nel/src/gui/CMakeLists.txt +++ b/nel/src/gui/CMakeLists.txt @@ -1,8 +1,7 @@ FILE(GLOB SRC *.cpp *.h) FILE(GLOB HEADERS ../../include/nel/gui/*.h) -SOURCE_GROUP("include" FILES ${HEADERS}) -SOURCE_GROUP("src" FILES ${SRC}) +SOURCE_GROUP("" FILES ${HEADERS} ${SRC}) NL_TARGET_LIB(nelgui ${SRC} ${HEADERS}) diff --git a/nel/src/gui/action_handler.cpp b/nel/src/gui/action_handler.cpp index 2b8bf890b..a10513ebb 100644 --- a/nel/src/gui/action_handler.cpp +++ b/nel/src/gui/action_handler.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -751,9 +752,7 @@ namespace NLGUI { virtual void execute (CCtrlBase *pCaller, const std::string ¶ms) { - ucstring s; - s.fromUtf8(params); - if (!CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(s)) + if (!CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(params)) { nlwarning("Copy to clipboard failed: '%s'", params.c_str()); } diff --git a/nel/src/gui/css_parser.cpp b/nel/src/gui/css_parser.cpp index e59cf832b..d43189fca 100644 --- a/nel/src/gui/css_parser.cpp +++ b/nel/src/gui/css_parser.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -65,7 +68,7 @@ namespace NLGUI _Rules.clear(); _Style.clear(); - _Style.fromUtf8(cssString); + _Style = cssString; preprocess(); _Position = 0; @@ -73,7 +76,7 @@ namespace NLGUI { skipWhitespace(); - if (_Style[_Position] == (ucchar)'@') + if (_Style[_Position] == '@') readAtRule(); else readRule(); @@ -89,13 +92,13 @@ namespace NLGUI // style: "color: red; font-size: 10px;" // // @internal - void CCssParser::parseRule(const ucstring &selectorString, const ucstring &styleString) + void CCssParser::parseRule(const std::string &selectorString, const std::string &styleString) { - std::vector selectors; - NLMISC::explode(selectorString, ucstring(","), selectors); + std::vector selectors; + NLMISC::explode(selectorString, std::string(","), selectors); TStyleVec props; - props = parseDecls(styleString.toUtf8()); + props = parseDecls(styleString); // duplicate props to each selector in selector list, // example 'div > p, h1' creates 'div>p' and 'h1' @@ -129,7 +132,7 @@ namespace NLGUI skipIdentifier(); // skip at-rule statement - while(!is_eof() && _Style[_Position] != (ucchar)';') + while(!is_eof() && _Style[_Position] != ';') { if (maybe_escape()) { @@ -174,9 +177,9 @@ namespace NLGUI _Position++; else if (is_quote(_Style[_Position])) skipString(); - else if (_Style[_Position] == (ucchar)'[') + else if (_Style[_Position] == '[') skipBlock(); - else if (_Style[_Position] == (ucchar)'{') + else if (_Style[_Position] == '{') break; else _Position++; @@ -184,7 +187,7 @@ namespace NLGUI if (!is_eof()) { - ucstring selector; + std::string selector; selector.append(_Style, start, _Position - start); skipWhitespace(); @@ -194,7 +197,7 @@ namespace NLGUI skipBlock(); if (_Position <= _Style.size()) { - ucstring rules; + std::string rules; rules.append(_Style, start + 1, _Position - start - 2); parseRule(selector, rules); @@ -215,7 +218,7 @@ namespace NLGUI for(uint i=0; i<6 && is_hex(_Style[_Position]); i++) _Position++; - if (_Style[_Position] == (ucchar)' ') + if (_Style[_Position] == ' ') _Position++; } else if (_Style[_Position] != 0x0A) @@ -246,23 +249,23 @@ namespace NLGUI // cannot start with digit valid = false; } - else if ((_Position - start) == 0 && _Style[_Position-1] == (ucchar)'-') + else if ((_Position - start) == 0 && _Style[_Position-1] == '-') { // cannot start with -# valid = false; } } - else if (_Style[_Position] == (ucchar)'_') + else if (_Style[_Position] == '_') { // valid } - else if (_Style[_Position] >= 0x0080) + else if (_Style[_Position] >= 0x80) { // 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 -- valid = false; @@ -285,7 +288,7 @@ namespace NLGUI // @internal void CCssParser::skipBlock() { - ucchar startChar = _Style[_Position]; + char startChar = _Style[_Position]; // block start _Position++; @@ -311,7 +314,7 @@ namespace NLGUI // @internal void CCssParser::skipString() { - ucchar endChar = _Style[_Position]; + char endChar = _Style[_Position]; // quote start _Position++; @@ -338,7 +341,7 @@ namespace NLGUI // *************************************************************************** // parse selector list // @internal - std::vector CCssParser::parse_selector(const ucstring &sel, std::string &pseudoElement) const + std::vector CCssParser::parse_selector(const std::string &sel, std::string &pseudoElement) const { std::vector result; CCssSelector current; @@ -346,10 +349,10 @@ namespace NLGUI pseudoElement.clear(); bool failed = false; - ucstring::size_type start = 0, pos = 0; + std::string::size_type start = 0, pos = 0; while(pos < sel.size()) { - ucstring uc; + std::string uc; uc = sel[pos]; if (is_nmchar(sel[pos]) && current.empty()) { @@ -358,7 +361,7 @@ namespace NLGUI while(pos < sel.size() && is_nmchar(sel[pos])) pos++; - current.Element = toLower(sel.substr(start, pos - start).toUtf8()); + current.Element = toLower(sel.substr(start, pos - start)); start = pos; continue; } @@ -371,7 +374,7 @@ namespace NLGUI while(pos < sel.size() && is_nmchar(sel[pos])) pos++; - current.Id = toLower(sel.substr(start, pos - start).toUtf8()); + current.Id = toLower(sel.substr(start, pos - start)); start = pos; } else if (sel[pos] == '.') @@ -383,7 +386,7 @@ namespace NLGUI while(pos < sel.size() && (is_nmchar(sel[pos]) || sel[pos] == '.')) pos++; - current.setClass(toLower(sel.substr(start, pos - start).toUtf8())); + current.setClass(toLower(sel.substr(start, pos - start))); start = pos; } else if (sel[pos] == '[') @@ -399,9 +402,9 @@ namespace NLGUI start = pos; } - ucstring key; - ucstring value; - ucchar op = ' '; + std::string key; + std::string value; + char op = ' '; // key while(pos < sel.size() && is_nmchar(sel[pos])) @@ -420,7 +423,7 @@ namespace NLGUI if (sel[pos] == ']') { - current.addAttribute(key.toUtf8()); + current.addAttribute(key); } else { @@ -496,14 +499,14 @@ namespace NLGUI // [value="attr" i] 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') { value = value.substr(0, value.size()-2); 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 } // no value @@ -549,7 +552,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()) { failed = true; @@ -647,7 +650,7 @@ namespace NLGUI size_t start; size_t charsLeft; bool quote = false; - ucchar quoteChar; + char quoteChar; while(!is_eof()) { charsLeft = _Style.size() - _Position - 1; @@ -660,14 +663,15 @@ namespace NLGUI if (charsLeft >= 1 && _Style[_Position] == 0x0D && _Style[_Position+1] == 0x0A) len++; - ucstring tmp; - tmp += 0x000A; + std::string tmp; + tmp += 0x0A; _Style.replace(_Position, 1, tmp); } else if (_Style[_Position] == 0x00) { // Unicode replacement character - _Style[_Position] = 0xFFFD; + // _Style[_Position] = 0xFFFD; + _Style.replace(_Position, 1, "\xEF\xBF\xBD"); } else { @@ -686,12 +690,12 @@ namespace NLGUI } 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) pos = _Style.size(); _Style.erase(_Position, pos - _Position + 2); - ucstring uc; + std::string uc; uc = _Style[_Position]; // _Position is already at correct place diff --git a/nel/src/gui/ctrl_base.cpp b/nel/src/gui/ctrl_base.cpp index 2d67ccc30..2e95c50dd 100644 --- a/nel/src/gui/ctrl_base.cpp +++ b/nel/src/gui/ctrl_base.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -122,30 +123,26 @@ namespace NLGUI CXMLAutoPtr prop; // get static toolTip - prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip" ); - if (prop) + prop = (char *)xmlGetProp(cur, (xmlChar *)"tooltip_i18n"); + if ((bool)prop && strlen((const char *)prop) > 0) { - const char *propPtr = prop; - if (strlen(propPtr) > 2 && propPtr[0] == 'u' && propPtr[1] == ':') - _ContextHelp = ucstring::makeFromUtf8(std::string(propPtr).substr(2)); + // Force I18N tooltip + if (!editorMode) + _ContextHelp = CI18N::get((const char *)prop); else - _ContextHelp = ucstring(propPtr); - - - if( !editorMode && ( strlen(propPtr) > 2 ) ) - { - if ((propPtr[0] == 'u') && (propPtr[1] == 'i')) - _ContextHelp = CI18N::get ((const char *) prop); - } + _ContextHelp = (const char *)prop; } - // Force I18N tooltip - prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_i18n" ); - if ((bool)prop && strlen((const char*)prop)>0) + else { - if( !editorMode ) - _ContextHelp = CI18N::get ((const char *) prop); - else - _ContextHelp = (const char*)prop; + // get static toolTip + prop = (char *)xmlGetProp(cur, (xmlChar *)"tooltip"); + if (prop) + { + if (!editorMode && NLMISC::startsWith((const char *)prop, "ui")) + _ContextHelp = CI18N::get((const char *)prop); + else + _ContextHelp = (const char *)prop; + } } // get dynamic toolTip ActionHandler @@ -173,7 +170,7 @@ namespace NLGUI _ToolTipSpecialParent= CStringShared(); if(prop) { - _ToolTipSpecialParent= std::string((const char*)prop); + _ToolTipSpecialParent= (const char*)prop; } // Tooltip posref @@ -201,12 +198,12 @@ namespace NLGUI { if( name == "tooltip" ) { - return _ContextHelp.toString(); + return _ContextHelp; } else if( name == "tooltip_i18n" ) { - return _ContextHelp.toString(); + return _ContextHelp; } else if( name == "on_tooltip" ) @@ -262,13 +259,19 @@ namespace NLGUI { if( name == "tooltip" ) { - _ContextHelp = ucstring::makeFromUtf8(value); + if (!editorMode && NLMISC::startsWith(value, "ui")) + _ContextHelp = CI18N::get(value); + else + _ContextHelp = value; return; } else if( name == "tooltip_i18n" ) { - _ContextHelp = value; + if (!editorMode) + _ContextHelp = CI18N::get(value); + else + _ContextHelp = value; return; } else @@ -380,8 +383,8 @@ namespace NLGUI if( node == NULL ) return NULL; - xmlNewProp( node, BAD_CAST "tooltip", BAD_CAST _ContextHelp.toString().c_str() ); - xmlNewProp( node, BAD_CAST "tooltip_i18n", 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.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 "tooltip_parent", BAD_CAST tooltipParentToString( _ToolTipParent ).c_str() ); @@ -474,7 +477,7 @@ namespace NLGUI // *************************************************************************** bool CCtrlBase::emptyContextHelp() const { - ucstring help; + std::string help; getContextHelp(help); std::string sTmp = _OnContextHelp; return help.empty() && sTmp.empty(); @@ -492,12 +495,15 @@ namespace NLGUI void CCtrlBase::serial(NLMISC::IStream &f) { CViewBase::serial(f); + + uint version = f.serialVersion(1); + nlassert(version); + f.serial(_ContextHelp); f.serial(_OnContextHelp); f.serial(_OnContextHelpParams); f.serial(_ToolTipSpecialParent); f.serialEnum(_ToolTipParent); - // THotSpot tmpToolTipParentPosRef = _ToolTipParentPosRef; THotSpot tmpToolTipPosRef = _ToolTipPosRef; @@ -513,7 +519,7 @@ namespace NLGUI _ToolTipPosRef = tmpToolTipPosRef; _ToolTipParentPosRefAlt = tmpToolTipParentPosRefAlt; _ToolTipPosRefAlt = tmpToolTipPosRefAlt; - // + nlSerialBitBool(f, _ToolTipInstant); } @@ -575,7 +581,7 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); std::string tooltip = ls.toString(1); - setDefaultContextHelp(ucstring::makeFromUtf8(tooltip)); + setDefaultContextHelp(tooltip); return 0; } diff --git a/nel/src/gui/ctrl_scroll.cpp b/nel/src/gui/ctrl_scroll.cpp index 6b2a5d066..a5a15809c 100644 --- a/nel/src/gui/ctrl_scroll.cpp +++ b/nel/src/gui/ctrl_scroll.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/gui/ctrl_text_button.cpp b/nel/src/gui/ctrl_text_button.cpp index d7902c166..ed45c59fd 100644 --- a/nel/src/gui/ctrl_text_button.cpp +++ b/nel/src/gui/ctrl_text_button.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -136,7 +137,7 @@ namespace NLGUI if( name == "hardtext" ) { if( _ViewText != NULL ) - return _ViewText->getText().toString(); + return _ViewText->getText(); else return std::string( "" ); } @@ -316,7 +317,7 @@ namespace NLGUI if( name == "hardtext" ) { if( _ViewText != NULL ) - _ViewText->setText( value ); + _ViewText->setHardText( value ); return; } else @@ -487,7 +488,7 @@ namespace NLGUI xmlNewProp( node, BAD_CAST "wmargin", BAD_CAST toString( _WMargin ).c_str() ); xmlNewProp( node, BAD_CAST "wmin", BAD_CAST toString( _WMin ).c_str() ); xmlNewProp( node, BAD_CAST "hmin", BAD_CAST toString( _HMin ).c_str() ); - xmlNewProp( node, BAD_CAST "hardtext", BAD_CAST _ViewText->getText().toString().c_str() ); + xmlNewProp( node, BAD_CAST "hardtext", BAD_CAST _ViewText->getText().c_str() ); xmlNewProp( node, BAD_CAST "text_y", BAD_CAST toString( _TextY ).c_str() ); xmlNewProp( node, BAD_CAST "text_x", BAD_CAST toString( _TextX ).c_str() ); xmlNewProp( node, BAD_CAST "text_underlined", BAD_CAST toString( _ViewText->getUnderlined() ).c_str() ); @@ -596,10 +597,7 @@ namespace NLGUI if (prop) { const char *propPtr = prop; - ucstring text = ucstring(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - text = CI18N::get (propPtr); - _ViewText->setText(text); + _ViewText->setTextLocalized(propPtr, true); } } @@ -988,7 +986,7 @@ namespace NLGUI nlassert( v != NULL ); _ViewText = dynamic_cast< CViewText* >( v ); _ViewText->setId( _Id + "_text" ); - _ViewText->setText( ucstring( "text" ) ); + _ViewText->setText( "text" ); _ViewText->setSerializable( false ); } @@ -1039,17 +1037,32 @@ namespace NLGUI // *************************************************************************** - void CCtrlTextButton::setText (const ucstring &text) + void CCtrlTextButton::setText (const std::string &text) { if (_ViewText && !_IsViewTextId) _ViewText->setText(text); } // *************************************************************************** - ucstring CCtrlTextButton::getText () const + std::string CCtrlTextButton::getText () const { if (_ViewText && !_IsViewTextId) return _ViewText->getText(); + return std::string(); + } + + // *************************************************************************** + void CCtrlTextButton::setTextAsUtf16 (const ucstring &text) + { + if (_ViewText && !_IsViewTextId) + _ViewText->setText(text.toUtf8()); + } + + // *************************************************************************** + ucstring CCtrlTextButton::getTextAsUtf16 () const + { + if (_ViewText && !_IsViewTextId) + return CUtfStringView(_ViewText->getText()).toUtf16(); return ucstring(""); } diff --git a/nel/src/gui/dbgroup_combo_box.cpp b/nel/src/gui/dbgroup_combo_box.cpp index 834d2d5bf..725019b72 100644 --- a/nel/src/gui/dbgroup_combo_box.cpp +++ b/nel/src/gui/dbgroup_combo_box.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2015 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -43,7 +43,7 @@ namespace NLGUI void force_link_dbgroup_combo_box_cpp() { } // Compare strings - static inline bool lt_text(const std::pair &s1, const std::pair &s2) + static inline bool lt_text(const std::pair &s1, const std::pair &s2) { return toLower(s1.second) < toLower(s2.second); } @@ -183,10 +183,10 @@ namespace NLGUI if (name) { const char *propPtr = name; - ucstring Text = ucstring::makeFromUtf8(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - Text = CI18N::get (propPtr); - addText(Text); + if (NLMISC::startsWith(propPtr, "ui")) + addText(CI18N::get(propPtr)); + else + addText(propPtr); } } child = child->next; @@ -236,7 +236,7 @@ namespace NLGUI // change selected text if(_CacheSelection<0 || _CacheSelection>=(sint32)_Texts.size() ) { - _ViewText->setText(ucstring()); + _ViewText->setText(std::string()); } else if(_IsExternViewText) { @@ -274,7 +274,7 @@ namespace NLGUI } // *************************************************************************** - void CDBGroupComboBox::addText(const ucstring &text) + void CDBGroupComboBox::addText(const std::string &text) { dirt(); _Texts.push_back(make_pair((uint)_Texts.size(), text)); @@ -283,7 +283,7 @@ namespace NLGUI } // *************************************************************************** - void CDBGroupComboBox::setText(uint i, const ucstring &text) + void CDBGroupComboBox::setText(uint i, const std::string &text) { dirt(); if(i<_Texts.size()) @@ -291,7 +291,7 @@ namespace NLGUI } // *************************************************************************** - void CDBGroupComboBox::insertText(uint i, const ucstring &text) + void CDBGroupComboBox::insertText(uint i, const std::string &text) { dirt(); if(i<_Texts.size()) @@ -313,7 +313,7 @@ namespace NLGUI } // *************************************************************************** - void CDBGroupComboBox::setTexture(uint i, const ucstring &texture) + void CDBGroupComboBox::setTexture(uint i, const std::string &texture) { dirt(); if(i<_Textures.size()) @@ -351,13 +351,19 @@ namespace NLGUI } // *************************************************************************** - const ucstring &CDBGroupComboBox::getText(uint i) const + const std::string &CDBGroupComboBox::getText(uint i) const { - static ucstring null; - if(i<_Texts.size()) + static const std::string empty; + if (i < _Texts.size()) return _Texts[i].second; else - return null; + return empty; + } + + // *************************************************************************** + ucstring CDBGroupComboBox::getTextAsUtf16(uint i) const + { + return ucstring::makeFromUtf8(getText(i)); } // *************************************************************************** @@ -385,15 +391,21 @@ namespace NLGUI { sort(_Texts.begin(), _Texts.end(), lt_text); } - + // *************************************************************************** - const ucstring &CDBGroupComboBox::getTexture(uint i) const + const std::string &CDBGroupComboBox::getTexture(uint i) const { - static ucstring null; - if(i<_Textures.size()) + static const std::string empty; + if (i < _Textures.size()) return _Textures[i]; else - return null; + return empty; + } + + // *************************************************************************** + ucstring CDBGroupComboBox::getTextureAsUtf16(uint i) const + { + return ucstring::makeFromUtf8(getTexture(i)); } // *************************************************************************** @@ -452,8 +464,7 @@ namespace NLGUI sint32 value; for(uint i=0; isetText(_ExternViewText); } // *************************************************************************** - ucstring CDBGroupComboBox::getViewText() const + std::string CDBGroupComboBox::getViewText() const { - return _ViewText->getText(); + return _ViewText->getText(); + } + + // *************************************************************************** + ucstring CDBGroupComboBox::getViewTextAsUtf16() const + { + return CUtfStringView(_ViewText->getText()).toUtf16(); } // *************************************************************************** @@ -486,18 +503,14 @@ namespace NLGUI // *************************************************************************** std::string CDBGroupComboBox::getSelectionText() const { - ucstring text; if (_LinkedToDB) { - text = getText(_Selection.getSInt32()); + return getText(_Selection.getSInt32()); } else { - text = getText(_NotLinkedToDBSelection); + return getText(_NotLinkedToDBSelection); } - std::string texteS; - text.toString(texteS); - return texteS; } // *************************************************************************** @@ -538,8 +551,7 @@ namespace NLGUI sint32 value; for(uint i=0; iaddLine(getText(i), "combo_box_select_end", toString(i), - "", std::string(), getTexture(i).toString(), checkable); + "", std::string(), getTexture(i), checkable); groupMenu->setGrayedLine(i, getGrayed(i)); } diff --git a/nel/src/gui/dbview_number.cpp b/nel/src/gui/dbview_number.cpp index af768140c..c0c728f2b 100644 --- a/nel/src/gui/dbview_number.cpp +++ b/nel/src/gui/dbview_number.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -43,7 +44,7 @@ namespace NLGUI { _Positive = false; _Cache= 0; - setText(ucstring("0")); + setText(std::string("0")); _Divisor = 1; _Modulo = 0; } @@ -225,7 +226,7 @@ namespace NLGUI // init cache. _Cache= 0; - setText(ucstring("0")); + setText(std::string("0")); return true; } @@ -238,9 +239,9 @@ namespace NLGUI if (_Cache != val) { _Cache= val; - ucstring value = _Format ? NLMISC::formatThousands(toString(val)) : toString(val); - if (_Positive) setText(val >= 0 ? ( ucstring(_Prefix) + value + ucstring(_Suffix) ) : ucstring("?")); - else setText( ucstring(_Prefix) + value + ucstring(_Suffix) ); + std::string value = _Format ? NLMISC::formatThousands(toString(val)) : toString(val); + if (_Positive) setText(val >= 0 ? ( _Prefix.toString() + value + _Suffix.toString() ) : "?"); + else setText( _Prefix.toString() + value + _Suffix.toString() ); } } diff --git a/nel/src/gui/dbview_quantity.cpp b/nel/src/gui/dbview_quantity.cpp index cac772c96..84c214191 100644 --- a/nel/src/gui/dbview_quantity.cpp +++ b/nel/src/gui/dbview_quantity.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -63,7 +64,7 @@ namespace NLGUI else if( name == "emptytext" ) { - return _EmptyText.toString(); + return _EmptyText; } else return CViewText::getProperty( name ); @@ -112,7 +113,7 @@ namespace NLGUI else xmlSetProp( node, BAD_CAST "valuemax", BAD_CAST "" ); - xmlSetProp( node, BAD_CAST "emptytext", BAD_CAST _EmptyText.toString().c_str() ); + xmlSetProp( node, BAD_CAST "emptytext", BAD_CAST _EmptyText.c_str() ); return node; } @@ -147,9 +148,10 @@ namespace NLGUI if(ptr) { const char *propPtr = ptr; - _EmptyText = ucstring(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - _EmptyText = CI18N::get (propPtr); + if (NLMISC::startsWith(propPtr, "ui")) + _EmptyText = CI18N::get(propPtr); + else + _EmptyText = propPtr; } // init cache. diff --git a/nel/src/gui/group_container.cpp b/nel/src/gui/group_container.cpp index 87fb59c38..0740bd80f 100644 --- a/nel/src/gui/group_container.cpp +++ b/nel/src/gui/group_container.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -1338,19 +1338,19 @@ namespace NLGUI if( name == "title" ) { if( _TitleTextOpened == _TitleTextClosed ) - return _TitleTextOpened.toString(); + return _TitleTextOpened; else return ""; } else if( name == "title_opened" ) { - return _TitleTextOpened.toString(); + return _TitleTextOpened; } else if( name == "title_closed" ) { - return _TitleTextClosed.toString(); + return _TitleTextClosed; } else if( name == "header_active" ) @@ -1997,12 +1997,12 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "content_y_offset", BAD_CAST toString( _ContentYOffset ).c_str() ); if( _TitleTextOpened == _TitleTextClosed ) - xmlSetProp( node, BAD_CAST "title", BAD_CAST _TitleTextOpened.toString().c_str() ); + xmlSetProp( node, BAD_CAST "title", BAD_CAST _TitleTextOpened.c_str() ); else xmlSetProp( node, BAD_CAST "title", BAD_CAST "" ); - xmlSetProp( node, BAD_CAST "title_opened", BAD_CAST _TitleTextOpened.toString().c_str() ); - xmlSetProp( node, BAD_CAST "title_closed", BAD_CAST _TitleTextClosed.toString().c_str() ); + xmlSetProp( node, BAD_CAST "title_opened", BAD_CAST _TitleTextOpened.c_str() ); + xmlSetProp( node, BAD_CAST "title_closed", BAD_CAST _TitleTextClosed.c_str() ); xmlSetProp( node, BAD_CAST "header_active", BAD_CAST toString( _HeaderActive ).c_str() ); if( _HeaderColor.getNodePtr() != NULL ) @@ -2144,24 +2144,20 @@ namespace NLGUI ptr = xmlGetProp (cur, (xmlChar*)"title"); if (ptr) { - if (_Localize) _TitleTextOpened = CI18N::get(string((const char*)ptr)); - else _TitleTextOpened = string((const char*)ptr); - if (_Localize) _TitleTextClosed = CI18N::get(string((const char*)ptr)); - else _TitleTextClosed = string((const char*)ptr); + _TitleTextOpened = (const char *)ptr; + _TitleTextClosed = (const char *)ptr; } ptr = xmlGetProp (cur, (xmlChar*)"title_opened"); if (ptr) { - if (_Localize) _TitleTextOpened = CI18N::get(string((const char*)ptr)); - else _TitleTextOpened = string((const char*)ptr); + _TitleTextOpened = (const char*)ptr; } ptr = xmlGetProp (cur, (xmlChar*)"title_closed"); if (ptr) { - if (_Localize) _TitleTextClosed = CI18N::get(string((const char*)ptr)); - else _TitleTextClosed = string((const char*)ptr); + _TitleTextClosed = (const char *)ptr; } ptr = xmlGetProp (cur, (xmlChar*)"header_active"); @@ -3712,7 +3708,7 @@ namespace NLGUI { CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam()); // the title here is actually the DB path - vti->setDBTextID(_TitleTextOpened.toString()); + vti->setDBTextID(_TitleTextOpened); vti->setDynamicString(_TitleClass==TitleTextDynString); _TitleOpened = vti; } @@ -3744,7 +3740,7 @@ namespace NLGUI _TitleOpened->setY (pLayer->getValSInt32 ("title_offset_y")); } _TitleOpened->setFontSize (pLayer->getValSInt32 ("title_font_size")); - if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened); + if (_TitleClass == TitleText) setTitledOpenedViewText(); _TitleOpened->setActive (_Opened); // Title when the container is closed @@ -3764,7 +3760,7 @@ namespace NLGUI { CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam()); // the title here is actually the DB path - vti->setDBTextID(_TitleTextClosed.toString()); + vti->setDBTextID(_TitleTextClosed); vti->setDynamicString(_TitleClass==TitleTextDynString); _TitleClosed = vti; } @@ -3796,7 +3792,7 @@ namespace NLGUI _TitleClosed->setY (pLayer->getValSInt32 ("title_offset_y")); } _TitleClosed->setFontSize (pLayer->getValSInt32 ("title_font_size")); - if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed); + if (_TitleClass == TitleText) setTitledClosedViewText(); _TitleClosed->setActive(!_Opened); @@ -3946,86 +3942,114 @@ namespace NLGUI } } + // *************************************************************************** + void CGroupContainer::setLocalize(bool localize) + { + _Localize = localize; + if (_TitleOpened) + { + _TitleOpened->setLocalized(localize); + } + if (_TitleClosed) + { + _TitleClosed->setLocalized(localize); + } + invalidateCoords(); + } + // *************************************************************************** std::string CGroupContainer::getTitle () const { - return _TitleTextOpened.toString(); + return _TitleTextOpened; } // *************************************************************************** void CGroupContainer::setTitle (const std::string &title) { - if (_Localize) setUCTitle (CI18N::get(title)); - else setUCTitle (title); + setTitleOpened(title); + setTitleClosed(title); } // *************************************************************************** std::string CGroupContainer::getTitleOpened () const { - return _TitleTextOpened.toString(); + return _TitleTextOpened; } // *************************************************************************** void CGroupContainer::setTitleOpened (const std::string &title) { - if (_Localize) setUCTitleOpened (CI18N::get(title)); - else setUCTitleOpened (title); + _TitleTextOpened = title; + setTitledOpenedViewText(); + invalidateCoords(); } // *************************************************************************** std::string CGroupContainer::getTitleClosed () const { - return _TitleTextClosed.toString(); + return _TitleTextClosed; } // *************************************************************************** void CGroupContainer::setTitleClosed (const std::string &title) { - if (_Localize) setUCTitleClosed (CI18N::get(title)); - else setUCTitleClosed (title); + _TitleTextClosed = title; + setTitledClosedViewText(); + invalidateCoords(); } // *************************************************************************** - void CGroupContainer::setUCTitleOpened(const ucstring &title) + void CGroupContainer::setTitledOpenedViewText() { - _TitleTextOpened = title; if (_TitleOpened != NULL) - _TitleOpened->setText (title); - invalidateCoords(); + { + _TitleOpened->setTextLocalized(_TitleTextOpened, _Localize); + } } // *************************************************************************** - void CGroupContainer::setUCTitleClosed(const ucstring &title) + void CGroupContainer::setTitledClosedViewText() { - _TitleTextClosed = title; if (_TitleClosed != NULL) - _TitleClosed->setText (_TitleTextClosed); - invalidateCoords(); + { + _TitleClosed->setTextLocalized(_TitleTextClosed, _Localize); + } + } + + // *************************************************************************** + void CGroupContainer::setUCTitleOpened(const ucstring &title) + { + setTitleOpened(title.toUtf8()); + } + + // *************************************************************************** + void CGroupContainer::setUCTitleClosed(const ucstring &title) + { + setTitleClosed(title.toUtf8()); } // *************************************************************************** void CGroupContainer::setUCTitle(const ucstring &title) { - setUCTitleOpened(title); - setUCTitleClosed(title); + setTitle(title.toUtf8()); } // *************************************************************************** ucstring CGroupContainer::getUCTitle () const { - return getUCTitleOpened(); + return ucstring::makeFromUtf8(getTitle()); } // *************************************************************************** ucstring CGroupContainer::getUCTitleOpened () const { - return _TitleTextOpened; + return ucstring::makeFromUtf8(getTitleOpened()); } // *************************************************************************** ucstring CGroupContainer::getUCTitleClosed () const { - return _TitleTextClosed; + return ucstring::makeFromUtf8(getTitleClosed()); } // *************************************************************************** diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp index 136909f63..27084dd1b 100644 --- a/nel/src/gui/group_editbox.cpp +++ b/nel/src/gui/group_editbox.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -21,6 +22,7 @@ #include "stdpch.h" #include "nel/gui/group_editbox.h" #include "nel/misc/command.h" +#include "nel/misc/utf_string_view.h" #include "nel/gui/view_text.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/interface_options.h" @@ -95,7 +97,7 @@ namespace NLGUI _ViewTextDeltaX(0) { - _Prompt = ">"; + _Prompt = ::u32string(1, (u32char)'>'); _BackSelectColor= CRGBA::White; _TextSelectColor= CRGBA::Black; } @@ -169,7 +171,7 @@ namespace NLGUI else if( name == "prompt" ) { - return _Prompt.toString(); + return CUtfStringView(_Prompt).toUtf8(); } else if( name == "enter_type" ) @@ -263,9 +265,9 @@ namespace NLGUI std::string s; s.reserve( _NegativeFilter.size() ); - std::vector< char >::const_iterator itr; - for( itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr ) - s.push_back( *itr ); + std::vector< u32char >::const_iterator itr; + for (itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr) + CUtfStringView::append(s, *itr); return s; } @@ -353,7 +355,7 @@ namespace NLGUI else if( name == "prompt" ) { - _Prompt = value; + _Prompt = CUtfStringView(value).toUtf32(); return; } else @@ -449,10 +451,10 @@ namespace NLGUI if( name == "negative_filter" ) { _NegativeFilter.clear(); - - std::string::size_type i; - for( i = 0; i < value.size(); i++ ) - _NegativeFilter.push_back( value[ i ] ); + ::u32string::size_type i; + ::u32string ustr = CUtfStringView(value).toUtf32(); + for( i = 0; i < ustr.size(); i++ ) + _NegativeFilter.push_back(ustr[i]); } else CInterfaceGroup::setProperty( name, value ); @@ -476,7 +478,7 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "max_chars_size", BAD_CAST toString( _MaxCharsSize ).c_str() ); xmlSetProp( node, BAD_CAST "enter_loose_focus", BAD_CAST toString( _LooseFocusOnEnter ).c_str() ); xmlSetProp( node, BAD_CAST "enter_recover_focus", BAD_CAST toString( _RecoverFocusOnEnter ).c_str() ); - xmlSetProp( node, BAD_CAST "prompt", BAD_CAST _Prompt.toString().c_str() ); + xmlSetProp( node, BAD_CAST "prompt", BAD_CAST CUtfStringView(_Prompt).toUtf8().c_str() ); std::string e; switch( _EntryType ) @@ -538,9 +540,9 @@ namespace NLGUI std::string s; s.reserve( _NegativeFilter.size() ); - std::vector< char >::const_iterator itr; + std::vector< u32char >::const_iterator 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() ); @@ -605,7 +607,7 @@ namespace NLGUI if (prop) _ResetFocusOnHide = convertBool(prop); prop = (char*) xmlGetProp( cur, (xmlChar*)"prompt" ); - if (prop) _Prompt = (const char*)prop; + if (prop) _Prompt = CUtfStringView((const char*)prop).toUtf32(); prop = (char*) xmlGetProp( cur, (xmlChar*)"entry_type" ); _EntryType = Text; @@ -656,9 +658,11 @@ namespace NLGUI prop = (char*) xmlGetProp( cur, (xmlChar*)"negative_filter" ); if (prop) { - uint length = (uint)strlen(prop); - _NegativeFilter.resize(length); - std::copy((const char *) prop, (const char *) prop + length, _NegativeFilter.begin()); + _NegativeFilter.clear(); + ::u32string::size_type i; + ::u32string ustr = CUtfStringView(prop).toUtf32(); + for( i = 0; i < ustr.size(); i++ ) + _NegativeFilter.push_back(ustr[i]); } return true; @@ -802,7 +806,7 @@ namespace NLGUI cutSelection(); } - ucstring sString; + string sString; if (CViewRenderer::getInstance()->getDriver()->pasteTextFromClipboard(sString)) { @@ -812,7 +816,7 @@ namespace NLGUI } // ---------------------------------------------------------------------------- - void CGroupEditBox::appendStringFromClipboard(const ucstring &str) + void CGroupEditBox::appendStringFromClipboard(const std::string &str) { stopParentBlink(); makeTopWindow(); @@ -826,11 +830,12 @@ namespace NLGUI } // ---------------------------------------------------------------------------- - void CGroupEditBox::writeString(const ucstring &str, bool replace, bool atEnd) + void CGroupEditBox::writeString(const std::string &str16, bool replace, bool atEnd) { + ::u32string str = CUtfStringView(str16).toUtf32(); sint length = (sint)str.length(); - ucstring toAppend; + ::u32string toAppend; // filter character depending on the entry type switch (_EntryType) { @@ -852,7 +857,7 @@ namespace NLGUI } } // 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; @@ -963,7 +968,7 @@ namespace NLGUI { length = _MaxNumChar - (sint)_InputString.length(); } - ucstring toAdd = toAppend.substr(0, length); + ::u32string toAdd = toAppend.substr(0, length); sint32 minPos; sint32 maxPos; if (_CurrSelection == this) @@ -1013,7 +1018,7 @@ namespace NLGUI _CursorAtPreviousLineEnd = false; if (_ClearOnEscape) { - setInputString(ucstring("")); + setInputStringAsUtf32(::u32string()); triggerOnChangeAH(); } CWidgetManager::getInstance()->setCaptureKeyboard(NULL); @@ -1059,8 +1064,9 @@ namespace NLGUI { if (isKeyRETURN) { - ucstring copyStr= _InputString; - if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn) + //ucstring copyStr= _InputString; + //if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn) + if ((uint)std::count(_InputString.begin(), _InputString.end(), '\n') >= _MaxNumReturn) break; } @@ -1074,7 +1080,7 @@ namespace NLGUI cutSelection(); } - ucchar c = isKeyRETURN ? '\n' : rEDK.getChar(); + u32char c = isKeyRETURN ? '\n' : rEDK.getChar(); if (isFiltered(c)) return; switch(_EntryType) { @@ -1121,11 +1127,11 @@ namespace NLGUI if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX)) { // estimate new string - ucstring copyStr= _InputString; - ucstring::iterator it = copyStr.begin() + _CursorPos; + ::u32string copyStr= _InputString; + ::u32string::iterator it = copyStr.begin() + _CursorPos; copyStr.insert(it, c); sint32 value; - fromString(copyStr.toString(), value); + fromString(CUtfStringView(copyStr).toUtf8(), value); // if out of bounds, abort char if(value<_IntegerMinValue || value>_IntegerMaxValue) return; @@ -1134,12 +1140,12 @@ namespace NLGUI if(_EntryType==PositiveInteger && (_PositiveIntegerMinValue!=0 || _PositiveIntegerMaxValue!=UINT_MAX)) { // estimate new string - ucstring copyStr= _InputString; - ucstring::iterator it = copyStr.begin() + _CursorPos; + ::u32string copyStr= _InputString; + ::u32string::iterator it = copyStr.begin() + _CursorPos; copyStr.insert(it, c); // \todo yoyo: this doesn't really work i think.... uint32 value; - fromString(copyStr.toString(), value); + fromString(CUtfStringView(copyStr).toUtf8(), value); // if out of bounds, abort char if(value<_PositiveIntegerMinValue || value>_PositiveIntegerMaxValue) return; @@ -1148,7 +1154,7 @@ namespace NLGUI if ((uint) _InputString.length() < _MaxNumChar) { makeTopWindow(); - ucstring::iterator it = _InputString.begin() + _CursorPos; + ::u32string::iterator it = _InputString.begin() + _CursorPos; _InputString.insert(it, c); ++ _CursorPos; triggerOnChangeAH(); @@ -1176,7 +1182,7 @@ namespace NLGUI if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (!_CanUndo) return false; _ModifiedInputString = _InputString; - setInputString(_StartInputString); + setInputStringAsUtf32(_StartInputString); _CanUndo = false; _CanRedo = true; setCursorPos((sint32)_InputString.length()); @@ -1189,7 +1195,7 @@ namespace NLGUI { if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (!_CanRedo) return false; - setInputString(_ModifiedInputString); + setInputStringAsUtf32(_ModifiedInputString); _CanUndo = true; _CanRedo = false; setCursorPos((sint32)_InputString.length()); @@ -1229,11 +1235,11 @@ namespace NLGUI { makeTopWindow(); // for french, deutsch and russian, be aware of unicode - std::string command = ucstring(_InputString.substr(1)).toUtf8(); + std::string command = CUtfStringView(_InputString.substr(1)).toUtf8(); ICommand::expand(command); - // then back to ucstring - _InputString.fromUtf8(command); - _InputString = '/' + _InputString; + // then back to u32string + _InputString = CUtfStringView('/' + command).toUtf32(); + _InputString = _InputString; _CursorPos = (sint32)_InputString.length(); _CursorAtPreviousLineEnd = false; triggerOnChangeAH(); @@ -1260,7 +1266,7 @@ namespace NLGUI // else delete last character else if(_InputString.size () > 0 && _CursorPos != 0) { - ucstring::iterator it = _InputString.begin() + (_CursorPos - 1); + ::u32string::iterator it = _InputString.begin() + (_CursorPos - 1); _InputString.erase(it); -- _CursorPos; _CursorAtPreviousLineEnd = false; @@ -1300,7 +1306,7 @@ namespace NLGUI default: break; } // update the text - setInputString(_InputString); + setInputStringAsUtf32(_InputString); // if event of type char or string, consider handle all of them if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring ) @@ -1430,16 +1436,14 @@ namespace NLGUI { if (_ViewText) { - ucstring usTmp; + std::string usTmp; if (_EntryType == Password) { - usTmp = _Prompt; - for (uint32 i = 0; i < _InputString.size(); ++i) - usTmp += "*"; + usTmp = CUtfStringView(_Prompt + ::u32string(_InputString.size(), 0x2022)).toUtf8(); } else { - usTmp = _Prompt + _InputString; + usTmp = CUtfStringView(_Prompt + _InputString).toUtf8(); } _ViewText->setText (usTmp); } @@ -1576,13 +1580,13 @@ namespace NLGUI _ViewText->setParent( this ); _ViewText->setIdRecurse( "edit_text" ); - _ViewText->setHardText( "" ); + _ViewText->setTextLocalized( "", false ); _ViewText->setPosRef( Hotspot_ML ); _ViewText->setParentPosRef( Hotspot_ML ); addView( _ViewText ); sint32 w,h; - w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() ); + w = std::max( sint32( _ViewText->getFontWidth() * CUtfStringView(_ViewText->getText()).count() ), getW() ); h = std::max( sint32( _ViewText->getFontHeight() ), getH() ); setH( h ); @@ -1622,7 +1626,18 @@ namespace NLGUI // ---------------------------------------------------------------------------- - void CGroupEditBox::setInputString(const ucstring &str) + void CGroupEditBox::setPrompt(const std::string &s) + { + _Prompt = CUtfStringView(s).toUtf32(); + } + + + // ---------------------------------------------------------------------------- + void CGroupEditBox::setInputString(const std::string &str) + { + setInputStringAsUtf32(CUtfStringView(str).toUtf32()); + } + void CGroupEditBox::setInputStringAsUtf32(const ::u32string &str) { _InputString = str; if (_CursorPos > (sint32) str.length()) @@ -1638,18 +1653,17 @@ namespace NLGUI // *************************************************************************** - void CGroupEditBox::setDefaultInputString(const ucstring &str) + void CGroupEditBox::setDefaultInputString(const std::string &str) { _DefaultInputString= true; setInputString(str); } - // *************************************************************************** sint32 CGroupEditBox::getInputStringAsInt() const { sint32 value; - fromString(_InputString.toString(), value); + fromString(getInputString(), value); return value; } @@ -1663,7 +1677,7 @@ namespace NLGUI sint64 CGroupEditBox::getInputStringAsInt64() const { sint64 value; - fromString(_InputString.toString(), value); + fromString(getInputString(), value); return value; } @@ -1677,7 +1691,7 @@ namespace NLGUI float CGroupEditBox::getInputStringAsFloat() const { float value; - fromString(_InputString.toString(), value); + fromString(getInputString(), value); return value; } @@ -1691,8 +1705,8 @@ namespace NLGUI // *************************************************************************** void CGroupEditBox::cutSelection() { - sint32 minPos= min(_CursorPos, _SelectCursorPos); - sint32 maxPos= max(_CursorPos, _SelectCursorPos); + ptrdiff_t minPos= min(_CursorPos, _SelectCursorPos); + ptrdiff_t maxPos= max(_CursorPos, _SelectCursorPos); // cut the selection if(!_InputString.empty()) { @@ -1704,12 +1718,12 @@ namespace NLGUI } // *************************************************************************** - ucstring CGroupEditBox::getSelection() + std::string CGroupEditBox::getSelection() { - sint32 minPos= min(_CursorPos, _SelectCursorPos); - sint32 maxPos= max(_CursorPos, _SelectCursorPos); + ptrdiff_t minPos= min(_CursorPos, _SelectCursorPos); + ptrdiff_t maxPos= max(_CursorPos, _SelectCursorPos); // get the selection - return _InputString.substr(minPos, maxPos-minPos); + return CUtfStringView(_InputString.substr(minPos, maxPos-minPos)).toUtf8(); } @@ -1736,42 +1750,38 @@ namespace NLGUI } // *************************************************************************** - void CGroupEditBox::setInputStringAsStdString(const std::string &str) + std::string CGroupEditBox::getPrompt() const { - setInputString(ucstring(str)); + return NLMISC::CUtfStringView(_Prompt).toUtf8(); } // *************************************************************************** - std::string CGroupEditBox::getInputStringAsStdString() const + std::string CGroupEditBox::getInputString() const { - std::string result; - _InputString.toString(result); - return result; + return NLMISC::CUtfStringView(_InputString).toUtf8(); } // *************************************************************************** - void CGroupEditBox::setInputStringAsUtf8(const std::string &str) + void CGroupEditBox::setInputStringAsUtf16(const ucstring &str) { - ucstring tmp; - tmp.fromUtf8(str); - setInputString(tmp); + setInputStringAsUtf32(CUtfStringView(str).toUtf32()); } // *************************************************************************** - std::string CGroupEditBox::getInputStringAsUtf8() const + ucstring CGroupEditBox::getInputStringAsUtf16() const { - return _InputString.toUtf8(); + return CUtfStringView(_InputString).toUtf16(); } // *************************************************************************** - void CGroupEditBox::setCommand(const ucstring &command, bool execute) + void CGroupEditBox::setCommand(const std::string &command, bool execute) { // do nothing if frozen if(_Frozen) return; // set the string and maybe execute - setInputString((ucchar) '/' + command); + setInputString('/' + command); if (execute) { // stop selection @@ -1826,18 +1836,35 @@ namespace NLGUI // *************************************************************************** void CGroupEditBox::serialConfig(NLMISC::IStream &f) { - f.serialVersion(0); + uint version = f.serialVersion(1); if(_DefaultInputString) // Don't want to save the default input { _DefaultInputString= false; _InputString.clear(); } - f.serial(_InputString); + if (version < 1) + { + ucstring str; + if (!f.isReading()) + str = CUtfStringView(_InputString).toUtf16(); + f.serial(str); + if (f.isReading()) + _InputString = CUtfStringView(str).toUtf32(); + } + else + { + std::string str; + if (!f.isReading()) + str = CUtfStringView(_InputString).toUtf8(); + f.serial(str); + if (f.isReading()) + _InputString = CUtfStringView(str).toUtf32(); + } f.serial(_CursorPos); f.serial(_PrevNumLine); if (f.isReading()) { - setInputString(_InputString); + setInputStringAsUtf32(_InputString); } // serial selection @@ -1854,7 +1881,7 @@ namespace NLGUI void CGroupEditBox::onQuit() { // clear the text and restore backup pos before final save - setInputString(ucstring("")); + setInputStringAsUtf32(::u32string()); _CurrSelection = NULL; } @@ -1862,7 +1889,7 @@ namespace NLGUI void CGroupEditBox::onLoadConfig() { // config is not saved when there's an empty string, so restore that default state. - setInputString(ucstring("")); + setInputStringAsUtf32(::u32string()); _CurrSelection = NULL; _PrevNumLine = 1; } @@ -1877,7 +1904,7 @@ namespace NLGUI if (_DefaultInputString) { _DefaultInputString= false; - setInputString(ucstring()); + setInputStringAsUtf32(::u32string()); } _CanRedo = false; _CanUndo = false; diff --git a/nel/src/gui/group_header.cpp b/nel/src/gui/group_header.cpp index 03d688921..2671c2a62 100644 --- a/nel/src/gui/group_header.cpp +++ b/nel/src/gui/group_header.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -161,8 +162,14 @@ namespace NLGUI // ... limitingParent = limitingParent->getParent(); } - - getParentContainer()->setW(totalWidth + getParentContainer()->getWReal() - limitingParent->getWReal()); + if (limitingParent) + { + getParentContainer()->setW(totalWidth + getParentContainer()->getWReal() - limitingParent->getWReal()); + } + else + { + nlwarning("No limiting parent for width"); + } } // resize H @@ -178,9 +185,14 @@ namespace NLGUI CInterfaceGroup *limitingParent = colEnclosing->getParent(); while (limitingParent && (limitingParent->getResizeFromChildH() || dynamic_cast(limitingParent))) limitingParent = limitingParent->getParent(); - - nlassert(limitingParent); - getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal()); + if (limitingParent) + { + getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal()); + } + else + { + nlwarning("No limiting parent for height"); + } } } } diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index 50b381a3c..508d60361 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -27,6 +27,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/rgba.h" #include "nel/misc/algo.h" +#include "nel/misc/utf_string_view.h" #include "nel/gui/libwww.h" #include "nel/gui/group_html.h" #include "nel/gui/group_list.h" @@ -1033,7 +1034,7 @@ namespace NLGUI // *************************************************************************** - void CGroupHTML::addText (const char * buf, int len) + void CGroupHTML::addText (const char *buf, int len) { if (_Browsing) { @@ -1041,44 +1042,43 @@ namespace NLGUI return; // Build a UTF8 string - string inputString(buf, buf+len); - if (_ParsingLua && _TrustedDomain) { // we are parsing a lua script - _LuaScript += inputString; + _LuaScript += string(buf, buf + len); // no more to do return; } // Build a unicode string - ucstring inputUCString; - inputUCString.fromUtf8(inputString); + CUtfStringView inputStringView(buf, len); // Build the final unicode string - ucstring tmp; + string tmp; tmp.reserve(len); - uint ucLen = (uint)inputUCString.size(); - for (uint i=0; igetText().empty() && *(_CurrentViewLink->getText().rbegin()) == (ucchar) '\n'; + bool skipLine = !_CurrentViewLink->getText().empty() && *(_CurrentViewLink->getText().rbegin()) == '\n'; bool sameShadow = style.TextShadow.Enabled && _CurrentViewLink->getShadow(); if (sameShadow && style.TextShadow.Enabled) { @@ -2887,7 +2887,7 @@ namespace NLGUI ctrlButton->setModulateGlobalColorAll (false); // Translate the tooltip - ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(getLinkTitle())); + ctrlButton->setDefaultContextHelp(getLinkTitle()); ctrlButton->setText(tmpStr); // empty url / button disabled bool disabled = string(getLink()).empty(); @@ -2967,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 ? if (!_Paragraph) @@ -3233,7 +3233,7 @@ namespace NLGUI } else { - ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(tooltip)); + ctrlButton->setDefaultContextHelp(tooltip); //ctrlButton->setOnContextHelp(string(tooltip)); } @@ -3305,11 +3305,11 @@ namespace NLGUI // *************************************************************************** - ucchar CGroupHTML::getLastChar() const + u32char CGroupHTML::getLastChar() const { if (_CurrentViewLink) { - const ucstring &str = _CurrentViewLink->getText(); + ::u32string str = CUtfStringView(_CurrentViewLink->getText()).toUtf32(); // FIXME: Optimize reverse UTF iteration if (!str.empty()) return str[str.length()-1]; } @@ -3401,7 +3401,7 @@ namespace NLGUI // *************************************************************************** - void CGroupHTML::setTitle (const ucstring &title) + void CGroupHTML::setContainerTitle (const std::string &title) { CInterfaceElement *parent = getParent(); if (parent) @@ -3411,7 +3411,7 @@ namespace NLGUI CGroupContainer *container = dynamic_cast(parent); if (container) { - container->setUCTitle (title); + container->setTitle(title); } } } @@ -3419,21 +3419,18 @@ namespace NLGUI void CGroupHTML::setTitle(const std::string &title) { - ucstring uctitle; - uctitle.fromUtf8(title); - _TitleString.clear(); if(!_TitlePrefix.empty()) { _TitleString = _TitlePrefix + " - "; } - _TitleString += uctitle; + _TitleString += title; - setTitle(_TitleString); + setContainerTitle(_TitleString); } std::string CGroupHTML::getTitle() const { - return _TitleString.toUtf8(); + return _TitleString; }; // *************************************************************************** @@ -3709,7 +3706,7 @@ namespace NLGUI CGroupEditBox *editBox = dynamic_cast(group); if (editBox) { - entryData = editBox->getViewText()->getText(); + entryData = CUtfStringView(editBox->getViewText()->getText()).toUtf16(); addEntry = true; } } @@ -4180,7 +4177,8 @@ namespace NLGUI } else { - renderHtmlString(content); + // Sanitize downloaded HTML UTF-8 encoding, and render + renderHtmlString(CUtfStringView(content).toUtf8(true)); } } @@ -4684,9 +4682,7 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 3, LUA_TBOOLEAN); string name = ls.toString(1); - - ucstring text; - text.fromUtf8(ls.toString(2)); + string text = ls.toString(2); if (!_Forms.empty()) { @@ -4716,7 +4712,7 @@ namespace NLGUI const char *funcName = "addString"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - addString(ucstring(ls.toString(1))); + addString(ls.toString(1)); return 0; } @@ -4944,7 +4940,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 (base != 16) return false; @@ -4954,7 +4950,7 @@ namespace NLGUI } // *************************************************************************** - inline ucchar convertHexDigit(ucchar c) + inline char convertHexDigit(char c) { if (c>='0' && c<='9') return c-'0'; if (c>='A' && c<='F') return c-'A'+10; @@ -4963,9 +4959,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; for (uint i=0; isetDefaultContextHelp(ucstring(tooltip)); + ctrlButton->setDefaultContextHelp(tooltip); } } - ctrlButton->setText(ucstring::makeFromUtf8(value)); + ctrlButton->setText(value); setTextButtonStyle(ctrlButton, _Style.Current); } @@ -5562,8 +5559,7 @@ namespace NLGUI { if (!_Paragraph || _Paragraph->getNumChildren() == 0) { - ucstring tmp("\n"); - addString(tmp); + addString("\n"); } else { @@ -6085,8 +6081,7 @@ namespace NLGUI { // Get the string name string name = elm.getAttribute("name"); - ucstring ucValue; - ucValue.fromUtf8(elm.getAttribute("value")); + string ucValue = elm.getAttribute("value"); uint size = 20; uint maxlength = 1024; @@ -6120,12 +6115,12 @@ namespace NLGUI string normal = elm.getAttribute("src"); string pushed; string over; - ucstring ucValue = ucstring("on"); + string ucValue = "on"; bool checked = elm.hasAttribute("checked"); // TODO: unknown if empty attribute should override or not if (elm.hasNonEmptyAttribute("value")) - ucValue.fromUtf8(elm.getAttribute("value")); + ucValue = elm.getAttribute("value"); if (type == "radio") { @@ -6190,8 +6185,7 @@ namespace NLGUI string name = elm.getAttribute("name"); // Get the value - ucstring ucValue; - ucValue.fromUtf8(elm.getAttribute("value")); + string ucValue = elm.getAttribute("value"); // Add an entry CGroupHTML::CForm::CEntry entry; @@ -6223,8 +6217,7 @@ namespace NLGUI if (elm.hasNonEmptyAttribute("value")) fromString(elm.getAttribute("value"), _UL.back().Value); - ucstring str; - str.fromUtf8(_UL.back().getListMarkerText()); + string str = _UL.back().getListMarkerText(); addString (str); // list-style-type: outside @@ -6428,7 +6421,7 @@ namespace NLGUI // use option text as 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 diff --git a/nel/src/gui/group_list.cpp b/nel/src/gui/group_list.cpp index b49eed7cc..c65d759ba 100644 --- a/nel/src/gui/group_list.cpp +++ b/nel/src/gui/group_list.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -518,11 +519,10 @@ namespace NLGUI { _HardText = std::string( (const char*)ptr ); const char *propPtr = ptr; - ucstring Text = ucstring(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - Text = CI18N::get (propPtr); - - addTextChild(Text); + if (NLMISC::startsWith(propPtr, "ui")) + addTextChild(CI18N::get(propPtr)); + else + addTextChild(propPtr); } else { @@ -540,7 +540,7 @@ namespace NLGUI // ---------------------------------------------------------------------------- - void CGroupList::addTextChild(const ucstring& line, bool multiLine /*= true*/) + void CGroupList::addTextChild(const std::string& line, bool multiLine /*= true*/) { const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); @@ -559,7 +559,7 @@ namespace NLGUI // ---------------------------------------------------------------------------- - void CGroupList::addTextChild(const ucstring& line, const CRGBA& textColor, bool multiLine /*= true*/) + void CGroupList::addTextChild(const std::string& line, const CRGBA& textColor, bool multiLine /*= true*/) { const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); @@ -1290,7 +1290,7 @@ namespace NLGUI ucstring text; if(CLuaIHM::pop(ls, text)) { - addTextChild(text); + addTextChild(text.toUtf8()); // FIXME: Lua UTF-8 } return 0; } @@ -1314,7 +1314,7 @@ namespace NLGUI uint b = (uint) ls.toInteger(4); uint a = (uint) ls.toInteger(5); - addTextChild(ucText, CRGBA(r, g, b, a)); + addTextChild(ucText.toUtf8(), CRGBA(r, g, b, a)); // FIXME: Lua UTF-8 return 0; } diff --git a/nel/src/gui/group_menu.cpp b/nel/src/gui/group_menu.cpp index 9bf033eca..06bb973db 100644 --- a/nel/src/gui/group_menu.cpp +++ b/nel/src/gui/group_menu.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2015 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -275,7 +275,7 @@ namespace NLGUI if (stricmp((char*)cur->name, "action") == 0) { string strId, strAh, strParams, strCond, strTexture; - ucstring ucstrName; + string ucstrName; if (id) strId = (const char*)id; CXMLAutoPtr name((const char*) xmlGetProp (cur, (xmlChar*)"name")); @@ -283,9 +283,10 @@ namespace NLGUI if (name) { const char *ptrName = (const char*)name; - ucstrName = ucstring(ptrName); - if ((strlen(ptrName)>2) && (ptrName[0] == 'u') && (ptrName[1] == 'i')) - ucstrName = CI18N::get (ptrName); + if (NLMISC::startsWith(ptrName, "ui")) + ucstrName = CI18N::get(ptrName); + else + ucstrName = ptrName; } CXMLAutoPtr ah((const char*) xmlGetProp (cur, (xmlChar*)"handler")); @@ -1222,7 +1223,7 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ - CViewTextMenu* CGroupSubMenu::addLine (const ucstring &name, const std::string &ah, + CViewTextMenu* CGroupSubMenu::addLine (const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id, const std::string &cond, const std::string &texture, bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */ @@ -1303,7 +1304,7 @@ namespace NLGUI return pV; } - CViewTextMenu* CGroupSubMenu::addLineAtIndex(uint index, const ucstring &name, const std::string &ah, + CViewTextMenu* CGroupSubMenu::addLineAtIndex(uint index, const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id /*=""*/, const std::string &cond /*=std::string()*/, const std::string &texture, bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */ @@ -1865,8 +1866,8 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); ucstring arg1; - nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); - addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4)); + nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); // FIXME: Lua UTF-8 + addLine(arg1.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4)); return 0; } @@ -1881,8 +1882,8 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); ucstring arg1; - nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); - addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5)); + nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); // FIXME: Lua UTF-8 + addLine(arg1.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5)); return 0; } @@ -1897,8 +1898,8 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); ucstring arg2; - nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); - addLineAtIndex((uint) ls.toInteger(1), arg2, ls.toString(3), ls.toString(4), ls.toString(5)); + nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); // FIXME: Lua UTF-8 + addLineAtIndex((uint) ls.toInteger(1), arg2.toUtf8(), ls.toString(3), ls.toString(4), ls.toString(5)); return 0; } @@ -2539,25 +2540,7 @@ namespace NLGUI } // ------------------------------------------------------------------------------------------------ - void CGroupMenu::addLine (const string &name, const string &ah, const string ¶ms, - const std::string &id/*=std::string()*/, - const std::string &cond /*= std::string()*/, const std::string &texture, - bool checkable /*= false*/, bool checked /*= false*/ - ) - { - if (_RootMenu == NULL) - { - _RootMenu = new CGroupSubMenu(CViewText::TCtorParam()); - _RootMenu->_GroupMenu = this; - _RootMenu->setSerializable( false ); - addGroup (_RootMenu); - } - - _RootMenu->addLine (name, ah, params, id, cond, texture, checkable, checked, _Formatted); - } - - // ------------------------------------------------------------------------------------------------ - void CGroupMenu::addLine(const ucstring &name, const std::string &ah, const std::string ¶ms, + void CGroupMenu::addLine(const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id /* = std::string()*/, const std::string &cond /*= std::string()*/, const std::string &texture, bool checkable /*= false*/, bool checked /*= false*/ @@ -2573,7 +2556,7 @@ namespace NLGUI _RootMenu->addLine (name, ah, params, id, cond, texture, checkable, checked, _Formatted); } // ------------------------------------------------------------------------------------------------ - void CGroupMenu::addLineAtIndex(uint index, const ucstring &name, const std::string &ah, + void CGroupMenu::addLineAtIndex(uint index, const std::string &name, const std::string &ah, const std::string ¶ms, const std::string &id /*=std::string()*/, const std::string &cond /*=std::string()*/, const std::string &texture, bool checkable /*=false*/, bool checked /*=false*/) diff --git a/nel/src/gui/group_paragraph.cpp b/nel/src/gui/group_paragraph.cpp index 9424c0218..4ca13c8ae 100644 --- a/nel/src/gui/group_paragraph.cpp +++ b/nel/src/gui/group_paragraph.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -476,11 +477,10 @@ namespace NLGUI { _HardText = std::string( (const char*)ptr ); const char *propPtr = ptr; - ucstring Text = ucstring(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - Text = CI18N::get (propPtr); - - addTextChild(Text); + if (NLMISC::startsWith(propPtr, "ui")) + addTextChild(CI18N::get(propPtr)); + else + addTextChild(propPtr); } else { @@ -496,7 +496,7 @@ namespace NLGUI } // ---------------------------------------------------------------------------- - void CGroupParagraph::addTextChild(const ucstring& line, bool multiLine /*= true*/) + void CGroupParagraph::addTextChild(const std::string& line, bool multiLine /*= true*/) { const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); @@ -514,7 +514,7 @@ namespace NLGUI // ---------------------------------------------------------------------------- - void CGroupParagraph::addTextChild(const ucstring& line, const CRGBA& textColor, bool multiLine /*= true*/) + void CGroupParagraph::addTextChild(const std::string& line, const CRGBA& textColor, bool multiLine /*= true*/) { const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); @@ -731,7 +731,7 @@ namespace NLGUI if (viewText) { changeLine = viewText->getNumLine() > 1; - if (!viewText->getText().empty() && *(viewText->getText().rbegin()) == (ucchar) '\n') + if (!viewText->getText().empty() && *(viewText->getText().rbegin()) == '\n') { changeLine = true; } diff --git a/nel/src/gui/group_tree.cpp b/nel/src/gui/group_tree.cpp index 83c080b5e..44636f1d6 100644 --- a/nel/src/gui/group_tree.cpp +++ b/nel/src/gui/group_tree.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -306,9 +307,10 @@ namespace NLGUI if (name) { const char *ptrName = (const char*)name; - Text = ucstring(ptrName); - if ((strlen(ptrName)>2) && (ptrName[0] == 'u') && (ptrName[1] == 'i')) - Text = CI18N::get (ptrName); + if (NLMISC::startsWith(ptrName, "ui")) + Text = CI18N::get(ptrName); + else + Text = ptrName; } CXMLAutoPtr color((const char*) xmlGetProp (cur, (xmlChar*)"color")); diff --git a/nel/src/gui/interface_element.cpp b/nel/src/gui/interface_element.cpp index cf5646077..bc5da4e03 100644 --- a/nel/src/gui/interface_element.cpp +++ b/nel/src/gui/interface_element.cpp @@ -1028,21 +1028,16 @@ namespace NLGUI } // ------------------------------------------------------------------------------------------------ - bool CInterfaceElement::convertBool (const char *ptr) + bool CInterfaceElement::convertBool (const char *ptr) { - std::string str = toLower(ptr); - bool b = false; - fromString( str, b ); - return b; + return NLMISC::toBool(ptr); } // ------------------------------------------------------------------------------------------------ NLMISC::CVector CInterfaceElement::convertVector (const char *ptr) { float x = 0.0f, y = 0.0f, z = 0.0f; - sscanf (ptr, "%f %f %f", &x, &y, &z); - return CVector(x,y,z); } diff --git a/nel/src/gui/interface_expr.cpp b/nel/src/gui/interface_expr.cpp index 813962526..c10627e02 100644 --- a/nel/src/gui/interface_expr.cpp +++ b/nel/src/gui/interface_expr.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -548,7 +549,7 @@ namespace NLGUI case Boolean: return true; case Integer: setBool(_IntegerValue != 0); return true; case Double: setBool(_DoubleValue != 0); return true; - case String: return evalBoolean(_StringValue.toString().c_str()) != NULL; + case String: return evalBoolean(_StringValue.c_str()) != NULL; default: break; } return false; @@ -564,7 +565,7 @@ namespace NLGUI case Integer: return true; case Double: setInteger((sint64) _DoubleValue); return true; case String: - if (evalNumber(_StringValue.toString().c_str())) return toInteger(); + if (evalNumber(_StringValue.c_str())) return toInteger(); return false; case RGBA: setInteger((sint64) _RGBAValue); return true; default: break; @@ -581,7 +582,7 @@ namespace NLGUI case Integer: setDouble((double) _IntegerValue); return true; case Double: return true; case String: - if (evalNumber(_StringValue.toString().c_str())) return toBool(); + if (evalNumber(_StringValue.c_str())) return toBool(); return false; case RGBA: setDouble((double) _RGBAValue); return true; default: break; @@ -627,7 +628,7 @@ namespace NLGUI return true; case String: - setRGBA( NLMISC::CRGBA::stringToRGBA(_StringValue.toString().c_str())); + setRGBA( NLMISC::CRGBA::stringToRGBA(_StringValue.c_str())); return true; default: @@ -869,14 +870,15 @@ namespace NLGUI } //================================================================== - std::string CInterfaceExprValue::getString() const + const std::string &CInterfaceExprValue::getString() const { if (_Type != String) { nlwarning(" bad type!"); - return ""; + static const std::string empty; + return empty; } - return _StringValue.toString(); + return _StringValue; } //================================================================== @@ -895,19 +897,6 @@ namespace NLGUI return col; } - - //================================================================== - const ucstring &CInterfaceExprValue::getUCString() const - { - if (_Type != String) - { - nlwarning(" bad type!"); - static ucstring emptyString; - return emptyString; - } - return _StringValue; - } - //================================================================== CInterfaceExprUserType *CInterfaceExprValue::getUserType() const { diff --git a/nel/src/gui/interface_expr_user_fct.cpp b/nel/src/gui/interface_expr_user_fct.cpp index d0c687d26..f5de62b6f 100644 --- a/nel/src/gui/interface_expr_user_fct.cpp +++ b/nel/src/gui/interface_expr_user_fct.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -359,13 +360,13 @@ namespace NLGUI { if (!args.empty()) { - ucstring res; + string res; for (uint32 i = 0; i < args.size(); ++i) { args[i].toString(); - res += args[i].getUCString(); + res += args[i].getString(); } - result.setUCString (res); + result.setString (res); return true; } @@ -553,13 +554,13 @@ namespace NLGUI result.setString ((elem->*(pRP->GetMethod.GetString))()); break; case CReflectedProperty::UCString: - result.setUCString ((elem->*(pRP->GetMethod.GetUCString))()); + result.setString ((elem->*(pRP->GetMethod.GetUCString))().toUtf8()); break; case CReflectedProperty::StringRef: result.setString ((elem->*(pRP->GetMethod.GetStringRef))()); break; case CReflectedProperty::UCStringRef: - result.setUCString ((elem->*(pRP->GetMethod.GetUCStringRef))()); + result.setString ((elem->*(pRP->GetMethod.GetUCStringRef))().toUtf8()); break; case CReflectedProperty::RGBA: result.setRGBA ((elem->*(pRP->GetMethod.GetRGBA))()); @@ -1072,7 +1073,7 @@ namespace NLGUI } sint64 nVal = args[0].getInteger(); - ucstring sTmp; + string sTmp; if (nVal < 0) nVal = 0; @@ -1099,7 +1100,7 @@ namespace NLGUI } } - result.setUCString(sTmp); + result.setString(sTmp); return true; } @@ -1121,7 +1122,7 @@ namespace NLGUI } sint64 nVal = args[0].getInteger(); - ucstring sTmp; + string sTmp; if (nVal < 0) nVal = 0; @@ -1150,7 +1151,7 @@ namespace NLGUI } } - result.setUCString(sTmp); + result.setString(sTmp); return true; } @@ -1186,7 +1187,7 @@ namespace NLGUI nlwarning("localize : 1 arg required"); return false; } - result.setUCString(CI18N::get(args[0].getString())); + result.setString(CI18N::get(args[0].getString())); return true; } REGISTER_INTERFACE_USER_FCT("localize", localize); diff --git a/nel/src/gui/interface_group.cpp b/nel/src/gui/interface_group.cpp index dacaf16cf..9cced8264 100644 --- a/nel/src/gui/interface_group.cpp +++ b/nel/src/gui/interface_group.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/gui/interface_link.cpp b/nel/src/gui/interface_link.cpp index 03a1212d3..6fbe3a3ec 100644 --- a/nel/src/gui/interface_link.cpp +++ b/nel/src/gui/interface_link.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -121,7 +121,7 @@ namespace NLGUI case CReflectedProperty::UCStringRef: if (valueToAffect.toString()) { - (destElem.*(property.SetMethod.SetUCString))(valueToAffect.getUCString()); + (destElem.*(property.SetMethod.SetUCString))(ucstring::makeFromUtf8(valueToAffect.getString())); } else { diff --git a/nel/src/gui/lua_helper.cpp b/nel/src/gui/lua_helper.cpp index d2b6a68d3..bb5fd5426 100644 --- a/nel/src/gui/lua_helper.cpp +++ b/nel/src/gui/lua_helper.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -216,16 +216,55 @@ namespace NLGUI // *** Load base libs { CLuaStackChecker lsc(this); - #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 +#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 luaL_openlibs(_State); - #else +#else luaopen_base (_State); luaopen_table (_State); luaopen_io (_State); luaopen_string (_State); luaopen_math (_State); luaopen_debug (_State); - #endif +#endif + +#ifdef _WIN32 + // Lua socket library for MobDebug, optional + if (NLMISC::CFile::fileExists("socket\\core.dll")) + { + // Load socket\core.dll dynamically + m_LuaSocket = LoadLibraryW(L"socket\\core.dll"); + if (!m_LuaSocket) + { + nlwarning("Lua socket library found, but failed to load"); + } + else + { + void *luaopen_socket_core = (void *)GetProcAddress(m_LuaSocket, "luaopen_socket_core"); + if (!luaopen_socket_core) + { + nlwarning("Lua socket library loaded, but `luaopen_socket_core` not found"); + FreeLibrary(m_LuaSocket); + m_LuaSocket = NULL; + } + else + { + // preload['socket.core'] = luaopen_socket_core +#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 + lua_getglobal(_State, "package"); + lua_getfield(_State, -1, "preload"); + lua_pushcfunction(_State, (lua_CFunction)luaopen_socket_core); + lua_setfield(_State, -2, "socket.core"); + lua_pop(_State, 2); + nlinfo("Lua socket library preloaded"); +#endif + } + } + } + else + { + m_LuaSocket = NULL; + } +#endif // open are buggy???? clear(); @@ -313,6 +352,14 @@ namespace NLGUI // Clear Small Script Cache _SmallScriptPool= 0; _SmallScriptCache.clear(); + +#ifdef _WIN32 + if (m_LuaSocket) + { + FreeLibrary(m_LuaSocket); + m_LuaSocket = NULL; + } +#endif } // *************************************************************************** @@ -464,7 +511,23 @@ namespace NLGUI // execute the script text, with dbgSrc==filename (use @ for lua internal purpose) - executeScriptInternal(script, string("@") + CFile::getFilename(pathName)); +#ifdef _WIN32 + // Paths need to be correct for debugging to work + std::string pathNameStandardized = pathName; + if (pathNameStandardized.size() > 1) + { + if (pathNameStandardized[1] == ':' && pathNameStandardized[0] >= 'a' && pathNameStandardized[0] <= 'z') + pathNameStandardized[0] -= 'a' - 'A'; + for (ptrdiff_t i = 0; i < (ptrdiff_t)pathNameStandardized.size(); ++i) + { + if (pathNameStandardized[i] == '/') + pathNameStandardized[i] = '\\'; + } + } +#else + const std::string &pathNameStandardized = pathName; +#endif + executeScriptInternal(script, string("@") + pathNameStandardized); return true; } diff --git a/nel/src/gui/lua_ihm.cpp b/nel/src/gui/lua_ihm.cpp index 946baa560..9b00026d7 100644 --- a/nel/src/gui/lua_ihm.cpp +++ b/nel/src/gui/lua_ihm.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -1145,34 +1145,8 @@ namespace NLGUI ls.push(value.getDouble()); break; case CInterfaceExprValue::String: - { - ucstring ucstr= value.getUCString(); - // Yoyo: dynamically decide whether must return a string or a ucstring - bool mustUseUCString= false; - for (uint i = 0; i < ucstr.size (); i++) - { - if (ucstr[i] > 255) - { - mustUseUCString= true; - break; - } - } - // push a ucstring? - if(mustUseUCString) - { - #if LUABIND_VERSION > 600 - luabind::detail::push(ls.getStatePointer(), ucstr); - #else - luabind::object obj(ls.getStatePointer(), ucstr); - obj.pushvalue(); - #endif - } - else - { - ls.push(ucstr.toString()); - } - break; - } + ls.push(value.getString()); + break; case CInterfaceExprValue::RGBA: { CRGBA color = value.getRGBA(); @@ -1691,7 +1665,7 @@ namespace NLGUI // inside i18n table luabind::module(L, "i18n") [ - luabind::def("get", &CI18N::get), + luabind::def("get", &CI18N::getAsUtf16), // FIXME: Lua UTF-8 luabind::def("hasTranslation", &CI18N::hasTranslation) ]; // inside 'nlfile' table @@ -1880,21 +1854,21 @@ namespace NLGUI ucstring CLuaIHM::findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace) { //H_AUTO(Lua_CLuaIHM_findReplaceAll) - return findReplaceAll(str, ucstring(search), ucstring(replace)); + return findReplaceAll(str, ucstring::makeFromUtf8(search), ucstring::makeFromUtf8(replace)); } // *************************************************************************** ucstring CLuaIHM::findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace) { //H_AUTO(Lua_CLuaIHM_findReplaceAll) - return findReplaceAll(str, ucstring(search), ucstring(replace)); + return findReplaceAll(str, ucstring::makeFromUtf8(search), replace); } // *************************************************************************** ucstring CLuaIHM::findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace) { //H_AUTO(Lua_CLuaIHM_findReplaceAll) - return findReplaceAll(str, ucstring(search), ucstring(replace)); + return findReplaceAll(str, search, ucstring::makeFromUtf8(replace)); } diff --git a/nel/src/gui/string_case.cpp b/nel/src/gui/string_case.cpp index c96e2cc7f..946b8d58a 100644 --- a/nel/src/gui/string_case.cpp +++ b/nel/src/gui/string_case.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -19,6 +20,7 @@ #include "stdpch.h" #include "nel/gui/string_case.h" +#include "nel/misc/utf_string_view.h" #ifdef DEBUG_NEW #define new DEBUG_NEW @@ -26,32 +28,22 @@ namespace NLGUI { - inline bool isSeparator (ucchar c) + inline bool isSeparator (char c) { return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'); } - // *************************************************************************** - - inline bool isEndSentence (ucstring& str, uint index) + inline bool isEndSentence (char c, char lastChar) { // 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; + return ((c == ' ') || (c == '\n')) + && ((lastChar == '.') || (lastChar == '!') || (lastChar == '?') || (lastChar == '\n')); } - - void setCase( ucstring &str, TCaseMode mode ) + void setCase(std::string &str, TCaseMode mode) { const uint length = (uint)str.length(); uint i; @@ -61,63 +53,96 @@ namespace NLGUI switch (mode) { case CaseLower: - str = NLMISC::toLower (str); + str = NLMISC::toLower(str); break; case CaseUpper: - str = NLMISC::toUpper (str); + str = NLMISC::toUpper(str); break; case CaseFirstStringLetterUp: - for (i=0; i> 2)); + for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();) { - if (!isSeparator (str[i])) + char c = str[i]; + if (!isSeparator(c)) { if (newString) - str[i] = NLMISC::toUpper (str[i]); + NLMISC::appendToUpper(res, str, i); else - str[i] = NLMISC::toLower (str[i]); + NLMISC::appendToLower(res, str, i); newString = false; } + else + { + res += c; + ++i; + } } + str.swap(res); break; + } case CaseFirstSentenceLetterUp: - for (i=0; i> 2)); + char lastChar = 0; + for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();) { - if (isEndSentence (str, i)) + char c = str[i]; + if (isEndSentence(c, lastChar)) + { newSentence = true; + res += c; + ++i; + } else { if (newSentence) - str[i] = NLMISC::toUpper (str[i]); + NLMISC::appendToUpper(res, str, i); else - str[i] = NLMISC::toLower (str[i]); + NLMISC::appendToLower(res, str, i); - if (!isSeparator (str[i])) + if (!isSeparator(c)) newSentence = false; } + lastChar = c; } + str.swap(res); break; + } case CaseFirstWordLetterUp: - for (i=0; i> 2)); + char lastChar = 0; + for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();) { - if (isSeparator (str[i]) || isEndSentence (str, i)) + char c = str[i]; + if (isSeparator(c) || isEndSentence(c, lastChar)) + { newWord = true; + res += c; + ++i; + } else { if (newWord) - str[i] = NLMISC::toUpper (str[i]); + NLMISC::appendToUpper(res, str, i); else - str[i] = NLMISC::toLower (str[i]); + NLMISC::appendToLower(res, str, i); newWord = false; } + lastChar = c; } + str.swap(res); break; + } default: break; } } - } - - +/* end of file */ diff --git a/nel/src/gui/view_pointer.cpp b/nel/src/gui/view_pointer.cpp index 82c0174f5..228868731 100644 --- a/nel/src/gui/view_pointer.cpp +++ b/nel/src/gui/view_pointer.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -206,7 +207,10 @@ namespace NLGUI if (_TxIdDefault == -2) { - _TxIdDefault = rVR.getTextureIdFromName (_TxDefault); + _TxIdDefault = rVR.getTextureIdFromName(_TxDefault); + } + if (_TxIdMoveWindow == -2) + { _TxIdMoveWindow = rVR.getTextureIdFromName (_TxMoveWindow); _TxIdResizeBRTL = rVR.getTextureIdFromName (_TxResizeBRTL); _TxIdResizeBLTR = rVR.getTextureIdFromName (_TxResizeBLTR); @@ -250,7 +254,7 @@ namespace NLGUI if (vLink->getMouseOverShape(tooltip, rot, col)) { - setString(ucstring::makeFromUtf8(tooltip)); + setString(tooltip); sint32 texId = rVR.getTextureIdFromName ("curs_pick.tga"); CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; @@ -406,7 +410,7 @@ namespace NLGUI splitString(tooltipInfos, "@", tooltipInfosList); texName = tooltipInfosList[0]; tooltip = tooltipInfosList[1]; - setString(ucstring::makeFromUtf8(tooltip)); + setString(tooltip); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 texId = rVR.getTextureIdFromName (texName); @@ -449,7 +453,7 @@ namespace NLGUI } // -------------------------------------------------------------------------------------------------------------------- - void CViewPointer::setString (const ucstring &str, CInterfaceGroup *target) + void CViewPointer::setString(const std::string &str, CInterfaceGroup *target) { if (target) { @@ -475,7 +479,7 @@ namespace NLGUI // -------------------------------------------------------------------------------------------------------------------- - void CViewPointer::setString (const ucstring &str) + void CViewPointer::setString (const std::string &str) { if (_ContextString != str) { diff --git a/nel/src/gui/view_renderer.cpp b/nel/src/gui/view_renderer.cpp index 6a7d86eef..7d077ba4c 100644 --- a/nel/src/gui/view_renderer.cpp +++ b/nel/src/gui/view_renderer.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -888,6 +889,7 @@ namespace NLGUI driver->setCursorScale( CViewRenderer::hwCursorScale ); char bufTmp[256], tgaName[256]; + tgaName[0] = 0; string sTGAname; float uvMinU, uvMinV, uvMaxU, uvMaxV; while (!iFile.eof()) diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp index dab618ff8..f96ac535d 100644 --- a/nel/src/gui/view_text.cpp +++ b/nel/src/gui/view_text.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -111,6 +111,8 @@ namespace NLGUI _ClampRight = true; // clamp on the right of the text _OverflowText = "..."; + _Localized = true; + _LetterColors = NULL; _Setuped= false; _AutoClampOffset = 0; @@ -118,9 +120,10 @@ namespace NLGUI // Letter size // - "_" that should be the character with the lowest part // - A with an accent for the highest part - _FontSizingChars.fromUtf8("_\xc3\x84"); + // https://www.compart.com/en/unicode/U+00C4 + _FontSizingChars = "_\xC3\x84q"; // fallback if SizingChars are not supported by font - _FontSizingFallback.fromUtf8("|"); + _FontSizingFallback = "|XO"; computeFontSize (); } @@ -150,7 +153,7 @@ namespace NLGUI _Color = Color; _Shadow = Shadow; _ShadowOutline = ShadowOutline; - setText(Text); + setHardText(Text); computeFontSize (); CWidgetManager::getInstance()->registerInterfaceScaleWatcher(this); @@ -210,7 +213,7 @@ namespace NLGUI _Index = 0xFFFFFFFF; _ModulateGlobalColor= vt._ModulateGlobalColor; - + _Localized = vt._Localized; // remove previous lines clearLines(); @@ -229,12 +232,12 @@ namespace NLGUI else if( name == "hardtext" ) { - return _Text.toString(); + return getHardText(); } else if( name == "hardtext_format" ) { - return _HardtextFormat; + return _HardTextFormat; } else return CViewBase::getProperty( name ); @@ -243,6 +246,11 @@ namespace NLGUI std::string CViewText::getTextProperty( const std::string &name ) const { + if( name == "localize" ) + { + return toString(_Localized); + } + else if( name == "color" ) { return toString( _Color ); @@ -396,12 +404,12 @@ namespace NLGUI else if ( name == "sizing_chars" ) { - return _FontSizingChars.toUtf8(); + return _FontSizingChars; } else if ( name == "sizing_fallback" ) { - return _FontSizingFallback.toUtf8(); + return _FontSizingFallback; } else return ""; @@ -417,6 +425,18 @@ namespace NLGUI bool CViewText::setTextProperty( const std::string &name, const std::string &value ) { + if( name == "localize" ) + { + bool b; + if (fromString(value, b)) + { + _Localized = b; + setTextLocalized(_HardText.empty() ? _Text : _HardText); // FIXME: setCase? + _TextLength = 0; + } + return true; + } + else if( name == "color" ) { CRGBA c; @@ -648,35 +668,44 @@ namespace NLGUI return true; } else + if( name == "text" ) + { + setTextLocalized(value); // FIXME: setCase? + _TextLength = 0; + invalidateContent(); + return true; + } + else if( name == "hardtext" ) { - _Text = value; - setCase( _Text, _CaseMode ); + _Localized = true; + setTextLocalized(value); // FIXME: setCase? + _TextLength = 0; invalidateContent(); return true; } else if( name == "hardtext_format" ) { - _HardtextFormat = value; + _HardTextFormat = value; if( _MultiLine ) - setTextFormatTaged( _HardtextFormat ); + setTextFormatTaged( _HardTextFormat ); else - setSingleLineTextFormatTaged( _HardtextFormat ); + setSingleLineTextFormatTaged( _HardTextFormat ); return true; } else if( name == "sizing_chars" ) { - _FontSizingChars.fromUtf8(value); + _FontSizingChars = value; return true; } else if( name == "sizing_fallback" ) { - _FontSizingFallback.fromUtf8(value); + _FontSizingFallback = value; return true; } else @@ -686,6 +715,8 @@ namespace NLGUI bool CViewText::serializeTextOptions( xmlNodePtr node ) const { + xmlSetProp( node, BAD_CAST "localize", BAD_CAST toString( _Localized ).c_str() ); + xmlSetProp( node, BAD_CAST "color", BAD_CAST toString( _Color ).c_str() ); xmlSetProp( node, BAD_CAST "global_color", BAD_CAST toString( _ModulateGlobalColor ).c_str() ); @@ -748,8 +779,8 @@ namespace NLGUI 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 "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_fallback", BAD_CAST _FontSizingFallback.toUtf8().c_str() ); + xmlSetProp( node, BAD_CAST "sizing_chars", BAD_CAST _FontSizingChars.c_str() ); + xmlSetProp( node, BAD_CAST "sizing_fallback", BAD_CAST _FontSizingFallback.c_str() ); return true; } @@ -764,11 +795,9 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "type", BAD_CAST "text" ); serializeTextOptions( node ); - - std::string hs = _Text.toString(); - xmlSetProp( node, BAD_CAST "hardtext", BAD_CAST hs.c_str() ); - xmlSetProp( node, BAD_CAST "hardtext_format", BAD_CAST _HardtextFormat.c_str() ); + xmlSetProp( node, BAD_CAST "text", BAD_CAST (_HardText.empty() ? _Text.c_str() : _HardText.c_str()) ); + xmlSetProp( node, BAD_CAST "hardtext_format", BAD_CAST _HardTextFormat.c_str() ); return node; } @@ -778,6 +807,9 @@ namespace NLGUI { CXMLAutoPtr prop; + prop = xmlGetProp (cur, (xmlChar*)"localize"); + if (prop) _Localized = convertBool((const char*)prop); + prop= (char*) xmlGetProp( cur, (xmlChar*)"color" ); _Color = CRGBA(255,255,255,255); if (prop) @@ -937,16 +969,18 @@ namespace NLGUI } // "_Ä" lowest/highest chars (underscore, A+diaeresis) - _FontSizingChars.fromUtf8("_\xc3\x84"); prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_chars" ); if (prop) - _FontSizingChars.fromUtf8((const char*)prop); + _FontSizingChars = (const char*)prop; + else + _FontSizingChars = "_\xC3\x84q"; // fallback if SizingChars are not supported by font - _FontSizingFallback.fromUtf8("|"); prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_fallback" ); if (prop) - _FontSizingFallback.fromUtf8((const char*)prop); + _FontSizingFallback = (const char *)prop; + else + _FontSizingFallback = "|XO"; computeFontSize (); } @@ -962,7 +996,6 @@ namespace NLGUI bool CViewText::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) { - // const ucstring* tmp; CXMLAutoPtr prop; //try to get props that can be inherited from groups //if a property is not defined, try to find it in the parent group. @@ -982,23 +1015,22 @@ namespace NLGUI if (prop) { const char *propPtr = prop; - _Text = ucstring(propPtr); - - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - _Text = CI18N::get (propPtr); - setCase (_Text, _CaseMode); + _Localized = true; + setTextLocalized(propPtr); + setCase(_Text, _CaseMode); + _TextLength = 0; } prop = (char*) xmlGetProp( cur, (xmlChar*)"hardtext_format" ); if (prop) { const char *propPtr = prop; - _HardtextFormat = propPtr; + _HardTextFormat = propPtr; if (_MultiLine) { - if (strlen(propPtr) > 2 && propPtr[0] == 'u' && propPtr[1] == ':') - setTextFormatTaged(ucstring::makeFromUtf8(std::string(propPtr).substr(2))); + if (NLMISC::startsWith(propPtr, "u:")) + setTextFormatTaged(std::string(propPtr).substr(2)); else setTextFormatTaged(CI18N::get(propPtr)); } @@ -1188,7 +1220,7 @@ namespace NLGUI CWord &currWord = currLine.getWord(k); charIndex += currWord.NumSpaces; sint cStart= max(charIndex, (sint)_TextSelectionStart); - sint cEnd= min(charIndex+(sint)currWord.Text.length(), (sint)_TextSelectionEnd); + sint cEnd= min(charIndex+(sint)currWord.Info.StringLength, (sint)_TextSelectionEnd); // range must be valid if(cStart easy cache test - if (_FormatTags.empty() && _CaseMode==CaseNormal) + setText(text.toUtf8()); + } + + // *************************************************************************** + void CViewText::setTextLocalized(const std::string &text, bool localized) + { + if (localized != _Localized) { - if (text != _Text) - { - _Text = text; - // no need to call "setCase (_Text, _CaseMode);" since CaseNormal: - invalidateContent (); - } + _Localized = localized; + + // Always recompute if localization and text changed + setTextLocalized(text); + setCase(_Text, _CaseMode); + _TextLength = 0; + invalidateContent(); } else { - // if the view text had some format before, no choice, must recompute all - if(!_FormatTags.empty()) - { - _Text = text; - setCase (_Text, _CaseMode); - invalidateContent (); - } - // else test if after the case change the cache succeed - else + setText(text); + } + } + + // *************************************************************************** + void CViewText::setLocalized(bool localized) + { + if (localized != _Localized) + { + const std::string &text = _HardText.empty() ? _Text : _HardText; + _Localized = localized; + if (!text.empty() && NLMISC::startsWith(text, "ui")) { - // compute the temp cased text - ucstring tempText= text; - setCase(tempText, _CaseMode); - if(tempText!=_Text) - { - _Text = tempText; - invalidateContent (); - } + setTextLocalized(text); + setCase(_Text, _CaseMode); + _TextLength = 0; + invalidateContent(); } } - // clear format tags if any - _FormatTags.clear(); + nlassert(_Text.empty() || ((_Localized && (NLMISC::startsWith(getText(), "ui"))) == (_HardText.empty() == _Text.empty()))); + } + + // *************************************************************************** + void CViewText::setTextLocalized(const std::string &text) + { + if (_Localized && NLMISC::startsWith(text, "ui")) + { + _HardText = text; + _Text = CI18N::get(text); + } + else + { + _Text = text; + _HardText.clear(); + } } + // *************************************************************************** + void CViewText::setText(const std::string &text) + { + // common case: no special format, no case mode => easy cache test + if (_FormatTags.empty() && _CaseMode == CaseNormal) + { + if (_HardText.empty() ? text != _Text : text != _HardText) + { + setTextLocalized(text); + _TextLength = 0; + // no need to call "setCase (_Text, _CaseMode);" since CaseNormal: + invalidateContent(); + } + } + else + { + // if the view text had some format before, no choice, must recompute all + if (!_FormatTags.empty()) + { + setTextLocalized(text); + setCase(_Text, _CaseMode); + _TextLength = 0; + invalidateContent(); + } + // else test if after the case change the cache succeed + else + { + // compute the temp cased text + std::string holdText, holdHardText; + holdText.swap(_Text); + holdHardText.swap(_HardText); + setTextLocalized(text); + setCase(_Text, _CaseMode); + if (holdText != _Text) + { + _TextLength = 0; + invalidateContent(); + } + else + { + holdText.swap(_Text); + } + } + } + + nlassert(_Text.empty() || ((_Localized && (NLMISC::startsWith(text, "ui"))) == (_HardText.empty() == _Text.empty()))); + + // clear format tags if any + _FormatTags.clear(); + } + // *************************************************************************** void CViewText::setFontSizing(const std::string &chars, const std::string &fallback) { - _FontSizingChars.clear(); - _FontSizingChars.fromUtf8(chars); - _FontSizingFallback.clear(); - _FontSizingFallback.fromUtf8(fallback); + _FontSizingChars = chars; + _FontSizingFallback = fallback; } // *************************************************************************** @@ -1618,7 +1718,7 @@ namespace NLGUI } // *************************************************************************** - void CViewText::flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat) + void CViewText::flushWordInLine(std::string &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat) { NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName); // create a new line? @@ -1637,20 +1737,23 @@ namespace NLGUI // *************************************************************************** void CViewText::updateTextContextMultiLine(float nMaxWidth) { - ucchar ucLetter; + // ucchar ucLetter; UTextContext::CStringInfo si; - uint i; + uint i = 0; // word state - ucstring ucCurrentWord; + std::string ucCurrentWord; CFormatInfo wordFormat; // line state float rWidthCurrentLine = 0; bool linePushed= false; // for all the text - uint textSize= (uint)_Text.size(); + // uint textSize= (uint)_Text.size(); uint formatTagIndex= 0; nMaxWidth *= _Scale; - for (i = 0; i < textSize; ++i) + //for (i = 0; i < textSize; ++i) + CUtfStringView sv(_Text); + ::u32string ucStrLetter(1, ' '); + for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++i) { if(isFormatTagChange(i, formatTagIndex)) { @@ -1669,8 +1772,7 @@ namespace NLGUI // Parse the letter { - ucLetter = _Text[i]; - if (ucLetter == ucchar('\n')) + if (*it == '\n') { flushWordInLine(ucCurrentWord, linePushed, wordFormat); // reset line state @@ -1679,8 +1781,7 @@ namespace NLGUI } else { - ucstring ucStrLetter; - ucStrLetter= ucLetter; + ucStrLetter[0] = *it; si = TextContext->getStringInfo (ucStrLetter); if ((rWidthCurrentLine + si.StringWidth) > nMaxWidth) { @@ -1689,12 +1790,13 @@ namespace NLGUI // reset line state, and begin with the cut letter linePushed= false; rWidthCurrentLine = si.StringWidth; - ucCurrentWord = ucLetter; + ucCurrentWord.clear(); + CUtfStringView::append(ucCurrentWord, *it); } else { // Grow the current word - ucCurrentWord += ucLetter; + CUtfStringView::append(ucCurrentWord, *it); rWidthCurrentLine += si.StringWidth; } } @@ -1718,7 +1820,7 @@ namespace NLGUI if (!currLine.empty()) { CFormatInfo lineWordFormat= currLine[0].Format; - ucstring lineWord; + std::string lineWord; for(uint i=0;i currLine; // if spaces are not expanded, all words of a line are inserted here (NB: index and stringInfo not filled) - ucstring wordValue; + std::string wordValue; CFormatInfo wordFormat; uint formatTagIndex= 0; // @@ -1778,7 +1878,7 @@ namespace NLGUI float newLineWidth = 0; breakLine = false; // - if (_Text[currPos] == (ucchar) '\n') + if (_Text[currPos] == '\n') { lineFeed = true; } @@ -1786,7 +1886,7 @@ namespace NLGUI { lineFeed = false; // Skip spaces and count them - spaceEnd = _Text.find_first_not_of(spaceStr, currPos); + spaceEnd = _Text.find_first_not_of(" ", currPos); if (spaceEnd == std::string::npos) { spaceEnd = _Text.length(); @@ -1832,7 +1932,7 @@ namespace NLGUI uint i; for(i= (uint)spaceEnd;i<(uint)_Text.length();i++) { - ucchar c= _Text[i]; + char c= _Text[i]; if(c==' ' || c=='\n') break; // If change of color tag, stop the word, but don't take the new color now. @@ -1902,7 +2002,7 @@ namespace NLGUI { uint maxNumSpaces = std::max(1U, (uint) (nMaxWidth / _SpaceWidth)); CWord spaceWord; // a word with only spaces in it - spaceWord.build (ucstring (""), *TextContext, maxNumSpaces); + spaceWord.build ("", *TextContext, maxNumSpaces); spaceWord.Format= wordFormat; _Lines.push_back(TLineSPtr(new CLine)); _Lines.back()->addWord(spaceWord, _FontWidth); @@ -1919,16 +2019,17 @@ namespace NLGUI else { float px = numSpaces * _SpaceWidth; - uint currChar = 0; - ucstring oneChar(" "); - for(currChar = 0; currChar < wordValue.length(); ++currChar) + ::u32string oneChar(1, ' '); + CUtfStringView wsv(wordValue); + CUtfStringView::iterator wit(wsv.begin()), wend(wsv.end()); + for (; wit != wend; ++wit) { - oneChar = wordValue[currChar]; + oneChar[0] = *wit; si = TextContext->getStringInfo(oneChar); if ((uint) (px + si.StringWidth) > nMaxWidth) break; px += si.StringWidth; } - currChar = std::max((uint) 1, currChar); // must fit at least one character otherwise there's an infinite loop + ptrdiff_t currChar = std::max((ptrdiff_t)1, (ptrdiff_t)wit.ptr() - (ptrdiff_t)wsv.ptr()); // must fit at least one character otherwise there's an infinite loop wordValue = _Text.substr(spaceEnd, currChar); CWord word; word.build(wordValue, *TextContext, numSpaces); @@ -2033,7 +2134,7 @@ namespace NLGUI } // if the text ends with \n, must insert the last line ourself - if (!_Text.empty() && _Text[_Text.length() - 1] == (ucchar) '\n') + if (!_Text.empty() && _Text[_Text.length() - 1] == '\n') { _Lines.push_back(TLineSPtr(new CLine)); } @@ -2146,16 +2247,16 @@ namespace NLGUI { TextContext->erase (_Index); - ucchar ucLetter; + // char ucLetter; UTextContext::CStringInfo si; - ucstring ucCurrentLine; + std::string ucCurrentLine; ucCurrentLine.reserve(_Text.size()); // Append ... to the end of line float dotWidth = 0.f; if (_OverflowText.size() > 0) { - si = TextContext->getStringInfo (ucstring(_OverflowText)); + si = TextContext->getStringInfo(_OverflowText); dotWidth = si.StringWidth; } @@ -2165,11 +2266,11 @@ namespace NLGUI // for all the text if (_ClampRight) { - for (uint i = 0; i < _Text.size(); ++i) + CUtfStringView sv(_Text); + ::u32string ucStrLetter = ::u32string(1, (u32char)' '); + for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) { - ucLetter= _Text[i]; - ucstring ucStrLetter; - ucStrLetter= ucLetter; + ucStrLetter[0] = *it; si = TextContext->getStringInfo (ucStrLetter); if ((rWidthCurrentLine + si.StringWidth + dotWidth) > fLineMaxW) { @@ -2178,7 +2279,7 @@ namespace NLGUI else { // Grow the current line - ucCurrentLine += ucLetter; + CUtfStringView::append(ucCurrentLine, *it); rWidthCurrentLine += si.StringWidth; } } @@ -2191,11 +2292,12 @@ namespace NLGUI } else { - for (sint i = (sint)_Text.size() - 1; i >= 0; --i) + // FIXME: Optimize reverse UTF iteration + ::u32string uctext = CUtfStringView(_Text).toUtf32(); + ::u32string ucStrLetter = ::u32string(1, (u32char)' '); + for (sint i = (sint)uctext.size() - 1; i >= 0; --i) { - ucLetter= _Text[i]; - ucstring ucStrLetter; - ucStrLetter= ucLetter; + ucStrLetter[0] = uctext[i]; si = TextContext->getStringInfo (ucStrLetter); if ((rWidthCurrentLine + si.StringWidth + dotWidth) > fLineMaxW) { @@ -2204,7 +2306,9 @@ namespace NLGUI else { // Grow the current line - ucCurrentLine = ucLetter + ucCurrentLine; + std::string tmp; + CUtfStringView::append(tmp, uctext[i]); + ucCurrentLine = tmp + ucCurrentLine; rWidthCurrentLine += si.StringWidth; } } @@ -2303,7 +2407,8 @@ namespace NLGUI } charIndex = newCharIndex; } - return (sint)_Lines.size() - 1; + // return (sint)_Lines.size() - 1; + return -1; } else { @@ -2322,7 +2427,7 @@ namespace NLGUI charIndex += currLine.getNumChars() + currLine.getEndSpaces() + (currLine.getLF() ? 1 : 0); } // 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 (getLineFromIndex(charIndex) == (sint) line) @@ -2347,16 +2452,33 @@ namespace NLGUI endOfPreviousLine = !_Lines[line]->getLF(); } + // *************************************************************************** + void CViewText::setHardTextAsUtf16(const ucstring &ht) + { + setHardText(ht.toUtf8()); + } + // *************************************************************************** void CViewText::setHardText (const std::string &ht) { - // ucstring Text = ucstring(ht); - ucstring Text; - if ((ht.size()>2) && (ht[0] == 'u') && (ht[1] == 'i')) - Text = CI18N::get (ht); - else - Text.fromUtf8(ht); - setText(Text); + if (!_Localized) + { + setText(std::string()); + _Localized = true; + } + setText(ht); + } + + // *************************************************************************** + ucstring CViewText::getTextAsUtf16() const + { + return CUtfStringView(getText()).toUtf16(); + } + + // *************************************************************************** + ucstring CViewText::getHardTextAsUtf16() const + { + return CUtfStringView(getHardText()).toUtf16(); } // *************************************************************************** @@ -2386,7 +2508,9 @@ namespace NLGUI // *************************************************************************** void CViewText::getCharacterPositionFromIndex(sint index, bool cursorAtPreviousLineEnd, float &x, float &y, float &height) const { - NLMISC::clamp(index, 0, (sint) _Text.length()); + if (!_TextLength && _Text.size()) + _TextLength = CUtfStringView(_Text).count(); + NLMISC::clamp(index, 0, (sint)_TextLength); NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); @@ -2404,7 +2528,7 @@ namespace NLGUI uint charIndex = 0; // special case for end of text - if (index == (sint) _Text.length()) + if (index >= (sint)_TextLength) { fy = dy; if (_Lines.empty()) @@ -2459,16 +2583,15 @@ namespace NLGUI for(uint k = 0; k < currLine.getNumWords(); ++k) { CWord &currWord = currLine.getWord(k); - if ((sint) (charIndex + currWord.NumSpaces + currWord.Text.length()) >= index) + if ((sint) (charIndex + currWord.NumSpaces + currWord.Info.StringLength) >= index) { // character is in currWord or the in spaces preceding it // check if the character is in the word if ((uint) (index - charIndex) > currWord.NumSpaces) { // get the x position - ucstring subStr = currWord.Text.substr(0, index - charIndex - currWord.NumSpaces); // compute the size - UTextContext::CStringInfo si = TextContext->getStringInfo(subStr); + UTextContext::CStringInfo si = TextContext->getStringInfo(currWord.Text, (ptrdiff_t)index - charIndex - currWord.NumSpaces); fx = px + si.StringWidth + currWord.NumSpaces * currLine.getSpaceWidth(); x = fx / _Scale; @@ -2485,7 +2608,7 @@ namespace NLGUI return; } } - charIndex += (uint)currWord.Text.length() + currWord.NumSpaces; + charIndex += (uint)currWord.Info.StringLength + currWord.NumSpaces; px += currWord.NumSpaces * currLine.getSpaceWidth() + currWord.Info.StringWidth; } } @@ -2496,9 +2619,8 @@ namespace NLGUI else { // get the x position - ucstring subStr = _Text.substr(0, index); // compute the size - UTextContext::CStringInfo si = TextContext->getStringInfo(subStr); + UTextContext::CStringInfo si = TextContext->getStringInfo(_Text, index); y = 0; x = (sint) ceilf(si.StringWidth / _Scale); } @@ -2506,17 +2628,18 @@ namespace NLGUI // *************************************************************************** // Tool fct : From a word and a x coordinate (font scale), give the matching character index - static uint getCharacterIndex(const ucstring &textValue, float x, NL3D::UTextContext &textContext) + static uint getCharacterIndex(const std::string &textValue, float x, NL3D::UTextContext &textContext) { float px = 0.f; UTextContext::CStringInfo si; - ucstring singleChar(" "); - uint i; - for (i = 0; i < textValue.length(); ++i) + ::u32string singleChar(1, ' '); + uint i = 0; + NLMISC::CUtfStringView sv(textValue); + for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++i) { // get character width - singleChar[0] = textValue[i]; + singleChar[0] = *it; si = textContext.getStringInfo(singleChar); px += si.StringWidth; // the character is at the i - 1 position @@ -2536,6 +2659,9 @@ namespace NLGUI { NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName); + if (!_TextLength && _Text.size()) + _TextLength = CUtfStringView(_Text).count(); + x *= _Scale; y = roundf(y * _Scale); @@ -2556,7 +2682,7 @@ namespace NLGUI float py = 0.f; if (py > y) { - index = (uint)_Text.length(); + index = (uint)_TextLength; cursorAtPreviousLineEnd = false; return; } @@ -2623,7 +2749,7 @@ namespace NLGUI } } px = newPx; - charPos += (uint)currWord.Text.length() + currWord.NumSpaces; + charPos += (uint)currWord.Info.StringLength + currWord.NumSpaces; } index = charPos; return; @@ -2633,7 +2759,7 @@ namespace NLGUI cursorAtPreviousLineEnd = false; if (y < 0) { - index = (uint)_Text.length(); + index = (uint)_TextLength; return; } if (y > (sint) _FontHeight) @@ -2663,23 +2789,25 @@ namespace NLGUI } // *************************************************************************** - void CViewText::setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd) + void CViewText::setStringSelectionSkipingSpace(uint stringId, const std::string &text, sint charStart, sint charEnd) { sint quadStart= charStart; sint quadSize= charEnd-charStart; sint j; - for(j=0;jsetStringSelection(stringId, quadStart, quadSize); + CViewRenderer::getTextContext(_FontName)->setStringSelection(stringId, quadStart, quadSize); // FIXME: This assumes spaces are the only empty glyphs! } // *************************************************************************** @@ -2742,7 +2870,7 @@ namespace NLGUI } // *************************************************************************** - void CViewText::CLine::addWord(const ucstring &text, uint numSpaces, const CFormatInfo &wordFormat, float fontWidth, NL3D::UTextContext &textContext) + void CViewText::CLine::addWord(const std::string &text, uint numSpaces, const CFormatInfo &wordFormat, float fontWidth, NL3D::UTextContext &textContext) { CWord word; word.build(text, textContext, numSpaces); @@ -2754,7 +2882,7 @@ namespace NLGUI void CViewText::CLine::addWord(const CWord &word, float fontWidth) { _Words.push_back(word); - _NumChars += word.NumSpaces + uint(word.Text.length()); + _NumChars += word.NumSpaces + uint(word.Info.StringLength); _NumSpaces += word.NumSpaces; if (fabsf(word.Info.StringLine) > fabsf(_StringLine)) { @@ -2789,12 +2917,13 @@ namespace NLGUI } // *************************************************************************** - void CViewText::CWord::build(const ucstring &text, NL3D::UTextContext &textContext, uint numSpaces) + void CViewText::CWord::build(const std::string &text, NL3D::UTextContext &textContext, uint numSpaces) { Text = text; NumSpaces = numSpaces; Index = textContext.textPush(text); Info = textContext.getStringInfo(Index); + nlassert(Info.StringLength == CUtfStringView(text).count()); } // *************************************************************************** @@ -2811,8 +2940,8 @@ namespace NLGUI // *************************************************************************** sint32 CViewText::getMaxUsedW() const { - static const ucstring spaceStr(" \t"); - static const ucstring lineFeedStr("\n"); + static const char *spaceStr(" \t"); + static const char *lineFeedStr("\n"); float maxWidth = 0; NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName); @@ -2829,13 +2958,13 @@ namespace NLGUI // Get the end of the line float lineWidth = 0; TCharPos lineEnd; - lineEnd = _Text.find_first_of(lineFeedStr, linePos); + lineEnd = _Text.find_first_of("\n", linePos); if (lineEnd == std::string::npos) { lineEnd = _Text.length(); } - ucstring lineValue; + std::string lineValue; lineValue = _Text.substr(linePos, lineEnd - linePos); TCharPos currPos = 0; @@ -2860,7 +2989,7 @@ namespace NLGUI wordEnd = lineValue.length(); } - ucstring wordValue; + std::string wordValue; wordValue = lineValue.substr(spaceEnd, wordEnd - spaceEnd); // compute width of word @@ -2886,7 +3015,7 @@ namespace NLGUI // *************************************************************************** sint32 CViewText::getMinUsedW() const { - static const ucstring spaceOrLineFeedStr(" \n\t"); + static const char *spaceOrLineFeedStr(" \n\t"); float maxWidth = 0.0f; // Not multi line ? Same size than min @@ -2915,7 +3044,7 @@ namespace NLGUI while (currPos < _Text.length()) { // Current word - ucstring wordValue; + std::string wordValue; UTextContext::CStringInfo si; TCharPos wordEnd; @@ -2978,6 +3107,44 @@ namespace NLGUI TextContext->setEmbolden (_Embolden); TextContext->setOblique (_Oblique); +#if 1 + + UTextContext::CStringInfo si = TextContext->getStringInfo("XO"); + float xoHeight = si.StringHeight; + + si = TextContext->getStringInfo("XO\xC3\x81\xC3\x83"); + float upHeight = si.StringHeight; + + si = TextContext->getStringInfo("XOgq"); + float downHeight = si.StringHeight; + float legHeight = si.StringLine; + + nlassert(upHeight >= xoHeight); + nlassert(downHeight >= xoHeight); + float diff; + if (downHeight > upHeight) + { + diff = downHeight - xoHeight; + } + else + { + diff = upHeight - xoHeight; + legHeight += upHeight - downHeight; + } + + _FontHeight = xoHeight + diff + diff; + _FontLegHeight = legHeight; + + // Space width + si = TextContext->getStringInfo(" "); + _SpaceWidth = si.StringWidth; + + // Font Width (used for ) + si = TextContext->getStringInfo("O"); + _FontWidth = si.StringWidth; + +#else + // Letter size UTextContext::CStringInfo si = TextContext->getStringInfo(_FontSizingChars); @@ -2992,17 +3159,19 @@ namespace NLGUI _FontLegHeight = si.StringLine; // Space width - si = TextContext->getStringInfo(ucstring(" ")); + si = TextContext->getStringInfo(" "); _SpaceWidth = si.StringWidth; // Font Width (used for ) - si = TextContext->getStringInfo(ucstring("_")); + si = TextContext->getStringInfo("_"); _FontWidth = si.StringWidth; + +#endif } // *************************************************************************** - static inline bool isColorTag(const ucstring &s, uint index, uint textSize) + static inline bool isColorTag(const std::string &s, uint index, uint textSize) { // Format is @{RGBA} if(s[index]=='@') @@ -3026,7 +3195,7 @@ namespace NLGUI // *************************************************************************** // isColorTag must be ok. - static inline CRGBA getColorTag(const ucstring &s, uint &index) + static inline CRGBA getColorTag(const std::string &s, uint &index) { // extract the color string: "FABC" char tmpCol[5]; @@ -3053,7 +3222,7 @@ namespace NLGUI // *************************************************************************** const uint MaxTabDigit= 3; - static inline bool isTabTag(const ucstring &s, uint index, uint textSize) + static inline bool isTabTag(const std::string &s, uint index, uint textSize) { // Format is @{Tvalue}, where value ,1,2,3 digit. if(s[index]=='@') @@ -3079,7 +3248,7 @@ namespace NLGUI // *************************************************************************** // isTabTag must be ok. - static inline sint getTabTag(const ucstring &s, uint &index) + static inline sint getTabTag(const std::string &s, uint &index) { // extract the tab min X value char tmpTab[MaxTabDigit+1]; @@ -3102,7 +3271,7 @@ namespace NLGUI // *************************************************************************** - static inline bool isTooltipTag(const ucstring &s, uint index, uint textSize) + static inline bool isTooltipTag(const std::string &s, uint index, uint textSize) { // Format is @{Huitt*} if(s[index]=='@') @@ -3126,9 +3295,9 @@ namespace NLGUI // *************************************************************************** // isTooltipTag must be ok. - static inline ucstring getTooltipTag(const ucstring &s, uint &index) + static inline std::string getTooltipTag(const std::string &s, uint &index) { - ucstring result; + std::string result; uint i = 3; while (s[index+i] != '}') { @@ -3144,7 +3313,7 @@ namespace NLGUI // *************************************************************************** - void CViewText::buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector &formatTags, std::vector &tooltips) + void CViewText::buildFormatTagText(const std::string &text, std::string &textBuild, std::vector &formatTags, std::vector &tooltips) { formatTags.clear(); tooltips.clear(); @@ -3180,7 +3349,7 @@ namespace NLGUI // get old tag. CViewText::CFormatTag ct= precTag; // get new Tab and skip tag. - ucstring uitt = getTooltipTag(text, i); + string uitt = getTooltipTag(text, i); if (uitt.empty()) { ct.IndexTt= -1; @@ -3217,18 +3386,23 @@ namespace NLGUI } } + // *************************************************************************** + void CViewText::setTextFormatTagedAsUtf16(const ucstring &text) + { + setTextFormatTaged(text.toUtf8()); + } // *************************************************************************** - void CViewText::setTextFormatTaged(const ucstring &text) + void CViewText::setTextFormatTaged(const std::string &text) { if( text.empty() ) return; // to allow cache (avoid infinite recurse in updateCoords() in some case), compute in temp - ucstring tempText; + std::string tempText; // static to avoid reallocation static std::vector tempFormatTags; - static std::vector tempTooltips; + static std::vector tempTooltips; buildFormatTagText(text, tempText, tempFormatTags, tempTooltips); setCase (tempText, _CaseMode); @@ -3254,7 +3428,9 @@ namespace NLGUI _FormatTags= tempFormatTags; // Copy to Text (preserve Memory) contReset(_Text); - _Text= tempText; + _Text = tempText; + _HardText.clear(); + _TextLength = 0; CInterfaceGroup *parent = getParent(); @@ -3275,8 +3451,9 @@ namespace NLGUI pTooltip->setId(_Id+"_tt"+toString(i)); pTooltip->setAvoidResizeParent(avoidResizeParent()); pTooltip->setRenderLayer(getRenderLayer()); - bool isI18N = tempTooltips[i].size() >= 2 && tempTooltips[i][0] == 'u' && tempTooltips[i][1] == 'i'; - pTooltip->setDefaultContextHelp(isI18N ? CI18N::get(tempTooltips[i].toString()) : tempTooltips[i]); + std::string tempTooltipStr = tempTooltips[i]; + bool isI18N = NLMISC::startsWith(tempTooltipStr, "ui"); + pTooltip->setDefaultContextHelp(isI18N ? CI18N::get(tempTooltipStr) : tempTooltipStr); pTooltip->setParentPos(this); pTooltip->setParentPosRef(Hotspot_BR); pTooltip->setPosRef(Hotspot_BR); @@ -3304,19 +3481,23 @@ namespace NLGUI // color format is available only if multilined if (!_MultiLine) - nlwarning( toString("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.toString().c_str()).c_str() ); + nlwarning("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.c_str()); } + void CViewText::setSingleLineTextFormatTagedAsUtf16(const ucstring &text) + { + setSingleLineTextFormatTaged(text.toUtf8()); + } - void CViewText::setSingleLineTextFormatTaged(const ucstring &text) + void CViewText::setSingleLineTextFormatTaged(const std::string &text) { if( text.empty() ) return; // to allow cache (avoid infinite recurse in updateCoords() in some case), compute in temp - ucstring tempText; + std::string tempText; static std::vector tempLetterColors; - static std::vector tempTooltips; + static std::vector tempTooltips; // parse text buildFormatTagText(text, tempText, tempLetterColors, tempTooltips); @@ -3331,7 +3512,7 @@ namespace NLGUI while(textIndex= 100); + + f.serial(_Localized); SERIAL_SINT(_FontSize); SERIAL_UINT(_FontWidth); SERIAL_UINT(_FontHeight); @@ -3471,21 +3660,22 @@ namespace NLGUI { if (_MultiLine) { - setTextFormatTaged(text); + setTextFormatTaged(text.toUtf8()); } else { - setSingleLineTextFormatTaged(text); + setSingleLineTextFormatTaged(text.toUtf8()); } } else { - setText(text); + setText(text.toUtf8()); } } else { - f.serial(_Text); + ucstring text = CUtfStringView(_Text).toUtf16(); + f.serial(text); } #undef SERIAL_UINT diff --git a/nel/src/gui/view_text_formated.cpp b/nel/src/gui/view_text_formated.cpp index ac9263936..537773788 100644 --- a/nel/src/gui/view_text_formated.cpp +++ b/nel/src/gui/view_text_formated.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -34,26 +35,26 @@ namespace NLGUI CViewTextFormated::IViewTextFormatter *CViewTextFormated::textFormatter = NULL; - std::string CViewTextFormated::getProperty( const std::string &name ) const - { - if( name == "format" ) + std::string CViewTextFormated::getProperty(const std::string &name) const + { + if (name == "format") { - return getFormatString().toString(); + return getFormatString(); } else - return CViewText::getProperty( name ); - } - - void CViewTextFormated::setProperty( const std::string &name, const std::string &value ) - { - if( name == "format" ) - { - setFormatString( value ); - return; - } - else - CViewText::setProperty( name, value ); - } + return CViewText::getProperty(name); + } + + void CViewTextFormated::setProperty(const std::string &name, const std::string &value) + { + if (name == "format") + { + setFormatString(value); + return; + } + else + CViewText::setProperty(name, value); + } xmlNodePtr CViewTextFormated::serialize( xmlNodePtr parentNode, const char *type ) const { @@ -73,9 +74,9 @@ namespace NLGUI if (!CViewText::parse(cur, parentGroup)) return false; CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); if (prop) - setFormatString(ucstring((const char *) prop)); + setFormatString((const char *)prop); else - setFormatString(ucstring("$t")); + setFormatString("$t"); return true; } @@ -83,8 +84,8 @@ namespace NLGUI void CViewTextFormated::checkCoords() { if (!getActive()) return; - ucstring formatedResult; - formatedResult = formatString(_FormatString, ucstring("")); + std::string formatedResult; + formatedResult = formatString(_FormatString, std::string()); // setText (formatedResult); @@ -92,17 +93,18 @@ namespace NLGUI } // **************************************************************************** - void CViewTextFormated::setFormatString(const ucstring &format) + void CViewTextFormated::setFormatString(const std::string &format) { - _FormatString = format; - if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) - _FormatString = NLMISC::CI18N::get (format.toString()); + if (NLMISC::startsWith(format, "ui")) + _FormatString = NLMISC::CI18N::get(format); + else + _FormatString = format; } // **************************************************************************** - ucstring CViewTextFormated::formatString(const ucstring &inputString, const ucstring ¶mString) + std::string CViewTextFormated::formatString(const std::string &inputString, const std::string ¶mString) { - ucstring formatedResult; + std::string formatedResult; if( textFormatter == NULL ) formatedResult = inputString; diff --git a/nel/src/gui/view_text_id.cpp b/nel/src/gui/view_text_id.cpp index 562ba881a..61d97b523 100644 --- a/nel/src/gui/view_text_id.cpp +++ b/nel/src/gui/view_text_id.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -204,7 +205,7 @@ namespace NLGUI if (!_Initialized) { // String result - ucstring result; + string result; if( textProvider != NULL ) { @@ -218,8 +219,8 @@ namespace NLGUI // Remove all {break} for(;;) { - ucstring::size_type index = result.find (ucstring("{break}")); - if (index == ucstring::npos) break; + string::size_type index = result.find("{break}"); + if (index == string::npos) break; result = result.substr (0, index) + result.substr(index+7, result.size()); } @@ -228,14 +229,18 @@ namespace NLGUI while(NLMISC::strFindReplace(result, "{ros_exit}", "")); // Modify the text? - if(_StringModifier) - _StringModifier->onReceiveTextId(result); + if (_StringModifier) + { + ucstring tmp = ucstring::makeFromUtf8(result); + _StringModifier->onReceiveTextId(tmp); // FIXME: UTF-8 + result = tmp.toUtf8(); + } // Set the Text if(_IsTextFormatTaged) setTextFormatTaged(result); else - setText (result); + setText(result); } CViewText::checkCoords(); } diff --git a/nel/src/gui/view_text_id_formated.cpp b/nel/src/gui/view_text_id_formated.cpp index 28998cee0..b6bd9dc22 100644 --- a/nel/src/gui/view_text_id_formated.cpp +++ b/nel/src/gui/view_text_id_formated.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -33,32 +34,31 @@ NLMISC_REGISTER_OBJECT(CViewBase, CViewTextIDFormated, std::string, "text_id_for namespace NLGUI { - std::string CViewTextIDFormated::getProperty( const std::string &name ) const + std::string CViewTextIDFormated::getProperty(const std::string &name) const { - if( name == "format" ) + if (name == "format") { - return getFormatString().toString(); + return getFormatString(); } else - return CViewTextID::getProperty( name ); + return CViewTextID::getProperty(name); } - - void CViewTextIDFormated::setProperty( const std::string &name, const std::string &value ) + void CViewTextIDFormated::setProperty(const std::string &name, const std::string &value) { - if( name == "format" ) + if (name == "format") { - setFormatString( value ); + setFormatString(value); return; } else - CViewTextID::setProperty( name, value ); + CViewTextID::setProperty(name, value); } - xmlNodePtr CViewTextIDFormated::serialize( xmlNodePtr parentNode, const char *type ) const + xmlNodePtr CViewTextIDFormated::serialize(xmlNodePtr parentNode, const char *type) const { - xmlNodePtr node = CViewTextID::serialize( parentNode, type ); - if( node == NULL ) + xmlNodePtr node = CViewTextID::serialize(parentNode, type); + if (node == NULL) return NULL; xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_id_formated" ); @@ -73,9 +73,9 @@ namespace NLGUI if (!CViewTextID::parse(cur, parentGroup)) return false; CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); if (prop) - setFormatString(ucstring((const char *) prop)); + setFormatString((const char *)prop); else - setFormatString(ucstring("$t")); + setFormatString("$t"); return true; } @@ -90,15 +90,15 @@ namespace NLGUI if (!_Initialized) { - ucstring result, formatedResult; + std::string result, formatedResult; bool bValid; if( CViewTextID::getTextProvider() == NULL ) { if(!_DBPath.empty()) - result = ucstring(_DBPath); + result = _DBPath; else - result = ucstring("Text ID = " + NLMISC::toString(_TextId)); + result = "Text ID = " + NLMISC::toString(_TextId); bValid = true; } else @@ -118,12 +118,13 @@ namespace NLGUI } // **************************************************************************** - void CViewTextIDFormated::setFormatString(const ucstring &format) + void CViewTextIDFormated::setFormatString(const std::string &format) { _Initialized = false; - _FormatString = format; - if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) - _FormatString = NLMISC::CI18N::get (format.toString()); + if (NLMISC::startsWith(format, "ui")) + _FormatString = NLMISC::CI18N::get(format); + else + _FormatString = format; } } diff --git a/nel/src/gui/widget_manager.cpp b/nel/src/gui/widget_manager.cpp index a1da03b2e..df4f5d706 100644 --- a/nel/src/gui/widget_manager.cpp +++ b/nel/src/gui/widget_manager.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) // Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -1195,6 +1195,7 @@ namespace NLGUI sint32 backupX = groupOver->getX(); // Copy all aspects to the view + vtDst->setLocalized (vtSrc->isLocalized()); vtDst->setText (vtSrc->getText()); vtDst->setFontSize (vtSrc->getFontSize()); vtDst->setColor (vtSrc->getColor()); diff --git a/nel/src/ligo/primitive.cpp b/nel/src/ligo/primitive.cpp index d43d4cde1..205464c67 100644 --- a/nel/src/ligo/primitive.cpp +++ b/nel/src/ligo/primitive.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/logic/logic_state_machine.cpp b/nel/src/logic/logic_state_machine.cpp index ff99255d2..0492671f6 100644 --- a/nel/src/logic/logic_state_machine.cpp +++ b/nel/src/logic/logic_state_machine.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -50,7 +53,7 @@ void xmlCheckNodeName (xmlNodePtr &node, const char *nodeName) // Make an error message char tmp[512]; smprintf (tmp, 512, "LogicStateMachine STATE_MACHINE XML Syntax error in block line %d, node %s should be %s", - node ? (int)node->line:-1, node->name, nodeName); + node ? (int)node->line:-1, node ? (const char *)node->name : "NULL", nodeName); nlinfo (tmp); nlstop; diff --git a/nel/src/misc/big_file.cpp b/nel/src/misc/big_file.cpp index 9713610cb..533d52818 100644 --- a/nel/src/misc/big_file.cpp +++ b/nel/src/misc/big_file.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -75,7 +78,7 @@ CBigFile::CHandleFile &CBigFile::CThreadFileArray::get(uint32 index) // if the vector is not allocated, allocate it (empty entries filled with NULL => not opened FILE* in this thread) if(index>=ptr->size()) { - ptr->resize(index+1); + ptr->resize((ptrdiff_t)index + 1); } return (*ptr)[index]; @@ -278,11 +281,13 @@ bool CBigFile::BNP::readHeader(FILE *file) } char sFileName[256]; - if (fread (sFileName, 1, nStringSize, file) != nStringSize) + if (nStringSize) { - return false; + if (fread(sFileName, 1, nStringSize, file) != nStringSize) + { + return false; + } } - sFileName[nStringSize] = 0; uint32 nFileSize2; diff --git a/nel/src/misc/bitmap.cpp b/nel/src/misc/bitmap.cpp index c21b30fb7..a40d7257d 100644 --- a/nel/src/misc/bitmap.cpp +++ b/nel/src/misc/bitmap.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2016 Jan BOON (Kaetemi) +// Copyright (C) 2016-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -4327,7 +4327,7 @@ void CBitmap::blend(CBitmap &Bm0, CBitmap &Bm1, uint16 factor, bool inputBitmapI else #endif //#ifdef NL_OS_WINDOWS { - uint8 *endPix = dest + (numPix << 2); + uint8 *endPix = dest + ((ptrdiff_t)numPix << 2); // no mmx version uint blendFact = (uint) factor; uint invblendFact = 256 - blendFact; diff --git a/nel/src/misc/cdb_branch.cpp b/nel/src/misc/cdb_branch.cpp index 5f5cea571..f77acc194 100644 --- a/nel/src/misc/cdb_branch.cpp +++ b/nel/src/misc/cdb_branch.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -215,7 +215,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, else { if (!_Nodes.empty()) - for ( _IdBits=1; _Nodes.size() > unsigned(1<<_IdBits) ; _IdBits++ ) {} + for ( _IdBits=1; _Nodes.size() > ((size_t)1 <<_IdBits) ; _IdBits++ ) {} else _IdBits = 0; } diff --git a/nel/src/misc/co_task.cpp b/nel/src/misc/co_task.cpp index 4548fbe86..7446a72d3 100644 --- a/nel/src/misc/co_task.cpp +++ b/nel/src/misc/co_task.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/misc/common.cpp b/nel/src/misc/common.cpp index b9e9a7d85..8d046c97c 100644 --- a/nel/src/misc/common.cpp +++ b/nel/src/misc/common.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -594,6 +594,8 @@ NLMISC_CATEGORISED_COMMAND(nel,stohr, "Convert a second number into an human rea return true; } +#if 0 + std::string toLower(const char *str) { if (!str) return ""; @@ -625,6 +627,8 @@ std::string toLower(const std::string &str) return res; } +#endif + char toLower(const char ch) { if( (ch >= 'A') && (ch <= 'Z') ) @@ -652,6 +656,8 @@ void toLower(char *str) } } +#if 0 + std::string toUpper(const std::string &str) { string res; @@ -666,6 +672,8 @@ std::string toUpper(const std::string &str) return res; } +#endif + void toUpper(char *str) { if (str == 0) @@ -876,7 +884,7 @@ std::string formatThousands(const std::string& s) { sint i, k; 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 if (remaining < 4) return s; diff --git a/nel/src/misc/debug.cpp b/nel/src/misc/debug.cpp index 1f7cf38db..f821ac620 100644 --- a/nel/src/misc/debug.cpp +++ b/nel/src/misc/debug.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // Copyright (C) 2015 Laszlo KIS-ADAM (dfighter) // // This program is free software: you can redistribute it and/or modify @@ -807,6 +807,8 @@ public: DWORD symSize = 10000; PIMAGEHLP_SYMBOL sym = (PIMAGEHLP_SYMBOL) GlobalAlloc (GMEM_FIXED, symSize); + if (!sym) return str; + ::ZeroMemory (sym, symSize); sym->SizeOfStruct = symSize; sym->MaxNameLength = symSize - sizeof(IMAGEHLP_SYMBOL); diff --git a/nel/src/misc/diff_tool.cpp b/nel/src/misc/diff_tool.cpp index 2b2a490bc..2e390f9d9 100644 --- a/nel/src/misc/diff_tool.cpp +++ b/nel/src/misc/diff_tool.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -232,15 +235,15 @@ bool loadStringFile(const std::string filename, vector &stringInfos ucstring prepareStringFile(const vector &strings, bool removeDiffComments, bool noDiffInfo) { - ucstring diff; + string diff; vector::const_iterator first(strings.begin()), last(strings.end()); for (; first != last; ++first) { - ucstring str; + string str; const TStringInfo &si = *first; - string comment = si.Comments.toString(); - vector lines; + string comment = si.Comments.toUtf8(); + vector lines; explode(comment, string("\n"), lines, true); uint i; @@ -274,30 +277,29 @@ ucstring prepareStringFile(const vector &strings, bool removeDiffCo } si.Comments = ucstring(comment); - str = si.Comments; + str = comment; if (!si.Identifier.empty() || !si.Text.empty()) { // add hash value comment if needed // if (si.Comments.find(ucstring("// HASH_VALUE ")) == ucstring::npos) if (!noDiffInfo) { - str += ucstring("// HASH_VALUE ") + CI18N::hashToString(si.HashValue)+ nl; - str += ucstring("// INDEX ") + NLMISC::toString("%u", first-strings.begin())+ nl; + str += "// HASH_VALUE " + CI18N::hashToString(si.HashValue) + "\n"; + str += "// INDEX " + NLMISC::toString("%u", first-strings.begin()) + "\n"; } str += si.Identifier + '\t'; - ucstring text = CI18N::makeMarkedString('[', ']', si.Text);; - ucstring text2; + string text = CI18N::makeMarkedString('[', ']', si.Text).toUtf8(); + string text2; // add new line and tab after each \n tag - ucstring::size_type pos; - const ucstring nlTag("\\n"); - while ((pos = text.find(nlTag)) != ucstring::npos) + string::size_type pos; + while ((pos = text.find("\\n")) != string::npos) { - text2 += text.substr(0, pos+2) + nl + "\t"; + text2 += text.substr(0, pos+2) + "\n\t"; text = text.substr(pos+2); } text2 += text;//.substr(0, pos+2); - str += text2 + nl + nl; + str += text2 + "\n\n"; // str += CI18N::makeMarkedString('[', ']', si.Text) + nl + nl; } @@ -305,7 +307,7 @@ ucstring prepareStringFile(const vector &strings, bool removeDiffCo diff += str; } - return diff; + return ucstring::makeFromUtf8(diff); } diff --git a/nel/src/misc/eid_translator.cpp b/nel/src/misc/eid_translator.cpp index 9978b37e0..d8c7e06ee 100644 --- a/nel/src/misc/eid_translator.cpp +++ b/nel/src/misc/eid_translator.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010-2019 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/src/misc/eval_num_expr.cpp b/nel/src/misc/eval_num_expr.cpp index 52dce523f..8cde36a48 100644 --- a/nel/src/misc/eval_num_expr.cpp +++ b/nel/src/misc/eval_num_expr.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2016 Jan BOON (Kaetemi) +// Copyright (C) 2016-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -773,7 +773,7 @@ CEvalNumExpr::TReturnState CEvalNumExpr::evalExpression (double &finalResult, TT case Exponent: { int exponent; - frexp( arg0, &exponent); + (void)frexp( arg0, &exponent); value = (double)exponent; } break; @@ -1032,13 +1032,13 @@ CEvalNumExpr::TReturnState CEvalNumExpr::evalExpression (double &finalResult, TT v0 -= v1; break; case ULeftShift: - v0 = (double)(((uint)floor (v0 + 0.5))<<((uint)floor (v1 + 0.5))); + v0 = (double)(uint)(((uint)floor (v0 + 0.5))<<((uint)floor (v1 + 0.5))); break; case URightShift: v0 = (double)(((uint)floor (v0 + 0.5))>>((uint)floor (v1 + 0.5))); break; case SLeftShift: - v0 = (double)(((sint)floor (v0 + 0.5))<<((sint)floor (v1 + 0.5))); + v0 = (double)(sint)(((sint)floor (v0 + 0.5))<<((sint)floor (v1 + 0.5))); break; case SRightShift: v0 = (double)(((sint)floor (v0 + 0.5))>>((sint)floor (v1 + 0.5))); diff --git a/nel/src/misc/event_emitter_multi.cpp b/nel/src/misc/event_emitter_multi.cpp index 45559ebc4..245d935a7 100644 --- a/nel/src/misc/event_emitter_multi.cpp +++ b/nel/src/misc/event_emitter_multi.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -98,13 +101,13 @@ const IEventEmitter *CEventEmitterMulti::getEmitter(uint index) const return _Emitters[index].first; } -bool CEventEmitterMulti::copyTextToClipboard(const ucstring &text) +bool CEventEmitterMulti::copyTextToClipboard(const std::string &text) { // Naush: wrapped to old API to avoid duplicate code return CSystemUtils::copyTextToClipboard(text); } -bool CEventEmitterMulti::pasteTextFromClipboard(ucstring &text) +bool CEventEmitterMulti::pasteTextFromClipboard(std::string &text) { // Naush: wrapped to old API to avoid duplicate code return CSystemUtils::pasteTextFromClipboard(text); diff --git a/nel/src/misc/file.cpp b/nel/src/misc/file.cpp index 24222bdfe..138e85c88 100644 --- a/nel/src/misc/file.cpp +++ b/nel/src/misc/file.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014-2016 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/misc/i18n.cpp b/nel/src/misc/i18n.cpp index f692fd849..74558db17 100644 --- a/nel/src/misc/i18n.cpp +++ b/nel/src/misc/i18n.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Laszlo KIS-ADAM (dfighter) // Copyright (C) 2014 Matthew LAGOE (Botanic) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -38,15 +39,18 @@ using namespace std; namespace NLMISC { -CI18N::StrMapContainer CI18N::_StrMap; -CI18N::StrMapContainer CI18N::_StrMapFallback; -bool CI18N::_StrMapLoaded = false; -const ucstring CI18N::_NotTranslatedValue(""); +CI18N::StrMapContainer CI18N::_StrMap; +CI18N::StrMapContainer CI18N::_StrMapFallback; +CI18N::StrMapContainer16 CI18N::_StrMap16; +CI18N::StrMapContainer16 CI18N::_StrMapFallback16; +bool CI18N::_StrMapLoaded = false; +const ucstring CI18N::_NotTranslatedValue16(""); +const std::string CI18N::_NotTranslatedValue(""); bool CI18N::_LanguagesNamesLoaded = false; string CI18N::_SelectedLanguageCode; CI18N::ILoadProxy *CI18N::_LoadProxy = 0; vector CI18N::_LanguageCodes; -vector CI18N::_LanguageNames; +vector CI18N::_LanguageNames; std::string CI18N::_SystemLanguageCode; bool CI18N::noResolution = false; @@ -65,17 +69,17 @@ void CI18N::initLanguages() _LanguageCodes.push_back("ru"); _LanguageCodes.push_back("es"); - _LanguageNames.push_back(ucstring("English")); - _LanguageNames.push_back(ucstring("French")); - _LanguageNames.push_back(ucstring("German")); - _LanguageNames.push_back(ucstring("Russian")); - _LanguageNames.push_back(ucstring("Spanish")); + _LanguageNames.push_back("English"); + _LanguageNames.push_back("French"); + _LanguageNames.push_back("German"); + _LanguageNames.push_back("Russian"); + _LanguageNames.push_back("Spanish"); _LanguagesNamesLoaded = true; } } -const std::vector &CI18N::getLanguageNames() +const std::vector &CI18N::getLanguageNames() { initLanguages(); @@ -91,19 +95,27 @@ const std::vector &CI18N::getLanguageCodes() void CI18N::load (const string &languageCode, const string &fallbackLanguageCode) { - if (_StrMapLoaded) _StrMap.clear (); - else _StrMapLoaded = true; + if (_StrMapLoaded) + { + _StrMap.clear(); + _StrMap16.clear(); + } + else + { + _StrMapLoaded = true; + } _SelectedLanguageCode = languageCode; - loadFileIntoMap(languageCode + ".uxt", _StrMap); + loadFileIntoMap(languageCode + ".uxt", _StrMap, _StrMap16); _StrMapFallback.clear(); + _StrMapFallback16.clear(); 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; // read in the text @@ -138,11 +150,12 @@ bool CI18N::loadFileIntoMap(const string &fileName, StrMapContainer &destMap) // ok, a line read. pair::iterator, bool> ret; - ret = destMap.insert(make_pair(label, ucs)); + ret = destMap16.insert(make_pair(label, ucs)); if (!ret.second) { 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); } @@ -152,13 +165,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()); } + nlassert(destMap.size() == destMap16.size()); return true; } void CI18N::loadFromFilename(const string &filename, bool reload) { StrMapContainer destMap; - if (!loadFileIntoMap(filename, destMap)) + StrMapContainer16 destMap16; + if (!loadFileIntoMap(filename, destMap, destMap16)) { return; } @@ -167,16 +182,52 @@ void CI18N::loadFromFilename(const string &filename, bool 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()); } } + _StrMap16[it->first] = ucstring::makeFromUtf8(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 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(""; + return badString; +} + +const ucstring &CI18N::getAsUtf16 (const string &label) { if( noResolution ) { @@ -187,13 +238,13 @@ const ucstring &CI18N::get (const string &label) if (label.empty()) { - static ucstring emptyString; + static const ucstring 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; static CHashSet missingStrings; @@ -204,8 +255,8 @@ const ucstring &CI18N::get (const string &label) } // use the fall back language if it exists - it = _StrMapFallback.find(label); - if (it != _StrMapFallback.end()) + it = _StrMapFallback16.find(label); + if (it != _StrMapFallback16.end()) return it->second; static ucstring badString; @@ -229,7 +280,7 @@ bool CI18N::hasTranslation(const string &label) return false; } -ucstring CI18N::getCurrentLanguageName () +std::string CI18N::getCurrentLanguageName () { return get("LanguageName"); } @@ -339,21 +390,25 @@ std::string CI18N::getSystemLanguageCode () typedef int (WINAPI* GetUserDefaultLocaleNamePtr)(LPWSTR lpLocaleName, int cchLocaleName); // get pointer on GetUserDefaultLocaleName, kernel32.dll is always in memory so no need to call LoadLibrary - GetUserDefaultLocaleNamePtr nlGetUserDefaultLocaleName = (GetUserDefaultLocaleNamePtr)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetUserDefaultLocaleName"); - - // only use it if found - if (nlGetUserDefaultLocaleName) + HMODULE hKernel32 = GetModuleHandleA("kernel32.dll"); + if (hKernel32) { - // get user locale - wchar_t buffer[LOCALE_NAME_MAX_LENGTH]; - sint res = nlGetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH); + GetUserDefaultLocaleNamePtr nlGetUserDefaultLocaleName = (GetUserDefaultLocaleNamePtr)GetProcAddress(hKernel32, "GetUserDefaultLocaleName"); - // convert wide string to std::string - std::string lang = wideToUtf8(buffer); + // only use it if found + if (nlGetUserDefaultLocaleName) + { + // get user locale + wchar_t buffer[LOCALE_NAME_MAX_LENGTH]; + sint res = nlGetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH); - // only keep 2 first characters - if (lang.size() > 1) - _SystemLanguageCode = lang.substr(0, 2); + // convert wide string to std::string + std::string lang = wideToUtf8(buffer); + + // only keep 2 first characters + if (lang.size() > 1) + _SystemLanguageCode = lang.substr(0, 2); + } } } #endif @@ -375,7 +430,7 @@ std::string CI18N::getSystemLanguageCode () // locales names are different under Windows, for example: French_France.1252 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 if (lang.compare(0, name.length(), name) == 0) @@ -435,7 +490,7 @@ bool CI18N::setSystemLanguageCode (const std::string &languageCode) // check if language name is supported 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) { diff --git a/nel/src/misc/i_xml.cpp b/nel/src/misc/i_xml.cpp index 24a2b7910..b38601f06 100644 --- a/nel/src/misc/i_xml.cpp +++ b/nel/src/misc/i_xml.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/src/misc/inter_window_msg_queue.cpp b/nel/src/misc/inter_window_msg_queue.cpp index f27fa55da..6e8478801 100644 --- a/nel/src/misc/inter_window_msg_queue.cpp +++ b/nel/src/misc/inter_window_msg_queue.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -459,6 +462,11 @@ namespace NLMISC { return handleWMCopyData(hwnd, (COPYDATASTRUCT *) lParam); } +#ifdef WM_UNICHAR + // https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-unichar + if (uMsg == WM_UNICHAR) + return (wParam == UNICODE_NOCHAR); +#endif return DefWindowProc(hwnd, uMsg, wParam, lParam); } diff --git a/nel/src/misc/mem_displayer.cpp b/nel/src/misc/mem_displayer.cpp index 04e5c71dd..cefa99589 100644 --- a/nel/src/misc/mem_displayer.cpp +++ b/nel/src/misc/mem_displayer.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014-2016 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -58,6 +58,8 @@ static string getFuncInfo (DWORD_TYPE funcAddr, DWORD_TYPE stackAddr) DWORD symSize = 10000; PIMAGEHLP_SYMBOL sym = (PIMAGEHLP_SYMBOL) GlobalAlloc (GMEM_FIXED, symSize); + if (!sym) return str; + ::ZeroMemory (sym, symSize); sym->SizeOfStruct = symSize; sym->MaxNameLength = symSize - sizeof(IMAGEHLP_SYMBOL); diff --git a/nel/src/misc/object_arena_allocator.cpp b/nel/src/misc/object_arena_allocator.cpp index bd00affc9..b8aea9ada 100644 --- a/nel/src/misc/object_arena_allocator.cpp +++ b/nel/src/misc/object_arena_allocator.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -60,22 +60,23 @@ CObjectArenaAllocator::~CObjectArenaAllocator() void *CObjectArenaAllocator::alloc(uint size) { #ifdef NL_DEBUG - if (_WantBreakOnAlloc) + if (_WantBreakOnAlloc) + { + if (_AllocID == _BreakAllocID) { - if (_AllocID == _BreakAllocID) - { - nlassert(0); - } + nlassert(0); } + } #endif if (size >= _MaxAllocSize) { // use standard allocator nlctassert(NL_DEFAULT_MEMORY_ALIGNMENT >= sizeof(uint)); - uint8 *block = (uint8 *)aligned_malloc(NL_DEFAULT_MEMORY_ALIGNMENT + size, NL_DEFAULT_MEMORY_ALIGNMENT); //new uint8[size + sizeof(uint)]; // an additionnal uint is needed to store size of block - if (!block) return NULL; + uint8 *block = (uint8 *)aligned_malloc(NL_DEFAULT_MEMORY_ALIGNMENT + (ptrdiff_t)size, NL_DEFAULT_MEMORY_ALIGNMENT); //new uint8[size + sizeof(uint)]; // an additionnal uint is needed to store size of block + if (!block) throw std::bad_alloc(); #ifdef NL_DEBUG - _MemBlockToAllocID[block] = _AllocID; + _MemBlockToAllocID[block] = _AllocID; + ++_AllocID; #endif *(uint *) block = size; return block + NL_DEFAULT_MEMORY_ALIGNMENT; @@ -87,16 +88,14 @@ void *CObjectArenaAllocator::alloc(uint size) _ObjectSizeToAllocator[entry] = new CFixedSizeAllocator(entry * _Granularity + NL_DEFAULT_MEMORY_ALIGNMENT, _MaxAllocSize / size); // an additionnal uint is needed to store size of block } void *block = _ObjectSizeToAllocator[entry]->alloc(); + if (!block) throw std::bad_alloc(); nlassert(((uintptr_t)block % NL_DEFAULT_MEMORY_ALIGNMENT) == 0); #ifdef NL_DEBUG - if (block) - { - _MemBlockToAllocID[block] = _AllocID; - } - ++_AllocID; + _MemBlockToAllocID[block] = _AllocID; + ++_AllocID; #endif - *(uint *) block = size; - return (void *) ((uint8 *) block + NL_DEFAULT_MEMORY_ALIGNMENT); + *(uint *)block = size; + return (void *)((uint8 *)block + NL_DEFAULT_MEMORY_ALIGNMENT); } // ***************************************************************************************************************** diff --git a/nel/src/misc/path.cpp b/nel/src/misc/path.cpp index cdc71c1eb..bd8190db0 100644 --- a/nel/src/misc/path.cpp +++ b/nel/src/misc/path.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2012-2019 Jan BOON (Kaetemi) +// Copyright (C) 2012-2020 Jan BOON (Kaetemi) // Copyright (C) 2014-2015 Laszlo KIS-ADAM (dfighter) // // This program is free software: you can redistribute it and/or modify @@ -1341,10 +1341,13 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse, fclose(Handle); return; } - if (fread (FileName, 1, nStringSize, Handle) != nStringSize) + if (nStringSize) { - fclose(Handle); - return; + if (fread(FileName, 1, nStringSize, Handle) != nStringSize) + { + fclose(Handle); + return; + } } FileName[nStringSize] = 0; uint32 nFileSize2; @@ -2787,16 +2790,13 @@ bool CPath::isAbsolutePath(const std::string &path) bool CFile::setRWAccess(const std::string &filename) { #ifdef NL_OS_WINDOWS - ucstring ucFile; - ucFile.fromUtf8(filename); - - wchar_t *wideFile = (wchar_t*)ucFile.c_str(); + std::wstring wideFile = NLMISC::utf8ToWide(filename); // if the file exists and there's no write access - if (_waccess (wideFile, 00) == 0 && _waccess (wideFile, 06) == -1) + if (_waccess (wideFile.c_str(), 00) == 0 && _waccess (wideFile.c_str(), 06) == -1) { // try to set the read/write access - if (_wchmod (wideFile, _S_IREAD | _S_IWRITE) == -1) + if (_wchmod (wideFile.c_str(), _S_IREAD | _S_IWRITE) == -1) { if (INelContext::getInstance().getAlreadyCreateSharedAmongThreads()) { @@ -2819,6 +2819,7 @@ bool CFile::setRWAccess(const std::string &filename) return false; } } +#endif else { if (INelContext::getInstance().getAlreadyCreateSharedAmongThreads()) @@ -2827,7 +2828,6 @@ bool CFile::setRWAccess(const std::string &filename) } // return false; } -#endif return true; } diff --git a/nel/src/misc/seven_zip.cpp b/nel/src/misc/seven_zip.cpp index ff226af7d..7a89c20c6 100644 --- a/nel/src/misc/seven_zip.cpp +++ b/nel/src/misc/seven_zip.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -172,8 +172,8 @@ bool unpack7Zip(const std::string &sevenZipFile, const std::string &destFileName filename.resize(nameLen); // write filename into ucstring - SzArEx_GetFileNameUtf16(&db, 0, &filename[0]); - + SzArEx_GetFileNameUtf16(&db, 0, reinterpret_cast(&filename[0])); + // write the extracted file FILE *outputHandle = nlfopen(destFileName, "wb+"); diff --git a/nel/src/misc/string_common.cpp b/nel/src/misc/string_common.cpp index a0fb40942..9e6459677 100644 --- a/nel/src/misc/string_common.cpp +++ b/nel/src/misc/string_common.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -21,6 +21,7 @@ #include "nel/misc/string_common.h" #include "nel/misc/sstring.h" +#include "nel/misc/utf_string_view.h" using namespace std; @@ -228,8 +229,7 @@ std::string wideToUtf8(const wchar_t *str, size_t len) #if defined(NL_OS_WINDOWS) return winWideToCp(str, len, CP_UTF8); #else - // TODO: UTF-32 to UTF-8 - nlassert(false); + return CUtfStringView(str, len).toUtf8(); #endif } @@ -242,10 +242,9 @@ std::string wideToUtf8(const std::wstring &str) std::wstring utf8ToWide(const char *str, size_t len) { #if defined(NL_OS_WINDOWS) - return winCpToWide(str, len, CP_UTF8); + return winCpToWide(str, len, CP_UTF8); // UTF-16 #else - // TODO: UTF-32 to UTF-8 - nlassert(false); + return CUtfStringView(str, len).toWide(); // UTF-32 #endif } diff --git a/nel/src/misc/string_mapper.cpp b/nel/src/misc/string_mapper.cpp index 8518afa4b..88b81ff07 100644 --- a/nel/src/misc/string_mapper.cpp +++ b/nel/src/misc/string_mapper.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/src/misc/system_info.cpp b/nel/src/misc/system_info.cpp index 1f5039de5..fb192cc43 100644 --- a/nel/src/misc/system_info.cpp +++ b/nel/src/misc/system_info.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -179,7 +179,6 @@ #else # include # include -# include # include # include # include diff --git a/nel/src/misc/system_utils.cpp b/nel/src/misc/system_utils.cpp index 8e6a1feae..8c01b227c 100644 --- a/nel/src/misc/system_utils.cpp +++ b/nel/src/misc/system_utils.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -19,6 +19,7 @@ #include "stdmisc.h" #include "nel/misc/system_utils.h" +#include "nel/misc/utf_string_view.h" #ifdef NL_OS_WINDOWS #define INITGUID @@ -154,7 +155,7 @@ bool CSystemUtils::updateProgressBar(uint value, uint total) return true; } -bool CSystemUtils::copyTextToClipboard(const ucstring &text) +bool CSystemUtils::copyTextToClipboard(const std::string &text) { if (text.empty()) return false; @@ -167,29 +168,47 @@ bool CSystemUtils::copyTextToClipboard(const ucstring &text) bool isUnicode = (IsClipboardFormatAvailable(CF_UNICODETEXT) == TRUE); // allocates a buffer to copy text in global memory - HGLOBAL mem = GlobalAlloc(GHND|GMEM_DDESHARE, (text.size()+1) * (isUnicode ? 2:1)); + std::string textMbcs; + std::wstring textWide; + if (!isUnicode) + { + textMbcs = NLMISC::utf8ToMbcs(text); // Prefer system for API + if (text.size() && !textMbcs.size()) + textMbcs = CUtfStringView(text).toAscii(); // Fallback to 7-bit ASCII + } + else + { + textWide = NLMISC::utf8ToWide(text); // Prefer system for API + if (text.size() && !textWide.size()) + textWide = CUtfStringView(text).toWide(); + } + HGLOBAL mem = GlobalAlloc(GHND | GMEM_DDESHARE, isUnicode + ? ((textWide.size() + 1) * sizeof(wchar_t)) + : (textMbcs.size() + 1)); if (mem) { // create a lock on this buffer void *hLock = GlobalLock(mem); + if (hLock) + { + // copy text to this buffer + if (isUnicode) + wcscpy((wchar_t *)hLock, textWide.c_str()); + else + strcpy((char *)hLock, textMbcs.c_str()); - // copy text to this buffer - if (isUnicode) - wcscpy((wchar_t*)hLock, (const wchar_t*)text.c_str()); - else - strcpy((char*)hLock, text.toString().c_str()); - - // unlock buffer - GlobalUnlock(mem); + // unlock buffer + GlobalUnlock(mem); - // empty clipboard - EmptyClipboard(); + // empty clipboard + EmptyClipboard(); - // set new data to clipboard in the right format - SetClipboardData(isUnicode ? CF_UNICODETEXT:CF_TEXT, mem); + // set new data to clipboard in the right format + SetClipboardData(isUnicode ? CF_UNICODETEXT : CF_TEXT, mem); - res = true; + res = true; + } } CloseClipboard(); @@ -199,7 +218,7 @@ bool CSystemUtils::copyTextToClipboard(const ucstring &text) return res; } -bool CSystemUtils::pasteTextFromClipboard(ucstring &text) +bool CSystemUtils::pasteTextFromClipboard(std::string &text) { bool res = false; @@ -211,7 +230,7 @@ bool CSystemUtils::pasteTextFromClipboard(ucstring &text) // get data from clipboard (if not of this type, they are converted) // warning, this code can't be debuggued in VC++ IDE, hObj will be always NULL - HANDLE hObj = GetClipboardData(isUnicode ? CF_UNICODETEXT:CF_TEXT); + HANDLE hObj = GetClipboardData(isUnicode ? CF_UNICODETEXT : CF_TEXT); if (hObj) { @@ -222,9 +241,23 @@ bool CSystemUtils::pasteTextFromClipboard(ucstring &text) { // retrieve clipboard data if (isUnicode) - text = (const ucchar*)hLock; - else - text = (const char*)hLock; + { + const wchar_t *str = (const wchar_t *)hLock; + text = NLMISC::wideToUtf8(str); // Prefer system for API + if (!text.size() && str[0]) + text = CUtfStringView(str).toUtf8(); + else + text = CUtfStringView(text).toUtf8(true); // Sanitize UTF-8 user input + } + else + { + const char *str = (const char *)hLock; + text = NLMISC::mbcsToUtf8(str); // Prefer system for API + if (!text.size() && str[0]) + text = CUtfStringView(str).toAscii(); // Fallback to 7-bit ASCII + else + text = CUtfStringView(text).toUtf8(true); // Sanitize UTF-8 user input + } // unlock data GlobalUnlock(hObj); diff --git a/nel/src/misc/ucstring.cpp b/nel/src/misc/ucstring.cpp new file mode 100644 index 000000000..9e97df650 --- /dev/null +++ b/nel/src/misc/ucstring.cpp @@ -0,0 +1,39 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdmisc.h" +#include "nel/misc/ucstring.h" +#include "nel/misc/utf_string_view.h" + +void ucstring::toString(std::string &str) const +{ + str = nlmove(NLMISC::CUtfStringView(*this).toUtf8()); +} + +std::string ucstring::toUtf8() const +{ + return NLMISC::CUtfStringView(*this).toUtf8(); +} + +void ucstring::fromUtf8(const std::string &stringUtf8) +{ + *this = NLMISC::CUtfStringView(stringUtf8).toUtf16(); +} + +/* end of file */ diff --git a/nel/src/misc/unicode.cpp b/nel/src/misc/unicode.cpp index 47a4cdfde..6e00afe88 100644 --- a/nel/src/misc/unicode.cpp +++ b/nel/src/misc/unicode.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -16,6 +19,7 @@ #include "stdmisc.h" #include "nel/misc/ucstring.h" +#include "nel/misc/utf_string_view.h" #ifdef DEBUG_NEW #define new DEBUG_NEW @@ -24,6 +28,9 @@ namespace NLMISC { +// TODO / FIXME: Write tool to regenerate the unicode tables in this file +// See: ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt + // Uppercase to lowercase 16 bits unicode. This table must be sorted. First entry must be unique. static const ucchar UnicodeUpperToLower[]= { @@ -1232,7 +1239,7 @@ static const ucchar UnicodeLowerToUpper[]= 0x03B6, 0x0396, // GREEK CAPITAL LETTER ZETA 0x03B7, 0x0397, // GREEK CAPITAL LETTER ETA 0x03B8, 0x0398, // GREEK CAPITAL LETTER THETA - 0x03B9, 0x0345, // COMBINING GREEK YPOGEGRAMMENI + 0x03B9, 0x0399, // GREEK CAPITAL LETTER IOTA 0x03BA, 0x039A, // GREEK CAPITAL LETTER KAPPA 0x03BB, 0x039B, // GREEK CAPITAL LETTER LAMDA 0x03BC, 0x039C, // GREEK CAPITAL LETTER MU @@ -1989,6 +1996,3432 @@ ucchar toUpper (ucchar c) return c; } +// *************************************************************************** +// *************************************************************************** +// *************************************************************************** + +static const char s_Utf8UpperToLowerC2[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xCE', '\xBC', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerC3[64 * 4] = { + '\xC3', '\xA0', '\x00', 0, + '\xC3', '\xA1', '\x00', 0, + '\xC3', '\xA2', '\x00', 0, + '\xC3', '\xA3', '\x00', 0, + '\xC3', '\xA4', '\x00', 0, + '\xC3', '\xA5', '\x00', 0, + '\xC3', '\xA6', '\x00', 0, + '\xC3', '\xA7', '\x00', 0, + '\xC3', '\xA8', '\x00', 0, + '\xC3', '\xA9', '\x00', 0, + '\xC3', '\xAA', '\x00', 0, + '\xC3', '\xAB', '\x00', 0, + '\xC3', '\xAC', '\x00', 0, + '\xC3', '\xAD', '\x00', 0, + '\xC3', '\xAE', '\x00', 0, + '\xC3', '\xAF', '\x00', 0, + '\xC3', '\xB0', '\x00', 0, + '\xC3', '\xB1', '\x00', 0, + '\xC3', '\xB2', '\x00', 0, + '\xC3', '\xB3', '\x00', 0, + '\xC3', '\xB4', '\x00', 0, + '\xC3', '\xB5', '\x00', 0, + '\xC3', '\xB6', '\x00', 0, + 0, 0, 0, 0, + '\xC3', '\xB8', '\x00', 0, + '\xC3', '\xB9', '\x00', 0, + '\xC3', '\xBA', '\x00', 0, + '\xC3', '\xBB', '\x00', 0, + '\xC3', '\xBC', '\x00', 0, + '\xC3', '\xBD', '\x00', 0, + '\xC3', '\xBE', '\x00', 0, + '\xC3', '\x9F', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerC4[64 * 4] = { + '\xC4', '\x81', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x83', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x85', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x87', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x89', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x8B', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x8D', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x8F', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x91', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x93', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x95', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x97', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x99', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x9B', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x9D', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\x9F', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xA1', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xA3', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xA5', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xA7', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xA9', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xAB', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xAD', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xAF', '\x00', 0, + 0, 0, 0, 0, + '\x69', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xB3', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xB5', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xB7', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + '\xC4', '\xBA', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xBC', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xBE', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x80', '\x00', 0, +}; + +static const char s_Utf8UpperToLowerC5[64 * 4] = { + 0, 0, 0, 0, + '\xC5', '\x82', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x84', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x86', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x88', '\x00', 0, + 0, 0, 0, 0, + '\xCA', '\xBC', '\x00', 0, + '\xC5', '\x8B', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x8D', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x8F', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x91', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x93', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x95', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x97', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x99', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x9B', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x9D', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x9F', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xA1', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xA3', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xA5', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xA7', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xA9', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xAB', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xAD', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xAF', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xB1', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xB3', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xB5', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xB7', '\x00', 0, + 0, 0, 0, 0, + '\xC3', '\xBF', '\x00', 0, + '\xC5', '\xBA', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xBC', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\xBE', '\x00', 0, + 0, 0, 0, 0, + '\x73', '\x00', '\x00', 0, +}; + +static const char s_Utf8UpperToLowerC6[64 * 4] = { + 0, 0, 0, 0, + '\xC9', '\x93', '\x00', 0, + '\xC6', '\x83', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\x85', '\x00', 0, + 0, 0, 0, 0, + '\xC9', '\x94', '\x00', 0, + '\xC6', '\x88', '\x00', 0, + 0, 0, 0, 0, + '\xC9', '\x96', '\x00', 0, + '\xC9', '\x97', '\x00', 0, + '\xC6', '\x8C', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xC7', '\x9D', '\x00', 0, + '\xC9', '\x99', '\x00', 0, + '\xC9', '\x9B', '\x00', 0, + '\xC6', '\x92', '\x00', 0, + 0, 0, 0, 0, + '\xC9', '\xA0', '\x00', 0, + '\xC9', '\xA3', '\x00', 0, + 0, 0, 0, 0, + '\xC9', '\xA9', '\x00', 0, + '\xC9', '\xA8', '\x00', 0, + '\xC6', '\x99', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xC9', '\xAF', '\x00', 0, + '\xC9', '\xB2', '\x00', 0, + 0, 0, 0, 0, + '\xC9', '\xB5', '\x00', 0, + '\xC6', '\xA1', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\xA3', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\xA5', '\x00', 0, + 0, 0, 0, 0, + '\xCA', '\x80', '\x00', 0, + '\xC6', '\xA8', '\x00', 0, + 0, 0, 0, 0, + '\xCA', '\x83', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xC6', '\xAD', '\x00', 0, + 0, 0, 0, 0, + '\xCA', '\x88', '\x00', 0, + '\xC6', '\xB0', '\x00', 0, + 0, 0, 0, 0, + '\xCA', '\x8A', '\x00', 0, + '\xCA', '\x8B', '\x00', 0, + '\xC6', '\xB4', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\xB6', '\x00', 0, + 0, 0, 0, 0, + '\xCA', '\x92', '\x00', 0, + '\xC6', '\xB9', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xC6', '\xBD', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerC7[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xC7', '\x86', '\x00', 0, + '\xC7', '\x86', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\x89', '\x00', 0, + '\xC7', '\x89', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\x8C', '\x00', 0, + '\xC7', '\x8C', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\x8E', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\x90', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\x92', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\x94', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\x96', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\x98', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\x9A', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\x9C', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xC7', '\x9F', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xA1', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xA3', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xA5', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xA7', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xA9', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xAB', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xAD', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xAF', '\x00', 0, + 0, 0, 0, 0, + '\x6A', '\x00', '\x00', 0, + '\xC7', '\xB3', '\x00', 0, + '\xC7', '\xB3', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xB5', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\x95', '\x00', 0, + '\xC6', '\xBF', '\x00', 0, + '\xC7', '\xB9', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xBB', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xBD', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xBF', '\x00', 0, + 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerC8[64 * 4] = { + '\xC8', '\x81', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x83', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x85', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x87', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x89', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x8B', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x8D', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x8F', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x91', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x93', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x95', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x97', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x99', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x9B', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x9D', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x9F', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\x9E', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\xA3', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\xA5', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\xA7', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\xA9', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\xAB', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\xAD', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\xAF', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\xB1', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\xB3', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerCD[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xCE', '\xB9', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerCE[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xCE', '\xAC', '\x00', 0, + 0, 0, 0, 0, + '\xCE', '\xAD', '\x00', 0, + '\xCE', '\xAE', '\x00', 0, + '\xCE', '\xAF', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x8C', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x8D', '\x00', 0, + '\xCF', '\x8E', '\x00', 0, + '\xCE', '\xB9', '\x00', 0, + '\xCE', '\xB1', '\x00', 0, + '\xCE', '\xB2', '\x00', 0, + '\xCE', '\xB3', '\x00', 0, + '\xCE', '\xB4', '\x00', 0, + '\xCE', '\xB5', '\x00', 0, + '\xCE', '\xB6', '\x00', 0, + '\xCE', '\xB7', '\x00', 0, + '\xCE', '\xB8', '\x00', 0, + '\xCE', '\xB9', '\x00', 0, + '\xCE', '\xBA', '\x00', 0, + '\xCE', '\xBB', '\x00', 0, + '\xCE', '\xBC', '\x00', 0, + '\xCE', '\xBD', '\x00', 0, + '\xCE', '\xBE', '\x00', 0, + '\xCE', '\xBF', '\x00', 0, + '\xCF', '\x80', '\x00', 0, + '\xCF', '\x81', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x83', '\x00', 0, + '\xCF', '\x84', '\x00', 0, + '\xCF', '\x85', '\x00', 0, + '\xCF', '\x86', '\x00', 0, + '\xCF', '\x87', '\x00', 0, + '\xCF', '\x88', '\x00', 0, + '\xCF', '\x89', '\x00', 0, + '\xCF', '\x8A', '\x00', 0, + '\xCF', '\x8B', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xCF', '\x85', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerCF[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, + '\xCF', '\x83', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xCE', '\xB2', '\x00', 0, + '\xCE', '\xB8', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xCF', '\x86', '\x00', 0, + '\xCF', '\x80', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x99', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x9B', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x9D', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x9F', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xA1', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xA3', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xA5', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xA7', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xA9', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xAB', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xAD', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xAF', '\x00', 0, + 0, 0, 0, 0, + '\xCE', '\xBA', '\x00', 0, + '\xCF', '\x81', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xCE', '\xB8', '\x00', 0, + '\xCE', '\xB5', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xB8', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xB2', '\x00', 0, + '\xCF', '\xBB', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerD0[64 * 4] = { + '\xD1', '\x90', '\x00', 0, + '\xD1', '\x91', '\x00', 0, + '\xD1', '\x92', '\x00', 0, + '\xD1', '\x93', '\x00', 0, + '\xD1', '\x94', '\x00', 0, + '\xD1', '\x95', '\x00', 0, + '\xD1', '\x96', '\x00', 0, + '\xD1', '\x97', '\x00', 0, + '\xD1', '\x98', '\x00', 0, + '\xD1', '\x99', '\x00', 0, + '\xD1', '\x9A', '\x00', 0, + '\xD1', '\x9B', '\x00', 0, + '\xD1', '\x9C', '\x00', 0, + '\xD1', '\x9D', '\x00', 0, + '\xD1', '\x9E', '\x00', 0, + '\xD1', '\x9F', '\x00', 0, + '\xD0', '\xB0', '\x00', 0, + '\xD0', '\xB1', '\x00', 0, + '\xD0', '\xB2', '\x00', 0, + '\xD0', '\xB3', '\x00', 0, + '\xD0', '\xB4', '\x00', 0, + '\xD0', '\xB5', '\x00', 0, + '\xD0', '\xB6', '\x00', 0, + '\xD0', '\xB7', '\x00', 0, + '\xD0', '\xB8', '\x00', 0, + '\xD0', '\xB9', '\x00', 0, + '\xD0', '\xBA', '\x00', 0, + '\xD0', '\xBB', '\x00', 0, + '\xD0', '\xBC', '\x00', 0, + '\xD0', '\xBD', '\x00', 0, + '\xD0', '\xBE', '\x00', 0, + '\xD0', '\xBF', '\x00', 0, + '\xD1', '\x80', '\x00', 0, + '\xD1', '\x81', '\x00', 0, + '\xD1', '\x82', '\x00', 0, + '\xD1', '\x83', '\x00', 0, + '\xD1', '\x84', '\x00', 0, + '\xD1', '\x85', '\x00', 0, + '\xD1', '\x86', '\x00', 0, + '\xD1', '\x87', '\x00', 0, + '\xD1', '\x88', '\x00', 0, + '\xD1', '\x89', '\x00', 0, + '\xD1', '\x8A', '\x00', 0, + '\xD1', '\x8B', '\x00', 0, + '\xD1', '\x8C', '\x00', 0, + '\xD1', '\x8D', '\x00', 0, + '\xD1', '\x8E', '\x00', 0, + '\xD1', '\x8F', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerD1[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xD1', '\xA1', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xA3', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xA5', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xA7', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xA9', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xAB', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xAD', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xAF', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xB1', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xB3', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xB5', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xB7', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xB9', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xBB', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xBD', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xBF', '\x00', 0, + 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerD2[64 * 4] = { + '\xD2', '\x81', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xD2', '\x8B', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x8D', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x8F', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x91', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x93', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x95', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x97', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x99', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x9B', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x9D', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x9F', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xA1', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xA3', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xA5', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xA7', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xA9', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xAB', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xAD', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xAF', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xB1', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xB3', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xB5', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xB7', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xB9', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xBB', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xBD', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xBF', '\x00', 0, + 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerD3[64 * 4] = { + 0, 0, 0, 0, + '\xD3', '\x82', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x84', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x86', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x88', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x8A', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x8C', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x8E', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xD3', '\x91', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x93', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x95', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x97', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x99', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x9B', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x9D', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x9F', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xA1', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xA3', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xA5', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xA7', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xA9', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xAB', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xAD', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xAF', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xB1', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xB3', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xB5', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xD3', '\xB9', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerD4[64 * 4] = { + '\xD4', '\x81', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x83', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x85', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x87', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x89', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x8B', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x8D', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x8F', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + '\xD5', '\xA1', '\x00', 0, + '\xD5', '\xA2', '\x00', 0, + '\xD5', '\xA3', '\x00', 0, + '\xD5', '\xA4', '\x00', 0, + '\xD5', '\xA5', '\x00', 0, + '\xD5', '\xA6', '\x00', 0, + '\xD5', '\xA7', '\x00', 0, + '\xD5', '\xA8', '\x00', 0, + '\xD5', '\xA9', '\x00', 0, + '\xD5', '\xAA', '\x00', 0, + '\xD5', '\xAB', '\x00', 0, + '\xD5', '\xAC', '\x00', 0, + '\xD5', '\xAD', '\x00', 0, + '\xD5', '\xAE', '\x00', 0, + '\xD5', '\xAF', '\x00', 0, +}; + +static const char s_Utf8UpperToLowerD5[64 * 4] = { + '\xD5', '\xB0', '\x00', 0, + '\xD5', '\xB1', '\x00', 0, + '\xD5', '\xB2', '\x00', 0, + '\xD5', '\xB3', '\x00', 0, + '\xD5', '\xB4', '\x00', 0, + '\xD5', '\xB5', '\x00', 0, + '\xD5', '\xB6', '\x00', 0, + '\xD5', '\xB7', '\x00', 0, + '\xD5', '\xB8', '\x00', 0, + '\xD5', '\xB9', '\x00', 0, + '\xD5', '\xBA', '\x00', 0, + '\xD5', '\xBB', '\x00', 0, + '\xD5', '\xBC', '\x00', 0, + '\xD5', '\xBD', '\x00', 0, + '\xD5', '\xBE', '\x00', 0, + '\xD5', '\xBF', '\x00', 0, + '\xD6', '\x80', '\x00', 0, + '\xD6', '\x81', '\x00', 0, + '\xD6', '\x82', '\x00', 0, + '\xD6', '\x83', '\x00', 0, + '\xD6', '\x84', '\x00', 0, + '\xD6', '\x85', '\x00', 0, + '\xD6', '\x86', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerD6[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xD5', '\xA5', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerE1B8[64 * 4] = { + '\xE1', '\xB8', '\x81', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x83', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x85', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x87', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x89', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x8B', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x8D', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x8F', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x91', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x93', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x95', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x97', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x99', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x9B', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x9D', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\x9F', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xA1', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xA3', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xA5', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xA7', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xA9', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xAB', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xAD', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xAF', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xB1', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xB3', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xB5', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xB7', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xB9', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xBB', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xBD', 0, + 0, 0, 0, 0, + '\xE1', '\xB8', '\xBF', 0, + 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerE1B9[64 * 4] = { + '\xE1', '\xB9', '\x81', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x83', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x85', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x87', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x89', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x8B', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x8D', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x8F', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x91', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x93', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x95', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x97', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x99', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x9B', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x9D', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\x9F', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xA1', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xA3', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xA5', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xA7', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xA9', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xAB', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xAD', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xAF', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xB1', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xB3', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xB5', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xB7', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xB9', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xBB', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xBD', 0, + 0, 0, 0, 0, + '\xE1', '\xB9', '\xBF', 0, + 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerE1BA[64 * 4] = { + '\xE1', '\xBA', '\x81', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\x83', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\x85', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\x87', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\x89', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\x8B', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\x8D', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\x8F', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\x91', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\x93', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\x95', 0, + 0, 0, 0, 0, + '\x68', '\x00', '\x00', 0, + '\x74', '\x00', '\x00', 0, + '\x77', '\x00', '\x00', 0, + '\x79', '\x00', '\x00', 0, + '\x61', '\x00', '\x00', 0, + '\xE1', '\xB9', '\xA1', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBA', '\xA1', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xA3', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xA5', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xA7', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xA9', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xAB', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xAD', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xAF', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xB1', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xB3', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xB5', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xB7', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xB9', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xBB', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xBD', 0, + 0, 0, 0, 0, + '\xE1', '\xBA', '\xBF', 0, + 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerE1BB[64 * 4] = { + '\xE1', '\xBB', '\x81', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x83', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x85', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x87', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x89', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x8B', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x8D', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x8F', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x91', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x93', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x95', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x97', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x99', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x9B', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x9D', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\x9F', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xA1', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xA3', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xA5', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xA7', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xA9', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xAB', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xAD', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xAF', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xB1', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xB3', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xB5', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xB7', 0, + 0, 0, 0, 0, + '\xE1', '\xBB', '\xB9', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerE1BC[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBC', '\x80', 0, + '\xE1', '\xBC', '\x81', 0, + '\xE1', '\xBC', '\x82', 0, + '\xE1', '\xBC', '\x83', 0, + '\xE1', '\xBC', '\x84', 0, + '\xE1', '\xBC', '\x85', 0, + '\xE1', '\xBC', '\x86', 0, + '\xE1', '\xBC', '\x87', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBC', '\x90', 0, + '\xE1', '\xBC', '\x91', 0, + '\xE1', '\xBC', '\x92', 0, + '\xE1', '\xBC', '\x93', 0, + '\xE1', '\xBC', '\x94', 0, + '\xE1', '\xBC', '\x95', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBC', '\xA0', 0, + '\xE1', '\xBC', '\xA1', 0, + '\xE1', '\xBC', '\xA2', 0, + '\xE1', '\xBC', '\xA3', 0, + '\xE1', '\xBC', '\xA4', 0, + '\xE1', '\xBC', '\xA5', 0, + '\xE1', '\xBC', '\xA6', 0, + '\xE1', '\xBC', '\xA7', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBC', '\xB0', 0, + '\xE1', '\xBC', '\xB1', 0, + '\xE1', '\xBC', '\xB2', 0, + '\xE1', '\xBC', '\xB3', 0, + '\xE1', '\xBC', '\xB4', 0, + '\xE1', '\xBC', '\xB5', 0, + '\xE1', '\xBC', '\xB6', 0, + '\xE1', '\xBC', '\xB7', 0, +}; + +static const char s_Utf8UpperToLowerE1BD[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBD', '\x80', 0, + '\xE1', '\xBD', '\x81', 0, + '\xE1', '\xBD', '\x82', 0, + '\xE1', '\xBD', '\x83', 0, + '\xE1', '\xBD', '\x84', 0, + '\xE1', '\xBD', '\x85', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xCF', '\x85', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x85', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x85', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x85', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + '\xE1', '\xBD', '\x91', 0, + 0, 0, 0, 0, + '\xE1', '\xBD', '\x93', 0, + 0, 0, 0, 0, + '\xE1', '\xBD', '\x95', 0, + 0, 0, 0, 0, + '\xE1', '\xBD', '\x97', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBD', '\xA0', 0, + '\xE1', '\xBD', '\xA1', 0, + '\xE1', '\xBD', '\xA2', 0, + '\xE1', '\xBD', '\xA3', 0, + '\xE1', '\xBD', '\xA4', 0, + '\xE1', '\xBD', '\xA5', 0, + '\xE1', '\xBD', '\xA6', 0, + '\xE1', '\xBD', '\xA7', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerE1BE[64 * 4] = { + '\xE1', '\xBC', '\x80', 0, + '\xE1', '\xBC', '\x81', 0, + '\xE1', '\xBC', '\x82', 0, + '\xE1', '\xBC', '\x83', 0, + '\xE1', '\xBC', '\x84', 0, + '\xE1', '\xBC', '\x85', 0, + '\xE1', '\xBC', '\x86', 0, + '\xE1', '\xBC', '\x87', 0, + '\xE1', '\xBE', '\x80', 0, + '\xE1', '\xBE', '\x81', 0, + '\xE1', '\xBE', '\x82', 0, + '\xE1', '\xBE', '\x83', 0, + '\xE1', '\xBE', '\x84', 0, + '\xE1', '\xBE', '\x85', 0, + '\xE1', '\xBE', '\x86', 0, + '\xE1', '\xBE', '\x87', 0, + '\xE1', '\xBC', '\xA0', 0, + '\xE1', '\xBC', '\xA1', 0, + '\xE1', '\xBC', '\xA2', 0, + '\xE1', '\xBC', '\xA3', 0, + '\xE1', '\xBC', '\xA4', 0, + '\xE1', '\xBC', '\xA5', 0, + '\xE1', '\xBC', '\xA6', 0, + '\xE1', '\xBC', '\xA7', 0, + '\xE1', '\xBE', '\x90', 0, + '\xE1', '\xBE', '\x91', 0, + '\xE1', '\xBE', '\x92', 0, + '\xE1', '\xBE', '\x93', 0, + '\xE1', '\xBE', '\x94', 0, + '\xE1', '\xBE', '\x95', 0, + '\xE1', '\xBE', '\x96', 0, + '\xE1', '\xBE', '\x97', 0, + '\xE1', '\xBD', '\xA0', 0, + '\xE1', '\xBD', '\xA1', 0, + '\xE1', '\xBD', '\xA2', 0, + '\xE1', '\xBD', '\xA3', 0, + '\xE1', '\xBD', '\xA4', 0, + '\xE1', '\xBD', '\xA5', 0, + '\xE1', '\xBD', '\xA6', 0, + '\xE1', '\xBD', '\xA7', 0, + '\xE1', '\xBE', '\xA0', 0, + '\xE1', '\xBE', '\xA1', 0, + '\xE1', '\xBE', '\xA2', 0, + '\xE1', '\xBE', '\xA3', 0, + '\xE1', '\xBE', '\xA4', 0, + '\xE1', '\xBE', '\xA5', 0, + '\xE1', '\xBE', '\xA6', 0, + '\xE1', '\xBE', '\xA7', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBD', '\xB0', 0, + '\xCE', '\xB1', '\x00', 0, + '\xCE', '\xAC', '\x00', 0, + 0, 0, 0, 0, + '\xCE', '\xB1', '\x00', 0, + '\xCE', '\xB1', '\x00', 0, + '\xE1', '\xBE', '\xB0', 0, + '\xE1', '\xBE', '\xB1', 0, + '\xE1', '\xBD', '\xB0', 0, + '\xE1', '\xBD', '\xB1', 0, + '\xE1', '\xBE', '\xB3', 0, + 0, 0, 0, 0, + '\xCE', '\xB9', '\x00', 0, + 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerE1BF[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBD', '\xB4', 0, + '\xCE', '\xB7', '\x00', 0, + '\xCE', '\xAE', '\x00', 0, + 0, 0, 0, 0, + '\xCE', '\xB7', '\x00', 0, + '\xCE', '\xB7', '\x00', 0, + '\xE1', '\xBD', '\xB2', 0, + '\xE1', '\xBD', '\xB3', 0, + '\xE1', '\xBD', '\xB4', 0, + '\xE1', '\xBD', '\xB5', 0, + '\xE1', '\xBF', '\x83', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xCE', '\xB9', '\x00', 0, + '\xCE', '\xB9', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xCE', '\xB9', '\x00', 0, + '\xCE', '\xB9', '\x00', 0, + '\xE1', '\xBF', '\x90', 0, + '\xE1', '\xBF', '\x91', 0, + '\xE1', '\xBD', '\xB6', 0, + '\xE1', '\xBD', '\xB7', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xCF', '\x85', '\x00', 0, + '\xCF', '\x85', '\x00', 0, + '\xCF', '\x81', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x85', '\x00', 0, + '\xCF', '\x85', '\x00', 0, + '\xE1', '\xBF', '\xA0', 0, + '\xE1', '\xBF', '\xA1', 0, + '\xE1', '\xBD', '\xBA', 0, + '\xE1', '\xBD', '\xBB', 0, + '\xE1', '\xBF', '\xA5', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBD', '\xBC', 0, + '\xCF', '\x89', '\x00', 0, + '\xCF', '\x8E', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x89', '\x00', 0, + '\xCF', '\x89', '\x00', 0, + '\xE1', '\xBD', '\xB8', 0, + '\xE1', '\xBD', '\xB9', 0, + '\xE1', '\xBD', '\xBC', 0, + '\xE1', '\xBD', '\xBD', 0, + '\xE1', '\xBF', '\xB3', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerE284[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xCF', '\x89', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\x6B', '\x00', '\x00', 0, + '\xC3', '\xA5', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerE285[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE2', '\x85', '\xB0', 0, + '\xE2', '\x85', '\xB1', 0, + '\xE2', '\x85', '\xB2', 0, + '\xE2', '\x85', '\xB3', 0, + '\xE2', '\x85', '\xB4', 0, + '\xE2', '\x85', '\xB5', 0, + '\xE2', '\x85', '\xB6', 0, + '\xE2', '\x85', '\xB7', 0, + '\xE2', '\x85', '\xB8', 0, + '\xE2', '\x85', '\xB9', 0, + '\xE2', '\x85', '\xBA', 0, + '\xE2', '\x85', '\xBB', 0, + '\xE2', '\x85', '\xBC', 0, + '\xE2', '\x85', '\xBD', 0, + '\xE2', '\x85', '\xBE', 0, + '\xE2', '\x85', '\xBF', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerE292[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE2', '\x93', '\x90', 0, + '\xE2', '\x93', '\x91', 0, + '\xE2', '\x93', '\x92', 0, + '\xE2', '\x93', '\x93', 0, + '\xE2', '\x93', '\x94', 0, + '\xE2', '\x93', '\x95', 0, + '\xE2', '\x93', '\x96', 0, + '\xE2', '\x93', '\x97', 0, + '\xE2', '\x93', '\x98', 0, + '\xE2', '\x93', '\x99', 0, +}; + +static const char s_Utf8UpperToLowerE293[64 * 4] = { + '\xE2', '\x93', '\x9A', 0, + '\xE2', '\x93', '\x9B', 0, + '\xE2', '\x93', '\x9C', 0, + '\xE2', '\x93', '\x9D', 0, + '\xE2', '\x93', '\x9E', 0, + '\xE2', '\x93', '\x9F', 0, + '\xE2', '\x93', '\xA0', 0, + '\xE2', '\x93', '\xA1', 0, + '\xE2', '\x93', '\xA2', 0, + '\xE2', '\x93', '\xA3', 0, + '\xE2', '\x93', '\xA4', 0, + '\xE2', '\x93', '\xA5', 0, + '\xE2', '\x93', '\xA6', 0, + '\xE2', '\x93', '\xA7', 0, + '\xE2', '\x93', '\xA8', 0, + '\xE2', '\x93', '\xA9', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerEFAC[64 * 4] = { + '\x66', '\x00', '\x00', 0, + '\x66', '\x00', '\x00', 0, + '\x66', '\x00', '\x00', 0, + '\x66', '\x00', '\x00', 0, + '\x66', '\x00', '\x00', 0, + '\x73', '\x00', '\x00', 0, + '\x73', '\x00', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xD5', '\xB4', '\x00', 0, + '\xD5', '\xB4', '\x00', 0, + '\xD5', '\xB4', '\x00', 0, + '\xD5', '\xBE', '\x00', 0, + '\xD5', '\xB4', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8UpperToLowerEFBC[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + '\xEF', '\xBD', '\x81', 0, + '\xEF', '\xBD', '\x82', 0, + '\xEF', '\xBD', '\x83', 0, + '\xEF', '\xBD', '\x84', 0, + '\xEF', '\xBD', '\x85', 0, + '\xEF', '\xBD', '\x86', 0, + '\xEF', '\xBD', '\x87', 0, + '\xEF', '\xBD', '\x88', 0, + '\xEF', '\xBD', '\x89', 0, + '\xEF', '\xBD', '\x8A', 0, + '\xEF', '\xBD', '\x8B', 0, + '\xEF', '\xBD', '\x8C', 0, + '\xEF', '\xBD', '\x8D', 0, + '\xEF', '\xBD', '\x8E', 0, + '\xEF', '\xBD', '\x8F', 0, + '\xEF', '\xBD', '\x90', 0, + '\xEF', '\xBD', '\x91', 0, + '\xEF', '\xBD', '\x92', 0, + '\xEF', '\xBD', '\x93', 0, + '\xEF', '\xBD', '\x94', 0, + '\xEF', '\xBD', '\x95', 0, + '\xEF', '\xBD', '\x96', 0, + '\xEF', '\xBD', '\x97', 0, + '\xEF', '\xBD', '\x98', 0, + '\xEF', '\xBD', '\x99', 0, + '\xEF', '\xBD', '\x9A', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char *s_Utf8UpperToLowerTables[32] = { + 0, 0, + s_Utf8UpperToLowerC2, + s_Utf8UpperToLowerC3, + s_Utf8UpperToLowerC4, + s_Utf8UpperToLowerC5, + s_Utf8UpperToLowerC6, + s_Utf8UpperToLowerC7, + s_Utf8UpperToLowerC8, + 0, 0, 0, 0, + s_Utf8UpperToLowerCD, + s_Utf8UpperToLowerCE, + s_Utf8UpperToLowerCF, + s_Utf8UpperToLowerD0, + s_Utf8UpperToLowerD1, + s_Utf8UpperToLowerD2, + s_Utf8UpperToLowerD3, + s_Utf8UpperToLowerD4, + s_Utf8UpperToLowerD5, + s_Utf8UpperToLowerD6, + 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char *s_Utf8UpperToLowerTablesE1[64] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + s_Utf8UpperToLowerE1B8, + s_Utf8UpperToLowerE1B9, + s_Utf8UpperToLowerE1BA, + s_Utf8UpperToLowerE1BB, + s_Utf8UpperToLowerE1BC, + s_Utf8UpperToLowerE1BD, + s_Utf8UpperToLowerE1BE, + s_Utf8UpperToLowerE1BF, +}; + +static const char *s_Utf8UpperToLowerTablesE2[64] = { + 0, 0, 0, 0, + s_Utf8UpperToLowerE284, + s_Utf8UpperToLowerE285, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + s_Utf8UpperToLowerE292, + s_Utf8UpperToLowerE293, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char *s_Utf8UpperToLowerTablesEF[64] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + s_Utf8UpperToLowerEFAC, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + s_Utf8UpperToLowerEFBC, + 0, 0, 0, +}; + +static const char **s_UtfUpperToLowerMap[16] = { + 0, + s_Utf8UpperToLowerTablesE1, + s_Utf8UpperToLowerTablesE2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + s_Utf8UpperToLowerTablesEF, +}; + +// *************************************************************************** +// *************************************************************************** +// *************************************************************************** + +static const char s_Utf8LowerToUpperC3[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + '\x41', '\x00', '\x00', 0, + '\x41', '\x00', '\x00', 0, + '\x41', '\x00', '\x00', 0, + '\x41', '\x00', '\x00', 0, + '\x41', '\x00', '\x00', 0, + '\xC3', '\x86', '\x00', 0, + '\x43', '\x00', '\x00', 0, + '\x45', '\x00', '\x00', 0, + '\x45', '\x00', '\x00', 0, + '\x45', '\x00', '\x00', 0, + '\x45', '\x00', '\x00', 0, + '\x49', '\x00', '\x00', 0, + '\x49', '\x00', '\x00', 0, + '\x49', '\x00', '\x00', 0, + '\x49', '\x00', '\x00', 0, + '\xC3', '\x90', '\x00', 0, + '\x4E', '\x00', '\x00', 0, + '\x4F', '\x00', '\x00', 0, + '\x4F', '\x00', '\x00', 0, + '\x4F', '\x00', '\x00', 0, + '\x4F', '\x00', '\x00', 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + '\x55', '\x00', '\x00', 0, + '\x55', '\x00', '\x00', 0, + '\x55', '\x00', '\x00', 0, + '\x55', '\x00', '\x00', 0, + '\x59', '\x00', '\x00', 0, + '\xC3', '\x9E', '\x00', 0, + '\x59', '\x00', '\x00', 0, +}; + +static const char s_Utf8LowerToUpperC4[64 * 4] = { + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x43', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x43', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x43', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x43', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x44', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x44', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x47', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x47', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x47', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x47', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x48', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x48', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\xC4', '\xB2', '\x00', 0, + 0, 0, 0, 0, + '\x4A', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4B', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\x4C', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4C', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4C', '\x00', '\x00', 0, + 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperC5[64 * 4] = { + '\x4C', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4C', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4E', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4E', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4E', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xC5', '\x8A', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\xC5', '\x92', '\x00', 0, + 0, 0, 0, 0, + '\x52', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x52', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x52', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x53', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x53', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x53', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x53', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x54', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x54', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x54', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x57', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x59', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\x5A', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x5A', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x5A', '\x00', '\x00', 0, + 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperC6[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\x42', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\x84', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\x43', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\x44', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\x46', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xC7', '\xB6', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + '\x4B', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\x4E', '\x00', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\xA2', '\x00', 0, + 0, 0, 0, 0, + '\x50', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xC6', '\xA7', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\x54', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\x59', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x5A', '\x00', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + '\xC6', '\xB8', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xC6', '\xBC', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xB7', '\x00', 0, +}; + +static const char s_Utf8LowerToUpperC7[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xC7', '\x84', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + '\xC7', '\x87', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xC7', '\x8A', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + '\xC6', '\x8E', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xA2', '\x00', 0, + 0, 0, 0, 0, + '\x47', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x47', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4B', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xAE', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xC7', '\xB1', '\x00', 0, + 0, 0, 0, 0, + '\x47', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + '\x4E', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\xC7', '\xBC', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, +}; + +static const char s_Utf8LowerToUpperC8[64 * 4] = { + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x52', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x52', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x53', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x54', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\xC8', '\x9C', '\x00', 0, + 0, 0, 0, 0, + '\x48', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xC8', '\xA2', '\x00', 0, + 0, 0, 0, 0, + '\x5A', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x59', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperC9[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\x42', '\x00', '\x00', 0, + '\xC6', '\x86', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\x89', '\x00', 0, + '\x44', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\x8F', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\x90', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\x47', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xC6', '\x94', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + '\xC6', '\x96', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xC6', '\x9C', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\x4E', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperCA[64 * 4] = { + '\xC6', '\xA6', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xC6', '\xA9', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\x54', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\xC6', '\xB1', '\x00', 0, + '\x56', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xC6', '\xB7', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperCE[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xCE', '\x86', '\x00', 0, + '\xCE', '\x88', '\x00', 0, + '\xCE', '\x89', '\x00', 0, + '\xCE', '\x8A', '\x00', 0, + 0, 0, 0, 0, + '\xCE', '\x91', '\x00', 0, + '\xCE', '\x92', '\x00', 0, + '\xCE', '\x93', '\x00', 0, + '\xCE', '\x94', '\x00', 0, + '\xCE', '\x95', '\x00', 0, + '\xCE', '\x96', '\x00', 0, + '\xCE', '\x97', '\x00', 0, + '\xCE', '\x98', '\x00', 0, + '\xCE', '\x99', '\x00', 0, + '\xCE', '\x9A', '\x00', 0, + '\xCE', '\x9B', '\x00', 0, + '\xCE', '\x9C', '\x00', 0, + '\xCE', '\x9D', '\x00', 0, + '\xCE', '\x9E', '\x00', 0, + '\xCE', '\x9F', '\x00', 0, +}; + +static const char s_Utf8LowerToUpperCF[64 * 4] = { + '\xCE', '\xA0', '\x00', 0, + '\xCE', '\xA1', '\x00', 0, + 0, 0, 0, 0, + '\xCE', '\xA3', '\x00', 0, + '\xCE', '\xA4', '\x00', 0, + '\xCE', '\xA5', '\x00', 0, + '\xCE', '\xA6', '\x00', 0, + '\xCE', '\xA7', '\x00', 0, + '\xCE', '\xA8', '\x00', 0, + '\xCE', '\xA9', '\x00', 0, + '\xCE', '\xAA', '\x00', 0, + '\xCE', '\xAB', '\x00', 0, + '\xCE', '\x8C', '\x00', 0, + '\xCE', '\x8E', '\x00', 0, + '\xCE', '\x8F', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + '\xCF', '\x98', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x9A', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x9C', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\x9E', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xA0', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xA2', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xA4', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xA6', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xA8', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xAA', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xAC', '\x00', 0, + 0, 0, 0, 0, + '\xCF', '\xAE', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xCF', '\xB9', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xCF', '\xB7', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + '\xCF', '\xBA', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperD0[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xD0', '\x90', '\x00', 0, + '\xD0', '\x91', '\x00', 0, + '\xD0', '\x92', '\x00', 0, + '\xD0', '\x93', '\x00', 0, + '\xD0', '\x94', '\x00', 0, + '\xD0', '\x95', '\x00', 0, + '\xD0', '\x96', '\x00', 0, + '\xD0', '\x97', '\x00', 0, + '\xD0', '\x98', '\x00', 0, + '\xD0', '\x99', '\x00', 0, + '\xD0', '\x9A', '\x00', 0, + '\xD0', '\x9B', '\x00', 0, + '\xD0', '\x9C', '\x00', 0, + '\xD0', '\x9D', '\x00', 0, + '\xD0', '\x9E', '\x00', 0, + '\xD0', '\x9F', '\x00', 0, +}; + +static const char s_Utf8LowerToUpperD1[64 * 4] = { + '\xD0', '\xA0', '\x00', 0, + '\xD0', '\xA1', '\x00', 0, + '\xD0', '\xA2', '\x00', 0, + '\xD0', '\xA3', '\x00', 0, + '\xD0', '\xA4', '\x00', 0, + '\xD0', '\xA5', '\x00', 0, + '\xD0', '\xA6', '\x00', 0, + '\xD0', '\xA7', '\x00', 0, + '\xD0', '\xA8', '\x00', 0, + '\xD0', '\xA9', '\x00', 0, + '\xD0', '\xAA', '\x00', 0, + '\xD0', '\xAB', '\x00', 0, + '\xD0', '\xAC', '\x00', 0, + '\xD0', '\xAD', '\x00', 0, + '\xD0', '\xAE', '\x00', 0, + '\xD0', '\xAF', '\x00', 0, + '\xD0', '\x80', '\x00', 0, + '\xD0', '\x81', '\x00', 0, + '\xD0', '\x82', '\x00', 0, + '\xD0', '\x83', '\x00', 0, + '\xD0', '\x84', '\x00', 0, + '\xD0', '\x85', '\x00', 0, + '\xD0', '\x86', '\x00', 0, + '\xD0', '\x87', '\x00', 0, + '\xD0', '\x88', '\x00', 0, + '\xD0', '\x89', '\x00', 0, + '\xD0', '\x8A', '\x00', 0, + '\xD0', '\x8B', '\x00', 0, + '\xD0', '\x8C', '\x00', 0, + '\xD0', '\x8D', '\x00', 0, + '\xD0', '\x8E', '\x00', 0, + '\xD0', '\x8F', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xA0', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xA2', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xA4', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xA6', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xA8', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xAA', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xAC', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xAE', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xB0', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xB2', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xB4', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xB6', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xB8', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xBA', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xBC', '\x00', 0, + 0, 0, 0, 0, + '\xD1', '\xBE', '\x00', 0, +}; + +static const char s_Utf8LowerToUpperD2[64 * 4] = { + 0, 0, 0, 0, + '\xD2', '\x80', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xD2', '\x8A', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x8C', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x8E', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x90', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x92', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x94', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x96', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x98', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x9A', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x9C', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\x9E', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xA0', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xA2', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xA4', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xA6', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xA8', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xAA', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xAC', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xAE', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xB0', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xB2', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xB4', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xB6', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xB8', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xBA', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xBC', '\x00', 0, + 0, 0, 0, 0, + '\xD2', '\xBE', '\x00', 0, +}; + +static const char s_Utf8LowerToUpperD3[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, + '\xD3', '\x81', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x83', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x85', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x87', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x89', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x8B', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x8D', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + '\xD3', '\x90', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x92', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x94', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x96', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x98', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x9A', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x9C', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\x9E', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xA0', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xA2', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xA4', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xA6', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xA8', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xAA', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xAC', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xAE', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xB0', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xB2', '\x00', 0, + 0, 0, 0, 0, + '\xD3', '\xB4', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + '\xD3', '\xB8', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperD4[64 * 4] = { + 0, 0, 0, 0, + '\xD4', '\x80', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x82', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x84', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x86', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x88', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x8A', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x8C', '\x00', 0, + 0, 0, 0, 0, + '\xD4', '\x8E', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperD5[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + '\xD4', '\xB1', '\x00', 0, + '\xD4', '\xB2', '\x00', 0, + '\xD4', '\xB3', '\x00', 0, + '\xD4', '\xB4', '\x00', 0, + '\xD4', '\xB5', '\x00', 0, + '\xD4', '\xB6', '\x00', 0, + '\xD4', '\xB7', '\x00', 0, + '\xD4', '\xB8', '\x00', 0, + '\xD4', '\xB9', '\x00', 0, + '\xD4', '\xBA', '\x00', 0, + '\xD4', '\xBB', '\x00', 0, + '\xD4', '\xBC', '\x00', 0, + '\xD4', '\xBD', '\x00', 0, + '\xD4', '\xBE', '\x00', 0, + '\xD4', '\xBF', '\x00', 0, + '\xD5', '\x80', '\x00', 0, + '\xD5', '\x81', '\x00', 0, + '\xD5', '\x82', '\x00', 0, + '\xD5', '\x83', '\x00', 0, + '\xD5', '\x84', '\x00', 0, + '\xD5', '\x85', '\x00', 0, + '\xD5', '\x86', '\x00', 0, + '\xD5', '\x87', '\x00', 0, + '\xD5', '\x88', '\x00', 0, + '\xD5', '\x89', '\x00', 0, + '\xD5', '\x8A', '\x00', 0, + '\xD5', '\x8B', '\x00', 0, + '\xD5', '\x8C', '\x00', 0, + '\xD5', '\x8D', '\x00', 0, + '\xD5', '\x8E', '\x00', 0, + '\xD5', '\x8F', '\x00', 0, +}; + +static const char s_Utf8LowerToUpperD6[64 * 4] = { + '\xD5', '\x90', '\x00', 0, + '\xD5', '\x91', '\x00', 0, + '\xD5', '\x92', '\x00', 0, + '\xD5', '\x93', '\x00', 0, + '\xD5', '\x94', '\x00', 0, + '\xD5', '\x95', '\x00', 0, + '\xD5', '\x96', '\x00', 0, + 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperE1B8[64 * 4] = { + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x42', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x42', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x42', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x43', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x44', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x44', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x44', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x44', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x44', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x46', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x47', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x48', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x48', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x48', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x48', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x48', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4B', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4B', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4B', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4C', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4C', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4C', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4C', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4D', '\x00', '\x00', 0, +}; + +static const char s_Utf8LowerToUpperE1B9[64 * 4] = { + 0, 0, 0, 0, + '\x4D', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4D', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4E', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4E', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4E', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4E', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x50', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x50', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x52', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x52', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x52', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x52', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x53', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x53', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x53', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x53', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x53', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x54', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x54', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x54', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x54', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x56', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x56', '\x00', '\x00', 0, +}; + +static const char s_Utf8LowerToUpperE1BA[64 * 4] = { + 0, 0, 0, 0, + '\x57', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x57', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x57', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x57', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x57', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x58', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x58', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x59', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x5A', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x5A', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x5A', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, +}; + +static const char s_Utf8LowerToUpperE1BB[64 * 4] = { + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x45', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x49', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x4F', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x55', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x59', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x59', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x59', '\x00', '\x00', 0, + 0, 0, 0, 0, + '\x59', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperE1BC[64 * 4] = { + '\xE1', '\xBC', '\x88', 0, + '\xE1', '\xBC', '\x89', 0, + '\xE1', '\xBC', '\x8A', 0, + '\xE1', '\xBC', '\x8B', 0, + '\xE1', '\xBC', '\x8C', 0, + '\xE1', '\xBC', '\x8D', 0, + '\xE1', '\xBC', '\x8E', 0, + '\xE1', '\xBC', '\x8F', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBC', '\x98', 0, + '\xE1', '\xBC', '\x99', 0, + '\xE1', '\xBC', '\x9A', 0, + '\xE1', '\xBC', '\x9B', 0, + '\xE1', '\xBC', '\x9C', 0, + '\xE1', '\xBC', '\x9D', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBC', '\xA8', 0, + '\xE1', '\xBC', '\xA9', 0, + '\xE1', '\xBC', '\xAA', 0, + '\xE1', '\xBC', '\xAB', 0, + '\xE1', '\xBC', '\xAC', 0, + '\xE1', '\xBC', '\xAD', 0, + '\xE1', '\xBC', '\xAE', 0, + '\xE1', '\xBC', '\xAF', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBC', '\xB8', 0, + '\xE1', '\xBC', '\xB9', 0, + '\xE1', '\xBC', '\xBA', 0, + '\xE1', '\xBC', '\xBB', 0, + '\xE1', '\xBC', '\xBC', 0, + '\xE1', '\xBC', '\xBD', 0, + '\xE1', '\xBC', '\xBE', 0, + '\xE1', '\xBC', '\xBF', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperE1BD[64 * 4] = { + '\xE1', '\xBD', '\x88', 0, + '\xE1', '\xBD', '\x89', 0, + '\xE1', '\xBD', '\x8A', 0, + '\xE1', '\xBD', '\x8B', 0, + '\xE1', '\xBD', '\x8C', 0, + '\xE1', '\xBD', '\x8D', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + '\xE1', '\xBD', '\x99', 0, + 0, 0, 0, 0, + '\xE1', '\xBD', '\x9B', 0, + 0, 0, 0, 0, + '\xE1', '\xBD', '\x9D', 0, + 0, 0, 0, 0, + '\xE1', '\xBD', '\x9F', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBD', '\xA8', 0, + '\xE1', '\xBD', '\xA9', 0, + '\xE1', '\xBD', '\xAA', 0, + '\xE1', '\xBD', '\xAB', 0, + '\xE1', '\xBD', '\xAC', 0, + '\xE1', '\xBD', '\xAD', 0, + '\xE1', '\xBD', '\xAE', 0, + '\xE1', '\xBD', '\xAF', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBE', '\xBA', 0, + '\xE1', '\xBE', '\xBB', 0, + '\xE1', '\xBF', '\x88', 0, + '\xE1', '\xBF', '\x89', 0, + '\xE1', '\xBF', '\x8A', 0, + '\xE1', '\xBF', '\x8B', 0, + '\xE1', '\xBF', '\x9A', 0, + '\xE1', '\xBF', '\x9B', 0, + '\xE1', '\xBF', '\xB8', 0, + '\xE1', '\xBF', '\xB9', 0, + '\xE1', '\xBF', '\xAA', 0, + '\xE1', '\xBF', '\xAB', 0, + '\xE1', '\xBF', '\xBA', 0, + '\xE1', '\xBF', '\xBB', 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperE1BE[64 * 4] = { + '\xE1', '\xBE', '\x88', 0, + '\xE1', '\xBE', '\x89', 0, + '\xE1', '\xBE', '\x8A', 0, + '\xE1', '\xBE', '\x8B', 0, + '\xE1', '\xBE', '\x8C', 0, + '\xE1', '\xBE', '\x8D', 0, + '\xE1', '\xBE', '\x8E', 0, + '\xE1', '\xBE', '\x8F', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBE', '\x98', 0, + '\xE1', '\xBE', '\x99', 0, + '\xE1', '\xBE', '\x9A', 0, + '\xE1', '\xBE', '\x9B', 0, + '\xE1', '\xBE', '\x9C', 0, + '\xE1', '\xBE', '\x9D', 0, + '\xE1', '\xBE', '\x9E', 0, + '\xE1', '\xBE', '\x9F', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBE', '\xA8', 0, + '\xE1', '\xBE', '\xA9', 0, + '\xE1', '\xBE', '\xAA', 0, + '\xE1', '\xBE', '\xAB', 0, + '\xE1', '\xBE', '\xAC', 0, + '\xE1', '\xBE', '\xAD', 0, + '\xE1', '\xBE', '\xAE', 0, + '\xE1', '\xBE', '\xAF', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBE', '\xB8', 0, + '\xE1', '\xBE', '\xB9', 0, + 0, 0, 0, 0, + '\xE1', '\xBE', '\xBC', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperE1BF[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBF', '\x8C', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBF', '\x98', 0, + '\xE1', '\xBF', '\x99', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBF', '\xA8', 0, + '\xE1', '\xBF', '\xA9', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBF', '\xAC', 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE1', '\xBF', '\xBC', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperE285[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\xE2', '\x85', '\xA0', 0, + '\xE2', '\x85', '\xA1', 0, + '\xE2', '\x85', '\xA2', 0, + '\xE2', '\x85', '\xA3', 0, + '\xE2', '\x85', '\xA4', 0, + '\xE2', '\x85', '\xA5', 0, + '\xE2', '\x85', '\xA6', 0, + '\xE2', '\x85', '\xA7', 0, + '\xE2', '\x85', '\xA8', 0, + '\xE2', '\x85', '\xA9', 0, + '\xE2', '\x85', '\xAA', 0, + '\xE2', '\x85', '\xAB', 0, + '\xE2', '\x85', '\xAC', 0, + '\xE2', '\x85', '\xAD', 0, + '\xE2', '\x85', '\xAE', 0, + '\xE2', '\x85', '\xAF', 0, +}; + +static const char s_Utf8LowerToUpperE293[64 * 4] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + '\x42', '\x00', '\x00', 0, + '\x43', '\x00', '\x00', 0, + '\x44', '\x00', '\x00', 0, + '\x45', '\x00', '\x00', 0, + '\x46', '\x00', '\x00', 0, + '\x47', '\x00', '\x00', 0, + '\x48', '\x00', '\x00', 0, + '\x49', '\x00', '\x00', 0, + '\x4A', '\x00', '\x00', 0, + '\x4B', '\x00', '\x00', 0, + '\x4C', '\x00', '\x00', 0, + '\x4D', '\x00', '\x00', 0, + '\x4E', '\x00', '\x00', 0, + '\x4F', '\x00', '\x00', 0, + '\x50', '\x00', '\x00', 0, + '\x51', '\x00', '\x00', 0, + '\x52', '\x00', '\x00', 0, + '\x53', '\x00', '\x00', 0, + '\x54', '\x00', '\x00', 0, + '\x55', '\x00', '\x00', 0, + '\x56', '\x00', '\x00', 0, + '\x57', '\x00', '\x00', 0, + '\x58', '\x00', '\x00', 0, + '\x59', '\x00', '\x00', 0, + '\x5A', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char s_Utf8LowerToUpperEFBD[64 * 4] = { + 0, 0, 0, 0, + '\x41', '\x00', '\x00', 0, + '\x42', '\x00', '\x00', 0, + '\x43', '\x00', '\x00', 0, + '\x44', '\x00', '\x00', 0, + '\x45', '\x00', '\x00', 0, + '\x46', '\x00', '\x00', 0, + '\x47', '\x00', '\x00', 0, + '\x48', '\x00', '\x00', 0, + '\x49', '\x00', '\x00', 0, + '\x4A', '\x00', '\x00', 0, + '\x4B', '\x00', '\x00', 0, + '\x4C', '\x00', '\x00', 0, + '\x4D', '\x00', '\x00', 0, + '\x4E', '\x00', '\x00', 0, + '\x4F', '\x00', '\x00', 0, + '\x50', '\x00', '\x00', 0, + '\x51', '\x00', '\x00', 0, + '\x52', '\x00', '\x00', 0, + '\x53', '\x00', '\x00', 0, + '\x54', '\x00', '\x00', 0, + '\x55', '\x00', '\x00', 0, + '\x56', '\x00', '\x00', 0, + '\x57', '\x00', '\x00', 0, + '\x58', '\x00', '\x00', 0, + '\x59', '\x00', '\x00', 0, + '\x5A', '\x00', '\x00', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char *s_Utf8LowerToUpperTables[32] = { + 0, 0, 0, + s_Utf8LowerToUpperC3, + s_Utf8LowerToUpperC4, + s_Utf8LowerToUpperC5, + s_Utf8LowerToUpperC6, + s_Utf8LowerToUpperC7, + s_Utf8LowerToUpperC8, + s_Utf8LowerToUpperC9, + s_Utf8LowerToUpperCA, + 0, 0, 0, + s_Utf8LowerToUpperCE, + s_Utf8LowerToUpperCF, + s_Utf8LowerToUpperD0, + s_Utf8LowerToUpperD1, + s_Utf8LowerToUpperD2, + s_Utf8LowerToUpperD3, + s_Utf8LowerToUpperD4, + s_Utf8LowerToUpperD5, + s_Utf8LowerToUpperD6, + 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char *s_Utf8LowerToUpperTablesE1[64] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + s_Utf8LowerToUpperE1B8, + s_Utf8LowerToUpperE1B9, + s_Utf8LowerToUpperE1BA, + s_Utf8LowerToUpperE1BB, + s_Utf8LowerToUpperE1BC, + s_Utf8LowerToUpperE1BD, + s_Utf8LowerToUpperE1BE, + s_Utf8LowerToUpperE1BF, +}; + +static const char *s_Utf8LowerToUpperTablesE2[64] = { + 0, 0, 0, 0, 0, + s_Utf8LowerToUpperE285, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + s_Utf8LowerToUpperE293, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +static const char *s_Utf8LowerToUpperTablesEF[64] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + s_Utf8LowerToUpperEFBD, + 0, 0, +}; + +static const char **s_UtfLowerToUpperMap[16] = { + 0, + s_Utf8LowerToUpperTablesE1, + s_Utf8LowerToUpperTablesE2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + s_Utf8LowerToUpperTablesEF, +}; + +// *************************************************************************** +// *************************************************************************** +// *************************************************************************** + +#if 1 + +NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrdiff_t &i) +{ + unsigned char c = str[i]; + unsigned char d, e; + if (c < 0x80) + { + if (c >= 'A' && c <= 'Z') + { + // 1-byte UTF-8 + c += 'a' - 'A'; + } + } + else if ((c & 0xE0) == 0xC0 && ((d = str[i + 1]) & 0xC0) == 0x80) + { + // 2-byte UTF-8 + const char *table = s_Utf8UpperToLowerTables[c & 0x1F]; + if (table) + { + unsigned char idx = (d & 0x3F) << 2; + if (table[idx]) + { + res += &table[idx]; + i += 2; + return; + } + } + } + else if ((c & 0xF0) == 0xE0 && ((d = str[i + 1]) & 0xC0) == 0x80 && ((e = str[i + 2]) & 0xC0) == 0x80) + { + // 3-byte UTF-8 + const char **map = s_UtfUpperToLowerMap[c & 0x0F]; + if (map) + { + const char *table = map[d & 0x3F]; + if (table) + { + unsigned char idx = (d & 0x3F) << 2; + if (table[idx]) + { + res += &table[idx]; + i += 3; + return; + } + } + } + } + res += c; + ++i; +} + +// *************************************************************************** + +std::string toLower(const char *str) +{ + // UTF-8 toLower, tables generated from UTF-16 tables + std::string res; + for (ptrdiff_t i = 0; str[i];) + appendToLowerAsUtf8(res, str, i); + return res; +} + +// *************************************************************************** + +std::string toLower(const std::string &str) +{ + // UTF-8 toLower, tables generated from UTF-16 tables + std::string res; + res.reserve(str.size() + (str.size() >> 2)); + const char *cstr = &str[0]; + for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();) + appendToLowerAsUtf8(res, cstr, i); + return res; +} + +// *************************************************************************** + +void appendToLower(std::string &res, const char *str, ptrdiff_t &i) +{ + appendToLowerAsUtf8(res, str, i); +} + +// *************************************************************************** + +void appendToLower(std::string &res, const std::string &str, ptrdiff_t &i) +{ + appendToLowerAsUtf8(res, &str[0], i); +} + +// *************************************************************************** +// *************************************************************************** +// *************************************************************************** + +NL_FORCE_INLINE void appendToUpperAsUtf8(std::string &res, const char *str, ptrdiff_t &i) +{ + unsigned char c = str[i]; + unsigned char d, e; + if (c < 0x80) + { + if (c >= 'a' && c <= 'z') + { + // 1-byte UTF-8 + c -= 'a' - 'A'; + } + } + else if ((c & 0xE0) == 0xC0 && ((d = str[i + 1]) & 0xC0) == 0x80) + { + // 2-byte UTF-8 + const char *table = s_Utf8LowerToUpperTables[c & 0x1F]; + if (table) + { + unsigned char idx = (d & 0x3F) << 2; + if (table[idx]) + { + res += &table[idx]; + i += 2; + return; + } + } + } + else if ((c & 0xF0) == 0xE0 && ((d = str[i + 1]) & 0xC0) == 0x80 && ((e = str[i + 2]) & 0xC0) == 0x80) + { + // 3-byte UTF-8 + const char **map = s_UtfLowerToUpperMap[c & 0x0F]; + if (map) + { + const char *table = map[d & 0x3F]; + if (table) + { + unsigned char idx = (d & 0x3F) << 2; + if (table[idx]) + { + res += &table[idx]; + i += 3; + return; + } + } + } + } + res += c; + ++i; +} + +// *************************************************************************** + +std::string toUpper(const char *str) +{ + // UTF-8 toLower, tables generated from UTF-16 tables + std::string res; + for (ptrdiff_t i = 0; str[i];) + appendToUpperAsUtf8(res, str, i); + return res; +} + +// *************************************************************************** + +std::string toUpper(const std::string &str) +{ + // UTF-8 toLower, tables generated from UTF-16 tables + std::string res; + res.reserve(str.size() + (str.size() >> 2)); + const char *cstr = &str[0]; + for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();) + appendToUpperAsUtf8(res, cstr, i); + return res; +} + +// *************************************************************************** + +void appendToUpper(std::string &res, const char *str, ptrdiff_t &i) +{ + appendToUpperAsUtf8(res, str, i); +} + +// *************************************************************************** + +void appendToUpper(std::string &res, const std::string &str, ptrdiff_t &i) +{ + appendToUpperAsUtf8(res, &str[0], i); +} + +// *************************************************************************** +// *************************************************************************** +// *************************************************************************** + +static const char s_UpperAscii[] = { + 'A', 0, 'B', 0, 'C', 0, 'D', 0, 'E', 0, 'F', 0, 'G', 0, + 'H', 0, 'I', 0, 'J', 0, 'K', 0, 'L', 0, 'M', 0, 'N', 0, + 'O', 0, 'P', 0, 'Q', 0, 'R', 0, 'S', 0, 'T', 0, 'U', 0, + 'V', 0, 'W', 0, 'X', 0, 'Y', 0, 'Z', 0, 0, 0, 0, 0 +}; + +const char *fetchToUpperAsUtf8(const char **str) +{ + unsigned char c = *(*str); + unsigned char d, e; + if (c < 0x80) + { + if (c >= 'a' && c <= 'z') + { + // 1-byte UTF-8 + ++(*str); + return &s_UpperAscii[(c - 'a') << 1]; + } + } + else if ((c & 0xE0) == 0xC0 && ((d = (*str)[1]) & 0xC0) == 0x80) + { + // 2-byte UTF-8 + const char *table = s_Utf8LowerToUpperTables[c & 0x1F]; + if (table) + { + unsigned char idx = (d & 0x3F) << 2; + if (table[idx]) + { + (*str) += 2; + return &table[idx]; + } + } + } + else if ((c & 0xF0) == 0xE0 && ((d = (*str)[1]) & 0xC0) == 0x80 && ((e = (*str)[2]) & 0xC0) == 0x80) + { + // 3-byte UTF-8 + const char **map = s_UtfLowerToUpperMap[c & 0x0F]; + if (map) + { + const char *table = map[d & 0x3F]; + if (table) + { + unsigned char idx = (d & 0x3F) << 2; + if (table[idx]) + { + (*str) += 3; + return &table[idx]; + } + } + } + } + return NULL; +} + +int compareCaseInsensitive(const char *a, const char *b) +{ + // while (*a != 0 && *b != 0) + for (; ;) + { + const char *ca = fetchToUpperAsUtf8(&a); + const char *cb = fetchToUpperAsUtf8(&b); + if (!ca && !cb) + { + // Easy case, ASCII compare or junk + if (*a != *b) + { + if (*a > * b) return 1; + else return -1; + } + else if (!*a) // Equal and NUL, ends both + { + return 0; + } + ++a; + ++b; + } + else if (!cb) + { + // String a changed lowercase, iterate ca until NUL alongside b + nlassert(*ca); + do + { + if (*ca != *b) + { + if (*ca > *b) return 1; + else return -1; + } + ++ca; + ++b; + } while (*ca); + } + else if (!ca) + { + // String b changed lowercase, iterate a alongside cb until NUL + nlassert(*cb); + do + { + if (*a != *cb) + { + if (*a > *cb) return 1; + else return -1; + } + ++a; + ++cb; + } while (*cb); + } + else + { + // Both strings changed lowercase + if (ca != cb) // Only check if it's a different result + { + do + { + if (*ca != *cb) + { + if (*ca > *cb) return 1; + else return -1; + } + ++ca; + ++cb; + } while (*ca && *cb); + } + } + } + // if (*a == *b) return 0; + // if (*a > *b) return 1; + // return -1; +} + +int compareCaseInsensitive(const char *a, size_t lenA, const char *b, size_t lenB) +{ + const char *ma = a + lenA; + const char *mb = b + lenB; + for (; ;) + { + if (a >= ma) + { + if (b >= mb) + { + return 0; // Both strings ended + } + else + { + return 1; // A is longer + } + } + if (b >= mb) + { + return -1; // B is longer + } + const char *ca = fetchToUpperAsUtf8(&a); + const char *cb = fetchToUpperAsUtf8(&b); + if (!ca && !cb) + { + // Easy case, ASCII compare or junk + if (*a != *b) + { + if (*a > * b) return 1; + else return -1; + } + /* + else if (!*a) // Equal and NUL, ends both + { + return 0; + } + */ + ++a; + ++b; + } + else if (!cb) + { + // String a changed lowercase, iterate ca until NUL alongside b + nlassert(*ca); + do + { + if (*ca != *b) + { + if (*ca > *b) return 1; + else return -1; + } + ++ca; + ++b; + } while (*ca); + } + else if (!ca) + { + // String b changed lowercase, iterate a alongside cb until NUL + nlassert(*cb); + do + { + if (*a != *cb) + { + if (*a > *cb) return 1; + else return -1; + } + ++a; + ++cb; + } while (*cb); + } + else + { + // Both strings changed lowercase + if (ca != cb) // Only check if it's a different result + { + do + { + if (*ca != *cb) + { + if (*ca > *cb) return 1; + else return -1; + } + ++ca; + ++cb; + } while (*ca && *cb); + } + } + } +} + +// *************************************************************************** + +#else + +// *************************************************************************** + +static std::string toLowerAsUtf8(CUtfStringView sv) +{ + // UTF-16 implementation-based + std::string res; + res.reserve(sv.largestSize()); + for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + { + u32char c = *it; + if (c < 0x10000) + { + ucchar uc = c; + ucchar *result = toLowerUpperSearch(&uc, UnicodeUpperToLower); + if (result) + c = result[1]; + } + CUtfStringView::append(res, c); + } + return res; +} + +std::string toLowerAsUtf8(const char *str) +{ + return toLowerAsUtf8(CUtfStringView(str)); +} + +// *************************************************************************** + +std::string toLowerAsUtf8(const std::string &str) +{ + return toLowerAsUtf8(CUtfStringView(str)); +} + +// *************************************************************************** +// *************************************************************************** +// *************************************************************************** + +static std::string toUpperAsUtf8(CUtfStringView sv) +{ + std::string res; + res.reserve(sv.largestSize()); + for (CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) + { + u32char c = *it; + if (c < 0x10000) + { + ucchar uc = c; + ucchar *result = toLowerUpperSearch(&uc, UnicodeLowerToUpper); + if (result) + c = result[1]; + } + CUtfStringView::append(res, c); + } + return res; +} + +// *************************************************************************** + +std::string toUpperAsUtf8(const char *str) +{ + return toUpperAsUtf8(CUtfStringView(str)); +} + +// *************************************************************************** + +std::string toUpperAsUtf8(const std::string &str) +{ + return toUpperAsUtf8(CUtfStringView(str)); +} + +#endif + +// *************************************************************************** +// *************************************************************************** +// *************************************************************************** + +#if 0 + +std::string getUtf8(char32_t c) +{ + std::string res; + if (c < 0x80) + { + // Encode as 1 byte + res += (char)c; + } + else if (c < 0x0800) + { + // Encode as 2 bytes + res += (char)((c & 0x07C0) >> 6) | 0xC0; + res += (char)(c & 0x3F) | 0x80; + } + else + { + // Encode as 3 bytes + res += (char)((c & 0xF000) >> 12) | 0xE0; + res += (char)((c & 0x0FC0) >> 6) | 0x80; + res += (char)(c & 0x3F) | 0x80; + } + return res; +} + +void printStringMap(const std::string &name, std::map &m, bool trim) +{ + std::cout << "static const char " << name << "[" << (trim ? "64" : "256") << " * 4] = {\n"; + bool zero = false; + for (int i = 0; i < (trim ? 64 : 256); ++i) + { + int x = trim ? i + 0x80 : i; + if (m.find(x) == m.end()) + { + if (x % 8 == 7) + { + zero = false; + std::cout << "0, 0, 0, 0,\n"; + } + else + { + zero = true; + std::cout << "0, 0, 0, 0, "; + } + } + else + { + if (zero) std::cout << "\n"; + std::cout << "'\\x" << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (m[x].length() > 0 ? (unsigned char)m[x][0] : 0) + << "', '\\x" << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (m[x].length() > 1 ? (unsigned char)m[x][1] : 0) + << "', '\\x" << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (m[x].length() > 2 ? (unsigned char)m[x][2] : 0) + << "', 0,\n"; + zero = false; + } + } + if (zero) std::cout << "\n"; + std::cout << "};\n\n"; +} + +void printMapMap(const std::string &name, const std::string &strName, std::map> &m, bool trim) +{ + std::cout << "static const char *" << name << "[" << (trim ? "64" : "256") << " * 2] = {\n"; + bool zero = false; + for (int i = 0; i < (trim ? 64 : 256); ++i) + { + int x = trim ? (i + 0x80) : i; + if (m.find(x) == m.end()) + x = trim ? (i + 0xC0) : i; + if (m.find(x) == m.end()) + { + if (x % 32 == 1315) + { + zero = false; + std::cout << "0, \n"; + } + else + { + zero = true; + std::cout << "0, "; + } + } + else + { + if (zero) std::cout << "\n"; + std::stringstream n; + n << strName; + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)x; + std::cout << n.str() << ",\n"; + zero = false; + } + } + if (zero) std::cout << "\n"; + std::cout << "};\n\n"; +} + +void printMapMapMap(const std::string &name, const std::string &mapName, std::map>> &m, bool trim) +{ + std::cout << "static const char **" << name << "[" << (trim ? "64" : "256") << " * 2] = {\n"; + bool zero = false; + for (int i = 0; i < (trim ? 64 : 256); ++i) + { + int x = trim ? (i + 0x80) : i; + if (m.find(x) == m.end()) + x = trim ? (i + 0xC0) : i; + if (m.find(x) == m.end()) + { + if (x % 32 == 1315) + { + zero = false; + std::cout << "0, \n"; + } + else + { + zero = true; + std::cout << "0, "; + } + } + else + { + if (zero) std::cout << "\n"; + std::stringstream n; + n << mapName; + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)x; + std::cout << n.str() << ",\n"; + zero = false; + } + } + if (zero) std::cout << "\n"; + std::cout << "};\n\n"; +} + +void generate() +{ + std::map m1; + std::map> m2; + std::map>> m3; + for (int i = 0; i < sizeof(UnicodeLowerToUpper) / sizeof(UnicodeLowerToUpper[0]); i += 2) + { + std::string from = getUtf8(UnicodeLowerToUpper[i]); + std::string to = getUtf8(UnicodeLowerToUpper[i + 1]); + // assert(from.size() == to.size()); + if (from.length() == 1) + { + m1[from[0]] = to; + } + else if (from.length() == 2) + { + if (m2.find(from[0]) == m2.end()) + m2[from[0]] = std::map(); + m2[from[0]][from[1]] = to; + } + else if (from.length() == 3) + { + if (m3.find(from[0]) == m3.end()) + m3[from[0]] = std::map>(); + if (m3[from[0]].find(from[1]) == m3[from[0]].end()) + m3[from[0]][from[1]] = std::map(); + m3[from[0]][from[1]][from[2]] = to; + } + } + printStringMap("s_Utf8LowerToUpper", m1, false); + for (int i = 0; i < 256; ++i) + { + std::stringstream n; + n << "s_Utf8LowerToUpper"; + if (m2.find(i) != m2.end()) + { + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + printStringMap(n.str(), m2[i], true); + } + else if (m3.find(i) != m3.end()) + { + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + for (int j = 0; j < 256; ++j) + { + if (m3[i].find(j) != m3[i].end()) + { + std::stringstream nn; + nn << n.str(); + nn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)j; + printStringMap(nn.str(), m3[i][j], true); + } + } + } + } + printMapMap("s_Utf8LowerToUpperTables", "s_Utf8LowerToUpper", m2, true); + for (int i = 0; i < 256; ++i) + { + std::stringstream n; + n << "s_Utf8LowerToUpperTables"; + std::stringstream nn; + nn << "s_Utf8LowerToUpper"; + if (m3.find(i) != m3.end()) + { + n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + nn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i; + printMapMap(n.str(), nn.str(), m3[i], true); + } + } + printMapMapMap("s_UtfLowerToUpperMap", "s_Utf8LowerToUpperTables", m3, true); +} + +#endif + +// *************************************************************************** +// *************************************************************************** // *************************************************************************** } // NLMISC diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp new file mode 100644 index 000000000..17dbaea58 --- /dev/null +++ b/nel/src/misc/utf_string_view.cpp @@ -0,0 +1,308 @@ +// NeL - MMORPG Framework +// Copyright (C) 2020 Jan BOON (Kaetemi) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdmisc.h" + +// Project includes +#include + +// References: +// - https://twiserandom.com/unicode/unicode-encoding-utf-8-utf-16-utf-32/ +// - https://www.compart.com/en/unicode/U+1F30D +// - 0xF0 0x9F 0x8C 0x8D +// - 0xD83C 0xDF0D +// - 0x0001F30D + +namespace NLMISC +{ + +NL_FORCE_INLINE void appendUtf8(std::string &str, u32char c) +{ + if (c < 0x80) + { + // Encode as 1 byte + str += (char)c; + } + else if (c < 0x0800) + { + // Encode as 2 bytes + str += (char)((c & 0x07C0) >> 6) | 0xC0; + str += (char)(c & 0x3F) | 0x80; + } + else if (c < 0x010000) + { + // Encode as 3 bytes + str += (char)((c & 0xF000) >> 12) | 0xE0; + str += (char)((c & 0x0FC0) >> 6) | 0x80; + str += (char)(c & 0x3F) | 0x80; + } + else if (c < 0x110000) + { + // Encode as 4 bytes + str += (char)((c & 0x1C0000) >> 18) | 0xF0; + str += (char)((c & 0x03F000) >> 12) | 0x80; + str += (char)((c & 0x0FC0) >> 6) | 0x80; + str += (char)(c & 0x3F) | 0x80; + } + else + { + // Replacement character � + str += "\xEF\xB\xBD"; + } +} + +void CUtfStringView::append(std::string &str, u32char c) +{ + appendUtf8(str, c); +} + +std::string CUtfStringView::toUtf8(bool reEncode) const +{ + // Decode UTF and encode UTF-8 + // This implementation makes no attempt at fixing invalid codepoints + if (m_Iterator == utf8Iterator && !reEncode) + return std::string((const char *)m_Str, (const char *)((ptrdiff_t)m_Str + m_Size)); + std::string res; + res.reserve(m_Size); + for (iterator it(begin()), end(this->end()); it != end; ++it) + { + appendUtf8(res, *it); + } + return res; +} + +ucstring CUtfStringView::toUtf16(bool reEncode) const +{ + if (m_Iterator == utf16Iterator && !reEncode) + return ucstring((const ucchar *)m_Str, (const ucchar *)((ptrdiff_t)m_Str + m_Size)); + ucstring res; + res.reserve(m_Size << 1); + for (iterator it(begin()), end(this->end()); it != end; ++it) + { + u32char c = *it; + if (c < 0x10000) + { + res += c; + } + else + { + c -= 0x10000; + res += (c >> 10) | 0xD800; + res += (c & 0x3FF) | 0xDC00; + } + } + return res; +} + +::u32string CUtfStringView::toUtf32() const +{ + // Decode any UTF + // This implementation makes no attempt at fixing bad encoding + if (m_Iterator == utf32Iterator) + return ::u32string((const u32char *)m_Str, (const u32char *)((ptrdiff_t)m_Str + m_Size)); + ::u32string res; + res.reserve(m_Size << 2); + for (iterator it(begin()), end(this->end()); it != end; ++it) + res += *it; + return res; +} + +std::string CUtfStringView::toAscii() const +{ + std::string res; + res.reserve(m_Size); + for (iterator it(begin()), end(this->end()); it != end; ++it) + { + u32char c = *it; + if (c < 0x80) + res += c; + else + res += '?'; + } + return res; +} + +std::wstring CUtfStringView::toWide() const +{ +#ifdef NL_OS_WINDOWS + if (m_Iterator == utf16Iterator) + return std::wstring((const wchar_t *)m_Str, (const wchar_t *)((ptrdiff_t)m_Str + m_Size)); + std::wstring res; + res.reserve(m_Size << 1); + for (iterator it(begin()), end(this->end()); it != end; ++it) + { + u32char c = *it; + if (c < 0x10000) + { + res += c; + } + else + { + c -= 0x10000; + res += (c >> 10) | 0xD800; + res += (c & 0x3FF) | 0xDC00; + } + } + return res; +#else + if (m_Iterator == utf32Iterator) + return std::wstring((const wchar_t *)m_Str, (const wchar_t *)((ptrdiff_t)m_Str + m_Size)); + std::wstring res; + res.reserve(m_Size << 2); + for (iterator it(begin()), end(this->end()); it != end; ++it) + res += *it; + return res; +#endif +} + +size_t CUtfStringView::count() const +{ + size_t res = 0; + for (iterator it(begin()), end(this->end()); it != end; ++it) + ++res; + return res; +} + +u32char CUtfStringView::utf8Iterator(const void **addr) +{ + // Decode UTF-8 + // This implementation makes no attempt at fixing bad encoding, except for bad UTF-16 surrogate pairs + // Invalid characters are replaced with the replacement character + const uint8 **pp = reinterpret_cast(addr); + u32char c0 = **pp; + ++(*pp); + if (c0 >= 0x80) + { + if (c0 < 0xC0) + { + // Replacement character � + return 0xFFFD; + } + uint8 cx = **pp; + if ((cx & 0xC0) == 0x80) + { + ++(*pp); + c0 &= 0x3F; // Drop first two bits + c0 <<= 6; + c0 |= (cx & 0x3F); // 12 bits now (6 + 6), 2-byte encoding + if (c0 & 0x800) + { + cx = **pp; + if ((cx & 0xC0) == 0x80) + { + ++(*pp); + c0 &= 0x07FF; // Drop first bit + c0 <<= 6; + c0 |= (cx & 0x3F); // 17 bits now (12 - 1 + 6), 3-byte encoding + if (c0 & 0x10000) + { + cx = **pp; + if ((cx & 0xC0) == 0x80) + { + ++(*pp); + c0 &= 0xFFFF; // Drop first bit + c0 <<= 6; + c0 |= (cx & 0x3F); // 22 bits now (17 - 1 + 6), 4-byte encoding + if (c0 >= 0x110000) + { + // Replacement character � + return 0xFFFD; + } + } + else + { + // Replacement character � + return 0xFFFD; + } + } + else if ((c0 & 0xFC00) == 0xD800) // Higher bits of nutcase UTF-16 encoded as UTF-8 + { + uint8 cy; + if ((*pp)[0] == 0xED && ((cx = (*pp)[1]) & 0xF0) == 0xB0 && ((cy = (*pp)[2]) & 0xC0) == 0x80) + { + // Lower bits of nutcase UTF-16 encoded as UTF-8 + (*pp) += 3; + uint16 c1 = (cx & 0x0F); + c1 <<= 6; + c1 |= (cy & 0x3F); + c0 &= 0x03FF; + c0 <<= 10; + c0 |= (c1 & 0x03FF); + c0 += 0x10000; + } + else + { + // Replacement character � + return 0xFFFD; + } + } + else if ((c0 & 0xFC00) == 0xDC00) // Lower bits of nutcase UTF-16 encoded as UTF-8 + { + // Replacement character � + return 0xFFFD; + } + } + else + { + // Replacement character � + return 0xFFFD; + } + } + } + else + { + // Replacement character � + return 0xFFFD; + } + } + return c0; +} + +u32char CUtfStringView::utf16Iterator(const void **addr) +{ + // Decode UTF-16 + // This implementation makes no attempt at fixing bad encoding + const uint16 **pp = reinterpret_cast(addr); + u32char c0 = **pp; + ++(*pp); + if ((c0 & 0xFC00) == 0xD800) // Higher bits + { + uint16 c1 = **pp; + if ((c1 & 0xFC00) == 0xDC00) // Lower bits + { + ++(*pp); + c0 &= 0x03FF; + c0 <<= 10; + c0 |= (c1 & 0x03FF); + c0 += 0x10000; + } + } + return c0; +} + +u32char CUtfStringView::utf32Iterator(const void **addr) +{ + // UTF-32 + // This implementation makes no attempt at fixing bad encoding + const u32char **pp = reinterpret_cast(addr); + u32char c = **pp; + ++(*pp); + return c; +} + +} /* namespace NLMISC */ + +/* end of file */ diff --git a/nel/src/misc/win_displayer.cpp b/nel/src/misc/win_displayer.cpp index 7a0045c17..50bef6030 100644 --- a/nel/src/misc/win_displayer.cpp +++ b/nel/src/misc/win_displayer.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/misc/win_event_emitter.cpp b/nel/src/misc/win_event_emitter.cpp index 5b6860794..dfc385bd9 100644 --- a/nel/src/misc/win_event_emitter.cpp +++ b/nel/src/misc/win_event_emitter.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -162,11 +162,24 @@ bool CWinEventEmitter::processMessage (HWND hWnd, uint32 msg, WPARAM wParam, LPA server->postEvent (new CEventKeyUp ((NLMISC::TKey)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this)); } break; +#ifdef WM_UNICHAR + 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; +#endif case WM_CHAR: if (_KeyboardEventsEnabled) { //if (wParam < KeyCount) //nlinfo("WM_CHAR with %u", wParam); +#ifndef WM_UNICHAR + // FIXME: Combine UTF-16 pairs +#endif server->postEvent (new CEventChar ((ucchar)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this)); } break; diff --git a/nel/src/misc/win_thread.cpp b/nel/src/misc/win_thread.cpp index 0de191d55..6f45594ca 100644 --- a/nel/src/misc/win_thread.cpp +++ b/nel/src/misc/win_thread.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2012-2014 Jan BOON (Kaetemi) +// Copyright (C) 2012-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -209,11 +209,11 @@ void CWinThread::start () ThreadHandle = (void *) ::CreateThread (NULL, 0, ProxyFunc, this, 0, (DWORD *)&ThreadId); // nldebug("NLMISC: thread %x started for runnable '%x'", typeid( Runnable ).name()); // OutputDebugString(toString(NL_LOC_MSG " NLMISC: thread %x started for runnable '%s'\n", ThreadId, typeid( *Runnable ).name()).c_str()); - SetThreadPriorityBoost (ThreadHandle, TRUE); // FALSE == Enable Priority Boost if (ThreadHandle == NULL) { throw EThread ( "Cannot create new thread" ); } + SetThreadPriorityBoost (ThreadHandle, TRUE); // FALSE == Enable Priority Boost _SuspendCount = 0; } diff --git a/nel/src/net/unified_network.cpp b/nel/src/net/unified_network.cpp index 5a6034e18..0ac8b1c21 100644 --- a/nel/src/net/unified_network.cpp +++ b/nel/src/net/unified_network.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014-2016 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -2090,6 +2090,14 @@ void CUnifiedNetwork::addNetworkAssociation (const string &networkName, uint8 ni void CUnifiedNetwork::callServiceUpCallback (const std::string &serviceName, TServiceId sid, bool callGlobalCallback) { + std::pair pss = std::make_pair(serviceName, sid); + if (_NotifiedUpCallbacks.find(pss) != _NotifiedUpCallbacks.end()) + { + nlwarning("HNETL5: Attempt to call service UP callback twice for '%s', ignored!", serviceName.c_str()); + return; + } + _NotifiedUpCallbacks.insert(pss); + // now we warn the user CUnifiedNetwork::TNameMappedCallback::iterator it = _UpCallbacks.find(serviceName); if (it != _UpCallbacks.end()) @@ -2119,6 +2127,14 @@ void CUnifiedNetwork::callServiceUpCallback (const std::string &serviceName, TSe void CUnifiedNetwork::callServiceDownCallback (const std::string &serviceName, TServiceId sid, bool callGlobalCallback) { + std::pair pss = std::make_pair(serviceName, sid); + if (_NotifiedUpCallbacks.find(pss) == _NotifiedUpCallbacks.end()) + { + nlwarning("HNETL5: Attempt to call service DOWN callback twice for '%s', ignored!", serviceName.c_str()); + return; + } + _NotifiedUpCallbacks.erase(pss); + // now we warn the user CUnifiedNetwork::TNameMappedCallback::iterator it = _DownCallbacks.find(serviceName); if (it != _DownCallbacks.end()) diff --git a/nel/src/pacs/build_indoor.cpp b/nel/src/pacs/build_indoor.cpp index f97dddfa7..e1207235d 100644 --- a/nel/src/pacs/build_indoor.cpp +++ b/nel/src/pacs/build_indoor.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/pacs/move_container.cpp b/nel/src/pacs/move_container.cpp index 7c346aed4..35b7ddcd6 100644 --- a/nel/src/pacs/move_container.cpp +++ b/nel/src/pacs/move_container.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010-2019 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -418,13 +421,13 @@ void CMoveContainer::updateCells (CMovePrimitive *primitive, uint8 worldImage) /* // Check BB width not too large if (wI->getBBXMax() - wI->getBBXMin() > _CellWidth) { - nlwarning ("Primitives have moved more than a cell."); + nlwarning ("Primitives have moved more than a cell, width: %f.", (float)(wI->getBBXMax() - wI->getBBXMin())); } // Check BB height not too large if (wI->getBBYMax() - wI->getBBYMin() > _CellHeight) { - nlwarning ("Primitives have moved more than a cell."); + nlwarning ("Primitives have moved more than a cell, height: %f.", (float)(wI->getBBYMax() - wI->getBBYMin())); } */ #endif diff --git a/nel/src/sound/audio_decoder.cpp b/nel/src/sound/audio_decoder.cpp index db87bd990..57fc8ead8 100644 --- a/nel/src/sound/audio_decoder.cpp +++ b/nel/src/sound/audio_decoder.cpp @@ -7,7 +7,7 @@ */ // NeL - MMORPG Framework -// Copyright (C) 2008-2019 Jan BOON (Kaetemi) +// Copyright (C) 2008-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/sound/driver/xaudio2/source_xaudio2.cpp b/nel/src/sound/driver/xaudio2/source_xaudio2.cpp index 785ce0565..13a613d6d 100644 --- a/nel/src/sound/driver/xaudio2/source_xaudio2.cpp +++ b/nel/src/sound/driver/xaudio2/source_xaudio2.cpp @@ -1,5 +1,5 @@ // NeL - MMORPG Framework -// Copyright (C) 2008-2015 Jan BOON (Kaetemi) +// Copyright (C) 2008-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -480,7 +480,7 @@ void CSourceXAudio2::setLooping(bool l) _SourceVoice->GetState(&voice_state); if (voice_state.BuffersQueued) { - nlwarning(NLSOUND_XAUDIO2_PREFIX "Not playing but buffer already queued while switching loop mode!?! Flush and requeue"); + // nlwarning(NLSOUND_XAUDIO2_PREFIX "Not playing but buffer already queued while switching loop mode!?! Flush and requeue"); if (FAILED(_SourceVoice->FlushSourceBuffers())) nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers"); // queue buffer with correct looping parameters diff --git a/nel/src/sound/music_channel_fader.cpp b/nel/src/sound/music_channel_fader.cpp index 70ab890d2..3e1b0f1cf 100644 --- a/nel/src/sound/music_channel_fader.cpp +++ b/nel/src/sound/music_channel_fader.cpp @@ -1,5 +1,5 @@ // NeL - MMORPG Framework -// Copyright (C) 2008-2012 Jan BOON (Kaetemi) +// Copyright (C) 2008-2020 Jan BOON (Kaetemi) // // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) diff --git a/nel/src/sound/stream_file_source.cpp b/nel/src/sound/stream_file_source.cpp index 50d9bda97..a7b45b948 100644 --- a/nel/src/sound/stream_file_source.cpp +++ b/nel/src/sound/stream_file_source.cpp @@ -7,7 +7,7 @@ */ // NeL - MMORPG Framework -// Copyright (C) 2012 Jan BOON (Kaetemi) +// Copyright (C) 2012-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/src/web/http_client_curl.cpp b/nel/src/web/http_client_curl.cpp index e61baa89f..10bb0776c 100644 --- a/nel/src/web/http_client_curl.cpp +++ b/nel/src/web/http_client_curl.cpp @@ -191,8 +191,11 @@ bool CCurlHttpClient::receive(string &res, bool verbose) // *************************************************************************** void CCurlHttpClient::disconnect() { - curl_easy_cleanup(_Curl); - _CurlStruct = NULL; + if (_CurlStruct) + { + curl_easy_cleanup(_Curl); + _CurlStruct = NULL; + } curl_global_cleanup(); } diff --git a/nel/tools/3d/build_clodtex/lod_texture_builder.cpp b/nel/tools/3d/build_clodtex/lod_texture_builder.cpp index b0ff316df..05bb184bb 100644 --- a/nel/tools/3d/build_clodtex/lod_texture_builder.cpp +++ b/nel/tools/3d/build_clodtex/lod_texture_builder.cpp @@ -1,6 +1,9 @@ // NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/nel/tools/3d/ig_elevation/main.cpp b/nel/tools/3d/ig_elevation/main.cpp index 126c66c62..4856051c3 100644 --- a/nel/tools/3d/ig_elevation/main.cpp +++ b/nel/tools/3d/ig_elevation/main.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/tools/3d/panoply_preview/main_window.cpp b/nel/tools/3d/panoply_preview/main_window.cpp index 1b743d439..1195642e8 100644 --- a/nel/tools/3d/panoply_preview/main_window.cpp +++ b/nel/tools/3d/panoply_preview/main_window.cpp @@ -1,5 +1,5 @@ // NeL - MMORPG Framework -// Copyright (C) 2014-2016 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -53,7 +53,7 @@ namespace { QString nli18n(const char *label) { - return QString::fromUtf16(CI18N::get(label).c_str()); + return QString::fromUtf16((const ushort *)CI18N::get(label).c_str()); } } /* anonymous namespace */ diff --git a/nel/tools/3d/plugin_max/nel_3dsmax_shared/string_common.h b/nel/tools/3d/plugin_max/nel_3dsmax_shared/string_common.h index 4a331a78a..22b16e981 100644 --- a/nel/tools/3d/plugin_max/nel_3dsmax_shared/string_common.h +++ b/nel/tools/3d/plugin_max/nel_3dsmax_shared/string_common.h @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp b/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp index 48bf1d921..2f00c9c63 100644 --- a/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp +++ b/nel/tools/3d/plugin_max/nel_patch_converter/script.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2011-2019 Jan BOON (Kaetemi) +// Copyright (C) 2011-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/nel/tools/build_gamedata/c1_shard_patch.py b/nel/tools/build_gamedata/c1_shard_patch.py index b67b053a8..e67314cd8 100755 --- a/nel/tools/build_gamedata/c1_shard_patch.py +++ b/nel/tools/build_gamedata/c1_shard_patch.py @@ -49,6 +49,9 @@ printLog(log, "-------") printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time()))) printLog(log, "") +# Find tools +SevenZip = findTool(log, ToolDirectories, SevenZipTool, ToolSuffix) + # List the directories that will be used archiveDirectories = [ ] for dir in InstallShardDataDirectories: @@ -89,23 +92,29 @@ else: printLog(log, "") if not args.admininstall: - printLog(log, ">>> Create new version <<<") - newVersion = 1 - vstr = str(newVersion).zfill(6) - vpath = PatchmanBridgeServerDirectory + "/" + vstr - while os.path.exists(vpath): - newVersion = newVersion + 1 + if SevenZip == "": + toolLogFail(log, SevenZipTool, ToolSuffix) + else: + printLog(log, ">>> Create new version <<<") + newVersion = 1 vstr = str(newVersion).zfill(6) vpath = PatchmanBridgeServerDirectory + "/" + vstr - mkPath(log, vpath) - for dir in archiveDirectories: - mkPath(log, ShardInstallDirectory + "/" + dir) - tgzPath = vpath + "/" + dir + ".tgz" - printLog(log, "WRITE " + tgzPath) - tar = tarfile.open(tgzPath, "w:gz") - tar.add(ShardInstallDirectory + "/" + dir, arcname = dir) - tar.close() - printLog(log, "") + while os.path.exists(vpath): + newVersion = newVersion + 1 + vstr = str(newVersion).zfill(6) + vpath = PatchmanBridgeServerDirectory + "/" + vstr + mkPath(log, vpath) + for dir in archiveDirectories: + mkPath(log, ShardInstallDirectory + "/" + dir) + # tgzPath = vpath + "/" + dir + ".tgz" + # printLog(log, "WRITE " + tgzPath) + # tar = tarfile.open(tgzPath, "w:gz") + # tar.add(ShardInstallDirectory + "/" + dir, arcname = dir) + # tar.close() + sevenZipPath = vpath + "/" + dir + ".7z" + printLog(log, "WRITE " + sevenZipPath) + subprocess.call([ SevenZip, "a", sevenZipPath, ShardInstallDirectory + "/" + dir ]) + printLog(log, "") log.close() if os.path.isfile("c1_shard_patch.log"): diff --git a/nel/tools/build_gamedata/configuration/tools.py b/nel/tools/build_gamedata/configuration/tools.py index ebb1d07da..ee933c8e9 100755 --- a/nel/tools/build_gamedata/configuration/tools.py +++ b/nel/tools/build_gamedata/configuration/tools.py @@ -98,3 +98,4 @@ PatchGenTool = "patch_gen" TranslationToolsTool = "translation_tools" BuildWorldPackedColTool = "build_world_packed_col" R2IslandsTexturesTool = "r2_islands_textures" +SevenZipTool = "7za" diff --git a/nel/tools/build_gamedata/d1_client_patch.py b/nel/tools/build_gamedata/d1_client_patch.py index ea4cc742c..5237542f6 100755 --- a/nel/tools/build_gamedata/d1_client_patch.py +++ b/nel/tools/build_gamedata/d1_client_patch.py @@ -123,7 +123,9 @@ else: printLog(log, "") printLog(log, ">>> Make bnp <<<") targetPath = ClientPatchDirectory + "/bnp" + tagPath = ClientPatchDirectory + "/bnp_tag" mkPath(log, targetPath) + mkPath(log, tagPath) for category in InstallClientData: packExt = ".bnp" if (category["StreamedPackages"]): @@ -133,25 +135,32 @@ else: sourcePath = InstallDirectory + "/" + package[0] mkPath(log, sourcePath) targetBnp = targetPath + "/" + package[0] + packExt + tagBnp = tagPath + "/" + package[0] + packExt + ".tag" if (len(package[1]) > 0): targetBnp = targetPath + "/" + package[1][0] + tagBnp = tagPath + "/" + package[1][0] + ".tag" printLog(log, "TARGET " + package[1][0]) needUpdateBnp = 1 if (len(package) > 2): - needUpdateBnp = needUpdate(log, sourcePath + "/" + package[2], targetBnp) + needUpdateBnp = needUpdate(log, sourcePath + "/" + package[2], tagBnp) else: - needUpdateBnp = needUpdateDirNoSubdirFile(log, sourcePath, targetBnp) + needUpdateBnp = needUpdateDirNoSubdirFile(log, sourcePath, tagBnp) if (needUpdateBnp): + subRet = 0 + open(tagBnp, 'a').close() + os.utime(tagBnp, None) if (category["StreamedPackages"]): printLog(log, "SNP " + targetBnp) # cwDir = os.getcwd().replace("\\", "/") # toolDir = os.path.dirname(Lzma).replace("\\", "/") # os.chdir(toolDir) - subprocess.call([ SnpMake, "-p", sourcePath, targetBnp, ClientPatchDirectory + "/stream" ] + package[1][1:]) + subRet = subprocess.call([ SnpMake, "-p", sourcePath, targetBnp, ClientPatchDirectory + "/stream" ] + package[1][1:]) # os.chdir(cwDir) else: printLog(log, "BNP " + targetBnp) - subprocess.call([ BnpMake, "-p", sourcePath, "-o", targetBnp ] + package[1][1:]) + subRet = subprocess.call([ BnpMake, "-p", sourcePath, "-o", targetBnp ] + package[1][1:]) + if (subRet != 0): + os.remove(tagBnp) else: printLog(log, "SKIP " + targetBnp) printLog(log, "") diff --git a/nel/tools/build_gamedata/processes/shape/2_build.py b/nel/tools/build_gamedata/processes/shape/2_build.py index f261473fe..86a3b6a99 100755 --- a/nel/tools/build_gamedata/processes/shape/2_build.py +++ b/nel/tools/build_gamedata/processes/shape/2_build.py @@ -74,6 +74,13 @@ else: printLog(log, ">>> Copy Shape <<<") copyFilesExtNoTreeIfNeeded(log, shapeDirectory, ExportBuildDirectory + "/" + ShapeClodtexBuildDirectory, ".shape") +printLog(log, ">>> Copy non-ShadowSkin non-CLodTex Shape <<<") +shapeDirectory = ExportBuildDirectory + "/" + ShapeNotOptimizedExportDirectory +mkPath(log, shapeDirectory) +mkPath(log, ExportBuildDirectory + "/" + ShapeClodtexBuildDirectory) +copyFilesExtNoTreeIfNeeded(log, shapeDirectory, ExportBuildDirectory + "/" + ShapeClodtexBuildDirectory, ".shape") +shapeDirectory = ExportBuildDirectory + "/" + ShapeClodtexBuildDirectory + # copy lightmap_not_optimized to lightmap printLog(log, ">>> Optimize lightmaps <<<") loPathLightmapsOriginal = ExportBuildDirectory + "/" + ShapeLightmapNotOptimizedExportDirectory diff --git a/nel/tools/pacs/build_rbank/prim_checker.cpp b/nel/tools/pacs/build_rbank/prim_checker.cpp index 3b8c11bf9..e4c2b0b91 100644 --- a/nel/tools/pacs/build_rbank/prim_checker.cpp +++ b/nel/tools/pacs/build_rbank/prim_checker.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/CMakeLists.txt b/ryzom/client/src/CMakeLists.txt index 7e1f89348..1b224ee8d 100644 --- a/ryzom/client/src/CMakeLists.txt +++ b/ryzom/client/src/CMakeLists.txt @@ -21,7 +21,7 @@ IF(WITH_RYZOM_CLIENT) ENDIF() FILE(GLOB CFG ../*.cfg) - FILE(GLOB SRC *.cpp *.h motion/*.cpp motion/*.h client.rc) + FILE(GLOB SRC *.cpp *.h motion/*.cpp motion/*.h client.rc *.manifest) FILE(GLOB SRC_INTERFACE interface_v3/*.h interface_v3/*.cpp) FILE(GLOB SRC_MODE motion/modes/*.cpp motion/modes/*.h) FILE(GLOB SRC_R2 r2/*.h r2/*.cpp r2/dmc/*.h r2/dmc/*.cpp) diff --git a/ryzom/client/src/actions.cpp b/ryzom/client/src/actions.cpp index c9b43795e..c9d6a73e5 100644 --- a/ryzom/client/src/actions.cpp +++ b/ryzom/client/src/actions.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -524,9 +525,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)) ret += CI18N::get("uiKeySHIFT") + "+"; if ((KeyButtons & ctrlKeyButton) && (Key != 0x11)) diff --git a/ryzom/client/src/actions.h b/ryzom/client/src/actions.h index a36fd082b..99a4d15d7 100644 --- a/ryzom/client/src/actions.h +++ b/ryzom/client/src/actions.h @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -66,7 +66,7 @@ public: void init (NLMISC::TKey key, NLMISC::TKeyButton keyButtons); /// Get the combo in human readable form - ucstring toUCString() const; + std::string toString() const; // For maps bool operator<(const CCombo &other) const diff --git a/ryzom/client/src/bg_downloader_access.cpp b/ryzom/client/src/bg_downloader_access.cpp index 61364ea5f..e2500eaa6 100644 --- a/ryzom/client/src/bg_downloader_access.cpp +++ b/ryzom/client/src/bg_downloader_access.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2012 Jan BOON (Kaetemi) +// Copyright (C) 2012-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -230,7 +230,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run() // that the downloader is still running and in slave mode if (!isDownloaderProcessRunning() && getDownloaderMode() != DownloaderMode_Slave) { - throw EDownloadException(CI18N::get("uiBGD_DownloaderStopped").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_DownloaderStopped")); } } else @@ -429,7 +429,7 @@ void CBGDownloaderAccess::CDownloadCoTask::createDownloaderProcess() BOOL ok = NLMISC::launchProgram(BGDownloaderName, Parent->_CommandLine); if (!ok) { - throw EDownloadException(CI18N::get("uiBGD_LaunchError").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_LaunchError")); } } else @@ -458,7 +458,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader() { nlwarning("CBGDownloaderAccess::CDownloadCoTask : detected shared memory segment, with NULL pid"); // some problem here ... - throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance")); } } 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"); // 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 @@ -475,7 +475,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader() if (!Parent->_RyzomInstPIDPtr) { // really, really bad luck ... - throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_MultipleRyzomInstance")); } *(uint32 *) Parent->_RyzomInstPIDPtr = (uint32) GetCurrentProcessId(); @@ -514,7 +514,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader() const uint32 totalTries = 7; 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); NLMISC::CMemStream dummyMsg; @@ -758,7 +758,7 @@ void CBGDownloaderAccess::CDownloadCoTask::waitMsg(BGDownloader::TMsgType wanted if (msgType != wantedMsgType) { 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()) { - throw EDownloadException(CI18N::get("uiBGD_DownloaderDisconnected").toUtf8()); + throw EDownloadException(CI18N::get("uiBGD_DownloaderDisconnected")); } } diff --git a/ryzom/client/src/candidate.h b/ryzom/client/src/candidate.h index aa190111a..41d04e681 100644 --- a/ryzom/client/src/candidate.h +++ b/ryzom/client/src/candidate.h @@ -15,7 +15,7 @@ // along with this program. If not, see . - +#if 0 #ifndef CL_CANDIDATE_H #define CL_CANDIDATE_H @@ -39,3 +39,4 @@ struct Candidate #endif // CL_CANDIDATE_H +#endif \ No newline at end of file diff --git a/ryzom/client/src/character_cl.cpp b/ryzom/client/src/character_cl.cpp index b371e4765..2cf396531 100644 --- a/ryzom/client/src/character_cl.cpp +++ b/ryzom/client/src/character_cl.cpp @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2016 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -809,8 +809,8 @@ bool CCharacterCL::build(const CEntitySheet *sheet) // virtual if (Type == Fauna) { // Get the fauna name in the sheet - const ucstring creatureName(STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id)); - if (creatureName.find(ucstring("Id); + if (!FINAL_VERSION || !NLMISC::startsWith(creatureName, "getAnimSetBaseName(), _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet, _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet, !modeWithHiddenItems())) { - //nlwarning("CH:computeAnimSet:%d: pb when trying to compute the animset. Sheet Id '%u(%s)'.", _Slot, _SheetId.asInt(), _SheetId.toString().c_str()); + nlwarning("CH:computeAnimSet:%d: pb when trying to compute the animset. Sheet Id '%u(%s)'.", _Slot, _SheetId.asInt(), _SheetId.toString().c_str()); } }// computeAnimSet // @@ -3360,7 +3360,7 @@ void CCharacterCL::showOrHideBodyParts( bool objectsVisible ) lHandInstIdx = SLOTTYPE::LEFT_HAND_SLOT; // hide gloves(armor) if player has magician amplifier - if( _Items[rHandInstIdx].Sheet && (_Items[rHandInstIdx].Sheet->ItemType == ITEM_TYPE::MAGICIAN_STAFF) ) + if( _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet && (_Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet->ItemType == ITEM_TYPE::MAGICIAN_STAFF) ) { if( !_Instances[SLOTTYPE::HANDS_SLOT].Current.empty() ) _Instances[SLOTTYPE::HANDS_SLOT].Current.hide(); @@ -3378,8 +3378,9 @@ void CCharacterCL::showOrHideBodyParts( bool objectsVisible ) if( !objectsVisible ) { // Right Hand + nlassert(SLOTTYPE::RIGHT_HAND_SLOT < _Items.size() && SLOTTYPE::LEFT_HAND_SLOT < _Items.size()); if(rHandInstIdx<_Instances.size()) - if( !(_Items[rHandInstIdx].Sheet && _Items[rHandInstIdx].Sheet->NeverHideWhenEquipped ) ) + if( !(_Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet && _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet->NeverHideWhenEquipped ) ) if(!_Instances[rHandInstIdx].Current.empty()) { _Instances[rHandInstIdx].Current.hide(); @@ -3387,7 +3388,7 @@ void CCharacterCL::showOrHideBodyParts( bool objectsVisible ) } // Left Hand if(lHandInstIdx <_Instances.size()) - if( !(_Items[lHandInstIdx].Sheet && _Items[lHandInstIdx].Sheet->NeverHideWhenEquipped ) ) + if( !(_Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet && _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet->NeverHideWhenEquipped ) ) if(!_Instances[lHandInstIdx].Current.empty()) { _Instances[lHandInstIdx].Current.hide(); @@ -7588,7 +7589,7 @@ void CCharacterCL::displayName() //--------------------------------------------------- void CCharacterCL::drawName(const NLMISC::CMatrix &mat) // virtual { - const ucstring &ucname = getEntityName(); + const string &ucname = getEntityName(); if(!getEntityName().empty()) { // If there is no extended name, just display the name @@ -7615,8 +7616,8 @@ void CCharacterCL::drawName(const NLMISC::CMatrix &mat) // virtual { if(_Sheet != 0) { - const ucstring name(STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id)); - if (name.find(ucstring("Id); + if (!FINAL_VERSION || !NLMISC::startsWith(name, "render3D(mat, name); } } @@ -7673,9 +7674,9 @@ void CCharacterCL::displayModifiers() // virtual } else if (TimeInSec >= mod.Time) { - ucstring hpModifier; + string hpModifier; if (mod.Text.empty()) - hpModifier = ucstring(toString("%d", mod.Value)); + hpModifier = toString("%d", mod.Value); else hpModifier = mod.Text; double t = TimeInSec-mod.Time; @@ -9293,14 +9294,14 @@ const char *CCharacterCL::getBoneNameFromBodyPart(BODY::TBodyPart part, BODY::TS const CItemSheet *CCharacterCL::getRightHandItemSheet() const { if (_RHandInstIdx == CEntityCL::BadIndex) return NULL; - return _Items[_RHandInstIdx].Sheet; + return _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet; } // ********************************************************************************************* const CItemSheet *CCharacterCL::getLeftHandItemSheet() const { if (_LHandInstIdx == CEntityCL::BadIndex) return NULL; - return _Items[_LHandInstIdx].Sheet; + return _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet; } // *************************************************************************** @@ -10366,7 +10367,7 @@ NLMISC_COMMAND(pvpMode, "modify pvp mode", "[ ]") str+="in_safe_zone "; if( pvpMode&PVP_MODE::PvpSafe) str+="safe "; - IM->displaySystemInfo(ucstring(str)); + IM->displaySystemInfo(str); nlinfo(" %s",str.c_str()); } else diff --git a/ryzom/client/src/client_cfg.cpp b/ryzom/client/src/client_cfg.cpp index 9d030cdca..82d8ef85f 100644 --- a/ryzom/client/src/client_cfg.cpp +++ b/ryzom/client/src/client_cfg.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2010-2019 Jan BOON (Kaetemi) +// Copyright (C) 2010-2020 Jan BOON (Kaetemi) // Copyright (C) 2011-2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) // @@ -2261,14 +2261,13 @@ string CClientConfig::getHtmlLanguageCode() const } // *************************************************************************** -ucstring CClientConfig::buildLoadingString( const ucstring& ucstr ) const +string CClientConfig::buildLoadingString( const string& ucstr ) const { if( LoadingStringCount > 0 ) { uint index = rand()%LoadingStringCount; - string tipId = "uiLoadingString"+toString(index); - ucstring randomUCStr = CI18N::get(tipId); - return randomUCStr; + string tipId = "uiLoadingString" + toString(index); + return CI18N::get(tipId); } else return ucstr; diff --git a/ryzom/client/src/client_cfg.h b/ryzom/client/src/client_cfg.h index 16a1e9e0c..db4a3b11c 100644 --- a/ryzom/client/src/client_cfg.h +++ b/ryzom/client/src/client_cfg.h @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2010-2014 Jan BOON (Kaetemi) +// Copyright (C) 2010-2020 Jan BOON (Kaetemi) // Copyright (C) 2011-2012 Matt RAYKOWSKI (sfb) // // This program is free software: you can redistribute it and/or modify @@ -891,10 +891,10 @@ public: float getActualLandscapeThreshold() const; // Return LanguageCode but if "wk", then return "en" - string getHtmlLanguageCode() const; + std::string getHtmlLanguageCode() const; // return a random loading tip or, if there are not, return the string in argument - ucstring buildLoadingString( const ucstring& ucstr ) const; + std::string buildLoadingString(const std::string &ucstr) const; /// get the path to client_default.cfg including the filename itself. bool getDefaultConfigLocation(std::string& fileLocation) const; diff --git a/ryzom/client/src/client_chat_manager.cpp b/ryzom/client/src/client_chat_manager.cpp index 9d222a1b7..ec8da3eb1 100644 --- a/ryzom/client/src/client_chat_manager.cpp +++ b/ryzom/client/src/client_chat_manager.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -240,7 +241,7 @@ CClientChatManager::CClientChatManager() } //------------------------------------------------------- -const ucstring *CClientChatManager::cycleLastTell() +const string *CClientChatManager::cycleLastTell() { if (_TellPeople.empty()) return NULL; _TellPeople.push_front(_TellPeople.back()); @@ -281,14 +282,14 @@ void CClientChatManager::init( const string& /* staticDBFileName */ ) // chat // //----------------------------------------------- -void CClientChatManager::chat( const ucstring& strIn, bool isChatTeam ) +void CClientChatManager::chat( const string& strIn, bool isChatTeam ) { // Truncate to 255 chars max (because of server restriction) - ucstring str= strIn.substr(0,255); + ucstring str= ucstring(strIn).substr(0,255); // FIXME: UTF-8 (serial) // send str to IOS CBitMemStream bms; - string msgType; + const char *msgType; if (isChatTeam) { @@ -302,13 +303,13 @@ void CClientChatManager::chat( const ucstring& strIn, bool isChatTeam ) if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { - bms.serial( str ); + bms.serial( str ); // FIXME: UTF-8 (serial) NetMngr.push( bms ); //nlinfo("impulseCallBack : %s %s sent", msgType.c_str(), str.toString().c_str()); } else { - nlwarning(" unknown message name : %s", msgType.c_str()); + nlwarning(" unknown message name : %s", msgType); } if (UserEntity != NULL) UserEntity->setAFK(false); @@ -320,11 +321,11 @@ void CClientChatManager::chat( const ucstring& strIn, bool isChatTeam ) // tell // //----------------------------------------------- -void CClientChatManager::tell( const string& receiverIn, const ucstring& strIn ) +void CClientChatManager::tell( const string& receiverIn, const string& strIn ) { // Truncate to 255 chars max (because of server restriction) - string receiver= receiverIn.substr(0,255); - ucstring str= strIn.substr(0,255); + string receiver= receiverIn.substr(0,255); // FIXME: UTF-8 (serial) + ucstring str= ucstring(strIn).substr(0,255); // FIXME: UTF-8 (serial) // *** send str CBitMemStream bms; @@ -332,7 +333,7 @@ void CClientChatManager::tell( const string& receiverIn, const ucstring& strIn ) if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { bms.serial( receiver ); - bms.serial( str ); + bms.serial( str ); // FIXME: UTF-8 NetMngr.push( bms ); //nlinfo("impulseCallBack : %s %s %s sent", msgType.c_str(), receiver.c_str(), str.toString().c_str()); } @@ -344,10 +345,10 @@ void CClientChatManager::tell( const string& receiverIn, const ucstring& strIn ) // *** manage list of last telled people // remove the telled people from list (if present) - std::list::iterator it = _TellPeople.begin(); + std::list::iterator it = _TellPeople.begin(); while(it != _TellPeople.end()) { - if (*it == ucstring(receiver)) + if (*it == receiver) { it = _TellPeople.erase(it); nlassert(_NumTellPeople != 0); @@ -453,14 +454,14 @@ void CClientChatManager::processTellString(NLMISC::CBitMemStream& bms, IChatDisp // Serial. For tell message, there is no chat mode, coz we know we are in tell mode ! bms.serial (chatMsg.CompressedIndex); bms.serial (chatMsg.SenderNameId); - bms.serial (chatMsg.Content); + bms.serial (chatMsg.Content); // FIXME: UTF-8 (serial) if (PermanentlyBanned) return; chatMsg.ChatMode = (uint8) CChatGroup::tell; // If !complete, wait - ucstring senderStr; + string senderStr; bool complete = true; complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr); if (!complete) @@ -471,8 +472,8 @@ void CClientChatManager::processTellString(NLMISC::CBitMemStream& bms, IChatDisp } // display - ucstring ucstr; - buildTellSentence(senderStr, chatMsg.Content, ucstr); + string ucstr; + buildTellSentence(senderStr, chatMsg.Content.toUtf8(), ucstr); chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, senderStr); } @@ -487,9 +488,9 @@ void CClientChatManager::processFarTellString(NLMISC::CBitMemStream& bms, IChatD if (PermanentlyBanned) return; // display - ucstring ucstr; - buildTellSentence(farTellMsg.SenderName, farTellMsg.Text, ucstr); - chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, farTellMsg.SenderName); + string ucstr; + buildTellSentence(farTellMsg.SenderName.toUtf8(), farTellMsg.Text.toUtf8(), ucstr); + chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, farTellMsg.SenderName.toUtf8()); } @@ -504,7 +505,7 @@ void CClientChatManager::processChatString( NLMISC::CBitMemStream& bms, IChatDis CChatMsg chatMsg; bms.serial( chatMsg ); CChatGroup::TGroupType type = static_cast(chatMsg.ChatMode); - ucstring senderStr; + string senderStr; bool complete = true; complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr); @@ -527,9 +528,9 @@ void CClientChatManager::processChatString( NLMISC::CBitMemStream& bms, IChatDis } // display - ucstring ucstr; - buildChatSentence(chatMsg.CompressedIndex, senderStr, chatMsg.Content, type, ucstr); - chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, chatMsg.Content, type, chatMsg.DynChatChanID, senderStr); + string ucstr; + buildChatSentence(chatMsg.CompressedIndex, senderStr, chatMsg.Content.toUtf8(), type, ucstr); + chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, chatMsg.Content.toUtf8(), type, chatMsg.DynChatChanID, senderStr); } @@ -544,8 +545,8 @@ void CClientChatManager::processTellString2(NLMISC::CBitMemStream& bms, IChatDis bms.serial(chatMsg.PhraseId); // if !complete, wait - ucstring senderStr; - ucstring rawMessage; + string senderStr; + string rawMessage; bool complete = true; complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr); complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(chatMsg.PhraseId, rawMessage); @@ -557,7 +558,7 @@ void CClientChatManager::processTellString2(NLMISC::CBitMemStream& bms, IChatDis } // display - ucstring ucstr; + string ucstr; buildTellSentence(senderStr, rawMessage, ucstr); chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, senderStr); } @@ -570,8 +571,8 @@ void CClientChatManager::processChatString2(NLMISC::CBitMemStream& bms, IChatDis bms.serial( chatMsg ); if (PermanentlyBanned) return; CChatGroup::TGroupType type = static_cast(chatMsg.ChatMode); - ucstring senderStr; - ucstring rawMessage; + string senderStr; + string rawMessage; // here, the type cannot be dyn_chat (no DynChatId in the message) => discard if(type==CChatGroup::dyn_chat) @@ -591,11 +592,11 @@ void CClientChatManager::processChatString2(NLMISC::CBitMemStream& bms, IChatDis return; } - rawMessage += ucstring(" "); - rawMessage += chatMsg.CustomTxt; + rawMessage += " "; + rawMessage += chatMsg.CustomTxt.toUtf8(); // display - ucstring ucstr; + string ucstr; buildChatSentence(chatMsg.CompressedIndex, senderStr, rawMessage, type, ucstr); chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, rawMessage, type, CEntityId::Unknown, senderStr); } @@ -614,7 +615,7 @@ void CClientChatManager::processChatStringWithNoSender( NLMISC::CBitMemStream& b chatMsg.SenderNameId = 0; chatMsg.ChatMode = type; chatMsg.PhraseId = phraseID; - ucstring ucstr; + string ucstr; // if !complete, wait bool complete = STRING_MANAGER::CStringManagerClient::instance()->getDynString(chatMsg.PhraseId, ucstr); @@ -626,7 +627,7 @@ void CClientChatManager::processChatStringWithNoSender( NLMISC::CBitMemStream& b } // diplay - ucstring senderName(""); + string senderName; chatDisplayer.displayChat(INVALID_DATASET_INDEX, ucstr, ucstr, type, CEntityId::Unknown, senderName); } @@ -642,7 +643,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer) for( itMsg = _ChatBuffer.begin(); itMsg != _ChatBuffer.end(); ) { CChatGroup::TGroupType type = static_cast(itMsg->ChatMode); - ucstring sender, content; + string sender, content; // all strings received? bool complete = true; @@ -651,7 +652,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer) if(itMsg->UsePhraseId) complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(itMsg->PhraseId, content); else - content= itMsg->Content; + content= itMsg->Content.toUtf8(); if (type == CChatGroup::dyn_chat) { @@ -665,7 +666,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer) // if complete, process if (complete) { - ucstring ucstr; + string ucstr; if (itMsg->SenderNameId == 0) { ucstr = content; @@ -702,7 +703,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer) // getString // //----------------------------------------------- -ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) +string CClientChatManager::getString( CBitMemStream& bms, string& ucstr ) { // deal with parameters @@ -713,11 +714,11 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { // search if a parameter exists in the string sprintf(chTmp,"$%d",dynParamIdx); - ucstring ucstrTmp( chTmp ); - ucstring::size_type idx = ucstr.find(ucstrTmp); + string ucstrTmp( chTmp ); + string::size_type idx = ucstr.find(ucstrTmp); // if there's a parameter in the string - if( idx != ucstring::npos ) + if( idx != string::npos ) { char c = (char)ucstr[idx+ucstrTmp.size()]; switch( c ) @@ -727,7 +728,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { bool huff; bms.serialBit(huff); - const ucstring dynStr("???"); + const string dynStr("???"); if( huff ) { nldebug(" receiving huffman dynamic parameter in static string"); @@ -755,8 +756,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { string dynStr; bms.serial( dynStr ); - ucstring ucDynStr(dynStr); - ucstr.replace( idx, ucstrTmp.size()+1, ucDynStr ); + ucstr.replace( idx, ucstrTmp.size()+1, dynStr ); } break; @@ -765,7 +765,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { uint32 nb; bms.serial( nb ); - ucstr.replace( idx, ucstrTmp.size()+1, ucstring(toString(nb)) ); + ucstr.replace( idx, ucstrTmp.size()+1, toString(nb) ); } break; /* @@ -793,7 +793,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { sint32 nb; bms.serial( nb ); - ucstr.replace( idx, ucstrTmp.size()+1, ucstring(toString(nb)) ); + ucstr.replace( idx, ucstrTmp.size()+1, toString(nb) ); } break; /* @@ -822,7 +822,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) { float nb; bms.serial( nb ); - ucstr.replace( idx, ucstrTmp.size()+1, ucstring(toString(nb)) ); + ucstr.replace( idx, ucstrTmp.size()+1, toString(nb) ); } break; @@ -848,7 +848,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr ) // getString // //----------------------------------------------- -bool CClientChatManager::getString( ucstring &result, std::vector& args, const ucstring &ucstrbase ) +bool CClientChatManager::getString( string &result, std::vector& args, const string &ucstrbase ) { result = ucstrbase; @@ -862,17 +862,17 @@ bool CClientChatManager::getString( ucstring &result, std::vector& args, { // search if a parameter exists in the string sprintf(chTmp,"$%d",dynParamIdx); - ucstring ucstrTmp( chTmp ); - ucstring::size_type idx = result.find(ucstrTmp); + string ucstrTmp( chTmp ); + string::size_type idx = result.find(ucstrTmp); // if there's a parameter in the string - if( idx != ucstring::npos ) + if( idx != string::npos ) { - ucstring rep; + string rep; rep = "???"; if (dynParamIdx >= args.size()) { - nlwarning ("Missing args for string '%s', only %d args, need arg %d", ucstrbase.toString().c_str(), args.size(), dynParamIdx); + nlwarning ("Missing args for string '%s', only %d args, need arg %d", ucstrbase.c_str(), args.size(), dynParamIdx); } else { @@ -947,15 +947,15 @@ bool CClientChatManager::getString( ucstring &result, std::vector& args, } // getString // // *************************************************************************** -void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstring &msg, ucstring &result) +void CClientChatManager::buildTellSentence(const string &sender, const string &msg, string &result) { // If no sender name was provided, show only the msg if ( sender.empty() ) result = msg; else { - ucstring name = CEntityCL::removeTitleAndShardFromName(sender); - ucstring csr; + string name = CEntityCL::removeTitleAndShardFromName(sender); + string csr; // special case where there is only a title, very rare case for some NPC if (name.empty()) @@ -967,8 +967,8 @@ void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstrin name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); { // Sometimes translation contains another title - ucstring::size_type pos = name.find('$'); - if (pos != ucstring::npos) + string::size_type pos = name.find('$'); + if (pos != string::npos) { name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name), bWoman); } @@ -977,16 +977,16 @@ void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstrin else { // Does the char have a CSR title? - csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring(""); + csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? "(CSR) " : ""; } - result = csr + name + ucstring(" ") + CI18N::get("tellsYou") + ucstring(": ") + msg; + result = csr + name + " " + CI18N::get("tellsYou") + ": " + msg; } } // *************************************************************************** -void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderIndex */, const ucstring &sender, const ucstring &msg, CChatGroup::TGroupType type, ucstring &result) +void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderIndex */, const string &sender, const string &msg, CChatGroup::TGroupType type, string &result) { // if its a tell, then use buildTellSentence if(type==CChatGroup::tell) @@ -1004,24 +1004,24 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde // get the category if any. Note, in some case (chat from other player), there is not categories // and we do not want getStringCategory to return 'SYS' category. - ucstring finalMsg; + string finalMsg; string catStr = getStringCategory(msg, finalMsg, false); - ucstring cat; + string cat; if (!catStr.empty()) - cat = string("&")+catStr+"&"; + cat = "&" + catStr + "&"; - if ( ! cat.empty()) + if (!cat.empty()) { result = msg; return; } // Format the sentence with the provided sender name - ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender); + string senderName = CEntityCL::removeTitleAndShardFromName(sender); - ucstring csr; + string csr; // Does the char have a CSR title? - csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring(""); + csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? "(CSR) " : ""; if (UserEntity && senderName == UserEntity->getDisplayName()) { @@ -1029,10 +1029,10 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde switch(type) { case CChatGroup::shout: - result = cat + csr + CI18N::get("youShout") + ucstring(": ") + finalMsg; + result = cat + csr + CI18N::get("youShout") + ": " + finalMsg; break; default: - result = cat + csr + CI18N::get("youSay") + ucstring(": ") + finalMsg; + result = cat + csr + CI18N::get("youSay") + ": " + finalMsg; break; } } @@ -1048,8 +1048,8 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); { // Sometimes translation contains another title - ucstring::size_type pos = senderName.find('$'); - if (pos != ucstring::npos) + string::size_type pos = senderName.find('$'); + if (pos != string::npos) { senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName), bWoman); } @@ -1060,10 +1060,10 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde switch(type) { case CChatGroup::shout: - result = cat + csr + senderName + ucstring(" ") + CI18N::get("heShout") + ucstring(": ") + finalMsg; + result = cat + csr + senderName + " " + CI18N::get("heShout") + ": " + finalMsg; break; default: - result = cat + csr + senderName + ucstring(" ") + CI18N::get("heSays") + ucstring(": ") + finalMsg; + result = cat + csr + senderName + " " + CI18N::get("heSays") + ": " + finalMsg; break; } } @@ -1173,12 +1173,12 @@ void CClientChatManager::updateDynamicChatChannels(IChatDisplayer &chatDisplayer class CHandlerTell : public IActionHandler { - void execute (CCtrlBase *pCaller, const std::string &sParams) + void execute (CCtrlBase *pCaller, const string &sParams) { string receiver = getParam (sParams, "player"); - ucstring message; - message.fromUtf8(getParam (sParams, "text")); -// message = getParam (sParams, "text"); + string message; + message = getParam (sParams, "text"); + if (receiver.empty() || message.empty()) return; @@ -1194,10 +1194,10 @@ class CHandlerTell : public IActionHandler // display in the good window CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); - ucstring finalMsg; + string finalMsg; 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") + ": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, true); @@ -1206,7 +1206,7 @@ class CHandlerTell : public IActionHandler // TDataSetIndex dsi; // not used .... PeopleInterraction.ChatInput.Tell.displayTellMessage(/*dsi, */finalMsg, receiver, prop.getRGBA()); - ucstring s = CI18N::get("youTellPlayer"); + string s = CI18N::get("youTellPlayer"); strFindReplace(s, "%name", receiver); strFindReplace(finalMsg, CI18N::get("youTell"), s); CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell)); @@ -1218,7 +1218,7 @@ REGISTER_ACTION_HANDLER( CHandlerTell, "tell"); class CHandlerEnterTell : public IActionHandler { - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + void execute (CCtrlBase * /* pCaller */, const string &sParams) { CInterfaceManager *im = CInterfaceManager::getInstance(); string receiver = getParam (sParams, "player"); @@ -1230,11 +1230,13 @@ class CHandlerEnterTell : public IActionHandler { CGroupContainer *pGC = pCGW->createFreeTeller(receiver); if (pGC != NULL) - pGC->setActive(true); - CGroupEditBox *eb = dynamic_cast(pGC->getGroup("eb")); - if (eb) { - CWidgetManager::getInstance()->setCaptureKeyboard(eb); + pGC->setActive(true); + CGroupEditBox *eb = dynamic_cast(pGC->getGroup("eb")); + if (eb) + { + CWidgetManager::getInstance()->setCaptureKeyboard(eb); + } } } } @@ -1292,7 +1294,7 @@ void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChanne case CChatGroup::guild: if (guildActive) pUserBut->setHardText("uiFilterGuild"); break; case CChatGroup::dyn_chat: uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dynamicChannelDbIndex); - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); if (title.empty()) { @@ -1302,7 +1304,7 @@ void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChanne } else { - pUserBut->setHardText(title.toUtf8()); + pUserBut->setHardText(title); } break; } @@ -1334,14 +1336,12 @@ void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChanne class CHandlerTalk : public IActionHandler { - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + void execute (CCtrlBase * /* pCaller */, const string &sParams) { // Param uint mode; fromString(getParam (sParams, "mode"), mode); - ucstring text; - text.fromUtf8 (getParam (sParams, "text")); -// text = getParam (sParams, "text"); + string text = getParam (sParams, "text"); // Parse any tokens in the text if ( ! CInterfaceManager::parseTokens(text)) @@ -1354,7 +1354,7 @@ class CHandlerTalk : public IActionHandler { if(text[0] == '/') { - string str = text.toUtf8(); + string str = text; string cmdWithArgs = str.substr(1); // Get the command name from the string, can contain spaces @@ -1375,7 +1375,7 @@ class CHandlerTalk : public IActionHandler else { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo (ucstring::makeFromUtf8(cmd) + ": " + CI18N::get ("uiCommandNotExists")); + im->displaySystemInfo (cmd + ": " + CI18N::get ("uiCommandNotExists")); } } else @@ -1408,7 +1408,7 @@ REGISTER_ACTION_HANDLER( CHandlerTalk, "talk"); class CHandlerEnterTalk : public IActionHandler { - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + void execute (CCtrlBase * /* pCaller */, const string &sParams) { // Param uint mode; @@ -1435,10 +1435,10 @@ REGISTER_ACTION_HANDLER( CHandlerEnterTalk, "enter_talk"); class CHandlerTalkMessage : public IActionHandler { - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + void execute (CCtrlBase * /* pCaller */, const string &sParams) { // Param - ucstring text = CI18N::get ("uiTalkMemMsg"+sParams); + string text = CI18N::get ("uiTalkMemMsg"+sParams); // Find the base group if (!text.empty()) @@ -1454,7 +1454,7 @@ REGISTER_ACTION_HANDLER( CHandlerTalkMessage, "talk_message"); class CHandlerSwapChatMode : public IActionHandler { - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + void execute (CCtrlBase * /* pCaller */, const string &sParams) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); bool updateCapture= getParam(sParams, "update_capture")=="1"; diff --git a/ryzom/client/src/client_chat_manager.h b/ryzom/client/src/client_chat_manager.h index 2f7decac9..19afcab15 100644 --- a/ryzom/client/src/client_chat_manager.h +++ b/ryzom/client/src/client_chat_manager.h @@ -137,11 +137,11 @@ public: * \param mode in which channel should this message goes * \param dynChatId is valid only if mode==dyn_chat. This the Id of channel (not the index in DB!) */ - virtual void displayChat(TDataSetIndex compressedSenderIndex, const ucstring &ucstr, const ucstring &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, ucstring &senderName, uint bubbleTimer=0) =0; + virtual void displayChat(TDataSetIndex compressedSenderIndex, const std::string &ucstr, const std::string &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, std::string &senderName, uint bubbleTimer=0) =0; /** * display a player tell message */ - virtual void displayTell(/*TDataSetIndex senderIndex, */const ucstring &ucstr, const ucstring &senderName) =0; + virtual void displayTell(/*TDataSetIndex senderIndex, */const std::string &ucstr, const std::string &senderName) =0; /** * Clear a channel. * \param dynChatDbIndex is valid only if mode==dyn_chat. Contrary to displayChat, this is the Db Index (0..MaxDynChanPerPlayer) @@ -177,18 +177,18 @@ public : * \param str is the chat content (truncated to 255 char max) * \param isChatTeam special case for Chat TEAM */ - void chat( const ucstring& str, bool isChatTeam = false ); + void chat( const std::string& str, bool isChatTeam = false ); /** * Transmit a chat message to the receiver * \param receiver is the name of the listening char (truncated to 255 char max) * \param str is the chat content (truncated to 255 char max) */ - void tell( const std::string& receiver, const ucstring& str ); + void tell( const std::string& receiver, const std::string& str ); /** Get the last name of the people with which a 'tell' has been done, then move that name at the start of the list */ - const ucstring *cycleLastTell(); + const std::string *cycleLastTell(); /** Set the max number of name in the tell list */ @@ -263,12 +263,12 @@ public : * \param result decoded string * \return true if the string is finalize, false if some param are missing from network */ - bool getString( ucstring &result, std::vector& args, const ucstring& strbase ); + bool getString( std::string &result, std::vector& args, const std::string& strbase ); // build a sentence to be displayed in the chat (e.g add "you say", "you shout", "[user name] says" or "[user name] shout") - static void buildChatSentence(TDataSetIndex compressedSenderIndex, const ucstring &sender, const ucstring &msg, CChatGroup::TGroupType type, ucstring &result); + static void buildChatSentence(TDataSetIndex compressedSenderIndex, const std::string &sender, const std::string &msg, CChatGroup::TGroupType type, std::string &result); // build a sentence to be displayed in the tell - static void buildTellSentence(const ucstring &sender, const ucstring &msg, ucstring &result); + static void buildTellSentence(const std::string &sender, const std::string &msg, std::string &result); /// \name Dynamic Chat channel mgt @@ -304,7 +304,7 @@ private : uint8 ChatMode; NLMISC::CEntityId DynChatChanID; // For Chat and Tell messages - ucstring Content; + ucstring Content; // FIXME: UTF-8 (serial) // For Chat2 and Tell2 messages uint32 PhraseId; // Use PhraseId or Content? @@ -338,7 +338,7 @@ private : std::list _ChatBuffer; // peoples - std::list _TellPeople; // the last people on which tells ha been done + std::list _TellPeople; // the last people on which tells ha been done uint _NumTellPeople; uint _MaxNumTellPeople; @@ -361,7 +361,7 @@ private : * \param str string with parameter values at end (str will change after) * \return decoded string (str) */ - ucstring getString( NLMISC::CBitMemStream& bms, ucstring& str ); + std::string getString( NLMISC::CBitMemStream& bms, std::string& str ); }; diff --git a/ryzom/client/src/client_sheets/character_sheet.cpp b/ryzom/client/src/client_sheets/character_sheet.cpp index ab935268b..2568717f9 100644 --- a/ryzom/client/src/client_sheets/character_sheet.cpp +++ b/ryzom/client/src/client_sheets/character_sheet.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -213,6 +216,21 @@ void CCharacterSheet::build(const NLGEORGES::UFormElm &item) // IN LEFT HAND readEquipment(item, "Basics.Equipment.HandL", ObjectInLeftHand); + if (!ObjectInRightHand.IdItem) + { + std::string right; + item.getValueByName(right, "item_right"); + if (!right.empty()) + ObjectInRightHand.IdItem = ClientSheetsStrings.add(NLMISC::toLower(right)); + } + + if (!ObjectInLeftHand.IdItem) + { + std::string left; + item.getValueByName(left, "item_left"); + if (!left.empty()) + ObjectInLeftHand.IdItem = ClientSheetsStrings.add(NLMISC::toLower(left)); + } // Get the animation set Base Name. string AnimSetBaseName; diff --git a/ryzom/client/src/client_sheets/item_sheet.cpp b/ryzom/client/src/client_sheets/item_sheet.cpp index b89b5fcd4..2f845892e 100644 --- a/ryzom/client/src/client_sheets/item_sheet.cpp +++ b/ryzom/client/src/client_sheets/item_sheet.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010-2019 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -982,7 +985,7 @@ bool CItemSheet::canExchangeOrGive(bool botChatGift) const } // *************************************************************************** -void CItemSheet::getItemPartListAsText(ucstring &ipList) const +void CItemSheet::getItemPartListAsText(std::string &ipList) const { bool all= true; for(uint i=0;i // Copyright (C) 2010-2019 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -466,7 +469,7 @@ public: bool canExchangeOrGive(bool botChatGift) const; // 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 const NLMISC::CSheetId &getCraftPlan() const { return CraftPlan; } diff --git a/ryzom/client/src/commands.cpp b/ryzom/client/src/commands.cpp index fad157147..d756c938c 100644 --- a/ryzom/client/src/commands.cpp +++ b/ryzom/client/src/commands.cpp @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2019 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -240,20 +240,18 @@ NLMISC_COMMAND(equipGroup, "equip group ", "name") } if(CItemGroupManager::getInstance()->equipGroup(args[0])) { - ucstring msg = CI18N::get("cmdEquipGroupSuccess"); + string msg = CI18N::get("cmdEquipGroupSuccess"); //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return true; } else { - ucstring msg = CI18N::get("cmdEquipGroupError"); + string msg = CI18N::get("cmdEquipGroupError"); //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return false; @@ -274,10 +272,9 @@ NLMISC_COMMAND(moveGroup, "move group to ", "name dst") if(CItemGroupManager::getInstance()->moveGroup(args[0], INVENTORIES::toInventory(args[1]))) { - ucstring msg = CI18N::get("cmdMoveGroupSuccess"); + string msg = CI18N::get("cmdMoveGroupSuccess"); //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%inventory", args[1]); pIM->displaySystemInfo(msg); @@ -285,10 +282,9 @@ NLMISC_COMMAND(moveGroup, "move group to ", "name dst") } else { - ucstring msg = CI18N::get("cmdMoveGroupError"); + string msg = CI18N::get("cmdMoveGroupError"); //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%inventory", args[1]); pIM->displaySystemInfo(msg); @@ -312,24 +308,22 @@ NLMISC_COMMAND(createGroup, "create group [true](create a for ev removeUnequiped = !args[1].empty(); if(CItemGroupManager::getInstance()->createGroup(args[0], removeUnequiped)) { - ucstring msg; + string msg; if(removeUnequiped) msg = CI18N::get("cmdCreateGroupSuccess2"); else msg = CI18N::get("cmdCreateGroupSuccess1"); //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return true; } else { - ucstring msg = CI18N::get("cmdCreateGroupError"); + string msg = CI18N::get("cmdCreateGroupError"); //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return false; @@ -350,20 +344,18 @@ NLMISC_COMMAND(deleteGroup, "delete group ", "name") } if(CItemGroupManager::getInstance()->deleteGroup(args[0])) { - ucstring msg = CI18N::get("cmdDeleteGroupSuccess"); + string msg = CI18N::get("cmdDeleteGroupSuccess"); //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return true; } else { - ucstring msg = CI18N::get("cmdDeleteGroupError"); + string msg = CI18N::get("cmdDeleteGroupError"); //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(args[0]); + string nameUC = args[0]; strFindReplace(msg, "%name", nameUC); pIM->displaySystemInfo(msg); return false; @@ -494,7 +486,7 @@ NLMISC_COMMAND(random, "Roll a dice and say the result around","[] [h if (!randomFromString(args[0], max)) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("uiRandomBadParameter"); + string msg = CI18N::get("uiRandomBadParameter"); strFindReplace(msg, "%s", args[0] ); pIM->displaySystemInfo(msg); return false; @@ -504,7 +496,7 @@ NLMISC_COMMAND(random, "Roll a dice and say the result around","[] [h if (!randomFromString(args[1], min)) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("uiRandomBadParameter"); + string msg = CI18N::get("uiRandomBadParameter"); strFindReplace(msg, "%s", args[1] ); pIM->displaySystemInfo(msg); return false; @@ -544,7 +536,7 @@ NLMISC_COMMAND(dumpShapePos, "Dump Last Added Shape Pos.", "") CInterfaceManager *IM = CInterfaceManager::getInstance(); CVector pos = ShapeAddedByCommand.back().getPos(); - IM->displaySystemInfo(ucstring(toString("Shape Pos = %f, %f, %f", pos.x, pos.y, pos.z))); + IM->displaySystemInfo(toString("Shape Pos = %f, %f, %f", pos.x, pos.y, pos.z)); return true; } //----------------------------------------------- @@ -853,7 +845,7 @@ NLMISC_COMMAND(bugReport, "Call the bug report tool with dump", " string sys; - sys = "Language "+CI18N::getCurrentLanguageName().toString() +" "; + sys = "Language "+CI18N::getCurrentLanguageName() +" "; if (!args.empty()) { @@ -932,9 +924,7 @@ NLMISC_COMMAND(a, "Execute an admin command on you"," ") cmd = args[0]; for (uint i = 1; i < args.size(); i++) { - // temporary fix for utf-8 - // servers commands are not decoded so convert them to ansi - std::string tmp = ucstring::makeFromUtf8(args[i]).toString(); + std::string tmp = args[i]; if (!arg.empty()) arg += ' '; @@ -976,9 +966,7 @@ NLMISC_COMMAND(b, "Execute an admin command on your target"," ") cmd = args[0]; for (uint i = 1; i < args.size(); i++) { - // temporary fix for utf-8 - // servers commands are not decoded so convert them to ansi - std::string tmp = ucstring::makeFromUtf8(args[i]).toString(); + std::string tmp = args[i]; if (!arg.empty()) arg += ' '; @@ -1023,9 +1011,7 @@ NLMISC_COMMAND(c, "Execute an admin command on character name"," cmd = args[1]; for (uint i = 2; i < args.size(); i++) { - // temporary fix for utf-8 - // servers commands are not decoded so convert them to ansi - std::string tmp = ucstring::makeFromUtf8(args[i]).toString(); + std::string tmp = args[i]; if (!arg.empty()) arg += ' '; @@ -1096,11 +1082,11 @@ NLMISC_COMMAND(verbose, "Enable/Disable some Debug Information", "none or magic" { // Help CInterfaceManager *IM = CInterfaceManager::getInstance(); - IM->displaySystemInfo(ucstring("This command need 1 parameter :")); - IM->displaySystemInfo(ucstring(" :")); - IM->displaySystemInfo(ucstring("- none(to remove all verboses)")); - IM->displaySystemInfo(ucstring("- magic(to add debug infos about magic)")); - IM->displaySystemInfo(ucstring("- anim (to add debug infos about animation)")); + IM->displaySystemInfo("This command need 1 parameter :"); + IM->displaySystemInfo(" :"); + IM->displaySystemInfo("- none(to remove all verboses)"); + IM->displaySystemInfo("- magic(to add debug infos about magic)"); + IM->displaySystemInfo("- anim (to add debug infos about animation)"); } else { @@ -1114,11 +1100,11 @@ NLMISC_COMMAND(verbose, "Enable/Disable some Debug Information", "none or magic" else { CInterfaceManager *IM = CInterfaceManager::getInstance(); - IM->displaySystemInfo(ucstring("This command need 1 parameter :")); - IM->displaySystemInfo(ucstring(" :")); - IM->displaySystemInfo(ucstring("- none(to remove all verboses)")); - IM->displaySystemInfo(ucstring("- magic(to add debug infos about magic)")); - IM->displaySystemInfo(ucstring("- anim (to add debug infos about animation)")); + IM->displaySystemInfo("This command need 1 parameter :"); + IM->displaySystemInfo(" :"); + IM->displaySystemInfo("- none(to remove all verboses)"); + IM->displaySystemInfo("- magic(to add debug infos about magic)"); + IM->displaySystemInfo("- anim (to add debug infos about animation)"); } } return true; @@ -1306,9 +1292,9 @@ NLMISC_COMMAND(execScript, "Execute a script file (.cmd)","") inComment++; if(inComment<=0) { - ucstring ucline(line); + string ucline(line); CInterfaceManager::parseTokens(ucline); - ICommand::execute(ucline.toUtf8(), g_log); + ICommand::execute(ucline, g_log); } if(strncmp(line, "*/", 2)==0) inComment--; @@ -1323,7 +1309,7 @@ NLMISC_COMMAND(execScript, "Execute a script file (.cmd)","") } else { - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("Cannot open file")); + CInterfaceManager::getInstance()->displaySystemInfo("Cannot open file"); } return true; @@ -1358,7 +1344,7 @@ NLMISC_COMMAND(db, "Modify Database"," ") else pIM->displaySystemInfo(toString("DB '%s' does not exist.", args[0].c_str())); #else - pIM->displaySystemInfo(ucstring("Can't write to DB when in Final Version.")); + pIM->displaySystemInfo("Can't write to DB when in Final Version."); #endif } else if (size == 1) @@ -1368,7 +1354,7 @@ NLMISC_COMMAND(db, "Modify Database"," ") { sint64 prop = node->getValue64(); string str = toString(prop); - pIM->displaySystemInfo(ucstring(str)); + pIM->displaySystemInfo(str); nlinfo("%s", str.c_str()); } else @@ -1385,14 +1371,14 @@ NLMISC_COMMAND(setItemName, "set name of items, sbrick, etc.."," 2) - desc.fromUtf8(args[2]); + desc = args[2]; if (args.size() > 3) - desc2.fromUtf8(args[3]); + desc2 = args[3]; STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); if (pSMC) @@ -1406,10 +1392,10 @@ NLMISC_COMMAND(setItemName, "set name of items, sbrick, etc.."," ") { if (args.size() < 2) return false; - ucstring name; - name.fromUtf8(args[0]); - ucstring text; - text.fromUtf8(args[1]); + string name; + name = args[0]; + string text; + text = args[1]; STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); if (pSMC) @@ -1459,7 +1445,7 @@ NLMISC_COMMAND(ah, "Launch an action handler", " ") static void setDynString(uint32 strID, const std::string &value) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - pSMC->receiveString(strID, ucstring(value)); + pSMC->receiveString(strID, value); CBitMemStream bm; if (bm.isReading()) bm.invert(); bm.serial(strID); @@ -1722,7 +1708,7 @@ NLMISC_COMMAND(getSheetId, "get_sheet_id","") return false; CSheetId id(args[0]); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(toString(id.asInt()))); + CInterfaceManager::getInstance()->displaySystemInfo(toString(id.asInt())); return true; } @@ -1737,7 +1723,7 @@ NLMISC_COMMAND(getSheetName, "get_sheet_name","") string name = id.toString(); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(name)); + CInterfaceManager::getInstance()->displaySystemInfo(name); return true; } @@ -2388,7 +2374,7 @@ NLMISC_COMMAND(sheet2idx, "Return the index of a sheet", " displaySystemInfo(ucstring(result)); + IM->displaySystemInfo(result); nlinfo("'sheet2idx': %s", result.c_str()); return true; } @@ -2411,7 +2397,7 @@ NLMISC_COMMAND(dynstr, "display a dyn string value", "") uint dynId; fromString(args[0], dynId); - ucstring result; + string result; STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynId, result); CInterfaceManager::getInstance()->displaySystemInfo(result); @@ -2426,7 +2412,7 @@ NLMISC_COMMAND(serverstr, "display a server string value", "getString(dynId, result); CInterfaceManager::getInstance()->displaySystemInfo(result); @@ -2510,11 +2496,11 @@ NLMISC_COMMAND(mode, "Change the mode for an entity in a slot", " [ if(args.size() < 2) { // Help - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 paramters :")); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the mode wanted for the entity, one of the following number :")); + CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 paramters :"); + CInterfaceManager::getInstance()->displaySystemInfo(" : the slot number of the entity to change"); + CInterfaceManager::getInstance()->displaySystemInfo(" : the mode wanted for the entity, one of the following number :"); for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::modeToString((MBEHAV::EMode)i).c_str()))); + CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::modeToString((MBEHAV::EMode)i).c_str())); } // Right parameters number else @@ -2544,7 +2530,7 @@ NLMISC_COMMAND(mode, "Change the mode for an entity in a slot", " [ } // Invalid slot. else - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); + CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot"); } // Command well done. @@ -2557,12 +2543,12 @@ NLMISC_COMMAND(behaviour, "Change the behaviour for an entity in a slot", " 6) { // Help - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 to 6 paramters :")); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the slot number of the entity to change")); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" : the behaviour to play for the entity, one of the following number :")); + CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 to 6 paramters :"); + CInterfaceManager::getInstance()->displaySystemInfo(" : the slot number of the entity to change"); + CInterfaceManager::getInstance()->displaySystemInfo(" : the behaviour to play for the entity, one of the following number :"); for(uint i = 0; idisplaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i).c_str()))); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); + CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i).c_str())); + CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END)); } else { @@ -2633,7 +2619,7 @@ NLMISC_COMMAND(behaviour, "Change the behaviour for an entity in a slot", "updateVisualProperty(NetMngr.getCurrentServerTick()+dt, CLFECOMMON::PROPERTY_BEHAVIOUR); } else - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); + CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot"); } // Command well done. @@ -2782,7 +2768,7 @@ NLMISC_COMMAND(spell, "Cast a spell", "\n" entity->updateVisualProperty(NetMngr.getCurrentServerTick()+50, CLFECOMMON::PROPERTY_BEHAVIOUR); } else - CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); + CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot"); } // Command well done. @@ -3871,7 +3857,7 @@ NLMISC_COMMAND(testLongBubble, "To display a bubble with a long text", " fromString(args[0], entityId); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring text("test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n"); + string text("test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n"); uint duration = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutBubbles).getValSInt32(); CEntityCL *entity = EntitiesMngr.entity(entityId); @@ -4005,7 +3991,7 @@ NLMISC_COMMAND(displayInventoryCounter, "display the Inventory counter to compar srvVal&= pIM->getLocalSyncActionCounterMask(); locVal&= pIM->getLocalSyncActionCounterMask(); - pIM->displaySystemInfo(ucstring( "ServerCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)) ); + pIM->displaySystemInfo("ServerCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)); // Well done. return true; @@ -4023,7 +4009,7 @@ NLMISC_COMMAND(displayActionCounter, "display the action counters", "") srvVal&= PHRASE_EXECUTE_COUNTER_MASK; locVal&= PHRASE_EXECUTE_COUNTER_MASK; - pIM->displaySystemInfo(ucstring( "NextCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)) ); + pIM->displaySystemInfo("NextCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)); // cycle srvVal= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_CYCLE)->getValue32(); @@ -4031,7 +4017,7 @@ NLMISC_COMMAND(displayActionCounter, "display the action counters", "") srvVal&= PHRASE_EXECUTE_COUNTER_MASK; locVal&= PHRASE_EXECUTE_COUNTER_MASK; - pIM->displaySystemInfo(ucstring( "CycleCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)) ); + pIM->displaySystemInfo("CycleCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)); return true; } @@ -4114,7 +4100,7 @@ NLMISC_COMMAND(skillToInt, "Convert a skill to an int", "") { if (args.size() != 1) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo(ucstring(toString((uint) SKILLS::toSkill(args[0])))); + im->displaySystemInfo(toString((uint) SKILLS::toSkill(args[0]))); return true; } @@ -4520,7 +4506,7 @@ NLMISC_COMMAND(getSkillValue, "get a skill value by its name", "skill_name") CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", skillId), false); if(node) { - pIM->displaySystemInfo(ucstring(toString(node->getValue32()))); + pIM->displaySystemInfo(toString(node->getValue32())); } return true; @@ -4550,7 +4536,7 @@ NLMISC_COMMAND(getBaseSkillValue, "get a baseskill value by its name", "skill_na CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", skillId), false); if(node) { - pIM->displaySystemInfo(ucstring(toString(node->getValue32()))); + pIM->displaySystemInfo(toString(node->getValue32())); } return true; @@ -4812,7 +4798,7 @@ NLMISC_COMMAND(stick_log, "", "") skel->getStickedObjects(sticks); nlinfo("StickedModels: %d", sticks.size()); - pIM->displaySystemInfo(ucstring(toString("StickedModels: %d", sticks.size()))); + pIM->displaySystemInfo(toString("StickedModels: %d", sticks.size())); for(uint i=0;i= args.size()) { // Not enough arguments - pIM->displaySystemInfo (ucstring(CommandName+" : ")+CI18N::get ("uiCommandWrongArgumentCount")); + pIM->displaySystemInfo (CommandName+" : "+CI18N::get ("uiCommandWrongArgumentCount")); return false; } else @@ -5414,7 +5400,7 @@ bool CUserCommand::execute(const std::string &/* rawCommandString */, const std: else { // Not enough argument - pIM->displaySystemInfo (ucstring(CommandName+" : ")+CI18N::get ("uiCommandWrongArgumentCount")); + pIM->displaySystemInfo (CommandName+" : "+CI18N::get ("uiCommandWrongArgumentCount")); return false; } return true; @@ -5658,7 +5644,7 @@ NLMISC_COMMAND(tickToDate, "convert a tick value into a readable ryzom time", "" CInterfaceManager *im = CInterfaceManager::getInstance(); float ryTime = rt.getRyzomTime(); std::string readableDate = toString("Day = %d, hour = %d:%d", rt.getRyzomDay(), (int) floorf(ryTime), (int) floorf(60.f * fmodf(ryTime, 1.f))); - im->displaySystemInfo(ucstring(readableDate)); + im->displaySystemInfo(readableDate); return true; } @@ -5930,7 +5916,7 @@ NLMISC_COMMAND(time, "Shows information about the current time", "") tm = gmtime(&date); strftime(cs_utc, size, "%X", tm); - ucstring msg = CI18N::get("uiCurrentLocalAndUtcTime"); + string msg = CI18N::get("uiCurrentLocalAndUtcTime"); strFindReplace(msg, "%local", cs_local); strFindReplace(msg, "%utc", cs_utc); CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND"); @@ -5939,7 +5925,7 @@ NLMISC_COMMAND(time, "Shows information about the current time", "") NLMISC_COMMAND(playedTime, "Display character played time", "") { - ucstring msg = CI18N::get("uiPlayedTime"); + string msg = CI18N::get("uiPlayedTime"); strFindReplace(msg, "%time", NLMISC::secondsToHumanReadable(CharPlayedTime)); CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND"); return true; @@ -5947,7 +5933,7 @@ NLMISC_COMMAND(playedTime, "Display character played time", "") NLMISC_COMMAND(version, "Display client version", "") { - ucstring msg = getDebugVersion(); + string msg = getDebugVersion(); CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND"); return true; } diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp index ee1be3318..df3eccb3a 100644 --- a/ryzom/client/src/connection.cpp +++ b/ryzom/client/src/connection.cpp @@ -4,7 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -146,8 +146,8 @@ string CharNameValidDBLink; uint8 PlayerSelectedSlot = 0; string PlayerSelectedFileName; TSessionId PlayerSelectedMainland= (TSessionId)0; // This is the mainland selected at the SELECT perso!! -ucstring PlayerSelectedHomeShardName; -ucstring PlayerSelectedHomeShardNameWithParenthesis; +std::string PlayerSelectedHomeShardName; +std::string PlayerSelectedHomeShardNameWithParenthesis; extern std::string CurrentCookie; @@ -365,7 +365,7 @@ bool connection (const string &cookie, const string &fsaddr) // Preload continents { - const ucstring nmsg("Loading continents..."); + const string nmsg("Loading continents..."); ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) ); ContinentMngr.preloadSheets(); @@ -403,7 +403,7 @@ bool connection (const string &cookie, const string &fsaddr) // Init out game setOutGameFullScreen(); - ucstring nmsg("Initializing outgame..."); + string nmsg("Initializing outgame..."); ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) ); pIM->initOutGame(); @@ -547,7 +547,7 @@ bool reconnection() // Preload continents { - const ucstring nmsg ("Loading continents..."); + const string nmsg ("Loading continents..."); ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) ); ContinentMngr.preloadSheets(); } @@ -986,7 +986,7 @@ TInterfaceState globalMenu() while (PlayerWantToGoInGame == false) { - #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG) + #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG) && 0 // tmp for debug if (::GetAsyncKeyState(VK_SPACE)) { @@ -1026,7 +1026,7 @@ TInterfaceState globalMenu() // Display the firewall alert string CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:outgame:connecting:title")); if (pVT != NULL) - pVT->setText(CI18N::get("uiFirewallAlert")+ucstring("...")); + pVT->setTextLocalized("uiFirewallAlert", true); // 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 @@ -1072,7 +1072,7 @@ TInterfaceState globalMenu() nlSleep(ClientCfg.Sleep); } - #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG) + #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG) && 0 if (::GetAsyncKeyState(VK_CONTROL)) { pIM->displayUIViewBBoxs(""); @@ -1242,8 +1242,8 @@ TInterfaceState globalMenu() if (pVT != NULL) { pVT->setMultiLine( true ); - pVT->setText(CI18N::get("uiFirewallFail")+ucstring(".\n")+ - CI18N::get("uiFirewallAlert")+ucstring(".")); + pVT->setTextLocalized(CI18N::get("uiFirewallFail")+".\n"+ + CI18N::get("uiFirewallAlert")+".", false); } } } @@ -1324,16 +1324,16 @@ public: if (pVT == NULL) return; if (rCS.Name.empty()) - pVT->setText(CI18N::get("uiEmptySlot")); + pVT->setTextLocalized("uiEmptySlot", true); else - pVT->setText(rCS.Name); + pVT->setTextLocalized(rCS.Name.toUtf8(), false); } // 5 slots for (; i < 5; ++i) { CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i))); if (pVT == NULL) return; - pVT->setText(CI18N::get("uiEmptySlot")); + pVT->setTextLocalized("uiEmptySlot", true); } } }; @@ -1355,7 +1355,7 @@ void setTarget(CCtrlBase *ctrl, const string &targetName, ucstring &value) if (ig) { CInterfaceExprValue exprValue; - exprValue.setUCString(value); + exprValue.setString(value.toUtf8()); CInterfaceLink::splitLinkTargets(targetName, ig, targets); for(uint k = 0; k < targets.size(); ++k) @@ -1446,7 +1446,7 @@ Deprecated { ucstring::size_type pos = sValue.find('$'); if (pos != ucstring::npos) { - sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue), womanTitle); + sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue.toUtf8()), womanTitle); } } setTarget (pCaller, sTarget, sValue); @@ -1691,7 +1691,7 @@ public: ucstring sSurName = ucstring("NotSet"); CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sEditBoxPath)); if (pGEB != NULL) - sFirstName = pGEB->getInputString(); + sFirstName = pGEB->getInputStringAsUtf16(); else nlwarning ("can't get edit box name : %s",sEditBoxPath.c_str()); @@ -2175,8 +2175,8 @@ public: CViewText *pVT = dynamic_cast(pNewLine->getView("name")); if (pVT != NULL) { - ucstring ucstr = Mainlands[i].Name + ucstring(" ") + Mainlands[i].Description; - pVT->setText(ucstr); + std::string str = Mainlands[i].Name.toUtf8() + " " + Mainlands[i].Description.toUtf8(); + pVT->setTextLocalized(str, false); } // Add to the list @@ -2340,13 +2340,13 @@ public: CViewText *pVT = dynamic_cast(pNewLine->getView("name")); if (pVT != NULL) { - pVT->setText(name); + pVT->setTextLocalized(name.toUtf8(), false); } CCtrlBase *pBut = pNewLine->getCtrl("but"); if (pBut != NULL) { - pBut->setDefaultContextHelp(tooltip); + pBut->setDefaultContextHelp(tooltip.toUtf8()); } addGroupInList(pNewLine); } @@ -2593,10 +2593,10 @@ static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName { CViewText* viewText = dynamic_cast(result); if(viewText) - viewText->setText(text); + viewText->setTextLocalized(text.toUtf8(), false); CGroupEditBox* editBox = dynamic_cast(result); if(editBox) - editBox->setInputString(text); + editBox->setInputStringAsUtf16(text); } } @@ -2716,7 +2716,7 @@ class CAHScenarioControl : public IActionHandler CViewText* viewText = dynamic_cast(result); if(viewText) { - viewText->setText(R2::getEditor().isInitialized()?CI18N::get("uiR2EDScenarioName"):CI18N::get("uiR2EDScenarioFileName")); + viewText->setTextLocalized(R2::getEditor().isInitialized() ? "uiR2EDScenarioName" : "uiR2EDScenarioFileName", true); } } @@ -2728,9 +2728,9 @@ class CAHScenarioControl : public IActionHandler if(okButton) { if(R2::getEditor().getAccessMode()!=R2::CEditor::AccessDM) - okButton->setHardText(CI18N::get("uiR2EDLaunchScenario").toString()); + okButton->setHardText(CI18N::get("uiR2EDLaunchScenario")); else - okButton->setHardText(CI18N::get("uiR2EDApplyScenarioFilters").toString()); + okButton->setHardText(CI18N::get("uiR2EDApplyScenarioFilters")); } } @@ -2746,7 +2746,7 @@ class CAHScenarioControl : public IActionHandler CViewText* viewText= dynamic_cast(result); if(viewText) - viewText->setText(ucstring("")); + viewText->setText(std::string()); } } setScenarioInformation(scenarioWnd, ""); @@ -2782,7 +2782,7 @@ class CAHScenarioControl : public IActionHandler CViewText *shardName = dynamic_cast(toggleGr->getView("button_text")); if (shardName) { - shardName->setText(Mainlands[i].Name); + shardName->setTextLocalized(Mainlands[i].Name.toUtf8(), false); } } } @@ -2860,7 +2860,7 @@ class CAHScenarioControl : public IActionHandler { CGroupEditBox* editBox = dynamic_cast(result); if(editBox) - editBox->setInputString(description); + editBox->setInputStringAsUtf16(description); } } } @@ -2922,7 +2922,7 @@ class CAHScenarioInformation : public IActionHandler scenarioName = scenarioName.substr(posScenarioName==0?posScenarioName:posScenarioName+1); posScenarioName = scenarioName.find('/'); } - viewText->setText(scenarioName); + viewText->setTextLocalized(scenarioName, false); } } @@ -3011,7 +3011,7 @@ class CAHLoadScenario : public IActionHandler { CGroupEditBox* editBox = dynamic_cast(result); if(editBox) - description = editBox->getInputString().toString(); + description = editBox->getInputString(); } // races @@ -3218,9 +3218,9 @@ class CAHLoadScenario : public IActionHandler // -------------------------- TRuleType ruleType(TRuleType::rt_strict); - if(rules==CI18N::get("uiR2EDliberal").toString()) + if(rules==CI18N::get("uiR2EDliberal")) ruleType = TRuleType(TRuleType::rt_liberal); - else if(rules == CI18N::get("uiR2EDstrict").toString()) + else if(rules == CI18N::get("uiR2EDstrict")) ruleType = TRuleType(TRuleType::rt_strict); volatile static bool override = false; if (override) @@ -3284,7 +3284,7 @@ class CAHLoadScenario : public IActionHandler { CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) - pVT->setText(CI18N::get("uiRingWarningFreeTrial")); + pVT->setTextLocalized("uiRingWarningFreeTrial", true); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); return; @@ -3365,7 +3365,7 @@ class CAHLoadScenario : public IActionHandler { CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) - pVT->setText(CI18N::get("uiRingWarningFreeTrial")); + pVT->setTextLocalized("uiRingWarningFreeTrial", true); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); } @@ -3379,10 +3379,10 @@ class CAHLoadScenario : public IActionHandler if(val!=0) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring res; + string res; if (pSMC->getString(val,res)) { - string charName = CEntityCL::removeTitleAndShardFromName(res).toString(); + string charName = CEntityCL::removeTitleAndShardFromName(res); sessionBrowser.inviteCharacterByName(sessionBrowser._LastScheduleSessionCharId, charName); if(!sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_invokeResult"))) @@ -3394,7 +3394,7 @@ class CAHLoadScenario : public IActionHandler { CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) - pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial")); + pVT->setTextLocalized("uiRingWarningInviteFreeTrial", true); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); } } diff --git a/ryzom/client/src/connection.h b/ryzom/client/src/connection.h index 79a72fb0e..3c61aed32 100644 --- a/ryzom/client/src/connection.h +++ b/ryzom/client/src/connection.h @@ -30,8 +30,8 @@ extern std::vector Mainlands; extern uint8 PlayerSelectedSlot; extern std::string PlayerSelectedFileName; extern TSessionId PlayerSelectedMainland; // This is the mainland selected at the SELECT perso!! -extern ucstring PlayerSelectedHomeShardName; // The home shard name (aniro, leanon etc....) -extern ucstring PlayerSelectedHomeShardNameWithParenthesis; // Same with parenthesis +extern std::string PlayerSelectedHomeShardName; // The home shard name (aniro, leanon etc....) +extern std::string PlayerSelectedHomeShardNameWithParenthesis; // Same with parenthesis extern std::vector CharacterSummaries; extern std::string UserPrivileges; extern sint LoginCharsel; diff --git a/ryzom/client/src/contextual_cursor.cpp b/ryzom/client/src/contextual_cursor.cpp index 15dd6a17a..2a4d053d1 100644 --- a/ryzom/client/src/contextual_cursor.cpp +++ b/ryzom/client/src/contextual_cursor.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -129,7 +130,7 @@ void CContextualCursor::del(const std::string &contextName) // context : // Select a nex context. //----------------------------------------------- -bool CContextualCursor::context(const std::string &contextName, float dist, const ucstring &cursName) +bool CContextualCursor::context(const std::string &contextName, float dist, const std::string &cursName) { // Delete the context. TContext::iterator it = _Contexts.find(contextName); diff --git a/ryzom/client/src/contextual_cursor.h b/ryzom/client/src/contextual_cursor.h index 6dfd20749..31ba7a3c5 100644 --- a/ryzom/client/src/contextual_cursor.h +++ b/ryzom/client/src/contextual_cursor.h @@ -68,7 +68,7 @@ public: void del(const std::string &contextName); // Select a nex context. - bool context(const std::string &contextName, float dist = 0, const ucstring &cursName = ucstring("")); + bool context(const std::string &contextName, float dist = 0, const std::string &cursName = std::string()); inline const std::string &context() const {return _Context;} // Check if there is an entity under the cursor. diff --git a/ryzom/client/src/continent.cpp b/ryzom/client/src/continent.cpp index d0fb15a95..2efb10fee 100644 --- a/ryzom/client/src/continent.cpp +++ b/ryzom/client/src/continent.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010-2019 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -964,6 +967,7 @@ void CContinent::unselect() // Setup the Root scene. if (BackgroundIG) { + nlassert(SceneRoot); BackgroundIG->removeFromScene (*SceneRoot); SceneRoot->deleteInstanceGroup (BackgroundIG); BackgroundIG = NULL; diff --git a/ryzom/client/src/continent.h b/ryzom/client/src/continent.h index 7e0d599b4..f48b4b043 100644 --- a/ryzom/client/src/continent.h +++ b/ryzom/client/src/continent.h @@ -109,7 +109,7 @@ public: }; NLMISC::CVector2f Pos; // Pos in local map - ucstring Title; + ucstring Title; // FIXME: UTF-8 (serial) uint8 Type; //User LandMarks Colors diff --git a/ryzom/client/src/cursor_functions.cpp b/ryzom/client/src/cursor_functions.cpp index 44e2dde7e..0354e11f8 100644 --- a/ryzom/client/src/cursor_functions.cpp +++ b/ryzom/client/src/cursor_functions.cpp @@ -197,7 +197,7 @@ static bool testMissionOption(sint32 priorityWanted) // Get the Text for the cursor if(textID) { - ucstring result; + string result; bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID, result); if (!res) result = NLMISC::CI18N::get("uiMissionOptionNotReceived"); @@ -224,7 +224,7 @@ static bool testMissionRing() uint32 textID = pNL->getValue32(); // if the string is not received display a temp string - ucstring missionRingText; + string missionRingText; if(!STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID, missionRingText)) missionRingText = NLMISC::CI18N::get("uiMissionRingNameNotReceived"); @@ -445,7 +445,7 @@ void checkUnderCursor() uint32 textID = pNL->getValue32(); // if the string is not received display a temp string - ucstring webPageText; + string webPageText; if(!STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID, webPageText)) webPageText = NLMISC::CI18N::get("uiWebPageNameNotReceived"); @@ -463,8 +463,8 @@ void checkUnderCursor() { // get the outpost name CSheetId outpostSheet(pNL->getValue32()); - ucstring outpostName; - outpostName= ucstring(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)); + string outpostName; + outpostName= STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet); // display the cursor if(ContextCur.context("OUTPOST", 0.f, outpostName)) @@ -564,14 +564,13 @@ void checkUnderCursor() cursor->setCursor("r2ed_tool_select_move_over.tga"); InstanceId = instance_idx; - if (ContextCur.context("ARKITECT", 0.f, ucstring("Edit"))) + if (ContextCur.context("ARKITECT", 0.f, "Edit")) return; } else { cursor->setCursor("curs_pick.tga"); - ucstring contextText; - contextText.fromUtf8(instref.ContextText); + string contextText = instref.ContextText; if (ContextCur.context("WEBIG", 0.f, contextText)) return; } diff --git a/ryzom/client/src/debug_client.cpp b/ryzom/client/src/debug_client.cpp index dd182f3c9..cbceca4ef 100644 --- a/ryzom/client/src/debug_client.cpp +++ b/ryzom/client/src/debug_client.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -514,7 +514,7 @@ string getDebugInformation() if(UserEntity) { - str += toString("Player Name: '%s'\n", UserEntity->getEntityName().toString().c_str()); + str += toString("Player Name: '%s'\n", UserEntity->getEntityName().c_str()); str += toString("UserPosition: %.2f %.2f %.2f\n", UserEntity->pos().x, UserEntity->pos().y, UserEntity->pos().z); } else @@ -529,7 +529,7 @@ string getDebugInformation() str += toString("ServerTick: %u\n", NetMngr.getCurrentServerTick()); str += toString("ConnectState: %s\n", NetMngr.getConnectionStateCStr()); 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()); if (ClientCfg.R2Mode) { diff --git a/ryzom/client/src/decal.cpp b/ryzom/client/src/decal.cpp index e270a7c29..a16cb93bf 100644 --- a/ryzom/client/src/decal.cpp +++ b/ryzom/client/src/decal.cpp @@ -162,7 +162,9 @@ CDecal::CDecal() { DecalAttenuationVertexProgram = new CVertexProgramDecalAttenuation(); } - _ShadowMap = new CShadowMap(&(((CSceneUser *) Scene)->getScene().getRenderTrav().getShadowMapManager())); + + // initialized in render() as depends on scene + _ShadowMap = NULL; _Material.initUnlit(); _Diffuse = CRGBA::White; _Emissive = CRGBA::Black; @@ -251,7 +253,11 @@ CRGBA CDecal::getDiffuse() const // **************************************************************************** CDecal::~CDecal() { - delete _ShadowMap; + if (_ShadowMap) + { + delete _ShadowMap; + _ShadowMap = NULL; + } } // **************************************************************************** @@ -527,7 +533,12 @@ void CDecal::render(NL3D::UDriver &/* drv */, // float tileNear = Landscape->getTileNear(); // - nlassert(_ShadowMap); + if (!_ShadowMap) + { + _ShadowMap = new CShadowMap(&(((CSceneUser *) Scene)->getScene().getRenderTrav().getShadowMapManager())); + nlassert(_ShadowMap); + } + _ShadowMap->LocalClipPlanes.resize(4); CVector corners[4] = { diff --git a/ryzom/client/src/entities.cpp b/ryzom/client/src/entities.cpp index 9ecadba93..80d64c35a 100644 --- a/ryzom/client/src/entities.cpp +++ b/ryzom/client/src/entities.cpp @@ -178,7 +178,7 @@ public : CCompassTarget ct = pGC->getTarget(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring oldName; + string oldName; if (!pSMC->getDynString(leaf->getOldValue32(), oldName)) { nlwarning("Can't get compass target name"); @@ -201,7 +201,7 @@ public : { // TODO : maybe the following code could be include in CGroupMap::checkCoords, but it is not called when the map is not visible... STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring name; + string name; if (pSMC->getDynString((*tmpIt)->getValue32(), name)) { // if (_AlreadyReceived.count(name) == 0) @@ -2268,7 +2268,7 @@ void CEntityManager::dumpXML(class NLMISC::IStream &f) f.xmlPushBegin("Name"); // Set a property name f.xmlSetAttrib ("string"); - ucstring n = _Entities[i]->getEntityName(); + string n = _Entities[i]->getEntityName(); f.serial(n); // Close the new node header f.xmlPushEnd(); @@ -2361,11 +2361,11 @@ CEntityCL *CEntityManager::getEntityByName (uint32 stringId) const } //----------------------------------------------- -CEntityCL *CEntityManager::getEntityByKeywords (const std::vector &keywords, bool onlySelectable) const +CEntityCL *CEntityManager::getEntityByKeywords (const std::vector &keywords, bool onlySelectable) const { if (keywords.empty()) return NULL; - std::vector lcKeywords; + std::vector lcKeywords; lcKeywords.resize(keywords.size()); for(uint k = 0; k < keywords.size(); k++) { @@ -2382,14 +2382,13 @@ CEntityCL *CEntityManager::getEntityByKeywords (const std::vector &key if (onlySelectable && !_Entities[i]->properties().selectable()) continue; - ucstring lcName; - lcName = toLower(_Entities[i]->getDisplayName()); + string lcName = toLower(_Entities[i]->getDisplayName()); if (lcName.empty()) continue; bool match = true; for (uint k = 0; k < lcKeywords.size(); ++k) { - if (lcName.find(lcKeywords[k]) == ucstring::npos) + if (lcName.find(lcKeywords[k]) == string::npos) { match = false; break; @@ -2418,9 +2417,9 @@ CEntityCL *CEntityManager::getEntityByKeywords (const std::vector &key } //----------------------------------------------- -CEntityCL *CEntityManager::getEntityByName (const ucstring &name, bool caseSensitive, bool complete) const +CEntityCL *CEntityManager::getEntityByName (const string &name, bool caseSensitive, bool complete) const { - ucstring source = name; + string source = name; const uint size = (uint)source.size(); if (!caseSensitive) { @@ -2438,7 +2437,7 @@ CEntityCL *CEntityManager::getEntityByName (const ucstring &name, bool caseSensi { if(_Entities[i]) { - ucstring value = _Entities[i]->getDisplayName(); + string value = _Entities[i]->getDisplayName(); bool foundEntity = false; uint j; diff --git a/ryzom/client/src/entities.h b/ryzom/client/src/entities.h index 48707d5cf..d6d286ced 100644 --- a/ryzom/client/src/entities.h +++ b/ryzom/client/src/entities.h @@ -308,13 +308,13 @@ public: * \param caseSensitive type of test to perform * \param complete : if true, the name must match the full name of the entity. */ - CEntityCL *getEntityByName (const ucstring &name, bool caseSensitive, bool complete) const; + CEntityCL *getEntityByName (const std::string &name, bool caseSensitive, bool complete) const; /** * Case insensitive match against entity name. All listed keywords must match. * \param keywords to match * \param onlySelectable : if true, match only entity that can be selected */ - CEntityCL *getEntityByKeywords (const std::vector &keywords, bool onlySelectable) const; + CEntityCL *getEntityByKeywords (const std::vector &keywords, bool onlySelectable) const; CEntityCL *getEntityBySheetName (const std::string &sheet) const; /// Get an entity by dataset index. Returns NULL if the entity is not found. CEntityCL *getEntityByCompressedIndex(TDataSetIndex compressedIndex) const; diff --git a/ryzom/client/src/entity_cl.cpp b/ryzom/client/src/entity_cl.cpp index 14f3a1769..77d1e3c65 100644 --- a/ryzom/client/src/entity_cl.cpp +++ b/ryzom/client/src/entity_cl.cpp @@ -3,8 +3,8 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -378,6 +378,8 @@ void CEntityCL::SInstanceCL::updateCurrentFromLoading(NL3D::USkeleton Skeleton) sint stickID = Skeleton.getBoneIdByName(StickPoint); if(stickID != -1) Skeleton.stickObject(Current, stickID); + else + nlwarning("Skeleton '%s' is missing bone '%s' for object attachment.", Skeleton.getShapeName().c_str(), StickPoint.c_str()); } } @@ -2095,7 +2097,7 @@ bool CEntityCL::clipped (const std::vector &clippingPlanes, cons // Set the name of the entity. Handle replacement tag if any // to insert NPC task translated. //--------------------------------------------------- -void CEntityCL::setEntityName(const ucstring &name) +void CEntityCL::setEntityName(const std::string &name) { _EntityName = name; } @@ -2260,7 +2262,7 @@ void CEntityCL::load() // virtual // onStringAvailable : // Callback when the name is arrived. //----------------------------------------------- -void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) +void CEntityCL::onStringAvailable(uint /* stringId */, const std::string &value) { _EntityName = value; @@ -2268,24 +2270,24 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) _EntityName= removeShardFromName(_EntityName); // New title - ucstring newtitle; + string newtitle; _HasReservedTitle = false; // check if there is any replacement tag in the string - ucstring::size_type p1 = _EntityName.find('$'); - if (p1 != ucstring::npos) + string::size_type p1 = _EntityName.find('$'); + if (p1 != string::npos) { // we found a replacement point begin tag - ucstring::size_type p2 = _EntityName.find('$', p1+1); - if (p2 != ucstring::npos) + string::size_type p2 = _EntityName.find('$', p1+1); + if (p2 != string::npos) { // ok, we have the second replacement point! // extract the replacement id - ucstring id = _EntityName.substr(p1+1, p2-p1-1); + string id = _EntityName.substr(p1+1, p2-p1-1); // retrieve the translated string - _TitleRaw = id.toString(); -// ucstring replacement = CI18N::get(strNewTitle); + _TitleRaw = id; +// string replacement = CI18N::get(strNewTitle); bool womanTitle = false; CCharacterCL * c = dynamic_cast(this); if(c) @@ -2293,17 +2295,16 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) womanTitle = ( c->getGender() == GSGENDER::female ); } - ucstring replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle)); + string replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle); // Sometimes translation contains another title { - ucstring::size_type pos = replacement.find('$'); - if (pos != ucstring::npos) + string::size_type pos = replacement.find('$'); + if (pos != string::npos) { - ucstring sn = replacement; - _EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(sn.substr(0, pos)); - ucstring::size_type pos2 = sn.find('$', pos + 1); - _TitleRaw = sn.substr(pos+1, pos2 - pos - 1); + _EntityName = _EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(sn.substr(0, pos)); + string::size_type pos2 = replacement.find('$', pos + 1); + _TitleRaw = replacement.substr(pos+1, pos2 - pos - 1); replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle); } } @@ -2319,7 +2320,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) _NameEx = replacement; newtitle = _NameEx; } - CHARACTER_TITLE::ECharacterTitle titleEnum = CHARACTER_TITLE::toCharacterTitle( _TitleRaw.toString() ); + CHARACTER_TITLE::ECharacterTitle titleEnum = CHARACTER_TITLE::toCharacterTitle( _TitleRaw ); if ( titleEnum >= CHARACTER_TITLE::BeginGmTitle && titleEnum <= CHARACTER_TITLE::EndGmTitle ) { _GMTitle = titleEnum - CHARACTER_TITLE::BeginGmTitle; @@ -2357,7 +2358,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) if (pGC != NULL) pGC->setUCTitle(_EntityName); CSkillManager *pSM = CSkillManager::getInstance(); - pSM->setPlayerTitle(_TitleRaw.toString()); + pSM->setPlayerTitle(_TitleRaw); } // Must rebuild the in scene interface 'cause name has changed @@ -2368,33 +2369,33 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) //----------------------------------------------- // getTitleFromName //----------------------------------------------- -ucstring CEntityCL::getTitleFromName(const ucstring &name) +std::string CEntityCL::getTitleFromName(const std::string &name) { - ucstring::size_type p1 = name.find('$'); - if (p1 != ucstring::npos) + std::string::size_type p1 = name.find('$'); + if (p1 != string::npos) { - ucstring::size_type p2 = name.find('$', p1 + 1); - if (p2 != ucstring::npos) + std::string::size_type p2 = name.find('$', p1 + 1); + if (p2 != std::string::npos) return name.substr(p1+1, p2-p1-1); } - return ucstring(""); + return std::string(); }// getTitleFromName // //----------------------------------------------- // removeTitleFromName //----------------------------------------------- -ucstring CEntityCL::removeTitleFromName(const ucstring &name) +std::string CEntityCL::removeTitleFromName(const std::string &name) { - ucstring::size_type p1 = name.find('$'); - if (p1 == ucstring::npos) + std::string::size_type p1 = name.find('$'); + if (p1 == string::npos) { return name; } else { - ucstring::size_type p2 = name.find('$', p1 + 1); - if (p2 != ucstring::npos) + std::string::size_type p2 = name.find('$', p1 + 1); + if (p2 != string::npos) { return name.substr(0, p1) + name.substr(p2 + 1); } @@ -2408,16 +2409,16 @@ ucstring CEntityCL::removeTitleFromName(const ucstring &name) //----------------------------------------------- // removeShardFromName //----------------------------------------------- -ucstring CEntityCL::removeShardFromName(const ucstring &name) +std::string CEntityCL::removeShardFromName(const std::string &name) { // The string must contains a '(' and a ')' - ucstring::size_type p0= name.find('('); - ucstring::size_type p1= name.find(')'); - if(p0==ucstring::npos || p1==ucstring::npos || p1<=p0) + std::string::size_type p0= name.find('('); + std::string::size_type p1= name.find(')'); + if(p0==std::string::npos || p1==std::string::npos || p1<=p0) return name; // if it is the same as the shard name of the user, remove it - if(ucstrnicmp(name, (uint)p0+1, (uint)(p1-p0-1), PlayerSelectedHomeShardName)==0) + if (!NLMISC::compareCaseInsensitive(name.c_str() + p0 + 1, p1-p0-1, PlayerSelectedHomeShardName.c_str(), PlayerSelectedHomeShardName.size())) return name.substr(0,p0) + name.substr(p1+1); // else don't modify else @@ -2427,7 +2428,7 @@ ucstring CEntityCL::removeShardFromName(const ucstring &name) //----------------------------------------------- // removeTitleAndShardFromName //----------------------------------------------- -ucstring CEntityCL::removeTitleAndShardFromName(const ucstring &name) +std::string CEntityCL::removeTitleAndShardFromName(const std::string &name) { return removeTitleFromName(removeShardFromName(name)); } diff --git a/ryzom/client/src/entity_cl.h b/ryzom/client/src/entity_cl.h index e2985493a..04689a3ac 100644 --- a/ryzom/client/src/entity_cl.h +++ b/ryzom/client/src/entity_cl.h @@ -334,19 +334,19 @@ public: */ //@{ /// Return the Name of the entity. There may be a specification in it (guard, trader, etc ...). It is then surrounded by '$' - const ucstring &getEntityName() const {return _EntityName;} + const std::string &getEntityName() const {return _EntityName;} /// Return the title from a name. The specification is surrounded by '$', and tells the title of the entity (guard, matis merchant, etc ..) - static ucstring getTitleFromName(const ucstring &name); + static std::string getTitleFromName(const std::string &name); /// Remove the specification from a name. The specification is surrounded by '$', and tells the title of the entity (guard, matis merchant, etc ..) - static ucstring removeTitleFromName(const ucstring &name); + static std::string removeTitleFromName(const std::string &name); /// Remove the shard from a name (if player from the same shard). The shard is surrounded by (), and tells the incoming shard of the entity (aniro, leanon etc...) - static ucstring removeShardFromName(const ucstring &name); + static std::string removeShardFromName(const std::string &name); /// Remove both title and shard from name - static ucstring removeTitleAndShardFromName(const ucstring &name); + static std::string removeTitleAndShardFromName(const std::string &name); /// Change the entity name. - void setEntityName(const ucstring &name); + void setEntityName(const std::string &name); /// Return a displayable name - ucstring getDisplayName() const + std::string getDisplayName() const { return removeTitleAndShardFromName(_EntityName); } @@ -638,7 +638,7 @@ public: // Add hit points gain/lost by this entity. void addHPOutput(sint16 hp, NLMISC::CRGBA color, float dt=0.0f) { if(_HPModifiers.size()<20) _HPModifiers.push_back(CHPModifier(hp,color,dt));} - void addHPOutput(const ucstring &text, NLMISC::CRGBA color, float dt=0.0f) { if(_HPModifiers.size()<20 && !text.empty()) _HPModifiers.push_back(CHPModifier(text,color,dt));} + void addHPOutput(const std::string &text, NLMISC::CRGBA color, float dt=0.0f) { if(_HPModifiers.size()<20 && !text.empty()) _HPModifiers.push_back(CHPModifier(text,color,dt));} /// Return the entity sheet scale. (return 1.0 if there is any problem). virtual float getSheetScale() const {return 1.0f;} @@ -769,25 +769,25 @@ public: bool isAnOutpostAlly() const; /// Return the entity title - const ucstring &getTitle() const + const std::string &getTitle() const { return _Title; } /// Return the entity tags - const ucstring &getTag(uint8 id) const + const std::string &getTag(uint8 id) const { if (_Tags.size() > id) { return _Tags[id]; } - static ucstring empty; + static const std::string empty; return empty; } /// Return the raw unparsed entity title - const ucstring getTitleRaw() const + const std::string &getTitleRaw() const { - return ucstring(_TitleRaw); + return _TitleRaw; } /// Return true if this entity has a reserved title @@ -931,20 +931,20 @@ protected: // Flags to know what is possible to do with the entity (selectable, liftable, etc.). CProperties _Properties; // Current Name for the entity - ucstring _EntityName; + std::string _EntityName; // Current entity title - ucstring _Title; + std::string _Title; // Current entity tags - std::vector _Tags; + std::vector _Tags; // Current entity title string id - ucstring _TitleRaw; + std::string _TitleRaw; // Current permanent content symbol for the entity std::string _PermanentStatutIcon; // Has reserved title? bool _HasReservedTitle; // Extended Name - ucstring _NameEx; + std::string _NameEx; // String ID uint32 _NameId; // Primitive used for the collision in PACS @@ -995,10 +995,10 @@ protected: CHPModifier() {} virtual ~CHPModifier() {} CHPModifier (sint16 value, NLMISC::CRGBA color, float dt) : Value(value), Color(color), DeltaT(dt) {} - CHPModifier (const ucstring &text, NLMISC::CRGBA color, float dt) : Text(text), Color(color), DeltaT(dt) {} + CHPModifier (const std::string &text, NLMISC::CRGBA color, float dt) : Text(text), Color(color), DeltaT(dt) {} sint16 Value; // If Text.empty(), take the Value - ucstring Text; + std::string Text; NLMISC::CRGBA Color; float DeltaT; }; @@ -1222,7 +1222,7 @@ public: private: // Override for string reception callback - virtual void onStringAvailable(uint stringId, const ucstring &value); + virtual void onStringAvailable(uint stringId, const std::string &value); }; diff --git a/ryzom/client/src/far_tp.cpp b/ryzom/client/src/far_tp.cpp index 80134f26b..fa3d9720d 100644 --- a/ryzom/client/src/far_tp.cpp +++ b/ryzom/client/src/far_tp.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2016 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -927,7 +927,7 @@ retryJoinEdit: } } pIM->messageBoxWithHelp( - CI18N::get(requestRetToMainland ? "uiSessionVanishedFarTP" : "uiSessionUnreachable") + ucstring(errorMsg), + CI18N::get(requestRetToMainland ? "uiSessionVanishedFarTP" : "uiSessionUnreachable") + errorMsg, letReturnToCharSelect ? "ui:outgame:charsel" : "ui:interface"); // Info in the log @@ -1117,7 +1117,7 @@ void CFarTP::disconnectFromPreviousShard() // Start progress bar and display background ProgressBar.reset (BAR_STEP_TP); - ucstring nmsg("Loading..."); + string nmsg("Loading..."); ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); ProgressBar.progress(0); diff --git a/ryzom/client/src/forage_source_cl.cpp b/ryzom/client/src/forage_source_cl.cpp index 4e673caaf..7141ad62f 100644 --- a/ryzom/client/src/forage_source_cl.cpp +++ b/ryzom/client/src/forage_source_cl.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -101,7 +102,7 @@ bool CForageSourceCL::build( const CEntitySheet *sheet ) const CForageSourceSheet *forageSourceSheet = dynamic_cast(sheet); if ( ! forageSourceSheet ) { - nlwarning( "Bad sheet %s for forage source", sheet->Id.toString().c_str() ); + nlwarning( "Bad sheet %s for forage source", sheet ? sheet->Id.toString().c_str() : "NULL" ); return false; } if ( ! setFx( forageSourceSheet->FxFilename ) ) @@ -507,9 +508,9 @@ void CForageSourceCL::updateVisualPropertyVisualFX(const NLMISC::TGameCycle &/* CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; if (prospector != NULL) { - ucstring prospectorName = prospector->getDisplayName(); + string prospectorName = prospector->getDisplayName(); if ( ! prospectorName.empty() ) - _EntityName += ucstring(" [") + prospectorName + ucstring("]"); + _EntityName += " [" + prospectorName + "]"; } } @@ -535,7 +536,7 @@ void CForageSourceCL::updateVisualPropertyVisualFX(const NLMISC::TGameCycle &/* void CForageSourceCL::updateVisualPropertyName(const NLMISC::TGameCycle &/* gameCycle */, const sint64 &prop) { CSheetId rmSheetId( (const uint32&)prop ); - const ucchar *name = STRING_MANAGER::CStringManagerClient::getItemLocalizedName( rmSheetId ); + const char *name = STRING_MANAGER::CStringManagerClient::getItemLocalizedName( rmSheetId ); if ( name ) { _EntityName = name; @@ -544,9 +545,9 @@ void CForageSourceCL::updateVisualPropertyName(const NLMISC::TGameCycle &/* game CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; if (prospector != NULL) { - ucstring prospectorName = prospector->getDisplayName(); + std::string prospectorName = prospector->getDisplayName(); if ( ! prospectorName.empty() ) - _EntityName += ucstring(" [") + prospectorName + ucstring("]"); + _EntityName += " [" + prospectorName + "]"; } } // Rebuild inscene interface @@ -567,9 +568,9 @@ void CForageSourceCL::updateVisualPropertyTarget(const NLMISC::TGameCycle &/* ga CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; // NULL if entity not received if (prospector != NULL) { - ucstring prospectorName = prospector->getDisplayName(); + std::string prospectorName = prospector->getDisplayName(); if ( ! prospectorName.empty() ) - _EntityName = _EntityName + ucstring(" [") + prospectorName + ucstring("]"); + _EntityName = _EntityName + " [" + prospectorName + "]"; } // Rebuild inscene interface @@ -622,7 +623,7 @@ void CForageSourceCL::displayModifiers() { uint16 qttyDelta = ((uint16)mod.Value) & 0xFF; uint16 qlty = ((uint16)mod.Value) >> 8; - ucstring hpModifier = ucstring(toString("%u ", qttyDelta) + CI18N::get("uittQualityAbbrev") + toString(" %u", qlty)); + string hpModifier = toString("%u ", qttyDelta) + CI18N::get("uittQualityAbbrev") + toString(" %u", qlty); double t = TimeInSec-mod.Time; // Compute the position for the Modifier. CVector pos= namePos + CVector(0.0f, 0.0f, 0.3f+(float)t*1.0f/totalDuration); diff --git a/ryzom/client/src/fx_cl.cpp b/ryzom/client/src/fx_cl.cpp index e1f29fd77..32a764e99 100644 --- a/ryzom/client/src/fx_cl.cpp +++ b/ryzom/client/src/fx_cl.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -75,7 +78,7 @@ bool CFxCL::build( const CEntitySheet *sheet ) if ( (! _FXSheet) || (_FXSheet->PSList.empty()) ) { _BadBuild = true; - nlwarning( "Bad sheet %s for fx", sheet->Id.toString().c_str() ); + nlwarning( "Bad sheet %s for fx", sheet ? sheet->Id.toString().c_str() : "NULL" ); return false; } diff --git a/ryzom/client/src/game_context_menu.cpp b/ryzom/client/src/game_context_menu.cpp index 78e58c4b5..17078677d 100644 --- a/ryzom/client/src/game_context_menu.cpp +++ b/ryzom/client/src/game_context_menu.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -761,7 +762,7 @@ void CGameContextMenu::updateContextMenuMissionsOptions( bool forceHide ) uint32 textID = (uint32) _MissionOption[k]->getValue32(); if (textID) { - ucstring result; + string result; bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID, result); if (!res) { @@ -783,13 +784,13 @@ void CGameContextMenu::updateContextMenuMissionsOptions( bool forceHide ) } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); pVTM->setActive(false); } } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); pVTM->setActive(false); } } @@ -813,7 +814,7 @@ void CGameContextMenu::updateContextMenuWebPage(uint options) uint32 textID = (uint32) _WebPageTitle->getValue32(); if (textID) { - ucstring result; + string result; bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID, result); if (!res) { @@ -823,12 +824,12 @@ void CGameContextMenu::updateContextMenuWebPage(uint options) } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); } } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); } } @@ -857,7 +858,7 @@ void CGameContextMenu::updateContextMenuOutpostState(uint options) { CViewTextMenu *pVTM = _TextOutpostState; if (pVTM) - pVTM->setText(ucstring(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet))); + pVTM->setText(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)); } // apply the active @@ -893,7 +894,7 @@ void CGameContextMenu::updateContextMenuMissionRing() // if the textId is ok and Flag is set. if ( textId ) { - ucstring result; + string result; bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, result); if (!res) { @@ -904,7 +905,7 @@ void CGameContextMenu::updateContextMenuMissionRing() } else { - pVTM->setText(ucstring("")); + pVTM->setText(""); pVTM->setActive(false); } } diff --git a/ryzom/client/src/init.cpp b/ryzom/client/src/init.cpp index 5e7b03549..b9e701e92 100644 --- a/ryzom/client/src/init.cpp +++ b/ryzom/client/src/init.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Robert TIMM (rti) -// Copyright (C) 2010-2019 Jan BOON (Kaetemi) +// Copyright (C) 2010-2020 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) // // This program is free software: you can redistribute it and/or modify @@ -168,7 +168,7 @@ extern NLMISC::CCmdArgs Args; // Tips of the day count #define RZ_NUM_TIPS 17 -ucstring TipsOfTheDay; +std::string TipsOfTheDay; uint TipsOfTheDayIndex; // includes for following register classes @@ -262,7 +262,7 @@ char *XmlStrdup4NeL (const char *str) #ifdef NL_OS_WINDOWS -static ucstring CurrentErrorMessage; +static std::wstring CurrentErrorMessage; static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM /* lParam */) { @@ -272,19 +272,19 @@ static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARA { if (CI18N::hasTranslation("TheSagaOfRyzom")) { - if (!SetWindowTextW(hwndDlg, (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str ())) + if (!SetWindowTextW(hwndDlg, nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()))) { nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str()); } } - SetDlgItemTextW(hwndDlg, IDC_ERROR_MSG_TEXT, (WCHAR*) CurrentErrorMessage.c_str ()); + SetDlgItemTextW(hwndDlg, IDC_ERROR_MSG_TEXT, (WCHAR*)CurrentErrorMessage.c_str()); if (CI18N::hasTranslation("uiRyzomErrorMsgBoxExit")) { - SetDlgItemTextW(hwndDlg, IDOK, (WCHAR*)CI18N::get ("uiRyzomErrorMsgBoxExit").c_str ()); + SetDlgItemTextW(hwndDlg, IDOK, nlUtf8ToWide(CI18N::get("uiRyzomErrorMsgBoxExit").c_str())); } if (CI18N::hasTranslation("uiRyzomErrorMsgBoxHelp")) { - SetDlgItemTextW(hwndDlg, IDC_RYZOM_ERROR_HELP, (WCHAR*)CI18N::get ("uiRyzomErrorMsgBoxHelp").c_str ()); + SetDlgItemTextW(hwndDlg, IDC_RYZOM_ERROR_HELP, nlUtf8ToWide(CI18N::get("uiRyzomErrorMsgBoxHelp").c_str())); } RECT rect; RECT rectDesktop; @@ -338,12 +338,12 @@ void ExitClientError (const char *format, ...) } #ifdef NL_OS_WINDOWS - CurrentErrorMessage.fromUtf8(str); + CurrentErrorMessage = NLMISC::utf8ToWide(str); DialogBox(HInstance, MAKEINTRESOURCE(IDD_ERROR_HELP_MESSAGE_BOX), NULL, ExitClientErrorDialogProc); /* ucstring ucstr; ucstr.fromUtf8 (str); - MessageBoxW (NULL, (WCHAR*)ucstr.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_OK|MB_ICONERROR); + MessageBoxW (NULL, (WCHAR *)ucstr.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONERROR); */ #else fprintf (stderr, "%s\n", str); @@ -360,7 +360,7 @@ void ExitClientError (const char *format, ...) void ClientInfo (const ucstring &message) { #ifdef NL_OS_WINDOWS - MessageBoxW (NULL, (WCHAR*)message.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_OK|MB_ICONINFORMATION); + MessageBoxW(NULL, (WCHAR *)message.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONINFORMATION); #endif } @@ -368,7 +368,7 @@ void ClientInfo (const ucstring &message) bool ClientQuestion (const ucstring &message) { #ifdef NL_OS_WINDOWS - return MessageBoxW (NULL, (WCHAR*)message.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_YESNO|MB_ICONQUESTION) != IDNO; + return MessageBoxW(NULL, (WCHAR *)message.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_YESNO|MB_ICONQUESTION) != IDNO; #else return false; #endif @@ -578,7 +578,7 @@ void checkDriverDepth () #else if (mode.Depth != 16 && mode.Depth != 24 && mode.Depth != 32) #endif - ExitClientError (CI18N::get ("uiDesktopNotIn32").toUtf8().c_str ()); + ExitClientError (CI18N::get ("uiDesktopNotIn32").c_str ()); } } @@ -937,7 +937,7 @@ void prelogInit() initDebugMemory(); // Load the application configuration. - ucstring nmsg("Loading config file..."); + string nmsg("Loading config file..."); ProgressBar.newMessage (nmsg); ClientCfg.init(ConfigFileName); @@ -1058,7 +1058,7 @@ void prelogInit() 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 return; } @@ -1149,14 +1149,14 @@ void prelogInit() string msg; if (mode.Windowed) { - msg = CI18N::get ("can_t_create_a_window_display").toUtf8(); + msg = CI18N::get ("can_t_create_a_window_display"); } 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 += CI18N::get ("bits").toUtf8 (); + msg += CI18N::get ("bits"); msg += ")"; ExitClientError (msg.c_str (), mode.Width, mode.Height, mode.Depth); // ExitClientError() call exit() so the code after is never called @@ -1532,7 +1532,7 @@ void postlogInit() Driver->clearBuffers(CRGBA::Black); Driver->swapBuffers(); CNiceInputAuto niceInputs; - ucstring nmsg; + string nmsg; try { diff --git a/ryzom/client/src/init_main_loop.cpp b/ryzom/client/src/init_main_loop.cpp index deeda2149..0714d1553 100644 --- a/ryzom/client/src/init_main_loop.cpp +++ b/ryzom/client/src/init_main_loop.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -225,8 +225,8 @@ struct CStatThread : public NLMISC::IRunnable string cookie() { string name; - if(UserEntity && !UserEntity->getEntityName().toString().empty()) - name = UserEntity->getEntityName().toString(); + if(UserEntity && !UserEntity->getEntityName().empty()) + name = UserEntity->getEntityName(); std::string userid = toString("u%d", NetMngr.getUserId())+name; return toUpper(getMD5((const uint8 *)userid.c_str(), (uint32)userid.size()).toString()); @@ -236,7 +236,7 @@ struct CStatThread : public NLMISC::IRunnable bool connect() { //nlinfo("connect"); - if(!UserEntity || UserEntity->getEntityName().toString().empty()) + if(!UserEntity || UserEntity->getEntityName().empty()) return false; referer = ContinentMngr.getCurrentContinentSelectName(); @@ -260,7 +260,7 @@ struct CStatThread : public NLMISC::IRunnable timeinfo = localtime ( &rawtime ); strftime (buffer,80,"%H%%3A%M", timeinfo); addParam(params, "localtime", buffer); - addParam(params, "cv_name", UserEntity->getEntityName().toUtf8()); + addParam(params, "cv_name", UserEntity->getEntityName()); //addParam(params, "cv_email", ""); //addParam(params, "cv_avatar", ""); addParam(params, "cv_Userid", toString(NetMngr.getUserId())); @@ -469,7 +469,7 @@ void initMainLoop() // Progress bar for init_main_loop() ProgressBar.reset (BAR_STEP_INIT_MAIN_LOOP); - ucstring nmsg; + string nmsg; FPU_CHECKER_ONCE @@ -1017,7 +1017,7 @@ void initMainLoop() // PreLoad Fauna and Characters if (!ClientCfg.Light && ClientCfg.PreCacheShapes) { - ucstring nmsg("Loading character shapes ..."); + string nmsg("Loading character shapes ..."); ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); @@ -1702,6 +1702,6 @@ void initBloomConfigUI() else { if(group) - group->setDefaultContextHelp(ucstring("")); + group->setDefaultContextHelp(std::string()); } } diff --git a/ryzom/client/src/interface_v3/action_handler_edit.cpp b/ryzom/client/src/interface_v3/action_handler_edit.cpp index 00a07dd39..1f3b7ee4f 100644 --- a/ryzom/client/src/interface_v3/action_handler_edit.cpp +++ b/ryzom/client/src/interface_v3/action_handler_edit.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -27,6 +28,7 @@ using namespace NLMISC; #include "nel/gui/action_handler.h" #include "nel/gui/group_editbox.h" +#include "nel/misc/utf_string_view.h" #include "interface_manager.h" #include "../client_chat_manager.h" #include "people_interraction.h" @@ -56,7 +58,7 @@ extern CClientChatManager ChatMngr; // *************************************************************************** // used for character classifiction (when the user press Ctrl-arrow) -static inline uint getCharacterCategory(ucchar c) +static inline uint getCharacterCategory(u32char c) { if (c == ' ') return 0; if (c > 127 || isalpha((char) c)) return 1; // alpha & other characters @@ -69,7 +71,7 @@ static inline uint getCharacterCategory(ucchar c) /** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed) * It returns the new index */ -static uint skipUCCharsRight(uint startPos, const ucstring &str) +static uint skipUCCharsRight(uint startPos, const ::u32string &str) { uint pos = startPos; uint endIndex = (uint)str.length(); @@ -86,7 +88,7 @@ static uint skipUCCharsRight(uint startPos, const ucstring &str) /** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed) * It returns the new index */ -static uint skipUCCharsLeft(uint startPos, const ucstring &str) +static uint skipUCCharsLeft(uint startPos, const ::u32string &str) { uint pos = startPos; -- pos; @@ -287,11 +289,11 @@ class CAHEditGotoLineBegin : public CAHEdit // go to the start of line if (_GroupEdit->getViewText()) { - sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length()); + sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length()); if (line == -1) return; - sint newPos = std::max(_GroupEdit->getViewText()->getLineStartIndex(line), (sint) _GroupEdit->getPrompt().length()); + sint newPos = std::max(_GroupEdit->getViewText()->getLineStartIndex(line), (sint) _GroupEdit->getPromptRef().length()); if (newPos == -1) return; - _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(false); } } @@ -309,20 +311,20 @@ class CAHEditGotoLineEnd : public CAHEdit { if (_GroupEdit->getViewText()->getMultiLine()) { - sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length(), _GroupEdit->isCursorAtPreviousLineEnd()); + sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length(), _GroupEdit->isCursorAtPreviousLineEnd()); if (line == -1) return; sint newPos; bool endOfPreviousLine; _GroupEdit->getViewText()->getLineEndIndex(line, newPos, endOfPreviousLine); if (newPos != -1) { - _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(endOfPreviousLine); } } else { - _GroupEdit->setCursorPos((sint32)_GroupEdit->getPrompt().length() + (sint32)_GroupEdit->getInputString().length()); + _GroupEdit->setCursorPos((sint32)_GroupEdit->getPromptRef().length() + (sint32)_GroupEdit->getInputString().length()); } } } @@ -362,7 +364,7 @@ class CAHEditPreviousLine : public CAHEdit if (_GroupEdit->getMaxHistoric() && (! _GroupEdit->getViewText()->getMultiLine())) { // Get the start of the string. - ucstring startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); + ::u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); // Search all historic string that match startStr. for(sint i=_GroupEdit->getCurrentHistoricIndex()+1;i<(sint)_GroupEdit->getNumHistoric();i++) @@ -377,7 +379,7 @@ class CAHEditPreviousLine : public CAHEdit } else if (_GroupEdit->getViewText()->getMultiLine()) { - uint cursorPosInText = _GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length(); + uint cursorPosInText = _GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length(); if ( (_GroupEdit->getCursorPos() == (sint32) _GroupEdit->getInputStringRef().length() && _GroupEdit->getViewText()->getNumLine() == 1) || _GroupEdit->getViewText()->getLineFromIndex(cursorPosInText, _GroupEdit->isCursorAtPreviousLineEnd()) == 0 @@ -395,7 +397,7 @@ class CAHEditPreviousLine : public CAHEdit _GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd); if (newLineEnd) { - _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(true); sint32 newPos = _GroupEdit->getCursorPos(); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); @@ -416,7 +418,7 @@ class CAHEditPreviousLine : public CAHEdit { _GroupEdit->setCursorPos(newCharIndex + 1); } - _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPromptRef().length()); sint32 newpos = _GroupEdit->getCursorPos(); clamp(newpos, (sint32) 0, (sint32)_GroupEdit->getInputStringRef().size()); _GroupEdit->setCursorPos(newpos); @@ -434,7 +436,7 @@ class CAHEditNextLine : public CAHEdit if( (! _GroupEdit->getViewText()->getMultiLine()) && _GroupEdit->getMaxHistoric() && _GroupEdit->getCurrentHistoricIndex()>0) { // Get the start of the string. - ucstring startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); + ::u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); // Search all historic string that match startStr. for(sint i=_GroupEdit->getCurrentHistoricIndex()-1;i>=0;i--) @@ -451,7 +453,7 @@ class CAHEditNextLine : public CAHEdit { float cx, cy; float height; - _GroupEdit->getViewText()->getCharacterPositionFromIndex(_GroupEdit->getCursorPos() + (sint)_GroupEdit->getPrompt().length(), _GroupEdit->isCursorAtPreviousLineEnd(), cx, cy, height); + _GroupEdit->getViewText()->getCharacterPositionFromIndex(_GroupEdit->getCursorPos() + (sint)_GroupEdit->getPromptRef().length(), _GroupEdit->isCursorAtPreviousLineEnd(), cx, cy, height); if (cy != 0) { cy -= height; @@ -460,7 +462,7 @@ class CAHEditNextLine : public CAHEdit _GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd); if (newLineEnd) { - _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPromptRef().length()); _GroupEdit->setCursorAtPreviousLineEnd(true); sint32 newPos = _GroupEdit->getCursorPos(); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); @@ -479,9 +481,9 @@ class CAHEditNextLine : public CAHEdit } else { - _GroupEdit->setCursorPos(min(sint32(newCharIndex + 1), sint32(_GroupEdit->getInputStringRef().length() + _GroupEdit->getPrompt().length()))); + _GroupEdit->setCursorPos(min(sint32(newCharIndex + 1), sint32(_GroupEdit->getInputStringRef().length() + _GroupEdit->getPromptRef().length()))); } - _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPrompt().length()); + _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPromptRef().length()); sint32 newPos = _GroupEdit->getCursorPos(); clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size()); _GroupEdit->setCursorPos(newPos); @@ -520,8 +522,8 @@ protected: // else cut forwards else if(_GroupEdit->getCursorPos() < (sint32) _GroupEdit->getInputStringRef().length()) { - ucstring inputString = _GroupEdit->getInputStringRef(); - ucstring::iterator it = inputString.begin() + _GroupEdit->getCursorPos(); + ::u32string inputString = _GroupEdit->getInputStringRef(); + ::u32string::iterator it = inputString.begin() + _GroupEdit->getCursorPos(); inputString.erase(it); _GroupEdit->setInputStringRef (inputString); if (!_GroupEdit->getAHOnChange().empty()) @@ -638,15 +640,14 @@ class CAHEditExpandOrCycleTell : public CAHEdit void actionPart () { // If the line starts with '/tell ', do not try to expand - static const ucstring TELL_STR("/tell "); - if (_GroupEdit->getInputString().substr(0, TELL_STR.length()) != TELL_STR) + if (!NLMISC::startsWith(_GroupEdit->getInputString(), "/tell ")) { if (_GroupEdit->expand()) return; } CInterfaceManager *im = CInterfaceManager::getInstance(); if (!im->isInGame()) return; // there was no / at the start of the line so try to cycle through the last people on which a tell was done - const ucstring *lastTellPeople = ChatMngr.cycleLastTell(); + const string *lastTellPeople = ChatMngr.cycleLastTell(); if (!lastTellPeople) return; // Get chat box from ist edit box // If it isn't a user chat or the main chat, just display 'tell' with the name. Otherwise, change the target of the window @@ -660,7 +661,7 @@ class CAHEditExpandOrCycleTell : public CAHEdit else { // it is not a filtered chat, display 'tell' (must be ingame) - _GroupEdit->setCommand(ucstring("tell ") + *lastTellPeople + (ucchar) ' ', false); + _GroupEdit->setCommand("tell " + (*lastTellPeople) + ' ', false); } } }; diff --git a/ryzom/client/src/interface_v3/action_handler_game.cpp b/ryzom/client/src/interface_v3/action_handler_game.cpp index 3e3ce9b8e..0847b1776 100644 --- a/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -192,9 +192,9 @@ public: CEntityCL *selection = EntitiesMngr.entity(UserEntity->selection()); if (selection && selection->Type == CEntityCL::Player) { - ucstring name = CEntityCL::removeTitleAndShardFromName(selection->getEntityName()); + string name = CEntityCL::removeTitleAndShardFromName(selection->getEntityName()); if (name.empty()) return; - CAHManager::getInstance()->runActionHandler("enter_tell", pCaller, "player=" + name.toString()); + CAHManager::getInstance()->runActionHandler("enter_tell", pCaller, "player=" + name); } } protected: @@ -1334,7 +1334,7 @@ class CSelectItemSheet : public IActionHandler // check if user has the level to use the item (applies to item & plans) if (ctrlSheet->getSheetCategory() == CDBCtrlSheet::Item) { - if (csg->getName() == "buy_selection") + if (csg && csg->getName() == "buy_selection") { const CItemSheet *is = ctrlSheet->asItemSheet(); if (is) @@ -1358,19 +1358,19 @@ class CSelectItemSheet : public IActionHandler // display msg in the system infos if (!canUse) { - ucstring msg = CI18N::get("msgCantUseItem"); + string msg = CI18N::get("msgCantUseItem"); string cat = getStringCategory(msg, msg); im->displaySystemInfo(msg, cat); } if (!canBuild) { - ucstring msg = CI18N::get("msgCantBuild"); + string msg = CI18N::get("msgCantBuild"); string cat = getStringCategory(msg, msg); im->displaySystemInfo(msg, cat); } if (!canUseBuiltItem) { - ucstring msg = CI18N::get("msgCantUseBuiltItem"); + string msg = CI18N::get("msgCantUseBuiltItem"); string cat = getStringCategory(msg, msg); im->displaySystemInfo(msg, cat); } @@ -1943,13 +1943,13 @@ public: sint32 Slot; - bool cbIDStringReceived(ucstring &inout) + bool cbIDStringReceived(string &inout) { if (UserEntity != NULL) { if (UserEntity->selection() == Slot) { - ucstring copyInout = inout; + string copyInout = inout; CStringPostProcessRemoveTitle::cbIDStringReceived(inout); if (inout.empty()) { @@ -1959,11 +1959,11 @@ public: if (pChar != NULL) womanTitle = pChar->getGender() == GSGENDER::female; - STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); + copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); // Sometimes translation contains another title - ucstring::size_type pos = copyInout.find('$'); - if (pos != ucstring::npos) + string::size_type pos = copyInout.find('$'); + if (pos != string::npos) { copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); } @@ -1987,7 +1987,7 @@ public: sint32 Slot; - bool cbIDStringReceived(ucstring &inout) + bool cbIDStringReceived(string &inout) { if (UserEntity != NULL) { @@ -2038,8 +2038,8 @@ class CActionHandlerSetTargetName : public IActionHandler { sint32 nSlot = (sint32)evValue.getInteger(); - ucstring TargetName; - ucstring TargetTitle; + string TargetName; + string TargetTitle; // Get from nSlot if (nSlot > -1) @@ -2074,9 +2074,9 @@ class CActionHandlerSetTargetName : public IActionHandler // Set to target CInterfaceExprValue evUCStr; TargetName = STRING_MANAGER::CStringManagerClient::getLocalizedName(TargetName); - evUCStr.setUCString(TargetName); + evUCStr.setString(TargetName); CInterfaceLink::setTargetProperty(sNameTarget, evUCStr); - evUCStr.setUCString(TargetTitle); + evUCStr.setString(TargetTitle); CInterfaceLink::setTargetProperty(sTitleTarget, evUCStr); } } @@ -2116,7 +2116,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler pVBR->setColor(CRGBA(0,0,0,0)); if (pTooltip) - pTooltip->setDefaultContextHelp(ucstring("")); + pTooltip->setDefaultContextHelp(std::string()); return; } @@ -2169,7 +2169,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler pVBR->setColor(CRGBA(0,0,0,0)); if (pTooltip) - pTooltip->setDefaultContextHelp(ucstring("")); + pTooltip->setDefaultContextHelp(std::string()); return; } @@ -2194,7 +2194,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler CCtrlBase *tooltip = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:target:header_opened:force")); if (tooltip) { - ucstring str; + string str; if (nForceRegion == 1) nForceRegion = 2; @@ -2424,28 +2424,27 @@ class CAHTarget : public IActionHandler { virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { - ucstring entityName; - entityName.fromUtf8(getParam(Params, "entity")); + string entityName = getParam(Params, "entity"); if (entityName.empty()) return; string completeMatch = getParam(Params, "prefer_complete_match"); bool quiet = (getParam (Params, "quiet") == "true"); - vector keywords; - NLMISC::splitUCString(entityName, ucstring(" "), keywords); - if (!keywords.empty() && keywords[0].size() > 0 && keywords[0][0] == (ucchar)'"') + vector keywords; + NLMISC::splitString(entityName, " ", keywords); + if (!keywords.empty() && keywords[0].size() > 0 && keywords[0][0] == '"') { // entity name is in quotes, do old style match with 'starts with' filter // search for optional second parameter from old command for prefer_complete_match param keywords.clear(); - ucstring::size_type lastOf = entityName.rfind(ucstring("\"")); + string::size_type lastOf = entityName.rfind("\""); if (lastOf == 0) - lastOf = ucstring::npos; + lastOf = string::npos; // override the value only when there is no 'prefer_complete_match' parameter set if (completeMatch.empty() && lastOf < entityName.size()) - completeMatch = trim(entityName.substr(lastOf+1).toUtf8()); + completeMatch = trim(entityName.substr(lastOf+1)); entityName = entityName.substr(1, lastOf-1); } @@ -2474,7 +2473,7 @@ class CAHTarget : public IActionHandler if (entity == NULL) { //Get the entity with a sheetName - entity = EntitiesMngr.getEntityBySheetName(entityName.toUtf8()); + entity = EntitiesMngr.getEntityBySheetName(entityName); } if (entity && entity->properties().selectable() && !entity->getDisplayName().empty()) @@ -2758,8 +2757,7 @@ class CAHAssist : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { // Get the entity name to target - ucstring entityName; - entityName.fromUtf8 (getParam (Params, "entity")); + string entityName = getParam (Params, "entity"); if (!entityName.empty()) { // Get the entity @@ -2822,24 +2820,6 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { - /* // Previous version (multiple pressed on a desktop change a central window - uint desktop; - fromString(Params, desktop); - if (desktop getDbProp(dbNames[desktop], false); - if (pNL != NULL) - sValue = NLMISC::toString((sint32)pNL->getValue64()); - vector vecStr; - vecStr.push_back(procNames[desktop]); - vecStr.push_back(sValue); - CWidgetManager::getInstance()->runProcedure(procNames[desktop], NULL, vecStr); - }*/ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:gestion_windows")); if (pGC == NULL) @@ -2850,11 +2830,14 @@ public: CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId("ui:interface:gestion_windows:close"); if (pIE != NULL) pIE->setActive(false); + bool switchDesktop = false; + CActionsManager *pAM = &Actions; if (!pAM->valide(CAction::CName("set_desktop",Params.c_str()))) { pGC->setActive(false); _FirstTime = true; + switchDesktop = true; } else // Key is down { @@ -2862,11 +2845,7 @@ public: if (_FirstTime) { _FirstTime = false; - - vector vecStr; - vecStr.push_back("tb_setdesktop"); - vecStr.push_back(Params); - CWidgetManager::getInstance()->runProcedure("tb_setdesktop", NULL, vecStr); + switchDesktop = true; } else // Not the first time { @@ -2876,6 +2855,13 @@ public: CWidgetManager::getInstance()->setTopWindow(pGC); } } + if (switchDesktop) + { + vector vecStr; + vecStr.push_back("tb_setdesktop"); + vecStr.push_back(Params); + CWidgetManager::getInstance()->runProcedure("tb_setdesktop", NULL, vecStr); + } } private: bool _FirstTime; @@ -3025,7 +3011,7 @@ void updateVRDevicesComboUI(bool enable) { std::stringstream displayname; displayname << std::string("[") << VRDeviceCache[i].first << "] [" << VRDeviceCache[i].second << "]"; - pCB->addText(ucstring(displayname.str())); + pCB->addText(displayname.str()); if (ClientCfg.VRDisplayDevice == VRDeviceCache[i].first) { if (selectedDevice == -1 || ClientCfg.VRDisplayDeviceId == VRDeviceCache[i].second) @@ -3039,7 +3025,7 @@ void updateVRDevicesComboUI(bool enable) // configured device not found, add a dummy std::stringstream displayname; displayname << std::string("[") << ClientCfg.VRDisplayDevice << "] [" << ClientCfg.VRDisplayDeviceId<< "] [DEVICE NOT FOUND]"; - pCB->addText(ucstring(displayname.str())); + pCB->addText(displayname.str()); selectedDevice = VRDeviceCache.size(); } NLGUI::CDBManager::getInstance()->getDbProp(GAME_CONFIG_VR_DEVICE_DB)->setValue32(-1); @@ -3074,7 +3060,7 @@ public: { pCB->resetTexts(); for (sint j = 0; j < (sint)stringModeList.size(); j++) - pCB->addText(ucstring(stringModeList[j])); + pCB->addText(stringModeList[j]); } // frequencies @@ -3083,7 +3069,7 @@ public: { pCB->resetTexts(); for (sint j = 0; j < (sint)stringFreqList.size(); j++) - pCB->addText(ucstring(stringFreqList[j])); + pCB->addText(stringFreqList[j]); } // -1 is important to indicate we set this value in edit mode @@ -3129,7 +3115,7 @@ public: while (anisotropic <= maxAnisotropic) { - pCB->addText(ucstring(NLMISC::toString("%dx", anisotropic))); + pCB->addText(NLMISC::toString("%dx", anisotropic)); if (ClientCfg.AnisotropicFilter == anisotropic) nAnisotropic = i; @@ -3234,7 +3220,7 @@ class CHandlerGameConfigMode : public IActionHandler // Get W, H sint w,h; { - string vidModeStr = pCB->getText(nVideModeNb).toString(); + string vidModeStr = pCB->getText(nVideModeNb); string tmp = vidModeStr.substr(0,vidModeStr.find('x')-1); fromString(tmp, w); tmp = vidModeStr.substr(vidModeStr.find('x')+2,vidModeStr.size()); @@ -3274,7 +3260,7 @@ class CHandlerGameConfigMode : public IActionHandler { pCB->resetTexts(); for (j = 0; j < (sint)stringFreqList.size(); j++) - pCB->addText(ucstring(stringFreqList[j]) + " Hz"); + pCB->addText(stringFreqList[j] + " Hz"); } NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(nFoundFreq); @@ -3476,7 +3462,7 @@ class CHandlerGameConfigApply : public IActionHandler CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); if( pCB != NULL ) { - string vidModeStr = pCB->getText(nVideModeNb).toString(); + string vidModeStr = pCB->getText(nVideModeNb); string tmp = vidModeStr.substr(0,vidModeStr.find('x')-1); fromString(tmp, w); tmp = vidModeStr.substr(vidModeStr.find('x')+2,vidModeStr.size()); @@ -3490,7 +3476,7 @@ class CHandlerGameConfigApply : public IActionHandler CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); if( pCB != NULL ) { - string vidFreqStr = pCB->getText(nVideoFreqNb).toString(); + string vidFreqStr = pCB->getText(nVideoFreqNb); fromString(vidFreqStr, freq); } } @@ -3809,7 +3795,7 @@ class CHandlerSetInterfaceScale : public IActionHandler } } - ucstring help("/setuiscale "+toString("%.1f .. %.1f", ClientCfg.InterfaceScale_min, ClientCfg.InterfaceScale_max)); + string help = "/setuiscale "+toString("%.1f .. %.1f", ClientCfg.InterfaceScale_min, ClientCfg.InterfaceScale_max); CInterfaceManager::getInstance()->displaySystemInfo(help); } }; @@ -3993,7 +3979,7 @@ public: // display parry mode msg CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgUserModeParry"); + string msg = CI18N::get("msgUserModeParry"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); } @@ -4010,7 +3996,7 @@ public: // display dodge mode msg CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgUserModeDodge"); + string msg = CI18N::get("msgUserModeDodge"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); } @@ -4038,7 +4024,7 @@ REGISTER_ACTION_HANDLER(CHandlerSelectProtectedSlot, "select_protected_slot"); // *************************************************************************** // Common code //static void fillPlayerBarText(ucstring &str, const string &dbScore, const string &dbScoreMax, const string &ttFormat) -static void fillPlayerBarText(ucstring &str, const string &dbScore, SCORES::TScores score, const string &ttFormat) +static void fillPlayerBarText(std::string &str, const string &dbScore, SCORES::TScores score, const string &ttFormat) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); CCDBNodeLeaf *node; @@ -4068,7 +4054,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring str; + string str; fillPlayerBarText(str, "HP", SCORES::hit_points, "uittPlayerLifeFormat"); CWidgetManager::getInstance()->setContextHelpText(str); @@ -4085,7 +4071,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring str; + string str; fillPlayerBarText(str, "STA", SCORES::stamina, "uittPlayerStaminaFormat"); CWidgetManager::getInstance()->setContextHelpText(str); @@ -4102,7 +4088,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring str; + string str; fillPlayerBarText(str, "SAP", SCORES::sap, "uittPlayerSapFormat"); CWidgetManager::getInstance()->setContextHelpText(str); @@ -4119,7 +4105,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring str; + string str; fillPlayerBarText(str, "FOCUS", SCORES::focus, "uittPlayerFocusFormat"); CWidgetManager::getInstance()->setContextHelpText(str); @@ -4149,7 +4135,7 @@ public: maxVal= node->getValue32(); // Replace in the formated text - ucstring str= CI18N::get("uittBulkFormat"); + string str= CI18N::get("uittBulkFormat"); strFindReplace(str, "%v", toString("%.2f", val) ); strFindReplace(str, "%m", toString(maxVal) ); CWidgetManager::getInstance()->setContextHelpText(str); @@ -4545,7 +4531,7 @@ public: if( sCustomPhrase.empty() ) { // Create the message and send. - const string msgName = "COMMAND:EMOTE"; + static const string msgName = "COMMAND:EMOTE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -4560,11 +4546,11 @@ public: else { // Create the message and send. - const string msgName = "COMMAND:CUSTOM_EMOTE"; + static const string msgName = "COMMAND:CUSTOM_EMOTE"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { - ucstring ucstr; + ucstring ucstr; // FIXME: UTF-8 (serial) ucstr.fromUtf8(sCustomPhrase); if( sCustomPhrase == "none" ) @@ -4573,7 +4559,7 @@ public: { // display "no animation for emote" CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgCustomizedEmoteNoAnim"); + string msg = CI18N::get("msgCustomizedEmoteNoAnim"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); return; @@ -4585,7 +4571,7 @@ public: } out.serialEnum(behavToSend); - out.serial(ucstr); + out.serial(ucstr); // FIXME: UTF-8 (serial) NetMngr.push(out); //nlinfo("impulseCallBack : %s %d %s sent", msgName.c_str(), (uint32)behavToSend, sCustomPhrase.c_str()); } @@ -4618,7 +4604,7 @@ public: CViewText *pVT = dynamic_cast(pIG->getView("t")); if (!pVT) break; - names.push_back(toUpper(pVT->getText().toUtf8())); + names.push_back(toUpper(pVT->getText())); } if (names.size() != nbChilds) diff --git a/ryzom/client/src/interface_v3/action_handler_help.cpp b/ryzom/client/src/interface_v3/action_handler_help.cpp index ff19bfa33..3030d177e 100644 --- a/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -669,7 +670,7 @@ class CHandlerOpenTitleHelp : public IActionHandler if (selection == NULL) return; //if(selection->isNPC()) { - ucstring name = selection->getEntityName(); + std::string name = selection->getEntityName(); if(name.empty()) { // try to get the name from the string manager (for npc) @@ -678,7 +679,7 @@ class CHandlerOpenTitleHelp : public IActionHandler { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); pSMC->getString (nDBid, name); - ucstring copyName = name; + std::string copyName = name; name = CEntityCL::removeTitleAndShardFromName(name); if (name.empty()) { @@ -688,7 +689,7 @@ class CHandlerOpenTitleHelp : public IActionHandler woman = pChar->getGender() == GSGENDER::female; // extract the replacement id - ucstring strNewTitle = CEntityCL::getTitleFromName(copyName); + std::string strNewTitle = CEntityCL::getTitleFromName(copyName); // retrieve the translated string if (!strNewTitle.empty()) @@ -699,7 +700,7 @@ class CHandlerOpenTitleHelp : public IActionHandler } } if(!name.empty()) - CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name.toUtf8()+"|ptype="+toString((int)selection->Type)); + CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name+"|ptype="+toString((int)selection->Type)); return; } } @@ -751,7 +752,7 @@ class CHandlerOpenTitleHelp : public IActionHandler for (titleIDnb = 0; titleIDnb < CHARACTER_TITLE::NB_CHARACTER_TITLE; ++titleIDnb) { bool women = UserEntity && UserEntity->getGender()==GSGENDER::female; - if (CStringManagerClient::getTitleLocalizedName(CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)titleIDnb),women) == title) + if (CStringManagerClient::getTitleLocalizedName(CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)titleIDnb),women) == title.toUtf8()) break; } @@ -992,9 +993,7 @@ class CHandlerBrowse : public IActionHandler } } - ucstring ucparams(params); - CInterfaceManager::parseTokens(ucparams); - params = ucparams.toUtf8(); + CInterfaceManager::parseTokens(params); // go. NB: the action handler himself may translate params from utf8 CAHManager::getInstance()->runActionHandler(action, elementGroup, params); @@ -1167,7 +1166,7 @@ void setHelpText(CSheetHelpSetup &setup, const ucstring &text) CViewText *viewText= dynamic_cast(setup.HelpWindow->getView(setup.ViewText)); if(viewText) { - viewText->setTextFormatTaged(copyStr); + viewText->setTextFormatTaged(copyStr.toUtf8()); } CInterfaceGroup *viewTextGroup = setup.HelpWindow->getGroup(setup.ScrollTextGroup); if (viewTextGroup) viewTextGroup->setActive(true); @@ -2014,7 +2013,7 @@ void getItemText (CDBCtrlSheet *item, ucstring &itemText, const CItemSheet*pIS) if(pIS->canBuildSomeItemPart()) { ucstring fmt= CI18N::get("uihelpItemMPCraft"); - ucstring ipList; + std::string ipList; pIS->getItemPartListAsText(ipList); strFindReplace(fmt, "%ip", ipList); strFindReplace(itemText, "%craft", fmt); @@ -2764,7 +2763,7 @@ class CPlayerShardNameRemover : public IOnReceiveTextId { virtual void onReceiveTextId(ucstring &str) { - str= CEntityCL::removeShardFromName(str); + str= CEntityCL::removeShardFromName(str.toUtf8()); } }; static CPlayerShardNameRemover PlayerShardNameRemover; @@ -3474,7 +3473,7 @@ void setConsoModSuccessTooltip( CDBCtrlSheet *cs ) CInterfaceManager * pIM = CInterfaceManager::getInstance(); CCDBNodeLeaf * nodeSM = NULL; - ucstring ustr; + string ustr; if( CSheetId(cs->getSheetId()).toString() == "mod_melee_success.sbrick" ) { ustr = CI18N::get("uittModMeleeSuccess"); @@ -3589,7 +3588,7 @@ public: CCDBNodeLeaf * node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:DEATH_XP_MALUS", false); if( node ) { - ucstring txt = CI18N::get("uittDeathPenalty"); + string txt = CI18N::get("uittDeathPenalty"); strFindReplace(txt, "%dp", toString((100*node->getValue16())/254)); CWidgetManager::getInstance()->setContextHelpText(txt); } @@ -3598,7 +3597,7 @@ public: else if( getAuraDisabledState(cs) ) { // get the normal string, and append a short info. - ucstring str; + std::string str; cs->getContextHelp(str); str+= CI18N::get("uittAuraDisabled"); @@ -3627,7 +3626,7 @@ public: return; } - ucstring txt; + string txt; CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:NAME", index)); if (node && CStringManagerClient::instance()->getDynString(node->getValue32(), txt)) { @@ -3677,7 +3676,7 @@ public: str += toString(minTimeRemaining); // replace the context help that is required. - CWidgetManager::getInstance()->setContextHelpText(str); + CWidgetManager::getInstance()->setContextHelpText(str.toUtf8()); } }; REGISTER_ACTION_HANDLER( CHandlerAnimalDeadPopupTooltip, "animal_dead_popup_tooltip"); @@ -3807,7 +3806,7 @@ static void onMpChangeItemPart(CInterfaceGroup *wnd, uint32 itemSheetId, const s string originFilterKey= "iompf" + ITEM_ORIGIN::enumToString((ITEM_ORIGIN::EItemOrigin)itemPart.OriginFilter); mpCraft+= CI18N::get(originFilterKey); - viewText->setText(mpCraft); + viewText->setText(mpCraft.toUtf8()); } diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp index 3d0981306..7a87719ab 100644 --- a/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -129,7 +130,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() { if ( pIS->Family == ITEMFAMILY::SCROLL) { - editBoxLarge->setInputString(itemInfo.CustomText); + editBoxLarge->setInputStringAsUtf16(itemInfo.CustomText); editLarge->setActive(true); editBoxLarge->setActive(true); @@ -147,7 +148,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() strFindReplace(customText, "%mfc", ucstring()); } - editBoxShort->setInputString(customText); + editBoxShort->setInputStringAsUtf16(customText); editShort->setActive(true); editBoxShort->setActive(true); @@ -160,9 +161,8 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() } else { - ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); if (itemInfo.CustomText.empty()) - display->setTextFormatTaged(localDesc); + display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); else { ucstring text = itemInfo.CustomText; @@ -182,7 +182,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() } if (!text.empty()) { - display->setTextFormatTaged(text); + display->setTextFormatTaged(text.toUtf8()); group->setActive(true); } } @@ -239,9 +239,9 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() closeButton->setActive(false); group->setActive(true); - editBoxShort->setInputString(ucstring()); - editBoxLarge->setInputString(ucstring()); - display->setTextFormatTaged(ucstring()); + editBoxShort->setInputString(std::string()); + editBoxLarge->setInputString(std::string()); + display->setTextFormatTaged(std::string()); // Finish the display or add the waiter @@ -250,7 +250,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() // If we already have item info if ( pIS->Family == ITEMFAMILY::SCROLL) { - editBoxLarge->setInputString(itemInfo.CustomText); + editBoxLarge->setInputStringAsUtf16(itemInfo.CustomText); editLarge->setActive(true); editBoxLarge->setActive(true); @@ -269,7 +269,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() strFindReplace(customText, "%mfc", ucstring()); } - editBoxShort->setInputString(customText); + editBoxShort->setInputStringAsUtf16(customText); editShort->setActive(true); editBoxShort->setActive(true); @@ -297,16 +297,15 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() closeButton->setActive(true); group->setActive(false); - editBoxShort->setInputString(ucstring()); - editBoxLarge->setInputString(ucstring()); - display->setTextFormatTaged(ucstring()); + editBoxShort->setInputString(std::string()); + editBoxLarge->setInputString(std::string()); + display->setTextFormatTaged(std::string()); // Finish the display or add the waiter if (getInventory().isItemInfoUpToDate(ItemSlotId)) { - ucstring localDesc = ucstring(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); if (itemInfo.CustomText.empty()) - display->setTextFormatTaged(localDesc); + display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)); else { ucstring text = itemInfo.CustomText; @@ -314,18 +313,18 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() { CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:web_transactions:content:html")); if (pGH) - pGH->browse(text.substr(4, text.size()-4).toString().c_str()); + pGH->browse(text.substr(4, text.size()-4).toUtf8().c_str()); text = localDesc; } else if (text.size() > 3 && text[0]=='@' && text[1]=='L' && text[2]=='U' && text[3]=='A') { - string code = text.substr(4, text.size()-4).toString(); + string code = text.substr(4, text.size()-4).toUtf8(); if (!code.empty()) CLuaManager::getInstance().executeLuaScript(code); text = localDesc; } if (!text.empty()) - display->setTextFormatTaged(text); + display->setTextFormatTaged(text.toUtf8()); } } else @@ -406,11 +405,11 @@ void CInterfaceItemEdition::CItemEditionWindow::validate() if (group && editShort && editBoxShort && editLarge && editBoxLarge && display && editButtons && closeButton && background) { bool textValid = editShort->getActive(); - ucstring text = editBoxShort->getInputString(); + ucstring text = editBoxShort->getInputStringAsUtf16(); if (!textValid) { textValid = editLarge->getActive(); - text = editBoxLarge->getInputString(); + text = editBoxLarge->getInputStringAsUtf16(); } if (textValid) @@ -1733,10 +1732,11 @@ void CItemMenuInBagInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet) // get the CreatorTextID bool isCraftedByUserEntity = false; - ucstring creatorNameString; + string creatorNameString; if( STRING_MANAGER::CStringManagerClient::instance()->getString ( itemInfo.CreatorName, creatorNameString) ) { - if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString)) + std::string userNameString = UserEntity->getEntityName() + PlayerSelectedHomeShardNameWithParenthesis; + if (NLMISC::compareCaseInsensitive(userNameString, creatorNameString) == 0) isCraftedByUserEntity = true; } @@ -1841,10 +1841,11 @@ class CHandlerItemMenuCheck : public IActionHandler if (getInventory().isItemInfoUpToDate(getInventory().getItemSlotId(pCS))) { // get the CreatorTextID - ucstring creatorNameString; + string creatorNameString; if( STRING_MANAGER::CStringManagerClient::instance()->getString ( getInventory().getItemInfo(getInventory().getItemSlotId(pCS)).CreatorName, creatorNameString) ) { - if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString)) + string userNameString = UserEntity->getEntityName() + PlayerSelectedHomeShardNameWithParenthesis; + if (NLMISC::compareCaseInsensitive(userNameString, creatorNameString) == 0) isTextEditionActive = true; } } @@ -2121,9 +2122,7 @@ class CHandlerItemMenuCheck : public IActionHandler std::string name = groupNames[i]; std::string ahParams = "name=" + name; //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(name); - pGroupMenu->addLine(nameUC, "", "", name); + pGroupMenu->addLine(name, "", "", name); CGroupSubMenu* pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam()); pGroupMenu->setSubMenu(pGroupMenu->getNumLine()-1, pNewSubMenu); if(pNewSubMenu) @@ -2149,7 +2148,7 @@ class CHandlerItemMenuCheck : public IActionHandler { //there is an offset of 1 because TInventory names are pet_animal1/2/3/4 std::string dst = toString("destination=pet_animal%d|", j + 1); - CViewTextMenu* tmp = pNewSubMenu->addLine(ucstring(pMoveToPa[j]->getHardText()),"item_group_move", dst + ahParams, name + toString("_pa%d", j + 1)); + CViewTextMenu* tmp = pNewSubMenu->addLine(pMoveToPa[j]->getHardText(),"item_group_move", dst + ahParams, name + toString("_pa%d", j + 1)); if(tmp) tmp->setGrayed(pMoveToPa[j]->getGrayed()); } } diff --git a/ryzom/client/src/interface_v3/action_handler_misc.cpp b/ryzom/client/src/interface_v3/action_handler_misc.cpp index 8b379f6d1..8b144f844 100644 --- a/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -598,7 +598,7 @@ void getBuffer (CBitmap &btm) void displayScreenShotSavedInfo(const string &filename) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring msg("'" + filename + "' " + CI18N::get("uiScreenshotSaved")); + string msg = "'" + filename + "' " + CI18N::get("uiScreenshotSaved"); pIM->displaySystemInfo(msg); } @@ -836,7 +836,7 @@ class CAHReplyTeller : public IActionHandler { w->setKeyboardFocus(); w->enableBlink(1); - PeopleInterraction.ChatGroup.Filter.setTargetPlayer(CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName)); + PeopleInterraction.ChatGroup.Filter.setTargetPlayer(CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName.toUtf8())); CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) { @@ -863,7 +863,7 @@ class CAHReplyTellerOnce : public IActionHandler { w->setKeyboardFocus(); w->enableBlink(1); - w->setCommand(ucstring("tell ") + CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName) + ucstring(" "), false); + w->setCommand(ucstring("tell ") + CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName.toUtf8()) + ucstring(" "), false); CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) { @@ -885,7 +885,7 @@ class CAHCycleTell : public IActionHandler { CInterfaceManager *im = CInterfaceManager::getInstance(); if (!im->isInGame()) return; - const ucstring *lastTellPeople = ChatMngr.cycleLastTell(); + const string *lastTellPeople = ChatMngr.cycleLastTell(); if (!lastTellPeople) return; // just popup the main chat //CChatWindow *w = PeopleInterraction.MainChat.Window; @@ -913,10 +913,10 @@ NLMISC_COMMAND(slsn, "Temp : set the name of the last sender.", "") } // *************************************************************************** -bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) +bool CStringPostProcessRemoveName::cbIDStringReceived(string &inOut) { // extract the replacement id - ucstring strNewTitle = CEntityCL::getTitleFromName(inOut); + string strNewTitle = CEntityCL::getTitleFromName(inOut); // retrieve the translated string if (!strNewTitle.empty()) @@ -938,16 +938,16 @@ bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) } // *************************************************************************** -bool CStringPostProcessRemoveTitle::cbIDStringReceived(ucstring &inOut) +bool CStringPostProcessRemoveTitle::cbIDStringReceived(string &inOut) { inOut = CEntityCL::removeTitleAndShardFromName(inOut); return true; } // *************************************************************************** -bool CStringPostProcessNPCRemoveTitle::cbIDStringReceived(ucstring &inOut) +bool CStringPostProcessNPCRemoveTitle::cbIDStringReceived(string &inOut) { - ucstring sOut = CEntityCL::removeTitleAndShardFromName(inOut); + string sOut = CEntityCL::removeTitleAndShardFromName(inOut); if (sOut.empty()) { CStringPostProcessRemoveName SPPRM; diff --git a/ryzom/client/src/interface_v3/action_handler_misc.h b/ryzom/client/src/interface_v3/action_handler_misc.h index d820963ac..93db8080b 100644 --- a/ryzom/client/src/interface_v3/action_handler_misc.h +++ b/ryzom/client/src/interface_v3/action_handler_misc.h @@ -157,7 +157,7 @@ class CStringPostProcessRemoveName : public CInterfaceManager::IStringProcess public: CStringPostProcessRemoveName():Woman(false) {} bool Woman; - bool cbIDStringReceived(ucstring &inOut); + bool cbIDStringReceived(std::string &inOut); }; // *************************************************************************** @@ -165,7 +165,7 @@ public: class CStringPostProcessRemoveTitle : public CInterfaceManager::IStringProcess { public: - bool cbIDStringReceived(ucstring &inOut); + bool cbIDStringReceived(std::string &inOut); }; // *************************************************************************** @@ -173,7 +173,7 @@ public: class CStringPostProcessNPCRemoveTitle : public CInterfaceManager::IStringProcess { public: - bool cbIDStringReceived(ucstring &inOut); + bool cbIDStringReceived(std::string &inOut); }; diff --git a/ryzom/client/src/interface_v3/action_handler_move.cpp b/ryzom/client/src/interface_v3/action_handler_move.cpp index ad07c7eb5..093f0feae 100644 --- a/ryzom/client/src/interface_v3/action_handler_move.cpp +++ b/ryzom/client/src/interface_v3/action_handler_move.cpp @@ -466,7 +466,7 @@ class CAHToggleDodgeParry : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring msg; + string msg; // 0 - dodge mode // 1 - parry mode if (NLGUI::CDBManager::getInstance()->getDbProp("SERVER:DEFENSE:DEFENSE_MODE")->getValue32() == 0) diff --git a/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/ryzom/client/src/interface_v3/action_handler_phrase.cpp index b18e348e5..4878d13a4 100644 --- a/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -1198,7 +1199,7 @@ public: { // display "you can't cast while moving" CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgNoCastWhileMoving"); + string msg = CI18N::get("msgNoCastWhileMoving"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); return; @@ -1217,57 +1218,60 @@ public: if( pPM->avoidCyclicForPhrase(phraseCom) ) cyclic= false; - // **** Launch the cast - // Cast only if their is a target, or if it is not a combat action - CEntityCL *target = EntitiesMngr.entity(UserEntity->targetSlot()); - if(target || !rootBrick->isCombat()) + if (UserEntity) { - // combat (may moveTo before) ? - if(rootBrick->isCombat()) + // **** Launch the cast + // Cast only if their is a target, or if it is not a combat action + CEntityCL *target = EntitiesMngr.entity(UserEntity->targetSlot()); + if (target || !rootBrick->isCombat()) { - if( !UserEntity->canEngageCombat() ) - return; + // combat (may moveTo before) ? + if (rootBrick->isCombat()) + { + if (!UserEntity->canEngageCombat()) + return; - UserEntity->executeCombatWithPhrase(target, memoryLine, memoryIndex, cyclic); - } - // else can cast soon! - else if ( rootBrick->isForageExtraction() && (! UserEntity->isRiding()) ) // if mounted, send directly to server (without moving) to receive the error message - { - // Yoyo: TEMP if a target selected, must be a forage source - if(!target || target->isForageSource()) + UserEntity->executeCombatWithPhrase(target, memoryLine, memoryIndex, cyclic); + } + // else can cast soon! + else if (rootBrick->isForageExtraction() && (!UserEntity->isRiding())) // if mounted, send directly to server (without moving) to receive the error message + { + // Yoyo: TEMP if a target selected, must be a forage source + if (!target || target->isForageSource()) + { + // Cancel any follow + UserEntity->disableFollow(); + // reset any moveTo also (if target==NULL, moveToExtractionPhrase() and therefore resetAnyMoveTo() not called) + // VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called) + UserEntity->resetAnyMoveTo(); + + // Move to targetted source + if (target) + UserEntity->moveToExtractionPhrase(target->slot(), MaxExtractionDistance, memoryLine, memoryIndex, cyclic); + + // start client execution + pPM->clientExecute(memoryLine, memoryIndex, cyclic); + + if (!target) + { + // inform Server of phrase cast + pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic); + } + } + } + else { - // Cancel any follow - UserEntity->disableFollow(); - // reset any moveTo also (if target==NULL, moveToExtractionPhrase() and therefore resetAnyMoveTo() not called) + // Cancel any moveTo(), because don't want to continue reaching the prec entity // VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called) UserEntity->resetAnyMoveTo(); - // Move to targetted source - if ( target ) - UserEntity->moveToExtractionPhrase( target->slot(), MaxExtractionDistance, memoryLine, memoryIndex, cyclic ); - - // start client execution + // start client execution: NB: start client execution even if it pPM->clientExecute(memoryLine, memoryIndex, cyclic); - if ( ! target ) - { - // inform Server of phrase cast - pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic); - } + // inform Server of phrase cast + pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic); } } - else - { - // Cancel any moveTo(), because don't want to continue reaching the prec entity - // VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called) - UserEntity->resetAnyMoveTo(); - - // start client execution: NB: start client execution even if it - pPM->clientExecute(memoryLine, memoryIndex, cyclic); - - // inform Server of phrase cast - pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic); - } } } } @@ -1439,7 +1443,7 @@ public: else { // debug: - pIM->displaySystemInfo( ucstring("PHRASE:CANCEL_ALL") ); + pIM->displaySystemInfo("PHRASE:CANCEL_ALL"); } } }; @@ -1691,7 +1695,7 @@ static DECLARE_INTERFACE_USER_FCT(getSPhraseName) return false; sint sphraseId= (sint)args[0].getInteger(); CSPhraseManager *pPM= CSPhraseManager::getInstance(); - result.setUCString(pPM->getPhrase(sphraseId).Name); + result.setString(pPM->getPhrase(sphraseId).Name.toUtf8()); return true; } else @@ -1722,7 +1726,7 @@ public: else strFindReplace(str, "%comp", CI18N::get("uittPhraseCombatRestrictOK")); - CWidgetManager::getInstance()->setContextHelpText(str); + CWidgetManager::getInstance()->setContextHelpText(str.toUtf8()); } }; REGISTER_ACTION_HANDLER( CHandlerCombatRestrictTooltip, "phrase_combat_restrict_tooltip"); diff --git a/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/ryzom/client/src/interface_v3/action_phrase_faber.cpp index 1c99983e3..6f88fb89c 100644 --- a/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -537,7 +538,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick { nlstop; } - viewText->setText( text ); + viewText->setText( text.toUtf8() ); } // Set as Icon the required MP FaberType / or Sheet Texture (directly...) @@ -1738,7 +1739,7 @@ void CActionPhraseFaber::updateItemResult() + "@{FFFF})"; } strFindReplace(text, "%success", successStr ); - successView->setTextFormatTaged(text); + successView->setTextFormatTaged(text.toUtf8()); } @@ -1826,7 +1827,7 @@ void CActionPhraseFaber::updateItemResult() RM_FABER_STAT_TYPE::isMagicProtectStat(RM_FABER_STAT_TYPE::TRMStatType(i)) ) statToolTip->setDefaultContextHelp(CI18N::get("uiFaberStatActive")); else - statToolTip->setDefaultContextHelp(ucstring()); + statToolTip->setDefaultContextHelp(std::string()); } else statToolTip->setDefaultContextHelp(CI18N::get("uiFaberStatGrayed")); 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 b7ec631b9..143a71837 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 @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -70,10 +71,10 @@ class CHandlerGuildCreate : public IActionHandler CGroupEditBox *pDesc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(guildDescWin)); - ucstring guildName = pGEB->getInputString(); + ucstring guildName = pGEB->getInputStringAsUtf16(); ucstring guildDesc; - if (pDesc != NULL) guildDesc = pDesc->getInputString(); + if (pDesc != NULL) guildDesc = pDesc->getInputStringAsUtf16(); uint64 icon = CGuildManager::iconMake((uint8)pCS->getGuildBack(), (uint8)pCS->getGuildSymbol(), pCS->getInvertGuildSymbol(), pCS->getGuildColor1(), pCS->getGuildColor2()); diff --git a/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp b/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp index 1e9d56dc3..c8190e8e7 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -156,14 +157,14 @@ void CBotChatPageDynamicMission::update() { if (ClientCfg.Local) { - _ChoiceCB[k]->setText(l, ucstring(toString("Dynamic mission %d:%d", (int) k, (int) l))); + _ChoiceCB[k]->setText(l, toString("Dynamic mission %d:%d", (int) k, (int) l)); _TextReceived[k][l] = true; } else { uint32 textID = (uint32) NLGUI::CDBManager::getInstance()->getDbProp(toString(DM_CHOICE "%d:%d:TEXT", (int) k, (int) l))->getValue32(); // see if text has been receive - ucstring result; + string result; bool received = CStringManagerClient::instance()->getDynString(textID, result); if (received) { @@ -179,7 +180,7 @@ void CBotChatPageDynamicMission::update() uint32 textID = (uint32) NLGUI::CDBManager::getInstance()->getDbProp(toString(DM_CHOICE "%d:%d:TEXT", (int) k, (int) l))->getValue32(); if (textID == 0 && !ClientCfg.Local) break; // see if text has been received - ucstring result; + string result; bool received = CStringManagerClient::instance()->getDynString(textID, result); if (received) { @@ -206,7 +207,7 @@ void CBotChatPageDynamicMission::update() uint32 textID = NLGUI::CDBManager::getInstance()->getDbProp(DM_TITLE_DB_PATH)->getValue32(); if (textID != 0) { - ucstring result; + string result; if (CStringManagerClient::instance()->getDynString(textID, result)) { textID = NLGUI::CDBManager::getInstance()->getDbProp(DM_DESCRIPTION_DB_PATH)->getValue32(); diff --git a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index d05ba9d7a..e32793d63 100644 --- a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -333,7 +334,7 @@ uint32 CBotChatPageTrade::getCurrItemQuantity() const CGroupEditBox *ed = dynamic_cast(ig->getGroup("header_opened:standard_price:quantity:edit:eb")); if (!ed) return std::numeric_limits::max(); uint32 intQuantity; - if (fromString(ed->getInputString().toString(), intQuantity)) + if (fromString(ed->getInputString(), intQuantity)) { return intQuantity; } @@ -894,7 +895,7 @@ void CBotChatPageTrade::startBuyDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCall { confirmButton->setActive( true ); // no need any context help because too simple - confirmButton->setDefaultContextHelp(ucstring()); + confirmButton->setDefaultContextHelp(std::string()); if(isItem) { CItemSheet * itemSheet = dynamic_cast ( SheetMngr.get( CSheetId( sheet->getSheetId() ) ) ); @@ -1013,7 +1014,7 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal { ucstring itemName; itemName = sheet->getItemActualName(); - itemNameView->setText(itemName); + itemNameView->setText(itemName.toUtf8()); } // set help for item @@ -1680,14 +1681,14 @@ void CBotChatPageTrade::setupFactionPointPrice(bool /* sellMode */, uint default { ucstring fmt= CI18N::get("uiUnitFPPrice"); strFindReplace(fmt, "%fac", factionName); - vt->setText(fmt); + vt->setText(fmt.toUtf8()); } vt= dynamic_cast(fpGroup->getView("total_price_header")); if(vt) { ucstring fmt= CI18N::get("uiTotalFPPrice"); strFindReplace(fmt, "%fac", factionName); - vt->setText(fmt); + vt->setText(fmt.toUtf8()); } // setup icon according to pvp clan @@ -2429,7 +2430,7 @@ public: void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { // \todo yoyo: for now disable tooltip - CWidgetManager::getInstance()->setContextHelpText(ucstring()); + CWidgetManager::getInstance()->setContextHelpText(std::string()); } }; REGISTER_ACTION_HANDLER(CHandlerBotChatTTItemType, "botchat_tt_item_type"); @@ -2576,11 +2577,11 @@ static DECLARE_INTERFACE_USER_FCT(getPriceWithFame) sint value= (sint)args[0].getInteger(); sint valueFame= (sint)args[1].getInteger(); if(value==-1) - result.setUCString(CI18N::get("uiBadPrice")); + result.setString(CI18N::get("uiBadPrice")); else if(value==valueFame) - result.setUCString(NLMISC::formatThousands(toString(value))); + result.setString(NLMISC::formatThousands(toString(value))); else - result.setUCString(NLMISC::formatThousands(toString(valueFame)) + " (" + NLMISC::formatThousands(toString(value)) + ")"); + result.setString(NLMISC::formatThousands(toString(valueFame)) + " (" + NLMISC::formatThousands(toString(value)) + ")"); return true; } @@ -2596,7 +2597,7 @@ static DECLARE_INTERFACE_USER_FCT(getBonusOnResale) sint valueHigh= (sint)args[0].getInteger(); sint valueLow= (sint)args[1].getInteger(); sint diff = valueHigh - valueLow; - result.setUCString("+" + NLMISC::formatThousands(toString(diff))); + result.setString("+" + NLMISC::formatThousands(toString(diff))); return true; } diff --git a/ryzom/client/src/interface_v3/chat_displayer.h b/ryzom/client/src/interface_v3/chat_displayer.h index a3218670d..217b4beb8 100644 --- a/ryzom/client/src/interface_v3/chat_displayer.h +++ b/ryzom/client/src/interface_v3/chat_displayer.h @@ -97,7 +97,7 @@ public: std::vector &rVal = acces.value (); for (uint i = 0; i < rVal.size(); ++i) { - CInterfaceManager::getInstance()->displayDebugInfo(ucstring(rVal[i].Str), rVal[i].Mode); + CInterfaceManager::getInstance()->displayDebugInfo(rVal[i].Str, rVal[i].Mode); } rVal.clear(); } diff --git a/ryzom/client/src/interface_v3/chat_filter.cpp b/ryzom/client/src/interface_v3/chat_filter.cpp index a5fd04c5b..237106170 100644 --- a/ryzom/client/src/interface_v3/chat_filter.cpp +++ b/ryzom/client/src/interface_v3/chat_filter.cpp @@ -170,7 +170,7 @@ void CChatInputFilter::chatWindowRemoved(CChatWindow *cw) } //============================================================================================================= -void CChatInputFilter::displayMessage(const ucstring &msg, NLMISC::CRGBA col, uint numBlinks /*=0*/, bool *windowVisible) +void CChatInputFilter::displayMessage(const string &msg, NLMISC::CRGBA col, uint numBlinks /*=0*/, bool *windowVisible) { bool windowVisibleTmp = false; std::vector::iterator it; @@ -187,10 +187,9 @@ void CChatInputFilter::displayMessage(const ucstring &msg, NLMISC::CRGBA col, ui } //============================================================================================================= -void CChatInputFilter::displayTellMessage(/*TDataSetIndex &receiverIndex, */const ucstring &msg, const ucstring &sender, NLMISC::CRGBA col, uint numBlinks /*=0*/,bool *windowVisible /*=NULL*/) +void CChatInputFilter::displayTellMessage(/*TDataSetIndex &receiverIndex, */const string &msg, const string &sender, NLMISC::CRGBA col, uint numBlinks /*=0*/,bool *windowVisible /*=NULL*/) { - ucstring senderLwr; - senderLwr.fromUtf8(NLMISC::toLower(sender.toUtf8())); + string senderLwr = NLMISC::toLower(sender); // look in people lists std::vector::iterator peopleListIt; @@ -290,7 +289,7 @@ void CChatTargetFilter::setChat(CChatWindow *w) } //============================================================================================================= -void CChatTargetFilter::msgEntered(const ucstring &msg, CChatWindow *chatWindow) +void CChatTargetFilter::msgEntered(const string &msg, CChatWindow *chatWindow) { // Common Target case if (ClientCfg.Local) @@ -307,9 +306,9 @@ void CChatTargetFilter::msgEntered(const ucstring &msg, CChatWindow *chatWindow) else if (!_TargetPlayer.empty()) { // the target must be a player, make a tell on him - ChatMngr.tell(_TargetPlayer.toString(), msg); + ChatMngr.tell(_TargetPlayer, msg); // direct output in the chat - chatWindow->displayLocalPlayerTell(_TargetPlayer.toString(), msg); + chatWindow->displayLocalPlayerTell(_TargetPlayer, msg); } else { @@ -334,7 +333,7 @@ void CChatTargetFilter::setTargetPartyChat(CChatWindow *w) } //============================================================================================================= -void CChatTargetFilter::setTargetPlayer(const ucstring &targetPlayer) +void CChatTargetFilter::setTargetPlayer(const string &targetPlayer) { _TargetPlayer = targetPlayer; if (_TargetPartyChat) @@ -345,7 +344,7 @@ void CChatTargetFilter::setTargetPlayer(const ucstring &targetPlayer) // set the prompt if (_Chat) { - _Chat->setPrompt(targetPlayer + (ucchar) '>'); + _Chat->setPrompt(targetPlayer + '>'); } } diff --git a/ryzom/client/src/interface_v3/chat_filter.h b/ryzom/client/src/interface_v3/chat_filter.h index aeff77afc..317069899 100644 --- a/ryzom/client/src/interface_v3/chat_filter.h +++ b/ryzom/client/src/interface_v3/chat_filter.h @@ -42,10 +42,10 @@ public: * Listening windows will blick only if there isnt a single visible listening window, so that the player can know if there's a message * \param windowVisible is not NULL, points a bool that will be filled with true if one of the window on the which the msg was displayed is visible. */ - void displayMessage(const ucstring &msg, NLMISC::CRGBA col, uint numBlinks = 0, bool *windowVisible = NULL); + void displayMessage(const std::string &msg, NLMISC::CRGBA col, uint numBlinks = 0, bool *windowVisible = NULL); /** The same as displayMessage, but with sender name, so that the msg will be displayed in attached people lists as well */ - void displayTellMessage(/*TDataSetIndex &senderIndex, */const ucstring &msg, const ucstring &sender, NLMISC::CRGBA col, uint numBlinks = 0, bool *windowVisible = NULL); + void displayTellMessage(/*TDataSetIndex &senderIndex, */const std::string &msg, const std::string &sender, NLMISC::CRGBA col, uint numBlinks = 0, bool *windowVisible = NULL); /** Clear the messages in all registered chat windows */ void clearMessages(); @@ -134,8 +134,8 @@ public: /** Set a player as the target. This remove any previous window target * NB : this replace any previous party chat or target group or player */ - void setTargetPlayer(const ucstring &targetPlayer); - const ucstring &getTargetPlayer() const { return _TargetPlayer; } + void setTargetPlayer(const std::string &targetPlayer); + const std::string &getTargetPlayer() const { return _TargetPlayer; } //@} private: @@ -148,14 +148,14 @@ private: // @{ CChatWindow *_TargetPartyChat; // the target party chat CChatGroup::TGroupType _TargetGroup; - ucstring _TargetPlayer; + std::string _TargetPlayer; // relevant only if _TargetGroup==dyn_chat uint32 _TargetDynamicChannelDbIndex; // @} private: // from IChatWindowListener void chatWindowRemoved(CChatWindow *cw); - void msgEntered(const ucstring &msg, CChatWindow *chatWindow); + void msgEntered(const std::string &msg, CChatWindow *chatWindow); // copy not supported CChatTargetFilter(const CChatTargetFilter &/* other */):NLMISC::CRefCount() { nlassert(0); } CChatTargetFilter& operator=(const CChatTargetFilter &/* other */) { nlassert(0); return *this; } diff --git a/ryzom/client/src/interface_v3/chat_text_manager.cpp b/ryzom/client/src/interface_v3/chat_text_manager.cpp index ec0aee822..a88412d5c 100644 --- a/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -105,15 +106,13 @@ bool CChatTextManager::showTimestamps() const } //================================================================================= -static CInterfaceGroup *parseCommandTag(ucstring &line) +static CInterfaceGroup *parseCommandTag(string &line) { - string::size_type start = line.find(ucstring("/$$")); + string::size_type start = line.find("/$$"); if (start == string::npos) return NULL; - string::size_type end = line.find(ucstring("$$/"), start + 3); + string::size_type end = line.find("$$/", start + 3); if (end == string::npos) return NULL; - std::string commandLine; - ucstring ucCommandLine = line.substr(start + 3, end - start - 3); - ucCommandLine.toString(commandLine); + std::string commandLine = line.substr(start + 3, end - start - 3); line = line.substr(0, start) + line.substr(end +3); vector params; explode(commandLine, std::string("|"), params); @@ -220,11 +219,11 @@ static inline bool isUrlTag(const ucstring &s, ucstring::size_type index, ucstri // *************************************************************************** // isUrlTag must match -static inline void getUrlTag(const ucstring &s, ucstring::size_type &index, ucstring &url, ucstring &title) +static inline void getUrlTag(const string &s, string::size_type &index, string &url, string &title) { bool isMarkdown = false; - ucstring::size_type textSize = s.size(); - ucstring::size_type pos; + string::size_type textSize = s.size(); + string::size_type pos; // see if we have markdown format if (s[index] == '(') @@ -249,8 +248,8 @@ static inline void getUrlTag(const ucstring &s, ucstring::size_type &index, ucst } } - ucchar chOpen = ' '; - ucchar chClose = ' '; + char chOpen = ' '; + char chClose = ' '; if (isMarkdown) { chOpen = '['; @@ -271,7 +270,7 @@ static inline void getUrlTag(const ucstring &s, ucstring::size_type &index, ucst pos = s.find_first_of(chClose, index); // handle common special case: 'text http://.../, text' - if (pos != ucstring::npos && index > 0) + if (pos != string::npos && index > 0) { if (s[index-1] == ' ' && (s[pos-1] == ',' || s[pos-1] == '.')) { @@ -307,7 +306,7 @@ static inline void getUrlTag(const ucstring &s, ucstring::size_type &index, ucst } // fallback to full string length as we did match http:// already and url spans to the end probably - if (pos == ucstring::npos) + if (pos == string::npos) { pos = textSize; } @@ -320,22 +319,22 @@ static inline void getUrlTag(const ucstring &s, ucstring::size_type &index, ucst } //================================================================================= -static void prependTimestamp(ucstring &msg) +static void prependTimestamp(string &msg) { - ucstring cur_time; + string cur_time; CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:SHOW_CLOCK_12H", false); if (node && node->getValueBool()) cur_time = CInterfaceManager::getTimestampHuman("[%I:%M:%S %p] "); else cur_time = CInterfaceManager::getTimestampHuman(); - ucstring::size_type codePos = msg.find(ucstring("@{")); - if (codePos != ucstring::npos) + string::size_type codePos = msg.find("@{"); + if (codePos != string::npos) { // Prepend the current time (do it after the color if the color at first position. if (codePos == 0) { - codePos = msg.find(ucstring("}")); + codePos = msg.find(string("}")); msg = msg.substr(0, codePos + 1) + cur_time + msg.substr(codePos + 1, msg.length() - codePos); } else @@ -350,9 +349,9 @@ static void prependTimestamp(ucstring &msg) } //================================================================================= -CViewBase *CChatTextManager::createMsgText(const ucstring &cstMsg, NLMISC::CRGBA col, bool justified /*=false*/, bool plaintext /*=false*/) +CViewBase *CChatTextManager::createMsgText(const string &cstMsg, NLMISC::CRGBA col, bool justified /*=false*/, bool plaintext /*=false*/) { - ucstring msg = cstMsg; + string msg = cstMsg; CInterfaceGroup *commandGroup = parseCommandTag(msg); if (showTimestamps()) @@ -364,7 +363,7 @@ CViewBase *CChatTextManager::createMsgText(const ucstring &cstMsg, NLMISC::CRGBA } //================================================================================= -CViewBase *CChatTextManager::createMsgTextSimple(const ucstring &msg, NLMISC::CRGBA col, bool justified, CInterfaceGroup *commandGroup) +CViewBase *CChatTextManager::createMsgTextSimple(const string &msg, NLMISC::CRGBA col, bool justified, CInterfaceGroup *commandGroup) { CViewText *vt = new CViewText(CViewText::TCtorParam()); // get parameters from config.xml @@ -378,7 +377,7 @@ CViewBase *CChatTextManager::createMsgTextSimple(const ucstring &msg, NLMISC::CR // if text contain any color code, set the text formated and white, // otherwise, set text normal and apply global color - if (msg.find(ucstring("@{")) != ucstring::npos) + if (msg.find("@{") != string::npos) { vt->setTextFormatTaged(msg); vt->setColor(NLMISC::CRGBA::White); @@ -400,9 +399,9 @@ CViewBase *CChatTextManager::createMsgTextSimple(const ucstring &msg, NLMISC::CR } //================================================================================= -CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::CRGBA col, bool justified, bool plaintext, CInterfaceGroup *commandGroup) +CViewBase *CChatTextManager::createMsgTextComplex(const string &msg, NLMISC::CRGBA col, bool justified, bool plaintext, CInterfaceGroup *commandGroup) { - ucstring::size_type textSize = msg.size(); + string::size_type textSize = msg.size(); CGroupParagraph *para = new CGroupParagraph(CViewBase::TCtorParam()); para->setId("line"); @@ -411,7 +410,7 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C // use right click because left click might be used to activate chat window para->setRightClickHandler("copy_chat_popup"); - para->setRightClickHandlerParams(msg.toUtf8()); + para->setRightClickHandlerParams(msg); if (plaintext) { @@ -462,11 +461,11 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C // quickly check if text has links or not bool hasUrl; { - ucstring s = toLower(msg); - hasUrl = (s.find(ucstring("http://")) || s.find(ucstring("https://"))); + string s = toLower(msg); + hasUrl = (s.find("http://") || s.find("https://")); } - for (ucstring::size_type i = pos; i< textSize;) + for (string::size_type i = pos; i< textSize;) { if (hasUrl && isUrlTag(msg, i, textSize)) { @@ -476,8 +475,8 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C para->addChild(vt); } - ucstring url; - ucstring title; + string url; + string title; getUrlTag(msg, i, url, title); if (url.size() > 0) { @@ -499,29 +498,29 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C if (title.size() > 0) { - vt->LinkTitle = title.toUtf8(); - vt->setText(title); + vt->LinkTitle = title; + vt->setText(vt->LinkTitle); } else { - vt->LinkTitle = url.toUtf8(); - vt->setText(url); + vt->LinkTitle = url; + vt->setText(vt->LinkTitle); } if (url.find_first_of('\'') != string::npos) { - ucstring clean; + string clean; for(string::size_type i = 0; i< url.size(); ++i) { if (url[i] == '\'') - clean += ucstring("%27"); + clean += "%27"; else clean += url[i]; } url = clean; } vt->setActionOnLeftClick("lua"); - vt->setParamsOnLeftClick("game:chatUrl('" + url.toUtf8() + "')"); + vt->setParamsOnLeftClick("game:chatUrl('" + url + "')"); para->addChildLink(vt); diff --git a/ryzom/client/src/interface_v3/chat_text_manager.h b/ryzom/client/src/interface_v3/chat_text_manager.h index 2f7e380be..1cf66730e 100644 --- a/ryzom/client/src/interface_v3/chat_text_manager.h +++ b/ryzom/client/src/interface_v3/chat_text_manager.h @@ -55,7 +55,7 @@ public: * \param justified Should be true for justified text (stretch spaces of line to fill the full width) * \param plaintext Text will not be parsed for uri markup links */ - NLGUI::CViewBase *createMsgText(const ucstring &msg, NLMISC::CRGBA col, bool justified = false, bool plaintext = false); + NLGUI::CViewBase *createMsgText(const std::string &msg, NLMISC::CRGBA col, bool justified = false, bool plaintext = false); // Singleton access static CChatTextManager &getInstance(); @@ -79,8 +79,8 @@ private: bool showTimestamps() const; - NLGUI::CViewBase *createMsgTextSimple(const ucstring &msg, NLMISC::CRGBA col, bool justified, NLGUI::CInterfaceGroup *commandGroup); - NLGUI::CViewBase *createMsgTextComplex(const ucstring &msg, NLMISC::CRGBA col, bool justified, bool plaintext, NLGUI::CInterfaceGroup *commandGroup); + NLGUI::CViewBase *createMsgTextSimple(const std::string &msg, NLMISC::CRGBA col, bool justified, NLGUI::CInterfaceGroup *commandGroup); + NLGUI::CViewBase *createMsgTextComplex(const std::string &msg, NLMISC::CRGBA col, bool justified, bool plaintext, NLGUI::CInterfaceGroup *commandGroup); }; // shortcut to get text manager instance diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp index 13f7bc66d..c04918d81 100644 --- a/ryzom/client/src/interface_v3/chat_window.cpp +++ b/ryzom/client/src/interface_v3/chat_window.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -203,11 +204,12 @@ bool CChatWindow::isVisible() const } //================================================================================= -void CChatWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks /* = 0*/, bool *windowVisible /*= NULL*/) +void CChatWindow::displayMessage(const string &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks /* = 0*/, bool *windowVisible /*= NULL*/) { if (!_Chat) { - nlwarning(" There's no global chat"); + if (msg != "WRN: There's no global chat") + nlwarning(" There's no global chat"); return; } CGroupList *gl; @@ -267,7 +269,7 @@ void CChatWindow::setPrompt(const ucstring &prompt) if (!_Chat) return; CGroupEditBox *eb = dynamic_cast(_Chat->getGroup("eb")); if (!eb) return; - eb->setPrompt(prompt); + eb->setPrompt(prompt.toUtf8()); } void CChatWindow::setPromptColor(NLMISC::CRGBA col) @@ -354,13 +356,13 @@ void CChatWindow::enableBlink(uint numBlinks) void CChatWindow::setCommand(const std::string &command, bool execute) { if (!_EB) return; - _EB->setCommand(ucstring(command), execute); + _EB->setCommand(command, execute); } void CChatWindow::setCommand(const ucstring &command,bool execute) { if (!_EB) return; - _EB->setCommand(command, execute); + _EB->setCommand(command.toUtf8(), execute); } @@ -368,7 +370,7 @@ void CChatWindow::setCommand(const ucstring &command,bool execute) void CChatWindow::setEntry(const ucstring &entry) { if (!_EB) return; - _EB->setInputString(entry); + _EB->setInputStringAsUtf16(entry); } //================================================================================= @@ -477,25 +479,25 @@ void CChatWindow::setHeaderColor(const std::string &n) //================================================================================= void CChatWindow::displayLocalPlayerTell(const ucstring &receiver, const ucstring &msg, uint numBlinks /*= 0*/) { - ucstring finalMsg; + string finalMsg; CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); 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") + ": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); encodeColorTag(prop.getRGBA(), finalMsg, true); - finalMsg += msg; + finalMsg += msg.toUtf8(); - ucstring s = CI18N::get("youTellPlayer"); - strFindReplace(s, "%name", receiver); + string s = CI18N::get("youTellPlayer"); + strFindReplace(s, "%name", receiver.toUtf8()); strFindReplace(finalMsg, CI18N::get("youTell"), s); displayMessage(finalMsg, prop.getRGBA(), CChatGroup::tell, 0, numBlinks); 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) // because we add 7 to the 8 bit color before shifting to right in order to match color @@ -503,8 +505,8 @@ void CChatWindow::encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, boo // 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... // - static ucchar ConvTable[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'F'}; - ucstring str; + static char ConvTable[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'F'}; + string str; if (append) { str.reserve(7 + str.size()); @@ -541,11 +543,12 @@ void CChatWindow::clearMessages(CChatGroup::TGroupType /* gt */, uint32 /* dynam // CChatGroupWindow // ////////////////////// -void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks, bool *windowVisible) +void CChatGroupWindow::displayMessage(const string &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks, bool *windowVisible) { if (!_Chat) { - nlwarning(" There's no global chat"); + if (msg != "WRN: There's no global chat") + nlwarning(" There's no global chat"); return; } @@ -565,8 +568,8 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC CInterfaceManager *pIM= CInterfaceManager::getInstance(); CRGBA newMsgColor= CRGBA::stringToRGBA(CWidgetManager::getInstance()->getParser()->getDefine("chat_group_tab_color_newmsg").c_str()); - ucstring newmsg = msg; - ucstring prefix; + string newmsg = msg; + string prefix; CViewBase *child = NULL; if (gl != NULL) @@ -606,20 +609,20 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC gl = gl2; // Add dyn chan number before string - ucstring prefix("[" + NLMISC::toString(dynamicChatDbIndex) + "]"); + string prefix = "[" + NLMISC::toString(dynamicChatDbIndex) + "]"; // Find position to put the new string // After timestamp? - size_t pos = newmsg.find(ucstring("]")); - size_t colonpos = newmsg.find(ucstring(": @{")); + size_t pos = newmsg.find("]"); + size_t colonpos = newmsg.find(": @{"); // If no ] found or if found but after the colon (so part of the user chat) - if (pos == ucstring::npos || (colonpos < pos)) + if (pos == string::npos || (colonpos < pos)) { // No timestamp, so put it right after the color and add a space - pos = newmsg.find(ucstring("}")); + pos = newmsg.find("}"); prefix += " "; } - if (pos == ucstring::npos) + if (pos == string::npos) newmsg = prefix + newmsg; else newmsg = newmsg.substr(0, pos + 1) + prefix + newmsg.substr(pos + 1); @@ -629,10 +632,10 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC if (node && node->getValueBool()) { uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dynamicChatDbIndex); - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); - prefix = title.empty() ? ucstring("") : ucstring(" ") + title; - pos = newmsg.find(ucstring("] ")); + prefix = (title.empty() ? "" : " ") + title; + pos = newmsg.find("] "); if (pos == ucstring::npos) newmsg = prefix + newmsg; @@ -680,7 +683,7 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC } //================================================================================= -void CChatGroupWindow::displayTellMessage(const ucstring &msg, NLMISC::CRGBA col, const ucstring &sender) +void CChatGroupWindow::displayTellMessage(const string &msg, NLMISC::CRGBA col, const string &sender) { // If we are here with a tell message this is because the teller doesn't belong to any people list CGroupContainer *gcChat = createFreeTeller(sender); @@ -890,7 +893,7 @@ void CChatGroupWindow::setActiveFreeTeller(const ucstring &winName, bool bActive } //================================================================================= -ucstring CChatGroupWindow::getFreeTellerName(const std::string &containerID) +string CChatGroupWindow::getFreeTellerName(const std::string &containerID) { uint32 i; for (i = 0; i < _FreeTellers.size(); ++i) @@ -900,8 +903,8 @@ ucstring CChatGroupWindow::getFreeTellerName(const std::string &containerID) break; } if (i == _FreeTellers.size()) - return ucstring(""); - return _FreeTellers[i]->getUCTitle(); + return string(); + return _FreeTellers[i]->getTitle(); } //================================================================================= @@ -1107,10 +1110,7 @@ CChatWindow *CChatWindowManager::createChatWindow(const CChatWindowDesc &desc) if (desc.Id.empty()) _WindowID++; - if (desc.Localize) - _ChatWindowMap[CI18N::get(desc.Title.toString())] = w; - else - _ChatWindowMap[desc.Title] = w; + _ChatWindowMap[desc.Title] = w; w->setAHOnActive(desc.AHOnActive); w->setAHOnActiveParams(desc.AHOnActiveParams); @@ -1149,10 +1149,7 @@ CChatWindow *CChatWindowManager::createChatGroupWindow(const CChatWindowDesc &de if (desc.Id.empty()) _WindowID++; - if (desc.Localize) - _ChatWindowMap[CI18N::get(desc.Title.toString())] = w; - else - _ChatWindowMap[desc.Title] = w; + _ChatWindowMap[desc.Title] = w; w->setAHOnActive(desc.AHOnActive); w->setAHOnActiveParams(desc.AHOnActiveParams); @@ -1199,7 +1196,7 @@ void CChatWindowManager::removeChatWindow(const ucstring &title) TChatWindowMap::iterator it = _ChatWindowMap.find(title); if (it == _ChatWindowMap.end()) { - nlwarning("unknwown window %s", title.toString().c_str()); + nlwarning("Unknown chat window '%s'", title.toUtf8().c_str()); return; } it->second->deleteContainer(); @@ -1239,18 +1236,9 @@ bool CChatWindowManager::rename(const ucstring &oldName, const ucstring &newName if (newWin != NULL) return false; // target window exists TChatWindowMap::iterator it = _ChatWindowMap.find(oldName); if (it == _ChatWindowMap.end()) return false; - if (newNameLocalize) - { - _ChatWindowMap[CI18N::get(newName.toString())] = it->second; - it->second->getContainer()->setLocalize(true); - it->second->getContainer()->setTitle(newName.toString()); - } - else - { - _ChatWindowMap[newName] = it->second; - it->second->getContainer()->setLocalize(false); - it->second->getContainer()->setUCTitle(newName); - } + _ChatWindowMap[newName] = it->second; + it->second->getContainer()->setLocalize(false); + it->second->getContainer()->setTitle(newName.toUtf8()); _ChatWindowMap.erase(it); return true; } @@ -1290,7 +1278,7 @@ public: { CGroupEditBox *pEB = dynamic_cast(pCaller); if (pEB == NULL) return; - ucstring text = pEB->getInputString(); + string text = pEB->getInputString(); // If the line is empty, do nothing if(text.empty()) return; @@ -1306,7 +1294,7 @@ public: // Parse any tokens in the text if ( ! CInterfaceManager::parseTokens(text)) { - pEB->setInputString (string("")); + pEB->setInputString(std::string()); return; } @@ -1314,7 +1302,7 @@ public: if(text[0] == '/') { CChatWindow::_ChatWindowLaunchingCommand = chat; - string str = text.toUtf8(); + string str = text; string cmdWithArgs = str.substr(1); // Get the command name from the string, can contain spaces @@ -1335,7 +1323,7 @@ public: else { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo (ucstring::makeFromUtf8(cmd) + ": " + CI18N::get ("uiCommandNotExists")); + im->displaySystemInfo (cmd + ": " + CI18N::get ("uiCommandNotExists")); } } else @@ -1346,7 +1334,7 @@ public: } } // Clear input string - pEB->setInputString (ucstring("")); + pEB->setInputString (std::string()); CGroupContainer *gc = static_cast< CGroupContainer* >( pEB->getEnclosingContainer() ); if (gc) @@ -1439,16 +1427,16 @@ class CHandlerInviteToRingSession : public IActionHandler public: void execute (CCtrlBase *pCaller, const std::string &/* sParams */) { - ucstring playerName = ::getFreeTellerName(pCaller); + string playerName = ::getFreeTellerName(pCaller).toUtf8(); if (!playerName.empty()) { // ask the SBS to invite the character in the session - CSessionBrowserImpl::getInstance().inviteCharacterByName(CSessionBrowserImpl::getInstance().getCharId(), playerName.toUtf8()); + CSessionBrowserImpl::getInstance().inviteCharacterByName(CSessionBrowserImpl::getInstance().getCharId(), playerName); // additionaly, send a tell to signal the player he has been invited to a ring session - ChatMngr.tell(playerName.toUtf8(), CI18N::get("uiRingInviteNotification")); + ChatMngr.tell(playerName, CI18N::get("uiRingInviteNotification")); // CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo(ucstring("@{6F6F}") + playerName +ucstring(" @{FFFF}") + CI18N::get("uiRingInvitationSent"), "BC"); + im->displaySystemInfo("@{6F6F}" + playerName +" @{FFFF}" + CI18N::get("uiRingInvitationSent"), "BC"); // force a refresh of the ui CLuaManager::getInstance().executeLuaScript("CharTracking:forceRefresh()"); } diff --git a/ryzom/client/src/interface_v3/chat_window.h b/ryzom/client/src/interface_v3/chat_window.h index 278824753..39fc448f9 100644 --- a/ryzom/client/src/interface_v3/chat_window.h +++ b/ryzom/client/src/interface_v3/chat_window.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -46,7 +47,7 @@ class CChatWindow; struct IChatWindowListener { // the user entered a msg in the given chat box - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) = 0; + virtual void msgEntered(const std::string &msg, CChatWindow *chatWindow) = 0; }; @@ -97,8 +98,8 @@ public: }; public: // display a message in this chat box with the given color - virtual void displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks = 0, bool *windowVisible = NULL); - virtual void displayTellMessage(const ucstring &/* msg */, NLMISC::CRGBA /* col */, const ucstring &/* sender */) {} + virtual void displayMessage(const std::string &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks = 0, bool *windowVisible = NULL); + virtual void displayTellMessage(const std::string &/* msg */, NLMISC::CRGBA /* col */, const std::string &/* sender */) {} virtual void clearMessages(CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex); // Test if the window is visible bool isVisible() const; @@ -156,7 +157,7 @@ public: 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 - 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: @@ -188,8 +189,8 @@ class CChatGroupWindow : public CChatWindow public: CChatGroupWindow() {} // display a message in this chat box with the given color (callback from chat input filter) - virtual void displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks = 0, bool *windowVisible = NULL); - virtual void displayTellMessage(const ucstring &msg, NLMISC::CRGBA col, const ucstring &sender); + virtual void displayMessage(const std::string &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks = 0, bool *windowVisible = NULL); + virtual void displayTellMessage(const std::string &msg, NLMISC::CRGBA col, const std::string &sender); virtual void clearMessages(CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex); sint32 getTabIndex(); void setTabIndex(sint32 n); @@ -197,7 +198,7 @@ public: // Free Teller NLGUI::CGroupContainer *createFreeTeller(const ucstring &winName, const std::string &winColor=""); void setActiveFreeTeller(const ucstring &winName, bool bActive=true); - ucstring getFreeTellerName(const std::string &containerID); + std::string getFreeTellerName(const std::string &containerID); bool removeFreeTeller(const std::string &containerID); // Return true if free teller found void removeAllFreeTellers(); void saveFreeTeller(NLMISC::IStream &f); diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 7b188742c..dfe205119 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2011 Jan BOON (Kaetemi) +// Copyright (C) 2011-2020 Jan BOON (Kaetemi) // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) // @@ -207,9 +207,9 @@ int CDBCtrlSheet::luaGetCreatorName(CLuaState &ls) { uint32 itemSlotId = getInventory().getItemSlotId(this); CClientItemInfo itemInfo = getInventory().getItemInfo(itemSlotId); - ucstring creatorName; + string creatorName; STRING_MANAGER::CStringManagerClient::instance()->getString(itemInfo.CreatorName, creatorName); - CLuaIHM::push(ls, creatorName); + CLuaIHM::push(ls, ucstring::makeFromUtf8(creatorName)); // FIXME: Lua UTF-8 return 1; } @@ -1467,7 +1467,7 @@ void CDBCtrlSheet::setupMission() void CDBCtrlSheet::setupGuildFlag () { // Find the guild name - ucstring usGuildName; + string usGuildName; sint32 nGuildName = _SheetId.getSInt32(); if (_LastSheetId != nGuildName || _NeedSetup) { @@ -2101,7 +2101,7 @@ void CDBCtrlSheet::draw() _RegenText = new CViewText(CViewBase::TCtorParam()); _RegenText->setId(getId() + ":regen"); _RegenText->setParent(_Parent); - _RegenText->setOverflowText(ucstring("")); + _RegenText->setOverflowText(std::string()); _RegenText->setModulateGlobalColor(false); _RegenText->setMultiLine(false); _RegenText->setTextMode(CViewText::ClipWord); @@ -3390,7 +3390,7 @@ void CDBCtrlSheet::setupItemInfoWaiter() } // *************************************************************************** -void CDBCtrlSheet::getContextHelp(ucstring &help) const +void CDBCtrlSheet::getContextHelp(std::string &help) const { if (getType() == CCtrlSheetInfo::SheetType_Skill) { @@ -3409,7 +3409,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const if (macroName.empty()) macroName = CI18N::get("uiNotAssigned"); - ucstring assignedTo = macro->Combo.toUCString(); + ucstring assignedTo = macro->Combo.toString(); if (assignedTo.empty()) assignedTo = CI18N::get("uiNotAssigned"); @@ -3443,7 +3443,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const strFindReplace(dispText, ucstring("%n"), macroName); strFindReplace(dispText, ucstring("%k"), assignedTo); strFindReplace(dispText, ucstring("%c"), dispCommands); - help = dispText; + help = dispText.toUtf8(); } else if(getType() == CCtrlSheetInfo::SheetType_Item) { @@ -3454,10 +3454,10 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const { // call lua function to update tooltip window _ItemInfoWaiter.sendRequest(); - help = _ItemInfoWaiter.infoValidated(); + help = _ItemInfoWaiter.infoValidated().toUtf8(); // its expected to get at least item name back if (help.empty()) - help = getItemActualName(); + help = getItemActualName().toUtf8(); } else if (!_ContextHelp.empty()) { @@ -3465,7 +3465,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const } else { - help = getItemActualName(); + help = getItemActualName().toUtf8();; } } else @@ -3505,7 +3505,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const sint32 phraseId= getSheetId(); if (phraseId == 0) { - help = ucstring(); + help = std::string(); } else { @@ -3523,10 +3523,11 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const game = game["game"]; game.callMethodByNameNoThrow("updatePhraseTooltip", 1, 1); // retrieve result from stack - help = ucstring(); + ucstring tmpHelp; if (!ls->empty()) { - CLuaIHM::pop(*ls, help); + CLuaIHM::pop(*ls, tmpHelp); // FIXME: Lua UTF-8 + help = tmpHelp.toUtf8(); } else { @@ -3574,7 +3575,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const } // *************************************************************************** -void CDBCtrlSheet::getContextHelpToolTip(ucstring &help) const +void CDBCtrlSheet::getContextHelpToolTip(std::string &help) const { // Special case for buff items and spell crystals, only for tooltips if (getType() == CCtrlSheetInfo::SheetType_Item) @@ -3585,7 +3586,7 @@ void CDBCtrlSheet::getContextHelpToolTip(ucstring &help) const if (useItemInfoForFamily(item->Family)) { _ItemInfoWaiter.sendRequest(); - help = _ItemInfoWaiter.infoValidated(); + help = _ItemInfoWaiter.infoValidated().toUtf8(); return; } } @@ -4580,7 +4581,7 @@ ucstring CDBCtrlSheet::getItemActualName() const return ucstring(); else { - ucstring ret; + string ret; // If NameId not 0, get from StringManager uint32 nameId= getItemNameId(); if(nameId) @@ -4612,21 +4613,21 @@ ucstring CDBCtrlSheet::getItemActualName() const { // get description string for item format std::string formatID = getItemRMFaberStatType() != RM_FABER_STAT_TYPE::Unknown ? "uihelpItemFaberPrefixAndSuffix" : "uihelpItemFaberPrefix"; - ucstring format; + string format; if (!CI18N::hasTranslation(formatID)) { - format = ucstring("%p %n %s"); // not found, uses default string + format = "%p %n %s"; // not found, uses default string } else { format = CI18N::get(formatID); } // suffix - strFindReplace(format, ucstring("%p"), RM_CLASS_TYPE::toLocalString(getItemRMClassType())); + strFindReplace(format, "%p", RM_CLASS_TYPE::toLocalString(getItemRMClassType())); // name - strFindReplace(format, ucstring("%n"), ret); + strFindReplace(format, "%n", ret); // prefix - strFindReplace(format, ucstring("%s"), CI18N::get(toString("mpstatItemQualifier%d", (int) getItemRMFaberStatType()).c_str())); + strFindReplace(format, "%s", CI18N::get(toString("mpstatItemQualifier%d", (int) getItemRMFaberStatType()).c_str())); ret = format; diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.h b/ryzom/client/src/interface_v3/dbctrl_sheet.h index f9a85dd05..3631948ff 100644 --- a/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -2,7 +2,7 @@ // Copyright (C) 2010-2019 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2011 Jan BOON (Kaetemi) +// Copyright (C) 2011-2020 Jan BOON (Kaetemi) // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) // @@ -393,9 +393,9 @@ public: NLMISC::CRGBA getSheetColor() const {return _SheetColor;} /// 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. diff --git a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index 3cd8e759c..be0df19ad 100644 --- a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -279,7 +280,7 @@ void CDBGroupBuildPhrase::clearBuildingPhrase() // Empty the name if(_UserSentenceName) { - _UserSentenceName->setInputString(ucstring()); + _UserSentenceName->setInputString(std::string()); } // update Display @@ -373,7 +374,7 @@ void CDBGroupBuildPhrase::startComposition(const CSPhraseCom &phrase) // set the editable name. if(_UserSentenceName) - _UserSentenceName->setInputString(name); + _UserSentenceName->setInputStringAsUtf16(name); } @@ -1074,7 +1075,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) float relative_cost; cost= pBM->getSabrinaCom().getPhraseBrickAndParamCost(phrase.Bricks, i); relative_cost = pBM->getSabrinaCom().getPhraseBrickAndParamRelativeCost(phrase.Bricks, i); - ucstring costText; + std::string costText; if( cost == 0 && relative_cost != 0.f ) { cost = (sint32)(relative_cost * 100.f); @@ -1243,7 +1244,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) { ucstring text; pPM->buildPhraseDesc(text, phrase, 0, false, "composition"); - _TextPhraseDesc->setTextFormatTaged(text); + _TextPhraseDesc->setTextFormatTaged(text.toUtf8()); } @@ -1790,7 +1791,7 @@ void CDBGroupBuildPhrase::buildCurrentPhrase(CSPhraseCom &newPhrase) // Set the Name if(_UserSentenceName) { - newPhrase.Name= _UserSentenceName->getInputString(); + newPhrase.Name= _UserSentenceName->getInputStringAsUtf16(); } } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp index be89ead3d..19083e4ee 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -141,7 +142,7 @@ void CDBGroupListSheetIconPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel); strFindReplace(sectionText, "%min", toString(minLevel)); strFindReplace(sectionText, "%max", toString(maxLevel)); - name->setText (sectionText); + name->setText (sectionText.toUtf8()); } } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp index da46e9e7b..188e06225 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -56,7 +57,7 @@ CViewText *CDBGroupListSheetMission::CSheetChildMission::createViewText() const CViewTextIDFormated *vti = new CViewTextIDFormated(CViewBase::TCtorParam()); if (Ctrl) vti->setDBLeaf(dynamic_cast(Ctrl->getRootBranch()->getNode(ICDBNode::CTextId("TEXT")))); else vti->setDBLeaf(NULL); - vti->setFormatString(ucstring("$t")); + vti->setFormatString("$t"); return vti; } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index f34053396..02d009661 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2015 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -313,7 +313,7 @@ void CDBGroupListSheetText::updateCoords () else { // if not received, must insert in list of pending dynstring to check each frame - ucstring result; + string result; if( !STRING_MANAGER::CStringManagerClient::instance()->getDynString ( curNameId, result) ) _NameIdToUpdate.insert( _SheetChildren[i] ); } @@ -492,7 +492,7 @@ void CDBGroupListSheetText::checkCoords () { CSheetChild * cst = (*it); // String result - ucstring result; + string result; if( STRING_MANAGER::CStringManagerClient::instance()->getDynString ( cst->NameId, result) ) { set< CSheetChild *>::iterator itTmp = it; @@ -1051,7 +1051,7 @@ void CDBGroupListSheetText::CSheetChild::updateViewTextAsItem() if(Ctrl && Text && Ctrl->getSheetCategory() == CDBCtrlSheet::Item) { // get the text - ucstring text; + std::string text; Ctrl->getContextHelp(text); // Text color red if requirement not met @@ -1070,7 +1070,7 @@ void CDBGroupListSheetText::CSheetChild::updateViewTextAsItem() // Add craft info for MP if(pIS->Family==ITEMFAMILY::RAW_MATERIAL) { - ucstring ipList; + string ipList; pIS->getItemPartListAsText(ipList); if(ipList.empty()) { diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index 2486bfc29..1cb977978 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -133,7 +134,7 @@ public: // Called at updateCoords to remake the text virtual void updateViewText(CDBGroupListSheetText * /* pFather */) { - ucstring text; + std::string text; Ctrl->getContextHelp(text); Text->setText(text); } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp index 490c36b85..e8ad3a2e8 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -137,11 +137,11 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::updateViewText(CDB // Temp if the Desc2 is empty, set Name ucstring desc2(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheetId)); if( !desc2.empty() && !hasOnlyBlankChars(desc2)) // tolerate Blank error in translation - Text->setText(desc2); + Text->setText(desc2.toUtf8()); else { desc2 = STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brickSheetId); - Text->setText(desc2); + Text->setText(desc2.toUtf8()); } @@ -159,7 +159,7 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::updateViewText(CDB { // Special Case for the "Remove Brick" brick. No Cost (not revelant) if( brick->Id==pBM->getInterfaceRemoveBrick() ) - CostView->setText( ucstring() ); + CostView->setText( std::string() ); else if( brick->SabrinaCost == 0 && brick->SabrinaRelativeCost != 0.f ) CostView->setText( toString("%+d", (sint32)(brick->SabrinaRelativeCost * 100.f) ) + string("%") ); else diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp index ec1bfbaed..cad06e699 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -77,7 +78,7 @@ void CDBGroupListSheetTextPhrase::CSheetChildPhrase::init(CDBGroupListSheetText // *************************************************************************** void CDBGroupListSheetTextPhrase::CSheetChildPhrase::updateViewText(CDBGroupListSheetText * /* pFather */) { - ucstring text; + std::string text; if(Ctrl->getType()!=CCtrlSheetInfo::SheetType_SPhrase) return; @@ -87,7 +88,7 @@ void CDBGroupListSheetTextPhrase::CSheetChildPhrase::updateViewText(CDBGroupList // append the level if possible if(LevelDB) { - ucstring fmt= CI18N::get("uiPhraseLevelFmt"); + std::string fmt= CI18N::get("uiPhraseLevelFmt").toUtf8(); strFindReplace(fmt, "%d", toString(LevelCache)); text+= "\n" + fmt; } @@ -173,7 +174,7 @@ void CDBGroupListSheetTextPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel); strFindReplace(sectionText, "%min", toString(minLevel)); strFindReplace(sectionText, "%max", toString(maxLevel)); - name->setText (sectionText); + name->setText (sectionText.toUtf8()); } } diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp index 45a78980e..6e5e19d9e 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -41,7 +44,7 @@ CDBGroupListSheetTextPhraseId::CSheetChildPhrase::CSheetChildPhrase() // *************************************************************************** void CDBGroupListSheetTextPhraseId::CSheetChildPhrase::updateViewText(CDBGroupListSheetText * /* pFather */) { - ucstring text; + std::string text; if(Ctrl->getType()!=CCtrlSheetInfo::SheetType_SPhraseId) return; diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index 4a7ef5701..21a56ec4f 100644 --- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -248,7 +249,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::update(CDBGroupListSheetText *pFa void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetText *pFather) { H_AUTO(CDBGroupListSheetTrade_updateViewText); - ucstring text; + std::string text; Ctrl->getContextHelp(text); // Append first the type of the sheet to select switch ( Ctrl->getSheetCategory() ) @@ -285,15 +286,15 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT bool melee,range; pPM->getCombatWeaponRestriction(weaponRestriction, Ctrl->getSheetId(),melee,range); // 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; - text+= "\n" + weaponRestriction; + text+= "\n" + weaponRestriction.toUtf8(); } } // Get the Text color - ucstring colorTag("@{FFFF}"); + std::string colorTag("@{FFFF}"); if(Ctrl->getType() == CCtrlSheetInfo::SheetType_Item) { if(!Ctrl->checkItemRequirement()) @@ -309,7 +310,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT // Add craft info for MP if(pIS->Family==ITEMFAMILY::RAW_MATERIAL) { - ucstring ipList; + string ipList; pIS->getItemPartListAsText(ipList); if(ipList.empty()) { @@ -412,7 +413,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT else text+= CI18N::get("uiBotChatRetirePrice") + NLMISC::formatThousands(toString(factor * LastPriceRetire)); // 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, "%h", toString(LastResaleTimeLeft%RYZOM_DAY_IN_HOUR)); text+= "\n" + fmt; @@ -431,7 +432,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT // else display the name of the vendor (not if this is the player himself, to avoid flood) else if (LastSellerType == BOTCHATTYPE::Resale) { - text+= "\n" + CI18N::get("uiBotChatVendorTag") + VendorNameString; + text+= "\n" + CI18N::get("uiBotChatVendorTag") + VendorNameString.toUtf8(); } } } @@ -475,7 +476,7 @@ bool CDBGroupListSheetTrade::CSheetChildTrade::isSheetValid(CDBGroupListSheetTex if ((pIS != NULL) && (!pIS->DropOrSell)) return false; // test if this whole family of items can be sold - if( !ITEMFAMILY::isSellableByPlayer(pIS->Family) ) + if((pIS != NULL) && !ITEMFAMILY::isSellableByPlayer(pIS->Family) ) return false; } @@ -688,7 +689,7 @@ void CDBGroupListSheetTrade::checkCoords () { CSheetChildTrade * cst = (*it); // String result - ucstring result; + string result; if( pSMC->getString ( cst->LastVendorNameId, result) ) { cst->VendorNameString = CEntityCL::removeShardFromName(result); diff --git a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index ec82b5c8d..8de31a438 100644 --- a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -193,7 +194,7 @@ void CEncyclopediaManager::rebuildAlbumList() nlassert(pTree != NULL); CGroupTree::SNode *pRoot = new CGroupTree::SNode; - ucstring res; + string res; // Add all albums for (uint32 i = 0; i < _Albums.size(); ++i) @@ -303,8 +304,8 @@ void CEncyclopediaManager::rebuildAlbumPage(uint32 albumName) if (pRBVT != NULL) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pAlbum->RewardBrick))); - pRBVT->setText(desc); + CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pAlbum->RewardBrick))); + pRBVT->setText(desc.toUtf8()); } } @@ -359,18 +360,15 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) { if (pES->type() == CEntitySheet::ITEM) { - const ucstring desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc); + pRBVT->setText(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); } else if (pES->type() == CEntitySheet::SBRICK) { - const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc); + pRBVT->setText(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); } else if (pES->type() == CEntitySheet::SPHRASE) { - const ucstring desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); - pRBVT->setText(desc); + pRBVT->setText(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); } } @@ -428,7 +426,7 @@ bool CEncyclopediaManager::isStringWaiting() for (uint32 i = 0; i < _Albums.size(); ++i) { - ucstring res; + string res; if (!pSMC->getDynString(_Albums[i].Name, res)) return true; for (uint32 j = 0; j < _Albums[i].Themas.size(); ++j) diff --git a/ryzom/client/src/interface_v3/flying_text_manager.cpp b/ryzom/client/src/interface_v3/flying_text_manager.cpp index 23e6e963e..37daf2f9e 100644 --- a/ryzom/client/src/interface_v3/flying_text_manager.cpp +++ b/ryzom/client/src/interface_v3/flying_text_manager.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -120,7 +121,7 @@ void CFlyingTextManager::releaseInGame() } // *************************************************************************** -void CFlyingTextManager::addFlyingText(void *key, const ucstring &text, const NLMISC::CVector &pos, CRGBA color, float scale, sint offsetX) +void CFlyingTextManager::addFlyingText(void *key, const string &text, const NLMISC::CVector &pos, CRGBA color, float scale, sint offsetX) { // key exist in the map? TInSceneCurrentMap::iterator it= _InSceneCurrent.find(key); diff --git a/ryzom/client/src/interface_v3/flying_text_manager.h b/ryzom/client/src/interface_v3/flying_text_manager.h index 95746b6c0..14e24c887 100644 --- a/ryzom/client/src/interface_v3/flying_text_manager.h +++ b/ryzom/client/src/interface_v3/flying_text_manager.h @@ -49,7 +49,7 @@ public: /** add a flying text at a position (called during entity display). NB: may fail if no more free groups * \param offsetx: screen offsetx of the group in scene */ - void addFlyingText(void *key, const ucstring &text, const NLMISC::CVector &pos, NLMISC::CRGBA color, float scale, sint offsetX=0); + void addFlyingText(void *key, const std::string &text, const NLMISC::CVector &pos, NLMISC::CRGBA color, float scale, sint offsetX=0); /// release no more used flying text (called by CEntityManager at each draw) void releaseNotUsedFlyingText(); diff --git a/ryzom/client/src/interface_v3/group_compas.cpp b/ryzom/client/src/interface_v3/group_compas.cpp index 87fcec6ce..a78c94681 100644 --- a/ryzom/client/src/interface_v3/group_compas.cpp +++ b/ryzom/client/src/interface_v3/group_compas.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -74,11 +75,20 @@ void CCompassTarget::serial(NLMISC::IStream &f) } } f.serialCheck(NELID("CTAR")); - f.serialVersion(0); + sint version = f.serialVersion(1); f.serial(Pos); // for the name, try to save a string identifier if possible, because language may be changed between // save & reload - f.serial(Name); + if (version < 1) + { + ucstring name; // Serial old version + f.serial(name); + Name = name.toUtf8(); + } + else + { + f.serial(Name); + } std::string language = toLower(ClientCfg.LanguageCode); f.serial(language); f.serialEnum(_Type); @@ -393,18 +403,18 @@ void CGroupCompas::draw() // The text char message[50]; - ucstring distText; + string distText; if (displayedTarget.getType() != CCompassTarget::North) { if (dist > 999.0f) { smprintf (message, 50, "%.1f ", dist/1000.0f); - distText = ucstring (message) + CI18N::get("uiKilometerUnit"); + distText = message + CI18N::get("uiKilometerUnit"); } else { smprintf (message, 50, "%.0f ", dist); - distText = ucstring (message) + CI18N::get("uiMeterUnit"); + distText = message + CI18N::get("uiMeterUnit"); } distText = distText + " - " + displayedTarget.Name; } @@ -424,11 +434,10 @@ void CGroupCompas::draw() CCtrlBase *toolTip = getCtrl("tt"); if (toolTip) { - ucstring text; if (displayedTarget.getType() != CCompassTarget::North) toolTip->setDefaultContextHelp(CI18N::get("uittCompassDistance")); else - toolTip->setDefaultContextHelp(text); + toolTip->setDefaultContextHelp(std::string()); } if (displayedTarget.Name != _CurrTargetName) @@ -558,7 +567,7 @@ bool buildCompassTargetFromTeamMember(CCompassTarget &ct, uint teamMemberId) ct.setPositionState(tracker); CStringManagerClient *pSMC = CStringManagerClient::instance(); - ucstring name; + string name; if (pSMC->getString(nameNode->getValue32(), name)) ct.Name = CEntityCL::removeTitleAndShardFromName(name); // TODO : dynamic support for name else @@ -742,7 +751,7 @@ void CGroupCompasMenu::setActive (bool state) if (entity != NULL) {*/ //ucstring targetName = CI18N::get("uiTargetTwoPoint") + entity->removeTitleAndShardFromName(entity->getEntityName()); - ucstring targetName = CI18N::get("uiTarget"); + std::string targetName = CI18N::get("uiTarget"); ct.setType(CCompassTarget::Selection); ct.Name = targetName; Targets.push_back(ct); @@ -777,7 +786,7 @@ void CGroupCompasMenu::setActive (bool state) CCDBNodeLeaf *textIDLeaf = NLGUI::CDBManager::getInstance()->getDbProp(baseDbPath + toString(":%d:TARGET%d:TITLE", (int) k, (int) l), false); if (textIDLeaf) { - ucstring name; + string name; if (CStringManagerClient::instance()->getDynString(textIDLeaf->getValue32(), name)) { CCDBNodeLeaf *leafPosX= NLGUI::CDBManager::getInstance()->getDbProp(baseDbPath + toString(":%d:TARGET%d:X", (int) k, (int) l), false); @@ -868,7 +877,7 @@ void CGroupCompasMenu::setActive (bool state) CCompassTarget ct; ct.setType(CCompassTarget::UserLandMark); ct.Pos = sortedLandmarks[k].Pos; - ct.Name = sortedLandmarks[k].Title; + ct.Name = sortedLandmarks[k].Title.toUtf8(); 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())); selectable= true; @@ -1047,12 +1056,12 @@ REGISTER_ACTION_HANDLER( CHandlerSetCompassNorth, "set_compass_north"); class CCompassDialogsStringCallback : public IStringWaitCallback { - virtual void onDynStringAvailable(uint /* stringId */, const ucstring &value) + virtual void onDynStringAvailable(uint /* stringId */, const std::string &value) { uint size = (uint)CCompassDialogsManager::getInstance()._Entries.size(); for ( uint i = 0; i < size; i++) { - ucstring name; + std::string name; if ( CStringManagerClient::instance()->getDynString(CCompassDialogsManager::getInstance()._Entries[i].Text, name) ) { if ( value == name ) diff --git a/ryzom/client/src/interface_v3/group_compas.h b/ryzom/client/src/interface_v3/group_compas.h index c9ba106ef..6a57b0294 100644 --- a/ryzom/client/src/interface_v3/group_compas.h +++ b/ryzom/client/src/interface_v3/group_compas.h @@ -46,7 +46,7 @@ class CCompassTarget public: enum TType { North = 0, Selection, Home, Respawn, ContinentLandMark, UserLandMark, PosTracker, NumTypes }; NLMISC::CVector2f Pos; // Used for static target (ie not the current selection, a team member ...) - ucstring Name; + std::string Name; CCompassTarget(); TType getType() const { return _Type; } void setType(TType type) { if (type == _Type) return; setPositionState(NULL); _Type = type; } @@ -124,11 +124,11 @@ private: bool _Blinking; double _StartBlinkTime; - ucstring _CurrTargetName; + std::string _CurrTargetName; // The dist text CViewText *_DistView; - ucstring _DistViewText; + std::string _DistViewText; CViewRadar *_RadarView; CViewText *_RadarRangeView; diff --git a/ryzom/client/src/interface_v3/group_html_cs.cpp b/ryzom/client/src/interface_v3/group_html_cs.cpp index ba20123e1..d02940e60 100644 --- a/ryzom/client/src/interface_v3/group_html_cs.cpp +++ b/ryzom/client/src/interface_v3/group_html_cs.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_html_cs.h b/ryzom/client/src/interface_v3/group_html_cs.h index 76a066e6d..f21eb0834 100644 --- a/ryzom/client/src/interface_v3/group_html_cs.h +++ b/ryzom/client/src/interface_v3/group_html_cs.h @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_html_forum.cpp b/ryzom/client/src/interface_v3/group_html_forum.cpp index fe218c215..4b74732f3 100644 --- a/ryzom/client/src/interface_v3/group_html_forum.cpp +++ b/ryzom/client/src/interface_v3/group_html_forum.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -59,7 +60,7 @@ void CGroupHTMLForum::addHTTPGetParams (string &url, bool /*trustedDomain*/) { ucstring user_name = UserEntity->getLoginName (); const SGuild &guild = CGuildManager::getInstance()->getGuild(); - string gname = guild.Name.toUtf8(); + string gname = guild.Name; if (!gname.empty()) { @@ -91,7 +92,7 @@ void CGroupHTMLForum::addHTTPPostParams (SFormFields &formfields, bool /*trusted { ucstring user_name = UserEntity->getLoginName (); const SGuild &guild = CGuildManager::getInstance()->getGuild(); - string gname = guild.Name.toUtf8(); + string gname = guild.Name; if (!gname.empty()) { diff --git a/ryzom/client/src/interface_v3/group_html_forum.h b/ryzom/client/src/interface_v3/group_html_forum.h index 31e5308be..ef7a98063 100644 --- a/ryzom/client/src/interface_v3/group_html_forum.h +++ b/ryzom/client/src/interface_v3/group_html_forum.h @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_html_mail.cpp b/ryzom/client/src/interface_v3/group_html_mail.cpp index 8627a8573..ac2241523 100644 --- a/ryzom/client/src/interface_v3/group_html_mail.cpp +++ b/ryzom/client/src/interface_v3/group_html_mail.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_html_mail.h b/ryzom/client/src/interface_v3/group_html_mail.h index 59cf4c852..1a24469cb 100644 --- a/ryzom/client/src/interface_v3/group_html_mail.h +++ b/ryzom/client/src/interface_v3/group_html_mail.h @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_html_webig.cpp b/ryzom/client/src/interface_v3/group_html_webig.cpp index 985ae3f20..d190b83b6 100644 --- a/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -97,7 +97,7 @@ void addWebIGParams (string &url, bool trustedDomain) if (url.find('$') != string::npos) { strFindReplace(url, "$gender$", GSGENDER::toString(UserEntity->getGender())); - strFindReplace(url, "$displayName$", UserEntity->getDisplayName().toString()); + strFindReplace(url, "$displayName$", UserEntity->getDisplayName()); // FIXME: UrlEncode... strFindReplace(url, "$posx$", toString(UserEntity->pos().x)); strFindReplace(url, "$posy$", toString(UserEntity->pos().y)); strFindReplace(url, "$posz$", toString(UserEntity->pos().z)); @@ -113,7 +113,7 @@ void addWebIGParams (string &url, bool trustedDomain) if (target) { strFindReplace(url, "$tdatasetid$", toString(target->dataSetId())); - strFindReplace(url, "$tdisplayName$", target->getDisplayName().toString()); + strFindReplace(url, "$tdisplayName$", target->getDisplayName()); // FIXME: UrlEncode... strFindReplace(url, "$tposx$", toString(target->pos().x)); strFindReplace(url, "$tposy$", toString(target->pos().y)); strFindReplace(url, "$tposz$", toString(target->pos().z)); diff --git a/ryzom/client/src/interface_v3/group_html_webig.h b/ryzom/client/src/interface_v3/group_html_webig.h index a339dd3dc..be6412710 100644 --- a/ryzom/client/src/interface_v3/group_html_webig.h +++ b/ryzom/client/src/interface_v3/group_html_webig.h @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 2276eb506..bfa7c0d53 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -455,7 +456,7 @@ void CGroupInSceneBubbleManager::update () { if (_DynBubbles[i].DescWaiting != 0) { - ucstring res; + string res; STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); if (pSMC->getDynString(_DynBubbles[i].DescWaiting,res)) { @@ -487,7 +488,7 @@ void CGroupInSceneBubbleManager::update () // *************************************************************************** -CGroupInSceneBubble *CGroupInSceneBubbleManager::newBubble (const ucstring &text) +CGroupInSceneBubble *CGroupInSceneBubbleManager::newBubble (const string &text) { if (!text.empty() && !_Bubbles.empty()) { @@ -530,10 +531,9 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t if (group) { // Skill name - const ucstring sSkillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); CViewText *pViewSkillName = dynamic_cast(group->getView("name")); if (pViewSkillName != NULL) - pViewSkillName->setText (sSkillName); + pViewSkillName->setText (STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); // Skill value CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false); @@ -576,7 +576,7 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t // *************************************************************************** -void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA color, uint time) +void CGroupInSceneBubbleManager::addMessagePopup (const string &message, CRGBA color, uint time) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -625,7 +625,7 @@ void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA // *************************************************************************** -void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message, CRGBA color, uint time) +void CGroupInSceneBubbleManager::addMessagePopupCenter (const string &message, CRGBA color, uint time) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -757,9 +757,9 @@ CGroupInSceneBubbleManager::CPopupContext *CGroupInSceneBubbleManager::buildCont // *************************************************************************** -void CGroupInSceneBubbleManager::addContextHelp (const ucstring &message, const string &targetName, uint time) +void CGroupInSceneBubbleManager::addContextHelp (const string &message, const string &targetName, uint time) { - ucstring finalMessage = message; + std::string finalMessage = message; CInterfaceElement *target; CPopupContext *context = CGroupInSceneBubbleManager::buildContextHelp ("context_help_", targetName, target, time); if (context) @@ -835,7 +835,7 @@ void CGroupInSceneBubbleManager::ignoreContextHelp (CInterfaceGroup *groupToRemo // *************************************************************************** -void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText, uint bubbleTimer) +void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const std::string &ucsText, uint bubbleTimer) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -1088,9 +1088,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con // Update the bubble's texts - ucstring ucText; - ucText.fromUtf8(text); - bubble->setText(ucText); + bubble->setText(text); id = bubble->getId() + ":header_opened:window:"; CViewText *pVT; CCtrlLink *pCL; @@ -1103,7 +1101,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con if (pVT != NULL) { pVT->setActive(false); - pVT->setText(ucstring("")); + pVT->setText(std::string()); } pCL = dynamic_cast(bubble->getElement(id+"optb"+toString(j))); if (pCL != NULL) pCL->setActive(false); @@ -1115,8 +1113,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con if (pVT != NULL) { pVT->setActive(true); - ucstring optionText; - optionText.fromUtf8(strs[j]); + string optionText = strs[j]; pVT->setText(optionText); pCL = dynamic_cast(bubble->getElement(id+"optb"+toString(j))); if (pCL != NULL) @@ -1340,14 +1337,14 @@ class CAHDynChatClickOption : public IActionHandler if (isBGDownloadEnabled()) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring result; + string result; if (!pSMC->getDynString(optStrId, result)) { return; // shouldn't happen since the button isn't visible as long as the text has not been received ... } static volatile bool forceWarning = false; // for debug - ucstring::size_type pos= result.find(ucstring("{ros_exit}")); - if(pos != ucstring::npos || forceWarning) + string::size_type pos= result.find("{ros_exit}"); + if(pos != string::npos || forceWarning) { if (AvailablePatchs != 0) { @@ -1357,7 +1354,7 @@ class CAHDynChatClickOption : public IActionHandler } } - const string sMsg = "BOTCHAT:DYNCHAT_SEND"; + static const string sMsg = "BOTCHAT:DYNCHAT_SEND"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { @@ -1448,19 +1445,19 @@ void CGroupInSceneBubble::unlink () // *************************************************************************** -void CGroupInSceneBubble::setText (const ucstring &text) +void CGroupInSceneBubble::setText (const string &text) { if (text.empty()) return; _TextParts.clear(); // Look for "{break}" in the message - ucstring finalMsg = text; - ucstring tmpMsg; + string finalMsg = text; + string tmpMsg; for(;;) { - ucstring::size_type index = finalMsg.find (ucstring("{break}")); - if (index == ucstring::npos) break; + string::size_type index = finalMsg.find ("{break}"); + if (index == string::npos) break; tmpMsg = finalMsg.substr (0, index); if (!tmpMsg.empty()) _TextParts.push_back(tmpMsg); @@ -1501,7 +1498,7 @@ void CGroupInSceneBubble::skip() // *************************************************************************** -void CGroupInSceneBubble::setRawText (const ucstring &text) +void CGroupInSceneBubble::setRawText (const string &text) { _CanBeShown = !text.empty(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -1607,8 +1604,7 @@ class CHandlerCharacterBubble : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); uint entityId; fromString(getParam (sParams, "entity"), entityId); - ucstring text; - text.fromUtf8(getParam (sParams, "text")); + string text = getParam (sParams, "text"); string sTime = getParam (sParams, "time"); uint duration; if (sTime.empty()) @@ -1656,10 +1652,8 @@ class CHandlerMessagePopup : public IActionHandler void execute (CCtrlBase * /* pCaller */, const std::string &sParams) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring text0; - text0.fromUtf8(getParam (sParams, "text0").c_str()); - ucstring text1; - text1.fromUtf8(getParam (sParams, "text1").c_str()); + string text0 = getParam (sParams, "text0"); + string text1 = getParam (sParams, "text1"); string sTime = getParam (sParams, "time"); uint duration; if (sTime.empty()) @@ -1683,8 +1677,7 @@ class CHandlerContextHelp : public IActionHandler string targetName = getParam (sParams, "target"); string text = getParam (sParams, "text"); - ucstring itext; - itext.fromUtf8 (getParam (sParams, "itext")); + string itext = getParam (sParams, "itext"); if (itext.empty()) itext = CI18N::get(text); diff --git a/ryzom/client/src/interface_v3/group_in_scene_bubble.h b/ryzom/client/src/interface_v3/group_in_scene_bubble.h index 288853488..f341153fa 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_bubble.h +++ b/ryzom/client/src/interface_v3/group_in_scene_bubble.h @@ -39,19 +39,19 @@ public: void update (); // Get a CGroupBubble - class CGroupInSceneBubble *newBubble (const ucstring &text); + class CGroupInSceneBubble *newBubble (const std::string &text); // Add a message popup. if 0, get the OptionTimeoutMessages - void addMessagePopup (const ucstring &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0); + void addMessagePopup (const std::string &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0); // The same as previous but centered in the screen. if 0, get the OptionTimeoutMessages - void addMessagePopupCenter (const ucstring &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0); + void addMessagePopupCenter (const std::string &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0); // Add a skill popup void addSkillPopup (uint skillId, sint delta, uint time); // Add a context help with a string - void addContextHelp (const ucstring &message, const std::string &target, uint time); + void addContextHelp (const std::string &message, const std::string &target, uint time); // Add a context help void addContextHelpHTML (const std::string &filename, const std::string &target, uint time); @@ -60,7 +60,7 @@ public: void ignoreContextHelp (CInterfaceGroup *groupToRemove); // Open a bubble chat (with next and skip button) - void chatOpen (uint32 nUID, const ucstring &ucsText, uint bubbleTimer = 0); + void chatOpen (uint32 nUID, const std::string &ucsText, uint bubbleTimer = 0); // Dynamic Chat @@ -199,7 +199,7 @@ public: void unlink (); // Set text - void setText (const ucstring &text); + void setText (const std::string &text); // Called from action handler void next(); @@ -217,7 +217,7 @@ public: private: - void setRawText (const ucstring &text); + void setRawText (const std::string &text); void displayNextAndSkip (bool show); private: @@ -233,7 +233,7 @@ private: CCharacterCL *_Character; // Multi part bubble - std::vector _TextParts; + std::vector _TextParts; uint32 _CurrentPart; }; diff --git a/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index aebc7cb4a..c930cf80a 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -3,8 +3,8 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -200,9 +200,9 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) // Names const char *templateName; - ucstring theTribeName; - ucstring entityName = entity->getDisplayName(); - ucstring entityTitle = entity->getTitle(); + const char *theTribeName = ""; + std::string entityName = entity->getDisplayName(); + std::string entityTitle = entity->getTitle(); // For some NPC's the name is empty and only a title is given, // in that case, treat the title as the name. @@ -980,7 +980,7 @@ void CGroupInSceneUserInfo::updateDynamicData () if (pPlayer != NULL) if (pPlayer->isAFK()) entityName += CI18N::get("uiAFK"); - _Name->setText(entityName); + _Name->setText(entityName.toUtf8()); // Title color get the PVP color if (_Title) @@ -1006,7 +1006,7 @@ void CGroupInSceneUserInfo::updateDynamicData () if (_GuildName) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring ucsTmp; + string ucsTmp; if (pSMC->getString (_Entity->getGuildNameID(), ucsTmp)) _GuildName->setText(ucsTmp); @@ -1032,8 +1032,8 @@ void CGroupInSceneUserInfo::updateDynamicData () if (_EventFaction) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring ucsTmp; - if (pSMC->getString (_Entity->getEventFactionID(), ucsTmp)) + string ucsTmp; + if (pSMC->getString(_Entity->getEventFactionID(), ucsTmp)) _EventFaction->setText(ucsTmp); // guildname color depends of PVP faction or not @@ -1136,7 +1136,7 @@ void CGroupInSceneUserInfo::updateDynamicData () { CInterfaceGroup *group = getGroup ("right"); CForageSourceCL *forageSource = static_cast(_Entity); - ucstring txt( CI18N::get( "uittForageContent" ) + toString( ": %u", forageSource->getCurrentQuantity() ) ); + string txt( CI18N::get( "uittForageContent" ) + toString( ": %u", forageSource->getCurrentQuantity() ) ); CCtrlBase *toolTip = group->getCtrl ("tt1"); if ( toolTip ) toolTip->setDefaultContextHelp( txt ); diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp index dd5e5ae20..d8b02f90f 100644 --- a/ryzom/client/src/interface_v3/group_map.cpp +++ b/ryzom/client/src/interface_v3/group_map.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -141,12 +141,12 @@ static void popupLandMarkNameDialog() const CUserLandMark userLM = map->getUserLandMark(LastSelectedLandMark); NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(userLM.Type)); - eb->setInputString(userLM.Title); + eb->setInputStringAsUtf16(userLM.Title); } else { NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(CUserLandMark::Misc)); - eb->setInputString(ucstring()); + eb->setInputStringAsUtf16(ucstring()); } CWidgetManager::getInstance()->setCaptureKeyboard(eb); @@ -1177,7 +1177,7 @@ void CGroupMap::checkCoords() // update text if needed if (!_MissionTargetTextReceived[k]) { - ucstring result; + string result; if (STRING_MANAGER::CStringManagerClient::instance()->getDynString(_MissionTargetTextIDs[k], result)) { _MissionLM[k]->setDefaultContextHelp(result); @@ -1241,9 +1241,7 @@ void CGroupMap::checkCoords() _RespawnLM[i] = createArkPointButton(_ArkPoints[i]); _RespawnLM[i]->setId(this->getId() + ":arklm_" + NLMISC::toString(i)); _RespawnLM[i]->setParent(this); - ucstring title; - title.fromUtf8(_ArkPoints[i].Title); - _RespawnLM[i]->setDefaultContextHelp(title); + _RespawnLM[i]->setDefaultContextHelp(_ArkPoints[i].Title); _RespawnLM[i]->HandleEvents = true; addCtrl(_RespawnLM[i]); updateLMPosFromDBPos(_RespawnLM[i], _ArkPoints[i].x, _ArkPoints[i].y); @@ -1404,12 +1402,12 @@ void CGroupMap::checkCoords() CInterfaceManager *im = CInterfaceManager::getInstance(); uint32 val = NLGUI::CDBManager::getInstance()->getDbProp(NLMISC::toString("SERVER:GROUP:%d:NAME",i))->getValue32(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring res; + string res; - if (pSMC->getString(val,res)) + if (pSMC->getString(val, res)) { - res = CEntityCL::removeTitleAndShardFromName(res); - _TeammateLM[i]->setDefaultContextHelp(res); + std::string res2 = CEntityCL::removeTitleAndShardFromName(res); + _TeammateLM[i]->setDefaultContextHelp(res2); } } updateLMPosFromDBPos(_TeammateLM[i], px, py); @@ -2472,7 +2470,8 @@ void CGroupMap::updateMatchedLandmarks() std::vector > params; params.clear(); params.push_back(std::pair("id", toString("lm%d", k))); - params.push_back(std::pair("tooltip", _MatchedLandmarks[k].Title.toUtf8())); + // ctrl base expects utf8 string to start with "u:" + params.push_back(std::pair("tooltip", "u:" + _MatchedLandmarks[k].Title.toUtf8())); params.push_back(std::pair("index", toString(k))); CInterfaceGroup *g = CWidgetManager::getInstance()->getParser()->createGroupInstance("lm_search_result", pL->getId(), params); @@ -2483,7 +2482,7 @@ void CGroupMap::updateMatchedLandmarks() CViewText* t = dynamic_cast(g->getView("title")); if (t) { - t->setSingleLineTextFormatTaged(_MatchedLandmarks[k].Title); + t->setSingleLineTextFormatTaged(_MatchedLandmarks[k].Title.toUtf8()); } CViewBitmap* b = dynamic_cast(g->getView("icon")); @@ -2532,19 +2531,19 @@ void CGroupMap::createLMWidgets(const std::vector &lms) NLMISC::CVector2f mapPos; worldToMap(mapPos, rCLM.Pos); - const ucstring ucsTmp(CStringManagerClient::getPlaceLocalizedName(rCLM.TitleTextID)); - const ucstring lcTitle = toLower(ucsTmp); + const char *ucsTmp = CStringManagerClient::getPlaceLocalizedName(rCLM.TitleTextID); + const std::string lcTitle = toLower(ucsTmp); bool searchMatch = notWorldMode && _LandmarkFilter.size() > 0 && filterLandmark(lcTitle); if (searchMatch) - _MatchedLandmarks.push_back(SMatchedLandmark(rCLM.Pos, ucsTmp, _ContinentLMOptions)); + _MatchedLandmarks.push_back(SMatchedLandmark(rCLM.Pos, ucstring::makeFromUtf8(ucsTmp), _ContinentLMOptions)); // Add button if not a region nor a place if ((rCLM.Type != CContLandMark::Region) && (rCLM.Type != CContLandMark::Place) && (rCLM.Type != CContLandMark::Street)) { if (rCLM.Type != CContLandMark::Stable) - addLandMark(_ContinentLM, mapPos, ucsTmp, _ContinentLMOptions); + addLandMark(_ContinentLM, mapPos, ucstring::makeFromUtf8(ucsTmp), _ContinentLMOptions); else addLandMark(_ContinentLM, mapPos, CI18N::get("uiStable"), _ContinentLMOptions); _ContinentLM.back()->Type = rCLM.Type; @@ -2680,7 +2679,7 @@ void CGroupMap::setLandmarkFilter(const std::string &s) if (!s.empty()) { ucstring ucs; ucs.fromUtf8(s); - splitUCString(toLower(s), ucstring(" "), _LandmarkFilter); + splitUCString(toLower(ucs), ucstring(" "), _LandmarkFilter); } // recreate landmarks @@ -2815,7 +2814,7 @@ void CGroupMap::addLandMark(TLandMarkButtonVect &destList, const NLMISC::CVector CLandMarkButton *lmb = createLandMarkButton(options); lmb->setParent(this); lmb->Pos = pos; - lmb->setDefaultContextHelp(title); + lmb->setDefaultContextHelp(title.toUtf8()); destList.push_back(lmb); addCtrl(lmb); } @@ -2837,7 +2836,7 @@ void CGroupMap::addUserLandMark(const NLMISC::CVector2f &pos, const ucstring &ti CLandMarkButton *lmb = createLandMarkButton(options); lmb->setParent(this); lmb->Pos = pos; - lmb->setDefaultContextHelp(title); + lmb->setDefaultContextHelp(title.toUtf8()); _UserLM.push_back(lmb); addCtrl(lmb); invalidateCoords(); @@ -2941,7 +2940,7 @@ void CGroupMap::updateUserLandMark(CCtrlButton *button, const ucstring &newTitle _CurContinent->UserLandMarks[k].Type = (uint8)lmType; updateLandMarkButton(_UserLM[k], getUserLandMarkOptions(k)); - button->setDefaultContextHelp(newTitle); + button->setDefaultContextHelp(newTitle.toUtf8()); CInterfaceManager::getInstance()->saveLandmarks(); return; @@ -3361,7 +3360,7 @@ void CGroupMap::targetLandmarkResult(uint32 index) CCompassTarget ct; ct.Pos = _MatchedLandmarks[index].Pos; - ct.Name = _MatchedLandmarks[index].Title; + ct.Name = _MatchedLandmarks[index].Title.toUtf8(); // type sets compass arrow color ct.setType(CCompassTarget::UserLandMark); @@ -3393,7 +3392,7 @@ CGroupMap::CLandMarkButton* CGroupMap::findClosestLandmark(const CVector2f ¢ for(TLandMarkButtonVect::const_iterator it = landmarks.begin(); it != landmarks.end(); ++it) { ucstring lc; - (*it)->getContextHelp(lc); + (*it)->getContextHelpAsUtf16(lc); if(filterLandmark(lc, keywords, startsWith)) { CVector2f pos; mapToWorld(pos, (*it)->Pos); @@ -3424,7 +3423,7 @@ CGroupMap::CLandMarkText* CGroupMap::findClosestLandmark(const CVector2f ¢er for(TLandMarkTextVect::const_iterator it = landmarks.begin(); it != landmarks.end(); ++it) { ucstring lc; - lc = (*it)->getText(); + lc = CUtfStringView((*it)->getText()).toUtf16(); if(filterLandmark(lc, keywords, startsWith)) { CVector2f pos; mapToWorld(pos, (*it)->Pos); @@ -3827,10 +3826,10 @@ void CGroupMap::updateClosestLandMarkMenu(const std::string &menu, const NLMISC: std::string lineId = toString("%s:lmcosest%d", menu.c_str(), i); std::string ahParams = toString("type=user|map=%s|index=%d", _Id.c_str(), index); - CViewTextMenu* vt = rootMenu->addLine(ucstring(""), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false); + CViewTextMenu* vt = rootMenu->addLine(std::string(), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false); if (!vt) break; - vt->setSingleLineTextFormatTaged(name); + vt->setSingleLineTextFormatTaged(name.toUtf8()); // TODO: should calculate from mouse pos and client width vt->setLineMaxW(800); @@ -3898,7 +3897,7 @@ class CAHLandMarkFilter : public IActionHandler CGroupEditBox* eb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(group)); if (!eb) return; - text = eb->getInputString().toUtf8(); + text = eb->getInputString(); } map->setLandmarkFilter(text); @@ -4006,7 +4005,7 @@ class CAHValidateUserLandMarkName : public IActionHandler CGroupMap *map = dynamic_cast(LastSelectedLandMark->getParent()); if (!map) return; // update existing landmark - map->updateUserLandMark(LastSelectedLandMark, eb->getInputString(), landMarkType); + map->updateUserLandMark(LastSelectedLandMark, eb->getInputStringAsUtf16(), landMarkType); } else { @@ -4014,11 +4013,11 @@ class CAHValidateUserLandMarkName : public IActionHandler if (!LastClickedMap) return; if( UseUserPositionForLandMark ) { - LastClickedMap->addUserLandMark(LastClickedMap->getPlayerPos(), eb->getInputString(), landMarkType); + LastClickedMap->addUserLandMark(LastClickedMap->getPlayerPos(), eb->getInputStringAsUtf16(), landMarkType); } else { - LastClickedMap->addUserLandMark(LastClickedMap->getRightClickLastPos(), eb->getInputString(), landMarkType); + LastClickedMap->addUserLandMark(LastClickedMap->getRightClickLastPos(), eb->getInputStringAsUtf16(), landMarkType); } LastClickedMap->invalidateCoords(); } diff --git a/ryzom/client/src/interface_v3/group_modal_get_key.cpp b/ryzom/client/src/interface_v3/group_modal_get_key.cpp index c2d29df78..b79f6c38a 100644 --- a/ryzom/client/src/interface_v3/group_modal_get_key.cpp +++ b/ryzom/client/src/interface_v3/group_modal_get_key.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -89,7 +90,7 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) // Setup the text ! CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewText *pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( VIEW_TEXT_KEY )); - if (pVT != NULL) pVT->setText(Combo.toUCString()); + if (pVT != NULL) pVT->setText(Combo.toString()); // Check if in use CActionsManager *pCurAM = NULL; @@ -111,12 +112,12 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) if (baseAction && pCurAM->isActionPresentInContext(it->second)) { ucstring shortcutName = baseAction->getActionLocalizedText(it->second); - if (pVT != NULL) pVT->setText(shortcutName); + if (pVT != NULL) pVT->setText(shortcutName.toUtf8()); } } else { - if (pVT != NULL) pVT->setText(string("")); + if (pVT != NULL) pVT->setText(string()); } } diff --git a/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp b/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp index 04d05e6f2..7d2054fc4 100644 --- a/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -224,7 +225,7 @@ void CGroupPhraseSkillFilter::rebuild() // just text pNode->DisplayText = true; pNode->Template = NULL; - pNode->Text= STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i);; + pNode->Text = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i); // Action handler? if(!_AHCtrlNode.empty()) diff --git a/ryzom/client/src/interface_v3/group_quick_help.cpp b/ryzom/client/src/interface_v3/group_quick_help.cpp index 0b789fccf..8a5e925cf 100644 --- a/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -244,7 +245,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())); if (ite != actionCombo.end()) { - addString (ite->second.toUCString()); + addString (ite->second.toString()); } } } diff --git a/ryzom/client/src/interface_v3/group_quick_help.h b/ryzom/client/src/interface_v3/group_quick_help.h index 0d897d014..6f9c748a3 100644 --- a/ryzom/client/src/interface_v3/group_quick_help.h +++ b/ryzom/client/src/interface_v3/group_quick_help.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/group_skills.cpp b/ryzom/client/src/interface_v3/group_skills.cpp index f2586401a..146117d17 100644 --- a/ryzom/client/src/interface_v3/group_skills.cpp +++ b/ryzom/client/src/interface_v3/group_skills.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -245,11 +246,11 @@ static DECLARE_INTERFACE_USER_FCT(getSkillBaseText) if(skillValue!=skillBase) { - result.setUCString( toString("(%d)", skillBase) ); + result.setString( toString("(%d)", skillBase) ); } else { - result.setUCString( ucstring() ); + result.setString( std::string() ); } return true; @@ -335,7 +336,7 @@ void CGroupSkills::createAllTreeNodes() // local variable (avoid realloc in loop) vector< pair > tempVec(2); - ucstring sSkillName; + const char *sSkillName; while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop { diff --git a/ryzom/client/src/interface_v3/guild_manager.cpp b/ryzom/client/src/interface_v3/guild_manager.cpp index 5190404ab..0ccabc494 100644 --- a/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/ryzom/client/src/interface_v3/guild_manager.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -245,11 +246,11 @@ bool CGuildManager::isLeaderOfTheGuild() } // *************************************************************************** -ucstring CGuildManager::getGuildName() +string CGuildManager::getGuildName() { if (_InGuild) return _Guild.Name; - return ucstring(""); + return string(); } // *************************************************************************** @@ -369,13 +370,13 @@ void CGuildManager::update() if (node && node->getValueBool()) { // See if we need to show any online/offline messages - static map CachedGuildMembers; - ucstring onlineMessage = CI18N::get("uiPlayerOnline"); - ucstring offlineMessage = CI18N::get("uiPlayerOffline"); + static map CachedGuildMembers; + const string &onlineMessage = CI18N::get("uiPlayerOnline"); + const string &offlineMessage = CI18N::get("uiPlayerOffline"); for (uint i = 0; i < _GuildMembers.size(); ++i) { - map::const_iterator it = CachedGuildMembers.find(_GuildMembers[i].Name); + map::const_iterator it = CachedGuildMembers.find(_GuildMembers[i].Name); if ( it != CachedGuildMembers.end() ) { if ( (*it).second.Online == _GuildMembers[i].Online) @@ -390,7 +391,7 @@ void CGuildManager::update() continue; } - ucstring msg = (_GuildMembers[i].Online != ccs_offline) ? onlineMessage : offlineMessage; + string msg = (_GuildMembers[i].Online != ccs_offline) ? onlineMessage : offlineMessage; strFindReplace(msg, "%s", _GuildMembers[i].Name); string cat = getStringCategory(msg, msg); map::const_iterator it; @@ -418,7 +419,7 @@ void CGuildManager::update() { uint i; _Grade = EGSPD::CGuildGrade::Member; - ucstring sUserName = toLower(UserEntity->getEntityName()); + string sUserName = toLower(UserEntity->getEntityName()); for (i = 0; i < _GuildMembers.size(); ++i) { if (toLower(_GuildMembers[i].Name) == sUserName) @@ -722,7 +723,7 @@ bool CDBGroupListAscensor::CSheetChildAscensor::isInvalidated(CDBGroupListSheetT STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); uint32 nameID = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:" + toString(Index) + ":NAME")->getValue32(); - ucstring name; + string name; if (nameID && pSMC->getDynString(nameID, name)) { Text->setText(name); @@ -886,7 +887,7 @@ class CAHGuildSheetOpen : public IActionHandler { CRyzomTime rt; rt.updateRyzomClock(rGuildMembers[i].EnterDate); - ucstring str = toString("%04d", rt.getRyzomYear()) + " "; + string str = toString("%04d", rt.getRyzomYear()) + " "; str += CI18N::get("uiJenaYear") + " : "; str += CI18N::get("uiAtysianCycle") + " "; str += toString("%01d", rt.getRyzomCycle()+1) +", "; @@ -998,12 +999,12 @@ class CAHGuildSheetMenuOpen : public IActionHandler public: // Current selection static sint32 MemberIndexSelected; // Index of the member selected when right clicked - static ucstring MemberNameSelected; // Name of the member selected when right clicked (for extra check) + static std::string MemberNameSelected; // Name of the member selected when right clicked (for extra check) }; REGISTER_ACTION_HANDLER (CAHGuildSheetMenuOpen, "guild_member_menu_open"); sint32 CAHGuildSheetMenuOpen::MemberIndexSelected= -1; -ucstring CAHGuildSheetMenuOpen::MemberNameSelected; +std::string CAHGuildSheetMenuOpen::MemberNameSelected; // *************************************************************************** @@ -1098,12 +1099,12 @@ public: // Current selection static sint32 MemberIndexSelected; // Index of the member selected when left clicked - static ucstring MemberNameSelected; // Name of the member selected when lef clicked + static std::string MemberNameSelected; // Name of the member selected when lef clicked }; REGISTER_ACTION_HANDLER(CAHGuildSheetTellMember, "guild_tell_member"); sint32 CAHGuildSheetTellMember::MemberIndexSelected= -1; -ucstring CAHGuildSheetTellMember::MemberNameSelected; +string CAHGuildSheetTellMember::MemberNameSelected; // *************************************************************************** class CAHGuildSheetSetLeader : public IActionHandler diff --git a/ryzom/client/src/interface_v3/guild_manager.h b/ryzom/client/src/interface_v3/guild_manager.h index 7b8b94df2..11c44210c 100644 --- a/ryzom/client/src/interface_v3/guild_manager.h +++ b/ryzom/client/src/interface_v3/guild_manager.h @@ -37,7 +37,7 @@ struct SGuildMember { uint32 Index; // Index in the DB uint32 NameID; - ucstring Name; + std::string Name; EGSPD::CGuildGrade::TGuildGrade Grade; TCharConnectionState Online; uint32 EnterDate; @@ -54,7 +54,7 @@ struct SGuildMember struct SGuild { uint32 NameID; - ucstring Name; + std::string Name; uint64 Icon; bool QuitGuildAvailable; @@ -131,7 +131,7 @@ public: bool isLeaderOfTheGuild(); /// If the player is in a guild get the guild name else return empty - ucstring getGuildName(); + std::string getGuildName(); /// If the player is in a guild get the amount of money the guild owns else return zero uint64 getMoney(); @@ -270,7 +270,7 @@ private: // Join Proposal handling uint32 _JoinPropPhraseID; - ucstring _JoinPropPhrase; + std::string _JoinPropPhrase; bool _JoinPropUpdate; }; diff --git a/ryzom/client/src/interface_v3/input_handler_manager.cpp b/ryzom/client/src/interface_v3/input_handler_manager.cpp index 67a1b2350..28420dff4 100644 --- a/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/input_handler_manager.h b/ryzom/client/src/interface_v3/input_handler_manager.h index 4b078ee84..b587fecef 100644 --- a/ryzom/client/src/interface_v3/input_handler_manager.h +++ b/ryzom/client/src/interface_v3/input_handler_manager.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/interface_v3/interface_ddx.cpp b/ryzom/client/src/interface_v3/interface_ddx.cpp index 347a0d94d..36bd17e62 100644 --- a/ryzom/client/src/interface_v3/interface_ddx.cpp +++ b/ryzom/client/src/interface_v3/interface_ddx.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -350,7 +351,7 @@ void CInterfaceDDX::CParam::updateScrollView(sint32 nVal) { if(ResultView) { - ResultView->setText(ucstring(toString(nVal)) + ResultUnit); + ResultView->setText(toString(nVal) + ResultUnit.toUtf8()); } } @@ -361,7 +362,7 @@ void CInterfaceDDX::CParam::updateScrollView(double nVal) { // allow N digits string fmt= toString("%%.%df", ResultDecimal); - ResultView->setText(ucstring(toString(fmt.c_str(), nVal)) + ResultUnit); + ResultView->setText(toString(fmt.c_str(), nVal) + ResultUnit.toUtf8()); } } diff --git a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index 30126c0d9..9494deacf 100644 --- a/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -176,7 +177,7 @@ static DECLARE_INTERFACE_USER_FCT(getCompassText) "uiWNW", }; - result.setUCString( CI18N::get(txts[direction]) ); + result.setString( CI18N::get(txts[direction]) ); return true; } REGISTER_INTERFACE_USER_FCT("getCompassText", getCompassText); @@ -251,7 +252,7 @@ static DECLARE_INTERFACE_USER_FCT(getDifficultyText) } SENTENCE_APPRAISAL::ESentenceAppraisal sa = (SENTENCE_APPRAISAL::ESentenceAppraisal)args[0].getInteger(); - result.setUCString (CI18N::get(SENTENCE_APPRAISAL::toString(sa))); + result.setString (CI18N::get(SENTENCE_APPRAISAL::toString(sa))); return true; } @@ -665,14 +666,14 @@ static DECLARE_INTERFACE_USER_FCT(getKey) CActionsManager::TActionComboMap::const_iterator it = acmap.find(CAction::CName(name.c_str(),param.c_str())); if (it != acmap.end()) { - result.setUCString (it->second.toUCString()); + result.setString (it->second.toString()); } else { if (notna) - result.setUCString (ucstring("")); + result.setString (std::string()); else - result.setUCString (CI18N::get("uiNotAssigned")); + result.setString (CI18N::get("uiNotAssigned")); } return true; @@ -1025,9 +1026,9 @@ static DECLARE_INTERFACE_USER_FCT(getBotChatBuyFilterMPText) RM_FABER_TYPE::TRMFType faberType= (RM_FABER_TYPE::TRMFType)args[0].getInteger(); if(faberType>=RM_FABER_TYPE::Unknown) - result.setUCString(CI18N::get("uittBCNoItemPartFilter")); + result.setString(CI18N::get("uittBCNoItemPartFilter")); else - result.setUCString(RM_FABER_TYPE::toLocalString(faberType)); + result.setString(RM_FABER_TYPE::toLocalString(faberType)); return true; } @@ -1076,15 +1077,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostName) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getOutpostLocalizedName(CSheetId(nSheet))); + const char *name = pSMC->getOutpostLocalizedName(CSheetId(nSheet)); - result.setUCString(name); + result.setString(name); return true; } @@ -1103,15 +1104,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostDesc) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getOutpostLocalizedDescription(CSheetId(nSheet))); + const char *name = pSMC->getOutpostLocalizedDescription(CSheetId(nSheet)); - result.setUCString(name); + result.setString(name); return true; } @@ -1130,15 +1131,15 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingName) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet))); + const char *name = pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet)); - result.setUCString(name); + result.setString(name); return true; } @@ -1157,18 +1158,18 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name - ucstring name; + const char *name; CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet)); COutpostBuildingSheet *pOBS = dynamic_cast(pSheet); if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty) { // Don't display description if the building is an empty slot - name.clear(); + name = ""; } else { @@ -1177,7 +1178,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc) } - result.setUCString(name); + result.setString(name); return true; } @@ -1196,15 +1197,15 @@ static DECLARE_INTERFACE_USER_FCT(getSquadName) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getSquadLocalizedName(CSheetId(nSheet))); + const char *name = pSMC->getSquadLocalizedName(CSheetId(nSheet)); - result.setUCString(name); + result.setString(name); return true; } @@ -1223,15 +1224,15 @@ static DECLARE_INTERFACE_USER_FCT(getSquadDesc) uint32 nSheet = (uint32)args[0].getInteger(); if (nSheet == 0) { - result.setUCString(string("")); + result.setString(string()); return true; } // get sheet name STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - const ucstring name(pSMC->getSquadLocalizedDescription(CSheetId(nSheet))); + const char *name = pSMC->getSquadLocalizedDescription(CSheetId(nSheet)); - result.setUCString(name); + result.setString(name); return true; } @@ -1284,7 +1285,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) // if status wanted is peace or unknow, then "N/A", because there is no attack period in peace mode if( status==OUTPOSTENUMS::Peace || status==OUTPOSTENUMS::UnknownOutpostState ) { - result.setUCString(string(" - ")); + result.setString(string(" - ")); return true; } @@ -1292,7 +1293,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) if( (isAttackPeriod && status>OUTPOSTENUMS::AttackRound) || (!isAttackPeriod && status>OUTPOSTENUMS::DefenseRound) ) { - result.setUCString(CI18N::get("uiOutpostPeriodEnded")); + result.setString(CI18N::get("uiOutpostPeriodEnded")); return true; } @@ -1312,7 +1313,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) tstruct= gmtime(&tval); if(!tstruct) { - result.setUCString(string("Bad Date Received")); + result.setString(string("Bad Date Received")); return true; } dname= tstruct->tm_wday; // 0-6 (Sunday==0!!) @@ -1325,21 +1326,21 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostPeriod) tstruct= gmtime(&tval); if(!tstruct) { - result.setUCString(string("Bad Date Received")); + result.setString(string("Bad Date Received")); return true; } hend= tstruct->tm_hour; // 0-23 mend= tstruct->tm_min; // 0-59 // translate - ucstring res= CI18N::get("uiOutpostPeriodFormat"); + string res= CI18N::get("uiOutpostPeriodFormat"); strFindReplace( res, "%dayname", CI18N::get(toString("uiDay%d", dname)) ); strFindReplace( res, "%daynumber", toString(dnumber) ); strFindReplace( res, "%month", CI18N::get(toString("uiMonth%02d", month+1)) ); strFindReplace( res, "%timestart", toString("%02d:%02d", hstart, mstart) ); strFindReplace( res, "%timeend", toString("%02d:%02d", hend, mend) ); - result.setUCString(res); + result.setString(res); return true; } REGISTER_INTERFACE_USER_FCT("getOutpostPeriod", getOutpostPeriod) diff --git a/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp b/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp index 9aeec4e5f..cae4b9d77 100644 --- a/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp +++ b/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -312,16 +313,16 @@ static DECLARE_INTERFACE_USER_FCT(getSheetName) // if from ctrlSheet, then take the correct ACTUAL name (ie from NAMEID if not 0) if(ctrlSheet) { - result.setUCString(ctrlSheet->getItemActualName()); + result.setString(ctrlSheet->getItemActualName().toUtf8()); return true; } // Standard (but less accurate) way else { const CItemSheet *itemSheet = getItemSheet(args); - ucstring tmp; + const char *tmp = ""; if (itemSheet != NULL) tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id); - result.setUCString(tmp); + result.setString(tmp); return true; } } @@ -345,9 +346,9 @@ static DECLARE_INTERFACE_USER_FCT(getItemTranslatedName) return false; } - ucstring tmp; + const char *tmp = ""; tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet); - result.setUCString(tmp); + result.setString(tmp); return true; } REGISTER_INTERFACE_USER_FCT("getItemTranslatedName", getItemTranslatedName) diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index e81785ea8..13dad2f2a 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010-2017 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2010-2019 Jan BOON (Kaetemi) +// Copyright (C) 2010-2020 Jan BOON (Kaetemi) // Copyright (C) 2011 Robert TIMM (rti) // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) @@ -310,12 +310,12 @@ public: class CStringManagerTextProvider : public CViewTextID::IViewTextProvider { - bool getString( uint32 stringId, ucstring &result ) + bool getString( uint32 stringId, string &result ) { return STRING_MANAGER::CStringManagerClient::instance()->getString( stringId, result ); } - bool getDynString( uint32 dynStringId, ucstring &result ) + bool getDynString( uint32 dynStringId, string &result ) { return STRING_MANAGER::CStringManagerClient::instance()->getDynString( dynStringId, result ); } @@ -324,112 +324,119 @@ class CStringManagerTextProvider : public CViewTextID::IViewTextProvider class CRyzomTextFormatter : public CViewTextFormated::IViewTextFormatter { public: - ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) + std::string formatString( const std::string &inputString, const std::string ¶mString ) { - ucstring formatedResult; + std::string formatedResult; // Apply the format - for(ucstring::const_iterator it = inputString.begin(); it != inputString.end();) + for(std::string::const_iterator it = inputString.begin(); it != inputString.end();) { if (*it == '$') { ++it; if (it == inputString.end()) + { + formatedResult += '$'; + --it; break; + } switch(*it) { case 't': // add text ID + { formatedResult += paramString; break; - + } case 'P': case 'p': // add player name - if (ClientCfg.Local) + { + if (ClientCfg.Local || !UserEntity) { - formatedResult += ucstring("player"); + if (*it == 'P') formatedResult += "PLAYER"; + else formatedResult += "Player"; } else { - if(UserEntity) - { - ucstring name = UserEntity->getEntityName(); - if (*it == 'P') setCase(name, CaseUpper); - formatedResult += name; - } + std::string name = UserEntity->getEntityName(); + if (*it == 'P') name = toUpper(name); + formatedResult += name; } break; - // + } case 's': case 'b': // add bot name + { + string botName; + bool womanTitle = false; + if (ClientCfg.Local) { - ucstring botName; - bool womanTitle = false; - if (ClientCfg.Local) - { - botName = ucstring("NPC"); - } - else + botName = "NPC"; + } + else + { + CLFECOMMON::TCLEntityId trader = CLFECOMMON::INVALID_SLOT; + if(UserEntity) + trader = UserEntity->trader(); + if (trader != CLFECOMMON::INVALID_SLOT) { - CLFECOMMON::TCLEntityId trader = CLFECOMMON::INVALID_SLOT; - if(UserEntity) - trader = UserEntity->trader(); - if (trader != CLFECOMMON::INVALID_SLOT) + CEntityCL *entity = EntitiesMngr.entity(trader); + if (entity != NULL) { - CEntityCL *entity = EntitiesMngr.entity(trader); - if (entity != NULL) + uint32 nDBid = entity->getNameId(); + if (nDBid != 0) + { + STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); + pSMC->getString(nDBid, botName); + } + else { - uint32 nDBid = entity->getNameId(); - if (nDBid != 0) - { - STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - pSMC->getString(nDBid, botName); - } - else - { - botName = entity->getDisplayName(); - } - CCharacterCL *pChar = dynamic_cast(entity); - if (pChar != NULL) - womanTitle = pChar->getGender() == GSGENDER::female; + botName = entity->getDisplayName(); } + CCharacterCL *pChar = dynamic_cast(entity); + if (pChar != NULL) + womanTitle = pChar->getGender() == GSGENDER::female; } } - // get the title translated - ucstring sTitleTranslated = botName; - CStringPostProcessRemoveName spprn; - spprn.Woman = womanTitle; - spprn.cbIDStringReceived(sTitleTranslated); - - botName = CEntityCL::removeTitleAndShardFromName(botName); + } + // get the title translated + string sTitleTranslated = botName; // FIXME: UTF-8 + CStringPostProcessRemoveName spprn; + spprn.Woman = womanTitle; + spprn.cbIDStringReceived(sTitleTranslated); - // short name (with no title such as 'guard', 'merchant' ...) - if (*it == 's') - { - // But if there is no name, display only the title - if (botName.empty()) - botName = sTitleTranslated; - } - else - { - // Else we want the title ! - if (!botName.empty()) - botName += " "; - botName += sTitleTranslated; - } + botName = CEntityCL::removeTitleAndShardFromName(botName); - formatedResult += botName; + // short name (with no title such as 'guard', 'merchant' ...) + if (*it == 's') + { + // But if there is no name, display only the title + if (botName.empty()) + botName = sTitleTranslated; + } + else + { + // Else we want the title ! + if (!botName.empty()) + botName += " "; + botName += sTitleTranslated; } + + formatedResult += botName; break; - default: - formatedResult += (ucchar) '$'; + } + default: + { + formatedResult += '$'; + --it; break; } + } ++it; } else { - formatedResult += (ucchar) *it; + formatedResult += *it; ++it; } } @@ -975,7 +982,7 @@ void CInterfaceManager::initInGame() // flush system msg buffer for( uint i=0; i(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather")); if (pVT != NULL) - pVT->setText(str); + pVT->setText(str.toUtf8()); CCtrlBase *pTooltip= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather_tt")); if (pTooltip != NULL) { - ucstring tt = toString("%02d", WeatherManager.getNextWeatherHour()) + CI18N::get("uiMissionTimerHour") + + string tt = toString("%02d", WeatherManager.getNextWeatherHour()) + CI18N::get("uiMissionTimerHour") + " - " + CI18N::get("uiHumidity") + " " + toString("%d", (uint)(roundWeatherValue(WeatherManager.getNextWeatherValue()) * 100.f)) + "%"; pTooltip->setDefaultContextHelp(tt); @@ -1564,7 +1571,7 @@ void CInterfaceManager::updateFrameEvents() pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:time")); if (pVT != NULL) - pVT->setText(str); + pVT->setText(str.toUtf8()); str.clear(); // Update the clock in the compass if enabled. @@ -1577,7 +1584,7 @@ void CInterfaceManager::updateFrameEvents() str = getTimestampHuman("%I:%M %p"); else str = getTimestampHuman("%H:%M"); - pVT->setText(str); + pVT->setText(str.toUtf8()); } } } @@ -2302,7 +2309,7 @@ void CInterfaceManager::addServerString (const std::string &sTarget, uint32 id, if (id == 0) { CInterfaceExprValue val; - val.setUCString (ucstring("")); + val.setString (std::string()); CInterfaceLink::setTargetProperty (sTarget, val); return; } @@ -2320,7 +2327,7 @@ void CInterfaceManager::addServerID (const std::string &sTarget, uint32 id, IStr if (id == 0) { CInterfaceExprValue val; - val.setUCString (ucstring("")); + val.setString (std::string()); CInterfaceLink::setTargetProperty (sTarget, val); return; } @@ -2340,7 +2347,7 @@ void CInterfaceManager::processServerIDString() for (uint32 i = 0; i < _IDStringWaiters.size(); ++i) { bool bAffect = false; - ucstring ucstrToAffect; + string ucstrToAffect; SIDStringWaiter *pISW = _IDStringWaiters[i]; if (pISW->IdOrString == true) // ID ! { @@ -2367,7 +2374,7 @@ void CInterfaceManager::processServerIDString() if (bValid) { ucstrToAffect = STRING_MANAGER::CStringManagerClient::getLocalizedName(ucstrToAffect); - val.setUCString (ucstrToAffect); + val.setString (ucstrToAffect); CInterfaceLink::setTargetProperty (pISW->Target, val); } @@ -2388,7 +2395,7 @@ void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const ucst if (group && viewText) { viewText->setCaseMode(caseMode); - viewText->setText(text); + viewText->setText(text.toUtf8()); CWidgetManager::getInstance()->enableModalWindow(NULL, group); // don't understand why but need to update coords here group->updateCoords(); @@ -2441,7 +2448,7 @@ void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const ucstring & CWidgetManager::getInstance()->setProcedureAction("proc_valid_message_box_cancel", 1, ahOnCancel, paramsOnCancel); // set text and icon - viewText->setText(text); + viewText->setText(text.toUtf8()); if(viewBitmap) { bool active= true; @@ -2488,7 +2495,7 @@ bool CInterfaceManager::getCurrentValidMessageBoxOnOk(string &ahOnOk, const std: // *************************************************************************** -void CInterfaceManager::displayDebugInfo(const ucstring &str, TSystemInfoMode mode /*=InfoMsg*/) +void CInterfaceManager::displayDebugInfo(const string &str, TSystemInfoMode mode /*=InfoMsg*/) { if (PeopleInterraction.DebugInfo) PeopleInterraction.ChatInput.DebugInfo.displayMessage(str, getDebugInfoColor(mode), 2); @@ -2518,7 +2525,7 @@ NLMISC::CRGBA CInterfaceManager::getDebugInfoColor(TSystemInfoMode mode) } // *************************************************************************** -void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat) +void CInterfaceManager::displaySystemInfo(const string &str, const string &cat) { CClientConfig::SSysInfoParam::TMode mode = CClientConfig::SSysInfoParam::Normal; CRGBA color = CRGBA::White; @@ -2989,8 +2996,8 @@ void CInterfaceManager::log(const ucstring &str, const std::string &cat) { const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " (" + NLMISC::toUpper(cat) + ") * " + str.toUtf8(); fprintf(f, "%s\n", finalString.c_str()); + fclose(f); } - fclose(f); } } @@ -3063,7 +3070,7 @@ NLMISC_COMMAND( localCounter, "Get value of local counter", "" ) { if (args.size() != 0) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo(ucstring(toString(im->getLocalSyncActionCounter()))); + im->displaySystemInfo(toString(im->getLocalSyncActionCounter())); return true; } @@ -3345,7 +3352,7 @@ void CInterfaceManager::initEmotes() translateEmote(sTmp, sTranslatedName, sCommandName, sCommandNameAlt); // Create a line - pMenu->addLine (sTranslatedName + " (/" + ucstring::makeFromUtf8(sCommandName) + ")", "emote", + pMenu->addLine (sTranslatedName.toUtf8() + " (/" + sCommandName + ")", "emote", "nb="+toString(nEmoteNb)+"|behav="+toString(nBehav), sTmp); } } @@ -3401,7 +3408,7 @@ void CInterfaceManager::initEmotes() { // Yeah that's a quick emote too; set command pMenu->addLineAtIndex (i, - "@{FFFF}/" + ucstring::makeFromUtf8(sCommandName), + "@{FFFF}/" + sCommandName, "emote", "nb="+toString(nEmoteNb)+"|behav="+toString(nBehav), "", "", "", false, false, true); @@ -4049,11 +4056,11 @@ char* CInterfaceManager::getTimestampHuman(const char* format /* "[%H:%M:%S] " * * * All \d's in default parameter remove a following character. */ -bool CInterfaceManager::parseTokens(ucstring& ucstr) +bool CInterfaceManager::parseTokens(string& ucstr) { - ucstring str = ucstr; - ucstring start_token("$"); - ucstring end_token("$"); + string str = ucstr; + string start_token("$"); + string end_token("$"); size_t start_pos = 0; size_t end_pos = 1; @@ -4070,8 +4077,8 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) // Get the whole token substring first end_pos = str.find(end_token, start_pos + 1); - if ((start_pos == ucstring::npos) || - (end_pos == ucstring::npos) || + if ((start_pos == string::npos) || + (end_pos == string::npos) || (end_pos <= start_pos + 1)) { // Wrong formatting; give up on this one. @@ -4089,19 +4096,19 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) continue; } - ucstring token_whole = str.luabind_substr(start_pos, end_pos - start_pos + 1); - ucstring token_string = token_whole.luabind_substr(1, token_whole.length() - 2); - ucstring token_replacement = token_whole; - ucstring token_default = token_whole; + string token_whole = str.substr(start_pos, end_pos - start_pos + 1); + string token_string = token_whole.substr(1, token_whole.length() - 2); + string token_replacement = token_whole; + string token_default = token_whole; - ucstring token_subject; - ucstring token_param; + string token_subject; + string token_param; // Does the token have a parameter? // If not it is 'name' by default - vector token_vector; - vector param_vector; - splitUCString(token_string, ucstring("."), token_vector); + vector token_vector; + vector param_vector; + splitString(token_string, ".", token_vector); if (token_vector.empty()) { // Wrong formatting; give up on this one. @@ -4111,23 +4118,23 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) token_subject = token_vector[0]; if (token_vector.size() == 1) { - splitUCString(token_subject, ucstring("/"), param_vector); - token_subject = !param_vector.empty() ? param_vector[0] : ucstring(""); - token_param = ucstring("name"); + splitString(token_subject, "/", param_vector); + token_subject = !param_vector.empty() ? param_vector[0] : string(); + token_param = string("name"); } else if (token_vector.size() > 1) { token_param = token_vector[1]; - if (token_param.luabind_substr(0, 3) != ucstring("gs(")) + if (token_param.substr(0, 3) != "gs(") { - splitUCString(token_vector[1], ucstring("/"), param_vector); - token_param = !param_vector.empty() ? param_vector[0] : ucstring(""); + splitString(token_vector[1], "/", param_vector); + token_param = !param_vector.empty() ? param_vector[0] : string(); } } // Get any default value, if not gs sint extra_replacement = 0; - if (token_param.luabind_substr(0, 3) != ucstring("gs(")) + if (token_param.substr(0, 3) != "gs(") { if (param_vector.size() == 2) { @@ -4135,9 +4142,9 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) token_replacement = param_vector[1]; // Delete following chars for every '\d' in default string::size_type token_replacement_pos; - while ((token_replacement_pos = token_replacement.find(ucstring("\\d"))) != string::npos) + while ((token_replacement_pos = token_replacement.find(string("\\d"))) != string::npos) { - token_replacement.replace(token_replacement_pos, 2, ucstring("")); + token_replacement.replace(token_replacement_pos, 2, string()); extra_replacement++; } token_default = token_replacement; @@ -4146,17 +4153,17 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) CEntityCL *pTokenSubjectEntity = NULL; - if (token_subject == ucstring("me")) + if (token_subject == "me") { pTokenSubjectEntity = static_cast(UserEntity); } - else if (token_subject == ucstring("t")) + else if (token_subject == "t") { // Target uint targetSlot = UserEntity->targetSlot(); pTokenSubjectEntity = EntitiesMngr.entity(targetSlot); } - else if (token_subject == ucstring("tt")) + else if (token_subject == "tt") { // Target's target uint targetSlot = UserEntity->targetSlot(); @@ -4174,11 +4181,11 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) } } else if ((token_subject.length() == 3) && - (token_subject.luabind_substr(0, 2) == ucstring("tm"))) + (token_subject.substr(0, 2) == "tm")) { // Teammate uint indexInTeam = 0; - fromString(token_subject.luabind_substr(2, 1).toString(), indexInTeam); + fromString(token_subject.substr(2, 1), indexInTeam); // Make 0-based --indexInTeam; @@ -4214,9 +4221,9 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) if (pTokenSubjectEntity != NULL) { // Parse the parameter - if (token_param == ucstring("name")) + if (token_param == "name") { - ucstring name = pTokenSubjectEntity->getDisplayName(); + string name = pTokenSubjectEntity->getDisplayName(); // special case where there is only a title, very rare case for some NPC if (name.empty()) { @@ -4224,12 +4231,12 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) } token_replacement = name.empty() ? token_replacement : name; } - else if (token_param == ucstring("title")) + else if (token_param == "title") { - ucstring title = pTokenSubjectEntity->getTitle(); + string title = pTokenSubjectEntity->getTitle(); token_replacement = title.empty() ? token_replacement : title; } - else if (token_param == ucstring("race")) + else if (token_param == "race") { CCharacterCL *pC = dynamic_cast(pTokenSubjectEntity); if (pC) @@ -4237,27 +4244,27 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) EGSPD::CPeople::TPeople race = pC->people(); if (race >= EGSPD::CPeople::Playable && race <= EGSPD::CPeople::EndPlayable) { - ucstring srace = NLMISC::CI18N::get("io" + EGSPD::CPeople::toString(race)); + string srace = NLMISC::CI18N::get("io" + EGSPD::CPeople::toString(race)); token_replacement = srace.empty() ? token_replacement : srace; } } } - else if (token_param == ucstring("guild")) + else if (token_param == "guild") { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring ucGuildName; + string ucGuildName; if (pSMC->getString(pTokenSubjectEntity->getGuildNameID(), ucGuildName)) { token_replacement = ucGuildName.empty() ? token_replacement : ucGuildName; } } - else if (token_param.luabind_substr(0, 3) == ucstring("gs(") && - token_param.luabind_substr(token_param.length() - 1 , 1) == ucstring(")")) + else if (token_param.substr(0, 3) == "gs(" && + token_param.substr(token_param.length() - 1 , 1) == ")") { // Gender string - vector strList; - ucstring gender_string = token_param.luabind_substr(3, token_param.length() - 4); - splitUCString(gender_string, ucstring("/"), strList); + vector strList; + string gender_string = token_param.substr(3, token_param.length() - 4); + splitString(gender_string, "/", strList); if (strList.size() <= 1) { @@ -4286,8 +4293,8 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) { // Nothing to replace; show message and exit CInterfaceManager *im = CInterfaceManager::getInstance(); - ucstring message = ucstring(CI18N::get("uiUntranslatedToken")); - message.replace(message.find(ucstring("%s")), 2, token_whole); + string message = CI18N::get("uiUntranslatedToken"); + message.replace(message.find("%s"), 2, token_whole); im->displaySystemInfo(message); return false; } diff --git a/ryzom/client/src/interface_v3/interface_manager.h b/ryzom/client/src/interface_v3/interface_manager.h index 0b89584bc..2aed09dc5 100644 --- a/ryzom/client/src/interface_v3/interface_manager.h +++ b/ryzom/client/src/interface_v3/interface_manager.h @@ -2,8 +2,8 @@ // Copyright (C) 2010-2018 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -249,7 +249,7 @@ public: { public: virtual ~IStringProcess() { } - virtual bool cbIDStringReceived(ucstring &inOut) = 0; // called when string or id is received (return true if valid the change) + virtual bool cbIDStringReceived(std::string &inOut) = 0; // called when string or id is received (return true if valid the change) }; void addServerString (const std::string &sTarget, uint32 id, IStringProcess *cb = NULL); @@ -292,12 +292,12 @@ public: void drawViews (NL3D::UCamera camera); // display a debug info - void displayDebugInfo(const ucstring &str, TSystemInfoMode mode = InfoMsg); + void displayDebugInfo(const std::string &str, TSystemInfoMode mode = InfoMsg); // get the color associated with the given system info mode NLMISC::CRGBA getDebugInfoColor(TSystemInfoMode mode); // display a system info string - void displaySystemInfo(const ucstring &str, const std::string &Category = "SYS"); + void displaySystemInfo(const std::string &str, const std::string &Category = "SYS"); NLMISC::CRGBA getSystemInfoColor(const std::string &Category = "SYS"); void setupOptions(); @@ -448,7 +448,7 @@ public: /** Parses any tokens in the ucstring like $t$ or $g()$ */ - static bool parseTokens(ucstring& ucstr); + static bool parseTokens(std::string& ucstr); // ------------------------------------------------------------------------------------------------ private: diff --git a/ryzom/client/src/interface_v3/inventory_manager.cpp b/ryzom/client/src/interface_v3/inventory_manager.cpp index 5c4799fe4..574140163 100644 --- a/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015-2019 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -2755,7 +2755,7 @@ class CHandlerInvSearchButton : public IActionHandler { CWidgetManager::getInstance()->setCaptureKeyboard(eb); eb->setSelectionAll(); - filter = eb->getInputString(); + filter = eb->getInputStringAsUtf16(); } CDBGroupListSheetBag *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(btn->getParent()->getId() + ":bag_list")); @@ -2805,10 +2805,10 @@ class CHandlerInvSetSearch : public IActionHandler std::string id = pCaller->getParent()->getParent()->getId(); CDBGroupListSheetBag *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(id + ":bag_list")); - if (pList != NULL) pList->setSearchFilter(eb->getInputString()); + if (pList != NULL) pList->setSearchFilter(eb->getInputStringAsUtf16()); CDBGroupIconListBag *pIcons = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(id + ":bag_icons")); - if (pIcons != NULL) pIcons->setSearchFilter(eb->getInputString()); + if (pIcons != NULL) pIcons->setSearchFilter(eb->getInputStringAsUtf16()); } }; REGISTER_ACTION_HANDLER( CHandlerInvSetSearch, "inv_set_search" ); @@ -3236,7 +3236,7 @@ class CHandlerInvTempToBag : public IActionHandler // If we cant find place display a message and dont send the request to the server if (!getInventory().isSpaceInAllBagsForItem(pCSDst)) { - ucstring msg = CI18N::get("msgCantPutItemInBag"); + string msg = CI18N::get("msgCantPutItemInBag"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); return; @@ -3322,7 +3322,7 @@ class CHandlerInvTempAll : public IActionHandler if (!bPlaceFound) { - ucstring msg = CI18N::get("msgCantPutItemInBag"); + string msg = CI18N::get("msgCantPutItemInBag"); string cat = getStringCategory(msg, msg); CInterfaceManager::getInstance()->displaySystemInfo(msg, cat); return; diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 8aa7af585..09fd8e9c3 100644 --- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2019 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -273,7 +273,7 @@ static DECLARE_INTERFACE_USER_FCT(lua) if (CLuaIHM::pop(ls, ucstrVal)) { - result.setUCString(ucstrVal); + result.setString(ucstrVal.toUtf8()); ok = true; } @@ -904,7 +904,7 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) throw ELuaIHMException("setTextFormatTaged(): '%s' is not a CViewText", pIE->getId().c_str()); // Set the text as format - vt->setTextFormatTaged(text); + vt->setTextFormatTaged(text.toUtf8()); return 0; } @@ -1070,7 +1070,7 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls) // Create a line pMenu->addLine(CI18N::get(sTmp), "lua", luaParams + "('" + sEmoteId + "', '" + toString(CI18N::get(sTmp)) + "')", sTmp); - emoteList[sEmoteId] = (toLower(CI18N::get(sTmp))).toUtf8(); + emoteList[sEmoteId] = (toLower(CI18N::get(sTmp))); } } @@ -1426,7 +1426,7 @@ int CLuaIHMRyzom::getPlayerGender(CLuaState &ls) int CLuaIHMRyzom::getPlayerName(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getPlayerName", 0); - ls.push(UserEntity->getEntityName().toUtf8()); + ls.push(UserEntity->getEntityName()); return 1; } @@ -1434,7 +1434,7 @@ int CLuaIHMRyzom::getPlayerName(CLuaState &ls) int CLuaIHMRyzom::getPlayerTitleRaw(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getPlayerTitleRaw", 0); - ls.push(UserEntity->getTitleRaw().toUtf8()); + ls.push(UserEntity->getTitleRaw()); return 1; } @@ -1442,7 +1442,7 @@ int CLuaIHMRyzom::getPlayerTitleRaw(CLuaState &ls) int CLuaIHMRyzom::getPlayerTitle(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getPlayerTitle", 0); - ls.push(UserEntity->getTitle().toUtf8()); + ls.push(UserEntity->getTitle()); return 1; } @@ -1504,7 +1504,7 @@ int CLuaIHMRyzom::getTargetName(CLuaState &ls) if (!target) return 0; - ls.push(target->getEntityName().toUtf8()); + ls.push(target->getEntityName()); return 1; } @@ -1516,7 +1516,7 @@ int CLuaIHMRyzom::getTargetTitleRaw(CLuaState &ls) if (!target) return 0; - ls.push(target->getTitleRaw().toUtf8()); + ls.push(target->getTitleRaw()); return 1; } @@ -1528,7 +1528,7 @@ int CLuaIHMRyzom::getTargetTitle(CLuaState &ls) if (!target) return 0; - ls.push(target->getTitle().toUtf8()); + ls.push(target->getTitle()); return 1; } @@ -1780,7 +1780,7 @@ int CLuaIHMRyzom::displaySystemInfo(CLuaState &ls) ucstring msg; nlverify(CLuaIHM::getUCStringOnStack(ls, 1, msg)); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->displaySystemInfo(msg, ls.toString(2)); + pIM->displaySystemInfo(msg.toUtf8(), ls.toString(2)); return 0; } @@ -2988,7 +2988,7 @@ std::string CLuaIHMRyzom::getDefine(const std::string &def) // *************************************************************************** void CLuaIHMRyzom::setContextHelpText(const ucstring &text) { - CWidgetManager::getInstance()->setContextHelpText(text); + CWidgetManager::getInstance()->setContextHelpText(text.toUtf8()); } // *************************************************************************** @@ -3383,11 +3383,9 @@ void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string if (UserEntity) { - userName = UserEntity->getDisplayName().toString(); + userName = UserEntity->getDisplayName(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring ucsTmp; - pSMC->getString(UserEntity->getGuildNameID(), ucsTmp); - guildName = ucsTmp.toString(); + pSMC->getString(UserEntity->getGuildNameID(), guildName); while (guildName.find(' ') != string::npos) { @@ -3438,16 +3436,16 @@ void CLuaIHMRyzom::clearHtmlUndoRedo(const std::string &htmlId) ucstring CLuaIHMRyzom::getDynString(sint32 dynStringId) { //H_AUTO(Lua_CLuaIHM_getDynString) - ucstring result; + string result; STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynStringId, result); - return result; + return ucstring::makeFromUtf8(result); // TODO: Lua UTF-8 } // *************************************************************************** bool CLuaIHMRyzom::isDynStringAvailable(sint32 dynStringId) { //H_AUTO(Lua_CLuaIHM_isDynStringAvailable) - ucstring result; + string result; bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynStringId, result); return res; } @@ -3599,7 +3597,7 @@ string CLuaIHMRyzom::getGuildMemberName(sint32 nMemberId) if ((nMemberId < 0) || (nMemberId >= getNbGuildMembers())) return ""; - return CGuildManager::getInstance()->getGuildMembers()[nMemberId].Name.toString(); + return CGuildManager::getInstance()->getGuildMembers()[nMemberId].Name; } // *************************************************************************** @@ -3763,7 +3761,7 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) if (!msg.empty()) { // Parse any tokens in the message. - ucstring msg_modified = msg; + string msg_modified = msg.toUtf8(); // Parse any tokens in the text if (! CInterfaceManager::parseTokens(msg_modified)) @@ -3782,7 +3780,7 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) CInterfaceManager *im = CInterfaceManager::getInstance(); w->setKeyboardFocus(); w->enableBlink(1); - w->setCommand(ucstring("tell ") + CEntityCL::removeTitleFromName(player) + ucstring(" "), false); + w->setCommand(ucstring("tell ") + CEntityCL::removeTitleFromName(player.toUtf8()) + ucstring(" "), false); CGroupEditBox *eb = w->getEditBox(); if (eb != NULL) @@ -4457,27 +4455,27 @@ int CLuaIHMRyzom::displayChatMessage(CLuaState &ls) if (input == "around") { prop.readRGBA(std::string(dbPath + ":SAY").c_str(), " "); - ci.AroundMe.displayMessage(ucstring(msg), prop.getRGBA()); + ci.AroundMe.displayMessage(msg, prop.getRGBA()); } else if (input == "region") { prop.readRGBA(std::string(dbPath + ":REGION").c_str(), " "); - ci.Region.displayMessage(ucstring(msg), prop.getRGBA()); + ci.Region.displayMessage(msg, prop.getRGBA()); } else if (input == "universe") { prop.readRGBA(std::string(dbPath + ":UNIVERSE_NEW").c_str(), " "); - ci.Universe.displayMessage(ucstring(msg), prop.getRGBA()); + ci.Universe.displayMessage(msg, prop.getRGBA()); } else if (input == "guild") { prop.readRGBA(std::string(dbPath + ":CLADE").c_str(), " "); - ci.Guild.displayMessage(ucstring(msg), prop.getRGBA()); + ci.Guild.displayMessage(msg, prop.getRGBA()); } else if (input == "team") { prop.readRGBA(std::string(dbPath + ":GROUP").c_str(), " "); - ci.Team.displayMessage(ucstring(msg), prop.getRGBA()); + ci.Team.displayMessage(msg, prop.getRGBA()); } } if (ls.type(2) == LUA_TNUMBER) @@ -4485,7 +4483,7 @@ int CLuaIHMRyzom::displayChatMessage(CLuaState &ls) sint64 id = ls.toInteger(2); prop.readRGBA(toString("%s:DYN:%i", dbPath.c_str(), id).c_str(), " "); if (id >= 0 && id < CChatGroup::MaxDynChanPerPlayer) - ci.DynamicChat[id].displayMessage(ucstring(msg), prop.getRGBA()); + ci.DynamicChat[id].displayMessage(msg, prop.getRGBA()); } return 1; } diff --git a/ryzom/client/src/interface_v3/macrocmd_key.cpp b/ryzom/client/src/interface_v3/macrocmd_key.cpp index 7f4c26c08..81033f5aa 100644 --- a/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -103,14 +104,14 @@ void addKeyLine (CGroupList *pParent, const ucstring &keyName, const ucstring &s CViewText *pViewKeyName = dynamic_cast(pKeysLine->getView(TEMPLATE_KEYS_KEY_NAME)); if (pViewKeyName != NULL) { - pViewKeyName->setText (keyName); + pViewKeyName->setText (keyName.toUtf8()); pViewKeyName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); } CViewText *pViewShortcutName = dynamic_cast(pKeysLine->getView(TEMPLATE_KEYS_SHORTCUT_NAME)); if (pViewShortcutName != NULL) { - pViewShortcutName->setText (shortcutName); + pViewShortcutName->setText (shortcutName.toUtf8()); pViewShortcutName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); } @@ -208,7 +209,7 @@ void getAllComboAction(uint8 nAM, CGroupList *pList, const mapsecond.Combo.Key==KeyCount) keyName= CI18N::get("uiNotAssigned"); else - keyName= remapIT->second.Combo.toUCString(); + keyName= remapIT->second.Combo.toString(); const CBaseAction *baseAction = pAM->getBaseAction(remapIT->second.ActionName); if (baseAction) { @@ -492,7 +493,7 @@ void CModalContainerEditCmd::activate() } if (found) { - pCB->addText( CI18N::get(rVCat[i].LocalizedName) ); + pCB->addText(CI18N::get(rVCat[i].LocalizedName)); CurrentEditCmdCategories.push_back(rVCat[i].Name); } } @@ -512,9 +513,9 @@ void CModalContainerEditCmd::activate() NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(-1); // reset name of params CViewText *pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); invalidCurrentCommand(); } @@ -679,7 +680,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std else sEditBox = WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_EDITBOX; CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sEditBox)); // sTmp is utf8 - pEB->setInputStringAsUtf8(sTmp); + pEB->setInputString(sTmp); } // Setup the param name if any @@ -711,7 +712,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); if (pVT != NULL) pVT->setActive(true); // setup the text of the key - pVT->setText(it->second.toUCString()); + pVT->setText(it->second.toString()); // There is already a shortcut so we can display ok button pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); @@ -863,7 +864,7 @@ void CModalContainerEditCmd::validCurrentCommand() CGroupEditBox *pEB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin )); // convert to utf8 if (pEB != NULL) - CurrentEditCmdLine.ActionName.Argu += pEB->getInputStringAsUtf8(); + CurrentEditCmdLine.ActionName.Argu += pEB->getInputString(); noParam++; } } @@ -887,7 +888,7 @@ void CModalContainerEditCmd::validCurrentCommand() { CurrentEditCmdLine.Combo = it->second; // Yes ok let setup the text of the key - pVT->setText(it->second.toUCString()); + pVT->setText(it->second.toString()); // There is already a shortcut so we can display ok button CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (false); @@ -1033,7 +1034,7 @@ void CModalContainerEditCmd::onChangeCategory() { if (rBA.isUsableInCurrentContext()) { - pCB->addText( CI18N::get(rBA.LocalizedName) ); + pCB->addText(CI18N::get(rBA.LocalizedName)); } } } @@ -1048,9 +1049,9 @@ void CModalContainerEditCmd::onChangeCategory() // reset name of params CViewText *pViewParamName; pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); // Reset key invalidCurrentCommand(); } @@ -1086,9 +1087,9 @@ void CModalContainerEditCmd::onChangeAction() // reset name of params CViewText *pViewParamName; pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); - if (pViewParamName != NULL) pViewParamName->setText (string("")); + if (pViewParamName != NULL) pViewParamName->setText (string()); uint noParam = 0; for (uint i = 0; i < rVParams.size(); ++i) @@ -1130,11 +1131,10 @@ void CModalContainerEditCmd::onChangeAction() if (ActionsContext.matchContext(rVal.Contexts)) { - if ((rVal.LocalizedValue.size() >= 2) && - (rVal.LocalizedValue[0] == 'u') && (rVal.LocalizedValue[1] == 'i')) + if (NLMISC::startsWith(rVal.LocalizedValue, "ui")) pCB->addText(CI18N::get(rVal.LocalizedValue)); else - pCB->addText(ucstring(rVal.LocalizedValue)); + pCB->addText(rVal.LocalizedValue); } } } @@ -1148,7 +1148,7 @@ void CModalContainerEditCmd::onChangeAction() CGroupEditBox *pEB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin )); if( pEB ) { - pEB->setInputString(ucstring("")); + pEB->setInputString(std::string()); } NLGUI::CDBManager::getInstance()->getDbProp( sDB )->setValue32(1); } @@ -1354,7 +1354,7 @@ public: pMCM->NewKey->CurrentEditCmdLine.Combo = pGetKey->Combo; CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+VIEW_EDITCMD_TEXT_KEY)); - if (pVT != NULL) pVT->setText(pMCM->NewKey->CurrentEditCmdLine.Combo.toUCString()); + if (pVT != NULL) pVT->setText(pMCM->NewKey->CurrentEditCmdLine.Combo.toString()); CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (false); @@ -1366,7 +1366,7 @@ public: pMCM->EditCmd->CurrentEditCmdLine.Combo = pGetKey->Combo; pMCM->CurrentEditMacro.Combo = pMCM->EditCmd->CurrentEditCmdLine.Combo; CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NEWMACRO_KEY)); - if (pVT != NULL) pVT->setText(pMCM->EditCmd->CurrentEditCmdLine.Combo.toUCString()); + if (pVT != NULL) pVT->setText(pMCM->EditCmd->CurrentEditCmdLine.Combo.toString()); } } }; diff --git a/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 4ffb2bb17..03e53c06b 100644 --- a/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -636,7 +637,7 @@ public: CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(Params)); if (pCS == NULL) return; - pCS->setMacroText(pEB->getInputStringAsStdString()); + pCS->setMacroText(pEB->getInputString()); } }; REGISTER_ACTION_HANDLER( CHandlerEBUpdateMacroText, "eb_update_macro_text"); @@ -703,10 +704,10 @@ public: CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_EDITTEXT)); if (pEB != NULL) { - pEB->setInputStringAsStdString(pMCM->CurrentEditMacro.DispText); + pEB->setInputString(pMCM->CurrentEditMacro.DispText); CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_ICON)); if (pCS != NULL) - pCS->setMacroText(pEB->getInputStringAsStdString()); + pCS->setMacroText(pEB->getInputString()); } CAHManager::getInstance()->runActionHandler("set_macro_back", NULL, string("target=")+CTRL_MACROICONCREATION_ICON+"|value="+toString(back)); @@ -827,7 +828,7 @@ void addCommandLine (CGroupList *pParent, uint cmdNb, const ucstring &cmdName) if (pNewCmd == NULL) return; CViewText *pVT = dynamic_cast(pNewCmd->getView(TEMPLATE_NEWMACRO_COMMAND_TEXT)); - if (pVT != NULL) pVT->setText(cmdName); + if (pVT != NULL) pVT->setText(cmdName.toUtf8()); pNewCmd->setParent (pParent); pParent->addChild (pNewCmd); @@ -862,7 +863,7 @@ public: if (pEB == NULL) return; CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); - pMCM->CurrentEditMacro.Name = pEB->getInputStringAsStdString(); + pMCM->CurrentEditMacro.Name = pEB->getInputString(); if ((pMCM->CurrentEditMacro.Name.size() >= 2) && (pMCM->CurrentEditMacro.Name[0] == 'u') && (pMCM->CurrentEditMacro.Name[1] == 'i')) pMCM->CurrentEditMacro.Name[0] = 'U'; @@ -897,7 +898,7 @@ public: if (pMCM->CurrentEditMacro.Combo.Key == KeyCount) pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); else - pVT->setText(pMCM->CurrentEditMacro.Combo.toUCString()); + pVT->setText(pMCM->CurrentEditMacro.Combo.toString()); } pList->clearGroups(); @@ -1003,7 +1004,7 @@ void addMacroLine (CGroupList *pParent, uint macNb, const CMacroCmd ¯o) if (pVT != NULL) { if (macro.Combo.Key != KeyCount) - pVT->setText(macro.Combo.toUCString()); + pVT->setText(macro.Combo.toString()); else pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); } diff --git a/ryzom/client/src/interface_v3/music_player.cpp b/ryzom/client/src/interface_v3/music_player.cpp index 56f97b554..b45af6c7b 100644 --- a/ryzom/client/src/interface_v3/music_player.cpp +++ b/ryzom/client/src/interface_v3/music_player.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -328,7 +329,7 @@ void CMusicPlayer::rebuildPlaylist() { ucstring title; title.fromUtf8(_Songs[i].Title); - pVT->setText(title); + pVT->setText(title.toUtf8()); } pVT = dynamic_cast(pNew->getView(TEMPLATE_PLAYLIST_SONG_DURATION)); @@ -483,7 +484,7 @@ void CMusicPlayer::updatePlayingInfo(const std::string info) CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text")); if (pVT) { - pVT->setText(ucstring::makeFromUtf8(info)); + pVT->setText(info); } } @@ -492,7 +493,7 @@ void CMusicPlayer::clearPlayingInfo() { if (_Songs.empty()) { - updatePlayingInfo(CI18N::get("uiNoFiles").toUtf8()); + updatePlayingInfo(CI18N::get("uiNoFiles")); } else { @@ -622,9 +623,9 @@ void CMusicPlayer::createPlaylistFromMusic() if (extensions.empty()) { // in the very unlikely scenario - const ucstring message("Sound driver has no support for music."); + static const string message("Sound driver has no support for music."); CInterfaceManager::getInstance()->displaySystemInfo(message, "SYS"); - nlinfo("%s", message.toUtf8().c_str()); + nlinfo("%s", message.c_str()); return; } std::string newPath = CPath::makePathAbsolute(CPath::standardizePath(ClientCfg.MediaPlayerDirectory), CPath::getCurrentPath(), true); @@ -632,9 +633,9 @@ void CMusicPlayer::createPlaylistFromMusic() join(extensions, ", ", extlist); extlist += ", m3u, m3u8"; - std::string msg(CI18N::get("uiMk_system6").toUtf8()); + std::string msg(CI18N::get("uiMk_system6")); msg += ": " + newPath + " (" + extlist + ")"; - CInterfaceManager::getInstance()->displaySystemInfo(ucstring::makeFromUtf8(msg), "SYS"); + CInterfaceManager::getInstance()->displaySystemInfo(msg, "SYS"); nlinfo("%s", msg.c_str()); // Recursive scan for files from media directory diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp index 9164a78ea..5a3ec4f2b 100644 --- a/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/ryzom/client/src/interface_v3/people_interraction.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -91,7 +91,7 @@ static const sint PARTY_CHAT_SPAWN_DELTA = 20; // to avoid that all party chat a /** Display an error msg in the system info window, and also in the last window that triggered the command (so that the user is sure to see it) */ -static void displayVisibleSystemMsg(const ucstring &msg, const string &cat = "CHK"); +static void displayVisibleSystemMsg(const std::string &msg, const string &cat = "CHK"); ////////////////////////////// @@ -102,7 +102,7 @@ static void displayVisibleSystemMsg(const ucstring &msg, const string &cat = "CH struct CPartyChatEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -120,7 +120,7 @@ struct CPartyChatEntryHandler : public IChatWindowListener // handler to manage user entry in 'around me' window struct CAroundMeEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -138,7 +138,7 @@ struct CAroundMeEntryHandler : public IChatWindowListener // handler to manage user entry in 'region' window struct CRegionEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -156,7 +156,7 @@ struct CRegionEntryHandler : public IChatWindowListener // handler to manage user entry in 'universe' window struct CUniverseEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -174,7 +174,7 @@ struct CUniverseEntryHandler : public IChatWindowListener // handler to manage user entry in 'guild chat' window struct CGuildChatEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -191,7 +191,7 @@ struct CGuildChatEntryHandler : public IChatWindowListener // handler to manage user entry in 'team chat' window struct CTeamChatEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -208,7 +208,7 @@ struct CTeamChatEntryHandler : public IChatWindowListener // handler to manage user entry in a 'talk with friend' window struct CFriendTalkEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -225,10 +225,9 @@ struct CFriendTalkEntryHandler : public IChatWindowListener // handler to manage user entry in a debug console window struct CDebugConsoleEntryHandler : public IChatWindowListener { - virtual void msgEntered(const ucstring &msg, CChatWindow * /* chatWindow */) + virtual void msgEntered(const string &msg, CChatWindow * /* chatWindow */) { - std::string str = msg.toString(); - NLMISC::ICommand::execute( str, g_log ); + NLMISC::ICommand::execute( msg, g_log ); } }; @@ -242,7 +241,7 @@ public: DbIndex= 0; } - virtual void msgEntered(const ucstring &msg, CChatWindow *chatWindow) + virtual void msgEntered(const string &msg, CChatWindow *chatWindow) { if (ClientCfg.Local) { @@ -937,7 +936,7 @@ class CHandlerChatGroupFilter : public IActionHandler case CChatGroup::dyn_chat: uint32 index = PeopleInterraction.TheUserChat.Filter.getTargetDynamicChannelDbIndex(); uint32 textId = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:DYN_CHAT:CHANNEL"+toString(index)+":NAME")->getValue32(); - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); if (title.empty()) { @@ -947,7 +946,7 @@ class CHandlerChatGroupFilter : public IActionHandler } else { - pUserBut->setHardText(title.toUtf8()); + pUserBut->setHardText(title); } break; } @@ -1281,7 +1280,7 @@ void CPeopleInterraction::addContactInList(uint32 contactId, const ucstring &nam CPeopleList &pl= nList==0?FriendList:IgnoreList; // remove the shard name if possible - ucstring name= CEntityCL::removeShardFromName(nameIn); + ucstring name= CEntityCL::removeShardFromName(nameIn.toUtf8()); @@ -1305,7 +1304,7 @@ void CPeopleInterraction::addContactInList(uint32 contactId, const ucstring &nam //================================================================================================================= void CPeopleInterraction::addContactInList(uint32 contactId, uint32 nameID, TCharConnectionState online, uint8 nList) { - ucstring name; + string name; STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); if (pSMC->getString(nameID, name)) { @@ -1334,7 +1333,7 @@ bool CPeopleInterraction::isContactInList(const ucstring &nameIn, uint8 nList) c // select correct people list const CPeopleList &pl= nList==0?FriendList:IgnoreList; // remove the shard name if possible - ucstring name= CEntityCL::removeShardFromName(nameIn); + ucstring name= CEntityCL::removeShardFromName(nameIn.toUtf8()); return pl.getIndexFromName(name) != -1; } @@ -1365,7 +1364,7 @@ void CPeopleInterraction::updateWaitingContacts() for (uint32 i = 0; i < WaitingContacts.size();) { SWaitingContact &w = WaitingContacts[i]; - ucstring name; + string name; STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); if (pSMC->getString(w.NameId, name)) { @@ -1401,7 +1400,7 @@ void CPeopleInterraction::updateContactInList(uint32 contactId, TCharConnectionS // Only show the message if this player is not in my guild (because then the guild manager will show a message) std::vector GuildMembers = CGuildManager::getInstance()->getGuildMembers(); bool bOnlyFriend = true; - ucstring name = toLower(FriendList.getName(index)); + string name = toLower(FriendList.getName(index).toUtf8()); for (uint i = 0; i < GuildMembers.size(); ++i) { if (toLower(GuildMembers[i].Name) == name) @@ -1417,8 +1416,8 @@ void CPeopleInterraction::updateContactInList(uint32 contactId, TCharConnectionS // Player is not in my guild, and the status change is from offline to online/abroad online or vice versa. if (showMsg) { - ucstring msg = (online != ccs_offline) ? CI18N::get("uiPlayerOnline") : CI18N::get("uiPlayerOffline"); - strFindReplace(msg, "%s", FriendList.getName(index)); + string msg = (online != ccs_offline) ? CI18N::get("uiPlayerOnline") : CI18N::get("uiPlayerOffline"); + strFindReplace(msg, "%s", FriendList.getName(index).toUtf8()); string cat = getStringCategory(msg, msg); map::const_iterator it; NLMISC::CRGBA col = CRGBA::Yellow; @@ -1890,7 +1889,7 @@ void CPeopleInterraction::refreshActiveUserChats() } //================================================================================================================= -void CPeopleInterraction::talkInDynamicChannel(uint32 channelNb,ucstring sentence) +void CPeopleInterraction::talkInDynamicChannel(uint32 channelNb,string sentence) { if(channelNbgetName(peopleIndex)); + CPeopleInterraction::displayTellInMainChat(list->getName(peopleIndex).toUtf8()); } } }; @@ -2167,7 +2166,7 @@ class CHandlerTellContact : public IActionHandler uint peopleIndex; if (PeopleInterraction.getPeopleFromContainerID(gc->getId(), list, peopleIndex)) { - CPeopleInterraction::displayTellInMainChat(list->getName(peopleIndex)); + CPeopleInterraction::displayTellInMainChat(list->getName(peopleIndex).toUtf8()); } } @@ -2206,7 +2205,7 @@ public: if (gc) { CGroupEditBox *geb = dynamic_cast(gc->getGroup("add_contact_eb:eb")); - geb->setInputString(ucstring("")); + geb->setInputString(std::string()); } CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams); } @@ -2263,12 +2262,12 @@ public: } else { - PeopleInterraction.askAddContact(geb->getInputString(), peopleList); - geb->setInputString(ucstring("")); + PeopleInterraction.askAddContact(geb->getInputStringAsUtf16(), peopleList); + geb->setInputString(std::string()); } } } - geb->setInputString(ucstring("")); + geb->setInputString(std::string()); } } } @@ -2446,7 +2445,7 @@ public: if (eb) { CWidgetManager::getInstance()->setCaptureKeyboard(eb); - eb->setInputString(ucstring("")); + eb->setInputString(std::string()); } // if (gc->getActive()) @@ -2473,7 +2472,7 @@ class CHandlerValidatePartyChatName : public IActionHandler if (!gc) return; CGroupEditBox *eb = dynamic_cast(gc->getGroup("eb")); if (!eb) return; - ucstring title = eb->getInputString(); + string title = eb->getInputString(); // TODO GAMEDEV : create (or join ?) a new channel. Each channel (party chat) should have a unique name in the game // moreover, it should not have the name of another available chat window (for example, it shouldn't be named 'Around Me') @@ -2482,7 +2481,7 @@ class CHandlerValidatePartyChatName : public IActionHandler if (!PeopleInterraction.testValidPartyChatName(title)) { - displayVisibleSystemMsg(title + ucstring(" : ") + CI18N::get("uiInvalidPartyChatName")); + displayVisibleSystemMsg(title + " : " + CI18N::get("uiInvalidPartyChatName")); return; } @@ -2650,7 +2649,7 @@ public: { for(uint l = 0; l < pl.PartyChats.size(); ++l) { - menu->addLineAtIndex(insertionIndex, pl.PartyChats[l].Window->getTitle(), "chat_target_selected", toString(pl.PartyChats[l].ID)); + menu->addLineAtIndex(insertionIndex, pl.PartyChats[l].Window->getTitle().toUtf8(), "chat_target_selected", toString(pl.PartyChats[l].ID)); ++ insertionIndex; } } @@ -2693,11 +2692,11 @@ public: uint32 canWrite = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:DYN_CHAT:CHANNEL"+s+":WRITE_RIGHT")->getValue32(); if (canWrite != 0) { - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); // replace dynamic channel name and shortcut - ucstring res = CI18N::get("uiFilterMenuDynamic"); + string res = CI18N::get("uiFilterMenuDynamic"); strFindReplace(res, "%channel", title); strFindReplace(res, "%shortcut", s); @@ -2886,7 +2885,7 @@ class CHandlerSelectChatSource : public IActionHandler pVTM->setActive(active); if (active) { - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); pVTM->setText("["+s+"] " + title); } @@ -2997,7 +2996,7 @@ class CHandlerSelectChatSource : public IActionHandler { if (pc[l].Filter != NULL) { - menu->addLineAtIndex(insertionIndex, pc[l].Window->getTitle(), FILTER_TOGGLE, toString(pc[l].ID)); + menu->addLineAtIndex(insertionIndex, pc[l].Window->getTitle().toUtf8(), FILTER_TOGGLE, toString(pc[l].ID)); menu->setUserGroupLeft(insertionIndex, createMenuCheckBox(FILTER_TOGGLE, toString(pc[l].ID), pc[l].Filter->isListeningWindow(cw))); ++ insertionIndex; } @@ -3011,7 +3010,7 @@ class CHandlerSelectChatSource : public IActionHandler bool active = (textId != 0); if (active) { - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); menu->addLineAtIndex(insertionIndex, "["+s+"] " + title, FILTER_TOGGLE, "dyn"+s); menu->setUserGroupLeft(insertionIndex, createMenuCheckBox(FILTER_TOGGLE, "dyn"+s, pi.ChatInput.DynamicChat[i].isListeningWindow(cw))); @@ -3372,7 +3371,7 @@ REGISTER_INTERFACE_USER_FCT("getNumUserChatLeft", getNumUserChatLeft) // STATIC FUNCTIONS IMPLEMENTATIONS // ////////////////////////////////////// -static void displayVisibleSystemMsg(const ucstring &msg, const string &cat) +static void displayVisibleSystemMsg(const string &msg, const string &cat) { CInterfaceManager *im = CInterfaceManager::getInstance(); im->displaySystemInfo(msg, cat); @@ -3385,7 +3384,7 @@ static void displayVisibleSystemMsg(const ucstring &msg, const string &cat) #if !FINAL_VERSION NLMISC_COMMAND(testSI, "tmp", "tmp") { - PeopleInterraction.ChatInput.DebugInfo.displayMessage(ucstring("test"), CRGBA::Red); + PeopleInterraction.ChatInput.DebugInfo.displayMessage("test", CRGBA::Red); return true; } #endif diff --git a/ryzom/client/src/interface_v3/people_interraction.h b/ryzom/client/src/interface_v3/people_interraction.h index 591a005e2..a88db2a65 100644 --- a/ryzom/client/src/interface_v3/people_interraction.h +++ b/ryzom/client/src/interface_v3/people_interraction.h @@ -250,14 +250,14 @@ public: // Test if the given chat is a user chat (this includes the main chat) bool isUserChat(CChatWindow *cw) const; - void talkInDynamicChannel(uint32 channelNb,ucstring sentence); + void talkInDynamicChannel(uint32 channelNb,std::string sentence); CChatGroupWindow *getChatGroupWindow() const; void updateAllFreeTellerHeaders(); void removeAllFreeTellers(); - static void displayTellInMainChat(const ucstring &playerName); + static void displayTellInMainChat(const std::string &playerName); private: // create various chat & people lists void createTeamChat(); diff --git a/ryzom/client/src/interface_v3/people_list.cpp b/ryzom/client/src/interface_v3/people_list.cpp index c3f2cf4d7..e8790df0c 100644 --- a/ryzom/client/src/interface_v3/people_list.cpp +++ b/ryzom/client/src/interface_v3/people_list.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -645,7 +646,7 @@ void CPeopleList::saveContactGroups() } //================================================================== -void CPeopleList::displayLocalPlayerTell(const ucstring &receiver, uint index, const ucstring &msg,uint numBlinks /*=0*/) +void CPeopleList::displayLocalPlayerTell(const string &receiver, uint index, const string &msg,uint numBlinks /*=0*/) { if (_ContactType == CPeopleListDesc::Ignore) { @@ -668,13 +669,13 @@ void CPeopleList::displayLocalPlayerTell(const ucstring &receiver, uint index, c return; } - ucstring csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); - ucstring finalMsg = csr + CI18N::get("youTell") + ": " + msg; + string csr = CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""; + string finalMsg = csr + CI18N::get("youTell") + ": " + msg; // display msg with good color CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); - ucstring s = CI18N::get("youTellPlayer"); + string s = CI18N::get("youTellPlayer"); strFindReplace(s, "%name", receiver); strFindReplace(finalMsg, CI18N::get("youTell"), s); CViewBase *child = getChatTextMngr().createMsgText(finalMsg, prop.getRGBA()); @@ -697,7 +698,7 @@ void CPeopleList::displayLocalPlayerTell(const ucstring &receiver, uint index, c //================================================================== -void CPeopleList::displayMessage(uint index, const ucstring &msg, NLMISC::CRGBA col, uint /* numBlinks */ /*= 0*/) +void CPeopleList::displayMessage(uint index, const string &msg, NLMISC::CRGBA col, uint /* numBlinks */ /*= 0*/) { if (_ContactType == CPeopleListDesc::Ignore) { @@ -1078,7 +1079,7 @@ class CHandlerContactEntry : public IActionHandler { CGroupEditBox *pEB = dynamic_cast(pCaller); if (pEB == NULL) return; - ucstring text = pEB->getInputString(); + string text = pEB->getInputString(); // If the line is empty, do nothing if(text.empty()) return; @@ -1086,7 +1087,7 @@ class CHandlerContactEntry : public IActionHandler // Parse any tokens in the text if ( ! CInterfaceManager::parseTokens(text)) { - pEB->setInputString (string("")); + pEB->setInputString (std::string()); return; } @@ -1094,10 +1095,9 @@ class CHandlerContactEntry : public IActionHandler if(text[0] == '/') { CChatWindow::_ChatWindowLaunchingCommand = NULL; // no CChatWindow instance there .. - // TODO : have NLMISC::ICommand accept unicode strings - std::string str = text.toUtf8().substr(1); + std::string str = text.substr(1); NLMISC::ICommand::execute( str, g_log ); - pEB->setInputString (string("")); + pEB->setInputString (std::string()); return; } // Well, we could have used CChatWindow class to handle this, but CPeopleList was written earlier, so for now @@ -1106,11 +1106,11 @@ class CHandlerContactEntry : public IActionHandler CGroupContainer *gc = static_cast< CGroupContainer* >( pCaller->getParent()->getEnclosingContainer() ); // title gives the name of the player - ucstring playerName = gc->getUCTitle(); + string playerName = gc->getUCTitle().toUtf8(); // Simply do a tell on the player - ChatMngr.tell(playerName.toString(), text); - pEB->setInputString (string("")); + ChatMngr.tell(playerName, text); + pEB->setInputString (std::string()); if (gc) { // Restore position of enclosing container if it hasn't been moved/scaled/poped by the user @@ -1142,17 +1142,17 @@ class CHandlerContactEntry : public IActionHandler CChatGroupWindow *pWin = PeopleInterraction.getChatGroupWindow(); CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); - ucstring final; + string final; CChatWindow::encodeColorTag(prop.getRGBA(), final, false); - ucstring csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); + string csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : ""); final += csr + CI18N::get("youTell")+": "; prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); CChatWindow::encodeColorTag(prop.getRGBA(), final, true); final += text; pWin->displayTellMessage(final, prop.getRGBA(), pWin->getFreeTellerName(str)); - ucstring s = CI18N::get("youTellPlayer"); + string s = CI18N::get("youTellPlayer"); strFindReplace(s, "%name", pWin->getFreeTellerName(str)); strFindReplace(final, CI18N::get("youTell"), s); CInterfaceManager::getInstance()->log(final, CChatGroup::groupTypeToString(CChatGroup::tell)); diff --git a/ryzom/client/src/interface_v3/people_list.h b/ryzom/client/src/interface_v3/people_list.h index 682b1a6e5..aeef30f3f 100644 --- a/ryzom/client/src/interface_v3/people_list.h +++ b/ryzom/client/src/interface_v3/people_list.h @@ -118,8 +118,8 @@ public: /** Display a message for the given people * If the window is closed, it causes it to blink (and also the parent window) */ - void displayMessage(uint index, const ucstring &msg, NLMISC::CRGBA col, uint numBlinks = 0); - void displayLocalPlayerTell(const ucstring &receiver, uint index, const ucstring &msg, uint numBlinks = 0); + void displayMessage(uint index, const std::string &msg, NLMISC::CRGBA col, uint numBlinks = 0); + void displayLocalPlayerTell(const std::string &receiver, uint index, const std::string &msg, uint numBlinks = 0); // Is the given people window visible ? bool isPeopleChatVisible(uint index) const; // reset remove everything from the interface diff --git a/ryzom/client/src/interface_v3/sbrick_manager.cpp b/ryzom/client/src/interface_v3/sbrick_manager.cpp index d12ed783c..a2cecf2d4 100644 --- a/ryzom/client/src/interface_v3/sbrick_manager.cpp +++ b/ryzom/client/src/interface_v3/sbrick_manager.cpp @@ -436,7 +436,7 @@ void CSBrickManager::compileBrickProperties() // **** for all bricks, recompute localized text with formated version - ucstring textTemp; + string textTemp; textTemp.reserve(1000); for (std::vector::size_type ib = 0; ib < _BrickVector.size(); ++ib) { @@ -445,7 +445,7 @@ void CSBrickManager::compileBrickProperties() continue; // Get the Brick texts - ucstring texts[3]; + std::string texts[3]; texts[0]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brickSheet->Id); texts[1]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedDescription(brickSheet->Id); texts[2]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheet->Id); @@ -453,7 +453,7 @@ void CSBrickManager::compileBrickProperties() // For alls texts, parse format for(uint i=0;i<3;i++) { - ucstring &text= texts[i]; + string &text= texts[i]; textTemp.erase(); // Parse the text diff --git a/ryzom/client/src/interface_v3/skill_manager.cpp b/ryzom/client/src/interface_v3/skill_manager.cpp index c2f242921..cf35e6bd6 100644 --- a/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/ryzom/client/src/interface_v3/skill_manager.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -588,7 +589,7 @@ void CSkillManager::checkTitleUnblocked(CHARACTER_TITLE::ECharacterTitle i, bool string titleStr = CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)i); bool womenTitle = (UserEntity && UserEntity->getGender() == GSGENDER::female); const ucstring newtitle(CStringManagerClient::getTitleLocalizedName(titleStr, womenTitle)); - CAHManager::getInstance()->runActionHandler("message_popup", NULL, "text1="+newtitle.toUtf8()+"|text0="+CI18N::get("uiNewTitleBold").toUtf8()); + CAHManager::getInstance()->runActionHandler("message_popup", NULL, "text1="+newtitle.toUtf8()+"|text0="+CI18N::get("uiNewTitleBold")); } else { @@ -1097,7 +1098,7 @@ public: string titleStr = CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)i); bool womenTitle = (UserEntity && UserEntity->getGender() == GSGENDER::female); const ucstring s(CStringManagerClient::getTitleLocalizedName(titleStr,womenTitle)); - pCB->addText(s); + pCB->addText(s.toUtf8()); pSM->_UIUnblockedTitles.push_back((CHARACTER_TITLE::ECharacterTitle)i); } } diff --git a/ryzom/client/src/interface_v3/sphrase_manager.cpp b/ryzom/client/src/interface_v3/sphrase_manager.cpp index f9dd511d5..f86fee39f 100644 --- a/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -3576,13 +3576,12 @@ void CSPhraseManager::updatePhraseProgressionDB() break; } } - } - - // if show, but only if full learnt, skip it if not fully learnt - if(phrase->ShowInAPOnlyIfLearnt && !known) - { - continue; + // if show, but only if full learnt, skip it if not fully learnt + if (phrase->ShowInAPOnlyIfLearnt && !known) + { + continue; + } } diff --git a/ryzom/client/src/interface_v3/task_bar_manager.cpp b/ryzom/client/src/interface_v3/task_bar_manager.cpp index 70d2d9fe7..713a9d07b 100644 --- a/ryzom/client/src/interface_v3/task_bar_manager.cpp +++ b/ryzom/client/src/interface_v3/task_bar_manager.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -180,7 +181,7 @@ public: if (pVT != NULL) { if (it != acmap.end()) - pVT->setText(it->second.toUCString()); + pVT->setText(it->second.toString()); else pVT->setText(CI18N::get("uiNotAssigned")); } diff --git a/ryzom/client/src/item_group_manager.cpp b/ryzom/client/src/item_group_manager.cpp index 82a60f478..2600966e8 100644 --- a/ryzom/client/src/item_group_manager.cpp +++ b/ryzom/client/src/item_group_manager.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -301,10 +304,18 @@ bool CItemGroupManager::loadGroups() NLMISC::CIFile f; f.open(userGroupFileName); NLMISC::CIXml xmlStream; - xmlStream.init(f); - // Actual loading xmlNodePtr globalEnclosing; - globalEnclosing = xmlStream.getRootNode(); + try + { + xmlStream.init(f); + // Actual loading + globalEnclosing = xmlStream.getRootNode(); + } + catch (const NLMISC::EXmlParsingError &ex) + { + nlwarning("Failed to parse '%s', skip", userGroupFileName.c_str()); + return false; + } if(!globalEnclosing) { nlwarning("no root element in item_group xml, skipping xml parsing"); @@ -686,10 +697,9 @@ void CItemGroupManager::listGroup() for(int i=0;i<_Groups.size();i++) { CItemGroup group = _Groups[i]; - ucstring msg = NLMISC::CI18N::get("cmdListGroupLine"); + string msg = NLMISC::CI18N::get("cmdListGroupLine"); //Use ucstring because group name can contain accentued characters (and stuff like that) - ucstring nameUC; - nameUC.fromUtf8(group.name); + string nameUC = group.name; NLMISC::strFindReplace(msg, "%name", nameUC); NLMISC::strFindReplace(msg, "%size", NLMISC::toString(group.Items.size())); pIM->displaySystemInfo(msg); diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp index 9eb9688ae..2e4f523a5 100644 --- a/ryzom/client/src/login.cpp +++ b/ryzom/client/src/login.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -247,7 +247,7 @@ void createOptionalCatUI() pVT = dynamic_cast(pNewLine->getView("size")); if (pVT != NULL) { - pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size)); + pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size).toUtf8()); } // Add to the list @@ -291,7 +291,7 @@ static void setDataScanLog(const ucstring &text) CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:log_txt:log")); if (pVT != NULL) { - pVT->setText(text); + pVT->setText(text.toUtf8()); } } @@ -300,10 +300,10 @@ static void setDataScanState(const ucstring &text, ucstring progress= ucstring() { CInterfaceManager *pIM= CInterfaceManager::getInstance(); CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:state")); - if (pVT != NULL) pVT->setText(text); + if (pVT != NULL) pVT->setText(text.toUtf8()); pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:progress")); - if (pVT != NULL) pVT->setText(progress); + if (pVT != NULL) pVT->setText(progress.toUtf8()); } void initCatDisplay() @@ -342,7 +342,7 @@ static void setPatcherStateText(const std::string &baseUIPath, const ucstring &s CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:state")); if (pVT != NULL) { - pVT->setText(str); + pVT->setText(str.toUtf8()); } } @@ -353,7 +353,7 @@ static void setPatcherProgressText(const std::string &baseUIPath, const ucstring CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:progress")); if (pVT != NULL) { - pVT->setText(str); + pVT->setText(str.toUtf8()); } } @@ -721,7 +721,7 @@ void loginMainLoop() ucstring sTmp; sTmp = BGDownloader::getWrittenSize(currentPatchingSize); sTmp += " / " + BGDownloader::getWrittenSize(totalPatchSize); - if (pVT != NULL) pVT->setText(sTmp); + if (pVT != NULL) pVT->setText(sTmp.toUtf8()); } // else if (screen == UI_VARIABLES_SCREEN_CATDISP) // If we are displaying patch info else if (LoginSM.getCurrentState() == CLoginStateMachine::st_display_cat) @@ -770,10 +770,10 @@ void loginMainLoop() // Total size of the patches is optional cats + required cat (f(optCat)) + non opt cat CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TOTAL_SIZE)); - if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(TotalPatchSize)); + if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(TotalPatchSize).toUtf8()); pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NON_OPTIONAL_SIZE)); - if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(nNonOptSize)); + if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(nNonOptSize).toUtf8()); } } } @@ -1215,9 +1215,10 @@ void initShardDisplay() { CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_SHARD ":s0:but")); if (pCB != NULL) + { pCB->setPushed(true); - CAHManager::getInstance()->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); - + CAHManager::getInstance()->runActionHandler(pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); + } } pList->invalidateCoords(); } @@ -1382,8 +1383,8 @@ class CAHOnLogin : public IActionHandler return; } - LoginLogin = pGEBLog->getInputStringAsStdString(); - LoginPassword = pGEBPwd->getInputStringAsStdString(); + LoginLogin = pGEBLog->getInputString(); + LoginPassword = pGEBPwd->getInputString(); onlogin(); } @@ -2397,7 +2398,7 @@ bool initCreateAccount() { CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId(editBoxes[i] + ":eb")); if(eb) - eb->setInputString(ucstring("")); + eb->setInputString(std::string()); } // conditions button @@ -2584,7 +2585,7 @@ class CAHOnCreateAccountSubmit : public IActionHandler { CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId(editBoxes[i] + ":eb")); if(eb) - results[i] = eb->getInputString().toUtf8(); + results[i] = eb->getInputString(); } // text @@ -2738,11 +2739,11 @@ class CAHCreateAccountLogin : public IActionHandler { CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId("eb_login:eb")); if(eb) - LoginLogin = eb->getInputString().toUtf8(); + LoginLogin = eb->getInputString(); eb = dynamic_cast(createAccountUI->findFromShortId("eb_password:eb")); if(eb) - LoginPassword = eb->getInputString().toUtf8(); + LoginPassword = eb->getInputString(); onlogin(false); } diff --git a/ryzom/client/src/login_patch.cpp b/ryzom/client/src/login_patch.cpp index 0a6b912dd..0be99a606 100644 --- a/ryzom/client/src/login_patch.cpp +++ b/ryzom/client/src/login_patch.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2014 Matthew LAGOE (Botanic) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -1931,9 +1931,9 @@ int CPatchManager::validateProgress(void *foo, double t, double d, double /* ult if (units.empty()) { - units.push_back(CI18N::get("uiByte").toUtf8()); - units.push_back(CI18N::get("uiKb").toUtf8()); - units.push_back(CI18N::get("uiMb").toUtf8()); + units.push_back(CI18N::get("uiByte")); + units.push_back(CI18N::get("uiKb")); + units.push_back(CI18N::get("uiMb")); } CPatchManager *pPM = CPatchManager::getInstance(); diff --git a/ryzom/client/src/main_loop.cpp b/ryzom/client/src/main_loop.cpp index a62b72e73..404c77432 100644 --- a/ryzom/client/src/main_loop.cpp +++ b/ryzom/client/src/main_loop.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2016 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -1124,7 +1124,7 @@ bool mainLoop() // #define BAR_STEP_TP 2 ProgressBar.reset (BAR_STEP_TP); - ucstring nmsg("Loading..."); + string nmsg("Loading..."); ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); ProgressBar.progress(0); ContinentMngr.select(UserEntity->pos(), ProgressBar); @@ -1165,7 +1165,7 @@ bool mainLoop() if (BanMsgCountdown < 0.f) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgPermanentlyBanned"); + string msg = CI18N::get("msgPermanentlyBanned"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); BanMsgCountdown = BanMsgRepeatTime; @@ -2532,9 +2532,6 @@ bool mainLoop() Actions.enable(true); EditActions.enable(true); - // For stoping the outgame music, start after 30 frames, and duration of 3 seconds - outgameFader = CMusicFader(60, 3); - // check for banned player if (testPermanentBanMarkers()) { @@ -2544,6 +2541,9 @@ bool mainLoop() } } + // For stoping the outgame music, start after 30 frames, and duration of 3 seconds + outgameFader = CMusicFader(60, 3); + // Short reinit of the main loop after farTP or character reselection Ping.init(); updateLightDesc(); @@ -3463,11 +3463,11 @@ NLMISC_COMMAND(dumpFontTexture, "Write font texture to file", "") { std::string fname = CFile::findNewFile("font-texture.tga"); TextContext->dumpCacheTexture(fname.c_str()); - im->displaySystemInfo(ucstring(fname + " created"), "SYS"); + im->displaySystemInfo(fname + " created", "SYS"); } else { - im->displaySystemInfo(ucstring("Error: TextContext == NULL"), "SYS"); + im->displaySystemInfo("Error: TextContext == NULL", "SYS"); } return true; } diff --git a/ryzom/client/src/main_loop_debug.cpp b/ryzom/client/src/main_loop_debug.cpp index ac29a3984..b4edaf5e9 100644 --- a/ryzom/client/src/main_loop_debug.cpp +++ b/ryzom/client/src/main_loop_debug.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010-2017 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013-2016 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -714,9 +714,9 @@ static std::string getActionKey(const char* name, const char* param = "") CActionsManager::TActionComboMap::const_iterator ite = acmap.find(CAction::CName(name, param)); if (ite != acmap.end()) - return ite->second.toUCString().toString(); + return ite->second.toString(); - return CI18N::get("uiNotAssigned").toString(); + return CI18N::get("uiNotAssigned"); } //--------------------------------------------------- diff --git a/ryzom/client/src/misc.cpp b/ryzom/client/src/misc.cpp index ee247e921..9816202d4 100644 --- a/ryzom/client/src/misc.cpp +++ b/ryzom/client/src/misc.cpp @@ -871,14 +871,14 @@ bool setVect(CVector &vectToChange, const CVector &vect, bool compute, bool chec return true; }// setVect // -NLMISC::CRGBA interpClientCfgColor(const ucstring &src, ucstring &dest) +NLMISC::CRGBA interpClientCfgColor(const string &src, string &dest) { CRGBA color = CRGBA::White; if (src.size() >= 3) { - if (src[0] == (ucchar) '&') + if (src[0] == '&') { - ucstring::size_type nextPos = src.find((ucchar) '&', 1); + string::size_type nextPos = src.find('&', 1); if (nextPos != ucstring::npos) { std::string colorCode; @@ -911,7 +911,7 @@ NLMISC::CRGBA interpClientCfgColor(const ucstring &src, ucstring &dest) return color; } -std::string getStringCategory(const ucstring &src, ucstring &dest, bool alwaysAddSysByDefault) +std::string getStringCategory(const string &src, string &dest, bool alwaysAddSysByDefault) { std::string str = getStringCategoryIfAny(src, dest); if (alwaysAddSysByDefault) @@ -921,41 +921,41 @@ std::string getStringCategory(const ucstring &src, ucstring &dest, bool alwaysAd } -std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest) +std::string getStringCategoryIfAny(const string &src, string &dest) { std::string colorCode; if (src.size() >= 3) { - uint startPos = 0; + size_t startPos = 0; // Skip or if present at beginning - ucstring preTag; - const uint PreTagSize = 5; - const ucstring newTag(""); + string preTag; + const size_t PreTagSize = 5; + static const string newTag = ""; if ( (src.size() >= PreTagSize) && (src.substr( 0, PreTagSize ) == newTag) ) { startPos = PreTagSize; preTag = newTag; } - const ucstring chgTag(""); + static const string chgTag = ""; if ( (src.size() >= PreTagSize) && (src.substr( 0, PreTagSize ) == chgTag) ) { startPos = PreTagSize; preTag = chgTag; } - if (src[startPos] == (ucchar) '&') + if (src[startPos] == '&') { - ucstring::size_type nextPos = src.find((ucchar) '&', startPos+1); - if (nextPos != ucstring::npos) + string::size_type nextPos = src.find('&', startPos+1); + if (nextPos != string::npos) { - uint codeSize = (uint)nextPos - startPos - 1; + size_t codeSize = nextPos - startPos - 1; colorCode.resize( codeSize ); - for(uint k = 0; k < codeSize; ++k) + for(ptrdiff_t k = 0; k < (ptrdiff_t)codeSize; ++k) { colorCode[k] = tolower((char) src[k + startPos + 1]); } - ucstring destTmp; + string destTmp; if ( startPos != 0 ) destTmp = preTag; // leave or in the dest string destTmp += src.substr(nextPos + 1); diff --git a/ryzom/client/src/misc.h b/ryzom/client/src/misc.h index 49127d100..96568c22e 100644 --- a/ryzom/client/src/misc.h +++ b/ryzom/client/src/misc.h @@ -165,11 +165,11 @@ bool setVect(NLMISC::CVector &vectToChange, const NLMISC::CVector &vect, bool co // read color from client cfg system info colors -NLMISC::CRGBA interpClientCfgColor(const ucstring &src, ucstring &dest); +NLMISC::CRGBA interpClientCfgColor(const std::string &src, std::string &dest); // Get the category from the string (src="&SYS&Who are you?" and dest="Who are you?" and return "SYS"), if no category, return "SYS" -std::string getStringCategory(const ucstring &src, ucstring &dest, bool alwaysAddSysByDefault = true); +std::string getStringCategory(const std::string &src, std::string &dest, bool alwaysAddSysByDefault = true); // Get the category from the string (src="&SYS&Who are you?" and dest="Who are you?" and return "SYS"), if no category, return "" -std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest); +std::string getStringCategoryIfAny(const std::string &src, std::string &dest); bool getRelativeFloatFromString(const std::string src, float &dst); void updateVector(const std::string part, NLMISC::CVector &dst, float value, bool add = false); diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index c6da153bc..605739788 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2019 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -601,24 +601,24 @@ void impulsePermanentUnban(NLMISC::CBitMemStream &impulse) class CInterfaceChatDisplayer : public CClientChatManager::IChatDisplayer { public: - virtual void displayChat(TDataSetIndex compressedSenderIndex, const ucstring &ucstr, const ucstring &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, ucstring &senderName, uint bubbleTimer=0); - virtual void displayTell(/*TDataSetIndex senderIndex, */const ucstring &ucstr, const ucstring &senderName); + virtual void displayChat(TDataSetIndex compressedSenderIndex, const std::string &ucstr, const std::string &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, std::string &senderName, uint bubbleTimer=0); + virtual void displayTell(/*TDataSetIndex senderIndex, */const std::string &ucstr, const std::string &senderName); virtual void clearChannel(CChatGroup::TGroupType mode, uint32 dynChatDbIndex); private: // Add colorization tag for sender name - void colorizeSender(ucstring &text, const ucstring &senderName, CRGBA baseColor); + void colorizeSender(string &text, const string &senderName, CRGBA baseColor); }; static CInterfaceChatDisplayer InterfaceChatDisplayer; -void CInterfaceChatDisplayer::colorizeSender(ucstring &text, const ucstring &senderName, CRGBA baseColor) +void CInterfaceChatDisplayer::colorizeSender(string &text, const string &senderName, CRGBA baseColor) { // find the sender/text separator to put color tags ucstring::size_type pos = senderName.length() - 1; if (pos != ucstring::npos) { - ucstring str; + string str; CInterfaceProperty prop; prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," "); @@ -631,30 +631,30 @@ void CInterfaceChatDisplayer::colorizeSender(ucstring &text, const ucstring &sen str += text.substr(pos+1); - text.swap(str); + text = str; } } // display a chat from network to interface -void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, const ucstring &ucstr, const ucstring &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, ucstring &senderName, uint bubbleTimer) +void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, const std::string &ucstr, const std::string &rawMessage, CChatGroup::TGroupType mode, NLMISC::CEntityId dynChatId, std::string &senderName, uint bubbleTimer) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - ucstring finalString; + string finalString; string stringCategory = getStringCategory(ucstr, finalString); bool bubbleWanted = true; // Subtract rawMessage from ucstr so that the 'sender' part remains. - ucstring senderPart = ucstr.luabind_substr(0, ucstr.length() - rawMessage.length()); + string senderPart = ucstr.substr(0, ucstr.length() - rawMessage.length()); // search a "{no_bubble}" tag { - ucstring::size_type index = finalString.find(ucstring("{no_bubble}")); + string::size_type index = finalString.find("{no_bubble}"); const size_t tokenSize= 11; // length of "{no_bubble}" - if (index != ucstring::npos) + if (index != string::npos) { bubbleWanted = false; - finalString = finalString.luabind_substr(0, index) + finalString.substr(index+tokenSize,finalString.size()); + finalString = finalString.substr(0, index) + finalString.substr(index+tokenSize,finalString.size()); } } @@ -666,9 +666,9 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c // Remove all {break} for(;;) { - ucstring::size_type index = finalString.find(ucstring("{break}")); + string::size_type index = finalString.find("{break}"); if (index == ucstring::npos) break; - finalString = finalString.luabind_substr(0, index) + finalString.luabind_substr(index+7,finalString.size()); + finalString = finalString.substr(0, index) + finalString.substr(index+7,finalString.size()); } // select DB @@ -717,10 +717,10 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c // find the sender/text separator to put color tags if (senderPart.empty() && stringCategory == "emt") { - size_t pos = finalString.find(ucstring(": "), 0); - if (pos != ucstring::npos) + size_t pos = finalString.find(": ", 0); + if (pos != string::npos) { - senderPart = finalString.luabind_substr(0, pos + 2); + senderPart = finalString.substr(0, pos + 2); } } colorizeSender(finalString, senderPart, col); @@ -791,16 +791,16 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if (pIM->getLogState()) { // Add dyn chan number before string - ucstring prefix("[" + NLMISC::toString(dbIndex) + "]"); + string prefix = "[" + NLMISC::toString(dbIndex) + "]"; // Find position to put the new string // After timestamp? - size_t pos = finalString.find(ucstring("]")); - size_t colonpos = finalString.find(ucstring(": @{")); + size_t pos = finalString.find("]"); + size_t colonpos = finalString.find(": @{"); // If no ] found or if found but after the colon (so part of the user chat) - if (pos == ucstring::npos || (colonpos < pos)) + if (pos == string::npos || (colonpos < pos)) { // No timestamp, so put it right after the color and add a space - pos = finalString.find(ucstring("}"));; + pos = finalString.find("}");; prefix += " "; } finalString = finalString.substr(0, pos + 1) + prefix + finalString.substr(pos + 1); @@ -808,28 +808,28 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if (node && node->getValueBool()) { uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dbIndex); - ucstring title; + string title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); - prefix = title.empty() ? ucstring("") : ucstring(" ") + title; - pos = finalString.find(ucstring("] ")); + prefix = (title.empty() ? "" : " ") + title; + pos = finalString.find("] "); finalString = finalString.substr(0, pos) + prefix + finalString.substr(pos); } } } else { - nlwarning("Dynamic chat %s not found for message: %s", dynChatId.toString().c_str(), finalString.toString().c_str()); + nlwarning("Dynamic chat %s not found for message: %s", dynChatId.toString().c_str(), finalString.c_str()); } } else { - ucstring::size_type index = finalString.find(ucstring("")); + string::size_type index = finalString.find(""); if (index != ucstring::npos) { bubbleWanted = false; finalString = finalString.substr(index+6,finalString.size()); - ucstring::size_type index2 = finalString.find(ucstring(" ")); - ucstring playerName; + string::size_type index2 = finalString.find(string(" ")); + string playerName; if (index2 < (finalString.size()-3)) { playerName = finalString.substr(0,index2); @@ -845,7 +845,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if (playerName.empty()) { senderEntity->removeStateFx(); - senderEntity->setStateFx(finalString.toString()); + senderEntity->setStateFx(finalString); nlinfo("empty"); } else @@ -854,7 +854,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c if (destEntity) { destEntity->removeStateFx(); - destEntity->setStateFx(finalString.toString()); + destEntity->setStateFx(finalString); nlinfo("no empty"); } } @@ -881,7 +881,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c // **** Process chat entry for the bubbles // todo hulud : registering a chat callback would be better than calling this hardcoded action handler - ucstring finalRawMessage; + string finalRawMessage; // remove color qualifier from raw string getStringCategory(rawMessage, finalRawMessage); if (bubbleWanted) @@ -907,7 +907,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c channel = "#" + toString((uint32)mode); } } - if (!stringCategory.empty() && NLMISC::toUpper(stringCategory) != "SYS") + if (!stringCategory.empty() && NLMISC::compareCaseInsensitive(stringCategory.c_str(), "SYS")) // Not empty and not 'SYS' { channel = channel + "/" + stringCategory; } @@ -917,13 +917,13 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c // display a tell from network to interface -void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const ucstring &ucstr, const ucstring &senderName) +void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const std::string &ucstr, const std::string &senderName) { - ucstring finalString = ucstr; + string finalString = ucstr; // for now, '&' are removed by server so use another format until a special msg is made - if (strFindReplace(finalString, ucstring(""), ucstring())) + if (strFindReplace(finalString, "", string())) { CLuaManager::getInstance().executeLuaScript("RingAccessPoint:forceRefresh()"); } @@ -933,13 +933,13 @@ void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const u prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); bool windowVisible; - ucstring goodSenderName = CEntityCL::removeTitleAndShardFromName(senderName); + string goodSenderName = CEntityCL::removeTitleAndShardFromName(senderName); // The sender part is up to and including the first ":" after the goodSenderName - ucstring::size_type pos = finalString.find(goodSenderName); + string::size_type pos = finalString.find(goodSenderName); pos = finalString.find(':', pos); pos = finalString.find(' ', pos); - ucstring senderPart = finalString.substr(0, pos+1); + string senderPart = finalString.substr(0, pos+1); colorizeSender(finalString, senderPart, prop.getRGBA()); PeopleInterraction.ChatInput.Tell.displayTellMessage(/*senderIndex, */finalString, goodSenderName, prop.getRGBA(), 2, &windowVisible); @@ -1532,7 +1532,7 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason) // start progress bar and display background ProgressBar.reset (BAR_STEP_TP); - ucstring nmsg("Loading..."); + string nmsg("Loading..."); ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); @@ -2130,7 +2130,7 @@ void impulseWhere(NLMISC::CBitMemStream &impulse) sprintf(buf,"Your server position is : X= %g Y= %g Z= %g",xf,yf,zf); nlinfo(buf); - CInterfaceManager::getInstance()->displaySystemInfo(ucstring(buf)); + CInterfaceManager::getInstance()->displaySystemInfo(buf); }// impulseWhere // //----------------------------------------------- @@ -2304,11 +2304,9 @@ void impulsePhraseSend(NLMISC::CBitMemStream &impulse) void impulseStringResp(NLMISC::CBitMemStream &impulse) { uint32 stringId; - string strUtf8; + string str; impulse.serial(stringId); - impulse.serial(strUtf8); - ucstring str; - str.fromUtf8(strUtf8); + impulse.serial(str); if (PermanentlyBanned) return; @@ -3273,8 +3271,8 @@ private: STRING_MANAGER::CStringManagerClient *pSMC= STRING_MANAGER::CStringManagerClient::instance(); // get the content string (should have been received!) - ucstring contentStr; - ucstring titleStr; + string contentStr; + string titleStr; if(!pSMC->getDynString(_TextId[ContentType], contentStr)) return; @@ -3301,8 +3299,8 @@ private: } if(i != digitMaxEnd) { - ucstring web_app = contentStr.substr(digitStart, i-digitStart); - contentStr = ucstring(ClientCfg.WebIgMainDomain + "/") + web_app + ucstring("/index.php?") + contentStr.substr((size_t)i + 1); + string web_app = contentStr.substr(digitStart, i-digitStart); + contentStr = string(ClientCfg.WebIgMainDomain + "/") + web_app + string("/index.php?") + contentStr.substr((size_t)i + 1); } else { @@ -3336,7 +3334,7 @@ private: if (is_webig) { CGroupHTML *groupHtml; - string group = titleStr.toString(); + string group = titleStr; // group = group.substr(9, group.size()-10); groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:"+group+":content:html")); @@ -3359,7 +3357,7 @@ private: { if (group == "webig") pGC->setActive(true); - string url = contentStr.toString(); + string url = contentStr; addWebIGParams(url, true); groupHtml->browse(url.c_str()); CWidgetManager::getInstance()->setTopWindow(pGC); @@ -3395,7 +3393,7 @@ private: public: // called when the string is available - virtual void onDynStringAvailable(uint stringId, const ucstring &value) + virtual void onDynStringAvailable(uint stringId, const std::string &value) { // don't care if already displayed if(_AlreadyDisplayed) @@ -3470,7 +3468,7 @@ void impulseCombatFlyingHpDelta(NLMISC::CBitMemStream &impulse) CRGBA color((uint8)(rgba>>24&255), (uint8)(rgba>>16&255), (uint8)(rgba>>8&255), (uint8)(rgba&255)); CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(entityID); if (entity) - entity->addHPOutput(ucstring(toString("%d", hpDelta)), color); + entity->addHPOutput(toString("%d", hpDelta), color); } void impulseCombatFlyingTextItemSpecialEffectProc(NLMISC::CBitMemStream &impulse) @@ -3484,7 +3482,7 @@ void impulseCombatFlyingTextItemSpecialEffectProc(NLMISC::CBitMemStream &impulse impulse.serial(effect); impulse.serial(param); CRGBA color((uint8)(rgba>>24&255), (uint8)(rgba>>16&255), (uint8)(rgba>>8&255), (uint8)(rgba&255)); - ucstring text = CI18N::get(toString("uiItemSpecialEffectFlyingText%s", ITEM_SPECIAL_EFFECT::toString((ITEM_SPECIAL_EFFECT::TItemSpecialEffect)effect).c_str())); + string text = CI18N::get(toString("uiItemSpecialEffectFlyingText%s", ITEM_SPECIAL_EFFECT::toString((ITEM_SPECIAL_EFFECT::TItemSpecialEffect)effect).c_str())); strFindReplace(text, "%param", toString("%d", param)); CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(entityID); if (entity) @@ -3500,7 +3498,7 @@ void impulseCombatFlyingText(NLMISC::CBitMemStream &impulse) COMBAT_FLYING_TEXT::TCombatFlyingText type = (COMBAT_FLYING_TEXT::TCombatFlyingText)tmp; CRGBA color(255, 255, 255); - ucstring text(""); + string text(""); float dt = 0.0f; switch (type) @@ -4211,7 +4209,7 @@ std::string WebServer; NLMISC_COMMAND(localTellTeam, "Temp : simulate a tell in local mode", " ") { if (args.empty()) return false; - ucstring player = args[0]; + string player = args[0]; std::string msg; if (args.size() >= 2) { @@ -4222,7 +4220,7 @@ NLMISC_COMMAND(localTellTeam, "Temp : simulate a tell in local mode", " ") { if (args.empty()) return false; - ucstring player = args[0]; + string player = args[0]; std::string msg; if (args.size() >= 2) { @@ -4241,7 +4239,7 @@ NLMISC_COMMAND(localTell, "Temp : simulate a tell in local mode", " } } // TDataSetIndex dsi = INVALID_DATASET_ROW; - InterfaceChatDisplayer.displayTell(/*dsi, */ucstring(msg), player); + InterfaceChatDisplayer.displayTell(/*dsi, */msg, player); return true; } diff --git a/ryzom/client/src/network_connection.cpp b/ryzom/client/src/network_connection.cpp index 731677043..bad168a60 100644 --- a/ryzom/client/src/network_connection.cpp +++ b/ryzom/client/src/network_connection.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014-2016 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -680,6 +680,7 @@ bool CNetworkConnection::connect(string &result) _LatestLoginTime = ryzomGetLocalTime (); _LatestSyncTime = _LatestLoginTime; _LatestProbeTime = _LatestLoginTime; + m_LoginAttempts = 0; nlinfo("CNET[%p]: Client connected to shard, attempting login", this); return true; @@ -1091,6 +1092,17 @@ bool CNetworkConnection::stateLogin() { sendSystemLogin(); _LatestLoginTime = _UpdateTime; + if (m_LoginAttempts > 24) + { + m_LoginAttempts = 0; + disconnect(); // will send disconnection message + nlwarning("CNET[%p]: Too many LOGIN attempts, connection problem", this); + return false; // exit now from loop, don't expect a new state + } + else + { + ++m_LoginAttempts; + } } return false; @@ -2308,6 +2320,7 @@ bool CNetworkConnection::stateProbe() else { nlwarning("CNET[%p]: received normal in state Probe", this); + _LatestProbeTime = _UpdateTime; } } } diff --git a/ryzom/client/src/network_connection.h b/ryzom/client/src/network_connection.h index d11702682..99b1bf699 100644 --- a/ryzom/client/src/network_connection.h +++ b/ryzom/client/src/network_connection.h @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -822,6 +822,7 @@ private: void sendSystemLogin(); bool stateLogin(); NLMISC::TTime _LatestLoginTime; + int m_LoginAttempts; // void receiveSystemSync(NLMISC::CBitMemStream &msgin); diff --git a/ryzom/client/src/player_cl.cpp b/ryzom/client/src/player_cl.cpp index eafdec032..58deeac56 100644 --- a/ryzom/client/src/player_cl.cpp +++ b/ryzom/client/src/player_cl.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -742,7 +743,7 @@ void CPlayerCL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle * } // update title when gender changed - const ucstring replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, _Gender == GSGENDER::female)); + const string replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, _Gender == GSGENDER::female); if (!replacement.empty() || !ClientCfg.DebugStringManager) { // Get extended name diff --git a/ryzom/client/src/player_r2_cl.cpp b/ryzom/client/src/player_r2_cl.cpp index 138e7d8fa..75effe9bf 100644 --- a/ryzom/client/src/player_r2_cl.cpp +++ b/ryzom/client/src/player_r2_cl.cpp @@ -446,7 +446,7 @@ void CPlayerR2CL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle } // update title when gender changed - const ucstring replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw,_Gender == GSGENDER::female)); + const string replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw,_Gender == GSGENDER::female)); if (!replacement.empty()) { // Get extended name diff --git a/ryzom/client/src/progress.cpp b/ryzom/client/src/progress.cpp index 67aa774f9..9d2afdc27 100644 --- a/ryzom/client/src/progress.cpp +++ b/ryzom/client/src/progress.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -50,7 +50,7 @@ extern NL3D::UMaterial LoadingMaterialFull; extern std::vector LogoBitmaps; extern uint TipsOfTheDayIndex; -extern ucstring TipsOfTheDay; +extern string TipsOfTheDay; extern string NewsAtProgress; extern bool UseEscapeDuringLoading; @@ -288,8 +288,8 @@ void CProgress::internalProgress (float value) // Display the tips of the day. TextContext->setFontSize((uint)(16.f * fontFactor)); TextContext->setHotSpot(UTextContext::MiddleTop); - ucstring::size_type index = 0; - ucstring::size_type end = TipsOfTheDay.find((ucchar)'\n'); + string::size_type index = 0; + string::size_type end = TipsOfTheDay.find('\n'); if (end == string::npos) end = TipsOfTheDay.size(); float fY = ClientCfg.TipsY; @@ -298,15 +298,15 @@ void CProgress::internalProgress (float value) while (index < end) { // Get the line - ucstring line = TipsOfTheDay.substr (index, end-index); + string line = TipsOfTheDay.substr (index, end-index); // Draw the line TextContext->printAt(0.5f, fY, line); fY = nextLine (TextContext->getFontSize(), Driver->getWindowHeight(), fY); index=end+1; - end = TipsOfTheDay.find((ucchar)'\n', index); - if (end == ucstring::npos) + end = TipsOfTheDay.find('\n', index); + if (end == string::npos) end = TipsOfTheDay.size(); } @@ -339,7 +339,7 @@ void CProgress::internalProgress (float value) TextContext->setFontSize((uint)(15.f * fontFactor)); TextContext->setHotSpot(UTextContext::BottomLeft); - ucstring uc = CI18N::get("uiR2EDTPEscapeToInteruptLoading") + " (" + _TPCancelText + ") - " + CI18N::get("uiDelayedTPCancel"); + string uc = CI18N::get("uiR2EDTPEscapeToInteruptLoading") + " (" + _TPCancelText.toUtf8() + ") - " + CI18N::get("uiDelayedTPCancel"); UTextContext::CStringInfo info = TextContext->getStringInfo(uc); float stringX = 0.5f - info.StringWidth/(ClientCfg.Width*2); TextContext->printAt(stringX, 7.f / ClientCfg.Height, uc); @@ -355,12 +355,12 @@ void CProgress::internalProgress (float value) // Print some more info uint32 day = RT.getRyzomDay(); - str = toString (CI18N::get ("uiTipsTeleport").toUtf8().c_str(), - CI18N::get (LoadingContinent->LocalizedName).toUtf8().c_str(), + str = toString (CI18N::get ("uiTipsTeleport").c_str(), + CI18N::get (LoadingContinent->LocalizedName).c_str(), day, (uint)RT.getRyzomTime(), - CI18N::get ("uiSeason"+toStringEnum(CRyzomTime::getSeasonByDay(day))).toUtf8().c_str(), - CI18N::get (WeatherManager.getCurrWeatherState().LocalizedName).toUtf8().c_str()); + CI18N::get ("uiSeason"+toStringEnum(CRyzomTime::getSeasonByDay(day))).c_str(), + CI18N::get (WeatherManager.getCurrWeatherState().LocalizedName).c_str()); ucstring ucstr; ucstr.fromUtf8 (str); TextContext->setHotSpot(UTextContext::MiddleBottom); @@ -387,17 +387,17 @@ void CProgress::internalProgress (float value) // build the ucstr(s) string text = (*itpc).Text; - ucstring ucstr; + string ucstr; if (text == "NEWS") - ucstr.fromUtf8(NewsAtProgress); + ucstr = NewsAtProgress; else ucstr = CI18N::get(text); - vector vucstr; - ucstring sep("\n"); - splitUCString(ucstr,sep,vucstr); + vector vucstr; + string sep("\n"); + splitString(ucstr,sep,vucstr); // Letter size - UTextContext::CStringInfo si = TextContext->getStringInfo(ucstring("|")); + UTextContext::CStringInfo si = TextContext->getStringInfo("|"); uint fontHeight = (uint) si.StringHeight + 2; // we add 2 pixels for the gap uint i; diff --git a/ryzom/client/src/r2/auto_group.cpp b/ryzom/client/src/r2/auto_group.cpp index 7372d6e48..7da977b3d 100644 --- a/ryzom/client/src/r2/auto_group.cpp +++ b/ryzom/client/src/r2/auto_group.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -276,12 +279,12 @@ void CAutoGroup::group(CObject *newEntityDesc, const NLMISC::CVectorD &createPos getEditor().getDMC().flushActions(); return; } - ucstring readableName; + string readableName; CLuaState &ls = getEditor().getLua(); R2::getEditor().getEnv()["PaletteIdToGroupTranslation"][newEntityDesc->getAttr("Base")->toString()].push(); if (ls.isString(-1)) - readableName.fromUtf8(ls.toString(-1)); - ucstring ucGroupName = ucstring(readableName + " " + CI18N::get("uiR2EDNameGroup").toUtf8()); + readableName = ls.toString(-1); + string ucGroupName = readableName + " " + CI18N::get("uiR2EDNameGroup"); newGroup->set("Name", getEditor().genInstanceName(ucGroupName).toUtf8()); getEditor().getDMC().requestInsertNode(destGroup->getParentAct()->getId(), diff --git a/ryzom/client/src/r2/displayer_visual_entity.cpp b/ryzom/client/src/r2/displayer_visual_entity.cpp index 6e09e580e..01eaf0bc0 100644 --- a/ryzom/client/src/r2/displayer_visual_entity.cpp +++ b/ryzom/client/src/r2/displayer_visual_entity.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2016 Jan BOON (Kaetemi) +// Copyright (C) 2016-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -994,7 +994,7 @@ void CDisplayerVisualEntity::updateName() } std::string firstPart; if(actNb>0) - firstPart = CI18N::get("uiR2EDDefaultActTitle").toString() + " " + NLMISC::toString(actNb); + firstPart = CI18N::get("uiR2EDDefaultActTitle") + " " + NLMISC::toString(actNb); if (act->isString("Name")) actName = act->toString("Name"); @@ -1006,7 +1006,7 @@ void CDisplayerVisualEntity::updateName() } else { - actName = CI18N::get("uiR2EDBaseAct").toString(); + actName = CI18N::get("uiR2EDBaseAct"); } actName = NLMISC::toString(" [%s]", actName.c_str()); @@ -1017,7 +1017,7 @@ void CDisplayerVisualEntity::updateName() { //BENCH(setEntityName) - _Entity->setEntityName(ucName); + _Entity->setEntityName(ucName.toUtf8()); } { //BENCH(buildInSceneInterface) diff --git a/ryzom/client/src/r2/displayer_visual_group.cpp b/ryzom/client/src/r2/displayer_visual_group.cpp index 05e120e66..ba7249fd9 100644 --- a/ryzom/client/src/r2/displayer_visual_group.cpp +++ b/ryzom/client/src/r2/displayer_visual_group.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -73,10 +74,10 @@ public: return CCtrlPolygon::contains(CVector2f(mouseXInWindow + 0.5f, mouseYInWindow + 0.5f)); } // tooltip - virtual void getContextHelp(::ucstring &help) const + virtual void getContextHelp(std::string &help) const { - help = Instance.getDisplayName(); - if (std::operator==(help, NLMISC::CI18N::get("uiR2EDNoName") )) + help = Instance.getDisplayName().toUtf8(); + if (help == NLMISC::CI18N::get("uiR2EDNoName")) help.clear(); } bool emptyContextHelp() const { return true; } @@ -98,7 +99,7 @@ protected: { CGroupMap *gm = CTool::getWorldMap(); if (!gm) dest = CVector::Null; - gm->worldToWindow(dest, src); + else gm->worldToWindow(dest, src); } }; @@ -122,10 +123,10 @@ public: return CCtrlQuad::contains(CVector2f(mouseXInWindow + 0.5f, mouseYInWindow + 0.5f)); } // tooltip - virtual void getContextHelp(ucstring &help) const + virtual void getContextHelp(std::string &help) const { - help = Instance.getDisplayName(); - if (std::operator==(help, NLMISC::CI18N::get("uiR2EDNoName"))) + help = Instance.getDisplayName().toUtf8(); + if (help == NLMISC::CI18N::get("uiR2EDNoName")) help.clear(); } bool emptyContextHelp() const { return true; } diff --git a/ryzom/client/src/r2/dmc/client_edition_module.cpp b/ryzom/client/src/r2/dmc/client_edition_module.cpp index f58a9f669..0898711eb 100644 --- a/ryzom/client/src/r2/dmc/client_edition_module.cpp +++ b/ryzom/client/src/r2/dmc/client_edition_module.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2015-2018 Jan BOON (Kaetemi) +// Copyright (C) 2015-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -1154,6 +1154,15 @@ void CClientEditionModule::startingScenario(class NLNET::IModuleProxy * /* serve { ok = true; connectionState = "uiR2EDUploadScenario"; + +#if !FINAL_VERSION + string filename = CFile::findNewFile("scenario.rt.txt"); + COFile output(filename); + std::string ss; + rtDataPtr->serialize(ss); + output.serialBuffer((uint8*)ss.c_str(),(uint)ss.size()); + output.flush(); +#endif } else { @@ -1859,7 +1868,7 @@ void CClientEditionModule::onTpPositionSimulated(NLNET::IModuleProxy * /* sender beginLoading (LoadingBackground); #define BAR_STEP_TP 2 // fixme : this define is duplicated.... ProgressBar.reset (BAR_STEP_TP); - ucstring nmsg("Loading..."); + string nmsg("Loading..."); ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); ProgressBar.progress(0); ContinentMngr.select(dest, ProgressBar); @@ -2227,6 +2236,7 @@ void CClientEditionModule::addToSaveList(const std::string& filename, const std: if (!ok) { delete sv; + return; } else { diff --git a/ryzom/client/src/r2/dmc/com_lua_module.cpp b/ryzom/client/src/r2/dmc/com_lua_module.cpp index 2ea3d91dd..aaa8410ab 100644 --- a/ryzom/client/src/r2/dmc/com_lua_module.cpp +++ b/ryzom/client/src/r2/dmc/com_lua_module.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/r2/editor.cpp b/ryzom/client/src/r2/editor.cpp index 457cee562..c9b47e6a3 100644 --- a/ryzom/client/src/r2/editor.cpp +++ b/ryzom/client/src/r2/editor.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2016 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -212,14 +212,24 @@ CDynamicMapClient(eid, clientGateway, luaState) void CDynamicMapClientEventForwarder::nodeErased(const std::string& instanceId, const std::string& attrName, sint32 position) { //H_AUTO(R2_CDynamicMapClientEventForwarder_nodeErased) - if (getEditor().getMode() != CEditor::EditionMode) return; + if (getEditor().getMode() != CEditor::EditionMode) + { + nlassert(getEditor().getMode() != CEditor::AnimationModeLoading); /* Probably should not happen */ + nldebug("Node erased, but not in edition mode"); + return; + } getEditor().nodeErased(instanceId, attrName, position); } void CDynamicMapClientEventForwarder::nodeSet(const std::string& instanceId, const std::string& attrName, CObject* value) { //H_AUTO(R2_CDynamicMapClientEventForwarder_nodeSet) - if (getEditor().getMode() != CEditor::EditionMode) return; + if (getEditor().getMode() != CEditor::EditionMode + && getEditor().getMode() != CEditor::AnimationModeLoading /* Loading animation scenario from terminal, ghost nodes created by translator */) + { + nldebug("Node set, but not in edition mode"); + return; + } getEditor().nodeSet(instanceId, attrName, value); } @@ -227,7 +237,12 @@ void CDynamicMapClientEventForwarder::nodeInserted(const std::string& instanceId const std::string& key, CObject* value) { //H_AUTO(R2_CDynamicMapClientEventForwarder_nodeInserted) - if (getEditor().getMode() != CEditor::EditionMode) return; + if (getEditor().getMode() != CEditor::EditionMode + && getEditor().getMode() != CEditor::AnimationModeLoading /* Loading animation scenario from terminal, ghost nodes created by translator */) + { + nldebug("Node inserted, but not in edition mode"); + return; + } getEditor().nodeInserted(instanceId, attrName, position, key, value); } @@ -236,7 +251,12 @@ void CDynamicMapClientEventForwarder::nodeMoved( const std::string& destInstanceId, const std::string& destAttrName, sint32 destPosition) { //H_AUTO(R2_CDynamicMapClientEventForwarder_nodeMoved) - if (getEditor().getMode() != CEditor::EditionMode) return; + if (getEditor().getMode() != CEditor::EditionMode) + { + nlassert(getEditor().getMode() != CEditor::AnimationModeLoading); /* Probably should not happen */ + nldebug("Node moved, but not in edition mode"); + return; + } getEditor().nodeMoved(instanceId, attrName, position, destInstanceId, destAttrName, destPosition); } @@ -1551,12 +1571,12 @@ int CEditor::luaGetUserEntityName(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 1); // this is a method if (UserEntity) { - ucstring name = UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis; - ls.push( name.toUtf8() ); + string name = UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis; + ls.push( name ); } else { - ls.push(std::string("")); + ls.push(std::string()); } return 1; @@ -1741,7 +1761,7 @@ void CEditor::waitScenarioScreen() // Display the firewall alert string CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_connecting:title")); if (pVT != NULL) - pVT->setText(CI18N::get("uiFirewallAlert")+ucstring("...")); + pVT->setText(CI18N::get("uiFirewallAlert")+"..."); // 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 @@ -1833,8 +1853,8 @@ void CEditor::waitScenarioScreen() if (pVT != NULL) { pVT->setMultiLine( true ); - pVT->setText(CI18N::get("uiFirewallFail")+ucstring(".\n")+ - CI18N::get("uiFirewallAlert")+ucstring(".")); + pVT->setText(CI18N::get("uiFirewallFail")+".\n"+ + CI18N::get("uiFirewallAlert")+"."); } } } @@ -5785,7 +5805,7 @@ void CEditor::scenarioUpdated(CObject* highLevel, bool willTP, uint32 initialAct } // projectInLua(_Scenario); // push on the lua stack - getLua().push(float(initialActIndex)); // example reconnect after test in act4 + getLua().push(initialActIndex); // example reconnect after test in act4 // update value in the framework callEnvFunc("onScenarioUpdated", 2); //nlwarning("Instance list now is :"); @@ -6302,7 +6322,7 @@ CInstance *CEditor::getInstanceUnderPos(float x, float y, float distSelection, b objectSelected= precInstanceUnderPos->getDisplayerVisual(); } - if (objectSelected->getSelectionType() == ISelectableObject::GroundProjected) + if (objectSelected && objectSelected->getSelectionType() == ISelectableObject::GroundProjected) { if (borderSelected && borderSelected != objectSelected) { @@ -7464,7 +7484,7 @@ class CAHInviteCharacter : public IActionHandler CGroupEditBox *geb = dynamic_cast(fatherGC->getGroup("add_contact_eb:eb")); if (geb && !geb->getInputString().empty()) { - string charName = geb->getInputString().toString(); + string charName = geb->getInputString(); CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance(); sessionBrowser.inviteCharacterByName(sessionBrowser.getCharId(), charName); @@ -7486,7 +7506,7 @@ class CAHInviteCharacter : public IActionHandler CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_newcomer"); } - geb->setInputString(ucstring("")); + geb->setInputString(std::string()); } } } diff --git a/ryzom/client/src/r2/instance_map_deco.cpp b/ryzom/client/src/r2/instance_map_deco.cpp index cdc792dc5..46b1ad874 100644 --- a/ryzom/client/src/r2/instance_map_deco.cpp +++ b/ryzom/client/src/r2/instance_map_deco.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -40,11 +41,12 @@ namespace R2 { // ********************************************************************************************************* -void CInstanceMapDeco::CCtrlButtonEntity::getContextHelp(ucstring &help) const +void CInstanceMapDeco::CCtrlButtonEntity::getContextHelp(std::string &help) const { //H_AUTO(R2_CCtrlButtonEntity_getContextHelp) - help = _Instance.getDisplayName(); - if (help == NLMISC::CI18N::get("uiR2EDNoName")) help.clear(); + help = _Instance.getDisplayName().toUtf8(); + if (help == NLMISC::CI18N::get("uiR2EDNoName")) + help.clear(); } // ********************************************************************************************************* diff --git a/ryzom/client/src/r2/instance_map_deco.h b/ryzom/client/src/r2/instance_map_deco.h index cf1a2352c..dd7c719e4 100644 --- a/ryzom/client/src/r2/instance_map_deco.h +++ b/ryzom/client/src/r2/instance_map_deco.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -91,7 +92,7 @@ private: private: CInstance &_Instance; protected: - virtual void getContextHelp(ucstring &help) const; + virtual void getContextHelp(std::string &help) const; bool emptyContextHelp() const { return true; } bool wantInstantContextHelp() const { return true; } virtual bool isCapturable() const { return false; } diff --git a/ryzom/client/src/r2/prim_render.cpp b/ryzom/client/src/r2/prim_render.cpp index 59b05e1c4..93f610377 100644 --- a/ryzom/client/src/r2/prim_render.cpp +++ b/ryzom/client/src/r2/prim_render.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -202,7 +203,7 @@ CCtrlPolygon *CPrimRender::newCtrlPolygon() const { CGroupMap *gm = CTool::getWorldMap(); if (!gm) dest = CVector::Null; - gm->worldToWindow(dest, src); + else gm->worldToWindow(dest, src); } }; CViewBase::TCtorParam param; diff --git a/ryzom/client/src/r2/tool_draw_prim.cpp b/ryzom/client/src/r2/tool_draw_prim.cpp index c32682626..7ec119e29 100644 --- a/ryzom/client/src/r2/tool_draw_prim.cpp +++ b/ryzom/client/src/r2/tool_draw_prim.cpp @@ -551,9 +551,9 @@ void CToolDrawPrim::commit() if (!_Extending) { // set readable name - ucstring readableName = NLMISC::CI18N::get(_PrimType == Road ? "uiR2EDNameBotRoad" : "uiR2EDNameBotRegion"); - readableName = getEditor().genInstanceName(readableName); - desc->set("Name", readableName.toUtf8()); + string readableName = NLMISC::CI18N::get(_PrimType == Road ? "uiR2EDNameBotRoad" : "uiR2EDNameBotRegion"); + readableName = getEditor().genInstanceName(readableName).toUtf8(); + desc->set("Name", readableName); // send creation command // tmp : static npc counter // add in component list of default feature diff --git a/ryzom/client/src/r2/tool_select_move.cpp b/ryzom/client/src/r2/tool_select_move.cpp index f9b9b9a1a..e23d969eb 100644 --- a/ryzom/client/src/r2/tool_select_move.cpp +++ b/ryzom/client/src/r2/tool_select_move.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -417,9 +420,9 @@ void CToolSelectMove::commitAction(CInstance &instance) } else { - ucstring instanceName = instance.getDisplayName(); + string instanceName = instance.getDisplayName().toUtf8(); if(instanceName == CI18N::get("uiR2EDNoName")) - instanceName = ucstring(instance.getClassName()); + instanceName = instance.getClassName(); //getDMC().newAction(CI18N::get("uiR2EDMoveAction") + instance.getDisplayName()); getDMC().newAction(CI18N::get("uiR2EDMoveAction") + instanceName); diff --git a/ryzom/client/src/segement_heap.manifest b/ryzom/client/src/segement_heap.manifest new file mode 100644 index 000000000..0deedb1e7 --- /dev/null +++ b/ryzom/client/src/segement_heap.manifest @@ -0,0 +1,8 @@ + + + + + SegmentHeap + + + diff --git a/ryzom/client/src/session_browser.cpp b/ryzom/client/src/session_browser.cpp index 6d80c55cb..7b29f3023 100644 --- a/ryzom/client/src/session_browser.cpp +++ b/ryzom/client/src/session_browser.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/ryzom/client/src/session_browser_impl.cpp b/ryzom/client/src/session_browser_impl.cpp index 9f3cc77a9..08a5dba3a 100644 --- a/ryzom/client/src/session_browser_impl.cpp +++ b/ryzom/client/src/session_browser_impl.cpp @@ -2,8 +2,8 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013 Jan BOON (Kaetemi) // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/client/src/string_manager_client.cpp b/ryzom/client/src/string_manager_client.cpp index a10be8114..7a12cc92d 100644 --- a/ryzom/client/src/string_manager_client.cpp +++ b/ryzom/client/src/string_manager_client.cpp @@ -39,17 +39,17 @@ namespace STRING_MANAGER // *************************************************************************** map CStringManagerClient::_SpecItem_TempMap; - map CStringManagerClient::_DynStrings; - vector CStringManagerClient::_TitleWords; + map CStringManagerClient::_DynStrings; + vector CStringManagerClient::_TitleWords; bool CStringManagerClient::_SpecItem_MemoryCompressed = false; char *CStringManagerClient::_SpecItem_Labels = NULL; - ucchar *CStringManagerClient::_SpecItem_NameDesc = NULL; + char *CStringManagerClient::_SpecItem_NameDesc = NULL; vector CStringManagerClient::_SpecItems; bool MustReleaseStaticArrays = true; CStringManagerClient *CStringManagerClient::_Instance= NULL; - ucstring CStringManagerClient::_WaitString("???"); + string CStringManagerClient::_WaitString("???"); CStringManagerClient::CStringManagerClient() @@ -57,7 +57,7 @@ namespace STRING_MANAGER _CacheInited = false; _CacheLoaded = false; // insert the empty string. - _ReceivedStrings.insert(make_pair((uint)EmptyStringId, ucstring())); + _ReceivedStrings.insert(make_pair((uint)EmptyStringId, string())); // reserve some place to avoid reallocation as possible _CacheStringToSave.reserve(1024); } @@ -122,6 +122,7 @@ namespace STRING_MANAGER { try { + const uint currentVersion = 1; _CacheFilename = std::string("save/") + _ShardId.substr(0, _ShardId.find(":")) + ".string_cache"; nlinfo("SM : Try to open the string cache : %s", _CacheFilename.c_str()); @@ -131,6 +132,8 @@ namespace STRING_MANAGER // there is a cache file, check date reset it if needed { NLMISC::CIFile file(_CacheFilename); + file.setVersionException(false, false); + file.serialVersion(currentVersion); file.serial(_Timestamp); } @@ -139,6 +142,7 @@ namespace STRING_MANAGER nlinfo("SM: Clearing string cache : outofdate"); // the cache is not sync, reset it NLMISC::COFile file(_CacheFilename); + file.serialVersion(currentVersion); file.serial(timestamp); } else @@ -151,6 +155,7 @@ namespace STRING_MANAGER nlinfo("SM: Creating string cache"); // cache file don't exist, create it with the timestamp NLMISC::COFile file(_CacheFilename); + file.serialVersion(currentVersion); file.serial(timestamp); } @@ -160,17 +165,19 @@ namespace STRING_MANAGER // NB : we keep the waiting strings and dyn strings // insert the empty string. - _ReceivedStrings.insert(make_pair((uint)EmptyStringId, ucstring())); + _ReceivedStrings.insert(make_pair((uint)EmptyStringId, string())); // load the cache file NLMISC::CIFile file(_CacheFilename); + int version = file.serialVersion(currentVersion); file.serial(_Timestamp); nlassert(_Timestamp == timestamp); + nlassert(version >= 1); // Initial version while (!file.eof()) { uint32 id; - ucstring str; + string str; file.serial(id); file.serial(str); @@ -194,12 +201,12 @@ namespace STRING_MANAGER - void CStringManagerClient::waitString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result) + void CStringManagerClient::waitString(uint32 stringId, const IStringWaiterRemover *premover, string *result) { H_AUTO( CStringManagerClient_waitString ) nlassert(premover && result); - ucstring value; + string value; if (getString(stringId, value)) *result = value; else @@ -217,7 +224,7 @@ namespace STRING_MANAGER H_AUTO( CStringManagerClient_waitString2 ) nlassert(pcallback != 0); - ucstring value; + string value; if (getString(stringId, value)) { pcallback->onStringAvailable(stringId, value); @@ -230,12 +237,12 @@ namespace STRING_MANAGER } - void CStringManagerClient::waitDynString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result) + void CStringManagerClient::waitDynString(uint32 stringId, const IStringWaiterRemover *premover, string *result) { H_AUTO( CStringManagerClient_waitDynString ) nlassert(premover && result); - ucstring value; + string value; if (getDynString(stringId, value)) *result = value; else @@ -253,7 +260,7 @@ namespace STRING_MANAGER H_AUTO( CStringManagerClient_waitDynString2 ) nlassert(pcallback != 0); - ucstring value; + string value; if (getDynString(stringId, value)) { pcallback->onDynStringAvailable(stringId, value); @@ -330,7 +337,7 @@ restartLoop4: - bool CStringManagerClient::getString(uint32 stringId, ucstring &result) + bool CStringManagerClient::getString(uint32 stringId, string &result) { H_AUTO( CStringManagerClient_getString ) @@ -357,7 +364,7 @@ restartLoop4: _WaitingStrings.insert(stringId); // need to ask for this string. NLMISC::CBitMemStream bms; - const std::string msgType = "STRING_MANAGER:STRING_RQ"; + static const string msgType = "STRING_MANAGER:STRING_RQ"; if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) { bms.serial( stringId ); @@ -374,7 +381,7 @@ restartLoop4: { char tmp[1024]; sprintf(tmp, "", stringId); - result = ucstring(tmp); + result = tmp; } else result.erase(); // = _WaitString; @@ -385,14 +392,14 @@ restartLoop4: { char tmp[1024]; sprintf(tmp, "", stringId); - result = ucstring(tmp) + it->second; + result = tmp + it->second; } else { result = it->second; - if (result.size() > 9 && result.substr(0, 9) == ucstring(" 9 && result.substr(0, 9) == "::iterator itds = _DynStrings.find(result.substr(9, result.size()-10)); + map::iterator itds = _DynStrings.find(result.substr(9, result.size()-10)); if (itds != _DynStrings.end()) result = itds->second; } @@ -402,7 +409,7 @@ restartLoop4: return true; } - void CStringManagerClient::receiveString(uint32 stringId, const ucstring &str) + void CStringManagerClient::receiveString(uint32 stringId, const string &str) { H_AUTO( CStringManagerClient_receiveString ) @@ -419,8 +426,8 @@ restartLoop4: TStringsContainer::iterator it(_ReceivedStrings.find(stringId)); nlwarning("Receiving stringID %u (%s), already in received string (%s), replacing with new value.", stringId, - str.toString().c_str(), - it->second.toString().c_str()); + str.c_str(), + it->second.c_str()); if (it->second != str) it->second = str; @@ -484,7 +491,7 @@ restartLoop: last = _WaitingDynStrings.end(); for (; first != last; ++first) { - ucstring value; + string value; uint number = first->first; /// Warning: if getDynString() return true, 'first' is erased => don't use it after in this loop if (getDynString(number, value)) @@ -616,7 +623,7 @@ restartLoop: return false; } // ok, we have the base string, we can serial the parameters - ucstring::iterator first(dynInfo.String.begin()), last(dynInfo.String.end()); + string::iterator first(dynInfo.String.begin()), last(dynInfo.String.end()); for (; first != last; ++first) { if (*first == '%') @@ -699,10 +706,10 @@ restartLoop: if (dynInfo.Status == TDynStringInfo::serialized) { // try to retreive all string parameter to build the string. - ucstring temp; + string temp; temp.reserve(dynInfo.String.size() * 2); - ucstring::iterator src(dynInfo.String.begin()); - ucstring::iterator move = src; + string::iterator src(dynInfo.String.begin()); + string::iterator move = src; std::vector::iterator first(dynInfo.Params.begin()), last(dynInfo.Params.end()); for (; first != last; ++first) @@ -712,7 +719,7 @@ restartLoop: { case string_id: { - ucstring str; + string str; if (!getString(param.StringId, str)) return false; @@ -734,15 +741,15 @@ restartLoop: // If the shard name is the same as the player home shard name, remove it uint len= (uint)PlayerSelectedHomeShardNameWithParenthesis.size(); uint start= (uint)str.size()-len; - if(ucstrnicmp(str, start, len, PlayerSelectedHomeShardNameWithParenthesis)==0) + if(ucstrnicmp(str, start, len, PlayerSelectedHomeShardNameWithParenthesis)==0) // TODO: NLMISC::compareCaseInsensitive str.resize(start); } } } // If the string contains a title, then remove it - ucstring::size_type pos = str.find('$'); - if ( ! str.empty() && pos != ucstring::npos) + string::size_type pos = str.find('$'); + if ( ! str.empty() && pos != string::npos) { str = CEntityCL::removeTitleFromName(str); } @@ -765,13 +772,13 @@ restartLoop: char value[1024]; sprintf(value, "%d", param.Integer); temp.append(move, src+param.ReplacementPoint); - temp+=ucstring(value); + temp += value; move = dynInfo.String.begin()+param.ReplacementPoint+2; } break; case time: { - ucstring value; + string value; uint32 time = (uint32)param.Time; if( time >= (10*60*60) ) { @@ -802,7 +809,7 @@ restartLoop: char value[1024]; sprintf(value, "%u", (uint32)param.Money); temp.append(move, src+param.ReplacementPoint); - temp+=ucstring(value); + temp += value; move = dynInfo.String.begin()+param.ReplacementPoint+2; } // TODO @@ -811,7 +818,7 @@ restartLoop: break; case dyn_string_id: { - ucstring dynStr; + string dynStr; if (!getDynString(param.DynStringId, dynStr)) return false; temp.append(move, src+param.ReplacementPoint); @@ -829,8 +836,8 @@ restartLoop: // apply any 'delete' character in the string and replace double '%' { - uint i =0; - while (i < temp.size()) + ptrdiff_t i =0; + while (i < (ptrdiff_t)temp.size()) { if (temp[i] == 8) { @@ -859,7 +866,7 @@ restartLoop: } - bool CStringManagerClient::getDynString(uint32 dynStringId, ucstring &result) + bool CStringManagerClient::getDynString(uint32 dynStringId, std::string &result) { H_AUTO( CStringManagerClient_getDynString ) @@ -888,7 +895,7 @@ restartLoop: { char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp) + it->second.String; + result = tmp + it->second.String; } else result = it->second.String; @@ -914,7 +921,7 @@ restartLoop: nlwarning("DynStringID %u is unknown !", dynStringId); char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp); + result = tmp; } else result.erase(); //_WaitString; @@ -926,7 +933,7 @@ restartLoop: { char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp) + it->second.String; + result = tmp + it->second.String; } else result = it->second.String; @@ -939,7 +946,7 @@ restartLoop: { char tmp[1024]; sprintf(tmp, "", dynStringId); - result = ucstring(tmp); + result = tmp; } else result.erase(); // = _WaitString; @@ -949,7 +956,7 @@ restartLoop: } // Tool fct to lookup a reference file - static string lookupReferenceFile(const std::string &fileName) + static string lookupReferenceFile(const string &fileName) { string referenceFile; // special location for the "wk" language @@ -970,14 +977,14 @@ restartLoop: return referenceFile; } - void CLoadProxy::loadStringFile(const std::string &filename, ucstring &text) + void CLoadProxy::loadStringFile(const string &filename, ucstring &text) { vector reference; vector addition; vector diff; // get the correct path name of the ref file - std::string referenceFile= lookupReferenceFile(filename); + string referenceFile= lookupReferenceFile(filename); // load the reference file if (!referenceFile.empty()) @@ -1047,7 +1054,7 @@ public: TWorksheet diff; // get the correct path name of the ref file - std::string referenceFile= lookupReferenceFile(filename); + string referenceFile= lookupReferenceFile(filename); // load the reference file if (!referenceFile.empty()) @@ -1140,7 +1147,7 @@ public: const string StringClientPackedFileName= "./save/string_client.pack"; // Must Increment this number if change are made to the code (else change not taken into account) const uint StringClientPackedVersion= 0; -bool CStringManagerClient::checkWordFileDates(vector &fileChecks, const std::vector &fileNames, const std::string &languageCode) +bool CStringManagerClient::checkWordFileDates(vector &fileChecks, const std::vector &fileNames, const string &languageCode) { fileChecks.resize(fileNames.size()); @@ -1148,7 +1155,7 @@ bool CStringManagerClient::checkWordFileDates(vector &fileChecks, co for(uint i=0;i &fileChecks, co // *************************************************************************** -void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) +void CStringManagerClient::initI18NSpecialWords(const string &languageCode) { - ucstring womenNameColIdent= string("women_name"); - ucstring descColIdent= string("description"); - ucstring descColIdent2= string("description2"); + ucstring womenNameColIdent = "women_name"; + ucstring descColIdent = "description"; + ucstring descColIdent2 = "description2"; // List of words to append to the local CI18N system. static const char *specialWords[]= @@ -1219,8 +1226,8 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) uint32 profile0= (uint32)ryzomGetLocalTime(); ucstring ucs; - std::string fileName = fileNames[i]; - std::string keyExtenstion = specialWords[i*3+2]; + string fileName = fileNames[i]; + string keyExtenstion = specialWords[i*3+2]; // read the ucstring and make diffs with data in ./translation/work. CReadWorkSheetFile rwsf; @@ -1256,17 +1263,17 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) for(uint j=1;j::iterator it; + std::map::iterator it; it= _SpecItem_TempMap.find( keyStr ); if ( it!=_SpecItem_TempMap.end() ) { @@ -1282,7 +1289,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) if(womenNameColIndex!=std::numeric_limits::max()) { const ucstring &womenName= ws.getData(j, womenNameColIndex); - _SpecItem_TempMap[keyStr].WomenName= womenName; + _SpecItem_TempMap[keyStr].WomenName= womenName.toUtf8(); // replace all \n in the women name with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].WomenName, "\\n", "\n")); } @@ -1291,7 +1298,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) if(descColIndex!=std::numeric_limits::max()) { const ucstring &desc= ws.getData(j, descColIndex); - _SpecItem_TempMap[keyStr].Desc= desc; + _SpecItem_TempMap[keyStr].Desc= desc.toUtf8(); // replace all \n in the desc with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].Desc, "\\n", "\n")); } @@ -1300,7 +1307,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) if(descColIndex2!=std::numeric_limits::max()) { const ucstring &desc= ws.getData(j, descColIndex2); - _SpecItem_TempMap[keyStr].Desc2= desc; + _SpecItem_TempMap[keyStr].Desc2= desc.toUtf8(); // replace all \n in the desc with true \n while(strFindReplace(_SpecItem_TempMap[keyStr].Desc2, "\\n", "\n")); } @@ -1364,7 +1371,7 @@ void CStringManagerClient::specialWordsMemoryCompress() // Make big strings _SpecItems.resize(nNbEntries); _SpecItem_Labels = new char[nLabelSize]; - _SpecItem_NameDesc = new ucchar[nNameDescSize]; + _SpecItem_NameDesc = new char[nNameDescSize]; nNbEntries = 0; nLabelSize = 0; @@ -1372,35 +1379,30 @@ void CStringManagerClient::specialWordsMemoryCompress() it = _SpecItem_TempMap.begin(); while (it != _SpecItem_TempMap.end()) { - - if (strnicmp(it->first.c_str(), "bf", 2) == 0) + if (NLMISC::startsWith(it->first.c_str(), "bf")) { uint nDbg = 0; nDbg++; } _SpecItems[nNbEntries].Label = _SpecItem_Labels+nLabelSize; - strcpy(_SpecItems[nNbEntries].Label, it->first.c_str()); + strcpy(_SpecItem_Labels+nLabelSize, it->first.c_str()); nLabelSize += (uint32)it->first.size() + 1; _SpecItems[nNbEntries].Name = _SpecItem_NameDesc+nNameDescSize; - memcpy(_SpecItems[nNbEntries].Name, it->second.Name.c_str(), 2*(it->second.Name.size()+1)); - _SpecItems[nNbEntries].Name[it->second.Name.size()] = 0; + strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Name.c_str()); nNameDescSize += (uint32)it->second.Name.size() + 1; _SpecItems[nNbEntries].WomenName = _SpecItem_NameDesc+nNameDescSize; - memcpy(_SpecItems[nNbEntries].WomenName, it->second.WomenName.c_str(), 2*(it->second.WomenName.size()+1)); - _SpecItems[nNbEntries].WomenName[it->second.WomenName.size()] = 0; + strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.WomenName.c_str()); nNameDescSize += (uint32)it->second.WomenName.size() + 1; _SpecItems[nNbEntries].Desc = _SpecItem_NameDesc+nNameDescSize; - memcpy(_SpecItems[nNbEntries].Desc, it->second.Desc.c_str(), 2*(it->second.Desc.size()+1)); - _SpecItems[nNbEntries].Desc[it->second.Desc.size()] = 0; + strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Desc.c_str()); nNameDescSize += (uint32)it->second.Desc.size() + 1; _SpecItems[nNbEntries].Desc2 = _SpecItem_NameDesc+nNameDescSize; - memcpy(_SpecItems[nNbEntries].Desc2, it->second.Desc2.c_str(), 2*(it->second.Desc2.size()+1)); - _SpecItems[nNbEntries].Desc2[it->second.Desc2.size()] = 0; + strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Desc2.c_str()); nNameDescSize += (uint32)it->second.Desc2.size() + 1; nNbEntries++; @@ -1412,22 +1414,21 @@ void CStringManagerClient::specialWordsMemoryCompress() } // *************************************************************************** -const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bool women) +const char *CStringManagerClient::getSpecialWord(const string &label, bool women) { if (label.empty()) { - static ucstring emptyString; + static string emptyString; return emptyString.c_str(); } if (label[0] == '#') { - static ucstring rawString; return getLocalizedName(label.substr(1, label.size()-1)); } // avoid case problems - static std::string lwrLabel; + static string lwrLabel; lwrLabel = toLower(label); if (_SpecItem_MemoryCompressed) @@ -1442,8 +1443,7 @@ const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bo { if( UseFemaleTitles && women ) { - ucstring ustr(it->WomenName); - if( !ustr.empty() ) + if( !it->WomenName[0] ) return it->WomenName; } return it->Name; @@ -1462,28 +1462,26 @@ const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bo } } - static ucstring badString; - - badString = ucstring(std::string(""); - + static string badString; + badString = ""; return badString.c_str(); } // *************************************************************************** -const ucchar * CStringManagerClient::getSpecialDesc(const std::string &label) +const char *CStringManagerClient::getSpecialDesc(const string &label) { - static ucstring emptyString; + static string emptyString; if (label.empty()) return emptyString.c_str(); // avoid case problems - static std::string lwrLabel; + static string lwrLabel; lwrLabel = toLower(label); if (_SpecItem_MemoryCompressed) { CItemLight tmp; - tmp.Label = (char*)lwrLabel.c_str(); + tmp.Label = lwrLabel.c_str(); vector::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp()); if (it != _SpecItems.end()) @@ -1503,20 +1501,20 @@ const ucchar * CStringManagerClient::getSpecialDesc(const std::string &label) } // *************************************************************************** -const ucchar * CStringManagerClient::getSpecialDesc2(const std::string &label) +const char *CStringManagerClient::getSpecialDesc2(const string &label) { - static ucstring emptyString; + static string emptyString; if (label.empty()) return emptyString.c_str(); // avoid case problems - static std::string lwrLabel; + static string lwrLabel; lwrLabel = toLower(label); if (_SpecItem_MemoryCompressed) { CItemLight tmp; - tmp.Label = (char*)lwrLabel.c_str(); + tmp.Label = lwrLabel.c_str(); vector::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp()); if (it != _SpecItems.end()) @@ -1545,87 +1543,88 @@ const ucchar * CStringManagerClient::getSpecialDesc2(const std::string &label) */ // *************************************************************************** -const ucchar *CStringManagerClient::getPlaceLocalizedName(const string &placeNameID) +const char *CStringManagerClient::getPlaceLocalizedName(const string &placeNameID) { return getSpecialWord(placeNameID); } // *************************************************************************** -const ucchar *CStringManagerClient::getFactionLocalizedName(const string &factionNameID) +const char *CStringManagerClient::getFactionLocalizedName(const string &factionNameID) { return getSpecialWord(factionNameID); } // *************************************************************************** -const ucchar *CStringManagerClient::getSkillLocalizedName(SKILLS::ESkills e) +const char *CStringManagerClient::getSkillLocalizedName(SKILLS::ESkills e) { return getSpecialWord(SKILLS::toString(e)); } // *************************************************************************** -const ucchar *CStringManagerClient::getItemLocalizedName(CSheetId id) +const char *CStringManagerClient::getItemLocalizedName(CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getCreatureLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getCreatureLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSBrickLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getSBrickLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSPhraseLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getSPhraseLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -/*const ucchar *CStringManagerClient::getBrickLocalizedDescription(BRICK_FAMILIES::TBrickFamily e) +/*const char *CStringManagerClient::getBrickLocalizedDescription(BRICK_FAMILIES::TBrickFamily e) { return getSpecialDesc(BRICK_FAMILIES::toString(e)); } */ // *************************************************************************** -const ucchar *CStringManagerClient::getSkillLocalizedDescription(SKILLS::ESkills e) +const char *CStringManagerClient::getSkillLocalizedDescription(SKILLS::ESkills e) { return getSpecialDesc(SKILLS::toString(e)); } // *************************************************************************** -const ucchar *CStringManagerClient::getItemLocalizedDescription(CSheetId id) +const char *CStringManagerClient::getItemLocalizedDescription(CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSBrickLocalizedDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getSBrickLocalizedDescription(NLMISC::CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id) { return getSpecialDesc2(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getTitleLocalizedName(const ucstring &titleId, bool women) +const char *CStringManagerClient::getTitleLocalizedName(const string &titleId, bool women) { - vector listInfos = getTitleInfos(titleId, women); + vector listInfos = getTitleInfos(titleId, women); + if (!listInfos.empty()) { _TitleWords.push_back(listInfos[0]); @@ -1667,18 +1666,16 @@ const ucchar *CStringManagerClient::getLocalizedName(const ucstring &uctext) } // *************************************************************************** -vector CStringManagerClient::getTitleInfos(const ucstring &titleId, bool women) +vector CStringManagerClient::getTitleInfos(const string &titleId, bool women) { - //ucstring infosUC; - //infosUC.fromUtf8(titleId); - vector listInfos; - splitUCString(titleId, ucstring("#"), listInfos); + vector listInfos; + splitString(titleId, string("#"), listInfos); if (!listInfos.empty()) { if (titleId[0] != '#') { - listInfos[0] = getSpecialWord(listInfos[0].toUtf8(), women); + listInfos[0] = getSpecialWord(listInfos[0], women); } } @@ -1686,74 +1683,76 @@ vector CStringManagerClient::getTitleInfos(const ucstring &titleId, bo } // *************************************************************************** -const ucchar *CStringManagerClient::getClassificationTypeLocalizedName(EGSPD::CClassificationType::TClassificationType type) +const char *CStringManagerClient::getClassificationTypeLocalizedName(EGSPD::CClassificationType::TClassificationType type) { return getSpecialDesc(EGSPD::CClassificationType::toString(type)); } // *************************************************************************** -const ucchar *CStringManagerClient::getOutpostLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getOutpostLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getOutpostLocalizedDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getOutpostLocalizedDescription(NLMISC::CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getOutpostBuildingLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getOutpostBuildingLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSquadLocalizedName(NLMISC::CSheetId id) +const char *CStringManagerClient::getSquadLocalizedName(NLMISC::CSheetId id) { return getSpecialWord(id.toString()); } // *************************************************************************** -const ucchar *CStringManagerClient::getSquadLocalizedDescription(NLMISC::CSheetId id) +const char *CStringManagerClient::getSquadLocalizedDescription(NLMISC::CSheetId id) { return getSpecialDesc(id.toString()); } // *************************************************************************** -void CStringManagerClient::replaceDynString(const ucstring &name, const ucstring &text) +void CStringManagerClient::replaceDynString(const std::string &name, const std::string &text) { _DynStrings[name] = text; } // *************************************************************************** -void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const ucstring &name, const ucstring &desc, const ucstring &desc2) +void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const std::string &name, const std::string &desc, const std::string &desc2) { - std::string label= id.toString(); + string label= id.toString(); if (label.empty()) { return; } // avoid case problems - static std::string lwrLabel; + static string lwrLabel; lwrLabel = toLower(label); + nlassert(!_SpecItem_MemoryCompressed); // Not allowed, strings are released! if (_SpecItem_MemoryCompressed) { - ucchar *strName = (ucchar *)name.c_str(); - ucchar *strDesc = (ucchar *)desc.c_str(); - ucchar *strDesc2 = (ucchar *)desc2.c_str(); +#if 0 + const char *strName = name.c_str(); + const char *strDesc = desc.c_str(); + const char *strDesc2 = desc2.c_str(); CItemLight tmp; - tmp.Label = (char*)lwrLabel.c_str(); + tmp.Label = lwrLabel.c_str(); vector::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp()); if (it != _SpecItems.end()) @@ -1779,6 +1778,7 @@ void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const ucstring tmp.Desc2 = strDesc2; _SpecItems.push_back(tmp); } +#endif } else { diff --git a/ryzom/client/src/string_manager_client.h b/ryzom/client/src/string_manager_client.h index c977a8380..864c80c1f 100644 --- a/ryzom/client/src/string_manager_client.h +++ b/ryzom/client/src/string_manager_client.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010-2017 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -60,14 +63,14 @@ public: // Force the cache to be saved void flushStringCache(); - bool getString(uint32 stringId, ucstring &result); - void waitString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result); + bool getString(uint32 stringId, std::string &result); + void waitString(uint32 stringId, const IStringWaiterRemover *premover, std::string *result); void waitString(uint32 stringId, IStringWaitCallback *pcallback); - bool getDynString(uint32 dynStringId, ucstring &result); - void waitDynString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result); + bool getDynString(uint32 dynStringId, std::string &result); + void waitDynString(uint32 stringId, const IStringWaiterRemover *premover, std::string *result); void waitDynString(uint32 stringId, IStringWaitCallback *pcallback); - void receiveString(uint32 stringId, const ucstring &str); + void receiveString(uint32 stringId, const std::string &str); void receiveDynString(NLMISC::CBitMemStream &bms); void releaseDynString(uint32 stringId); @@ -76,55 +79,55 @@ public: static void initI18NSpecialWords(const std::string &languageCode); static void specialWordsMemoryCompress(); // Yoyo: Replace the Brick Name with Filled stats (CSBrickManager work). No-Op if not found - static void replaceSBrickName(NLMISC::CSheetId id, const ucstring &name, const ucstring &desc, const ucstring &desc2); - static void replaceDynString(const ucstring &name, const ucstring &text); + static void replaceSBrickName(NLMISC::CSheetId id, const std::string &name, const std::string &desc, const std::string &desc2); + static void replaceDynString(const std::string &name, const std::string &text); // Get the Localized Name of the Places. - static const ucchar *getPlaceLocalizedName(const std::string &placeNameID); + static const char *getPlaceLocalizedName(const std::string &placeNameID); // Get the Localized Name of the faction (for the fame) - static const ucchar *getFactionLocalizedName(const std::string &factionNameID); + static const char *getFactionLocalizedName(const std::string &factionNameID); // Get the Localized Name of the Skill. - static const ucchar *getSkillLocalizedName(SKILLS::ESkills e); + static const char *getSkillLocalizedName(SKILLS::ESkills e); // Get the Localized Name of the Item. - static const ucchar *getItemLocalizedName(NLMISC::CSheetId id); + static const char *getItemLocalizedName(NLMISC::CSheetId id); // Get the Localized Name of the Creature. - static const ucchar *getCreatureLocalizedName(NLMISC::CSheetId id); + static const char *getCreatureLocalizedName(NLMISC::CSheetId id); // Get the Localized Name of the SBrick. - static const ucchar *getSBrickLocalizedName(NLMISC::CSheetId id); + static const char *getSBrickLocalizedName(NLMISC::CSheetId id); // Get the Localized Name of the SPhrase. - static const ucchar *getSPhraseLocalizedName(NLMISC::CSheetId id); + static const char *getSPhraseLocalizedName(NLMISC::CSheetId id); // Get the Localized Description of the Skill. - static const ucchar *getSkillLocalizedDescription(SKILLS::ESkills e); + static const char *getSkillLocalizedDescription(SKILLS::ESkills e); // Get the Localized Descriptionof the Item. - static const ucchar *getItemLocalizedDescription(NLMISC::CSheetId id); + static const char *getItemLocalizedDescription(NLMISC::CSheetId id); // Get the Localized Description of the SBrick. - static const ucchar *getSBrickLocalizedDescription(NLMISC::CSheetId id); + static const char *getSBrickLocalizedDescription(NLMISC::CSheetId id); // Get the Localized Composition Description of the SBrick. - static const ucchar *getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id); + static const char *getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id); // Get the Localized Description of the SPhrase. - static const ucchar *getSPhraseLocalizedDescription(NLMISC::CSheetId id); + static const char *getSPhraseLocalizedDescription(NLMISC::CSheetId id); // Get the Localized Title name - static const ucchar *getTitleLocalizedName(const ucstring &titleId, bool women); - static const ucchar *getLocalizedName(const ucstring &text); - static std::vector getTitleInfos(const ucstring &titleId, bool women); + static const char *getTitleLocalizedName(const std::string &titleId, bool women); + static const char *getLocalizedName(const std::string &text); + static std::vector getTitleInfos(const std::string &titleId, bool women); // Get the Localized name of a classification type - static const ucchar *getClassificationTypeLocalizedName(EGSPD::CClassificationType::TClassificationType type); + static const char *getClassificationTypeLocalizedName(EGSPD::CClassificationType::TClassificationType type); // Outpost name - static const ucchar *getOutpostLocalizedName(NLMISC::CSheetId id); + static const char *getOutpostLocalizedName(NLMISC::CSheetId id); // Outpost description - static const ucchar *getOutpostLocalizedDescription(NLMISC::CSheetId id); + static const char *getOutpostLocalizedDescription(NLMISC::CSheetId id); // Outpost building name - static const ucchar *getOutpostBuildingLocalizedName(NLMISC::CSheetId id); + static const char *getOutpostBuildingLocalizedName(NLMISC::CSheetId id); // Outpost building description - static const ucchar *getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id); + static const char *getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id); // Squad name - static const ucchar *getSquadLocalizedName(NLMISC::CSheetId id); + static const char *getSquadLocalizedName(NLMISC::CSheetId id); // Squad description - static const ucchar *getSquadLocalizedDescription(NLMISC::CSheetId id); + static const char *getSquadLocalizedDescription(NLMISC::CSheetId id); private: // constructor. @@ -149,8 +152,8 @@ private: struct TParamValue { - TParamType Type; - ucstring::size_type ReplacementPoint; + TParamType Type; + std::string::size_type ReplacementPoint; union { uint32 StringId; @@ -173,7 +176,7 @@ private: NLMISC::CBitMemStream Message; uint32 StringId; std::vector Params; - ucstring String; + std::string String; }; enum @@ -185,7 +188,7 @@ private: struct TStringWaiter { /// Pointer to the ucstring to fill - ucstring *Result; + std::string *Result; /// Pointer to the remover that contains this string reference const IStringWaiterRemover *Remover; }; @@ -194,7 +197,7 @@ private: /// Container for simple strings - typedef CHashMap TStringsContainer; + typedef CHashMap TStringsContainer; /// Container for dyn strings typedef CHashMap TDynStringsContainer; /// Container of string reference waiting for value. @@ -220,7 +223,7 @@ private: TStringCallbacksContainer _DynStringsCallbacks; // Return value for waiting string.. - static ucstring _WaitString; + static std::string _WaitString; // Singleton pattern implementation static CStringManagerClient *_Instance; @@ -243,7 +246,7 @@ private: struct CCacheString { uint32 StringId; - ucstring String; + std::string String; }; std::vector _CacheStringToSave; //@} @@ -253,41 +256,60 @@ private: { public: // The Name of the item - ucstring Name; + std::string Name; // The Women Name of the item - ucstring WomenName; + std::string WomenName; // Description of the item - ucstring Desc; + std::string Desc; // Optional Second description (For SBrick composition for example) - ucstring Desc2; + std::string Desc2; void serial(NLMISC::IStream &f) { - sint ver= f.serialVersion(1); - f.serial(Name); - if (ver >= 1) + sint ver = f.serialVersion(2); + if (ver >= 2) + { + f.serial(Name); f.serial(WomenName); - f.serial(Desc); - f.serial(Desc2); + f.serial(Desc); + f.serial(Desc2); + } + else + { + nlassert(f.isReading()); + ucstring name; + ucstring womenName; + ucstring desc; + ucstring desc2; + f.serial(name); + if (ver >= 1) + f.serial(womenName); + f.serial(desc); + f.serial(desc2); + Name = name.toUtf8(); + WomenName = womenName.toUtf8(); + Desc = desc.toUtf8(); + Desc2 = desc2.toUtf8(); + } } }; static bool _SpecItem_MemoryCompressed; static std::map _SpecItem_TempMap; - static std::vector _TitleWords; - static std::map _DynStrings; + static std::vector _TitleWords; + static std::map _DynStrings; static char *_SpecItem_Labels; - static ucchar *_SpecItem_NameDesc; + static char *_SpecItem_NameDesc; struct CItemLight { - char *Label; - ucchar *Name; - ucchar *WomenName; - ucchar *Desc; - ucchar *Desc2; + const char *Label; + const char *Name; + const char *WomenName; + const char *Desc; + const char *Desc2; }; struct CItemLightComp { @@ -299,9 +321,9 @@ private: static std::vector _SpecItems; - static const ucchar *getSpecialWord(const std::string &label, bool women = false); - static const ucchar *getSpecialDesc(const std::string &label); - static const ucchar *getSpecialDesc2(const std::string &label); + static const char *getSpecialWord(const std::string &label, bool women = false); + static const char *getSpecialDesc(const std::string &label); + static const char *getSpecialDesc2(const std::string &label); // Check Files for the Packed string. class CFileCheck @@ -377,9 +399,9 @@ class IStringWaitCallback { public: /// Overide this method to receive callback for string. - virtual void onStringAvailable(uint /* stringId */, const ucstring &/* value */) {} + virtual void onStringAvailable(uint /* stringId */, const std::string &/* value */) {} /// Overide this method to receive callback for dynamic string. - virtual void onDynStringAvailable(uint /* stringId */, const ucstring &/* value */) {} + virtual void onDynStringAvailable(uint /* stringId */, const std::string &/* value */) {} virtual ~IStringWaitCallback() { diff --git a/ryzom/client/src/timed_fx_manager.cpp b/ryzom/client/src/timed_fx_manager.cpp index b316f0ab5..c42928127 100644 --- a/ryzom/client/src/timed_fx_manager.cpp +++ b/ryzom/client/src/timed_fx_manager.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -204,7 +204,7 @@ CTimedFXManager::TFXGroupHandle CTimedFXManager::add(const std::vector //sint32 debugDay; if (!(fi.FXSheet && fi.FXSheet->Mode == CSeasonFXSheet::AlwaysStarted)) { - if (fi.FXSheet->Mode == CSeasonFXSheet::Spawn) + if (fi.FXSheet && fi.FXSheet->Mode == CSeasonFXSheet::Spawn) { // compute next spawn date float cycleLength = fi.FXSheet ? fi.FXSheet->CycleDuration : _DayLength; diff --git a/ryzom/client/src/user_entity.cpp b/ryzom/client/src/user_entity.cpp index 312fffca8..21e36737d 100644 --- a/ryzom/client/src/user_entity.cpp +++ b/ryzom/client/src/user_entity.cpp @@ -3,7 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) -// Copyright (C) 2013-2019 Jan BOON (Kaetemi) +// Copyright (C) 2013-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -2952,7 +2952,7 @@ bool CUserEntity::sit(bool s) // autowalk disabled UserControls.autowalkState(false); - const string msgName = "COMMAND:SIT"; + static const string msgName = "COMMAND:SIT"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -2967,7 +2967,7 @@ bool CUserEntity::sit(bool s) // display sit msg CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgUserIsSitting"); + string msg = CI18N::get("msgUserIsSitting"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); } @@ -2980,7 +2980,7 @@ bool CUserEntity::sit(bool s) { if(mode(MBEHAV::NORMAL)) { - const string msgName = "COMMAND:SIT"; + static const string msgName = "COMMAND:SIT"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -2995,7 +2995,7 @@ bool CUserEntity::sit(bool s) // display stand msg CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgUserIsStanding"); + string msg = CI18N::get("msgUserIsStanding"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); } @@ -3071,7 +3071,7 @@ void CUserEntity::setAFK(bool b, string afkTxt) } // send afk state - string msgName = "COMMAND:AFK"; + static const string msgName = "COMMAND:AFK"; CBitMemStream out; if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) { @@ -3085,15 +3085,15 @@ void CUserEntity::setAFK(bool b, string afkTxt) ucstring ucstr; ucstr.fromUtf8( afkTxt ); CBitMemStream outTxt; - msgName = "STRING:AFK_TXT"; - if( GenericMsgHeaderMngr.pushNameToStream(msgName,outTxt) ) + static const string msgNameTxt = "STRING:AFK_TXT"; + if( GenericMsgHeaderMngr.pushNameToStream(msgNameTxt,outTxt) ) { outTxt.serial( ucstr ); NetMngr.push( outTxt ); } else { - nlwarning("CUserEntity:setAFK: unknown message named '%s'.", msgName.c_str()); + nlwarning("CUserEntity:setAFK: unknown message named '%s'.", msgNameTxt.c_str()); } @@ -3115,7 +3115,7 @@ void CUserEntity::rollDice(sint16 min, sint16 max, bool local) } sint16 roll = min + (sint16)dice->rand(max-min); - ucstring msg = CI18N::get("msgRollDiceLocal"); + string msg = CI18N::get("msgRollDiceLocal"); strFindReplace(msg, "%min", toString(min)); strFindReplace(msg, "%max", toString(max)); strFindReplace(msg, "%roll", toString(roll)); @@ -3147,7 +3147,7 @@ bool CUserEntity::canEngageCombat() { // display "you can't fight while sitting" message) CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgCantFightSit"); + string msg = CI18N::get("msgCantFightSit"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); @@ -3158,7 +3158,7 @@ bool CUserEntity::canEngageCombat() { // display "you can't fight while swiming" message) CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgCantFightSwim"); + string msg = CI18N::get("msgCantFightSwim"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); @@ -3169,7 +3169,7 @@ bool CUserEntity::canEngageCombat() { // display "you can't fight while swimming" message) CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgCantFightRide"); + string msg = CI18N::get("msgCantFightRide"); string cat = getStringCategory(msg, msg); pIM->displaySystemInfo(msg, cat); @@ -4144,7 +4144,7 @@ void CUserEntity::switchVelocity(bool userRequest) // display message : your are running, you are walking CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg; + string msg; if( _Run ) msg = CI18N::get("msgUserIsRunning"); else diff --git a/ryzom/common/src/game_share/crypt.cpp b/ryzom/common/src/game_share/crypt.cpp index 1416cac52..5a2e99b9c 100644 --- a/ryzom/common/src/game_share/crypt.cpp +++ b/ryzom/common/src/game_share/crypt.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp b/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp index 5e46d9923..3568cf7d2 100644 --- a/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp +++ b/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp @@ -159,6 +159,16 @@ bool CGenericXmlMsgHeaderManager::pushNameToStream(const string &msgName, CBitMe return res; } +// +bool CGenericXmlMsgHeaderManager::pushNameToStream(const char *msgName, CBitMemStream &strm) +{ + bool res = (_Root->select(msgName, strm) != NULL); + + if (!res) nlwarning("pushNameToStream failed: Unknown message name '%s'", msgName); + + return res; +} + // void CGenericXmlMsgHeaderManager::popNameFromStream(string &resultName, CBitMemStream &strm) { diff --git a/ryzom/common/src/game_share/generic_xml_msg_mngr.h b/ryzom/common/src/game_share/generic_xml_msg_mngr.h index a6a6a7167..45a89ec8c 100644 --- a/ryzom/common/src/game_share/generic_xml_msg_mngr.h +++ b/ryzom/common/src/game_share/generic_xml_msg_mngr.h @@ -231,6 +231,14 @@ public: */ bool pushNameToStream(const std::string &msgName, NLMISC::CBitMemStream &strm); + /** + * Convert and write a Message Name into a stream. + * \param string msgName : Message Name to convert and write into the stream. + * \param CBitMemStream strm : the stream to receive the Message Name. + * \return bool : 'false' if the method cannot write the message Name into the stream (probably because de message name is wrong). + */ + bool pushNameToStream(const char *msgName, NLMISC::CBitMemStream &strm); + /** * Convert and return the Message Name from a stream. * \param string resultName: The result for the Message Name. diff --git a/ryzom/common/src/game_share/mirrored_data_set.cpp b/ryzom/common/src/game_share/mirrored_data_set.cpp index 8db024784..61c7dc08b 100644 --- a/ryzom/common/src/game_share/mirrored_data_set.cpp +++ b/ryzom/common/src/game_share/mirrored_data_set.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2016 Jan BOON (Kaetemi) +// Copyright (C) 2016-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/msg_client_server.h b/ryzom/common/src/game_share/msg_client_server.h index 08dc0e171..c66e7856a 100644 --- a/ryzom/common/src/game_share/msg_client_server.h +++ b/ryzom/common/src/game_share/msg_client_server.h @@ -633,7 +633,7 @@ public: uint8 ChatMode; // uint32 DynChatChanID; NLMISC::CEntityId DynChatChanID; - ucstring Content; + ucstring Content; // FIXME: UTF-8 (serial) CChatMsg() { @@ -650,7 +650,7 @@ public: f.serial( ChatMode ); if(ChatMode==CChatGroup::dyn_chat) f.serial(DynChatChanID); - f.serial( Content ); + f.serial( Content ); // FIXME: UTF-8 (serial) } }; @@ -669,7 +669,7 @@ public: uint32 SenderNameId; uint8 ChatMode; uint32 PhraseId; - ucstring CustomTxt; + ucstring CustomTxt; // FIXME: UTF-8 (serial) CChatMsg2() { @@ -685,7 +685,7 @@ public: f.serial( SenderNameId ); f.serial( ChatMode ); f.serial( PhraseId ); - f.serial( CustomTxt ); + f.serial( CustomTxt ); // FIXME: UTF-8 (serial) } }; @@ -700,8 +700,8 @@ public: class CFarTellMsg { public: - ucstring SenderName; - ucstring Text; + ucstring SenderName; // FIXME: UTF-8 (serial) + ucstring Text; // FIXME: UTF-8 (serial) void serial(NLMISC::CBitMemStream &f) { diff --git a/ryzom/common/src/game_share/object.cpp b/ryzom/common/src/game_share/object.cpp index bb92c4936..51e5e3ef6 100644 --- a/ryzom/common/src/game_share/object.cpp +++ b/ryzom/common/src/game_share/object.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2016 Jan BOON (Kaetemi) +// Copyright (C) 2016-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/object.h b/ryzom/common/src/game_share/object.h index 806d790aa..5b8c1c45d 100644 --- a/ryzom/common/src/game_share/object.h +++ b/ryzom/common/src/game_share/object.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2019 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/ryzom/common/src/game_share/rm_family.cpp b/ryzom/common/src/game_share/rm_family.cpp index a45793aad..cae184117 100644 --- a/ryzom/common/src/game_share/rm_family.cpp +++ b/ryzom/common/src/game_share/rm_family.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -118,7 +121,7 @@ namespace RM_FABER_TYPE } /// Client: use the CI18N - const ucstring& toLocalString( TRMFType e ) + const std::string& toLocalString( TRMFType e ) { return CI18N::get("mpft" + toString(e)); } @@ -134,7 +137,7 @@ namespace RM_FABER_TYPE namespace RM_FAMILY { /// Get the Localized UCString - const ucstring& toLocalString( TRMFamily e ) + const std::string& toLocalString( TRMFamily e ) { return CI18N::get("mpfam" + toString(e)); } @@ -144,7 +147,7 @@ namespace RM_FAMILY namespace RM_GROUP { /// Get the Localized UCString - const ucstring& toLocalString( TRMGroup e ) + const std::string& toLocalString( TRMGroup e ) { return CI18N::get("mpgroup" + toString(e)); } @@ -154,7 +157,7 @@ namespace RM_GROUP namespace RM_FABER_PROPERTY { /// Get the Localized UCString - const ucstring& toLocalString( TRMFProperty e ) + const std::string& toLocalString( TRMFProperty e ) { return CI18N::get("mpprop" + toString(e)); } @@ -188,7 +191,7 @@ namespace RM_FABER_QUALITY } /// Client: use the CI18N - const ucstring& toLocalString( TFaberQuality e ) + const std::string& toLocalString( TFaberQuality e ) { return CI18N::get("mpfq" + toString(e)); } @@ -224,7 +227,7 @@ namespace RM_COLOR } /// Get the Localized UCString - const ucstring& toLocalString( sint value ) + const std::string& toLocalString( sint value ) { return CI18N::get("mpcol" + toString(value)); } @@ -283,7 +286,7 @@ namespace RM_FABER_STAT_TYPE return conversion.toString(stats); } - const ucstring& toLocalString( TRMStatType stats ) + const std::string& toLocalString( TRMStatType stats ) { // must change en.uxt nlctassert(NumRMStatType == sizeof(stringTable)/sizeof(stringTable[0])); @@ -663,9 +666,9 @@ namespace RM_FABER_STAT_TYPE namespace RM_CLASS_TYPE { -const ucstring &toLocalString(TRMClassType classType) +const std::string &toLocalString(TRMClassType classType) { - return CI18N::get(toString("uiItemRMClass%d", classType).c_str()); + return CI18N::get(toString("uiItemRMClass%d", classType)); } diff --git a/ryzom/common/src/game_share/rm_family.h b/ryzom/common/src/game_share/rm_family.h index a69a51517..627969214 100644 --- a/ryzom/common/src/game_share/rm_family.h +++ b/ryzom/common/src/game_share/rm_family.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -85,7 +88,7 @@ namespace RM_FABER_TYPE const std::string &faberTypeToSheetEntry(TRMFType type); /// Get the Localized UCString - const ucstring& toLocalString( TRMFType e ); + const std::string& toLocalString( TRMFType e ); /// For Client Interface, return the define name of the type (eg: "item_part_icon_MpL") std::string toIconDefineString( TRMFType e ); @@ -101,7 +104,7 @@ namespace RM_FAMILY const TRMFamily Unknown = 0; /// Get the Localized UCString - const ucstring& toLocalString( TRMFamily e ); + const std::string& toLocalString( TRMFamily e ); /// Debug string inline std::string toString( TRMFamily e ) { return NLMISC::toString(e); } @@ -119,7 +122,7 @@ namespace RM_GROUP const TRMGroup Unknown = 0; /// Get the Localized UCString - const ucstring& toLocalString( TRMGroup e ); + const std::string& toLocalString( TRMGroup e ); // Note: the group names are accessible on server by CMP::rmGroupToString() @@ -138,7 +141,7 @@ namespace RM_FABER_PROPERTY const TRMFProperty Unknown = 0; /// Get the Localized UCString - const ucstring& toLocalString( TRMFProperty e ); + const std::string& toLocalString( TRMFProperty e ); /// Debug string inline std::string toString( TRMFProperty e ) { return NLMISC::toString(e); } @@ -178,7 +181,7 @@ namespace RM_FABER_QUALITY TFaberQuality toFaberQuality( const std::string& str ); /// Get the Localized UCString - const ucstring& toLocalString( TFaberQuality e ); + const std::string& toLocalString( TFaberQuality e ); } @@ -199,7 +202,7 @@ namespace RM_COLOR const std::string& toString( sint value ); /// Get the Localized UCString - const ucstring& toLocalString( sint value ); + const std::string& toLocalString( sint value ); }; @@ -251,7 +254,7 @@ namespace RM_FABER_STAT_TYPE const std::string& toString( TRMStatType stats ); /// Get the Localized UCString - const ucstring& toLocalString( TRMStatType stats ); + const std::string& toLocalString( TRMStatType stats ); /// For each Raw material faber type, does this Stat is relevant? bool isStatRelevant(RM_FABER_TYPE::TRMFType ft, TRMStatType fs); @@ -309,7 +312,7 @@ namespace RM_CLASS_TYPE }; /// Get the Localized UCString - const ucstring& toLocalString( TRMClassType classType ); + const std::string& toLocalString( TRMClassType classType ); /// return the item class for a given stat energy [0..100] inline TRMClassType getItemClass(uint32 energy) diff --git a/ryzom/common/src/game_share/roles.cpp b/ryzom/common/src/game_share/roles.cpp index 57ccfdcd4..f4471183a 100644 --- a/ryzom/common/src/game_share/roles.cpp +++ b/ryzom/common/src/game_share/roles.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -73,7 +76,7 @@ ERole toRoleId( const std::string& Role ) } // Return the Translated name of the Job -const ucstring &roleToUCString (ERole r) +const std::string &roleToUCString(ERole r) { return NLMISC::CI18N::get( toString( r ) ); } diff --git a/ryzom/common/src/game_share/roles.h b/ryzom/common/src/game_share/roles.h index 9164a3254..226a4d3c6 100644 --- a/ryzom/common/src/game_share/roles.h +++ b/ryzom/common/src/game_share/roles.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -60,7 +63,7 @@ const std::string& toString( ERole r ); ERole toRoleId( const std::string& Role ); // Return the Translated name of the Job -const ucstring &roleToUCString (ERole r); +const std::string &roleToUCString (ERole r); } // ROLES diff --git a/ryzom/common/src/game_share/server_animation_module.cpp b/ryzom/common/src/game_share/server_animation_module.cpp index 3c3276130..634d518c3 100644 --- a/ryzom/common/src/game_share/server_animation_module.cpp +++ b/ryzom/common/src/game_share/server_animation_module.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/ryzom/common/src/game_share/time_weather_season/weather_function.cpp b/ryzom/common/src/game_share/time_weather_season/weather_function.cpp index 02432142f..e43561da1 100644 --- a/ryzom/common/src/game_share/time_weather_season/weather_function.cpp +++ b/ryzom/common/src/game_share/time_weather_season/weather_function.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -37,7 +40,7 @@ CWeatherFunction::CWeatherFunction() void CWeatherFunction::buildFromSheet(const CWeatherFunctionSheet &sheet, const CWeatherManager &wm) { // copy common part of objects (parameters) - *static_cast(this) = *static_cast(&sheet); + static_cast(*this) = static_cast(sheet); // get pointer on the setup from their names _WeatherSetups.resize(sheet.SetupNames.size()); nlassert(sheet.SetupWeights.size() == sheet.SetupNames.size()); diff --git a/ryzom/common/src/game_share/timer.h b/ryzom/common/src/game_share/timer.h index 1659464fa..8f7ed63dd 100644 --- a/ryzom/common/src/game_share/timer.h +++ b/ryzom/common/src/game_share/timer.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/ryzom/common/src/game_share/utils.h b/ryzom/common/src/game_share/utils.h index a534b156b..cb22574a4 100644 --- a/ryzom/common/src/game_share/utils.h +++ b/ryzom/common/src/game_share/utils.h @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2010 Matt RAYKOWSKI (sfb) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/common/src/game_share/visual_slot_manager.h b/ryzom/common/src/game_share/visual_slot_manager.h index 4fd46cd81..de1a5634a 100644 --- a/ryzom/common/src/game_share/visual_slot_manager.h +++ b/ryzom/common/src/game_share/visual_slot_manager.h @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -53,7 +56,7 @@ public: static void releaseInstance(); public: - typedef struct + typedef struct TElement { uint32 Index; NLMISC::CSheetId SheetId; @@ -66,7 +69,7 @@ public: } } TElement; - typedef struct + typedef struct TElementList { // elements list for a visual slot. std::vector Element; diff --git a/ryzom/tools/client/client_config_qt/src/general_settings_widget.cpp b/ryzom/tools/client/client_config_qt/src/general_settings_widget.cpp index f38e5299b..3ba0d9bf3 100644 --- a/ryzom/tools/client/client_config_qt/src/general_settings_widget.cpp +++ b/ryzom/tools/client/client_config_qt/src/general_settings_widget.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -42,13 +45,13 @@ void CGeneralSettingsWidget::load() CSystem &s = CSystem::GetInstance(); std::vector codes = NLMISC::CI18N::getLanguageCodes(); - std::vector names = NLMISC::CI18N::getLanguageNames(); + std::vector names = NLMISC::CI18N::getLanguageNames(); languageComboBox->clear(); for(uint i = 0; i < codes.size(); ++i) { - languageComboBox->addItem(QString::fromUtf16(names[i].c_str()), QString::fromUtf8(codes[i].c_str())); + languageComboBox->addItem(QString::fromUtf8(names[i].c_str()), QString::fromUtf8(codes[i].c_str())); } sint32 cbIndex = getIndexForLanguageCode( QString::fromUtf8( s.config.getString( "LanguageCode" ).c_str() ) ); diff --git a/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp b/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp index 673c12d9a..24d2bec98 100644 --- a/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp +++ b/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -187,7 +187,7 @@ BOOL CFileTreeCtrl::OnNotify ( WPARAM wParam, LPARAM lParam, LRESULT* pResult ) { LPNMHDR pnmh = (LPNMHDR) lParam; // Tree ? - if (wParam == 0) + // if (wParam == 0) { switch (pnmh->code) { diff --git a/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp b/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp index a4d35fdcc..9d3b4df65 100644 --- a/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp +++ b/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -720,6 +720,8 @@ void CFormDialog::onLastFocus () int CFormDialog::getWidget (uint dialogId) const { + if (dialogId == 0xFFFE) + dialogId = 0; for (uint i=0; iisDialog (dialogId)) @@ -1198,6 +1200,11 @@ void CFormDialog::onGetSubFocus (uint id) { // Get the widget int widget = getWidget (id); + if (widget < 0) + { + nldebug("Invalid widget id %d", (int)id); + return; + } WidgetFocused = widget; // Window view @@ -1584,7 +1591,7 @@ void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, { // Create the mem combobox parent->setComboSpinSize (currentPos); - Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); + Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE, reg, theApp.RememberListSize); parent->initWidget (Combo); // Create the spin @@ -1599,7 +1606,7 @@ void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, { // Create the mem combobox parent->setComboBrowseSize (currentPos); - Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); + Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE, reg, theApp.RememberListSize); parent->initWidget (Combo); // Create the spin @@ -1621,7 +1628,7 @@ void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, { // Create the mem combobox parent->setComboSize (currentPos, parent->SmallWidget); - Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); + Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE, reg, theApp.RememberListSize); parent->initWidget (Combo); parent->getNextPos (currentPos); } @@ -1914,7 +1921,7 @@ void CFormCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, ui parent->setComboSize (currentPos, parent->SmallWidget); RECT comboPos = currentPos; parent->adjusteComboSize (comboPos); - Combo.Create (WS_CHILD|WS_VSCROLL|WS_VISIBLE|CBS_DROPDOWNLIST|CBS_HASSTRINGS|WS_CHILD|WS_TABSTOP, comboPos, parent, dialog_index); + Combo.Create (WS_CHILD|WS_VSCROLL|WS_VISIBLE|CBS_DROPDOWNLIST|CBS_HASSTRINGS|WS_CHILD|WS_TABSTOP, comboPos, parent, dialog_index ? dialog_index : 0xFFFE); parent->initWidget (Combo); parent->getNextPos (currentPos); @@ -2097,7 +2104,7 @@ void CFormBigEdit::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, // Create the mem combobox parent->setBigEditSize (currentPos, parent->SmallWidget); - Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_VSCROLL|ES_OEMCONVERT|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, parent, dialog_index); + Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_VSCROLL|ES_OEMCONVERT|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, parent, dialog_index ? dialog_index : 0xFFFE); parent->initWidget (Edit); parent->getNextPos (currentPos); @@ -2271,7 +2278,7 @@ void CColorEdit::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, ui // Create the mem combobox parent->setColorSize (currentPos, parent->SmallWidget); - Color.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); + Color.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE); parent->initWidget (Color); // Create the reset button @@ -2501,7 +2508,7 @@ void CListWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, u // Create the mem combobox parent->setListSize (currentPos, parent->SmallWidget); - ListCtrl.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); + ListCtrl.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE); parent->initWidget (ListCtrl); parent->getNextPos (currentPos); @@ -2759,7 +2766,7 @@ void CIconWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, u // Create the mem combobox parent->setEditSize (currentPos, parent->IconHeight, parent->IconHeight); - Icon.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); + Icon.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index ? dialog_index : 0xFFFE); parent->initWidget (Icon); parent->getNextPos (currentPos); diff --git a/ryzom/tools/leveldesign/mission_compiler_lib/main.cpp b/ryzom/tools/leveldesign/mission_compiler_lib/main.cpp index 6c4285d46..6f32fbd8c 100644 --- a/ryzom/tools/leveldesign/mission_compiler_lib/main.cpp +++ b/ryzom/tools/leveldesign/mission_compiler_lib/main.cpp @@ -1,6 +1,9 @@ // Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/ryzom/tools/leveldesign/mp_generator/main.cpp b/ryzom/tools/leveldesign/mp_generator/main.cpp index 150807f5c..f265ccc05 100644 --- a/ryzom/tools/leveldesign/mp_generator/main.cpp +++ b/ryzom/tools/leveldesign/mp_generator/main.cpp @@ -3,6 +3,7 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) +// Copyright (C) 2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp b/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp index 0140452b5..c57536fd3 100644 --- a/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp +++ b/ryzom/tools/leveldesign/world_editor/world_editor/world_editor.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2019 Jan BOON (Kaetemi) +// Copyright (C) 2019-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp b/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp index 3062878ed..f5c3971d9 100644 --- a/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp +++ b/ryzom/tools/sheets_packer_shard/sheets_packer_shard.cpp @@ -1,5 +1,5 @@ // NeL - MMORPG Framework -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/ryzom/tools/translation_tools/main.cpp b/ryzom/tools/translation_tools/main.cpp index 4f65df260..dc91079f3 100644 --- a/ryzom/tools/translation_tools/main.cpp +++ b/ryzom/tools/translation_tools/main.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2014 Jan BOON (Kaetemi) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/studio/src/plugins/bnp_manager/bnp_manager_window.cpp b/studio/src/plugins/bnp_manager/bnp_manager_window.cpp index 9a4af0cd5..5dc19ff8f 100644 --- a/studio/src/plugins/bnp_manager/bnp_manager_window.cpp +++ b/studio/src/plugins/bnp_manager/bnp_manager_window.cpp @@ -1,6 +1,9 @@ // Object Viewer Qt - BNP Manager Plugin - MMORPG Framework // Copyright (C) 2011 Roland WINKLMEIER // +// This source file has been modified by the following contributors: +// Copyright (C) 2020 Jan BOON (Kaetemi) +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the diff --git a/studio/src/plugins/core/general_settings_page.cpp b/studio/src/plugins/core/general_settings_page.cpp index 6fb51b128..af2ede1b7 100644 --- a/studio/src/plugins/core/general_settings_page.cpp +++ b/studio/src/plugins/core/general_settings_page.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/studio/src/plugins/georges_editor/georges_editor_form.cpp b/studio/src/plugins/georges_editor/georges_editor_form.cpp index 009d2a6f0..89d8dfd19 100644 --- a/studio/src/plugins/georges_editor/georges_editor_form.cpp +++ b/studio/src/plugins/georges_editor/georges_editor_form.cpp @@ -4,6 +4,7 @@ // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp b/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp index 014b6c6ba..b6b6a8f92 100644 --- a/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -3,8 +3,8 @@ // // This source file has been modified by the following contributors: // Copyright (C) 2012 Matt RAYKOWSKI (sfb) -// Copyright (C) 2014 Jan BOON (Kaetemi) // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) +// Copyright (C) 2014-2020 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as diff --git a/tool/attribution/annotate.py b/tool/attribution/annotate.py index 80d530650..6029f9aeb 100644 --- a/tool/attribution/annotate.py +++ b/tool/attribution/annotate.py @@ -1,5 +1,5 @@ # -# Copyright (C) 2019 Jan BOON +# Copyright (C) 2019-2020 Jan BOON # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -45,7 +45,7 @@ from datetime import datetime from pathlib import Path from git import Repo -repo = Repo("../../..") +repo = Repo("../..") # Mapping for author short name to full display name authors = { } @@ -83,6 +83,7 @@ authors["etrange"] = "StudioEtrange " authors["sircotare"] = "SirCotare" authors["rolandw"] = "Roland WINKLMEIER " authors["thibg"] = "Thibaut GIRKA (ThibG) " # LibVR support +authors["xtarsia"] = "Xtarsia" # Mapping from git author name to short name, dash to ignore author short_authors = { } @@ -164,6 +165,8 @@ short_authors["cemycc "] = "cemycc" short_authors["cemycc"] = "cemycc" short_authors["Thibaut Girka "] = "thibg" short_authors["Thibaut Girka (ThibG)"] = "thibg" +short_authors["Xtarsia <69606701+Xtarsia@users.noreply.github.com>"] = "xtarsia" +short_authors["Xtarsia"] = "xtarsia" # short_authors["\"picomancer ext:(%22) "] = "-" # short_authors["Quitta"] = "-" # short_authors["Krolock"] = "-" @@ -206,12 +209,12 @@ override_author["dc734ed66226b257becae9fcd140898e14510e6a"] = "-" # Header clean # Exclude some paths exclude_paths = { } -exclude_paths["code/nel/3rdparty"] = True -exclude_paths["code/nel/src/3d/driver/opengl/GL"] = True -exclude_paths["code/nel/src/3d/driver/opengl/EGL"] = True -exclude_paths["code/nel/src/3d/driver/opengl/GLES"] = True -exclude_paths["code/nel/src/3d/driver/opengl/KHR"] = True -exclude_paths["code/studio/src/3rdparty"] = True +exclude_paths["nel/3rdparty"] = True +exclude_paths["nel/src/3d/driver/opengl/GL"] = True +exclude_paths["nel/src/3d/driver/opengl/EGL"] = True +exclude_paths["nel/src/3d/driver/opengl/GLES"] = True +exclude_paths["nel/src/3d/driver/opengl/KHR"] = True +exclude_paths["studio/src/3rdparty"] = True # Programmatical remappings def remap_author(blob, commit, author): @@ -234,7 +237,7 @@ def remap_author(blob, commit, author): short_author = "winch_gate" if short_author == "sircotare" and authored_date.year >= 2012: short_author = "winch_gate" - if short_author == "inky": + if short_author == "inky" and authored_date.year < 2020: short_author = "winch_gate" if "feature-export-assimp" in commit.message and authored_date.year <= 2015: # Project paid for by Winch Gate @@ -334,7 +337,7 @@ def rewrite_cpp(path, copyright_oldest, copyright_newest, copyright_lines): # Everything before the first "// Copyright" remains intact # Parse existing notices, merge with lists, track which one is first # Write out new copyright and modification notices - contents = Path("../../../" + path).read_text() + contents = Path("../../" + path).read_text() content_start = contents.find("// This program is free software") if content_start < 0: header_not_found[path] = True @@ -431,7 +434,7 @@ def rewrite_cpp(path, copyright_oldest, copyright_newest, copyright_lines): new_contents = contents[0:copyright_start] + new_statement + contents[content_start:] if contents != new_contents: print(new_statement) - Path("../../../" + path).write_text(new_contents) + Path("../../" + path).write_text(new_contents) def process_cpp(cpp_entry): print(cpp_entry.path)