Merge branch 'develop' into ryzomclassic-develop

ryzomclassic-develop
kaetemi 4 years ago
commit e773027c6d

@ -68,6 +68,7 @@ namespace NLGUI
void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; } void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; }
void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; } void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; }
void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; } void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; }
void 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 setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); }
void setUserType(CInterfaceExprUserType *value); void setUserType(CInterfaceExprUserType *value);
// reset this object to initial state (no type) // reset this object to initial state (no type)

@ -61,8 +61,11 @@ namespace NLGUI
// TEMP PATCH // TEMP PATCH
void setCursor (const std::string &name) void setCursor (const std::string &name)
{ {
_TxDefault = name; if (_TxDefault != name)
_TxIdDefault = -2; {
_TxDefault = name;
_TxIdDefault = -2;
}
} }
// TEMP PATCH // TEMP PATCH

@ -84,8 +84,10 @@ namespace NLGUI
/// Set /// Set
void setText(const std::string &text); //< Not localized. Use setHardText to localize strings starting with "ui". TODO: Add a Localize flag, like title in group container. HardText then simply sets localize to true. void setText(const std::string &text);
void setTextLocalized(const std::string &text, bool localized);
void setTextAsUtf16 (const ucstring &text); void setTextAsUtf16 (const ucstring &text);
void setLocalized(bool localized);
void setFontName (const std::string &name); void setFontName (const std::string &name);
void setFontSize (sint nFontSize, bool coef = true); void setFontSize (sint nFontSize, bool coef = true);
void setEmbolden (bool nEmbolden); void setEmbolden (bool nEmbolden);
@ -114,9 +116,10 @@ namespace NLGUI
void disableStringSelection(); void disableStringSelection();
/// Get /// Get
std::string getText() const { return _Text; } std::string getText() const { return _HardText.empty() ? _Text : _HardText; }
ucstring getTextAsUtf16() const; ucstring getTextAsUtf16() const;
ucstring getHardTextAsUtf16() const; ucstring getHardTextAsUtf16() const;
bool isLocalized() const { return _Localized; }
sint getFontSize() const; sint getFontSize() const;
std::string getFontName() const { return _FontName; } std::string getFontName() const { return _FontName; }
bool getEmbolden() { return _Embolden; } bool getEmbolden() { return _Embolden; }
@ -224,6 +227,7 @@ namespace NLGUI
REFLECT_EXPORT_START(CViewText, CViewBase) REFLECT_EXPORT_START(CViewText, CViewBase)
REFLECT_STRING("text_raw", getText, setText); REFLECT_STRING("text_raw", getText, setText);
REFLECT_STRING("hardtext", getHardText, setHardText); REFLECT_STRING("hardtext", getHardText, setHardText);
REFLECT_BOOL ("localize", isLocalized, setLocalized);
// REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions // REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions
REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16); REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16);
REFLECT_UCSTRING("uc_hardtext_format", getTextAsUtf16, setTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense REFLECT_UCSTRING("uc_hardtext_format", getTextAsUtf16, setTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense
@ -248,6 +252,7 @@ namespace NLGUI
std::string _HardText; std::string _HardText;
std::string _Text; std::string _Text;
mutable sint _TextLength; mutable sint _TextLength;
bool _Localized;
/// index of the computed String associated to this text control /// index of the computed String associated to this text control
uint _Index; uint _Index;
/// info on the computed String associated to this text control /// info on the computed String associated to this text control
@ -443,6 +448,8 @@ namespace NLGUI
void setup (); void setup ();
void setupDefault (); void setupDefault ();
void setTextLocalized(const std::string &text);
void setStringSelectionSkipingSpace(uint stringId, const std::string &text, sint charStart, sint charEnd); void setStringSelectionSkipingSpace(uint stringId, const std::string &text, sint charStart, sint charEnd);
// void pushString(const ucstring &str, bool deleteSpaceAtStart = false); // void pushString(const ucstring &str, bool deleteSpaceAtStart = false);

@ -240,6 +240,20 @@ std::string toUpper ( const char *str ); // UTF-8
std::string toUpper ( const std::string &str); // UTF-8 std::string toUpper ( const std::string &str); // UTF-8
void toUpper ( char *str); // Ascii only 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);
/** /**
* Convert to an hexadecimal std::string * Convert to an hexadecimal std::string

@ -254,9 +254,10 @@ inline bool fromString(const std::string &str, double &val) { bool ret = sscanf(
inline bool fromString(const std::string &str, wchar_t &val) { return fromString(str, reinterpret_cast<uint16 &>(val)); } inline bool fromString(const std::string &str, wchar_t &val) { return fromString(str, reinterpret_cast<uint16 &>(val)); }
#endif #endif
// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, anything else is undefined. /// 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.
// (str[0] == '1' || (str[0] & 0xD2) == 0x50) /// - Kaetemi
// - 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); bool fromString(const std::string &str, bool &val);

@ -597,12 +597,7 @@ namespace NLGUI
if (prop) if (prop)
{ {
const char *propPtr = prop; const char *propPtr = prop;
std::string text; _ViewText->setTextLocalized(propPtr, true);
if (NLMISC::startsWith(propPtr, "ui"))
text = CI18N::get(propPtr);
else
text = propPtr;
_ViewText->setText(text);
} }
} }

@ -2144,24 +2144,20 @@ namespace NLGUI
ptr = xmlGetProp (cur, (xmlChar*)"title"); ptr = xmlGetProp (cur, (xmlChar*)"title");
if (ptr) if (ptr)
{ {
if (_Localize) _TitleTextOpened = CI18N::get(string((const char*)ptr)); _TitleTextOpened = (const char *)ptr;
else _TitleTextOpened = string((const char*)ptr); _TitleTextClosed = (const char *)ptr;
if (_Localize) _TitleTextClosed = CI18N::get(string((const char*)ptr));
else _TitleTextClosed = string((const char*)ptr);
} }
ptr = xmlGetProp (cur, (xmlChar*)"title_opened"); ptr = xmlGetProp (cur, (xmlChar*)"title_opened");
if (ptr) if (ptr)
{ {
if (_Localize) _TitleTextOpened = CI18N::get(string((const char*)ptr)); _TitleTextOpened = (const char*)ptr;
else _TitleTextOpened = string((const char*)ptr);
} }
ptr = xmlGetProp (cur, (xmlChar*)"title_closed"); ptr = xmlGetProp (cur, (xmlChar*)"title_closed");
if (ptr) if (ptr)
{ {
if (_Localize) _TitleTextClosed = CI18N::get(string((const char*)ptr)); _TitleTextClosed = (const char *)ptr;
else _TitleTextClosed = string((const char*)ptr);
} }
ptr = xmlGetProp (cur, (xmlChar*)"header_active"); ptr = xmlGetProp (cur, (xmlChar*)"header_active");
@ -3950,8 +3946,14 @@ namespace NLGUI
void CGroupContainer::setLocalize(bool localize) void CGroupContainer::setLocalize(bool localize)
{ {
_Localize = localize; _Localize = localize;
setTitledOpenedViewText(); if (_TitleOpened)
setTitledClosedViewText(); {
_TitleOpened->setLocalized(localize);
}
if (_TitleClosed)
{
_TitleClosed->setLocalized(localize);
}
invalidateCoords(); invalidateCoords();
} }
@ -4001,10 +4003,7 @@ namespace NLGUI
{ {
if (_TitleOpened != NULL) if (_TitleOpened != NULL)
{ {
if (_Localize && NLMISC::startsWith(_TitleTextOpened, "ui")) _TitleOpened->setTextLocalized(_TitleTextOpened, _Localize);
_TitleOpened->setHardText(_TitleTextOpened);
else
_TitleOpened->setText(_TitleTextOpened);
} }
} }
@ -4013,10 +4012,7 @@ namespace NLGUI
{ {
if (_TitleClosed != NULL) if (_TitleClosed != NULL)
{ {
if (_Localize && NLMISC::startsWith(_TitleTextClosed, "ui")) _TitleClosed->setTextLocalized(_TitleTextClosed, _Localize);
_TitleClosed->setHardText(_TitleTextClosed);
else
_TitleClosed->setText(_TitleTextClosed);
} }
} }

@ -1580,7 +1580,7 @@ namespace NLGUI
_ViewText->setParent( this ); _ViewText->setParent( this );
_ViewText->setIdRecurse( "edit_text" ); _ViewText->setIdRecurse( "edit_text" );
_ViewText->setHardText( "" ); _ViewText->setTextLocalized( "", false );
_ViewText->setPosRef( Hotspot_ML ); _ViewText->setPosRef( Hotspot_ML );
_ViewText->setParentPosRef( Hotspot_ML ); _ViewText->setParentPosRef( Hotspot_ML );
addView( _ViewText ); addView( _ViewText );

@ -1036,21 +1036,16 @@ namespace NLGUI
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool CInterfaceElement::convertBool (const char *ptr) bool CInterfaceElement::convertBool (const char *ptr)
{ {
std::string str = toLower(ptr); return NLMISC::toBool(ptr);
bool b = false;
fromString( str, b );
return b;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
NLMISC::CVector CInterfaceElement::convertVector (const char *ptr) NLMISC::CVector CInterfaceElement::convertVector (const char *ptr)
{ {
float x = 0.0f, y = 0.0f, z = 0.0f; float x = 0.0f, y = 0.0f, z = 0.0f;
sscanf (ptr, "%f %f %f", &x, &y, &z); sscanf (ptr, "%f %f %f", &x, &y, &z);
return CVector(x,y,z); return CVector(x,y,z);
} }

@ -28,19 +28,19 @@
namespace NLGUI namespace NLGUI
{ {
inline bool isSeparator (u32char c) inline bool isSeparator (char c)
{ {
return (c == (u32char)' ') || (c == (u32char)'\t') || (c == (u32char)'\n') || (c == (u32char)'\r'); return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r');
} }
inline bool isEndSentence (u32char c, u32char lastChar) inline bool isEndSentence (char c, char lastChar)
{ {
// Ex: One sentence. Another sentence. // Ex: One sentence. Another sentence.
// ^ // ^
// Counterexample: nevrax.com // Counterexample: nevrax.com
// ^ // ^
return ((c == (u32char)' ') || (c == (u32char)'\n')) return ((c == ' ') || (c == '\n'))
&& (lastChar == (u32char)'.') || (lastChar == (u32char)'!') || (lastChar == (u32char)'?'); && ((lastChar == '.') || (lastChar == '!') || (lastChar == '?') || (lastChar == '\n'));
} }
void setCase(std::string &str, TCaseMode mode) void setCase(std::string &str, TCaseMode mode)
@ -60,85 +60,83 @@ namespace NLGUI
break; break;
case CaseFirstStringLetterUp: case CaseFirstStringLetterUp:
{ {
NLMISC::CUtfStringView sv(str);
std::string res; std::string res;
res.reserve(sv.largestSize()); res.reserve(str.size() + (str.size() >> 2));
for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();)
{ {
u32char c = *it; char c = str[i];
if (c < 0x10000) if (!isSeparator(c))
{ {
if (!isSeparator(c)) if (newString)
{ NLMISC::appendToUpper(res, str, i);
if (newString) else
c = NLMISC::toUpper((ucchar)c); NLMISC::appendToLower(res, str, i);
else newString = false;
c = NLMISC::toLower((ucchar)c); }
newString = false; else
} {
res += c;
++i;
} }
NLMISC::CUtfStringView::append(res, c);
} }
str = nlmove(res); str.swap(res);
break; break;
} }
case CaseFirstSentenceLetterUp: case CaseFirstSentenceLetterUp:
{ {
NLMISC::CUtfStringView sv(str);
std::string res; std::string res;
res.reserve(sv.largestSize()); res.reserve(str.size() + (str.size() >> 2));
u32char lastChar = 0; char lastChar = 0;
for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();)
{ {
u32char c = *it; char c = str[i];
if (c < 0x10000) if (isEndSentence(c, lastChar))
{ {
if (isEndSentence(c, lastChar)) newSentence = true;
newSentence = true; res += c;
++i;
}
else
{
if (newSentence)
NLMISC::appendToUpper(res, str, i);
else else
{ NLMISC::appendToLower(res, str, i);
if (newSentence)
c = NLMISC::toUpper((ucchar)c);
else
c = NLMISC::toLower((ucchar)c);
if (!isSeparator(c)) if (!isSeparator(c))
newSentence = false; newSentence = false;
}
} }
NLMISC::CUtfStringView::append(res, c);
lastChar = c; lastChar = c;
} }
str = nlmove(res); str.swap(res);
break; break;
} }
case CaseFirstWordLetterUp: case CaseFirstWordLetterUp:
{ {
NLMISC::CUtfStringView sv(str);
std::string res; std::string res;
res.reserve(sv.largestSize()); res.reserve(str.size() + (str.size() >> 2));
u32char lastChar = 0; char lastChar = 0;
for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();)
{ {
u32char c = *it; char c = str[i];
if (c < 0x10000) if (isSeparator(c) || isEndSentence(c, lastChar))
{
newWord = true;
res += c;
++i;
}
else
{ {
if (isSeparator(c) || isEndSentence(c, lastChar)) if (newWord)
newWord = true; NLMISC::appendToUpper(res, str, i);
else else
{ NLMISC::appendToLower(res, str, i);
if (newWord)
c = NLMISC::toUpper((ucchar)c);
else
c = NLMISC::toLower((ucchar)c);
newWord = false; newWord = false;
}
} }
NLMISC::CUtfStringView::append(res, c);
lastChar = c; lastChar = c;
} }
str = nlmove(res); str.swap(res);
break; break;
} }
default: default:

@ -207,7 +207,10 @@ namespace NLGUI
if (_TxIdDefault == -2) if (_TxIdDefault == -2)
{ {
_TxIdDefault = rVR.getTextureIdFromName (_TxDefault); _TxIdDefault = rVR.getTextureIdFromName(_TxDefault);
}
if (_TxIdMoveWindow == -2)
{
_TxIdMoveWindow = rVR.getTextureIdFromName (_TxMoveWindow); _TxIdMoveWindow = rVR.getTextureIdFromName (_TxMoveWindow);
_TxIdResizeBRTL = rVR.getTextureIdFromName (_TxResizeBRTL); _TxIdResizeBRTL = rVR.getTextureIdFromName (_TxResizeBRTL);
_TxIdResizeBLTR = rVR.getTextureIdFromName (_TxResizeBLTR); _TxIdResizeBLTR = rVR.getTextureIdFromName (_TxResizeBLTR);

@ -111,6 +111,8 @@ namespace NLGUI
_ClampRight = true; // clamp on the right of the text _ClampRight = true; // clamp on the right of the text
_OverflowText = "..."; _OverflowText = "...";
_Localized = true;
_LetterColors = NULL; _LetterColors = NULL;
_Setuped= false; _Setuped= false;
_AutoClampOffset = 0; _AutoClampOffset = 0;
@ -211,7 +213,7 @@ namespace NLGUI
_Index = 0xFFFFFFFF; _Index = 0xFFFFFFFF;
_ModulateGlobalColor= vt._ModulateGlobalColor; _ModulateGlobalColor= vt._ModulateGlobalColor;
_Localized = vt._Localized;
// remove previous lines // remove previous lines
clearLines(); clearLines();
@ -244,6 +246,11 @@ namespace NLGUI
std::string CViewText::getTextProperty( const std::string &name ) const std::string CViewText::getTextProperty( const std::string &name ) const
{ {
if( name == "localize" )
{
return toString(_Localized);
}
else
if( name == "color" ) if( name == "color" )
{ {
return toString( _Color ); return toString( _Color );
@ -418,6 +425,18 @@ namespace NLGUI
bool CViewText::setTextProperty( const std::string &name, const std::string &value ) 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" ) if( name == "color" )
{ {
CRGBA c; CRGBA c;
@ -649,28 +668,19 @@ namespace NLGUI
return true; return true;
} }
else else
if( name == "text" )
{
setTextLocalized(value); // FIXME: setCase?
_TextLength = 0;
invalidateContent();
return true;
}
else
if( name == "hardtext" ) if( name == "hardtext" )
{ {
#if 1 _Localized = true;
if (NLMISC::startsWith(value, "ui")) setTextLocalized(value); // FIXME: setCase?
{
_Text = CI18N::get(value);
_TextLength = 0;
_HardText = value;
}
else
{
_Text = value;
_TextLength = 0;
_HardText.clear();
}
#else
_Text = value;
_TextLength = 0; _TextLength = 0;
_HardText.clear();
if (NLMISC::startsWith(value, "ui"))
_HardText = _Text;
#endif
invalidateContent(); invalidateContent();
return true; return true;
} }
@ -705,6 +715,8 @@ namespace NLGUI
bool CViewText::serializeTextOptions( xmlNodePtr node ) const 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 "color", BAD_CAST toString( _Color ).c_str() );
xmlSetProp( node, BAD_CAST "global_color", BAD_CAST toString( _ModulateGlobalColor ).c_str() ); xmlSetProp( node, BAD_CAST "global_color", BAD_CAST toString( _ModulateGlobalColor ).c_str() );
@ -784,7 +796,7 @@ namespace NLGUI
serializeTextOptions( node ); serializeTextOptions( node );
xmlSetProp( node, BAD_CAST "hardtext", BAD_CAST _Text.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() ); xmlSetProp( node, BAD_CAST "hardtext_format", BAD_CAST _HardTextFormat.c_str() );
return node; return node;
@ -795,6 +807,9 @@ namespace NLGUI
{ {
CXMLAutoPtr prop; CXMLAutoPtr prop;
prop = xmlGetProp (cur, (xmlChar*)"localize");
if (prop) _Localized = convertBool((const char*)prop);
prop= (char*) xmlGetProp( cur, (xmlChar*)"color" ); prop= (char*) xmlGetProp( cur, (xmlChar*)"color" );
_Color = CRGBA(255,255,255,255); _Color = CRGBA(255,255,255,255);
if (prop) if (prop)
@ -1000,18 +1015,8 @@ namespace NLGUI
if (prop) if (prop)
{ {
const char *propPtr = prop; const char *propPtr = prop;
if (NLMISC::startsWith(propPtr, "ui")) _Localized = true;
{ setTextLocalized(propPtr);
_HardText = propPtr;
_Text = CI18N::get(propPtr);
_TextLength = 0;
}
else
{
_HardText.clear();
_Text = propPtr;
_TextLength = 0;
}
setCase(_Text, _CaseMode); setCase(_Text, _CaseMode);
_TextLength = 0; _TextLength = 0;
} }
@ -1424,49 +1429,109 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
void CViewText::setText(const std::string &text) void CViewText::setTextLocalized(const std::string &text, bool localized)
{ {
_HardText.clear(); if (localized != _Localized)
// common case: no special format, no case mode => easy cache test
if (_FormatTags.empty() && _CaseMode==CaseNormal)
{ {
if (text != _Text) _Localized = localized;
{
_Text = text; // Always recompute if localization and text changed
_TextLength = 0; setTextLocalized(text);
// no need to call "setCase (_Text, _CaseMode);" since CaseNormal: setCase(_Text, _CaseMode);
invalidateContent (); _TextLength = 0;
} invalidateContent();
} }
else else
{ {
// if the view text had some format before, no choice, must recompute all setText(text);
if (!_FormatTags.empty()) }
}
// ***************************************************************************
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"))
{ {
_Text = text; setTextLocalized(text);
setCase (_Text, _CaseMode); setCase(_Text, _CaseMode);
_TextLength = 0; _TextLength = 0;
invalidateContent (); invalidateContent();
}
// else test if after the case change the cache succeed
else
{
// compute the temp cased text
std::string tempText = text;
setCase (tempText, _CaseMode);
if (tempText != _Text)
{
_Text = tempText;
_TextLength = 0;
invalidateContent();
}
} }
} }
// clear format tags if any nlassert(_Text.empty() || ((_Localized && (NLMISC::startsWith(getText(), "ui"))) == (_HardText.empty() == _Text.empty())));
_FormatTags.clear(); }
// ***************************************************************************
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) void CViewText::setFontSizing(const std::string &chars, const std::string &fallback)
{ {
@ -2393,15 +2458,12 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CViewText::setHardText (const std::string &ht) void CViewText::setHardText (const std::string &ht)
{ {
if (NLMISC::startsWith(ht, "ui")) if (!_Localized)
{
setText(CI18N::get(ht));
_HardText = ht;
}
else
{ {
setText(ht); setText(std::string());
_Localized = true;
} }
setText(ht);
} }
// *************************************************************************** // ***************************************************************************
@ -3364,6 +3426,7 @@ namespace NLGUI
// Copy to Text (preserve Memory) // Copy to Text (preserve Memory)
contReset(_Text); contReset(_Text);
_Text = tempText; _Text = tempText;
_HardText.clear();
_TextLength = 0; _TextLength = 0;
CInterfaceGroup *parent = getParent(); CInterfaceGroup *parent = getParent();
@ -3474,6 +3537,7 @@ namespace NLGUI
// Copy to Text (preserve Memory) // Copy to Text (preserve Memory)
contReset(_Text); contReset(_Text);
_Text = tempText; _Text = tempText;
_HardText.clear();
_TextLength = 0; _TextLength = 0;
invalidateContent (); invalidateContent ();
} }
@ -3557,6 +3621,11 @@ namespace NLGUI
#define SERIAL_UINT(val) { uint32 tmp = (uint32) val; f.serial(tmp); val = (uint) tmp; } #define SERIAL_UINT(val) { uint32 tmp = (uint32) val; f.serial(tmp); val = (uint) tmp; }
#define SERIAL_SINT(val) { sint32 tmp = (sint32) val; f.serial(tmp); val = (sint) tmp; } #define SERIAL_SINT(val) { sint32 tmp = (sint32) val; f.serial(tmp); val = (sint) tmp; }
CViewBase::serial(f); CViewBase::serial(f);
int version = f.serialVersion(101);
nlassert(version >= 100);
f.serial(_Localized);
SERIAL_SINT(_FontSize); SERIAL_SINT(_FontSize);
SERIAL_UINT(_FontWidth); SERIAL_UINT(_FontWidth);
SERIAL_UINT(_FontHeight); SERIAL_UINT(_FontHeight);

@ -1210,6 +1210,7 @@ namespace NLGUI
sint32 backupX = groupOver->getX(); sint32 backupX = groupOver->getX();
// Copy all aspects to the view // Copy all aspects to the view
vtDst->setLocalized (vtSrc->isLocalized());
vtDst->setText (vtSrc->getText()); vtDst->setText (vtSrc->getText());
vtDst->setFontSize (vtSrc->getFontSize()); vtDst->setFontSize (vtSrc->getFontSize());
vtDst->setColor (vtSrc->getColor()); vtDst->setColor (vtSrc->getColor());

@ -4732,8 +4732,8 @@ static const char **s_UtfLowerToUpperMap[16] = {
NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrdiff_t &i) NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrdiff_t &i)
{ {
char c = str[i]; unsigned char c = str[i];
char d, e; unsigned char d, e;
if (c < 0x80) if (c < 0x80)
{ {
if (c >= 'A' && c <= 'Z') if (c >= 'A' && c <= 'Z')
@ -4752,7 +4752,7 @@ NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrd
if (table[idx]) if (table[idx])
{ {
res += &table[idx]; res += &table[idx];
++i; i += 2;
return; return;
} }
} }
@ -4770,20 +4770,23 @@ NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrd
if (table[idx]) if (table[idx])
{ {
res += &table[idx]; res += &table[idx];
i += 2; i += 3;
return; return;
} }
} }
} }
} }
res += c; res += c;
++i;
} }
// ***************************************************************************
std::string toLower(const char *str) std::string toLower(const char *str)
{ {
// UTF-8 toLower, tables generated from UTF-16 tables // UTF-8 toLower, tables generated from UTF-16 tables
std::string res; std::string res;
for (ptrdiff_t i = 0; str[i]; ++i) for (ptrdiff_t i = 0; str[i];)
appendToLowerAsUtf8(res, str, i); appendToLowerAsUtf8(res, str, i);
return res; return res;
} }
@ -4796,19 +4799,33 @@ std::string toLower(const std::string &str)
std::string res; std::string res;
res.reserve(str.size() + (str.size() >> 2)); res.reserve(str.size() + (str.size() >> 2));
const char *cstr = &str[0]; const char *cstr = &str[0];
for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size(); ++i) for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();)
appendToLowerAsUtf8(res, cstr, i); appendToLowerAsUtf8(res, cstr, i);
return res; 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) NL_FORCE_INLINE void appendToUpperAsUtf8(std::string &res, const char *str, ptrdiff_t &i)
{ {
char c = str[i]; unsigned char c = str[i];
char d, e; unsigned char d, e;
if (c < 0x80) if (c < 0x80)
{ {
if (c >= 'a' && c <= 'z') if (c >= 'a' && c <= 'z')
@ -4827,7 +4844,7 @@ NL_FORCE_INLINE void appendToUpperAsUtf8(std::string &res, const char *str, ptrd
if (table[idx]) if (table[idx])
{ {
res += &table[idx]; res += &table[idx];
++i; i += 2;
return; return;
} }
} }
@ -4845,13 +4862,14 @@ NL_FORCE_INLINE void appendToUpperAsUtf8(std::string &res, const char *str, ptrd
if (table[idx]) if (table[idx])
{ {
res += &table[idx]; res += &table[idx];
i += 2; i += 3;
return; return;
} }
} }
} }
} }
res += c; res += c;
++i;
} }
// *************************************************************************** // ***************************************************************************
@ -4860,7 +4878,7 @@ std::string toUpper(const char *str)
{ {
// UTF-8 toLower, tables generated from UTF-16 tables // UTF-8 toLower, tables generated from UTF-16 tables
std::string res; std::string res;
for (ptrdiff_t i = 0; str[i]; ++i) for (ptrdiff_t i = 0; str[i];)
appendToUpperAsUtf8(res, str, i); appendToUpperAsUtf8(res, str, i);
return res; return res;
} }
@ -4873,13 +4891,251 @@ std::string toUpper(const std::string &str)
std::string res; std::string res;
res.reserve(str.size() + (str.size() >> 2)); res.reserve(str.size() + (str.size() >> 2));
const char *cstr = &str[0]; const char *cstr = &str[0];
for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size(); ++i) for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();)
appendToUpperAsUtf8(res, cstr, i); appendToUpperAsUtf8(res, cstr, i);
return res; 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 #else
// *************************************************************************** // ***************************************************************************

@ -21,7 +21,7 @@ IF(WITH_RYZOM_CLIENT)
ENDIF() ENDIF()
FILE(GLOB CFG ../*.cfg) 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_INTERFACE interface_v3/*.h interface_v3/*.cpp)
FILE(GLOB SRC_MODE motion/modes/*.cpp motion/modes/*.h) FILE(GLOB SRC_MODE motion/modes/*.cpp motion/modes/*.h)
FILE(GLOB SRC_R2 r2/*.h r2/*.cpp r2/dmc/*.h r2/dmc/*.cpp) FILE(GLOB SRC_R2 r2/*.h r2/*.cpp r2/dmc/*.h r2/dmc/*.cpp)

@ -811,7 +811,7 @@ bool CCharacterCL::build(const CEntitySheet *sheet) // virtual
// Get the fauna name in the sheet // Get the fauna name in the sheet
const ucstring creatureName(STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id)); const ucstring creatureName(STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id));
if (creatureName.find(ucstring("<NotExist:")) != 0) if (creatureName.find(ucstring("<NotExist:")) != 0)
_EntityName = creatureName; _EntityName = creatureName.toUtf8();
} }
else else
{ {

@ -955,7 +955,7 @@ void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstrin
result = msg; result = msg;
else else
{ {
ucstring name = CEntityCL::removeTitleAndShardFromName(sender); ucstring name = CEntityCL::removeTitleAndShardFromName(sender.toUtf8());
ucstring csr; ucstring csr;
// special case where there is only a title, very rare case for some NPC // special case where there is only a title, very rare case for some NPC
@ -965,20 +965,20 @@ void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstrin
CCharacterCL *entity = dynamic_cast<CCharacterCL*>(EntitiesMngr.getEntityByName(sender, true, true)); CCharacterCL *entity = dynamic_cast<CCharacterCL*>(EntitiesMngr.getEntityByName(sender, true, true));
bool bWoman = entity && entity->getGender() == GSGENDER::female; bool bWoman = entity && entity->getGender() == GSGENDER::female;
name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender.toUtf8()), bWoman);
{ {
// Sometimes translation contains another title // Sometimes translation contains another title
ucstring::size_type pos = name.find('$'); ucstring::size_type pos = name.find('$');
if (pos != ucstring::npos) if (pos != ucstring::npos)
{ {
name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name), bWoman); name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name.toUtf8()), bWoman);
} }
} }
} }
else else
{ {
// Does the char have a CSR title? // Does the char have a CSR title?
csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring(""); csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender.toUtf8())) ? ucstring("(CSR) ") : ucstring("");
} }
result = csr + name + ucstring(" ") + CI18N::get("tellsYou") + ucstring(": ") + msg; result = csr + name + ucstring(" ") + CI18N::get("tellsYou") + ucstring(": ") + msg;
@ -1018,13 +1018,13 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde
} }
// Format the sentence with the provided sender name // Format the sentence with the provided sender name
ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender); ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender.toUtf8());
ucstring csr; ucstring csr;
// Does the char have a CSR title? // Does the char have a CSR title?
csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring(""); csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender.toUtf8())) ? ucstring("(CSR) ") : ucstring("");
if (UserEntity && senderName == UserEntity->getDisplayName()) if (UserEntity && senderName.toUtf8() == UserEntity->getDisplayName())
{ {
// The player talks // The player talks
switch(type) switch(type)
@ -1046,13 +1046,13 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde
// We need the gender to display the correct title // We need the gender to display the correct title
bool bWoman = entity && entity->getGender() == GSGENDER::female; bool bWoman = entity && entity->getGender() == GSGENDER::female;
senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman); senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender.toUtf8()), bWoman);
{ {
// Sometimes translation contains another title // Sometimes translation contains another title
ucstring::size_type pos = senderName.find('$'); ucstring::size_type pos = senderName.find('$');
if (pos != ucstring::npos) if (pos != ucstring::npos)
{ {
senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName), bWoman); senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName.toUtf8()), bWoman);
} }
} }
} }

@ -1385,14 +1385,14 @@ NLMISC_COMMAND(setItemName, "set name of items, sbrick, etc..","<sheet_id> <name
{ {
if (args.size() < 2) return false; if (args.size() < 2) return false;
CSheetId id(args[0]); CSheetId id(args[0]);
ucstring name; string name;
name.fromUtf8(args[1]); name = args[1];
ucstring desc; string desc;
ucstring desc2; string desc2;
if (args.size() > 2) if (args.size() > 2)
desc.fromUtf8(args[2]); desc = args[2];
if (args.size() > 3) if (args.size() > 3)
desc2.fromUtf8(args[3]); desc2 = args[3];
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
if (pSMC) if (pSMC)
@ -1406,10 +1406,10 @@ NLMISC_COMMAND(setItemName, "set name of items, sbrick, etc..","<sheet_id> <name
NLMISC_COMMAND(setMissingDynstringText, "set text of missing dynamic string"," <name> <text>") NLMISC_COMMAND(setMissingDynstringText, "set text of missing dynamic string"," <name> <text>")
{ {
if (args.size() < 2) return false; if (args.size() < 2) return false;
ucstring name; string name;
name.fromUtf8(args[0]); name = args[0];
ucstring text; string text;
text.fromUtf8(args[1]); text = args[1];
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
if (pSMC) if (pSMC)
@ -1459,7 +1459,7 @@ NLMISC_COMMAND(ah, "Launch an action handler", "<ActionHandler> <AHparam>")
static void setDynString(uint32 strID, const std::string &value) static void setDynString(uint32 strID, const std::string &value)
{ {
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
pSMC->receiveString(strID, ucstring(value)); pSMC->receiveString(strID, value);
CBitMemStream bm; CBitMemStream bm;
if (bm.isReading()) bm.invert(); if (bm.isReading()) bm.invert();
bm.serial(strID); bm.serial(strID);

@ -145,8 +145,8 @@ string CharNameValidDBLink;
uint8 PlayerSelectedSlot = 0; uint8 PlayerSelectedSlot = 0;
string PlayerSelectedFileName; string PlayerSelectedFileName;
TSessionId PlayerSelectedMainland= (TSessionId)0; // This is the mainland selected at the SELECT perso!! TSessionId PlayerSelectedMainland= (TSessionId)0; // This is the mainland selected at the SELECT perso!!
ucstring PlayerSelectedHomeShardName; std::string PlayerSelectedHomeShardName;
ucstring PlayerSelectedHomeShardNameWithParenthesis; std::string PlayerSelectedHomeShardNameWithParenthesis;
extern std::string CurrentCookie; extern std::string CurrentCookie;
ucstring NewKeysCharNameWanted; // name of the character for which a new keyset must be created ucstring NewKeysCharNameWanted; // name of the character for which a new keyset must be created
@ -1019,7 +1019,7 @@ TInterfaceState globalMenu()
// Display the firewall alert string // Display the firewall alert string
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:outgame:connecting:title")); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:outgame:connecting:title"));
if (pVT != NULL) if (pVT != NULL)
pVT->setText(CI18N::get("uiFirewallAlert") + "..."); pVT->setTextLocalized("uiFirewallAlert", true);
// The mouse and fullscreen mode should be unlocked for the user to set the firewall permission // The mouse and fullscreen mode should be unlocked for the user to set the firewall permission
nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts
@ -1235,8 +1235,8 @@ TInterfaceState globalMenu()
if (pVT != NULL) if (pVT != NULL)
{ {
pVT->setMultiLine( true ); pVT->setMultiLine( true );
pVT->setText(CI18N::get("uiFirewallFail")+".\n"+ pVT->setTextLocalized(CI18N::get("uiFirewallFail")+".\n"+
CI18N::get("uiFirewallAlert")+"."); CI18N::get("uiFirewallAlert")+".", false);
} }
} }
} }
@ -1317,16 +1317,16 @@ public:
if (pVT == NULL) return; if (pVT == NULL) return;
if (rCS.Name.empty()) if (rCS.Name.empty())
pVT->setText(CI18N::get("uiEmptySlot")); pVT->setTextLocalized("uiEmptySlot", true);
else else
pVT->setText(rCS.Name.toUtf8()); pVT->setTextLocalized(rCS.Name.toUtf8(), false);
} }
// 5 slots // 5 slots
for (; i < 5; ++i) for (; i < 5; ++i)
{ {
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i))); CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i)));
if (pVT == NULL) return; if (pVT == NULL) return;
pVT->setText(CI18N::get("uiEmptySlot")); pVT->setTextLocalized("uiEmptySlot", true);
} }
} }
}; };
@ -1439,7 +1439,7 @@ Deprecated {
ucstring::size_type pos = sValue.find('$'); ucstring::size_type pos = sValue.find('$');
if (pos != ucstring::npos) 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); setTarget (pCaller, sTarget, sValue);
@ -2169,7 +2169,7 @@ public:
if (pVT != NULL) if (pVT != NULL)
{ {
std::string str = Mainlands[i].Name.toUtf8() + " " + Mainlands[i].Description.toUtf8(); std::string str = Mainlands[i].Name.toUtf8() + " " + Mainlands[i].Description.toUtf8();
pVT->setText(str); pVT->setTextLocalized(str, false);
} }
// Add to the list // Add to the list
@ -2309,7 +2309,7 @@ public:
CViewText *pVT = dynamic_cast<CViewText*>(pNewLine->getView("name")); CViewText *pVT = dynamic_cast<CViewText*>(pNewLine->getView("name"));
if (pVT != NULL) if (pVT != NULL)
{ {
pVT->setText(name.toUtf8()); pVT->setTextLocalized(name.toUtf8(), false);
} }
CCtrlBase *pBut = pNewLine->getCtrl("but"); CCtrlBase *pBut = pNewLine->getCtrl("but");
@ -2557,7 +2557,7 @@ static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName
{ {
CViewText* viewText = dynamic_cast<CViewText*>(result); CViewText* viewText = dynamic_cast<CViewText*>(result);
if(viewText) if(viewText)
viewText->setText(text.toUtf8()); viewText->setTextLocalized(text.toUtf8(), false);
CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result); CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result);
if(editBox) if(editBox)
editBox->setInputStringAsUtf16(text); editBox->setInputStringAsUtf16(text);
@ -2680,7 +2680,7 @@ class CAHScenarioControl : public IActionHandler
CViewText* viewText = dynamic_cast<CViewText*>(result); CViewText* viewText = dynamic_cast<CViewText*>(result);
if(viewText) if(viewText)
{ {
viewText->setText(R2::getEditor().isInitialized()?CI18N::get("uiR2EDScenarioName"):CI18N::get("uiR2EDScenarioFileName")); viewText->setTextLocalized(R2::getEditor().isInitialized() ? "uiR2EDScenarioName" : "uiR2EDScenarioFileName", true);
} }
} }
@ -2710,7 +2710,7 @@ class CAHScenarioControl : public IActionHandler
CViewText* viewText= dynamic_cast<CViewText*>(result); CViewText* viewText= dynamic_cast<CViewText*>(result);
if(viewText) if(viewText)
viewText->setText(""); viewText->setText(std::string());
} }
} }
setScenarioInformation(scenarioWnd, ""); setScenarioInformation(scenarioWnd, "");
@ -2746,7 +2746,7 @@ class CAHScenarioControl : public IActionHandler
CViewText *shardName = dynamic_cast<CViewText *>(toggleGr->getView("button_text")); CViewText *shardName = dynamic_cast<CViewText *>(toggleGr->getView("button_text"));
if (shardName) if (shardName)
{ {
shardName->setText(Mainlands[i].Name.toUtf8()); shardName->setTextLocalized(Mainlands[i].Name.toUtf8(), false);
} }
} }
} }
@ -2886,7 +2886,7 @@ class CAHScenarioInformation : public IActionHandler
scenarioName = scenarioName.substr(posScenarioName==0?posScenarioName:posScenarioName+1); scenarioName = scenarioName.substr(posScenarioName==0?posScenarioName:posScenarioName+1);
posScenarioName = scenarioName.find('/'); posScenarioName = scenarioName.find('/');
} }
viewText->setText(scenarioName); viewText->setTextLocalized(scenarioName, false);
} }
} }
@ -3248,7 +3248,7 @@ class CAHLoadScenario : public IActionHandler
{ {
CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL) if (pVT != NULL)
pVT->setText(CI18N::get("uiRingWarningFreeTrial")); pVT->setTextLocalized("uiRingWarningFreeTrial", true);
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
return; return;
@ -3329,7 +3329,7 @@ class CAHLoadScenario : public IActionHandler
{ {
CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL) if (pVT != NULL)
pVT->setText(CI18N::get("uiRingWarningFreeTrial")); pVT->setTextLocalized("uiRingWarningFreeTrial", true);
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
} }
@ -3346,7 +3346,7 @@ class CAHLoadScenario : public IActionHandler
ucstring res; ucstring res;
if (pSMC->getString(val,res)) if (pSMC->getString(val,res))
{ {
string charName = CEntityCL::removeTitleAndShardFromName(res).toString(); string charName = CEntityCL::removeTitleAndShardFromName(res.toUtf8());
sessionBrowser.inviteCharacterByName(sessionBrowser._LastScheduleSessionCharId, charName); sessionBrowser.inviteCharacterByName(sessionBrowser._LastScheduleSessionCharId, charName);
if(!sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_invokeResult"))) if(!sessionBrowser.waitOneMessage(sessionBrowser.getMessageName("on_invokeResult")))
@ -3358,7 +3358,7 @@ class CAHLoadScenario : public IActionHandler
{ {
CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL) if (pVT != NULL)
pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial")); pVT->setTextLocalized("uiRingWarningInviteFreeTrial", true);
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
} }
} }

@ -30,8 +30,8 @@ extern std::vector<CMainlandSummary> Mainlands;
extern uint8 PlayerSelectedSlot; extern uint8 PlayerSelectedSlot;
extern std::string PlayerSelectedFileName; extern std::string PlayerSelectedFileName;
extern TSessionId PlayerSelectedMainland; // This is the mainland selected at the SELECT perso!! extern TSessionId PlayerSelectedMainland; // This is the mainland selected at the SELECT perso!!
extern ucstring PlayerSelectedHomeShardName; // The home shard name (aniro, leanon etc....) extern std::string PlayerSelectedHomeShardName; // The home shard name (aniro, leanon etc....)
extern ucstring PlayerSelectedHomeShardNameWithParenthesis; // Same with parenthesis extern std::string PlayerSelectedHomeShardNameWithParenthesis; // Same with parenthesis
extern std::vector<CCharacterSummary> CharacterSummaries; extern std::vector<CCharacterSummary> CharacterSummaries;
extern std::string UserPrivileges; extern std::string UserPrivileges;
extern sint LoginCharsel; extern sint LoginCharsel;

@ -514,7 +514,7 @@ string getDebugInformation()
if(UserEntity) 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); str += toString("UserPosition: %.2f %.2f %.2f\n", UserEntity->pos().x, UserEntity->pos().y, UserEntity->pos().z);
} }
else else

@ -2097,7 +2097,7 @@ bool CEntityCL::clipped (const std::vector<NLMISC::CPlane> &clippingPlanes, cons
// Set the name of the entity. Handle replacement tag if any // Set the name of the entity. Handle replacement tag if any
// to insert NPC task translated. // to insert NPC task translated.
//--------------------------------------------------- //---------------------------------------------------
void CEntityCL::setEntityName(const ucstring &name) void CEntityCL::setEntityName(const std::string &name)
{ {
_EntityName = name; _EntityName = name;
} }
@ -2262,7 +2262,7 @@ void CEntityCL::load() // virtual
// onStringAvailable : // onStringAvailable :
// Callback when the name is arrived. // 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; _EntityName = value;
@ -2270,24 +2270,24 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value)
_EntityName= removeShardFromName(_EntityName); _EntityName= removeShardFromName(_EntityName);
// New title // New title
ucstring newtitle; string newtitle;
_HasReservedTitle = false; _HasReservedTitle = false;
// check if there is any replacement tag in the string // check if there is any replacement tag in the string
ucstring::size_type p1 = _EntityName.find('$'); string::size_type p1 = _EntityName.find('$');
if (p1 != ucstring::npos) if (p1 != ucstring::npos)
{ {
// we found a replacement point begin tag // we found a replacement point begin tag
ucstring::size_type p2 = _EntityName.find('$', p1+1); string::size_type p2 = _EntityName.find('$', p1+1);
if (p2 != ucstring::npos) if (p2 != ucstring::npos)
{ {
// ok, we have the second replacement point! // ok, we have the second replacement point!
// extract the replacement id // 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 // retrieve the translated string
_TitleRaw = id.toString(); _TitleRaw = id;
// ucstring replacement = CI18N::get(strNewTitle); // string replacement = CI18N::get(strNewTitle);
bool womanTitle = false; bool womanTitle = false;
CCharacterCL * c = dynamic_cast<CCharacterCL*>(this); CCharacterCL * c = dynamic_cast<CCharacterCL*>(this);
if(c) if(c)
@ -2295,22 +2295,21 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value)
womanTitle = ( c->getGender() == GSGENDER::female ); womanTitle = ( c->getGender() == GSGENDER::female );
} }
ucstring replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle)); string replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw.toUtf8(), womanTitle);
// Sometimes translation contains another title // Sometimes translation contains another title
{ {
ucstring::size_type pos = replacement.find('$'); string::size_type pos = replacement.find('$');
if (pos != ucstring::npos) if (pos != ucstring::npos)
{ {
ucstring sn = replacement; _EntityName = replacement.substr(0, pos);
_EntityName = sn.substr(0, pos); string::size_type pos2 = replacement.find('$', pos + 1);
ucstring::size_type pos2 = sn.find('$', pos + 1); _TitleRaw = replacement.substr(pos+1, pos2 - pos - 1);
_TitleRaw = sn.substr(pos+1, pos2 - pos - 1); replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw.toUtf8(), womanTitle);
replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle);
} }
} }
_Tags = STRING_MANAGER::CStringManagerClient::getTitleInfos(_TitleRaw, womanTitle); _Tags = STRING_MANAGER::CStringManagerClient::getTitleInfos(_TitleRaw.toUtf8(), womanTitle);
if (!replacement.empty() || !ClientCfg.DebugStringManager) if (!replacement.empty() || !ClientCfg.DebugStringManager)
{ {
@ -2319,9 +2318,9 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value)
_EntityName = _EntityName.substr(0, p1); // + _Name.substr(p2+1) _EntityName = _EntityName.substr(0, p1); // + _Name.substr(p2+1)
// Get extended name // Get extended name
_NameEx = replacement; _NameEx = replacement;
newtitle = _NameEx; newtitle = _NameEx.toUtf8();
} }
CHARACTER_TITLE::ECharacterTitle titleEnum = CHARACTER_TITLE::toCharacterTitle( _TitleRaw.toString() ); CHARACTER_TITLE::ECharacterTitle titleEnum = CHARACTER_TITLE::toCharacterTitle( _TitleRaw.toUtf8() );
if ( titleEnum >= CHARACTER_TITLE::BeginGmTitle && titleEnum <= CHARACTER_TITLE::EndGmTitle ) if ( titleEnum >= CHARACTER_TITLE::BeginGmTitle && titleEnum <= CHARACTER_TITLE::EndGmTitle )
{ {
_GMTitle = titleEnum - CHARACTER_TITLE::BeginGmTitle; _GMTitle = titleEnum - CHARACTER_TITLE::BeginGmTitle;
@ -2355,7 +2354,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value)
if (pGC != NULL) pGC->setUCTitle(_EntityName); if (pGC != NULL) pGC->setUCTitle(_EntityName);
CSkillManager *pSM = CSkillManager::getInstance(); CSkillManager *pSM = CSkillManager::getInstance();
pSM->setPlayerTitle(_TitleRaw.toString()); pSM->setPlayerTitle(_TitleRaw.toUtf8());
} }
// Must rebuild the in scene interface 'cause name has changed // Must rebuild the in scene interface 'cause name has changed
@ -2366,32 +2365,32 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value)
//----------------------------------------------- //-----------------------------------------------
// getTitleFromName // getTitleFromName
//----------------------------------------------- //-----------------------------------------------
ucstring CEntityCL::getTitleFromName(const ucstring &name) std::string CEntityCL::getTitleFromName(const std::string &name)
{ {
ucstring::size_type p1 = name.find('$'); std::string::size_type p1 = name.find('$');
if (p1 != ucstring::npos) if (p1 != ucstring::npos)
{ {
ucstring::size_type p2 = name.find('$', p1 + 1); std::string::size_type p2 = name.find('$', p1 + 1);
if (p2 != ucstring::npos) if (p2 != std::string::npos)
return name.substr(p1+1, p2-p1-1); return name.substr(p1+1, p2-p1-1);
} }
return ucstring(""); return std::string();
}// getTitleFromName // }// getTitleFromName //
//----------------------------------------------- //-----------------------------------------------
// removeTitleFromName // removeTitleFromName
//----------------------------------------------- //-----------------------------------------------
ucstring CEntityCL::removeTitleFromName(const ucstring &name) std::string CEntityCL::removeTitleFromName(const std::string &name)
{ {
ucstring::size_type p1 = name.find('$'); std::string::size_type p1 = name.find('$');
if (p1 == ucstring::npos) if (p1 == ucstring::npos)
{ {
return name; return name;
} }
else else
{ {
ucstring::size_type p2 = name.find('$', p1 + 1); std::string::size_type p2 = name.find('$', p1 + 1);
if (p2 != ucstring::npos) if (p2 != ucstring::npos)
{ {
return name.substr(0, p1) + name.substr(p2 + 1); return name.substr(0, p1) + name.substr(p2 + 1);
@ -2406,16 +2405,16 @@ ucstring CEntityCL::removeTitleFromName(const ucstring &name)
//----------------------------------------------- //-----------------------------------------------
// removeShardFromName // removeShardFromName
//----------------------------------------------- //-----------------------------------------------
ucstring CEntityCL::removeShardFromName(const ucstring &name) std::string CEntityCL::removeShardFromName(const std::string &name)
{ {
// The string must contains a '(' and a ')' // The string must contains a '(' and a ')'
ucstring::size_type p0= name.find('('); std::string::size_type p0= name.find('(');
ucstring::size_type p1= name.find(')'); std::string::size_type p1= name.find(')');
if(p0==ucstring::npos || p1==ucstring::npos || p1<=p0) if(p0==std::string::npos || p1==std::string::npos || p1<=p0)
return name; return name;
// if it is the same as the shard name of the user, remove it // 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); return name.substr(0,p0) + name.substr(p1+1);
// else don't modify // else don't modify
else else
@ -2425,7 +2424,7 @@ ucstring CEntityCL::removeShardFromName(const ucstring &name)
//----------------------------------------------- //-----------------------------------------------
// removeTitleAndShardFromName // removeTitleAndShardFromName
//----------------------------------------------- //-----------------------------------------------
ucstring CEntityCL::removeTitleAndShardFromName(const ucstring &name) std::string CEntityCL::removeTitleAndShardFromName(const std::string &name)
{ {
return removeTitleFromName(removeShardFromName(name)); return removeTitleFromName(removeShardFromName(name));
} }

@ -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 '$' /// 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 ..) /// 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 ..) /// 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...) /// 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 /// 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. /// Change the entity name.
void setEntityName(const ucstring &name); void setEntityName(const std::string &name);
/// Return a displayable name /// Return a displayable name
ucstring getDisplayName() const std::string getDisplayName() const
{ {
return removeTitleAndShardFromName(_EntityName); return removeTitleAndShardFromName(_EntityName);
} }
@ -931,11 +931,11 @@ protected:
// Flags to know what is possible to do with the entity (selectable, liftable, etc.). // Flags to know what is possible to do with the entity (selectable, liftable, etc.).
CProperties _Properties; CProperties _Properties;
// Current Name for the entity // Current Name for the entity
ucstring _EntityName; std::string _EntityName;
// Current entity title // Current entity title
ucstring _Title; ucstring _Title;
// Current entity tags // Current entity tags
std::vector<ucstring> _Tags; std::vector<std::string> _Tags;
// Current entity title string id // Current entity title string id
ucstring _TitleRaw; ucstring _TitleRaw;
// Current permanent content symbol for the entity // Current permanent content symbol for the entity
@ -1222,7 +1222,7 @@ public:
private: private:
// Override for string reception callback // Override for string reception callback
virtual void onStringAvailable(uint stringId, const ucstring &value); virtual void onStringAvailable(uint stringId, const std::string &value);
}; };

@ -508,9 +508,9 @@ void CForageSourceCL::updateVisualPropertyVisualFX(const NLMISC::TGameCycle &/*
CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot];
if (prospector != NULL) if (prospector != NULL)
{ {
ucstring prospectorName = prospector->getDisplayName(); string prospectorName = prospector->getDisplayName();
if ( ! prospectorName.empty() ) if ( ! prospectorName.empty() )
_EntityName += ucstring(" [") + prospectorName + ucstring("]"); _EntityName += " [" + prospectorName + "]";
} }
} }
@ -536,7 +536,7 @@ void CForageSourceCL::updateVisualPropertyVisualFX(const NLMISC::TGameCycle &/*
void CForageSourceCL::updateVisualPropertyName(const NLMISC::TGameCycle &/* gameCycle */, const sint64 &prop) void CForageSourceCL::updateVisualPropertyName(const NLMISC::TGameCycle &/* gameCycle */, const sint64 &prop)
{ {
CSheetId rmSheetId( (const uint32&)prop ); CSheetId rmSheetId( (const uint32&)prop );
const ucchar *name = STRING_MANAGER::CStringManagerClient::getItemLocalizedName( rmSheetId ); const char *name = STRING_MANAGER::CStringManagerClient::getItemLocalizedName( rmSheetId );
if ( name ) if ( name )
{ {
_EntityName = name; _EntityName = name;
@ -545,9 +545,9 @@ void CForageSourceCL::updateVisualPropertyName(const NLMISC::TGameCycle &/* game
CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot];
if (prospector != NULL) if (prospector != NULL)
{ {
ucstring prospectorName = prospector->getDisplayName(); std::string prospectorName = prospector->getDisplayName();
if ( ! prospectorName.empty() ) if ( ! prospectorName.empty() )
_EntityName += ucstring(" [") + prospectorName + ucstring("]"); _EntityName += " [" + prospectorName + "]";
} }
} }
// Rebuild inscene interface // Rebuild inscene interface
@ -568,9 +568,9 @@ void CForageSourceCL::updateVisualPropertyTarget(const NLMISC::TGameCycle &/* ga
CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; // NULL if entity not received CEntityCL *prospector = EntitiesMngr.entities()[_ProspectorSlot]; // NULL if entity not received
if (prospector != NULL) if (prospector != NULL)
{ {
ucstring prospectorName = prospector->getDisplayName(); std::string prospectorName = prospector->getDisplayName();
if ( ! prospectorName.empty() ) if ( ! prospectorName.empty() )
_EntityName = _EntityName + ucstring(" [") + prospectorName + ucstring("]"); _EntityName = _EntityName + " [" + prospectorName + "]";
} }
// Rebuild inscene interface // Rebuild inscene interface

@ -792,7 +792,7 @@ void CGameContextMenu::updateContextMenuOutpostState(uint options)
{ {
CViewTextMenu *pVTM = _TextOutpostState; CViewTextMenu *pVTM = _TextOutpostState;
if (pVTM) if (pVTM)
pVTM->setText(CUtfStringView(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)).toUtf8()); pVTM->setText(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet));
} }
// apply the active // apply the active

@ -168,7 +168,7 @@ extern NLMISC::CCmdArgs Args;
// Tips of the day count // Tips of the day count
#define RZ_NUM_TIPS 17 #define RZ_NUM_TIPS 17
ucstring TipsOfTheDay; std::string TipsOfTheDay;
uint TipsOfTheDayIndex; uint TipsOfTheDayIndex;
// includes for following register classes // includes for following register classes
@ -272,19 +272,19 @@ static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARA
{ {
if (CI18N::hasTranslation("TheSagaOfRyzom")) 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()); 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")) 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")) 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 rect;
RECT rectDesktop; RECT rectDesktop;
@ -343,7 +343,7 @@ void ExitClientError (const char *format, ...)
/* /*
ucstring ucstr; ucstring ucstr;
ucstr.fromUtf8 (str); 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 #else
fprintf (stderr, "%s\n", str); fprintf (stderr, "%s\n", str);
@ -360,7 +360,7 @@ void ExitClientError (const char *format, ...)
void ClientInfo (const ucstring &message) void ClientInfo (const ucstring &message)
{ {
#ifdef NL_OS_WINDOWS #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 #endif
} }
@ -368,7 +368,7 @@ void ClientInfo (const ucstring &message)
bool ClientQuestion (const ucstring &message) bool ClientQuestion (const ucstring &message)
{ {
#ifdef NL_OS_WINDOWS #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 #else
return false; return false;
#endif #endif

@ -229,8 +229,8 @@ struct CStatThread : public NLMISC::IRunnable
string cookie() string cookie()
{ {
string name; string name;
if(UserEntity && !UserEntity->getEntityName().toString().empty()) if(UserEntity && !UserEntity->getEntityName().empty())
name = UserEntity->getEntityName().toString(); name = UserEntity->getEntityName();
std::string userid = toString("u%d", NetMngr.getUserId())+name; std::string userid = toString("u%d", NetMngr.getUserId())+name;
return toUpper(getMD5((const uint8 *)userid.c_str(), (uint32)userid.size()).toString()); return toUpper(getMD5((const uint8 *)userid.c_str(), (uint32)userid.size()).toString());
@ -240,7 +240,7 @@ struct CStatThread : public NLMISC::IRunnable
bool connect() bool connect()
{ {
//nlinfo("connect"); //nlinfo("connect");
if(!UserEntity || UserEntity->getEntityName().toString().empty()) if(!UserEntity || UserEntity->getEntityName().empty())
return false; return false;
referer = ContinentMngr.getCurrentContinentSelectName(); referer = ContinentMngr.getCurrentContinentSelectName();
@ -268,7 +268,7 @@ struct CStatThread : public NLMISC::IRunnable
timeinfo = localtime ( &rawtime ); timeinfo = localtime ( &rawtime );
strftime (buffer,80,"%H%%3A%M", timeinfo); strftime (buffer,80,"%H%%3A%M", timeinfo);
addParam(params, "localtime", buffer); addParam(params, "localtime", buffer);
addParam(params, "cv_name", UserEntity->getEntityName().toUtf8()); addParam(params, "cv_name", UserEntity->getEntityName());
//addParam(params, "cv_email", ""); //addParam(params, "cv_email", "");
//addParam(params, "cv_avatar", ""); //addParam(params, "cv_avatar", "");
addParam(params, "cv_Userid", toString(NetMngr.getUserId())); addParam(params, "cv_Userid", toString(NetMngr.getUserId()));

@ -1957,13 +1957,13 @@ public:
if (pChar != NULL) if (pChar != NULL)
womanTitle = pChar->getGender() == GSGENDER::female; womanTitle = pChar->getGender() == GSGENDER::female;
STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout.toUtf8()), womanTitle);
// Sometimes translation contains another title // Sometimes translation contains another title
ucstring::size_type pos = copyInout.find('$'); ucstring::size_type pos = copyInout.find('$');
if (pos != ucstring::npos) if (pos != ucstring::npos)
{ {
copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle); copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout.toUtf8()), womanTitle);
} }
CStringPostProcessRemoveTitle::cbIDStringReceived(copyInout); CStringPostProcessRemoveTitle::cbIDStringReceived(copyInout);

@ -670,7 +670,7 @@ class CHandlerOpenTitleHelp : public IActionHandler
if (selection == NULL) return; if (selection == NULL) return;
//if(selection->isNPC()) //if(selection->isNPC())
{ {
ucstring name = selection->getEntityName(); std::string name = selection->getEntityName();
if(name.empty()) if(name.empty())
{ {
// try to get the name from the string manager (for npc) // try to get the name from the string manager (for npc)
@ -679,7 +679,7 @@ class CHandlerOpenTitleHelp : public IActionHandler
{ {
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
pSMC->getString (nDBid, name); pSMC->getString (nDBid, name);
ucstring copyName = name; std::string copyName = name;
name = CEntityCL::removeTitleAndShardFromName(name); name = CEntityCL::removeTitleAndShardFromName(name);
if (name.empty()) if (name.empty())
{ {
@ -689,7 +689,7 @@ class CHandlerOpenTitleHelp : public IActionHandler
woman = pChar->getGender() == GSGENDER::female; woman = pChar->getGender() == GSGENDER::female;
// extract the replacement id // extract the replacement id
ucstring strNewTitle = CEntityCL::getTitleFromName(copyName); std::string strNewTitle = CEntityCL::getTitleFromName(copyName);
// retrieve the translated string // retrieve the translated string
if (!strNewTitle.empty()) if (!strNewTitle.empty())
@ -700,7 +700,7 @@ class CHandlerOpenTitleHelp : public IActionHandler
} }
} }
if(!name.empty()) 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; return;
} }
} }
@ -752,7 +752,7 @@ class CHandlerOpenTitleHelp : public IActionHandler
for (titleIDnb = 0; titleIDnb < CHARACTER_TITLE::NB_CHARACTER_TITLE; ++titleIDnb) for (titleIDnb = 0; titleIDnb < CHARACTER_TITLE::NB_CHARACTER_TITLE; ++titleIDnb)
{ {
bool women = UserEntity && UserEntity->getGender()==GSGENDER::female; 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; break;
} }
@ -2762,7 +2762,7 @@ class CPlayerShardNameRemover : public IOnReceiveTextId
{ {
virtual void onReceiveTextId(ucstring &str) virtual void onReceiveTextId(ucstring &str)
{ {
str= CEntityCL::removeShardFromName(str); str= CEntityCL::removeShardFromName(str.toUtf8());
} }
}; };
static CPlayerShardNameRemover PlayerShardNameRemover; static CPlayerShardNameRemover PlayerShardNameRemover;
@ -3629,7 +3629,7 @@ public:
CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:NAME", index)); CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:NAME", index));
if (node && CStringManagerClient::instance()->getDynString(node->getValue32(), txt)) if (node && CStringManagerClient::instance()->getDynString(node->getValue32(), txt))
{ {
CWidgetManager::getInstance()->setContextHelpText(CEntityCL::removeTitleFromName(txt).toUtf8()); CWidgetManager::getInstance()->setContextHelpText(CEntityCL::removeTitleFromName(txt.toUtf8()));
} }
} }
}; };

@ -161,7 +161,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived()
else else
{ {
if (itemInfo.CustomText.empty()) if (itemInfo.CustomText.empty())
display->setTextFormatTaged(CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)).toUtf8()); display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id));
else else
{ {
ucstring text = itemInfo.CustomText; ucstring text = itemInfo.CustomText;
@ -299,7 +299,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
{ {
// If we already have item info // If we already have item info
if (itemInfo.CustomText.empty()) if (itemInfo.CustomText.empty())
display->setTextFormatTaged(CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)).toUtf8()); display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id));
else else
{ {
ucstring text = itemInfo.CustomText; ucstring text = itemInfo.CustomText;
@ -1721,7 +1721,7 @@ void CItemMenuInBagInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet)
ucstring creatorNameString; ucstring creatorNameString;
if( STRING_MANAGER::CStringManagerClient::instance()->getString ( itemInfo.CreatorName, creatorNameString) ) if( STRING_MANAGER::CStringManagerClient::instance()->getString ( itemInfo.CreatorName, creatorNameString) )
{ {
if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString)) if ( toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString.toUtf8()))
isCraftedByUserEntity = true; isCraftedByUserEntity = true;
} }
@ -1827,7 +1827,7 @@ class CHandlerItemMenuCheck : public IActionHandler
ucstring creatorNameString; ucstring creatorNameString;
if( STRING_MANAGER::CStringManagerClient::instance()->getString ( getInventory().getItemInfo(getInventory().getItemSlotId(pCS)).CreatorName, creatorNameString) ) if( STRING_MANAGER::CStringManagerClient::instance()->getString ( getInventory().getItemInfo(getInventory().getItemSlotId(pCS)).CreatorName, creatorNameString) )
{ {
if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString)) if (toLower(UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis) == toLower(creatorNameString.toUtf8()))
isTextEditionActive = true; isTextEditionActive = true;
} }
} }

@ -836,7 +836,7 @@ class CAHReplyTeller : public IActionHandler
{ {
w->setKeyboardFocus(); w->setKeyboardFocus();
w->enableBlink(1); w->enableBlink(1);
PeopleInterraction.ChatGroup.Filter.setTargetPlayer(CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName)); PeopleInterraction.ChatGroup.Filter.setTargetPlayer(CEntityCL::removeTitleAndShardFromName(PeopleInterraction.LastSenderName.toUtf8()));
CGroupEditBox *eb = w->getEditBox(); CGroupEditBox *eb = w->getEditBox();
if (eb != NULL) if (eb != NULL)
{ {
@ -863,7 +863,7 @@ class CAHReplyTellerOnce : public IActionHandler
{ {
w->setKeyboardFocus(); w->setKeyboardFocus();
w->enableBlink(1); 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(); CGroupEditBox *eb = w->getEditBox();
if (eb != NULL) if (eb != NULL)
{ {
@ -916,7 +916,7 @@ NLMISC_COMMAND(slsn, "Temp : set the name of the last sender.", "<name>")
bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut) bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut)
{ {
// extract the replacement id // extract the replacement id
ucstring strNewTitle = CEntityCL::getTitleFromName(inOut); string strNewTitle = CEntityCL::getTitleFromName(inOut.toUtf8());
// retrieve the translated string // retrieve the translated string
if (!strNewTitle.empty()) if (!strNewTitle.empty())
@ -927,7 +927,7 @@ bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut)
ucstring::size_type pos = inOut.find('$'); ucstring::size_type pos = inOut.find('$');
if (pos != ucstring::npos) if (pos != ucstring::npos)
{ {
inOut = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(inOut), Woman); inOut = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(inOut.toUtf8()), Woman);
} }
} }
} }
@ -940,14 +940,14 @@ bool CStringPostProcessRemoveName::cbIDStringReceived(ucstring &inOut)
// *************************************************************************** // ***************************************************************************
bool CStringPostProcessRemoveTitle::cbIDStringReceived(ucstring &inOut) bool CStringPostProcessRemoveTitle::cbIDStringReceived(ucstring &inOut)
{ {
inOut = CEntityCL::removeTitleAndShardFromName(inOut); inOut = CEntityCL::removeTitleAndShardFromName(inOut.toUtf8());
return true; return true;
} }
// *************************************************************************** // ***************************************************************************
bool CStringPostProcessNPCRemoveTitle::cbIDStringReceived(ucstring &inOut) bool CStringPostProcessNPCRemoveTitle::cbIDStringReceived(ucstring &inOut)
{ {
ucstring sOut = CEntityCL::removeTitleAndShardFromName(inOut); ucstring sOut = CEntityCL::removeTitleAndShardFromName(inOut.toUtf8());
if (sOut.empty()) if (sOut.empty())
{ {
CStringPostProcessRemoveName SPPRM; CStringPostProcessRemoveName SPPRM;

@ -208,7 +208,8 @@ void CChatWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGr
{ {
if (!_Chat) if (!_Chat)
{ {
nlwarning("<CChatWindow::displayMessage> There's no global chat"); if (msg.toUtf8() != "WRN: <CChatWindow::displayMessage> There's no global chat")
nlwarning("<CChatWindow::displayMessage> There's no global chat");
return; return;
} }
CGroupList *gl; CGroupList *gl;
@ -541,7 +542,8 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC
{ {
if (!_Chat) if (!_Chat)
{ {
nlwarning("<CChatGroupWindow::displayMessage> There's no global chat"); if (msg.toUtf8() != "WRN: <CChatGroupWindow::displayMessage> There's no global chat")
nlwarning("<CChatGroupWindow::displayMessage> There's no global chat");
return; return;
} }
@ -1091,10 +1093,7 @@ CChatWindow *CChatWindowManager::createChatWindow(const CChatWindowDesc &desc)
if (desc.Id.empty()) if (desc.Id.empty())
_WindowID++; _WindowID++;
if (desc.Localize) _ChatWindowMap[desc.Title] = w;
_ChatWindowMap[CI18N::get(desc.Title.toString())] = w;
else
_ChatWindowMap[desc.Title] = w;
w->setAHOnActive(desc.AHOnActive); w->setAHOnActive(desc.AHOnActive);
w->setAHOnActiveParams(desc.AHOnActiveParams); w->setAHOnActiveParams(desc.AHOnActiveParams);
@ -1133,10 +1132,7 @@ CChatWindow *CChatWindowManager::createChatGroupWindow(const CChatWindowDesc &de
if (desc.Id.empty()) if (desc.Id.empty())
_WindowID++; _WindowID++;
if (desc.Localize) _ChatWindowMap[desc.Title] = w;
_ChatWindowMap[CI18N::get(desc.Title.toString())] = w;
else
_ChatWindowMap[desc.Title] = w;
w->setAHOnActive(desc.AHOnActive); w->setAHOnActive(desc.AHOnActive);
w->setAHOnActiveParams(desc.AHOnActiveParams); w->setAHOnActiveParams(desc.AHOnActiveParams);
@ -1183,7 +1179,7 @@ void CChatWindowManager::removeChatWindow(const ucstring &title)
TChatWindowMap::iterator it = _ChatWindowMap.find(title); TChatWindowMap::iterator it = _ChatWindowMap.find(title);
if (it == _ChatWindowMap.end()) if (it == _ChatWindowMap.end())
{ {
nlwarning("unknwown window %s", title.toString().c_str()); nlwarning("Unknown chat window '%s'", title.toUtf8().c_str());
return; return;
} }
it->second->deleteContainer(); it->second->deleteContainer();
@ -1223,18 +1219,9 @@ bool CChatWindowManager::rename(const ucstring &oldName, const ucstring &newName
if (newWin != NULL) return false; // target window exists if (newWin != NULL) return false; // target window exists
TChatWindowMap::iterator it = _ChatWindowMap.find(oldName); TChatWindowMap::iterator it = _ChatWindowMap.find(oldName);
if (it == _ChatWindowMap.end()) return false; if (it == _ChatWindowMap.end()) return false;
if (newNameLocalize) _ChatWindowMap[newName] = it->second;
{ it->second->getContainer()->setLocalize(false);
_ChatWindowMap[CI18N::get(newName.toString())] = it->second; it->second->getContainer()->setTitle(newName.toUtf8());
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.erase(it); _ChatWindowMap.erase(it);
return true; return true;
} }

@ -3379,7 +3379,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
{ {
// just show the name of the skill // just show the name of the skill
// the sheet id is interpreted as a skill enum // the sheet id is interpreted as a skill enum
help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName( (SKILLS::ESkills)_SheetId.getSInt32() )).toUtf8(); help= STRING_MANAGER::CStringManagerClient::getSkillLocalizedName( (SKILLS::ESkills)_SheetId.getSInt32() );
} }
else if(getType() == CCtrlSheetInfo::SheetType_Macro) else if(getType() == CCtrlSheetInfo::SheetType_Macro)
{ {
@ -3479,7 +3479,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
CSBrickManager *pBM= CSBrickManager::getInstance(); CSBrickManager *pBM= CSBrickManager::getInstance();
CSBrickSheet *brick= pBM->getBrick(CSheetId(getSheetId())); CSBrickSheet *brick= pBM->getBrick(CSheetId(getSheetId()));
if(brick) if(brick)
help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id)).toUtf8(); help= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id);
else else
help= _ContextHelp; help= _ContextHelp;
} }
@ -3543,7 +3543,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
{ {
CSPhraseSheet *phrase= dynamic_cast<CSPhraseSheet*>(SheetMngr.get(CSheetId(getSheetId()))); CSPhraseSheet *phrase= dynamic_cast<CSPhraseSheet*>(SheetMngr.get(CSheetId(getSheetId())));
if(phrase) if(phrase)
help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id)).toUtf8(); help= STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id);
else else
help= _ContextHelp; help= _ContextHelp;
} }
@ -3551,7 +3551,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
{ {
const COutpostBuildingSheet *outpost = asOutpostBuildingSheet(); const COutpostBuildingSheet *outpost = asOutpostBuildingSheet();
if (outpost) if (outpost)
help = CUtfStringView(CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32()))).toUtf8(); help = CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32()));
else else
help = _ContextHelp; help = _ContextHelp;
} }

@ -269,7 +269,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT
if (pOBS != NULL) if (pOBS != NULL)
{ {
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
text += string("\n") + CUtfStringView(pSMC->getOutpostBuildingLocalizedDescription(CSheetId(Ctrl->getSheetId()))).toUtf8(); text += string("\n") + pSMC->getOutpostBuildingLocalizedDescription(CSheetId(Ctrl->getSheetId()));
text += "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(pOBS->CostDapper)); text += "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(pOBS->CostDapper));
text += CI18N::get("uiBotChatTime") + toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute"); text += CI18N::get("uiBotChatTime") + toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute");
if ((pOBS->CostTime % 60) != 0) if ((pOBS->CostTime % 60) != 0)
@ -692,7 +692,7 @@ void CDBGroupListSheetTrade::checkCoords ()
ucstring result; ucstring result;
if( pSMC->getString ( cst->LastVendorNameId, result) ) if( pSMC->getString ( cst->LastVendorNameId, result) )
{ {
cst->VendorNameString = CEntityCL::removeShardFromName(result); cst->VendorNameString = CEntityCL::removeShardFromName(result.toUtf8());
set< CSheetChildTrade *>::iterator itTmp = it; set< CSheetChildTrade *>::iterator itTmp = it;
++it; ++it;
VendorNameIdToUpdate.erase(itTmp); VendorNameIdToUpdate.erase(itTmp);

@ -360,18 +360,15 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName)
{ {
if (pES->type() == CEntitySheet::ITEM) if (pES->type() == CEntitySheet::ITEM)
{ {
CUtfStringView desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet))); pRBVT->setText(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet)));
pRBVT->setText(desc.toUtf8());
} }
else if (pES->type() == CEntitySheet::SBRICK) else if (pES->type() == CEntitySheet::SBRICK)
{ {
CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet))); pRBVT->setText(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet)));
pRBVT->setText(desc.toUtf8());
} }
else if (pES->type() == CEntitySheet::SPHRASE) else if (pES->type() == CEntitySheet::SPHRASE)
{ {
CUtfStringView desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet))); pRBVT->setText(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet)));
pRBVT->setText(desc.toUtf8());
} }
} }

@ -560,7 +560,7 @@ bool buildCompassTargetFromTeamMember(CCompassTarget &ct, uint teamMemberId)
CStringManagerClient *pSMC = CStringManagerClient::instance(); CStringManagerClient *pSMC = CStringManagerClient::instance();
ucstring name; ucstring name;
if (pSMC->getString(nameNode->getValue32(), name)) if (pSMC->getString(nameNode->getValue32(), name))
ct.Name = CEntityCL::removeTitleAndShardFromName(name); // TODO : dynamic support for name ct.Name = CEntityCL::removeTitleAndShardFromName(name.toUtf8()); // TODO : dynamic support for name
else else
ct.Name = CI18N::get("uiNotReceived"); ct.Name = CI18N::get("uiNotReceived");
return true; return true;
@ -1047,12 +1047,12 @@ REGISTER_ACTION_HANDLER( CHandlerSetCompassNorth, "set_compass_north");
class CCompassDialogsStringCallback : public IStringWaitCallback 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(); uint size = (uint)CCompassDialogsManager::getInstance()._Entries.size();
for ( uint i = 0; i < size; i++) for ( uint i = 0; i < size; i++)
{ {
ucstring name; std::string name;
if ( CStringManagerClient::instance()->getDynString(CCompassDialogsManager::getInstance()._Entries[i].Text, name) ) if ( CStringManagerClient::instance()->getDynString(CCompassDialogsManager::getInstance()._Entries[i].Text, name) )
{ {
if ( value == name ) if ( value == name )

@ -97,7 +97,7 @@ void addWebIGParams (string &url, bool trustedDomain)
if (url.find('$') != string::npos) if (url.find('$') != string::npos)
{ {
strFindReplace(url, "$gender$", GSGENDER::toString(UserEntity->getGender())); 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, "$posx$", toString(UserEntity->pos().x));
strFindReplace(url, "$posy$", toString(UserEntity->pos().y)); strFindReplace(url, "$posy$", toString(UserEntity->pos().y));
strFindReplace(url, "$posz$", toString(UserEntity->pos().z)); strFindReplace(url, "$posz$", toString(UserEntity->pos().z));
@ -113,7 +113,7 @@ void addWebIGParams (string &url, bool trustedDomain)
if (target) if (target)
{ {
strFindReplace(url, "$tdatasetid$", toString(target->dataSetId())); 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, "$tposx$", toString(target->pos().x));
strFindReplace(url, "$tposy$", toString(target->pos().y)); strFindReplace(url, "$tposy$", toString(target->pos().y));
strFindReplace(url, "$tposz$", toString(target->pos().z)); strFindReplace(url, "$tposz$", toString(target->pos().z));

@ -531,10 +531,9 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t
if (group) if (group)
{ {
// Skill name // Skill name
CUtfStringView sSkillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId));
CViewText *pViewSkillName = dynamic_cast<CViewText*>(group->getView("name")); CViewText *pViewSkillName = dynamic_cast<CViewText*>(group->getView("name"));
if (pViewSkillName != NULL) if (pViewSkillName != NULL)
pViewSkillName->setText (sSkillName.toUtf8()); pViewSkillName->setText (STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId));
// Skill value // Skill value
CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false); CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false);

@ -200,9 +200,9 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity)
// Names // Names
const char *templateName; const char *templateName;
ucstring theTribeName; const char *theTribeName = "";
ucstring entityName = entity->getDisplayName(); std::string entityName = entity->getDisplayName();
ucstring entityTitle = entity->getTitle(); std::string entityTitle = entity->getTitle().toUtf8();
// For some NPC's the name is empty and only a title is given, // For some NPC's the name is empty and only a title is given,
// in that case, treat the title as the name. // in that case, treat the title as the name.
@ -780,19 +780,19 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity)
// Set player name // Set player name
if (info->_Name) if (info->_Name)
{ {
info->_Name->setText(entityName.toUtf8()); info->_Name->setText(entityName);
info->_Name->setModulateGlobalColor(false); info->_Name->setModulateGlobalColor(false);
} }
// Set player title // Set player title
if (info->_Title) if (info->_Title)
info->_Title->setText(entityTitle.toUtf8()); info->_Title->setText(entityTitle);
// Set tribe name // Set tribe name
if (info->_TribeName) if (info->_TribeName)
{ {
nlassert(info->_GuildName == NULL); nlassert(info->_GuildName == NULL);
info->_TribeName->setText(theTribeName.toUtf8()); info->_TribeName->setText(theTribeName);
} }
// Init user leaf nodes // Init user leaf nodes

@ -1201,7 +1201,7 @@ void CGroupMap::checkCoords()
CEntityCL *sel = EntitiesMngr.entity(UserEntity->selection()); CEntityCL *sel = EntitiesMngr.entity(UserEntity->selection());
if (sel) if (sel)
{ {
_TargetLM->setDefaultContextHelp(NLMISC::CI18N::get("uiTargetTwoPoint") + sel->removeTitleAndShardFromName(sel->getEntityName()).toUtf8()); _TargetLM->setDefaultContextHelp(NLMISC::CI18N::get("uiTargetTwoPoint") + sel->removeTitleAndShardFromName(sel->getEntityName()));
} }
} }
} }
@ -1367,8 +1367,8 @@ void CGroupMap::checkCoords()
if (pSMC->getString(val,res)) if (pSMC->getString(val,res))
{ {
res = CEntityCL::removeTitleAndShardFromName(res); std::string res2 = CEntityCL::removeTitleAndShardFromName(res.toUtf8());
_TeammateLM[i]->setDefaultContextHelp(res.toUtf8()); _TeammateLM[i]->setDefaultContextHelp(res2);
} }
} }
updateLMPosFromDBPos(_TeammateLM[i], px, py); updateLMPosFromDBPos(_TeammateLM[i], px, py);
@ -2471,19 +2471,19 @@ void CGroupMap::createLMWidgets(const std::vector<CContLandMark> &lms)
NLMISC::CVector2f mapPos; NLMISC::CVector2f mapPos;
worldToMap(mapPos, rCLM.Pos); worldToMap(mapPos, rCLM.Pos);
const ucstring ucsTmp(CStringManagerClient::getPlaceLocalizedName(rCLM.TitleTextID)); const char *ucsTmp = CStringManagerClient::getPlaceLocalizedName(rCLM.TitleTextID);
const ucstring lcTitle = toLower(ucsTmp); const std::string lcTitle = toLower(ucsTmp);
bool searchMatch = notWorldMode && _LandmarkFilter.size() > 0 && filterLandmark(lcTitle); bool searchMatch = notWorldMode && _LandmarkFilter.size() > 0 && filterLandmark(lcTitle);
if (searchMatch) 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 // Add button if not a region nor a place
if ((rCLM.Type != CContLandMark::Region) && (rCLM.Type != CContLandMark::Place) && if ((rCLM.Type != CContLandMark::Region) && (rCLM.Type != CContLandMark::Place) &&
(rCLM.Type != CContLandMark::Street)) (rCLM.Type != CContLandMark::Street))
{ {
if (rCLM.Type != CContLandMark::Stable) if (rCLM.Type != CContLandMark::Stable)
addLandMark(_ContinentLM, mapPos, ucsTmp, _ContinentLMOptions); addLandMark(_ContinentLM, mapPos, ucstring::makeFromUtf8(ucsTmp), _ContinentLMOptions);
else else
addLandMark(_ContinentLM, mapPos, CI18N::get("uiStable"), _ContinentLMOptions); addLandMark(_ContinentLM, mapPos, CI18N::get("uiStable"), _ContinentLMOptions);
_ContinentLM.back()->Type = rCLM.Type; _ContinentLM.back()->Type = rCLM.Type;
@ -2492,7 +2492,7 @@ void CGroupMap::createLMWidgets(const std::vector<CContLandMark> &lms)
else // just add a text else // just add a text
{ {
CLandMarkText *pNewText = new CLandMarkText(CViewBase::TCtorParam()); CLandMarkText *pNewText = new CLandMarkText(CViewBase::TCtorParam());
pNewText->setText(ucsTmp.toUtf8()); pNewText->setText(ucsTmp);
pNewText->Pos = mapPos; pNewText->Pos = mapPos;
pNewText->setParent(this); pNewText->setParent(this);
pNewText->setParentPosRef(Hotspot_BL); pNewText->setParentPosRef(Hotspot_BL);

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

@ -336,7 +336,7 @@ void CGroupSkills::createAllTreeNodes()
// local variable (avoid realloc in loop) // local variable (avoid realloc in loop)
vector< pair<string, string> > tempVec(2); vector< pair<string, string> > tempVec(2);
string sSkillName; const char *sSkillName;
while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop
{ {
@ -366,7 +366,7 @@ void CGroupSkills::createAllTreeNodes()
pNode->Id = NLMISC::toString(i); pNode->Id = NLMISC::toString(i);
// get Skill Name // get Skill Name
sSkillName = CUtfStringView(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i)).toUtf8(); sSkillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i);
// just text or template? // just text or template?
if(_TemplateSkill.empty()) if(_TemplateSkill.empty())

@ -359,7 +359,7 @@ void CGuildManager::update()
for (uint i = 0; i < _GuildMembers.size(); ++i) for (uint i = 0; i < _GuildMembers.size(); ++i)
{ {
if (!pSMC->getString (_GuildMembers[i].NameID, _GuildMembers[i].Name)) bAllValid = false; if (!pSMC->getString (_GuildMembers[i].NameID, _GuildMembers[i].Name)) bAllValid = false;
else _GuildMembers[i].Name = CEntityCL::removeTitleAndShardFromName(_GuildMembers[i].Name); else _GuildMembers[i].Name = CEntityCL::removeTitleAndShardFromName(_GuildMembers[i].Name.toUtf8());
} }
// If all is valid no more need update and if guild is opened update the interface // If all is valid no more need update and if guild is opened update the interface
@ -875,7 +875,7 @@ class CAHGuildSheetOpen : public IActionHandler
CCtrlBase *inviteButton = pLine->getCtrl("invite_button"); CCtrlBase *inviteButton = pLine->getCtrl("invite_button");
if (inviteButton != NULL) if (inviteButton != NULL)
inviteButton->setActive(rGuildMembers[i].Online != ccs_offline && rGuildMembers[i].Name != UserEntity->getEntityName()); inviteButton->setActive(rGuildMembers[i].Online != ccs_offline && rGuildMembers[i].Name.toUtf8() != UserEntity->getEntityName());
// Enter Date // Enter Date
CViewText *pViewEnterDate = dynamic_cast<CViewText*>(pLine->getView(TEMPLATE_GUILD_MEMBER_ENTER_DATE)); CViewText *pViewEnterDate = dynamic_cast<CViewText*>(pLine->getView(TEMPLATE_GUILD_MEMBER_ENTER_DATE));

@ -1066,7 +1066,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostName)
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
const std::string name = CUtfStringView(pSMC->getOutpostLocalizedName(CSheetId(nSheet))).toUtf8(); const char *name = pSMC->getOutpostLocalizedName(CSheetId(nSheet));
result.setString(name); result.setString(name);
@ -1093,7 +1093,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostDesc)
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
const string name = CUtfStringView(pSMC->getOutpostLocalizedDescription(CSheetId(nSheet))).toUtf8(); const char *name = pSMC->getOutpostLocalizedDescription(CSheetId(nSheet));
result.setString(name); result.setString(name);
@ -1120,7 +1120,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingName)
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
const string name = CUtfStringView(pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet))).toUtf8(); const char *name = pSMC->getOutpostBuildingLocalizedName(CSheetId(nSheet));
result.setString(name); result.setString(name);
@ -1146,18 +1146,18 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc)
} }
// get sheet name // get sheet name
string name; const char *name;
CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet)); CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet));
COutpostBuildingSheet *pOBS = dynamic_cast<COutpostBuildingSheet*>(pSheet); COutpostBuildingSheet *pOBS = dynamic_cast<COutpostBuildingSheet*>(pSheet);
if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty) if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty)
{ {
// Don't display description if the building is an empty slot // Don't display description if the building is an empty slot
name.clear(); name = "";
} }
else else
{ {
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
name = CUtfStringView(pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet))).toUtf8(); name = pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet));
} }
@ -1186,7 +1186,7 @@ static DECLARE_INTERFACE_USER_FCT(getSquadName)
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
const string name = CUtfStringView(pSMC->getSquadLocalizedName(CSheetId(nSheet))).toUtf8(); const char *name = pSMC->getSquadLocalizedName(CSheetId(nSheet));
result.setString(name); result.setString(name);
@ -1213,7 +1213,7 @@ static DECLARE_INTERFACE_USER_FCT(getSquadDesc)
// get sheet name // get sheet name
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
const string name = CUtfStringView(pSMC->getSquadLocalizedDescription(CSheetId(nSheet))).toUtf8(); const char *name = pSMC->getSquadLocalizedDescription(CSheetId(nSheet));
result.setString(name); result.setString(name);

@ -320,8 +320,8 @@ static DECLARE_INTERFACE_USER_FCT(getSheetName)
else else
{ {
const CItemSheet *itemSheet = getItemSheet(args); const CItemSheet *itemSheet = getItemSheet(args);
string tmp; const char *tmp = "";
if (itemSheet != NULL) tmp = CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id)).toUtf8(); if (itemSheet != NULL) tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(itemSheet->Id);
result.setString(tmp); result.setString(tmp);
return true; return true;
} }
@ -346,8 +346,8 @@ static DECLARE_INTERFACE_USER_FCT(getItemTranslatedName)
return false; return false;
} }
string tmp; const char *tmp = "";
tmp = CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet)).toUtf8(); tmp = STRING_MANAGER::CStringManagerClient::getItemLocalizedName(sheet);
result.setString(tmp); result.setString(tmp);
return true; return true;
} }

@ -358,7 +358,7 @@ public:
} }
else else
{ {
std::string name = UserEntity->getEntityName().toUtf8(); std::string name = UserEntity->getEntityName();
if (*it == 'P') name = toUpper(name); if (*it == 'P') name = toUpper(name);
formatedResult += name; formatedResult += name;
} }
@ -391,7 +391,7 @@ public:
} }
else else
{ {
botName = entity->getDisplayName().toUtf8(); botName = entity->getDisplayName();
} }
CCharacterCL *pChar = dynamic_cast<CCharacterCL*>(entity); CCharacterCL *pChar = dynamic_cast<CCharacterCL*>(entity);
if (pChar != NULL) if (pChar != NULL)
@ -405,7 +405,7 @@ public:
spprn.Woman = womanTitle; spprn.Woman = womanTitle;
spprn.cbIDStringReceived(sTitleTranslated); spprn.cbIDStringReceived(sTitleTranslated);
botName = CEntityCL::removeTitleAndShardFromName(botName).toUtf8(); botName = CEntityCL::removeTitleAndShardFromName(botName);
// short name (with no title such as 'guard', 'merchant' ...) // short name (with no title such as 'guard', 'merchant' ...)
if (*it == 's') if (*it == 's')
@ -425,37 +425,6 @@ public:
formatedResult += botName; formatedResult += botName;
break; break;
} }
case '\'': // 's and 'S -> Potatos Identity and TOMATOES IDENTITY
{
std::string::const_iterator it2 = it;
++it2;
if (it2 == inputString.end())
{
formatedResult += "$'";
}
else
{
it = it2;
if (*it == 's' || *it == 'S')
{
if (formatedResult.size() && (formatedResult[formatedResult.size() - 1] == 's' || formatedResult[formatedResult.size() - 1] == 'S'))
{
formatedResult += "\xE2\x80\x99"; // RIGHT SINGLE QUOTATION MARK
}
else
{
formatedResult += "\xE2\x80\x99"; // RIGHT SINGLE QUOTATION MARK
formatedResult += *it;
}
}
else
{
--it;
formatedResult += "$'";
}
}
break;
}
default: default:
{ {
formatedResult += '$'; formatedResult += '$';
@ -4246,7 +4215,7 @@ bool CInterfaceManager::parseTokens(string& ucstr)
// Parse the parameter // Parse the parameter
if (token_param == "name") if (token_param == "name")
{ {
string name = pTokenSubjectEntity->getDisplayName().toUtf8(); string name = pTokenSubjectEntity->getDisplayName();
// special case where there is only a title, very rare case for some NPC // special case where there is only a title, very rare case for some NPC
if (name.empty()) if (name.empty())
{ {

@ -1345,7 +1345,7 @@ int CLuaIHMRyzom::getPlayerGender(CLuaState &ls)
int CLuaIHMRyzom::getPlayerName(CLuaState &ls) int CLuaIHMRyzom::getPlayerName(CLuaState &ls)
{ {
CLuaIHM::checkArgCount(ls, "getPlayerName", 0); CLuaIHM::checkArgCount(ls, "getPlayerName", 0);
ls.push(UserEntity->getEntityName().toUtf8()); ls.push(UserEntity->getEntityName());
return 1; return 1;
} }
@ -1423,7 +1423,7 @@ int CLuaIHMRyzom::getTargetName(CLuaState &ls)
if (!target) return 0; if (!target) return 0;
ls.push(target->getEntityName().toUtf8()); ls.push(target->getEntityName());
return 1; return 1;
} }
@ -3218,7 +3218,7 @@ void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string
if (UserEntity) if (UserEntity)
{ {
userName = UserEntity->getDisplayName().toString(); userName = UserEntity->getDisplayName();
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
ucstring ucsTmp; ucstring ucsTmp;
pSMC->getString(UserEntity->getGuildNameID(), ucsTmp); pSMC->getString(UserEntity->getGuildNameID(), ucsTmp);
@ -3584,7 +3584,7 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg)
CInterfaceManager *im = CInterfaceManager::getInstance(); CInterfaceManager *im = CInterfaceManager::getInstance();
w->setKeyboardFocus(); w->setKeyboardFocus();
w->enableBlink(1); 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(); CGroupEditBox *eb = w->getEditBox();
if (eb != NULL) if (eb != NULL)

@ -1276,7 +1276,7 @@ void CPeopleInterraction::addContactInList(uint32 contactId, const ucstring &nam
CPeopleList &pl= nList==0?FriendList:IgnoreList; CPeopleList &pl= nList==0?FriendList:IgnoreList;
// remove the shard name if possible // remove the shard name if possible
ucstring name= CEntityCL::removeShardFromName(nameIn); ucstring name= CEntityCL::removeShardFromName(nameIn.toUtf8());
// add the contact to this list // add the contact to this list
sint index = pl.getIndexFromName(name); sint index = pl.getIndexFromName(name);
@ -1327,7 +1327,7 @@ bool CPeopleInterraction::isContactInList(const ucstring &nameIn, uint8 nList) c
// select correct people list // select correct people list
const CPeopleList &pl= nList==0?FriendList:IgnoreList; const CPeopleList &pl= nList==0?FriendList:IgnoreList;
// remove the shard name if possible // remove the shard name if possible
ucstring name= CEntityCL::removeShardFromName(nameIn); ucstring name= CEntityCL::removeShardFromName(nameIn.toUtf8());
return pl.getIndexFromName(name) != -1; return pl.getIndexFromName(name) != -1;
} }
@ -2250,7 +2250,7 @@ public:
if (peopleList) if (peopleList)
{ {
// don't add if it is the player name // don't add if it is the player name
if (!ClientCfg.Local && (UserEntity->getEntityName() == geb->getInputStringAsUtf16())) if (!ClientCfg.Local && (UserEntity->getEntityName() == geb->getInputString()))
{ {
displayVisibleSystemMsg(CI18N::get("uiCantAddYourSelfInContactList")); displayVisibleSystemMsg(CI18N::get("uiCantAddYourSelfInContactList"));
} }

@ -436,7 +436,7 @@ void CSBrickManager::compileBrickProperties()
// **** for all bricks, recompute localized text with formated version // **** for all bricks, recompute localized text with formated version
ucstring textTemp; string textTemp;
textTemp.reserve(1000); textTemp.reserve(1000);
for (std::vector<CSBrickSheet *>::size_type ib = 0; ib < _BrickVector.size(); ++ib) for (std::vector<CSBrickSheet *>::size_type ib = 0; ib < _BrickVector.size(); ++ib)
{ {
@ -445,7 +445,7 @@ void CSBrickManager::compileBrickProperties()
continue; continue;
// Get the Brick texts // Get the Brick texts
ucstring texts[3]; std::string texts[3];
texts[0]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brickSheet->Id); texts[0]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brickSheet->Id);
texts[1]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedDescription(brickSheet->Id); texts[1]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedDescription(brickSheet->Id);
texts[2]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheet->Id); texts[2]= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheet->Id);
@ -453,7 +453,7 @@ void CSBrickManager::compileBrickProperties()
// For alls texts, parse format // For alls texts, parse format
for(uint i=0;i<3;i++) for(uint i=0;i<3;i++)
{ {
ucstring &text= texts[i]; string &text= texts[i];
textTemp.erase(); textTemp.erase();
// Parse the text // Parse the text

@ -832,7 +832,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c
} }
if (!senderName.empty()) if (!senderName.empty())
{ {
CEntityCL *senderEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(senderName), true, true); CEntityCL *senderEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(senderName.toUtf8()), true, true);
if (senderEntity) if (senderEntity)
{ {
if (senderEntity->Type != CEntityCL::Player) if (senderEntity->Type != CEntityCL::Player)
@ -845,7 +845,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c
} }
else else
{ {
CEntityCL *destEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(playerName), false, true); CEntityCL *destEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(playerName.toUtf8()), false, true);
if (destEntity) if (destEntity)
{ {
destEntity->removeStateFx(); destEntity->removeStateFx();
@ -866,7 +866,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c
// if tell, bkup sendername // if tell, bkup sendername
if (mode == CChatGroup::tell && windowVisible && !senderName.empty()) if (mode == CChatGroup::tell && windowVisible && !senderName.empty())
{ {
PeopleInterraction.LastSenderName = CEntityCL::removeTitleAndShardFromName(senderName); PeopleInterraction.LastSenderName = CEntityCL::removeTitleAndShardFromName(senderName.toUtf8());
} }
} }
@ -928,7 +928,7 @@ void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const u
prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," ");
bool windowVisible; bool windowVisible;
ucstring goodSenderName = CEntityCL::removeTitleAndShardFromName(senderName); ucstring goodSenderName = CEntityCL::removeTitleAndShardFromName(senderName.toUtf8());
// The sender part is up to and including the first ":" after the goodSenderName // The sender part is up to and including the first ":" after the goodSenderName
ucstring::size_type pos = finalString.find(goodSenderName); ucstring::size_type pos = finalString.find(goodSenderName);
@ -2299,11 +2299,9 @@ void impulsePhraseSend(NLMISC::CBitMemStream &impulse)
void impulseStringResp(NLMISC::CBitMemStream &impulse) void impulseStringResp(NLMISC::CBitMemStream &impulse)
{ {
uint32 stringId; uint32 stringId;
string strUtf8; string str;
impulse.serial(stringId); impulse.serial(stringId);
impulse.serial(strUtf8); impulse.serial(str);
ucstring str;
str.fromUtf8(strUtf8);
if (PermanentlyBanned) return; if (PermanentlyBanned) return;
@ -3389,7 +3387,7 @@ private:
public: public:
// called when the string is available // 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 // don't care if already displayed
if(_AlreadyDisplayed) if(_AlreadyDisplayed)

@ -702,7 +702,7 @@ void CPlayerCL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle *
} }
// update title when gender changed // update title when gender changed
const ucstring replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, _Gender == GSGENDER::female)); const string replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw.toUtf8(), _Gender == GSGENDER::female);
if (!replacement.empty() || !ClientCfg.DebugStringManager) if (!replacement.empty() || !ClientCfg.DebugStringManager)
{ {
// Get extended name // Get extended name

@ -446,7 +446,7 @@ void CPlayerR2CL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle
} }
// update title when gender changed // update title when gender changed
const ucstring replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw,_Gender == GSGENDER::female)); const string replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw.toUtf8(),_Gender == GSGENDER::female));
if (!replacement.empty()) if (!replacement.empty())
{ {
// Get extended name // Get extended name

@ -50,7 +50,7 @@ extern NL3D::UMaterial LoadingMaterialFull;
extern std::vector<UTextureFile*> LogoBitmaps; extern std::vector<UTextureFile*> LogoBitmaps;
extern uint TipsOfTheDayIndex; extern uint TipsOfTheDayIndex;
extern ucstring TipsOfTheDay; extern string TipsOfTheDay;
extern bool UseEscapeDuringLoading; extern bool UseEscapeDuringLoading;
CProgress::CProgress () CProgress::CProgress ()
@ -287,8 +287,8 @@ void CProgress::internalProgress (float value)
// Display the tips of the day. // Display the tips of the day.
TextContext->setFontSize((uint)(16.f * fontFactor)); TextContext->setFontSize((uint)(16.f * fontFactor));
TextContext->setHotSpot(UTextContext::MiddleTop); TextContext->setHotSpot(UTextContext::MiddleTop);
ucstring::size_type index = 0; string::size_type index = 0;
ucstring::size_type end = TipsOfTheDay.find((ucchar)'\n'); string::size_type end = TipsOfTheDay.find('\n');
if (end == string::npos) if (end == string::npos)
end = TipsOfTheDay.size(); end = TipsOfTheDay.size();
float fY = ClientCfg.TipsY; float fY = ClientCfg.TipsY;
@ -297,15 +297,15 @@ void CProgress::internalProgress (float value)
while (index < end) while (index < end)
{ {
// Get the line // Get the line
ucstring line = TipsOfTheDay.substr (index, end-index); string line = TipsOfTheDay.substr (index, end-index);
// Draw the line // Draw the line
TextContext->printAt(0.5f, fY, line); TextContext->printAt(0.5f, fY, line);
fY = nextLine (TextContext->getFontSize(), Driver->getWindowHeight(), fY); fY = nextLine (TextContext->getFontSize(), Driver->getWindowHeight(), fY);
index=end+1; index=end+1;
end = TipsOfTheDay.find((ucchar)'\n', index); end = TipsOfTheDay.find('\n', index);
if (end == ucstring::npos) if (end == string::npos)
end = TipsOfTheDay.size(); end = TipsOfTheDay.size();
} }
@ -338,7 +338,7 @@ void CProgress::internalProgress (float value)
TextContext->setFontSize((uint)(15.f * fontFactor)); TextContext->setFontSize((uint)(15.f * fontFactor));
TextContext->setHotSpot(UTextContext::BottomLeft); 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); UTextContext::CStringInfo info = TextContext->getStringInfo(uc);
float stringX = 0.5f - info.StringWidth/(ClientCfg.Width*2); float stringX = 0.5f - info.StringWidth/(ClientCfg.Width*2);
TextContext->printAt(stringX, 7.f / ClientCfg.Height, uc); TextContext->printAt(stringX, 7.f / ClientCfg.Height, uc);
@ -386,13 +386,13 @@ void CProgress::internalProgress (float value)
TextContext->setFontSize( (uint)(16.f * fontFactor)); TextContext->setFontSize( (uint)(16.f * fontFactor));
// build the ucstr(s) // build the ucstr(s)
ucstring ucstr = CI18N::get((*itpc).Text); string ucstr = CI18N::get((*itpc).Text);
vector<ucstring> vucstr; vector<string> vucstr;
ucstring sep("\n"); string sep("\n");
splitUCString(ucstr,sep,vucstr); splitString(ucstr,sep,vucstr);
// Letter size // 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 fontHeight = (uint) si.StringHeight + 2; // we add 2 pixels for the gap
uint i; uint i;

@ -279,12 +279,12 @@ void CAutoGroup::group(CObject *newEntityDesc, const NLMISC::CVectorD &createPos
getEditor().getDMC().flushActions(); getEditor().getDMC().flushActions();
return; return;
} }
ucstring readableName; string readableName;
CLuaState &ls = getEditor().getLua(); CLuaState &ls = getEditor().getLua();
R2::getEditor().getEnv()["PaletteIdToGroupTranslation"][newEntityDesc->getAttr("Base")->toString()].push(); R2::getEditor().getEnv()["PaletteIdToGroupTranslation"][newEntityDesc->getAttr("Base")->toString()].push();
if (ls.isString(-1)) if (ls.isString(-1))
readableName.fromUtf8(ls.toString(-1)); readableName = ls.toString(-1);
ucstring ucGroupName = ucstring(readableName + " " + CI18N::get("uiR2EDNameGroup")); string ucGroupName = readableName + " " + CI18N::get("uiR2EDNameGroup");
newGroup->set("Name", getEditor().genInstanceName(ucGroupName).toUtf8()); newGroup->set("Name", getEditor().genInstanceName(ucGroupName).toUtf8());
getEditor().getDMC().requestInsertNode(destGroup->getParentAct()->getId(), getEditor().getDMC().requestInsertNode(destGroup->getParentAct()->getId(),

@ -1017,7 +1017,7 @@ void CDisplayerVisualEntity::updateName()
{ {
//BENCH(setEntityName) //BENCH(setEntityName)
_Entity->setEntityName(ucName); _Entity->setEntityName(ucName.toUtf8());
} }
{ {
//BENCH(buildInSceneInterface) //BENCH(buildInSceneInterface)

@ -1571,12 +1571,12 @@ int CEditor::luaGetUserEntityName(CLuaState &ls)
CLuaIHM::checkArgCount(ls, funcName, 1); // this is a method CLuaIHM::checkArgCount(ls, funcName, 1); // this is a method
if (UserEntity) if (UserEntity)
{ {
ucstring name = UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis; string name = UserEntity->getEntityName()+PlayerSelectedHomeShardNameWithParenthesis;
ls.push( name.toUtf8() ); ls.push( name );
} }
else else
{ {
ls.push(std::string("")); ls.push(std::string());
} }
return 1; return 1;

@ -551,9 +551,9 @@ void CToolDrawPrim::commit()
if (!_Extending) if (!_Extending)
{ {
// set readable name // set readable name
ucstring readableName = NLMISC::CI18N::get(_PrimType == Road ? "uiR2EDNameBotRoad" : "uiR2EDNameBotRegion"); string readableName = NLMISC::CI18N::get(_PrimType == Road ? "uiR2EDNameBotRoad" : "uiR2EDNameBotRegion");
readableName = getEditor().genInstanceName(readableName); readableName = getEditor().genInstanceName(readableName).toUtf8();
desc->set("Name", readableName.toUtf8()); desc->set("Name", readableName);
// send creation command // send creation command
// tmp : static npc counter // tmp : static npc counter
// add in component list of default feature // add in component list of default feature

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2020/WindowsSettings">
<heapType>SegmentHeap</heapType>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>

@ -39,17 +39,17 @@ namespace STRING_MANAGER
// *************************************************************************** // ***************************************************************************
map<string, CStringManagerClient::CItem> CStringManagerClient::_SpecItem_TempMap; map<string, CStringManagerClient::CItem> CStringManagerClient::_SpecItem_TempMap;
map<ucstring, ucstring> CStringManagerClient::_DynStrings; map<string, string> CStringManagerClient::_DynStrings;
vector<ucstring> CStringManagerClient::_TitleWords; vector<string> CStringManagerClient::_TitleWords;
bool CStringManagerClient::_SpecItem_MemoryCompressed = false; bool CStringManagerClient::_SpecItem_MemoryCompressed = false;
char *CStringManagerClient::_SpecItem_Labels = NULL; char *CStringManagerClient::_SpecItem_Labels = NULL;
ucchar *CStringManagerClient::_SpecItem_NameDesc = NULL; char *CStringManagerClient::_SpecItem_NameDesc = NULL;
vector<CStringManagerClient::CItemLight> CStringManagerClient::_SpecItems; vector<CStringManagerClient::CItemLight> CStringManagerClient::_SpecItems;
bool MustReleaseStaticArrays = true; bool MustReleaseStaticArrays = true;
CStringManagerClient *CStringManagerClient::_Instance= NULL; CStringManagerClient *CStringManagerClient::_Instance= NULL;
ucstring CStringManagerClient::_WaitString("???"); string CStringManagerClient::_WaitString("???");
CStringManagerClient::CStringManagerClient() CStringManagerClient::CStringManagerClient()
@ -57,7 +57,7 @@ namespace STRING_MANAGER
_CacheInited = false; _CacheInited = false;
_CacheLoaded = false; _CacheLoaded = false;
// insert the empty string. // 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 // reserve some place to avoid reallocation as possible
_CacheStringToSave.reserve(1024); _CacheStringToSave.reserve(1024);
} }
@ -99,7 +99,7 @@ namespace STRING_MANAGER
} }
} }
void CStringManagerClient::initCache(const std::string &languageCode) void CStringManagerClient::initCache(const string &languageCode)
{ {
H_AUTO( CStringManagerClient_initLanguage ) H_AUTO( CStringManagerClient_initLanguage )
@ -112,7 +112,7 @@ namespace STRING_MANAGER
// NB : we keep the waiting strings and dyn strings // NB : we keep the waiting strings and dyn strings
// insert the empty string. // insert the empty string.
_ReceivedStrings.insert(make_pair((uint)EmptyStringId, ucstring())); _ReceivedStrings.insert(make_pair((uint)EmptyStringId, string()));
// to be inited, language code must be filled // to be inited, language code must be filled
_CacheInited = !m_LanguageCode.empty(); _CacheInited = !m_LanguageCode.empty();
@ -128,8 +128,10 @@ namespace STRING_MANAGER
{ {
try try
{ {
std::string clientApp = ClientCfg.ConfigFile.getVar("Application").asString(0); const uint currentVersion = 1;
_CacheFilename = std::string("save/") + clientApp + "_" + toString(shardId) + "_" + m_LanguageCode + ".string_cache";
string clientApp = ClientCfg.ConfigFile.getVar("Application").asString(0);
_CacheFilename = string("save/") + clientApp + "_" + toString(shardId) + "_" + m_LanguageCode + ".string_cache";
nlinfo("SM : Try to open the string cache : %s", _CacheFilename.c_str()); nlinfo("SM : Try to open the string cache : %s", _CacheFilename.c_str());
@ -138,6 +140,8 @@ namespace STRING_MANAGER
// there is a cache file, check date reset it if needed // there is a cache file, check date reset it if needed
{ {
NLMISC::CIFile file(_CacheFilename); NLMISC::CIFile file(_CacheFilename);
file.setVersionException(false, false);
file.serialVersion(currentVersion);
file.serial(_Timestamp); file.serial(_Timestamp);
} }
@ -146,6 +150,7 @@ namespace STRING_MANAGER
nlinfo("SM: Clearing string cache : outofdate"); nlinfo("SM: Clearing string cache : outofdate");
// the cache is not sync, reset it // the cache is not sync, reset it
NLMISC::COFile file(_CacheFilename); NLMISC::COFile file(_CacheFilename);
file.serialVersion(currentVersion);
file.serial(timestamp); file.serial(timestamp);
} }
else else
@ -158,6 +163,7 @@ namespace STRING_MANAGER
nlinfo("SM: Creating string cache"); nlinfo("SM: Creating string cache");
// cache file don't exist, create it with the timestamp // cache file don't exist, create it with the timestamp
NLMISC::COFile file(_CacheFilename); NLMISC::COFile file(_CacheFilename);
file.serialVersion(currentVersion);
file.serial(timestamp); file.serial(timestamp);
} }
@ -168,17 +174,19 @@ namespace STRING_MANAGER
// NB : we keep the waiting strings and dyn strings // NB : we keep the waiting strings and dyn strings
// insert the empty string. // insert the empty string.
_ReceivedStrings.insert(make_pair((uint)EmptyStringId, ucstring())); _ReceivedStrings.insert(make_pair((uint)EmptyStringId, string()));
// load the cache file // load the cache file
NLMISC::CIFile file(_CacheFilename); NLMISC::CIFile file(_CacheFilename);
int version = file.serialVersion(currentVersion);
file.serial(_Timestamp); file.serial(_Timestamp);
nlassert(_Timestamp == timestamp); nlassert(_Timestamp == timestamp);
nlassert(version >= 1); // Initial version
while (!file.eof()) while (!file.eof())
{ {
uint32 id; uint32 id;
ucstring str; string str;
file.serial(id); file.serial(id);
file.serial(str); file.serial(str);
@ -202,12 +210,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 ) H_AUTO( CStringManagerClient_waitString )
nlassert(premover && result); nlassert(premover && result);
ucstring value; string value;
if (getString(stringId, value)) if (getString(stringId, value))
*result = value; *result = value;
else else
@ -225,7 +233,7 @@ namespace STRING_MANAGER
H_AUTO( CStringManagerClient_waitString2 ) H_AUTO( CStringManagerClient_waitString2 )
nlassert(pcallback != 0); nlassert(pcallback != 0);
ucstring value; string value;
if (getString(stringId, value)) if (getString(stringId, value))
{ {
pcallback->onStringAvailable(stringId, value); pcallback->onStringAvailable(stringId, value);
@ -238,12 +246,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 ) H_AUTO( CStringManagerClient_waitDynString )
nlassert(premover && result); nlassert(premover && result);
ucstring value; string value;
if (getDynString(stringId, value)) if (getDynString(stringId, value))
*result = value; *result = value;
else else
@ -261,7 +269,7 @@ namespace STRING_MANAGER
H_AUTO( CStringManagerClient_waitDynString2 ) H_AUTO( CStringManagerClient_waitDynString2 )
nlassert(pcallback != 0); nlassert(pcallback != 0);
ucstring value; string value;
if (getDynString(stringId, value)) if (getDynString(stringId, value))
{ {
pcallback->onDynStringAvailable(stringId, value); pcallback->onDynStringAvailable(stringId, value);
@ -338,7 +346,7 @@ restartLoop4:
bool CStringManagerClient::getString(uint32 stringId, ucstring &result) bool CStringManagerClient::getString(uint32 stringId, string &result)
{ {
H_AUTO( CStringManagerClient_getString ) H_AUTO( CStringManagerClient_getString )
@ -365,7 +373,7 @@ restartLoop4:
_WaitingStrings.insert(stringId); _WaitingStrings.insert(stringId);
// need to ask for this string. // need to ask for this string.
NLMISC::CBitMemStream bms; NLMISC::CBitMemStream bms;
const std::string msgType = "STRING_MANAGER:STRING_RQ"; const string msgType = "STRING_MANAGER:STRING_RQ";
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
{ {
bms.serial( stringId ); bms.serial( stringId );
@ -382,7 +390,7 @@ restartLoop4:
{ {
char tmp[1024]; char tmp[1024];
sprintf(tmp, "<WAIT STR %u>", stringId); sprintf(tmp, "<WAIT STR %u>", stringId);
result = ucstring(tmp); result = tmp;
} }
else else
result.erase(); // = _WaitString; result.erase(); // = _WaitString;
@ -393,14 +401,14 @@ restartLoop4:
{ {
char tmp[1024]; char tmp[1024];
sprintf(tmp, "<STR %u>", stringId); sprintf(tmp, "<STR %u>", stringId);
result = ucstring(tmp) + it->second; result = tmp + it->second;
} }
else else
{ {
result = it->second; result = it->second;
if (result.size() > 9 && result.substr(0, 9) == ucstring("<missing:")) if (result.size() > 9 && result.substr(0, 9) == "<missing:")
{ {
map<ucstring, ucstring>::iterator itds = _DynStrings.find(result.substr(9, result.size()-10)); map<string, string>::iterator itds = _DynStrings.find(result.substr(9, result.size()-10));
if (itds != _DynStrings.end()) if (itds != _DynStrings.end())
result = itds->second; result = itds->second;
} }
@ -410,7 +418,7 @@ restartLoop4:
return true; return true;
} }
void CStringManagerClient::receiveString(uint32 stringId, const ucstring &str) void CStringManagerClient::receiveString(uint32 stringId, const string &str)
{ {
H_AUTO( CStringManagerClient_receiveString ) H_AUTO( CStringManagerClient_receiveString )
@ -427,8 +435,8 @@ restartLoop4:
TStringsContainer::iterator it(_ReceivedStrings.find(stringId)); TStringsContainer::iterator it(_ReceivedStrings.find(stringId));
nlwarning("Receiving stringID %u (%s), already in received string (%s), replacing with new value.", nlwarning("Receiving stringID %u (%s), already in received string (%s), replacing with new value.",
stringId, stringId,
str.toString().c_str(), str.c_str(),
it->second.toString().c_str()); it->second.c_str());
if (it->second != str) if (it->second != str)
it->second = str; it->second = str;
@ -492,7 +500,7 @@ restartLoop:
last = _WaitingDynStrings.end(); last = _WaitingDynStrings.end();
for (; first != last; ++first) for (; first != last; ++first)
{ {
ucstring value; string value;
uint number = first->first; uint number = first->first;
/// Warning: if getDynString() return true, 'first' is erased => don't use it after in this loop /// Warning: if getDynString() return true, 'first' is erased => don't use it after in this loop
if (getDynString(number, value)) if (getDynString(number, value))
@ -624,7 +632,7 @@ restartLoop:
return false; return false;
} }
// ok, we have the base string, we can serial the parameters // 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) for (; first != last; ++first)
{ {
if (*first == '%') if (*first == '%')
@ -707,10 +715,10 @@ restartLoop:
if (dynInfo.Status == TDynStringInfo::serialized) if (dynInfo.Status == TDynStringInfo::serialized)
{ {
// try to retreive all string parameter to build the string. // try to retreive all string parameter to build the string.
ucstring temp; string temp;
temp.reserve(dynInfo.String.size() * 2); temp.reserve(dynInfo.String.size() * 2);
ucstring::iterator src(dynInfo.String.begin()); string::iterator src(dynInfo.String.begin());
ucstring::iterator move = src; string::iterator move = src;
std::vector<TParamValue>::iterator first(dynInfo.Params.begin()), last(dynInfo.Params.end()); std::vector<TParamValue>::iterator first(dynInfo.Params.begin()), last(dynInfo.Params.end());
for (; first != last; ++first) for (; first != last; ++first)
@ -720,7 +728,7 @@ restartLoop:
{ {
case string_id: case string_id:
{ {
ucstring str; string str;
if (!getString(param.StringId, str)) if (!getString(param.StringId, str))
return false; return false;
@ -736,14 +744,14 @@ restartLoop:
// If the shard name is the same as the player home shard name, remove it // If the shard name is the same as the player home shard name, remove it
uint len= (uint)PlayerSelectedHomeShardNameWithParenthesis.size(); uint len= (uint)PlayerSelectedHomeShardNameWithParenthesis.size();
uint start= (uint)str.size()-len; 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); str.resize(start);
} }
} }
} }
// If the string contains a title, then remove it // If the string contains a title, then remove it
ucstring::size_type pos = str.find('$'); string::size_type pos = str.find('$');
if ( ! str.empty() && pos != ucstring::npos) if ( ! str.empty() && pos != ucstring::npos)
{ {
str = CEntityCL::removeTitleFromName(str); str = CEntityCL::removeTitleFromName(str);
@ -761,13 +769,13 @@ restartLoop:
char value[1024]; char value[1024];
sprintf(value, "%d", param.Integer); sprintf(value, "%d", param.Integer);
temp.append(move, src+param.ReplacementPoint); temp.append(move, src+param.ReplacementPoint);
temp+=ucstring(value); temp += value;
move = dynInfo.String.begin()+param.ReplacementPoint+2; move = dynInfo.String.begin()+param.ReplacementPoint+2;
} }
break; break;
case time: case time:
{ {
ucstring value; string value;
uint32 time = (uint32)param.Time; uint32 time = (uint32)param.Time;
if( time >= (10*60*60) ) if( time >= (10*60*60) )
{ {
@ -798,7 +806,7 @@ restartLoop:
char value[1024]; char value[1024];
sprintf(value, "%u", (uint32)param.Money); sprintf(value, "%u", (uint32)param.Money);
temp.append(move, src+param.ReplacementPoint); temp.append(move, src+param.ReplacementPoint);
temp+=ucstring(value); temp += value;
move = dynInfo.String.begin()+param.ReplacementPoint+2; move = dynInfo.String.begin()+param.ReplacementPoint+2;
} }
// TODO // TODO
@ -807,7 +815,7 @@ restartLoop:
break; break;
case dyn_string_id: case dyn_string_id:
{ {
ucstring dynStr; string dynStr;
if (!getDynString(param.DynStringId, dynStr)) if (!getDynString(param.DynStringId, dynStr))
return false; return false;
temp.append(move, src+param.ReplacementPoint); temp.append(move, src+param.ReplacementPoint);
@ -825,8 +833,8 @@ restartLoop:
// apply any 'delete' character in the string and replace double '%' // apply any 'delete' character in the string and replace double '%'
{ {
uint i =0; ptrdiff_t i =0;
while (i < temp.size()) while (i < (ptrdiff_t)temp.size())
{ {
if (temp[i] == 8) if (temp[i] == 8)
{ {
@ -855,7 +863,7 @@ restartLoop:
} }
bool CStringManagerClient::getDynString(uint32 dynStringId, ucstring &result) bool CStringManagerClient::getDynString(uint32 dynStringId, std::string &result)
{ {
H_AUTO( CStringManagerClient_getDynString ) H_AUTO( CStringManagerClient_getDynString )
@ -884,7 +892,7 @@ restartLoop:
{ {
char tmp[1024]; char tmp[1024];
sprintf(tmp, "<DYNSTR %u>", dynStringId); sprintf(tmp, "<DYNSTR %u>", dynStringId);
result = ucstring(tmp) + it->second.String; result = tmp + it->second.String;
} }
else else
result = it->second.String; result = it->second.String;
@ -910,7 +918,7 @@ restartLoop:
nlwarning("DynStringID %u is unknown !", dynStringId); nlwarning("DynStringID %u is unknown !", dynStringId);
char tmp[1024]; char tmp[1024];
sprintf(tmp, "<UNKNOWN DYNSTR %u>", dynStringId); sprintf(tmp, "<UNKNOWN DYNSTR %u>", dynStringId);
result = ucstring(tmp); result = tmp;
} }
else else
result.erase(); //_WaitString; result.erase(); //_WaitString;
@ -922,7 +930,7 @@ restartLoop:
{ {
char tmp[1024]; char tmp[1024];
sprintf(tmp, "<DYNSTR %u>", dynStringId); sprintf(tmp, "<DYNSTR %u>", dynStringId);
result = ucstring(tmp) + it->second.String; result = tmp + it->second.String;
} }
else else
result = it->second.String; result = it->second.String;
@ -935,7 +943,7 @@ restartLoop:
{ {
char tmp[1024]; char tmp[1024];
sprintf(tmp, "<WAIT DYNSTR %u>", dynStringId); sprintf(tmp, "<WAIT DYNSTR %u>", dynStringId);
result = ucstring(tmp); result = tmp;
} }
else else
result.erase(); // = _WaitString; result.erase(); // = _WaitString;
@ -945,7 +953,7 @@ restartLoop:
} }
// Tool fct to lookup a reference file // Tool fct to lookup a reference file
static string lookupReferenceFile(const std::string &fileName) static string lookupReferenceFile(const string &fileName)
{ {
string referenceFile; string referenceFile;
// special location for the "wk" language // special location for the "wk" language
@ -966,14 +974,14 @@ restartLoop:
return referenceFile; return referenceFile;
} }
void CLoadProxy::loadStringFile(const std::string &filename, ucstring &text) void CLoadProxy::loadStringFile(const string &filename, ucstring &text)
{ {
vector<TStringInfo> reference; vector<TStringInfo> reference;
vector<TStringInfo> addition; vector<TStringInfo> addition;
vector<TStringInfo> diff; vector<TStringInfo> diff;
// get the correct path name of the ref file // get the correct path name of the ref file
std::string referenceFile= lookupReferenceFile(filename); string referenceFile= lookupReferenceFile(filename);
// load the reference file // load the reference file
if (!referenceFile.empty()) if (!referenceFile.empty())
@ -1043,7 +1051,7 @@ public:
TWorksheet diff; TWorksheet diff;
// get the correct path name of the ref file // get the correct path name of the ref file
std::string referenceFile= lookupReferenceFile(filename); string referenceFile= lookupReferenceFile(filename);
// load the reference file // load the reference file
if (!referenceFile.empty()) if (!referenceFile.empty())
@ -1136,7 +1144,7 @@ public:
const string StringClientPackedFileName= "./save/string_client.pack"; const string StringClientPackedFileName= "./save/string_client.pack";
// Must Increment this number if change are made to the code (else change not taken into account) // Must Increment this number if change are made to the code (else change not taken into account)
const uint StringClientPackedVersion= 0; const uint StringClientPackedVersion= 0;
bool CStringManagerClient::checkWordFileDates(vector<CFileCheck> &fileChecks, const std::vector<std::string> &fileNames, const std::string &languageCode) bool CStringManagerClient::checkWordFileDates(vector<CFileCheck> &fileChecks, const std::vector<string> &fileNames, const string &languageCode)
{ {
fileChecks.resize(fileNames.size()); fileChecks.resize(fileNames.size());
@ -1144,7 +1152,7 @@ bool CStringManagerClient::checkWordFileDates(vector<CFileCheck> &fileChecks, co
for(uint i=0;i<fileChecks.size();i++) for(uint i=0;i<fileChecks.size();i++)
{ {
// get the correct path name of the ref file // get the correct path name of the ref file
std::string referenceFile= lookupReferenceFile(fileNames[i]); string referenceFile= lookupReferenceFile(fileNames[i]);
fileChecks[i].ReferenceDate= referenceFile.empty()?0:CFile::getFileModificationDate(referenceFile); fileChecks[i].ReferenceDate= referenceFile.empty()?0:CFile::getFileModificationDate(referenceFile);
// get then one of the working File (NB: 0 is a valid reponse for Final Client: no working file) // get then one of the working File (NB: 0 is a valid reponse for Final Client: no working file)
@ -1171,7 +1179,7 @@ bool CStringManagerClient::checkWordFileDates(vector<CFileCheck> &fileChecks, co
// *************************************************************************** // ***************************************************************************
void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode) void CStringManagerClient::initI18NSpecialWords(const string &languageCode)
{ {
ucstring womenNameColIdent= string("women_name"); ucstring womenNameColIdent= string("women_name");
ucstring descColIdent= string("description"); ucstring descColIdent= string("description");
@ -1215,8 +1223,8 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
uint32 profile0= (uint32)ryzomGetLocalTime(); uint32 profile0= (uint32)ryzomGetLocalTime();
ucstring ucs; ucstring ucs;
std::string fileName = fileNames[i]; string fileName = fileNames[i];
std::string keyExtenstion = specialWords[i*3+2]; string keyExtenstion = specialWords[i*3+2];
// read the ucstring and make diffs with data in ./translation/work. // read the ucstring and make diffs with data in ./translation/work.
CReadWorkSheetFile rwsf; CReadWorkSheetFile rwsf;
@ -1252,17 +1260,17 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
for(uint j=1;j<ws.size();j++) for(uint j=1;j<ws.size();j++)
{ {
// Get the key and name string. // Get the key and name string.
const ucstring &key= ws.getData(j, keyColIndex); const string &key= ws.getData(j, keyColIndex).toUtf8();
const ucstring &name= ws.getData(j, nameColIndex); const string &name= ws.getData(j, nameColIndex).toUtf8();
// Append to the I18N. // Append to the I18N.
// avoid case problems // avoid case problems
string keyStr= NLMISC::toLower(key.toString()); string keyStr = NLMISC::toLower(key);
// append the special key extension. // append the special key extension.
keyStr+= keyExtenstion; keyStr+= keyExtenstion;
// insert in map. // insert in map.
std::map<std::string, CItem>::iterator it; std::map<string, CItem>::iterator it;
it= _SpecItem_TempMap.find( keyStr ); it= _SpecItem_TempMap.find( keyStr );
if ( it!=_SpecItem_TempMap.end() ) if ( it!=_SpecItem_TempMap.end() )
{ {
@ -1278,7 +1286,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
if(womenNameColIndex!=std::numeric_limits<uint>::max()) if(womenNameColIndex!=std::numeric_limits<uint>::max())
{ {
const ucstring &womenName= ws.getData(j, womenNameColIndex); 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 // replace all \n in the women name with true \n
while(strFindReplace(_SpecItem_TempMap[keyStr].WomenName, "\\n", "\n")); while(strFindReplace(_SpecItem_TempMap[keyStr].WomenName, "\\n", "\n"));
} }
@ -1287,7 +1295,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
if(descColIndex!=std::numeric_limits<uint>::max()) if(descColIndex!=std::numeric_limits<uint>::max())
{ {
const ucstring &desc= ws.getData(j, descColIndex); 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 // replace all \n in the desc with true \n
while(strFindReplace(_SpecItem_TempMap[keyStr].Desc, "\\n", "\n")); while(strFindReplace(_SpecItem_TempMap[keyStr].Desc, "\\n", "\n"));
} }
@ -1296,7 +1304,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
if(descColIndex2!=std::numeric_limits<uint>::max()) if(descColIndex2!=std::numeric_limits<uint>::max())
{ {
const ucstring &desc= ws.getData(j, descColIndex2); 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 // replace all \n in the desc with true \n
while(strFindReplace(_SpecItem_TempMap[keyStr].Desc2, "\\n", "\n")); while(strFindReplace(_SpecItem_TempMap[keyStr].Desc2, "\\n", "\n"));
} }
@ -1360,7 +1368,7 @@ void CStringManagerClient::specialWordsMemoryCompress()
// Make big strings // Make big strings
_SpecItems.resize(nNbEntries); _SpecItems.resize(nNbEntries);
_SpecItem_Labels = new char[nLabelSize]; _SpecItem_Labels = new char[nLabelSize];
_SpecItem_NameDesc = new ucchar[nNameDescSize]; _SpecItem_NameDesc = new char[nNameDescSize];
nNbEntries = 0; nNbEntries = 0;
nLabelSize = 0; nLabelSize = 0;
@ -1368,35 +1376,30 @@ void CStringManagerClient::specialWordsMemoryCompress()
it = _SpecItem_TempMap.begin(); it = _SpecItem_TempMap.begin();
while (it != _SpecItem_TempMap.end()) while (it != _SpecItem_TempMap.end())
{ {
if (NLMISC::startsWith(it->first.c_str(), "bf"))
if (strnicmp(it->first.c_str(), "bf", 2) == 0)
{ {
uint nDbg = 0; uint nDbg = 0;
nDbg++; nDbg++;
} }
_SpecItems[nNbEntries].Label = _SpecItem_Labels+nLabelSize; _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; nLabelSize += (uint32)it->first.size() + 1;
_SpecItems[nNbEntries].Name = _SpecItem_NameDesc+nNameDescSize; _SpecItems[nNbEntries].Name = _SpecItem_NameDesc+nNameDescSize;
memcpy(_SpecItems[nNbEntries].Name, it->second.Name.c_str(), 2*(it->second.Name.size()+1)); strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Name.c_str());
_SpecItems[nNbEntries].Name[it->second.Name.size()] = 0;
nNameDescSize += (uint32)it->second.Name.size() + 1; nNameDescSize += (uint32)it->second.Name.size() + 1;
_SpecItems[nNbEntries].WomenName = _SpecItem_NameDesc+nNameDescSize; _SpecItems[nNbEntries].WomenName = _SpecItem_NameDesc+nNameDescSize;
memcpy(_SpecItems[nNbEntries].WomenName, it->second.WomenName.c_str(), 2*(it->second.WomenName.size()+1)); strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.WomenName.c_str());
_SpecItems[nNbEntries].WomenName[it->second.WomenName.size()] = 0;
nNameDescSize += (uint32)it->second.WomenName.size() + 1; nNameDescSize += (uint32)it->second.WomenName.size() + 1;
_SpecItems[nNbEntries].Desc = _SpecItem_NameDesc+nNameDescSize; _SpecItems[nNbEntries].Desc = _SpecItem_NameDesc+nNameDescSize;
memcpy(_SpecItems[nNbEntries].Desc, it->second.Desc.c_str(), 2*(it->second.Desc.size()+1)); strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Desc.c_str());
_SpecItems[nNbEntries].Desc[it->second.Desc.size()] = 0;
nNameDescSize += (uint32)it->second.Desc.size() + 1; nNameDescSize += (uint32)it->second.Desc.size() + 1;
_SpecItems[nNbEntries].Desc2 = _SpecItem_NameDesc+nNameDescSize; _SpecItems[nNbEntries].Desc2 = _SpecItem_NameDesc+nNameDescSize;
memcpy(_SpecItems[nNbEntries].Desc2, it->second.Desc2.c_str(), 2*(it->second.Desc2.size()+1)); strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Desc2.c_str());
_SpecItems[nNbEntries].Desc2[it->second.Desc2.size()] = 0;
nNameDescSize += (uint32)it->second.Desc2.size() + 1; nNameDescSize += (uint32)it->second.Desc2.size() + 1;
nNbEntries++; nNbEntries++;
@ -1408,23 +1411,23 @@ 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()) if (label.empty())
{ {
static ucstring emptyString; static string emptyString;
return emptyString.c_str(); return emptyString.c_str();
} }
if (label[0] == '#') if (label[0] == '#')
{ {
static ucstring rawString; static string rawString;
rawString = label.substr(1, label.size()-1); rawString = label.substr(1, label.size()-1);
return rawString.c_str(); return rawString.c_str();
} }
// avoid case problems // avoid case problems
static std::string lwrLabel; static string lwrLabel;
lwrLabel = toLower(label); lwrLabel = toLower(label);
if (_SpecItem_MemoryCompressed) if (_SpecItem_MemoryCompressed)
@ -1459,28 +1462,26 @@ const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bo
} }
} }
static ucstring badString; static string badString;
badString = "<NotExist:" + lwrLabel + ">";
badString = ucstring(std::string("<NotExist:")+lwrLabel+">");
return badString.c_str(); 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()) if (label.empty())
return emptyString.c_str(); return emptyString.c_str();
// avoid case problems // avoid case problems
static std::string lwrLabel; static string lwrLabel;
lwrLabel = toLower(label); lwrLabel = toLower(label);
if (_SpecItem_MemoryCompressed) if (_SpecItem_MemoryCompressed)
{ {
CItemLight tmp; CItemLight tmp;
tmp.Label = (char*)lwrLabel.c_str(); tmp.Label = lwrLabel.c_str();
vector<CItemLight>::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp()); vector<CItemLight>::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp());
if (it != _SpecItems.end()) if (it != _SpecItems.end())
@ -1500,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()) if (label.empty())
return emptyString.c_str(); return emptyString.c_str();
// avoid case problems // avoid case problems
static std::string lwrLabel; static string lwrLabel;
lwrLabel = toLower(label); lwrLabel = toLower(label);
if (_SpecItem_MemoryCompressed) if (_SpecItem_MemoryCompressed)
{ {
CItemLight tmp; CItemLight tmp;
tmp.Label = (char*)lwrLabel.c_str(); tmp.Label = lwrLabel.c_str();
vector<CItemLight>::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp()); vector<CItemLight>::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp());
if (it != _SpecItems.end()) if (it != _SpecItems.end())
@ -1542,87 +1543,87 @@ 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); return getSpecialWord(placeNameID);
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getFactionLocalizedName(const string &factionNameID) const char *CStringManagerClient::getFactionLocalizedName(const string &factionNameID)
{ {
return getSpecialWord(factionNameID); return getSpecialWord(factionNameID);
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getSkillLocalizedName(SKILLS::ESkills e) const char *CStringManagerClient::getSkillLocalizedName(SKILLS::ESkills e)
{ {
return getSpecialWord(SKILLS::toString(e)); return getSpecialWord(SKILLS::toString(e));
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getItemLocalizedName(CSheetId id) const char *CStringManagerClient::getItemLocalizedName(CSheetId id)
{ {
return getSpecialWord(id.toString()); return getSpecialWord(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getCreatureLocalizedName(NLMISC::CSheetId id) const char *CStringManagerClient::getCreatureLocalizedName(NLMISC::CSheetId id)
{ {
return getSpecialWord(id.toString()); return getSpecialWord(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getSBrickLocalizedName(NLMISC::CSheetId id) const char *CStringManagerClient::getSBrickLocalizedName(NLMISC::CSheetId id)
{ {
return getSpecialWord(id.toString()); return getSpecialWord(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getSPhraseLocalizedName(NLMISC::CSheetId id) const char *CStringManagerClient::getSPhraseLocalizedName(NLMISC::CSheetId id)
{ {
return getSpecialWord(id.toString()); 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)); 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)); return getSpecialDesc(SKILLS::toString(e));
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getItemLocalizedDescription(CSheetId id) const char *CStringManagerClient::getItemLocalizedDescription(CSheetId id)
{ {
return getSpecialDesc(id.toString()); return getSpecialDesc(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getSBrickLocalizedDescription(NLMISC::CSheetId id) const char *CStringManagerClient::getSBrickLocalizedDescription(NLMISC::CSheetId id)
{ {
return getSpecialDesc(id.toString()); return getSpecialDesc(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id) const char *CStringManagerClient::getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id)
{ {
return getSpecialDesc2(id.toString()); return getSpecialDesc2(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId id) const char *CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId id)
{ {
return getSpecialDesc(id.toString()); return getSpecialDesc(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getTitleLocalizedName(const ucstring &titleId, bool women) const char *CStringManagerClient::getTitleLocalizedName(const string &titleId, bool women)
{ {
vector<ucstring> listInfos = getTitleInfos(titleId, women); vector<string> listInfos = getTitleInfos(titleId, women);
if (!listInfos.empty()) if (!listInfos.empty())
{ {
@ -1634,18 +1635,18 @@ const ucchar *CStringManagerClient::getTitleLocalizedName(const ucstring &titleI
} }
// *************************************************************************** // ***************************************************************************
vector<ucstring> CStringManagerClient::getTitleInfos(const ucstring &titleId, bool women) vector<string> CStringManagerClient::getTitleInfos(const string &titleId, bool women)
{ {
//ucstring infosUC; //ucstring infosUC;
//infosUC.fromUtf8(titleId); //infosUC.fromUtf8(titleId);
vector<ucstring> listInfos; vector<string> listInfos;
splitUCString(titleId, ucstring("#"), listInfos); splitString(titleId, string("#"), listInfos);
if (!listInfos.empty()) if (!listInfos.empty())
{ {
if (titleId[0] != '#') if (titleId[0] != '#')
{ {
listInfos[0] = getSpecialWord(listInfos[0].toUtf8(), women); listInfos[0] = getSpecialWord(listInfos[0], women);
} }
} }
@ -1653,74 +1654,76 @@ vector<ucstring> 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)); return getSpecialDesc(EGSPD::CClassificationType::toString(type));
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getOutpostLocalizedName(NLMISC::CSheetId id) const char *CStringManagerClient::getOutpostLocalizedName(NLMISC::CSheetId id)
{ {
return getSpecialWord(id.toString()); return getSpecialWord(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getOutpostLocalizedDescription(NLMISC::CSheetId id) const char *CStringManagerClient::getOutpostLocalizedDescription(NLMISC::CSheetId id)
{ {
return getSpecialDesc(id.toString()); return getSpecialDesc(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getOutpostBuildingLocalizedName(NLMISC::CSheetId id) const char *CStringManagerClient::getOutpostBuildingLocalizedName(NLMISC::CSheetId id)
{ {
return getSpecialWord(id.toString()); return getSpecialWord(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id) const char *CStringManagerClient::getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id)
{ {
return getSpecialDesc(id.toString()); return getSpecialDesc(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getSquadLocalizedName(NLMISC::CSheetId id) const char *CStringManagerClient::getSquadLocalizedName(NLMISC::CSheetId id)
{ {
return getSpecialWord(id.toString()); return getSpecialWord(id.toString());
} }
// *************************************************************************** // ***************************************************************************
const ucchar *CStringManagerClient::getSquadLocalizedDescription(NLMISC::CSheetId id) const char *CStringManagerClient::getSquadLocalizedDescription(NLMISC::CSheetId id)
{ {
return getSpecialDesc(id.toString()); 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; _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()) if (label.empty())
{ {
return; return;
} }
// avoid case problems // avoid case problems
static std::string lwrLabel; static string lwrLabel;
lwrLabel = toLower(label); lwrLabel = toLower(label);
nlassert(!_SpecItem_MemoryCompressed); // Not allowed, strings are released!
if (_SpecItem_MemoryCompressed) if (_SpecItem_MemoryCompressed)
{ {
ucchar *strName = (ucchar *)name.c_str(); #if 0
ucchar *strDesc = (ucchar *)desc.c_str(); const char *strName = name.c_str();
ucchar *strDesc2 = (ucchar *)desc2.c_str(); const char *strDesc = desc.c_str();
const char *strDesc2 = desc2.c_str();
CItemLight tmp; CItemLight tmp;
tmp.Label = (char*)lwrLabel.c_str(); tmp.Label = lwrLabel.c_str();
vector<CItemLight>::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp()); vector<CItemLight>::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp());
if (it != _SpecItems.end()) if (it != _SpecItems.end())
@ -1746,6 +1749,7 @@ void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const ucstring
tmp.Desc2 = strDesc2; tmp.Desc2 = strDesc2;
_SpecItems.push_back(tmp); _SpecItems.push_back(tmp);
} }
#endif
} }
else else
{ {

@ -63,15 +63,16 @@ public:
// Force the cache to be saved // Force the cache to be saved
void flushStringCache(); void flushStringCache();
bool getString(uint32 stringId, std::string &result) { ucstring temp; bool res = getString(stringId, temp); result = temp.toUtf8(); return res; } // FIXME: UTF-8 bool getString(uint32 stringId, std::string &result);
bool getString(uint32 stringId, ucstring &result); bool getString(uint32 stringId, ucstring &result) { std::string temp; bool res = getString(stringId, temp); result.fromUtf8(temp); return res; } // FIXME: UTF-8
void waitString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result); void waitString(uint32 stringId, const IStringWaiterRemover *premover, std::string *result);
void waitString(uint32 stringId, IStringWaitCallback *pcallback); void waitString(uint32 stringId, IStringWaitCallback *pcallback);
bool getDynString(uint32 dynStringId, ucstring &result); bool getDynString(uint32 dynStringId, std::string &result);
void waitDynString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result); bool getDynString(uint32 dynStringId, ucstring &result) { std::string temp; bool res = getString(dynStringId, temp); result.fromUtf8(temp); return res; } // FIXME: UTF-8
void waitDynString(uint32 stringId, const IStringWaiterRemover *premover, std::string *result);
void waitDynString(uint32 stringId, IStringWaitCallback *pcallback); 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 receiveDynString(NLMISC::CBitMemStream &bms);
void releaseDynString(uint32 stringId); void releaseDynString(uint32 stringId);
@ -80,54 +81,54 @@ public:
static void initI18NSpecialWords(const std::string &languageCode); static void initI18NSpecialWords(const std::string &languageCode);
static void specialWordsMemoryCompress(); static void specialWordsMemoryCompress();
// Yoyo: Replace the Brick Name with Filled stats (CSBrickManager work). No-Op if not found // 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 replaceSBrickName(NLMISC::CSheetId id, const std::string &name, const std::string &desc, const std::string &desc2);
static void replaceDynString(const ucstring &name, const ucstring &text); static void replaceDynString(const std::string &name, const std::string &text);
// Get the Localized Name of the Places. // 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) // 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. // 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. // 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. // 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. // 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. // 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. // 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. // 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. // 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. // 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. // 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 // Get the Localized Title name
static const ucchar *getTitleLocalizedName(const ucstring &titleId, bool women); static const char *getTitleLocalizedName(const std::string &titleId, bool women);
static std::vector<ucstring> getTitleInfos(const ucstring &titleId, bool women); static std::vector<std::string> getTitleInfos(const std::string &titleId, bool women);
// Get the Localized name of a classification type // 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 // Outpost name
static const ucchar *getOutpostLocalizedName(NLMISC::CSheetId id); static const char *getOutpostLocalizedName(NLMISC::CSheetId id);
// Outpost description // Outpost description
static const ucchar *getOutpostLocalizedDescription(NLMISC::CSheetId id); static const char *getOutpostLocalizedDescription(NLMISC::CSheetId id);
// Outpost building name // Outpost building name
static const ucchar *getOutpostBuildingLocalizedName(NLMISC::CSheetId id); static const char *getOutpostBuildingLocalizedName(NLMISC::CSheetId id);
// Outpost building description // Outpost building description
static const ucchar *getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id); static const char *getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id);
// Squad name // Squad name
static const ucchar *getSquadLocalizedName(NLMISC::CSheetId id); static const char *getSquadLocalizedName(NLMISC::CSheetId id);
// Squad description // Squad description
static const ucchar *getSquadLocalizedDescription(NLMISC::CSheetId id); static const char *getSquadLocalizedDescription(NLMISC::CSheetId id);
private: private:
// constructor. // constructor.
@ -152,8 +153,8 @@ private:
struct TParamValue struct TParamValue
{ {
TParamType Type; TParamType Type;
ucstring::size_type ReplacementPoint; std::string::size_type ReplacementPoint;
union union
{ {
uint32 StringId; uint32 StringId;
@ -176,7 +177,7 @@ private:
NLMISC::CBitMemStream Message; NLMISC::CBitMemStream Message;
uint32 StringId; uint32 StringId;
std::vector<TParamValue> Params; std::vector<TParamValue> Params;
ucstring String; std::string String;
}; };
enum enum
@ -188,7 +189,7 @@ private:
struct TStringWaiter struct TStringWaiter
{ {
/// Pointer to the ucstring to fill /// Pointer to the ucstring to fill
ucstring *Result; std::string *Result;
/// Pointer to the remover that contains this string reference /// Pointer to the remover that contains this string reference
const IStringWaiterRemover *Remover; const IStringWaiterRemover *Remover;
}; };
@ -197,7 +198,7 @@ private:
/// Container for simple strings /// Container for simple strings
typedef CHashMap<uint, ucstring> TStringsContainer; typedef CHashMap<uint, std::string> TStringsContainer;
/// Container for dyn strings /// Container for dyn strings
typedef CHashMap<uint, TDynStringInfo> TDynStringsContainer; typedef CHashMap<uint, TDynStringInfo> TDynStringsContainer;
/// Container of string reference waiting for value. /// Container of string reference waiting for value.
@ -223,7 +224,7 @@ private:
TStringCallbacksContainer _DynStringsCallbacks; TStringCallbacksContainer _DynStringsCallbacks;
// Return value for waiting string.. // Return value for waiting string..
static ucstring _WaitString; static std::string _WaitString;
// Singleton pattern implementation // Singleton pattern implementation
static CStringManagerClient *_Instance; static CStringManagerClient *_Instance;
@ -244,7 +245,7 @@ private:
struct CCacheString struct CCacheString
{ {
uint32 StringId; uint32 StringId;
ucstring String; std::string String;
}; };
std::vector<CCacheString> _CacheStringToSave; std::vector<CCacheString> _CacheStringToSave;
//@} //@}
@ -254,41 +255,60 @@ private:
{ {
public: public:
// The Name of the item // The Name of the item
ucstring Name; std::string Name;
// The Women Name of the item // The Women Name of the item
ucstring WomenName; std::string WomenName;
// Description of the item // Description of the item
ucstring Desc; std::string Desc;
// Optional Second description (For SBrick composition for example) // Optional Second description (For SBrick composition for example)
ucstring Desc2; std::string Desc2;
void serial(NLMISC::IStream &f) void serial(NLMISC::IStream &f)
{ {
sint ver= f.serialVersion(1); sint ver = f.serialVersion(2);
f.serial(Name); if (ver >= 2)
if (ver >= 1) {
f.serial(Name);
f.serial(WomenName); f.serial(WomenName);
f.serial(Desc); f.serial(Desc);
f.serial(Desc2); 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 bool _SpecItem_MemoryCompressed;
static std::map<std::string, CItem> _SpecItem_TempMap; static std::map<std::string, CItem> _SpecItem_TempMap;
static std::vector<ucstring> _TitleWords; static std::vector<std::string> _TitleWords;
static std::map<ucstring, ucstring> _DynStrings; static std::map<std::string, std::string> _DynStrings;
static char *_SpecItem_Labels; static char *_SpecItem_Labels;
static ucchar *_SpecItem_NameDesc; static char *_SpecItem_NameDesc;
struct CItemLight struct CItemLight
{ {
char *Label; const char *Label;
ucchar *Name; const char *Name;
ucchar *WomenName; const char *WomenName;
ucchar *Desc; const char *Desc;
ucchar *Desc2; const char *Desc2;
}; };
struct CItemLightComp struct CItemLightComp
{ {
@ -300,9 +320,9 @@ private:
static std::vector<CItemLight> _SpecItems; static std::vector<CItemLight> _SpecItems;
static const ucchar *getSpecialWord(const std::string &label, bool women = false); static const char *getSpecialWord(const std::string &label, bool women = false);
static const ucchar *getSpecialDesc(const std::string &label); static const char *getSpecialDesc(const std::string &label);
static const ucchar *getSpecialDesc2(const std::string &label); static const char *getSpecialDesc2(const std::string &label);
// Check Files for the Packed string. // Check Files for the Packed string.
class CFileCheck class CFileCheck
@ -378,9 +398,9 @@ class IStringWaitCallback
{ {
public: public:
/// Overide this method to receive callback for string. /// 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. /// 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() virtual ~IStringWaitCallback()
{ {

Loading…
Cancel
Save