From a08a666e58da7b9ae88aa5888eea8b2f5dc80067 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 16 Jun 2012 22:21:14 +0200 Subject: [PATCH] CHANGED: #1471 moved some ucstring handling code to the NELGUI library ( required for CViewText ) --- code/nel/include/nel/gui/string_case.h | 29 ++++++ code/nel/src/gui/string_case.cpp | 99 +++++++++++++++++++ code/ryzom/client/src/client_chat_manager.cpp | 2 + code/ryzom/client/src/connection.cpp | 2 + .../client/src/interface_v3/guild_manager.cpp | 2 + .../src/interface_v3/inventory_manager.cpp | 2 + .../src/interface_v3/people_interraction.cpp | 2 + .../client/src/interface_v3/view_text.cpp | 11 +-- .../ryzom/client/src/interface_v3/view_text.h | 6 +- code/ryzom/client/src/login.cpp | 2 + code/ryzom/client/src/misc.cpp | 94 ------------------ code/ryzom/client/src/misc.h | 18 ---- 12 files changed, 145 insertions(+), 124 deletions(-) create mode 100644 code/nel/include/nel/gui/string_case.h create mode 100644 code/nel/src/gui/string_case.cpp diff --git a/code/nel/include/nel/gui/string_case.h b/code/nel/include/nel/gui/string_case.h new file mode 100644 index 000000000..9788bbf9e --- /dev/null +++ b/code/nel/include/nel/gui/string_case.h @@ -0,0 +1,29 @@ +#ifndef STRING_CASE_H +#define STRING_CASE_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/ucstring.h" + +namespace NLGUI +{ + + enum TCaseMode + { + CaseNormal = 0, // Nothing done + CaseLower, // All letters in lowercase + CaseUpper, // All letters in uppercase + CaseFirstStringLetterUp, // The first letter of the string is uppercase, the others are lowercase + CaseFirstSentenceLetterUp, // The first letter of the string and each sentences are uppercase, the others are lowercase. Sentences are seprated with '.'. + CaseFirstWordLetterUp, // The first letter of each word is uppercase, the others are lowercase + CaseCount + }; + + + void setCase( ucstring &str, TCaseMode mode ); + + +} + +#endif + + diff --git a/code/nel/src/gui/string_case.cpp b/code/nel/src/gui/string_case.cpp new file mode 100644 index 000000000..193716f12 --- /dev/null +++ b/code/nel/src/gui/string_case.cpp @@ -0,0 +1,99 @@ +#include "nel/gui/string_case.h" + +namespace NLGUI +{ + inline bool isSeparator (ucchar c) + { + return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'); + } + + // *************************************************************************** + + inline bool isEndSentence (ucstring& str, uint index) + { + // Ex: One sentence. Another sentence. + // ^ + // Counterexample: nevrax.com + // ^ + ucchar c = str[index]; + if ((str[index] == ' ') || (str[index] == '\n')) + { + if (index < 1) + return false; + c = str[index-1]; + return (c == '.') || (c == '!') || (c == '?'); + } + return false; + } + + + void setCase( ucstring &str, TCaseMode mode ) + { + const uint length = (uint)str.length(); + uint i; + bool newString = true; + bool newSentence = true; + bool newWord = true; + switch (mode) + { + case CaseLower: + str = NLMISC::toLower (str); + break; + case CaseUpper: + str = NLMISC::toUpper (str); + break; + case CaseFirstStringLetterUp: + for (i=0; i +#include "../misc.h" + using namespace NLMISC; using namespace std; diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index af81274c1..b58ca9eaa 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -14,21 +14,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "nel/misc/bit_mem_stream.h" #include "nel/misc/i18n.h" #include "view_text.h" #include "interface_manager.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/widget_manager.h" #include "group_container.h" // CCtrlResizer #include "nel/gui/ctrl_tooltip.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/lua_ihm.h" -#include "lua_ihm_ryzom.h" using namespace std; using namespace NLMISC; @@ -2415,7 +2412,7 @@ void CViewText::setTextFormatTaged(const ucstring &text) // color format is available only if multilined if (!_MultiLine) - CLuaIHMRyzom::debugInfo(toString("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.toString().c_str())); + nlwarning( toString("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.toString().c_str()).c_str() ); } @@ -2472,7 +2469,7 @@ void CViewText::setSingleLineTextFormatTaged(const ucstring &text) // this color format is available only if not multilined if (_MultiLine) - CLuaIHMRyzom::debugInfo(toString("ViewText is multilined : uc_hardtext_single_line_format will not act as wanted !\n%s", text.toString().c_str())); + nlwarning( toString("ViewText is multilined : uc_hardtext_single_line_format will not act as wanted !\n%s", text.toString().c_str()).c_str() ); } diff --git a/code/ryzom/client/src/interface_v3/view_text.h b/code/ryzom/client/src/interface_v3/view_text.h index 623e2c2aa..9fe54825b 100644 --- a/code/ryzom/client/src/interface_v3/view_text.h +++ b/code/ryzom/client/src/interface_v3/view_text.h @@ -20,7 +20,7 @@ #define NL_VIEW_TEXT_H #include "nel/gui/view_base.h" -#include "../misc.h" +#include "nel/gui/string_case.h" #include "nel/3d/u_text_context.h" namespace NLGUI @@ -408,10 +408,6 @@ private: void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const; }; -// change case of a string -void setCase (ucstring &str, TCaseMode mode); - - #endif // NL_VIEW_TEXT_H /* End of view_text.h */ diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index c981f083f..0b96b0782 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -60,6 +60,8 @@ #include "game_share/crypt.h" #include "game_share/bg_downloader_msg.h" +#include "misc.h" + void ConnectToShard(); // *************************************************************************** diff --git a/code/ryzom/client/src/misc.cpp b/code/ryzom/client/src/misc.cpp index 2dd72ad52..bb8cc7387 100644 --- a/code/ryzom/client/src/misc.cpp +++ b/code/ryzom/client/src/misc.cpp @@ -976,100 +976,6 @@ std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest) } -// *************************************************************************** - -inline bool isSeparator (ucchar c) -{ - return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'); -} - -// *************************************************************************** - -inline bool isEndSentence (ucstring& str, uint index) -{ - // Ex: One sentence. Another sentence. - // ^ - // Counterexample: nevrax.com - // ^ - ucchar c = str[index]; - if ((str[index] == ' ') || (str[index] == '\n')) - { - if (index < 1) - return false; - c = str[index-1]; - return (c == '.') || (c == '!') || (c == '?'); - } - return false; -} - - -void setCase (ucstring &str, TCaseMode mode) -{ - const uint length = (uint)str.length(); - uint i; - bool newString = true; - bool newSentence = true; - bool newWord = true; - switch (mode) - { - case CaseLower: - str = toLower (str); - break; - case CaseUpper: - str = toUpper (str); - break; - case CaseFirstStringLetterUp: - for (i=0; i