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 setDouble(double value) { clean(); _Type = Double; _DoubleValue = 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 setUserType(CInterfaceExprUserType *value);
// reset this object to initial state (no type)

@ -60,10 +60,13 @@ namespace NLGUI
// TEMP PATCH
void setCursor (const std::string &name)
{
if (_TxDefault != name)
{
_TxDefault = name;
_TxIdDefault = -2;
}
}
// TEMP PATCH
/// Show or hide the pointer. Please, use SetMouseMode (bool freelook) instead.

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

@ -240,6 +240,20 @@ std::string toUpper ( const char *str ); // UTF-8
std::string toUpper ( const std::string &str); // UTF-8
void toUpper ( char *str); // Ascii only
/** Convert a single character in UTF-8 to upper or lowercase.
* \param res Character is appended in UTF-8 into this string.
* \param src Character is sourced from this UTF-8 string.
* \param i Index in `str`, incremented by the number of bytes read.
*/
void appendToLower(std::string &res, const char *str, ptrdiff_t &i);
void appendToLower(std::string &res, const std::string &str, ptrdiff_t &i);
void appendToUpper(std::string &res, const char *str, ptrdiff_t &i);
void appendToUpper(std::string &res, const std::string &str, ptrdiff_t &i);
/** UTF-8 case insensitive compare */
int compareCaseInsensitive(const char *a, const char *b);
int compareCaseInsensitive(const char *a, size_t lenA, const char *b, size_t lenB);
/**
* 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)); }
#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.
// (str[0] == '1' || (str[0] & 0xD2) == 0x50)
// - Kaetemi
/// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, and empty strings, anything else is undefined.
/// - Kaetemi
inline bool toBool(const char *str) { return str[0] == '1' || (str[0] & 0xD2) == 0x50; }
inline bool toBool(const std::string &str) { return toBool(str.c_str()); } // Safe because first byte may be null
bool fromString(const std::string &str, bool &val);

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

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

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

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

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

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

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

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

@ -4732,8 +4732,8 @@ static const char **s_UtfLowerToUpperMap[16] = {
NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrdiff_t &i)
{
char c = str[i];
char d, e;
unsigned char c = str[i];
unsigned char d, e;
if (c < 0x80)
{
if (c >= 'A' && c <= 'Z')
@ -4752,7 +4752,7 @@ NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrd
if (table[idx])
{
res += &table[idx];
++i;
i += 2;
return;
}
}
@ -4770,20 +4770,23 @@ NL_FORCE_INLINE void appendToLowerAsUtf8(std::string &res, const char *str, ptrd
if (table[idx])
{
res += &table[idx];
i += 2;
i += 3;
return;
}
}
}
}
res += c;
++i;
}
// ***************************************************************************
std::string toLower(const char *str)
{
// UTF-8 toLower, tables generated from UTF-16 tables
std::string res;
for (ptrdiff_t i = 0; str[i]; ++i)
for (ptrdiff_t i = 0; str[i];)
appendToLowerAsUtf8(res, str, i);
return res;
}
@ -4796,19 +4799,33 @@ std::string toLower(const std::string &str)
std::string res;
res.reserve(str.size() + (str.size() >> 2));
const char *cstr = &str[0];
for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size(); ++i)
for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();)
appendToLowerAsUtf8(res, cstr, i);
return res;
}
// ***************************************************************************
void appendToLower(std::string &res, const char *str, ptrdiff_t &i)
{
appendToLowerAsUtf8(res, str, i);
}
// ***************************************************************************
void appendToLower(std::string &res, const std::string &str, ptrdiff_t &i)
{
appendToLowerAsUtf8(res, &str[0], i);
}
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
NL_FORCE_INLINE void appendToUpperAsUtf8(std::string &res, const char *str, ptrdiff_t &i)
{
char c = str[i];
char d, e;
unsigned char c = str[i];
unsigned char d, e;
if (c < 0x80)
{
if (c >= 'a' && c <= 'z')
@ -4827,7 +4844,7 @@ NL_FORCE_INLINE void appendToUpperAsUtf8(std::string &res, const char *str, ptrd
if (table[idx])
{
res += &table[idx];
++i;
i += 2;
return;
}
}
@ -4845,13 +4862,14 @@ NL_FORCE_INLINE void appendToUpperAsUtf8(std::string &res, const char *str, ptrd
if (table[idx])
{
res += &table[idx];
i += 2;
i += 3;
return;
}
}
}
}
res += c;
++i;
}
// ***************************************************************************
@ -4860,7 +4878,7 @@ std::string toUpper(const char *str)
{
// UTF-8 toLower, tables generated from UTF-16 tables
std::string res;
for (ptrdiff_t i = 0; str[i]; ++i)
for (ptrdiff_t i = 0; str[i];)
appendToUpperAsUtf8(res, str, i);
return res;
}
@ -4873,13 +4891,251 @@ std::string toUpper(const std::string &str)
std::string res;
res.reserve(str.size() + (str.size() >> 2));
const char *cstr = &str[0];
for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size(); ++i)
for (ptrdiff_t i = 0; i < (ptrdiff_t)str.size();)
appendToUpperAsUtf8(res, cstr, i);
return res;
}
// ***************************************************************************
void appendToUpper(std::string &res, const char *str, ptrdiff_t &i)
{
appendToUpperAsUtf8(res, str, i);
}
// ***************************************************************************
void appendToUpper(std::string &res, const std::string &str, ptrdiff_t &i)
{
appendToUpperAsUtf8(res, &str[0], i);
}
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
static const char s_UpperAscii[] = {
'A', 0, 'B', 0, 'C', 0, 'D', 0, 'E', 0, 'F', 0, 'G', 0,
'H', 0, 'I', 0, 'J', 0, 'K', 0, 'L', 0, 'M', 0, 'N', 0,
'O', 0, 'P', 0, 'Q', 0, 'R', 0, 'S', 0, 'T', 0, 'U', 0,
'V', 0, 'W', 0, 'X', 0, 'Y', 0, 'Z', 0, 0, 0, 0, 0
};
const char *fetchToUpperAsUtf8(const char **str)
{
unsigned char c = *(*str);
unsigned char d, e;
if (c < 0x80)
{
if (c >= 'a' && c <= 'z')
{
// 1-byte UTF-8
++(*str);
return &s_UpperAscii[(c - 'a') << 1];
}
}
else if ((c & 0xE0) == 0xC0 && ((d = (*str)[1]) & 0xC0) == 0x80)
{
// 2-byte UTF-8
const char *table = s_Utf8LowerToUpperTables[c & 0x1F];
if (table)
{
unsigned char idx = (d & 0x3F) << 2;
if (table[idx])
{
(*str) += 2;
return &table[idx];
}
}
}
else if ((c & 0xF0) == 0xE0 && ((d = (*str)[1]) & 0xC0) == 0x80 && ((e = (*str)[2]) & 0xC0) == 0x80)
{
// 3-byte UTF-8
const char **map = s_UtfLowerToUpperMap[c & 0x0F];
if (map)
{
const char *table = map[d & 0x3F];
if (table)
{
unsigned char idx = (d & 0x3F) << 2;
if (table[idx])
{
(*str) += 3;
return &table[idx];
}
}
}
}
return NULL;
}
int compareCaseInsensitive(const char *a, const char *b)
{
// while (*a != 0 && *b != 0)
for (; ;)
{
const char *ca = fetchToUpperAsUtf8(&a);
const char *cb = fetchToUpperAsUtf8(&b);
if (!ca && !cb)
{
// Easy case, ASCII compare or junk
if (*a != *b)
{
if (*a > * b) return 1;
else return -1;
}
else if (!*a) // Equal and NUL, ends both
{
return 0;
}
++a;
++b;
}
else if (!cb)
{
// String a changed lowercase, iterate ca until NUL alongside b
nlassert(*ca);
do
{
if (*ca != *b)
{
if (*ca > *b) return 1;
else return -1;
}
++ca;
++b;
} while (*ca);
}
else if (!ca)
{
// String b changed lowercase, iterate a alongside cb until NUL
nlassert(*cb);
do
{
if (*a != *cb)
{
if (*a > *cb) return 1;
else return -1;
}
++a;
++cb;
} while (*cb);
}
else
{
// Both strings changed lowercase
if (ca != cb) // Only check if it's a different result
{
do
{
if (*ca != *cb)
{
if (*ca > *cb) return 1;
else return -1;
}
++ca;
++cb;
} while (*ca && *cb);
}
}
}
// if (*a == *b) return 0;
// if (*a > *b) return 1;
// return -1;
}
int compareCaseInsensitive(const char *a, size_t lenA, const char *b, size_t lenB)
{
const char *ma = a + lenA;
const char *mb = b + lenB;
for (; ;)
{
if (a >= ma)
{
if (b >= mb)
{
return 0; // Both strings ended
}
else
{
return 1; // A is longer
}
}
if (b >= mb)
{
return -1; // B is longer
}
const char *ca = fetchToUpperAsUtf8(&a);
const char *cb = fetchToUpperAsUtf8(&b);
if (!ca && !cb)
{
// Easy case, ASCII compare or junk
if (*a != *b)
{
if (*a > * b) return 1;
else return -1;
}
/*
else if (!*a) // Equal and NUL, ends both
{
return 0;
}
*/
++a;
++b;
}
else if (!cb)
{
// String a changed lowercase, iterate ca until NUL alongside b
nlassert(*ca);
do
{
if (*ca != *b)
{
if (*ca > *b) return 1;
else return -1;
}
++ca;
++b;
} while (*ca);
}
else if (!ca)
{
// String b changed lowercase, iterate a alongside cb until NUL
nlassert(*cb);
do
{
if (*a != *cb)
{
if (*a > *cb) return 1;
else return -1;
}
++a;
++cb;
} while (*cb);
}
else
{
// Both strings changed lowercase
if (ca != cb) // Only check if it's a different result
{
do
{
if (*ca != *cb)
{
if (*ca > *cb) return 1;
else return -1;
}
++ca;
++cb;
} while (*ca && *cb);
}
}
}
}
// ***************************************************************************
#else
// ***************************************************************************

@ -21,7 +21,7 @@ IF(WITH_RYZOM_CLIENT)
ENDIF()
FILE(GLOB CFG ../*.cfg)
FILE(GLOB SRC *.cpp *.h motion/*.cpp motion/*.h client.rc)
FILE(GLOB SRC *.cpp *.h motion/*.cpp motion/*.h client.rc *.manifest)
FILE(GLOB SRC_INTERFACE interface_v3/*.h interface_v3/*.cpp)
FILE(GLOB SRC_MODE motion/modes/*.cpp motion/modes/*.h)
FILE(GLOB SRC_R2 r2/*.h r2/*.cpp r2/dmc/*.h r2/dmc/*.cpp)

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

@ -955,7 +955,7 @@ void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstrin
result = msg;
else
{
ucstring name = CEntityCL::removeTitleAndShardFromName(sender);
ucstring name = CEntityCL::removeTitleAndShardFromName(sender.toUtf8());
ucstring csr;
// 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));
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
ucstring::size_type pos = name.find('$');
if (pos != ucstring::npos)
{
name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name), bWoman);
name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name.toUtf8()), bWoman);
}
}
}
else
{
// Does the char have a CSR title?
csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring("");
csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender.toUtf8())) ? ucstring("(CSR) ") : ucstring("");
}
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
ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender);
ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender.toUtf8());
ucstring csr;
// Does the char have a CSR title?
csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring("");
csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender.toUtf8())) ? ucstring("(CSR) ") : ucstring("");
if (UserEntity && senderName == UserEntity->getDisplayName())
if (UserEntity && senderName.toUtf8() == UserEntity->getDisplayName())
{
// The player talks
switch(type)
@ -1046,13 +1046,13 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde
// We need the gender to display the correct title
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
ucstring::size_type pos = senderName.find('$');
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;
CSheetId id(args[0]);
ucstring name;
name.fromUtf8(args[1]);
ucstring desc;
ucstring desc2;
string name;
name = args[1];
string desc;
string desc2;
if (args.size() > 2)
desc.fromUtf8(args[2]);
desc = args[2];
if (args.size() > 3)
desc2.fromUtf8(args[3]);
desc2 = args[3];
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
if (pSMC)
@ -1406,10 +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>")
{
if (args.size() < 2) return false;
ucstring name;
name.fromUtf8(args[0]);
ucstring text;
text.fromUtf8(args[1]);
string name;
name = args[0];
string text;
text = args[1];
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
if (pSMC)
@ -1459,7 +1459,7 @@ NLMISC_COMMAND(ah, "Launch an action handler", "<ActionHandler> <AHparam>")
static void setDynString(uint32 strID, const std::string &value)
{
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
pSMC->receiveString(strID, ucstring(value));
pSMC->receiveString(strID, value);
CBitMemStream bm;
if (bm.isReading()) bm.invert();
bm.serial(strID);

@ -145,8 +145,8 @@ string CharNameValidDBLink;
uint8 PlayerSelectedSlot = 0;
string PlayerSelectedFileName;
TSessionId PlayerSelectedMainland= (TSessionId)0; // This is the mainland selected at the SELECT perso!!
ucstring PlayerSelectedHomeShardName;
ucstring PlayerSelectedHomeShardNameWithParenthesis;
std::string PlayerSelectedHomeShardName;
std::string PlayerSelectedHomeShardNameWithParenthesis;
extern std::string CurrentCookie;
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
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:outgame:connecting:title"));
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
nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts
@ -1235,8 +1235,8 @@ TInterfaceState globalMenu()
if (pVT != NULL)
{
pVT->setMultiLine( true );
pVT->setText(CI18N::get("uiFirewallFail")+".\n"+
CI18N::get("uiFirewallAlert")+".");
pVT->setTextLocalized(CI18N::get("uiFirewallFail")+".\n"+
CI18N::get("uiFirewallAlert")+".", false);
}
}
}
@ -1317,16 +1317,16 @@ public:
if (pVT == NULL) return;
if (rCS.Name.empty())
pVT->setText(CI18N::get("uiEmptySlot"));
pVT->setTextLocalized("uiEmptySlot", true);
else
pVT->setText(rCS.Name.toUtf8());
pVT->setTextLocalized(rCS.Name.toUtf8(), false);
}
// 5 slots
for (; i < 5; ++i)
{
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i)));
if (pVT == NULL) return;
pVT->setText(CI18N::get("uiEmptySlot"));
pVT->setTextLocalized("uiEmptySlot", true);
}
}
};
@ -1439,7 +1439,7 @@ Deprecated {
ucstring::size_type pos = sValue.find('$');
if (pos != ucstring::npos)
{
sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue), womanTitle);
sValue = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sValue.toUtf8()), womanTitle);
}
}
setTarget (pCaller, sTarget, sValue);
@ -2169,7 +2169,7 @@ public:
if (pVT != NULL)
{
std::string str = Mainlands[i].Name.toUtf8() + " " + Mainlands[i].Description.toUtf8();
pVT->setText(str);
pVT->setTextLocalized(str, false);
}
// Add to the list
@ -2309,7 +2309,7 @@ public:
CViewText *pVT = dynamic_cast<CViewText*>(pNewLine->getView("name"));
if (pVT != NULL)
{
pVT->setText(name.toUtf8());
pVT->setTextLocalized(name.toUtf8(), false);
}
CCtrlBase *pBut = pNewLine->getCtrl("but");
@ -2557,7 +2557,7 @@ static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName
{
CViewText* viewText = dynamic_cast<CViewText*>(result);
if(viewText)
viewText->setText(text.toUtf8());
viewText->setTextLocalized(text.toUtf8(), false);
CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result);
if(editBox)
editBox->setInputStringAsUtf16(text);
@ -2680,7 +2680,7 @@ class CAHScenarioControl : public IActionHandler
CViewText* viewText = dynamic_cast<CViewText*>(result);
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);
if(viewText)
viewText->setText("");
viewText->setText(std::string());
}
}
setScenarioInformation(scenarioWnd, "");
@ -2746,7 +2746,7 @@ class CAHScenarioControl : public IActionHandler
CViewText *shardName = dynamic_cast<CViewText *>(toggleGr->getView("button_text"));
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);
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"));
if (pVT != NULL)
pVT->setText(CI18N::get("uiRingWarningFreeTrial"));
pVT->setTextLocalized("uiRingWarningFreeTrial", true);
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
return;
@ -3329,7 +3329,7 @@ class CAHLoadScenario : public IActionHandler
{
CViewText* pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL)
pVT->setText(CI18N::get("uiRingWarningFreeTrial"));
pVT->setTextLocalized("uiRingWarningFreeTrial", true);
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
}
@ -3346,7 +3346,7 @@ class CAHLoadScenario : public IActionHandler
ucstring res;
if (pSMC->getString(val,res))
{
string charName = CEntityCL::removeTitleAndShardFromName(res).toString();
string charName = CEntityCL::removeTitleAndShardFromName(res.toUtf8());
sessionBrowser.inviteCharacterByName(sessionBrowser._LastScheduleSessionCharId, charName);
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"));
if (pVT != NULL)
pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial"));
pVT->setTextLocalized("uiRingWarningInviteFreeTrial", true);
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 std::string PlayerSelectedFileName;
extern TSessionId PlayerSelectedMainland; // This is the mainland selected at the SELECT perso!!
extern ucstring PlayerSelectedHomeShardName; // The home shard name (aniro, leanon etc....)
extern ucstring PlayerSelectedHomeShardNameWithParenthesis; // Same with parenthesis
extern std::string PlayerSelectedHomeShardName; // The home shard name (aniro, leanon etc....)
extern std::string PlayerSelectedHomeShardNameWithParenthesis; // Same with parenthesis
extern std::vector<CCharacterSummary> CharacterSummaries;
extern std::string UserPrivileges;
extern sint LoginCharsel;

@ -514,7 +514,7 @@ string getDebugInformation()
if(UserEntity)
{
str += toString("Player Name: '%s'\n", UserEntity->getEntityName().toString().c_str());
str += toString("Player Name: '%s'\n", UserEntity->getEntityName().c_str());
str += toString("UserPosition: %.2f %.2f %.2f\n", UserEntity->pos().x, UserEntity->pos().y, UserEntity->pos().z);
}
else

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

@ -334,19 +334,19 @@ public:
*/
//@{
/// Return the Name of the entity. There may be a specification in it (guard, trader, etc ...). It is then surrounded by '$'
const ucstring &getEntityName() const {return _EntityName;}
const std::string &getEntityName() const {return _EntityName;}
/// Return the title from a name. The specification is surrounded by '$', and tells the title of the entity (guard, matis merchant, etc ..)
static ucstring getTitleFromName(const ucstring &name);
static std::string getTitleFromName(const std::string &name);
/// Remove the specification from a name. The specification is surrounded by '$', and tells the title of the entity (guard, matis merchant, etc ..)
static ucstring removeTitleFromName(const ucstring &name);
static std::string removeTitleFromName(const std::string &name);
/// Remove the shard from a name (if player from the same shard). The shard is surrounded by (), and tells the incoming shard of the entity (aniro, leanon etc...)
static ucstring removeShardFromName(const ucstring &name);
static std::string removeShardFromName(const std::string &name);
/// Remove both title and shard from name
static ucstring removeTitleAndShardFromName(const ucstring &name);
static std::string removeTitleAndShardFromName(const std::string &name);
/// Change the entity name.
void setEntityName(const ucstring &name);
void setEntityName(const std::string &name);
/// Return a displayable name
ucstring getDisplayName() const
std::string getDisplayName() const
{
return removeTitleAndShardFromName(_EntityName);
}
@ -931,11 +931,11 @@ protected:
// Flags to know what is possible to do with the entity (selectable, liftable, etc.).
CProperties _Properties;
// Current Name for the entity
ucstring _EntityName;
std::string _EntityName;
// Current entity title
ucstring _Title;
// Current entity tags
std::vector<ucstring> _Tags;
std::vector<std::string> _Tags;
// Current entity title string id
ucstring _TitleRaw;
// Current permanent content symbol for the entity
@ -1222,7 +1222,7 @@ public:
private:
// Override for string reception callback
virtual void onStringAvailable(uint stringId, const ucstring &value);
virtual void onStringAvailable(uint stringId, const std::string &value);
};

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

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

@ -168,7 +168,7 @@ extern NLMISC::CCmdArgs Args;
// Tips of the day count
#define RZ_NUM_TIPS 17
ucstring TipsOfTheDay;
std::string TipsOfTheDay;
uint TipsOfTheDayIndex;
// includes for following register classes
@ -272,7 +272,7 @@ static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARA
{
if (CI18N::hasTranslation("TheSagaOfRyzom"))
{
if (!SetWindowTextW(hwndDlg, (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str ()))
if (!SetWindowTextW(hwndDlg, nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str())))
{
nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str());
}
@ -280,11 +280,11 @@ static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARA
SetDlgItemTextW(hwndDlg, IDC_ERROR_MSG_TEXT, (WCHAR*)CurrentErrorMessage.c_str());
if (CI18N::hasTranslation("uiRyzomErrorMsgBoxExit"))
{
SetDlgItemTextW(hwndDlg, IDOK, (WCHAR*)CI18N::get ("uiRyzomErrorMsgBoxExit").c_str ());
SetDlgItemTextW(hwndDlg, IDOK, nlUtf8ToWide(CI18N::get("uiRyzomErrorMsgBoxExit").c_str()));
}
if (CI18N::hasTranslation("uiRyzomErrorMsgBoxHelp"))
{
SetDlgItemTextW(hwndDlg, IDC_RYZOM_ERROR_HELP, (WCHAR*)CI18N::get ("uiRyzomErrorMsgBoxHelp").c_str ());
SetDlgItemTextW(hwndDlg, IDC_RYZOM_ERROR_HELP, nlUtf8ToWide(CI18N::get("uiRyzomErrorMsgBoxHelp").c_str()));
}
RECT rect;
RECT rectDesktop;
@ -343,7 +343,7 @@ void ExitClientError (const char *format, ...)
/*
ucstring ucstr;
ucstr.fromUtf8 (str);
MessageBoxW (NULL, (WCHAR*)ucstr.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_OK|MB_ICONERROR);
MessageBoxW (NULL, (WCHAR *)ucstr.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONERROR);
*/
#else
fprintf (stderr, "%s\n", str);
@ -360,7 +360,7 @@ void ExitClientError (const char *format, ...)
void ClientInfo (const ucstring &message)
{
#ifdef NL_OS_WINDOWS
MessageBoxW (NULL, (WCHAR*)message.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_OK|MB_ICONINFORMATION);
MessageBoxW(NULL, (WCHAR *)message.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_OK|MB_ICONINFORMATION);
#endif
}
@ -368,7 +368,7 @@ void ClientInfo (const ucstring &message)
bool ClientQuestion (const ucstring &message)
{
#ifdef NL_OS_WINDOWS
return MessageBoxW (NULL, (WCHAR*)message.c_str(), (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str (), MB_YESNO|MB_ICONQUESTION) != IDNO;
return MessageBoxW(NULL, (WCHAR *)message.c_str(), nlUtf8ToWide(CI18N::get("TheSagaOfRyzom").c_str()), MB_YESNO|MB_ICONQUESTION) != IDNO;
#else
return false;
#endif

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

@ -1957,13 +1957,13 @@ public:
if (pChar != NULL)
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
ucstring::size_type pos = copyInout.find('$');
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);

@ -670,7 +670,7 @@ class CHandlerOpenTitleHelp : public IActionHandler
if (selection == NULL) return;
//if(selection->isNPC())
{
ucstring name = selection->getEntityName();
std::string name = selection->getEntityName();
if(name.empty())
{
// try to get the name from the string manager (for npc)
@ -679,7 +679,7 @@ class CHandlerOpenTitleHelp : public IActionHandler
{
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
pSMC->getString (nDBid, name);
ucstring copyName = name;
std::string copyName = name;
name = CEntityCL::removeTitleAndShardFromName(name);
if (name.empty())
{
@ -689,7 +689,7 @@ class CHandlerOpenTitleHelp : public IActionHandler
woman = pChar->getGender() == GSGENDER::female;
// extract the replacement id
ucstring strNewTitle = CEntityCL::getTitleFromName(copyName);
std::string strNewTitle = CEntityCL::getTitleFromName(copyName);
// retrieve the translated string
if (!strNewTitle.empty())
@ -700,7 +700,7 @@ class CHandlerOpenTitleHelp : public IActionHandler
}
}
if(!name.empty())
CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name.toUtf8()+"|ptype="+toString((int)selection->Type));
CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name+"|ptype="+toString((int)selection->Type));
return;
}
}
@ -752,7 +752,7 @@ class CHandlerOpenTitleHelp : public IActionHandler
for (titleIDnb = 0; titleIDnb < CHARACTER_TITLE::NB_CHARACTER_TITLE; ++titleIDnb)
{
bool women = UserEntity && UserEntity->getGender()==GSGENDER::female;
if (CStringManagerClient::getTitleLocalizedName(CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)titleIDnb),women) == title)
if (CStringManagerClient::getTitleLocalizedName(CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)titleIDnb),women) == title.toUtf8())
break;
}
@ -2762,7 +2762,7 @@ class CPlayerShardNameRemover : public IOnReceiveTextId
{
virtual void onReceiveTextId(ucstring &str)
{
str= CEntityCL::removeShardFromName(str);
str= CEntityCL::removeShardFromName(str.toUtf8());
}
};
static CPlayerShardNameRemover PlayerShardNameRemover;
@ -3629,7 +3629,7 @@ public:
CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:NAME", index));
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
{
if (itemInfo.CustomText.empty())
display->setTextFormatTaged(CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)).toUtf8());
display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id));
else
{
ucstring text = itemInfo.CustomText;
@ -299,7 +299,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
{
// If we already have item info
if (itemInfo.CustomText.empty())
display->setTextFormatTaged(CUtfStringView(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id)).toUtf8());
display->setTextFormatTaged(STRING_MANAGER::CStringManagerClient::getItemLocalizedDescription(pIS->Id));
else
{
ucstring text = itemInfo.CustomText;
@ -1721,7 +1721,7 @@ void CItemMenuInBagInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet)
ucstring 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;
}
@ -1827,7 +1827,7 @@ class CHandlerItemMenuCheck : public IActionHandler
ucstring 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;
}
}

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

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

@ -3379,7 +3379,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
{
// just show the name of the skill
// 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)
{
@ -3479,7 +3479,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
CSBrickManager *pBM= CSBrickManager::getInstance();
CSBrickSheet *brick= pBM->getBrick(CSheetId(getSheetId()));
if(brick)
help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id)).toUtf8();
help= STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brick->Id);
else
help= _ContextHelp;
}
@ -3543,7 +3543,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
{
CSPhraseSheet *phrase= dynamic_cast<CSPhraseSheet*>(SheetMngr.get(CSheetId(getSheetId())));
if(phrase)
help= CUtfStringView(STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id)).toUtf8();
help= STRING_MANAGER::CStringManagerClient::getSPhraseLocalizedName(phrase->Id);
else
help= _ContextHelp;
}
@ -3551,7 +3551,7 @@ void CDBCtrlSheet::getContextHelp(std::string &help) const
{
const COutpostBuildingSheet *outpost = asOutpostBuildingSheet();
if (outpost)
help = CUtfStringView(CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32()))).toUtf8();
help = CStringManagerClient::getOutpostBuildingLocalizedName(CSheetId(_SheetId.getSInt32()));
else
help = _ContextHelp;
}

@ -269,7 +269,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT
if (pOBS != NULL)
{
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 += CI18N::get("uiBotChatTime") + toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute");
if ((pOBS->CostTime % 60) != 0)
@ -692,7 +692,7 @@ void CDBGroupListSheetTrade::checkCoords ()
ucstring result;
if( pSMC->getString ( cst->LastVendorNameId, result) )
{
cst->VendorNameString = CEntityCL::removeShardFromName(result);
cst->VendorNameString = CEntityCL::removeShardFromName(result.toUtf8());
set< CSheetChildTrade *>::iterator itTmp = it;
++it;
VendorNameIdToUpdate.erase(itTmp);

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

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

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

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

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

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

@ -225,7 +225,7 @@ void CGroupPhraseSkillFilter::rebuild()
// just text
pNode->DisplayText = true;
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?
if(!_AHCtrlNode.empty())

@ -336,7 +336,7 @@ void CGroupSkills::createAllTreeNodes()
// local variable (avoid realloc in loop)
vector< pair<string, string> > tempVec(2);
string sSkillName;
const char *sSkillName;
while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop
{
@ -366,7 +366,7 @@ void CGroupSkills::createAllTreeNodes()
pNode->Id = NLMISC::toString(i);
// 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?
if(_TemplateSkill.empty())

@ -359,7 +359,7 @@ void CGuildManager::update()
for (uint i = 0; i < _GuildMembers.size(); ++i)
{
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
@ -875,7 +875,7 @@ class CAHGuildSheetOpen : public IActionHandler
CCtrlBase *inviteButton = pLine->getCtrl("invite_button");
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
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
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);
@ -1093,7 +1093,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostDesc)
// get sheet name
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);
@ -1120,7 +1120,7 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingName)
// get sheet name
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);
@ -1146,18 +1146,18 @@ static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc)
}
// get sheet name
string name;
const char *name;
CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet));
COutpostBuildingSheet *pOBS = dynamic_cast<COutpostBuildingSheet*>(pSheet);
if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty)
{
// Don't display description if the building is an empty slot
name.clear();
name = "";
}
else
{
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
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);
@ -1213,7 +1213,7 @@ static DECLARE_INTERFACE_USER_FCT(getSquadDesc)
// get sheet name
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);

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

@ -358,7 +358,7 @@ public:
}
else
{
std::string name = UserEntity->getEntityName().toUtf8();
std::string name = UserEntity->getEntityName();
if (*it == 'P') name = toUpper(name);
formatedResult += name;
}
@ -391,7 +391,7 @@ public:
}
else
{
botName = entity->getDisplayName().toUtf8();
botName = entity->getDisplayName();
}
CCharacterCL *pChar = dynamic_cast<CCharacterCL*>(entity);
if (pChar != NULL)
@ -405,7 +405,7 @@ public:
spprn.Woman = womanTitle;
spprn.cbIDStringReceived(sTitleTranslated);
botName = CEntityCL::removeTitleAndShardFromName(botName).toUtf8();
botName = CEntityCL::removeTitleAndShardFromName(botName);
// short name (with no title such as 'guard', 'merchant' ...)
if (*it == 's')
@ -425,37 +425,6 @@ public:
formatedResult += botName;
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:
{
formatedResult += '$';
@ -4246,7 +4215,7 @@ bool CInterfaceManager::parseTokens(string& ucstr)
// Parse the parameter
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
if (name.empty())
{

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

@ -1276,7 +1276,7 @@ void CPeopleInterraction::addContactInList(uint32 contactId, const ucstring &nam
CPeopleList &pl= nList==0?FriendList:IgnoreList;
// remove the shard name if possible
ucstring name= CEntityCL::removeShardFromName(nameIn);
ucstring name= CEntityCL::removeShardFromName(nameIn.toUtf8());
// add the contact to this list
sint index = pl.getIndexFromName(name);
@ -1327,7 +1327,7 @@ bool CPeopleInterraction::isContactInList(const ucstring &nameIn, uint8 nList) c
// select correct people list
const CPeopleList &pl= nList==0?FriendList:IgnoreList;
// remove the shard name if possible
ucstring name= CEntityCL::removeShardFromName(nameIn);
ucstring name= CEntityCL::removeShardFromName(nameIn.toUtf8());
return pl.getIndexFromName(name) != -1;
}
@ -2250,7 +2250,7 @@ public:
if (peopleList)
{
// 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"));
}

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

@ -832,7 +832,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c
}
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->Type != CEntityCL::Player)
@ -845,7 +845,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c
}
else
{
CEntityCL *destEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(playerName), false, true);
CEntityCL *destEntity = EntitiesMngr.getEntityByName (CEntityCL::removeTitleAndShardFromName(playerName.toUtf8()), false, true);
if (destEntity)
{
destEntity->removeStateFx();
@ -866,7 +866,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c
// if tell, bkup sendername
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"," ");
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
ucstring::size_type pos = finalString.find(goodSenderName);
@ -2299,11 +2299,9 @@ void impulsePhraseSend(NLMISC::CBitMemStream &impulse)
void impulseStringResp(NLMISC::CBitMemStream &impulse)
{
uint32 stringId;
string strUtf8;
string str;
impulse.serial(stringId);
impulse.serial(strUtf8);
ucstring str;
str.fromUtf8(strUtf8);
impulse.serial(str);
if (PermanentlyBanned) return;
@ -3389,7 +3387,7 @@ private:
public:
// called when the string is available
virtual void onDynStringAvailable(uint stringId, const ucstring &value)
virtual void onDynStringAvailable(uint stringId, const std::string &value)
{
// don't care if already displayed
if(_AlreadyDisplayed)

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save