Support UTF-32 in edit box, ryzom/ryzomcore#335

develop
kaetemi 4 years ago
parent 1a045e437e
commit 932a612f53

@ -137,6 +137,20 @@ public:
CComputedString &output, CComputedString &output,
bool keep800x600Ratio= true); bool keep800x600Ratio= true);
/**
* Same as computeString but do not make vertex buffers and primitives
*/
void computeStringInfo (NLMISC::CUtfStringView sv,
size_t len,
CFontGenerator *fontGen,
const NLMISC::CRGBA &color,
uint32 fontSize,
bool embolden,
bool oblique,
IDriver *driver,
CComputedString &output,
bool keep800x600Ratio= true);
/** /**
* Same as computeString but do not make vertex buffers and primitives * Same as computeString but do not make vertex buffers and primitives
*/ */

@ -382,6 +382,11 @@ public:
_FontManager->computeStringInfo (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio); _FontManager->computeStringInfo (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
} }
void computeStringInfo (NLMISC::CUtfStringView sv, CComputedString& output, size_t len)
{
_FontManager->computeStringInfo (sv, len, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
}
/// Debug : write to the disk the texture cache /// Debug : write to the disk the texture cache
void dumpCache (const char *filename) void dumpCache (const char *filename)
{ {

@ -104,6 +104,7 @@ public:
void erase(uint32 i) ; void erase(uint32 i) ;
virtual CStringInfo getStringInfo (uint32 i); virtual CStringInfo getStringInfo (uint32 i);
virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv); virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv);
virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv, size_t len);
void clear() ; void clear() ;
void printAt(float x, float y, uint32 i) ; void printAt(float x, float y, uint32 i) ;

@ -275,6 +275,11 @@ public:
* The returned string info is in pixel size per default. * The returned string info is in pixel size per default.
*/ */
virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv) = 0; virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv) = 0;
/**
* Get a string information from the ucstring
* The returned string info is in pixel size per default.
*/
virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv, size_t len) = 0;
/** /**
* empty the map * empty the map
*/ */

@ -63,16 +63,16 @@ namespace NLGUI
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
/// Accessors /// Accessors
ucstring getInputString() const { return _InputString; } u32string getInputString() const { return _InputString; }
const ucstring &getInputStringRef() const { return _InputString; } const u32string &getInputStringRef() const { return _InputString; }
const ucstring &getPrompt() const { return _Prompt; } const ucstring &getPrompt() const { return _Prompt; }
/** Set the prompt /** Set the prompt
* NB : line returns are encoded as '\n', not '\r\n' * NB : line returns are encoded as '\n', not '\r\n'
*/ */
void setPrompt(const ucstring &s) { _Prompt = s; } void setPrompt(const ucstring &s) { _Prompt = s; }
void setInputString(const ucstring &str); void setInputString(const u32string &str);
void setInputStringRef(const ucstring &str) {_InputString = str; }; void setInputStringRef(const u32string &str) {_InputString = str; };
void setInputStringAsInt(sint32 val); void setInputStringAsInt(sint32 val);
sint32 getInputStringAsInt() const; sint32 getInputStringAsInt() const;
void setInputStringAsInt64(sint64 val); void setInputStringAsInt64(sint64 val);
@ -81,6 +81,8 @@ namespace NLGUI
float getInputStringAsFloat() const; float getInputStringAsFloat() const;
void setInputStringAsUtf8(const std::string &str); void setInputStringAsUtf8(const std::string &str);
std::string getInputStringAsUtf8() const; std::string getInputStringAsUtf8() const;
void setInputStringAsUtf16(const ucstring &str);
ucstring getInputStringAsUtf16() const;
void setColor(NLMISC::CRGBA col); void setColor(NLMISC::CRGBA col);
@ -119,7 +121,7 @@ namespace NLGUI
sint32 getMaxHistoric() const {return _MaxHistoric;} sint32 getMaxHistoric() const {return _MaxHistoric;}
sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;} sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;}
void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;} void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;}
const ucstring &getHistoric(uint32 index) const {return _Historic[index];} const u32string &getHistoric(uint32 index) const {return _Historic[index];}
uint32 getNumHistoric() const {return (uint32)_Historic.size ();} uint32 getNumHistoric() const {return (uint32)_Historic.size ();}
// Get on change action handler // Get on change action handler
@ -188,7 +190,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText); REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText);
REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText); REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText);
REFLECT_STRING("input_string", getInputStringAsUtf8, setInputStringAsUtf8); REFLECT_STRING("input_string", getInputStringAsUtf8, setInputStringAsUtf8);
REFLECT_UCSTRING("uc_input_string", getInputString, setInputString); REFLECT_UCSTRING("uc_input_string", getInputStringAsUtf16, setInputStringAsUtf16);
REFLECT_EXPORT_END REFLECT_EXPORT_END
/** Restore the original value of the edit box. /** Restore the original value of the edit box.
@ -227,16 +229,16 @@ namespace NLGUI
// Text info // Text info
ucstring _Prompt; ucstring _Prompt;
ucstring _InputString; u32string _InputString;
CViewText *_ViewText; CViewText *_ViewText;
// undo / redo // undo / redo
ucstring _StartInputString; // value of the input string when focus was acuired first u32string _StartInputString; // value of the input string when focus was acuired first
ucstring _ModifiedInputString; u32string _ModifiedInputString;
// Historic info // Historic info
typedef std::deque<ucstring> THistoric; typedef std::deque<u32string> THistoric;
THistoric _Historic; THistoric _Historic;
uint32 _MaxHistoric; uint32 _MaxHistoric;
sint32 _CurrentHistoricIndex; sint32 _CurrentHistoricIndex;

@ -30,6 +30,8 @@ namespace NLMISC {
class CUtfStringView class CUtfStringView
{ {
public: public:
inline CUtfStringView() : m_Str(NULL), m_Size(0), m_Iterator(utf32Iterator) {}
inline CUtfStringView(const char *utf8Str) : m_Str(utf8Str), m_Size(strlen(utf8Str)), m_Iterator(utf8Iterator) {} inline CUtfStringView(const char *utf8Str) : m_Str(utf8Str), m_Size(strlen(utf8Str)), m_Iterator(utf8Iterator) {}
inline CUtfStringView(const char *utf8Str, size_t len): m_Str(utf8Str), m_Size(len), m_Iterator(utf8Iterator) inline CUtfStringView(const char *utf8Str, size_t len): m_Str(utf8Str), m_Size(len), m_Iterator(utf8Iterator)
{ {
@ -75,9 +77,24 @@ public:
m_Char = 0; m_Char = 0;
} }
} }
inline void operator+=(ptrdiff_t a)
{
while (m_Addr)
{
++(*this);
}
}
inline bool operator!=(const const_iterator &o) const { return m_Addr != o.m_Addr; } inline bool operator!=(const const_iterator &o) const { return m_Addr != o.m_Addr; }
inline bool operator==(const const_iterator &o) const { return m_Addr == o.m_Addr; } inline bool operator==(const const_iterator &o) const { return m_Addr == o.m_Addr; }
inline const u32char &operator*() const { return m_Char; } inline const u32char &operator*() const { return m_Char; }
const_iterator() : m_View(*(CUtfStringView *)NULL), m_Addr(NULL), m_Char(0) { }
const_iterator &operator=(const const_iterator &other)
{
if(this == &other) return *this;
this->~const_iterator();
return *new(this) const_iterator(other);
}
private: private:
friend class CUtfStringView; friend class CUtfStringView;
inline const_iterator(const CUtfStringView &view, const void *addr) : m_View(view), m_Addr(addr), m_Char(addr ? view.m_Iterator(&m_Addr) : 0) { } inline const_iterator(const CUtfStringView &view, const void *addr) : m_View(view), m_Addr(addr), m_Char(addr ? view.m_Iterator(&m_Addr) : 0) { }
@ -98,12 +115,28 @@ public:
inline bool empty() const { return !m_Size; } inline bool empty() const { return !m_Size; }
const void *ptr() const { return m_Str; } const void *ptr() const { return m_Str; }
inline CUtfStringView substr(const iterator &begin, const iterator &end) const
{
return CUtfStringView(begin.m_Addr, (ptrdiff_t)end.m_Addr - (ptrdiff_t)begin.m_Addr, m_Iterator);
}
inline bool endsWith(char c) { nlassert(c < 0x80); return *((char *)m_Str + m_Size - 1) == c; }
CUtfStringView &operator=(const CUtfStringView &other)
{
if(this == &other) return *this;
this->~CUtfStringView();
return *new(this) CUtfStringView(other);
}
private: private:
typedef u32char (*TIterator)(const void **addr); typedef u32char (*TIterator)(const void **addr);
static u32char utf8Iterator(const void **addr); static u32char utf8Iterator(const void **addr);
static u32char utf16Iterator(const void **addr); static u32char utf16Iterator(const void **addr);
static u32char utf32Iterator(const void **addr); static u32char utf32Iterator(const void **addr);
inline CUtfStringView(const void *str, size_t len, TIterator it) : m_Str(str), m_Size(len), m_Iterator(it) { }
const void *const m_Str; // String const void *const m_Str; // String
const size_t m_Size; // Size in bytes const size_t m_Size; // Size in bytes
const TIterator m_Iterator; const TIterator m_Iterator;

@ -237,6 +237,22 @@ void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv,
IDriver *driver, IDriver *driver,
CComputedString &output, CComputedString &output,
bool keep800x600Ratio ) bool keep800x600Ratio )
{
computeStringInfo(sv, sv.largestSize(), fontGen, color, fontSize, embolden, oblique, driver, output, keep800x600Ratio);
}
// ***************************************************************************
void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv,
size_t len,
CFontGenerator *fontGen,
const NLMISC::CRGBA &color,
uint32 fontSize,
bool embolden,
bool oblique,
IDriver *driver,
CComputedString &output,
bool keep800x600Ratio )
{ {
output.Color = color; output.Color = color;
@ -274,7 +290,8 @@ void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv,
CTextureFont::SLetterKey k; CTextureFont::SLetterKey k;
CTextureFont::SLetterInfo *pLI; CTextureFont::SLetterInfo *pLI;
for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it) size_t idx = 0;
for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end && idx < len; ++it, ++idx)
{ {
// Creating font // Creating font
k.Char = *it; k.Char = *it;

@ -286,6 +286,13 @@ UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringVie
_TextContext.computeStringInfo(sv, _CacheString); _TextContext.computeStringInfo(sv, _CacheString);
return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine); return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine);
} }
UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringView sv, size_t len)
{
H_AUTO2;
_TextContext.computeStringInfo(sv, _CacheString, len);
return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine);
}
void CTextContextUser::clear() void CTextContextUser::clear()
{ {
H_AUTO2; H_AUTO2;

@ -21,6 +21,7 @@
#include "stdpch.h" #include "stdpch.h"
#include "nel/gui/group_editbox.h" #include "nel/gui/group_editbox.h"
#include "nel/misc/command.h" #include "nel/misc/command.h"
#include "nel/misc/utf_string_view.h"
#include "nel/gui/view_text.h" #include "nel/gui/view_text.h"
#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/interface_options.h" #include "nel/gui/interface_options.h"
@ -826,11 +827,12 @@ namespace NLGUI
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupEditBox::writeString(const ucstring &str, bool replace, bool atEnd) void CGroupEditBox::writeString(const ucstring &str16, bool replace, bool atEnd)
{ {
u32string str = CUtfStringView(str16).toUtf32();
sint length = (sint)str.length(); sint length = (sint)str.length();
ucstring toAppend; u32string toAppend;
// filter character depending on the entry type // filter character depending on the entry type
switch (_EntryType) switch (_EntryType)
{ {
@ -963,7 +965,7 @@ namespace NLGUI
{ {
length = _MaxNumChar - (sint)_InputString.length(); length = _MaxNumChar - (sint)_InputString.length();
} }
ucstring toAdd = toAppend.substr(0, length); u32string toAdd = toAppend.substr(0, length);
sint32 minPos; sint32 minPos;
sint32 maxPos; sint32 maxPos;
if (_CurrSelection == this) if (_CurrSelection == this)
@ -1013,7 +1015,7 @@ namespace NLGUI
_CursorAtPreviousLineEnd = false; _CursorAtPreviousLineEnd = false;
if (_ClearOnEscape) if (_ClearOnEscape)
{ {
setInputString(ucstring("")); setInputString(u32string());
triggerOnChangeAH(); triggerOnChangeAH();
} }
CWidgetManager::getInstance()->setCaptureKeyboard(NULL); CWidgetManager::getInstance()->setCaptureKeyboard(NULL);
@ -1059,8 +1061,9 @@ namespace NLGUI
{ {
if (isKeyRETURN) if (isKeyRETURN)
{ {
ucstring copyStr= _InputString; //ucstring copyStr= _InputString;
if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn) //if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn)
if ((uint)std::count(_InputString.begin(), _InputString.end(), '\n') >= _MaxNumReturn)
break; break;
} }
@ -1121,11 +1124,11 @@ namespace NLGUI
if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX)) if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX))
{ {
// estimate new string // estimate new string
ucstring copyStr= _InputString; u32string copyStr= _InputString;
ucstring::iterator it = copyStr.begin() + _CursorPos; u32string::iterator it = copyStr.begin() + _CursorPos;
copyStr.insert(it, c); copyStr.insert(it, c);
sint32 value; sint32 value;
fromString(copyStr.toString(), value); fromString(CUtfStringView(copyStr).toUtf8(), value);
// if out of bounds, abort char // if out of bounds, abort char
if(value<_IntegerMinValue || value>_IntegerMaxValue) if(value<_IntegerMinValue || value>_IntegerMaxValue)
return; return;
@ -1134,12 +1137,12 @@ namespace NLGUI
if(_EntryType==PositiveInteger && (_PositiveIntegerMinValue!=0 || _PositiveIntegerMaxValue!=UINT_MAX)) if(_EntryType==PositiveInteger && (_PositiveIntegerMinValue!=0 || _PositiveIntegerMaxValue!=UINT_MAX))
{ {
// estimate new string // estimate new string
ucstring copyStr= _InputString; u32string copyStr= _InputString;
ucstring::iterator it = copyStr.begin() + _CursorPos; u32string::iterator it = copyStr.begin() + _CursorPos;
copyStr.insert(it, c); copyStr.insert(it, c);
// \todo yoyo: this doesn't really work i think.... // \todo yoyo: this doesn't really work i think....
uint32 value; uint32 value;
fromString(copyStr.toString(), value); fromString(CUtfStringView(copyStr).toUtf8(), value);
// if out of bounds, abort char // if out of bounds, abort char
if(value<_PositiveIntegerMinValue || value>_PositiveIntegerMaxValue) if(value<_PositiveIntegerMinValue || value>_PositiveIntegerMaxValue)
return; return;
@ -1148,7 +1151,7 @@ namespace NLGUI
if ((uint) _InputString.length() < _MaxNumChar) if ((uint) _InputString.length() < _MaxNumChar)
{ {
makeTopWindow(); makeTopWindow();
ucstring::iterator it = _InputString.begin() + _CursorPos; u32string::iterator it = _InputString.begin() + _CursorPos;
_InputString.insert(it, c); _InputString.insert(it, c);
++ _CursorPos; ++ _CursorPos;
triggerOnChangeAH(); triggerOnChangeAH();
@ -1229,11 +1232,11 @@ namespace NLGUI
{ {
makeTopWindow(); makeTopWindow();
// for french, deutsch and russian, be aware of unicode // for french, deutsch and russian, be aware of unicode
std::string command = _InputString.substr(1).toUtf8(); std::string command = CUtfStringView(_InputString.substr(1)).toUtf8();
ICommand::expand(command); ICommand::expand(command);
// then back to ucstring // then back to u32string
_InputString.fromUtf8(command); _InputString = CUtfStringView('/' + command).toUtf32();
_InputString = '/' + _InputString; _InputString = _InputString;
_CursorPos = (sint32)_InputString.length(); _CursorPos = (sint32)_InputString.length();
_CursorAtPreviousLineEnd = false; _CursorAtPreviousLineEnd = false;
triggerOnChangeAH(); triggerOnChangeAH();
@ -1260,7 +1263,7 @@ namespace NLGUI
// else delete last character // else delete last character
else if(_InputString.size () > 0 && _CursorPos != 0) else if(_InputString.size () > 0 && _CursorPos != 0)
{ {
ucstring::iterator it = _InputString.begin() + (_CursorPos - 1); u32string::iterator it = _InputString.begin() + (_CursorPos - 1);
_InputString.erase(it); _InputString.erase(it);
-- _CursorPos; -- _CursorPos;
_CursorAtPreviousLineEnd = false; _CursorAtPreviousLineEnd = false;
@ -1439,7 +1442,7 @@ namespace NLGUI
} }
else else
{ {
usTmp = _Prompt + _InputString; usTmp = _Prompt + CUtfStringView(_InputString).toUtf16();
} }
_ViewText->setText (usTmp); _ViewText->setText (usTmp);
} }
@ -1622,7 +1625,7 @@ namespace NLGUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupEditBox::setInputString(const ucstring &str) void CGroupEditBox::setInputString(const u32string &str)
{ {
_InputString = str; _InputString = str;
if (_CursorPos > (sint32) str.length()) if (_CursorPos > (sint32) str.length())
@ -1641,7 +1644,7 @@ namespace NLGUI
void CGroupEditBox::setDefaultInputString(const ucstring &str) void CGroupEditBox::setDefaultInputString(const ucstring &str)
{ {
_DefaultInputString= true; _DefaultInputString= true;
setInputString(str); setInputString(CUtfStringView(str).toUtf32());
} }
@ -1649,35 +1652,35 @@ namespace NLGUI
sint32 CGroupEditBox::getInputStringAsInt() const sint32 CGroupEditBox::getInputStringAsInt() const
{ {
sint32 value; sint32 value;
fromString(_InputString.toString(), value); fromString(getInputStringAsUtf8(), value);
return value; return value;
} }
// *************************************************************************** // ***************************************************************************
void CGroupEditBox::setInputStringAsInt(sint32 val) void CGroupEditBox::setInputStringAsInt(sint32 val)
{ {
setInputString(NLMISC::toString(val)); setInputStringAsUtf8(NLMISC::toString(val));
} }
// *************************************************************************** // ***************************************************************************
sint64 CGroupEditBox::getInputStringAsInt64() const sint64 CGroupEditBox::getInputStringAsInt64() const
{ {
sint64 value; sint64 value;
fromString(_InputString.toString(), value); fromString(getInputStringAsUtf8(), value);
return value; return value;
} }
// *************************************************************************** // ***************************************************************************
void CGroupEditBox::setInputStringAsInt64(sint64 val) void CGroupEditBox::setInputStringAsInt64(sint64 val)
{ {
setInputString(NLMISC::toString(val)); setInputStringAsUtf8(NLMISC::toString(val));
} }
// *************************************************************************** // ***************************************************************************
float CGroupEditBox::getInputStringAsFloat() const float CGroupEditBox::getInputStringAsFloat() const
{ {
float value; float value;
fromString(_InputString.toString(), value); fromString(getInputStringAsUtf8(), value);
return value; return value;
} }
@ -1685,14 +1688,14 @@ namespace NLGUI
void CGroupEditBox::setInputStringAsFloat(float val) void CGroupEditBox::setInputStringAsFloat(float val)
{ {
string fmt= "%." + NLMISC::toString(_MaxFloatPrec) + "f"; string fmt= "%." + NLMISC::toString(_MaxFloatPrec) + "f";
setInputString(NLMISC::toString(fmt.c_str(), val)); setInputStringAsUtf8(NLMISC::toString(fmt.c_str(), val));
} }
// *************************************************************************** // ***************************************************************************
void CGroupEditBox::cutSelection() void CGroupEditBox::cutSelection()
{ {
sint32 minPos= min(_CursorPos, _SelectCursorPos); ptrdiff_t minPos= min(_CursorPos, _SelectCursorPos);
sint32 maxPos= max(_CursorPos, _SelectCursorPos); ptrdiff_t maxPos= max(_CursorPos, _SelectCursorPos);
// cut the selection // cut the selection
if(!_InputString.empty()) if(!_InputString.empty())
{ {
@ -1706,10 +1709,10 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
ucstring CGroupEditBox::getSelection() ucstring CGroupEditBox::getSelection()
{ {
sint32 minPos= min(_CursorPos, _SelectCursorPos); ptrdiff_t minPos= min(_CursorPos, _SelectCursorPos);
sint32 maxPos= max(_CursorPos, _SelectCursorPos); ptrdiff_t maxPos= max(_CursorPos, _SelectCursorPos);
// get the selection // get the selection
return _InputString.substr(minPos, maxPos-minPos); return CUtfStringView(_InputString.substr(minPos, maxPos-minPos)).toUtf16();
} }
@ -1738,13 +1741,25 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupEditBox::setInputStringAsUtf8(const std::string &str) void CGroupEditBox::setInputStringAsUtf8(const std::string &str)
{ {
setInputString(ucstring::makeFromUtf8(str)); setInputString(CUtfStringView(str).toUtf32());
} }
// *************************************************************************** // ***************************************************************************
std::string CGroupEditBox::getInputStringAsUtf8() const std::string CGroupEditBox::getInputStringAsUtf8() const
{ {
return _InputString.toUtf8(); return CUtfStringView(_InputString).toUtf8();
}
// ***************************************************************************
void CGroupEditBox::setInputStringAsUtf16(const ucstring &str)
{
setInputString(CUtfStringView(str).toUtf32());
}
// ***************************************************************************
ucstring CGroupEditBox::getInputStringAsUtf16() const
{
return CUtfStringView(_InputString).toUtf16();
} }
// *************************************************************************** // ***************************************************************************
@ -1755,7 +1770,7 @@ namespace NLGUI
return; return;
// set the string and maybe execute // set the string and maybe execute
setInputString((ucchar) '/' + command); setInputString(CUtfStringView((ucchar) '/' + command).toUtf32());
if (execute) if (execute)
{ {
// stop selection // stop selection
@ -1810,13 +1825,30 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupEditBox::serialConfig(NLMISC::IStream &f) void CGroupEditBox::serialConfig(NLMISC::IStream &f)
{ {
f.serialVersion(0); uint version = f.serialVersion(1);
if(_DefaultInputString) // Don't want to save the default input if(_DefaultInputString) // Don't want to save the default input
{ {
_DefaultInputString= false; _DefaultInputString= false;
_InputString.clear(); _InputString.clear();
} }
f.serial(_InputString); if (version < 1)
{
ucstring str;
if (!f.isReading())
str = CUtfStringView(_InputString).toUtf16();
f.serial(str);
if (f.isReading())
_InputString = CUtfStringView(str).toUtf32();
}
else
{
std::string str;
if (!f.isReading())
str = CUtfStringView(_InputString).toUtf8();
f.serial(str);
if (f.isReading())
_InputString = CUtfStringView(str).toUtf32();
}
f.serial(_CursorPos); f.serial(_CursorPos);
f.serial(_PrevNumLine); f.serial(_PrevNumLine);
if (f.isReading()) if (f.isReading())
@ -1838,7 +1870,7 @@ namespace NLGUI
void CGroupEditBox::onQuit() void CGroupEditBox::onQuit()
{ {
// clear the text and restore backup pos before final save // clear the text and restore backup pos before final save
setInputString(ucstring("")); setInputString(u32string());
_CurrSelection = NULL; _CurrSelection = NULL;
} }
@ -1846,7 +1878,7 @@ namespace NLGUI
void CGroupEditBox::onLoadConfig() void CGroupEditBox::onLoadConfig()
{ {
// config is not saved when there's an empty string, so restore that default state. // config is not saved when there's an empty string, so restore that default state.
setInputString(ucstring("")); setInputString(u32string());
_CurrSelection = NULL; _CurrSelection = NULL;
_PrevNumLine = 1; _PrevNumLine = 1;
} }
@ -1861,7 +1893,7 @@ namespace NLGUI
if (_DefaultInputString) if (_DefaultInputString)
{ {
_DefaultInputString= false; _DefaultInputString= false;
setInputString(ucstring()); setInputString(u32string());
} }
_CanRedo = false; _CanRedo = false;
_CanUndo = false; _CanUndo = false;

@ -27,6 +27,7 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/misc/rgba.h" #include "nel/misc/rgba.h"
#include "nel/misc/algo.h" #include "nel/misc/algo.h"
#include "nel/misc/utf_string_view.h"
#include "nel/gui/libwww.h" #include "nel/gui/libwww.h"
#include "nel/gui/group_html.h" #include "nel/gui/group_html.h"
#include "nel/gui/group_list.h" #include "nel/gui/group_list.h"
@ -3023,7 +3024,7 @@ namespace NLGUI
CGroupEditBox *eb = dynamic_cast<CGroupEditBox*>(textArea->getGroup("eb")); CGroupEditBox *eb = dynamic_cast<CGroupEditBox*>(textArea->getGroup("eb"));
if (eb) if (eb)
{ {
eb->setInputString(decodeHTMLEntities(content)); eb->setInputString(CUtfStringView(decodeHTMLEntities(content)).toUtf32());
if (style.hasStyle("background-color")) if (style.hasStyle("background-color"))
{ {
CViewBitmap *bg = dynamic_cast<CViewBitmap*>(eb->getView("bg")); CViewBitmap *bg = dynamic_cast<CViewBitmap*>(eb->getView("bg"));

@ -2466,9 +2466,8 @@ namespace NLGUI
if ((uint) (index - charIndex) > currWord.NumSpaces) if ((uint) (index - charIndex) > currWord.NumSpaces)
{ {
// get the x position // get the x position
ucstring subStr = currWord.Text.substr(0, index - charIndex - currWord.NumSpaces);
// compute the size // compute the size
UTextContext::CStringInfo si = TextContext->getStringInfo(subStr); UTextContext::CStringInfo si = TextContext->getStringInfo(currWord.Text, (ptrdiff_t)index - charIndex - currWord.NumSpaces);
fx = px + si.StringWidth + currWord.NumSpaces * currLine.getSpaceWidth(); fx = px + si.StringWidth + currWord.NumSpaces * currLine.getSpaceWidth();
x = fx / _Scale; x = fx / _Scale;
@ -2496,9 +2495,8 @@ namespace NLGUI
else else
{ {
// get the x position // get the x position
ucstring subStr = _Text.substr(0, index);
// compute the size // compute the size
UTextContext::CStringInfo si = TextContext->getStringInfo(subStr); UTextContext::CStringInfo si = TextContext->getStringInfo(_Text, index);
y = 0; y = 0;
x = (sint) ceilf(si.StringWidth / _Scale); x = (sint) ceilf(si.StringWidth / _Scale);
} }
@ -2511,12 +2509,13 @@ namespace NLGUI
float px = 0.f; float px = 0.f;
UTextContext::CStringInfo si; UTextContext::CStringInfo si;
ucstring singleChar(" "); u32string singleChar(1, ' ');
uint i; uint i = 0;
for (i = 0; i < textValue.length(); ++i) NLMISC::CUtfStringView sv(textValue);
for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++i)
{ {
// get character width // get character width
singleChar[0] = textValue[i]; singleChar[0] = *it;
si = textContext.getStringInfo(singleChar); si = textContext.getStringInfo(singleChar);
px += si.StringWidth; px += si.StringWidth;
// the character is at the i - 1 position // the character is at the i - 1 position

@ -1686,7 +1686,7 @@ public:
ucstring sSurName = ucstring("NotSet"); ucstring sSurName = ucstring("NotSet");
CGroupEditBox *pGEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(sEditBoxPath)); CGroupEditBox *pGEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(sEditBoxPath));
if (pGEB != NULL) if (pGEB != NULL)
sFirstName = pGEB->getInputString(); sFirstName = pGEB->getInputStringAsUtf16();
else else
nlwarning ("can't get edit box name : %s",sEditBoxPath.c_str()); nlwarning ("can't get edit box name : %s",sEditBoxPath.c_str());
@ -2562,7 +2562,7 @@ static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName
viewText->setText(text); viewText->setText(text);
CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result); CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result);
if(editBox) if(editBox)
editBox->setInputString(text); editBox->setInputStringAsUtf16(text);
} }
} }
@ -2826,7 +2826,7 @@ class CAHScenarioControl : public IActionHandler
{ {
CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result); CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result);
if(editBox) if(editBox)
editBox->setInputString(description); editBox->setInputStringAsUtf16(description);
} }
} }
} }
@ -2977,7 +2977,7 @@ class CAHLoadScenario : public IActionHandler
{ {
CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result); CGroupEditBox* editBox = dynamic_cast<CGroupEditBox*>(result);
if(editBox) if(editBox)
description = editBox->getInputString().toString(); description = editBox->getInputStringAsUtf8();
} }
// races // races

@ -27,6 +27,7 @@ using namespace NLMISC;
#include "nel/gui/action_handler.h" #include "nel/gui/action_handler.h"
#include "nel/gui/group_editbox.h" #include "nel/gui/group_editbox.h"
#include "nel/misc/utf_string_view.h"
#include "interface_manager.h" #include "interface_manager.h"
#include "../client_chat_manager.h" #include "../client_chat_manager.h"
#include "people_interraction.h" #include "people_interraction.h"
@ -56,7 +57,7 @@ extern CClientChatManager ChatMngr;
// *************************************************************************** // ***************************************************************************
// used for character classifiction (when the user press Ctrl-arrow) // used for character classifiction (when the user press Ctrl-arrow)
static inline uint getCharacterCategory(ucchar c) static inline uint getCharacterCategory(u32char c)
{ {
if (c == ' ') return 0; if (c == ' ') return 0;
if (c > 127 || isalpha((char) c)) return 1; // alpha & other characters if (c > 127 || isalpha((char) c)) return 1; // alpha & other characters
@ -69,7 +70,7 @@ static inline uint getCharacterCategory(ucchar c)
/** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed) /** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed)
* It returns the new index * It returns the new index
*/ */
static uint skipUCCharsRight(uint startPos, const ucstring &str) static uint skipUCCharsRight(uint startPos, const u32string &str)
{ {
uint pos = startPos; uint pos = startPos;
uint endIndex = (uint)str.length(); uint endIndex = (uint)str.length();
@ -86,7 +87,7 @@ static uint skipUCCharsRight(uint startPos, const ucstring &str)
/** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed) /** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed)
* It returns the new index * It returns the new index
*/ */
static uint skipUCCharsLeft(uint startPos, const ucstring &str) static uint skipUCCharsLeft(uint startPos, const u32string &str)
{ {
uint pos = startPos; uint pos = startPos;
-- pos; -- pos;
@ -362,7 +363,7 @@ class CAHEditPreviousLine : public CAHEdit
if (_GroupEdit->getMaxHistoric() && (! _GroupEdit->getViewText()->getMultiLine())) if (_GroupEdit->getMaxHistoric() && (! _GroupEdit->getViewText()->getMultiLine()))
{ {
// Get the start of the string. // Get the start of the string.
ucstring startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos());
// Search all historic string that match startStr. // Search all historic string that match startStr.
for(sint i=_GroupEdit->getCurrentHistoricIndex()+1;i<(sint)_GroupEdit->getNumHistoric();i++) for(sint i=_GroupEdit->getCurrentHistoricIndex()+1;i<(sint)_GroupEdit->getNumHistoric();i++)
@ -434,7 +435,7 @@ class CAHEditNextLine : public CAHEdit
if( (! _GroupEdit->getViewText()->getMultiLine()) && _GroupEdit->getMaxHistoric() && _GroupEdit->getCurrentHistoricIndex()>0) if( (! _GroupEdit->getViewText()->getMultiLine()) && _GroupEdit->getMaxHistoric() && _GroupEdit->getCurrentHistoricIndex()>0)
{ {
// Get the start of the string. // Get the start of the string.
ucstring startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos()); u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos());
// Search all historic string that match startStr. // Search all historic string that match startStr.
for(sint i=_GroupEdit->getCurrentHistoricIndex()-1;i>=0;i--) for(sint i=_GroupEdit->getCurrentHistoricIndex()-1;i>=0;i--)
@ -520,8 +521,8 @@ protected:
// else cut forwards // else cut forwards
else if(_GroupEdit->getCursorPos() < (sint32) _GroupEdit->getInputStringRef().length()) else if(_GroupEdit->getCursorPos() < (sint32) _GroupEdit->getInputStringRef().length())
{ {
ucstring inputString = _GroupEdit->getInputStringRef(); u32string inputString = _GroupEdit->getInputStringRef();
ucstring::iterator it = inputString.begin() + _GroupEdit->getCursorPos(); u32string::iterator it = inputString.begin() + _GroupEdit->getCursorPos();
inputString.erase(it); inputString.erase(it);
_GroupEdit->setInputStringRef (inputString); _GroupEdit->setInputStringRef (inputString);
if (!_GroupEdit->getAHOnChange().empty()) if (!_GroupEdit->getAHOnChange().empty())
@ -638,7 +639,7 @@ class CAHEditExpandOrCycleTell : public CAHEdit
void actionPart () void actionPart ()
{ {
// If the line starts with '/tell ', do not try to expand // If the line starts with '/tell ', do not try to expand
static const ucstring TELL_STR("/tell "); static const u32string TELL_STR(CUtfStringView("/tell ").toUtf32());
if (_GroupEdit->getInputString().substr(0, TELL_STR.length()) != TELL_STR) if (_GroupEdit->getInputString().substr(0, TELL_STR.length()) != TELL_STR)
{ {
if (_GroupEdit->expand()) return; if (_GroupEdit->expand()) return;

@ -129,7 +129,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived()
{ {
if ( pIS->Family == ITEMFAMILY::SCROLL) if ( pIS->Family == ITEMFAMILY::SCROLL)
{ {
editBoxLarge->setInputString(itemInfo.CustomText); editBoxLarge->setInputStringAsUtf16(itemInfo.CustomText);
editLarge->setActive(true); editLarge->setActive(true);
editBoxLarge->setActive(true); editBoxLarge->setActive(true);
@ -147,7 +147,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived()
strFindReplace(customText, "%mfc", ucstring()); strFindReplace(customText, "%mfc", ucstring());
} }
editBoxShort->setInputString(customText); editBoxShort->setInputStringAsUtf16(customText);
editShort->setActive(true); editShort->setActive(true);
editBoxShort->setActive(true); editBoxShort->setActive(true);
@ -239,8 +239,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
closeButton->setActive(false); closeButton->setActive(false);
group->setActive(true); group->setActive(true);
editBoxShort->setInputString(ucstring()); editBoxShort->setInputString(u32string());
editBoxLarge->setInputString(ucstring()); editBoxLarge->setInputString(u32string());
display->setTextFormatTaged(ucstring()); display->setTextFormatTaged(ucstring());
@ -250,7 +250,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
// If we already have item info // If we already have item info
if ( pIS->Family == ITEMFAMILY::SCROLL) if ( pIS->Family == ITEMFAMILY::SCROLL)
{ {
editBoxLarge->setInputString(itemInfo.CustomText); editBoxLarge->setInputStringAsUtf16(itemInfo.CustomText);
editLarge->setActive(true); editLarge->setActive(true);
editBoxLarge->setActive(true); editBoxLarge->setActive(true);
@ -269,7 +269,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
strFindReplace(customText, "%mfc", ucstring()); strFindReplace(customText, "%mfc", ucstring());
} }
editBoxShort->setInputString(customText); editBoxShort->setInputStringAsUtf16(customText);
editShort->setActive(true); editShort->setActive(true);
editBoxShort->setActive(true); editBoxShort->setActive(true);
@ -297,8 +297,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
closeButton->setActive(true); closeButton->setActive(true);
group->setActive(false); group->setActive(false);
editBoxShort->setInputString(ucstring()); editBoxShort->setInputString(u32string());
editBoxLarge->setInputString(ucstring()); editBoxLarge->setInputString(u32string());
display->setTextFormatTaged(ucstring()); display->setTextFormatTaged(ucstring());
// Finish the display or add the waiter // Finish the display or add the waiter
@ -406,11 +406,11 @@ void CInterfaceItemEdition::CItemEditionWindow::validate()
if (group && editShort && editBoxShort && editLarge && editBoxLarge && display && editButtons && closeButton && background) if (group && editShort && editBoxShort && editLarge && editBoxLarge && display && editButtons && closeButton && background)
{ {
bool textValid = editShort->getActive(); bool textValid = editShort->getActive();
ucstring text = editBoxShort->getInputString(); ucstring text = editBoxShort->getInputStringAsUtf16();
if (!textValid) if (!textValid)
{ {
textValid = editLarge->getActive(); textValid = editLarge->getActive();
text = editBoxLarge->getInputString(); text = editBoxLarge->getInputStringAsUtf16();
} }
if (textValid) if (textValid)

@ -718,7 +718,7 @@ void CActionPhraseFaber::startMpSelection(uint itemReqLine, uint mpSlot)
if (eb) if (eb)
{ {
CWidgetManager::getInstance()->setCaptureKeyboard(eb); CWidgetManager::getInstance()->setCaptureKeyboard(eb);
eb->setInputString(toString(maxQuantity)); eb->setInputStringAsUtf8(toString(maxQuantity));
eb->setSelectionAll(); eb->setSelectionAll();
} }
} }

@ -70,10 +70,10 @@ class CHandlerGuildCreate : public IActionHandler
CGroupEditBox *pDesc = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(guildDescWin)); CGroupEditBox *pDesc = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(guildDescWin));
ucstring guildName = pGEB->getInputString(); ucstring guildName = pGEB->getInputStringAsUtf16();
ucstring guildDesc; ucstring guildDesc;
if (pDesc != NULL) guildDesc = pDesc->getInputString(); if (pDesc != NULL) guildDesc = pDesc->getInputStringAsUtf16();
uint64 icon = CGuildManager::iconMake((uint8)pCS->getGuildBack(), (uint8)pCS->getGuildSymbol(), uint64 icon = CGuildManager::iconMake((uint8)pCS->getGuildBack(), (uint8)pCS->getGuildSymbol(),
pCS->getInvertGuildSymbol(), pCS->getGuildColor1(), pCS->getGuildColor2()); pCS->getInvertGuildSymbol(), pCS->getGuildColor1(), pCS->getGuildColor2());

@ -333,7 +333,7 @@ uint32 CBotChatPageTrade::getCurrItemQuantity() const
CGroupEditBox *ed = dynamic_cast<CGroupEditBox *>(ig->getGroup("header_opened:standard_price:quantity:edit:eb")); CGroupEditBox *ed = dynamic_cast<CGroupEditBox *>(ig->getGroup("header_opened:standard_price:quantity:edit:eb"));
if (!ed) return std::numeric_limits<uint32>::max(); if (!ed) return std::numeric_limits<uint32>::max();
uint32 intQuantity; uint32 intQuantity;
if (fromString(ed->getInputString().toString(), intQuantity)) if (fromString(ed->getInputStringAsUtf8(), intQuantity))
{ {
return intQuantity; return intQuantity;
} }
@ -1465,7 +1465,7 @@ void CBotChatPageTrade::setupPriceGroupQuantity(CInterfaceGroup *priceGroup, sin
CGroupEditBox *eb = dynamic_cast<CGroupEditBox *>(quantityGroup->getGroup("edit:eb")); CGroupEditBox *eb = dynamic_cast<CGroupEditBox *>(quantityGroup->getGroup("edit:eb"));
if (eb) if (eb)
{ {
eb->setInputString(toString(defaultQuantity)); eb->setInputStringAsUtf8(toString(defaultQuantity));
} }
} }
} }
@ -1569,7 +1569,7 @@ void CBotChatPageTrade::setupResellGroup(bool sellMode, uint defaultQuantity, CI
{ {
sint32 resaleMargin= NLGUI::CDBManager::getInstance()->getDbProp( "UI:SAVE:TRADE_ITEM:RESALE_MARGIN" )->getValue32(); sint32 resaleMargin= NLGUI::CDBManager::getInstance()->getDbProp( "UI:SAVE:TRADE_ITEM:RESALE_MARGIN" )->getValue32();
clamp(resaleMargin, 0, (sint32)MaxResaleMargin); clamp(resaleMargin, 0, (sint32)MaxResaleMargin);
eb->setInputString( toString( resaleMargin ) ); eb->setInputStringAsUtf8( toString( resaleMargin ) );
eb->setPositiveIntegerMaxValue(MaxResaleMargin); eb->setPositiveIntegerMaxValue(MaxResaleMargin);
} }
} }
@ -1725,8 +1725,8 @@ void CBotChatPageTrade::startChangeBuyFilterDialog(const std::string &dbext, con
sint rangeMax= 0; sint rangeMax= 0;
if(dbRangeMin) rangeMin= dbRangeMin->getValue32(); if(dbRangeMin) rangeMin= dbRangeMin->getValue32();
if(dbRangeMax) rangeMax= dbRangeMax->getValue32(); if(dbRangeMax) rangeMax= dbRangeMax->getValue32();
if(edMin) edMin->setInputString(toString(rangeMin)); if(edMin) edMin->setInputStringAsUtf8(toString(rangeMin));
if(edMax) edMax->setInputString(toString(rangeMax)); if(edMax) edMax->setInputStringAsUtf8(toString(rangeMax));
if(edMin) edMin->setPositiveIntegerMaxValue(maxValue); if(edMin) edMin->setPositiveIntegerMaxValue(maxValue);
if(edMax) edMax->setPositiveIntegerMaxValue(maxValue); if(edMax) edMax->setPositiveIntegerMaxValue(maxValue);
@ -1754,8 +1754,8 @@ void CBotChatPageTrade::resetBuyFilterDialog()
sint rangeMin= 0; sint rangeMin= 0;
sint rangeMax= _FilterBuyDlgMaxValue; sint rangeMax= _FilterBuyDlgMaxValue;
// write result in EditBox, and in db // write result in EditBox, and in db
if(edMin) edMin->setInputString(toString(rangeMin)); if(edMin) edMin->setInputStringAsUtf8(toString(rangeMin));
if(edMax) edMax->setInputString(toString(rangeMax)); if(edMax) edMax->setInputStringAsUtf8(toString(rangeMax));
if(dbRangeMin) dbRangeMin->setValue32(rangeMin); if(dbRangeMin) dbRangeMin->setValue32(rangeMin);
if(dbRangeMax) dbRangeMax->setValue32(rangeMax); if(dbRangeMax) dbRangeMax->setValue32(rangeMax);

@ -363,7 +363,7 @@ void CChatWindow::setCommand(const ucstring &command,bool execute)
void CChatWindow::setEntry(const ucstring &entry) void CChatWindow::setEntry(const ucstring &entry)
{ {
if (!_EB) return; if (!_EB) return;
_EB->setInputString(entry); _EB->setInputStringAsUtf16(entry);
} }
//================================================================================= //=================================================================================
@ -1273,7 +1273,7 @@ public:
{ {
CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(pCaller); CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(pCaller);
if (pEB == NULL) return; if (pEB == NULL) return;
ucstring text = pEB->getInputString(); ucstring text = pEB->getInputStringAsUtf16();
// If the line is empty, do nothing // If the line is empty, do nothing
if(text.empty()) if(text.empty())
return; return;
@ -1289,7 +1289,7 @@ public:
// Parse any tokens in the text // Parse any tokens in the text
if ( ! CInterfaceManager::parseTokens(text)) if ( ! CInterfaceManager::parseTokens(text))
{ {
pEB->setInputString (string("")); pEB->setInputString (u32string());
return; return;
} }
@ -1329,7 +1329,7 @@ public:
} }
} }
// Clear input string // Clear input string
pEB->setInputString (ucstring("")); pEB->setInputString (u32string());
CGroupContainer *gc = static_cast< CGroupContainer* >( pEB->getEnclosingContainer() ); CGroupContainer *gc = static_cast< CGroupContainer* >( pEB->getEnclosingContainer() );
if (gc) if (gc)

@ -279,7 +279,7 @@ void CDBGroupBuildPhrase::clearBuildingPhrase()
// Empty the name // Empty the name
if(_UserSentenceName) if(_UserSentenceName)
{ {
_UserSentenceName->setInputString(ucstring()); _UserSentenceName->setInputString(u32string());
} }
// update Display // update Display
@ -373,7 +373,7 @@ void CDBGroupBuildPhrase::startComposition(const CSPhraseCom &phrase)
// set the editable name. // set the editable name.
if(_UserSentenceName) if(_UserSentenceName)
_UserSentenceName->setInputString(name); _UserSentenceName->setInputStringAsUtf16(name);
} }
@ -1790,7 +1790,7 @@ void CDBGroupBuildPhrase::buildCurrentPhrase(CSPhraseCom &newPhrase)
// Set the Name // Set the Name
if(_UserSentenceName) if(_UserSentenceName)
{ {
newPhrase.Name= _UserSentenceName->getInputString(); newPhrase.Name= _UserSentenceName->getInputStringAsUtf16();
} }
} }

@ -141,12 +141,12 @@ static void popupLandMarkNameDialog()
const CUserLandMark userLM = map->getUserLandMark(LastSelectedLandMark); const CUserLandMark userLM = map->getUserLandMark(LastSelectedLandMark);
NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(userLM.Type)); NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(userLM.Type));
eb->setInputString(userLM.Title); eb->setInputStringAsUtf16(userLM.Title);
} }
else else
{ {
NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(CUserLandMark::Misc)); NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(CUserLandMark::Misc));
eb->setInputString(ucstring()); eb->setInputStringAsUtf16(ucstring());
} }
CWidgetManager::getInstance()->setCaptureKeyboard(eb); CWidgetManager::getInstance()->setCaptureKeyboard(eb);
@ -3882,7 +3882,7 @@ class CAHLandMarkFilter : public IActionHandler
CGroupEditBox* eb = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(group)); CGroupEditBox* eb = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(group));
if (!eb) return; if (!eb) return;
text = eb->getInputString().toUtf8(); text = eb->getInputStringAsUtf8();
} }
map->setLandmarkFilter(text); map->setLandmarkFilter(text);
@ -3988,7 +3988,7 @@ class CAHValidateUserLandMarkName : public IActionHandler
CGroupMap *map = dynamic_cast<CGroupMap *>(LastSelectedLandMark->getParent()); CGroupMap *map = dynamic_cast<CGroupMap *>(LastSelectedLandMark->getParent());
if (!map) return; if (!map) return;
// update existing landmark // update existing landmark
map->updateUserLandMark(LastSelectedLandMark, eb->getInputString(), landMarkType); map->updateUserLandMark(LastSelectedLandMark, eb->getInputStringAsUtf16(), landMarkType);
} }
else else
{ {
@ -3996,11 +3996,11 @@ class CAHValidateUserLandMarkName : public IActionHandler
if (!LastClickedMap) return; if (!LastClickedMap) return;
if( UseUserPositionForLandMark ) if( UseUserPositionForLandMark )
{ {
LastClickedMap->addUserLandMark(LastClickedMap->getPlayerPos(), eb->getInputString(), landMarkType); LastClickedMap->addUserLandMark(LastClickedMap->getPlayerPos(), eb->getInputStringAsUtf16(), landMarkType);
} }
else else
{ {
LastClickedMap->addUserLandMark(LastClickedMap->getRightClickLastPos(), eb->getInputString(), landMarkType); LastClickedMap->addUserLandMark(LastClickedMap->getRightClickLastPos(), eb->getInputStringAsUtf16(), landMarkType);
} }
LastClickedMap->invalidateCoords(); LastClickedMap->invalidateCoords();
} }

@ -2755,7 +2755,7 @@ class CHandlerInvSearchButton : public IActionHandler
{ {
CWidgetManager::getInstance()->setCaptureKeyboard(eb); CWidgetManager::getInstance()->setCaptureKeyboard(eb);
eb->setSelectionAll(); eb->setSelectionAll();
filter = eb->getInputString(); filter = eb->getInputStringAsUtf16();
} }
CDBGroupListSheetBag *pList = dynamic_cast<CDBGroupListSheetBag*>(CWidgetManager::getInstance()->getElementFromId(btn->getParent()->getId() + ":bag_list")); CDBGroupListSheetBag *pList = dynamic_cast<CDBGroupListSheetBag*>(CWidgetManager::getInstance()->getElementFromId(btn->getParent()->getId() + ":bag_list"));
@ -2805,10 +2805,10 @@ class CHandlerInvSetSearch : public IActionHandler
std::string id = pCaller->getParent()->getParent()->getId(); std::string id = pCaller->getParent()->getParent()->getId();
CDBGroupListSheetBag *pList = dynamic_cast<CDBGroupListSheetBag*>(CWidgetManager::getInstance()->getElementFromId(id + ":bag_list")); CDBGroupListSheetBag *pList = dynamic_cast<CDBGroupListSheetBag*>(CWidgetManager::getInstance()->getElementFromId(id + ":bag_list"));
if (pList != NULL) pList->setSearchFilter(eb->getInputString()); if (pList != NULL) pList->setSearchFilter(eb->getInputStringAsUtf16());
CDBGroupIconListBag *pIcons = dynamic_cast<CDBGroupIconListBag*>(CWidgetManager::getInstance()->getElementFromId(id + ":bag_icons")); CDBGroupIconListBag *pIcons = dynamic_cast<CDBGroupIconListBag*>(CWidgetManager::getInstance()->getElementFromId(id + ":bag_icons"));
if (pIcons != NULL) pIcons->setSearchFilter(eb->getInputString()); if (pIcons != NULL) pIcons->setSearchFilter(eb->getInputStringAsUtf16());
} }
}; };
REGISTER_ACTION_HANDLER( CHandlerInvSetSearch, "inv_set_search" ); REGISTER_ACTION_HANDLER( CHandlerInvSetSearch, "inv_set_search" );

@ -1148,7 +1148,7 @@ void CModalContainerEditCmd::onChangeAction()
CGroupEditBox *pEB= dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId( sWin )); CGroupEditBox *pEB= dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId( sWin ));
if( pEB ) if( pEB )
{ {
pEB->setInputString(ucstring("")); pEB->setInputString(u32string());
} }
NLGUI::CDBManager::getInstance()->getDbProp( sDB )->setValue32(1); NLGUI::CDBManager::getInstance()->getDbProp( sDB )->setValue32(1);
} }

@ -886,7 +886,7 @@ public:
if (pCS != NULL) pCS->readFromMacro(pMCM->CurrentEditMacro); if (pCS != NULL) pCS->readFromMacro(pMCM->CurrentEditMacro);
// Name // Name
CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_EDIT_NAME)); CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_EDIT_NAME));
if (pEB != NULL) pEB->setInputString(pMCM->CurrentEditMacro.Name); if (pEB != NULL) pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.Name);
// Commands // Commands
CGroupList *pList = dynamic_cast<CGroupList*>(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_COMMANDS)); CGroupList *pList = dynamic_cast<CGroupList*>(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_COMMANDS));
if (pList == NULL) return; if (pList == NULL) return;

@ -2199,7 +2199,7 @@ public:
if (gc) if (gc)
{ {
CGroupEditBox *geb = dynamic_cast<CGroupEditBox *>(gc->getGroup("add_contact_eb:eb")); CGroupEditBox *geb = dynamic_cast<CGroupEditBox *>(gc->getGroup("add_contact_eb:eb"));
geb->setInputString(ucstring("")); geb->setInputString(u32string());
} }
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams);
} }
@ -2250,18 +2250,18 @@ public:
if (peopleList) if (peopleList)
{ {
// don't add if it is the player name // don't add if it is the player name
if (!ClientCfg.Local && (UserEntity->getEntityName() == geb->getInputString())) if (!ClientCfg.Local && (UserEntity->getEntityName() == geb->getInputStringAsUtf16()))
{ {
displayVisibleSystemMsg(CI18N::get("uiCantAddYourSelfInContactList")); displayVisibleSystemMsg(CI18N::get("uiCantAddYourSelfInContactList"));
} }
else else
{ {
PeopleInterraction.askAddContact(geb->getInputString(), peopleList); PeopleInterraction.askAddContact(geb->getInputStringAsUtf16(), peopleList);
geb->setInputString(ucstring("")); geb->setInputString(u32string());
} }
} }
} }
geb->setInputString(ucstring("")); geb->setInputString(u32string());
} }
} }
} }
@ -2389,7 +2389,7 @@ public:
if (eb) if (eb)
{ {
CWidgetManager::getInstance()->setCaptureKeyboard(eb); CWidgetManager::getInstance()->setCaptureKeyboard(eb);
eb->setInputString(ucstring("")); eb->setInputString(u32string());
} }
// //
if (gc->getActive()) if (gc->getActive())
@ -2416,7 +2416,7 @@ class CHandlerValidatePartyChatName : public IActionHandler
if (!gc) return; if (!gc) return;
CGroupEditBox *eb = dynamic_cast<CGroupEditBox *>(gc->getGroup("eb")); CGroupEditBox *eb = dynamic_cast<CGroupEditBox *>(gc->getGroup("eb"));
if (!eb) return; if (!eb) return;
ucstring title = eb->getInputString(); ucstring title = eb->getInputStringAsUtf16();
// TODO GAMEDEV : create (or join ?) a new channel. Each channel (party chat) should have a unique name in the game // TODO GAMEDEV : create (or join ?) a new channel. Each channel (party chat) should have a unique name in the game
// moreover, it should not have the name of another available chat window (for example, it shouldn't be named 'Around Me') // moreover, it should not have the name of another available chat window (for example, it shouldn't be named 'Around Me')

@ -876,7 +876,7 @@ class CHandlerContactEntry : public IActionHandler
{ {
CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(pCaller); CGroupEditBox *pEB = dynamic_cast<CGroupEditBox*>(pCaller);
if (pEB == NULL) return; if (pEB == NULL) return;
ucstring text = pEB->getInputString(); ucstring text = pEB->getInputStringAsUtf16();
// If the line is empty, do nothing // If the line is empty, do nothing
if(text.empty()) if(text.empty())
return; return;
@ -884,7 +884,7 @@ class CHandlerContactEntry : public IActionHandler
// Parse any tokens in the text // Parse any tokens in the text
if ( ! CInterfaceManager::parseTokens(text)) if ( ! CInterfaceManager::parseTokens(text))
{ {
pEB->setInputString (string("")); pEB->setInputString (u32string());
return; return;
} }
@ -895,7 +895,7 @@ class CHandlerContactEntry : public IActionHandler
// TODO : have NLMISC::ICommand accept unicode strings // TODO : have NLMISC::ICommand accept unicode strings
std::string str = text.toUtf8().substr(1); std::string str = text.toUtf8().substr(1);
NLMISC::ICommand::execute( str, g_log ); NLMISC::ICommand::execute( str, g_log );
pEB->setInputString (string("")); pEB->setInputString (u32string());
return; return;
} }
// Well, we could have used CChatWindow class to handle this, but CPeopleList was written earlier, so for now // Well, we could have used CChatWindow class to handle this, but CPeopleList was written earlier, so for now
@ -908,7 +908,7 @@ class CHandlerContactEntry : public IActionHandler
// Simply do a tell on the player // Simply do a tell on the player
ChatMngr.tell(playerName.toString(), text); ChatMngr.tell(playerName.toString(), text);
pEB->setInputString (string("")); pEB->setInputString (u32string());
if (gc) if (gc)
{ {
// Restore position of enclosing container if it hasn't been moved/scaled/poped by the user // Restore position of enclosing container if it hasn't been moved/scaled/poped by the user

@ -808,7 +808,7 @@ void initLoginScreen()
CGroupEditBox *pGEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); CGroupEditBox *pGEB = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN));
if (pGEB != NULL && (pGEB->getInputString().empty())) if (pGEB != NULL && (pGEB->getInputString().empty()))
{ {
pGEB->setInputString(l); pGEB->setInputStringAsUtf8(l);
} }
CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false"); CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false");
} }
@ -830,8 +830,8 @@ void initAutoLogin()
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
CGroupEditBox *pGEBLog = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); CGroupEditBox *pGEBLog = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN));
CGroupEditBox *pGEBPwd = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD)); CGroupEditBox *pGEBPwd = dynamic_cast<CGroupEditBox*>(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD));
pGEBLog->setInputString(LoginLogin); pGEBLog->setInputStringAsUtf8(LoginLogin);
pGEBPwd->setInputString(LoginPassword); pGEBPwd->setInputStringAsUtf8(LoginPassword);
CAHManager::getInstance()->runActionHandler("on_login", NULL, ""); CAHManager::getInstance()->runActionHandler("on_login", NULL, "");
if (ClientCfg.R2Mode) if (ClientCfg.R2Mode)
@ -1379,8 +1379,8 @@ class CAHOnLogin : public IActionHandler
return; return;
} }
LoginLogin = pGEBLog->getInputString().toString(); // FIXME: Unicode login LoginLogin = pGEBLog->getInputStringAsUtf8();
LoginPassword = pGEBPwd->getInputString().toString(); LoginPassword = pGEBPwd->getInputStringAsUtf8();
onlogin(); onlogin();
} }
@ -2394,7 +2394,7 @@ bool initCreateAccount()
{ {
CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId(editBoxes[i] + ":eb")); CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId(editBoxes[i] + ":eb"));
if(eb) if(eb)
eb->setInputString(ucstring("")); eb->setInputString(u32string());
} }
// conditions button // conditions button
@ -2581,7 +2581,7 @@ class CAHOnCreateAccountSubmit : public IActionHandler
{ {
CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId(editBoxes[i] + ":eb")); CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId(editBoxes[i] + ":eb"));
if(eb) if(eb)
results[i] = eb->getInputString().toUtf8(); results[i] = eb->getInputStringAsUtf8();
} }
// text // text
@ -2735,11 +2735,11 @@ class CAHCreateAccountLogin : public IActionHandler
{ {
CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId("eb_login:eb")); CGroupEditBox * eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId("eb_login:eb"));
if(eb) if(eb)
LoginLogin = eb->getInputString().toUtf8(); LoginLogin = eb->getInputStringAsUtf8();
eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId("eb_password:eb")); eb = dynamic_cast<CGroupEditBox*>(createAccountUI->findFromShortId("eb_password:eb"));
if(eb) if(eb)
LoginPassword = eb->getInputString().toUtf8(); LoginPassword = eb->getInputStringAsUtf8();
onlogin(false); onlogin(false);
} }

@ -7484,7 +7484,7 @@ class CAHInviteCharacter : public IActionHandler
CGroupEditBox *geb = dynamic_cast<CGroupEditBox *>(fatherGC->getGroup("add_contact_eb:eb")); CGroupEditBox *geb = dynamic_cast<CGroupEditBox *>(fatherGC->getGroup("add_contact_eb:eb"));
if (geb && !geb->getInputString().empty()) if (geb && !geb->getInputString().empty())
{ {
string charName = geb->getInputString().toString(); string charName = geb->getInputStringAsUtf8();
CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance(); CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance();
sessionBrowser.inviteCharacterByName(sessionBrowser.getCharId(), charName); sessionBrowser.inviteCharacterByName(sessionBrowser.getCharId(), charName);
@ -7506,7 +7506,7 @@ class CAHInviteCharacter : public IActionHandler
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_newcomer"); CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_newcomer");
} }
geb->setInputString(ucstring("")); geb->setInputString(u32string());
} }
} }
} }

Loading…
Cancel
Save