fix merge conflict

feature/develop-atys
Nimetu 4 years ago
commit 72098f624d

@ -36,7 +36,7 @@ typedef struct FT_FaceRec_* FT_Face;
#include "nel/misc/types_nl.h"
#include <string>
#include <vector>
namespace NL3D {
@ -88,6 +88,7 @@ private:
static uint32 _FontGeneratorCounterUID;
uint32 _UID;
std::string _FontFileName;
std::vector<std::string> _FontFileNames;
#ifndef NL_DONT_USE_EXTERNAL_CODE
const char *getFT2Error(FT_Error fte);
@ -95,7 +96,7 @@ private:
static FT_Library _Library;
static uint _LibraryInit;
FT_Face _Face;
std::vector<FT_Face> _Faces;
#else // NL_DONT_USE_EXTERNAL_CODE
#endif // NL_DONT_USE_EXTERNAL_CODE

@ -631,7 +631,7 @@ inline bool CFormElm::convertValue (bool &result, const std::string &value) cons
}
else
{
std::string temp = NLMISC::toLower(value);
std::string temp = NLMISC::toLowerAscii(value);
if (strcmp (temp.c_str (), "true") == 0)
{
result = true;

@ -87,7 +87,9 @@ namespace NLGUI
/// Get the ContextHelp for this control. Default is to return _ContextHelp
virtual void getContextHelp(std::string &help) const {help= _ContextHelp;}
virtual void getContextHelpAsUtf16(ucstring &help) const {help.fromUtf8(_ContextHelp);}
#ifdef RYZOM_LUA_UCSTRING
virtual void getContextHelpAsUtf16(ucstring &help) const {help.fromUtf8(_ContextHelp);} // Compatibility
#endif
/// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp.
virtual void getContextHelpToolTip(std::string &help) const { getContextHelp(help); }
// Get the name of the context help window. Default to "context_help"
@ -127,8 +129,10 @@ namespace NLGUI
/// replace the default contextHelp
std::string getDefaultContextHelp() const {return _ContextHelp;}
void setDefaultContextHelp(const std::string &help) {_ContextHelp= help;}
ucstring getDefaultContextHelpAsUtf16() const {return ucstring::makeFromUtf8(_ContextHelp);}
void setDefaultContextHelpAsUtf16(const ucstring &help) {_ContextHelp= help.toUtf8();}
#ifdef RYZOM_LUA_UCSTRING
ucstring getDefaultContextHelpAsUtf16() const {return ucstring::makeFromUtf8(_ContextHelp);} // Compatibility
void setDefaultContextHelpAsUtf16(const ucstring &help) {_ContextHelp= help.toUtf8();} // Compatibility
#endif
void setOnContextHelp(const std::string &help) {_OnContextHelp= help;}
void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;}
@ -158,12 +162,18 @@ namespace NLGUI
// called when keyboard capture has been lost
virtual void onKeyboardCaptureLost() {}
#ifdef RYZOM_LUA_UCSTRING
// 'tooltip' property expects string to be ucstring or latin1 which is not possible from html page
int luaSetTooltipUtf8(CLuaState &ls);
int luaSetTooltipUtf8(CLuaState &ls); // Compatibility
#endif
REFLECT_EXPORT_START(CCtrlBase, CViewBase)
REFLECT_UCSTRING("tooltip", getDefaultContextHelpAsUtf16, setDefaultContextHelpAsUtf16); // FIXME: Lua UTF-8
REFLECT_LUA_METHOD("setTooltipUtf8", luaSetTooltipUtf8);
#ifdef RYZOM_LUA_UCSTRING
REFLECT_UCSTRING("tooltip", getDefaultContextHelpAsUtf16, setDefaultContextHelpAsUtf16); // Compatibility
REFLECT_LUA_METHOD("setTooltipUtf8", luaSetTooltipUtf8); // Compatibility
#else
REFLECT_STRING("tooltip", getDefaultContextHelp, setDefaultContextHelp);
#endif
REFLECT_EXPORT_END
// special for mouse over : return true and fill the name of the cursor to display

@ -99,8 +99,12 @@ namespace NLGUI
// Set text (noop if text id)
void setText (const std::string &text);
std::string getText () const;
void setTextAsUtf16 (const ucstring &text);
ucstring getTextAsUtf16 () const;
#ifdef RYZOM_LUA_UCSTRING
void setTextAsUtf16 (const ucstring &text); // Compatibility
ucstring getTextAsUtf16 () const; // Compatibility
#endif
void setLocalize (bool localize);
bool isLocalized () const;
void setHardText (const std::string &text);
std::string getHardText () const;
@ -143,8 +147,12 @@ namespace NLGUI
int luaGetViewText(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton)
REFLECT_UCSTRING("uc_hardtext", getTextAsUtf16, setTextAsUtf16);
#ifdef RYZOM_LUA_UCSTRING
REFLECT_UCSTRING("uc_hardtext", getTextAsUtf16, setTextAsUtf16); // Compatibility
#endif
REFLECT_BOOL("localize", isLocalized, setLocalize);
REFLECT_STRING("hardtext", getHardText, setHardText);
REFLECT_STRING("text", getText, setText);
REFLECT_SINT32("text_x", getTextX, setTextX)
REFLECT_SINT32("wmargin", getWMargin, setWMargin)
REFLECT_SINT32("wmin", getWMin, setWMin)

@ -64,11 +64,15 @@ namespace NLGUI
void setText(uint i, const std::string &text);
void insertText(uint i, const std::string &text);
const std::string &getText(uint i) const;
ucstring getTextAsUtf16(uint i) const;
#ifdef RYZOM_LUA_UCSTRING
ucstring getTextAsUtf16(uint i) const; // Compatibility
#endif
uint getTextId(uint i) const;
uint getTextPos(uint nId) const;
const std::string &getTexture(uint i) const;
ucstring getTextureAsUtf16(uint i) const;
#ifdef RYZOM_LUA_UCSTRING
ucstring getTextureAsUtf16(uint i) const; // Compatibility
#endif
void setGrayed(uint i, bool g);
bool getGrayed(uint i) const;
void removeText(uint nPos);
@ -91,8 +95,10 @@ namespace NLGUI
// view text
void setViewText(const std::string & text);
std::string getViewText() const;
void setViewTextAsUtf16(const ucstring &text) { setViewText(text.toUtf8()); }
ucstring getViewTextAsUtf16() const;
#ifdef RYZOM_LUA_UCSTRING
void setViewTextAsUtf16(const ucstring &text) { setViewText(text.toUtf8()); } // Compatibility
ucstring getViewTextAsUtf16() const; // Compatibility
#endif
CViewText *getViewText();
void setTexture(uint i, const std::string &texture);
@ -126,7 +132,11 @@ namespace NLGUI
REFLECT_LUA_METHOD("resetTexts", luaResetTexts)
REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb)
REFLECT_STRING ("selection_text", getSelectionText, setSelectionText)
REFLECT_UCSTRING ("view_text", getViewTextAsUtf16, setViewTextAsUtf16) // FIXME: Better to have UTF-8
#ifdef RYZOM_LUA_UCSTRING
REFLECT_UCSTRING ("view_text", getViewTextAsUtf16, setViewTextAsUtf16) // Compatibility
#else
REFLECT_STRING ("view_text", getViewText, setViewText)
#endif
REFLECT_EXPORT_END

@ -249,12 +249,14 @@ namespace NLGUI
// Get the header color draw. NB: depends if grayed, and if active.
NLMISC::CRGBA getDrawnHeaderColor () const;
ucstring getUCTitleOpened () const;
void setUCTitleOpened (const ucstring &title);
ucstring getUCTitleClosed () const;
void setUCTitleClosed (const ucstring &title);
ucstring getUCTitle () const;
void setUCTitle (const ucstring &title);
#ifdef RYZOM_LUA_UCSTRING
ucstring getUCTitleOpened () const; // Compatibility
void setUCTitleOpened (const ucstring &title); // Compatibility
ucstring getUCTitleClosed () const; // Compatibility
void setUCTitleClosed (const ucstring &title); // Compatibility
ucstring getUCTitle () const; // Compatibility
void setUCTitle (const ucstring &title); // Compatibility
#endif
void setPopable(bool popable) { _Popable = popable; }
bool isPopable() const { return _Popable; }
@ -289,9 +291,11 @@ namespace NLGUI
REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened);
REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed);
REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); // FIXME: Lua UTF-8
REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); // FIXME: Lua UTF-8
REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); // FIXME: Lua UTF-8
#ifdef RYZOM_LUA_UCSTRING
REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); // Compatibility
REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); // Compatibility
REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); // Compatibility
#endif
REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString);
REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH);

@ -74,17 +74,19 @@ namespace NLGUI
*/
void setPrompt(const std::string &s);
void setInputString(const std::string &str);
void setInputStringRef(const ::u32string &str) {_InputString = str; };
void setInputStringRef(const ::u32string &str);
void setInputStringAsInt(sint32 val);
sint32 getInputStringAsInt() const;
void setInputStringAsInt64(sint64 val);
sint64 getInputStringAsInt64() const;
void setInputStringAsFloat(float val);
float getInputStringAsFloat() const;
void setInputStringAsUtf16(const ucstring &str);
ucstring getInputStringAsUtf16() const;
void setInputStringAsUtf32(const ::u32string &str);
::u32string getInputStringAsUtf32() const { return _InputString; }
#ifdef RYZOM_LUA_UCSTRING
void setInputStringAsUtf16(const ucstring &str); // Compatibility
ucstring getInputStringAsUtf16() const; // Compatibility
void setInputStringAsUtf32(const ::u32string &str) { setInputStringRef(str); } // Compatibility
::u32string getInputStringAsUtf32() const { return _InputString; } // Compatibility
#endif
void setColor(NLMISC::CRGBA col);
@ -192,7 +194,9 @@ namespace NLGUI
REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText);
REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText);
REFLECT_STRING("input_string", getInputString, setInputString);
REFLECT_UCSTRING("uc_input_string", getInputStringAsUtf16, setInputStringAsUtf16);
#ifdef RYZOM_LUA_UCSTRING
REFLECT_UCSTRING("uc_input_string", getInputStringAsUtf16, setInputStringAsUtf16); // Compatibility
#endif
REFLECT_EXPORT_END
/** Restore the original value of the edit box.
@ -217,6 +221,7 @@ namespace NLGUI
float _BlinkTime;
sint32 _CursorPos;
uint32 _MaxNumChar;
uint32 _MaxNumBytes;
uint32 _MaxNumReturn;
uint32 _MaxFloatPrec; // used in setInputStringAsFloat() only
sint32 _MaxCharsSize;

@ -115,8 +115,10 @@ namespace NLGUI
bool getOpened() const { return Opened; }
void setText(const std::string &text) { Text = text; }
const std::string& getText() const { return Text; }
void setTextAsUtf16(const ucstring &text) { Text = text.toUtf8(); }
ucstring getTextAsUtf16() const { return ucstring::makeFromUtf8(Text); }
#ifdef RYZOM_LUA_UCSTRING
void setTextAsUtf16(const ucstring &text) { Text = text.toUtf8(); } // Compatibility
ucstring getTextAsUtf16() const { return ucstring::makeFromUtf8(Text); } // Compatibility
#endif
sint32 getFontSize() const { return FontSize; }
void setFontSize(sint32 value) { FontSize = value; }
sint32 getYDecal() const { return YDecal; }
@ -184,7 +186,11 @@ namespace NLGUI
REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose);
REFLECT_BOOL("Opened", getOpened, setOpened);
REFLECT_BOOL("Show", getShow, setShow);
REFLECT_UCSTRING("Text", getTextAsUtf16, setTextAsUtf16); // FIXME: Lua UTF-8
#ifdef RYZOM_LUA_UCSTRING
REFLECT_UCSTRING("Text", getTextAsUtf16, setTextAsUtf16); // Compatibility
#else
REFLECT_STRING_REF("Text", getText, setText);
#endif
// lua
REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren);
REFLECT_LUA_METHOD("getChild", luaGetChild);

@ -86,10 +86,12 @@ namespace NLGUI
// ucstring
#ifdef RYZOM_LUA_UCSTRING
static bool pop(CLuaState &ls, ucstring &dest);
static void push(CLuaState &ls, const ucstring &value);
static bool isUCStringOnStack(CLuaState &ls, sint index);
static bool getUCStringOnStack(CLuaState &ls, sint index, ucstring &dest);
#endif
// RGBA
@ -108,7 +110,9 @@ namespace NLGUI
static void check(CLuaState &ls, bool ok, const std::string &failReason);
static void checkArgType(CLuaState &ls, const char *funcName, uint index, int argType);
static void checkArgTypeRGBA(CLuaState &ls, const char *funcName, uint index);
#ifdef RYZOM_LUA_UCSTRING
static void checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index);
#endif
/** throw a lua expection (inside a C function called from lua) with the given reason, and the current call stack
* The various check... function call this function when their test fails
*/
@ -154,10 +158,12 @@ namespace NLGUI
static uint32 getLocalTime();
static double getPreciseLocalTime();
static std::string findReplaceAll(const std::string &str, const std::string &search, const std::string &replace);
#ifdef RYZOM_LUA_UCSTRING
static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace);
static ucstring findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace);
static ucstring findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace);
static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace);
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -183,8 +189,10 @@ namespace NLGUI
static int runExpr(CLuaState &ls); // params: "expr". return: any of: nil,bool,string,number, RGBA, UCString
static int runFct(CLuaState &ls); // params: "expr", param1, param2.... return: any of: nil,bool,string,number, RGBA, UCString
static int runCommand(CLuaState &ls); // params: "command name", param1, param2 ... return true or false
#ifdef RYZOM_LUA_UCSTRING
static int isUCString(CLuaState &ls);
static int concatUCString(CLuaState &ls); // workaround for + operator that don't work in luabind for ucstrings ...
#endif
static int concatString(CLuaState &ls); // speedup concatenation of several strings
static int tableToString(CLuaState &ls); // concat element of a table to build a string
static int getPathContent(CLuaState &ls);

@ -298,6 +298,7 @@ namespace NLGUI
props.push_back(prop); \
}
#ifdef RYZOM_LUA_UCSTRING
// export a unicode string value, by giving the name of the get and the set method
#define REFLECT_UCSTRING(exportName, getMethod, setMethod) \
{ \
@ -308,6 +309,7 @@ namespace NLGUI
prop.SetMethod.SetUCString = (CReflectedProperty::TSetUCString) static_cast<TSetUCStringa>(&A::setMethod); \
props.push_back(prop); \
}
#endif
// export a string value, by giving the name of the get and the set method
#define REFLECT_STRING_REF(exportName, getMethod, setMethod) \
@ -320,6 +322,7 @@ namespace NLGUI
props.push_back(prop); \
}
#ifdef RYZOM_LUA_UCSTRING
// export a unicode string value, by giving the name of the get and the set method
#define REFLECT_UCSTRING_REF(exportName, getMethod, setMethod) \
{ \
@ -330,7 +333,7 @@ namespace NLGUI
prop.SetMethod.SetUCString = (CReflectedProperty::TSetUCString) static_cast<TSetUCStringa>(&A::setMethod); \
props.push_back(prop); \
}
#endif
// export a color value, by giving the name of the get and the set method
#define REFLECT_RGBA(exportName, getMethod, setMethod) \

@ -86,7 +86,9 @@ namespace NLGUI
void setText(const std::string &text);
void setTextLocalized(const std::string &text, bool localized);
void setTextAsUtf16 (const ucstring &text);
#ifdef RYZOM_LUA_UCSTRING
void setTextAsUtf16 (const ucstring &text); // Compatibility
#endif
void setLocalized(bool localized);
void setFontName (const std::string &name);
void setFontSize (sint nFontSize, bool coef = true);
@ -99,7 +101,9 @@ namespace NLGUI
void setShadowOffset (sint x, sint y);
void setLineMaxW (sint nMaxW, bool invalidate=true);
void setOverflowText(const std::string &text) { _OverflowText = text; }
void setOverflowTextAsUtf16(const ucstring &text) { _OverflowText = text.toUtf8(); }
#ifdef RYZOM_LUA_UCSTRING
void setOverflowTextAsUtf16(const ucstring &text) { _OverflowText = text.toUtf8(); } // Compatibility
#endif
void setMultiLine (bool bMultiLine);
void setMultiLineSpace (sint nMultiLineSpace);
void setMultiLineMaxWOnly (bool state);
@ -117,8 +121,10 @@ namespace NLGUI
/// Get
std::string getText() const { return _HardText.empty() ? _Text : _HardText; }
ucstring getTextAsUtf16() const;
ucstring getHardTextAsUtf16() const;
#ifdef RYZOM_LUA_UCSTRING
ucstring getTextAsUtf16() const; // Compatibility
ucstring getHardTextAsUtf16() const; // Compatibility
#endif
bool isLocalized() const { return _Localized; }
sint getFontSize() const;
std::string getFontName() const { return _FontName; }
@ -130,7 +136,9 @@ namespace NLGUI
NLMISC::CRGBA getShadowColor() { return _ShadowColor; }
void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; }
sint getLineMaxW() const { return _LineMaxW; }
ucstring getOverflowTextAsUtf16() const { return _OverflowText; }
#ifdef RYZOM_LUA_UCSTRING
ucstring getOverflowTextAsUtf16() const { return _OverflowText; } // Compatibility
#endif
bool getMultiLine() const { return _MultiLine; }
sint getMultiLineSpace() const { return _MultiLineSpace; }
bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; }
@ -182,7 +190,9 @@ namespace NLGUI
std::string getHardText() const { return _HardText.empty() ? _Text : _HardText; }
void setHardText (const std::string &ht); //< Localizes strings starting with "ui"
void setHardTextAsUtf16(const ucstring &ht);
#ifdef RYZOM_LUA_UCSTRING
void setHardTextAsUtf16(const ucstring &ht); // Compatibility
#endif
std::string getColorAsString() const;
void setColorAsString(const std::string &ht);
@ -196,10 +206,14 @@ namespace NLGUI
/** Setup a Text with Format Tags. Text is store without color/format tags, and special array is allocated for Format association
*/
void setTextFormatTaged(const std::string &text);
void setTextFormatTagedAsUtf16(const ucstring &text);
#ifdef RYZOM_LUA_UCSTRING
void setTextFormatTagedAsUtf16(const ucstring &text); // Compatibility
#endif
void setSingleLineTextFormatTaged(const std::string &text);
void setSingleLineTextFormatTagedAsUtf16(const ucstring &text);
#ifdef RYZOM_LUA_UCSTRING
void setSingleLineTextFormatTagedAsUtf16(const ucstring &text); // Compatibility
#endif
// Remove end space
void removeEndSpaces();
@ -225,13 +239,17 @@ namespace NLGUI
int luaSetLineMaxW(CLuaState &ls);
REFLECT_EXPORT_START(CViewText, CViewBase)
REFLECT_STRING("text_raw", getText, setText);
REFLECT_STRING("hardtext", getHardText, setHardText);
REFLECT_BOOL ("localize", isLocalized, setLocalized);
REFLECT_BOOL("localize", isLocalized, setLocalized);
REFLECT_STRING("hardtext", getHardText, setHardText); // Same as text, but localize is implicitly set true
REFLECT_STRING("text", getText, setText);
REFLECT_STRING("text_format", getText, setTextFormatTaged);
REFLECT_STRING("text_single_line_format", getText, setSingleLineTextFormatTaged);
#ifdef RYZOM_LUA_UCSTRING
// REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions
REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16);
REFLECT_UCSTRING("uc_hardtext_format", getTextAsUtf16, setTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense
REFLECT_UCSTRING("uc_hardtext_single_line_format", getTextAsUtf16, setSingleLineTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense
REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16); // Compatibility
REFLECT_UCSTRING("uc_hardtext_format", getTextAsUtf16, setTextFormatTagedAsUtf16); // Compatibility
REFLECT_UCSTRING("uc_hardtext_single_line_format", getTextAsUtf16, setSingleLineTextFormatTagedAsUtf16); // Compatibility
#endif
REFLECT_STRING ("color", getColorAsString, setColorAsString);
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
@ -452,7 +470,7 @@ namespace NLGUI
void setStringSelectionSkipingSpace(uint stringId, const std::string &text, sint charStart, sint charEnd);
// void pushString(const ucstring &str, bool deleteSpaceAtStart = false);
// void pushString(const ucstring &str, bool deleteSpaceAtStart = false); // OLD
/// \from CInterfaceElement
void onInvalidateContent();

@ -39,7 +39,7 @@ namespace NLGUI
public:
virtual ~IOnReceiveTextId() {}
// the deriver may change the input text
virtual void onReceiveTextId(ucstring &str) =0;
virtual void onReceiveTextId(std::string &str) =0;
};
// ***************************************************************************
@ -145,7 +145,7 @@ namespace NLGUI
// If true, setTextFormatted() is used instead of setText()
bool _IsTextFormatTaged;
// Optional ucstring modifier
// Optional utf-8 string modifier
IOnReceiveTextId *_StringModifier;
std::string _DBPath;
static IViewTextProvider* getTextProvider(){ return textProvider; }

@ -255,6 +255,29 @@ int compareCaseInsensitive(const char *a, const char *b);
int compareCaseInsensitive(const char *a, size_t lenA, const char *b, size_t lenB);
inline int compareCaseInsensitive(const std::string &a, const std::string &b) { return compareCaseInsensitive(&a[0], a.size(), &b[0], b.size()); }
/** ASCII to lowercase. Useful for internal identifiers.
* Characters outside of the 7-bit ASCII space, and control characters, are replaced.
*/
std::string toLowerAscii(const std::string &str, char replacement);
void toLowerAscii(char *str, char replacement);
/** ASCII to uppercase. Useful for internal identifiers.
* Characters outside of the 7-bit ASCII space, and control characters, are replaced.
*/
std::string toUpperAscii(const std::string &str, char replacement);
void toUpperAscii(char *str, char replacement);
/** ASCII to lowercase. Useful for internal identifiers.
* Characters outside of the 7-bit ASCII space are not affected.
*/
std::string toLowerAscii(const std::string &str);
void toLowerAscii(char *str);
/** ASCII to uppercase. Useful for internal identifiers.
* Characters outside of the 7-bit ASCII space are not affected.
*/
std::string toUpperAscii(const std::string &str);
void toUpperAscii(char *str);
/**
* Convert to an hexadecimal std::string

@ -20,6 +20,8 @@
#ifndef NL_UCSTRING_H
#define NL_UCSTRING_H
#define RYZOM_LUA_UCSTRING
#include "types_nl.h"
#include "debug.h"

@ -23,6 +23,8 @@
namespace NLMISC {
class IStream;
/// String view for UTF-8 and UTF-32 iteration as 32-bit codepoints.
/// This string view keeps the string as a reference, it does not make a copy.
/// Only use this for iterating a string's codepoints.
@ -141,6 +143,13 @@ public:
static void append(std::string &str, u32char c);
/// Encode or decode a single UTF-8 character in a stream (also useful for packing unsigned 20-bit integers)
static void append(IStream &s, u32char c);
static u32char get(IStream &s);
/// Get an UTF-8 string from an undefined ASCII-based codepage, without attempting to convert non-7-bit characters
static std::string fromAscii(const std::string &str);
private:
typedef u32char (*TIterator)(const void **addr);
static u32char utf8Iterator(const void **addr);

@ -36,7 +36,7 @@ namespace NLMISC {
class CWinEventEmitter : public IEventEmitter
{
public:
CWinEventEmitter () : _MouseEventsEnabled(true), _KeyboardEventsEnabled(true), _IMEEventsEnabled(true)
CWinEventEmitter () : _Utf16Pair(0), _MouseEventsEnabled(true), _KeyboardEventsEnabled(true), _IMEEventsEnabled(true)
{
_HWnd=NULL;
resetButtonFlagState ();
@ -106,6 +106,7 @@ public:
private:
CWinEventServer _InternalServer;
HWND _HWnd;
wchar_t _Utf16Pair;
public:
// private: may need to be in sync with direct input flags however...
bool _CtrlButton;

@ -289,7 +289,7 @@ void CAnimationSet::preloadSSSShapes(IDriver &drv, CShapeBank &shapeBank)
std::set<std::string>::iterator it;
for(it=_SSSShapes.begin();it!=_SSSShapes.end();it++)
{
string fileName= toLower(*it);
string fileName= toLowerAscii(*it);
// link the shape to the shapeCache
shapeBank.linkShapeToShapeCache(fileName, shapeCacheName);

@ -151,7 +151,7 @@ uint CAsyncTextureManager::addTextureRef(const string &textNameNotLwr, CMeshBa
uint ret;
// lower case name
string textName = toLower(textNameNotLwr);
string textName = toLowerAscii(textNameNotLwr);
// find the texture in map
ItTextureEntryMap it;

@ -117,7 +117,7 @@ bool CCoarseMeshBuild::buildBitmap (const std::vector<CCoarseMeshDesc>& coarseMe
if (texture->supportSharing())
{
// Get sharing name
name+=toLower(texture->getShareName());
name+=toLowerAscii(texture->getShareName());
}
else
{
@ -477,7 +477,7 @@ void CCoarseMeshBuild::remapCoordinates (const std::vector<CCoarseMeshDesc>& coa
if (texture->supportSharing())
{
// Get sharing name
name+=toLower(texture->getShareName());
name+=toLowerAscii(texture->getShareName());
}
else
{

@ -291,7 +291,7 @@ bool IDriver::invalidateShareTexture (ITexture &texture)
void IDriver::getTextureShareName (const ITexture& tex, string &output)
{
// Create the shared Name.
output= toLower(tex.getShareName());
output= toLowerAscii(tex.getShareName());
// append format Id of the texture.
static char fmt[256];
@ -372,7 +372,7 @@ void IDriver::profileTextureUsage(std::vector<std::string> &result)
// get the shareName
string shareName;
if(text->supportSharing())
shareName= toLower(text->getShareName());
shareName= toLowerAscii(text->getShareName());
else
shareName= "Not Shared";

@ -2583,7 +2583,7 @@ void CDriverGL::retrieveATIDriverVersion()
result = RegQueryValueExA(subKey, "DriverDesc", NULL, &valueType, (unsigned char *) driverDesc, &driverDescBufSize);
if (result == ERROR_SUCCESS && valueType == REG_SZ)
{
toLower(driverDesc);
toLowerAscii(driverDesc);
if (strstr(driverDesc, "radeon")) // is it a radeon card ?
{
char driverVersion[256];

@ -26,6 +26,7 @@
#include "nel/misc/common.h"
#include "nel/misc/path.h"
#include "nel/misc/file.h"
#include "nel/misc/i18n.h"
#include "nel/3d/font_generator.h"
@ -190,6 +191,20 @@ CFontGenerator::CFontGenerator (const std::string &fontFileName, const std::stri
_FontGeneratorCounterUID++;
_FontFileName = fontFileName;
if (NLMISC::startsWith(fontFileName, "ui"))
{
std::string nameList = CI18N::get(fontFileName);
NLMISC::explode(nameList, string("\n"), _FontFileNames, true);
for (std::vector<std::string>::iterator it(_FontFileNames.begin()), end(_FontFileNames.end()); it != end; ++it)
{
*it = CPath::lookup(*it);
}
}
else
{
_FontFileNames.push_back(fontFileName);
}
FT_Error error;
if (!_LibraryInit)
@ -202,49 +217,66 @@ CFontGenerator::CFontGenerator (const std::string &fontFileName, const std::stri
}
++_LibraryInit;
FT_Open_Args args;
if (!createFreetypeStream(fontFileName, args))
for (std::vector<std::string>::iterator it(_FontFileNames.begin()), end(_FontFileNames.end()); it != end; ++it)
{
nlerror ("createFreetypeStream failed with file '%s'", fontFileName.c_str());
}
FT_Open_Args args;
const std::string &fileName = *it;
error = FT_Open_Face(_Library, &args, 0, &_Face);
if (error)
{
nlerror ("FT_New_Face() failed with file '%s': %s", fontFileName.c_str(), getFT2Error(error));
}
if (!createFreetypeStream(fileName, args))
{
nlerror("createFreetypeStream failed with file '%s'", fileName.c_str());
}
string fontEx = fontExFileName;
if (fontEx.empty())
{
// try to see if the ex filename exists based on the fontExFileName
fontEx = CPath::lookup(CFile::getFilenameWithoutExtension (fontFileName)+".afm", false, false);
}
FT_Face face;
error = FT_Open_Face(_Library, &args, 0, &face);
if (error)
{
nlerror("FT_New_Face() failed with file '%s': %s", fileName.c_str(), getFT2Error(error));
}
if (!fontEx.empty())
{
if (!createFreetypeStream(fontEx, args))
string fontEx = fontExFileName;
if (fontEx.empty())
{
// try to see if the ex filename exists based on the fontExFileName
fontEx = CPath::lookup(CFile::getFilenameWithoutExtension(fileName) + ".afm", false, false);
}
if (!fontEx.empty())
{
nlerror ("createFreetypeStream failed with file '%s'", fontFileName.c_str());
if (!createFreetypeStream(fontEx, args))
{
nlerror("createFreetypeStream failed with file '%s'", fileName.c_str());
FT_Done_Face(face);
continue;
}
error = FT_Attach_Stream(face, &args);
if (error)
{
nlwarning("FT_Attach_File() failed with file '%s': %s", fontEx.c_str(), getFT2Error(error));
FT_Done_Face(face);
continue;
}
}
error = FT_Attach_Stream(_Face, &args);
error = FT_Select_Charmap(face, ft_encoding_unicode);
if (error)
{
nlwarning ("FT_Attach_File() failed with file '%s': %s", fontEx.c_str(), getFT2Error(error));
nlerror("FT_Select_Charmap() failed with file '%s': %s", fileName.c_str(), getFT2Error(error));
FT_Done_Face(face);
continue;
}
}
error = FT_Select_Charmap (_Face, ft_encoding_unicode);
if (error)
{
nlerror ("FT_Select_Charmap() failed with file '%s': %s", fontFileName.c_str(), getFT2Error(error));
_Faces.push_back(face);
}
}
CFontGenerator::~CFontGenerator ()
{
for (std::vector<FT_Face>::iterator it(_Faces.begin()), end(_Faces.end()); it != end; ++it)
FT_Done_Face(*it);
_Faces.clear();
// important: destroying and creating your last font generator
// will also reload the freetype library
nlassert(_LibraryInit);
@ -259,30 +291,41 @@ CFontGenerator::~CFontGenerator ()
void CFontGenerator::getSizes (u32char c, uint32 size, uint32 &width, uint32 &height)
{
FT_Error error;
FT_Face face;
FT_UInt glyph_index = 0;
error = FT_Set_Pixel_Sizes (_Face, size, size);
if (error)
if (!_Faces.size())
{
nlerror ("FT_Set_Pixel_Sizes() failed: %s", getFT2Error(error));
nlerror("No faces loaded");
return;
}
// retrieve glyph index from character code
FT_UInt glyph_index = FT_Get_Char_Index (_Face, c);
if (glyph_index == 0)
for (std::vector<FT_Face>::iterator it(_Faces.begin()), end(_Faces.end()); it != end; ++it)
{
// no glyph available, replace with a dot
glyph_index = FT_Get_Char_Index (_Face, u32char('.'));
face = *it;
error = FT_Set_Pixel_Sizes(face, size, size);
if (error)
{
nlerror("FT_Set_Pixel_Sizes() failed: %s", getFT2Error(error));
continue;
}
// retrieve glyph index from character code
glyph_index = FT_Get_Char_Index(face, c);
// found glyph
if (glyph_index)
break;
}
// load glyph image into the slot (erase previous one)
error = FT_Load_Glyph (_Face, glyph_index, FT_LOAD_DEFAULT);
error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
if (error)
{
// use fallback for glyph/character errors (composite char limit for example)
nlwarning ("FT_Load_Glyph() failed: %s", getFT2Error(error));
error = FT_Load_Glyph (_Face, 0, FT_LOAD_DEFAULT);
error = FT_Load_Glyph(face, 0, FT_LOAD_DEFAULT);
if (error)
{
nlerror("FT_Load_Glyph() fallback failed: %s", getFT2Error(error));
@ -290,39 +333,48 @@ void CFontGenerator::getSizes (u32char c, uint32 size, uint32 &width, uint32 &he
}
// convert 24.6 fixed point into integer
width = _Face->glyph->metrics.width >> 6;
height = _Face->glyph->metrics.height >> 6;
width = face->glyph->metrics.width >> 6;
height = face->glyph->metrics.height >> 6;
}
uint8 *CFontGenerator::getBitmap (u32char c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex)
{
FT_Error error;
FT_Face face;
FT_UInt glyph_index = 0;
error = FT_Set_Pixel_Sizes (_Face, size, size);
if (error)
if (!_Faces.size())
{
nlerror ("FT_Set_Pixel_Sizes() failed: %s", getFT2Error(error));
nlerror("No faces loaded");
return NULL;
}
// retrieve glyph index from character code
FT_UInt glyph_index = FT_Get_Char_Index (_Face, c);
/*
if (glyph_index == 0)
for (std::vector<FT_Face>::iterator it(_Faces.begin()), end(_Faces.end()); it != end; ++it)
{
// no glyph available, replace with a dot
glyph_index = FT_Get_Char_Index (_Face, u32char('.'));
face = *it;
error = FT_Set_Pixel_Sizes(face, size, size);
if (error)
{
nlerror("FT_Set_Pixel_Sizes() failed: %s", getFT2Error(error));
continue;
}
// retrieve glyph index from character code
glyph_index = FT_Get_Char_Index(face, c);
// found glyph
if (glyph_index)
break;
}
*/
// load glyph image into the slot (erase previous one)
error = FT_Load_Glyph (_Face, glyph_index, FT_LOAD_DEFAULT);
error = FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT);
if (error)
{
// use fallback for glyph/character errors (composite char limit for example)
nlwarning ("FT_Load_Glyph() failed: %s", getFT2Error(error));
error = FT_Load_Glyph (_Face, 0, FT_LOAD_DEFAULT);
error = FT_Load_Glyph (face, 0, FT_LOAD_DEFAULT);
if (error)
{
nlerror("FT_Load_Glyph() fallback failed: %s", getFT2Error(error));
@ -343,47 +395,49 @@ uint8 *CFontGenerator::getBitmap (u32char c, uint32 size, bool embolden, bool ob
if (embolden)
{
FT_GlyphSlot_Embolden(_Face->glyph);
FT_GlyphSlot_Embolden(face->glyph);
}
if (oblique)
{
FT_GlyphSlot_Oblique(_Face->glyph);
FT_GlyphSlot_Oblique(face->glyph);
}
// convert to an anti-aliased bitmap
error = FT_Render_Glyph (_Face->glyph, ft_render_mode_normal);
error = FT_Render_Glyph (face->glyph, ft_render_mode_normal);
if (error)
{
nlerror ("FT_Render_Glyph() failed: %s", getFT2Error(error));
}
width = _Face->glyph->bitmap.width;
height = _Face->glyph->bitmap.rows;
pitch = _Face->glyph->bitmap.pitch;
width = face->glyph->bitmap.width;
height = face->glyph->bitmap.rows;
pitch = face->glyph->bitmap.pitch;
left = _Face->glyph->bitmap_left;
top = _Face->glyph->bitmap_top;
left = face->glyph->bitmap_left;
top = face->glyph->bitmap_top;
advx = _Face->glyph->advance.x >> 6;
advx = face->glyph->advance.x >> 6;
glyphIndex = glyph_index;
return (uint8 *) _Face->glyph->bitmap.buffer;
return (uint8 *) face->glyph->bitmap.buffer;
}
void CFontGenerator::getKerning (u32char left, u32char right, sint32 &kernx)
{
if (!FT_HAS_KERNING(_Face))
if (!FT_HAS_KERNING(_Faces[0]))
{
kernx = 0;
}
else
{
// This is currently not used...
FT_Vector kerning;
FT_Error error = FT_Get_Kerning (_Face, left, right, ft_kerning_default, &kerning);
FT_Error error = FT_Get_Kerning (_Faces[0], left, right, ft_kerning_default, &kerning);
if (error)
{
nlerror ("FT_Get_Kerning() failed: %s", getFT2Error(error));
@ -396,12 +450,14 @@ void CFontGenerator::getKerning (u32char left, u32char right, sint32 &kernx)
uint32 CFontGenerator::getCharIndex (u32char c)
{
uint32 ret = FT_Get_Char_Index(_Face, c);
// This is currently not used...
uint32 ret = FT_Get_Char_Index(_Faces[0], c);
if (ret == 0)
{
// no glyph available, replace with a dot
ret = FT_Get_Char_Index (_Face, u32char('.'));
ret = FT_Get_Char_Index (_Faces[0], u32char('.'));
}
return ret;

@ -59,7 +59,7 @@ uint32 CHLSTextureBank::addColorTexture(const CHLSColorTexture &tex)
// ***************************************************************************
void CHLSTextureBank::addTextureInstance(const std::string &name, uint32 colorTextureId, const vector<CHLSColorDelta> &cols)
{
string nameLwr= toLower(name);
string nameLwr= toLowerAscii(name);
// checks
nlassert(colorTextureId<_ColorTextures.size());

@ -76,7 +76,7 @@ sint CHLSTextureManager::findTexture(const std::string &name) const
return -1;
// Build a valid key.
string nameLwr= toLower(name);
string nameLwr= toLowerAscii(name);
CHLSTextureBank::CTextureInstance textKey;
CHLSTextureBank::CTextureInstanceHandle textKeyHandle;
textKey.buildAsKey(nameLwr.c_str());

@ -415,7 +415,7 @@ void CInstanceLighter::light (const CInstanceGroup &igIn, CInstanceGroup &igOut,
string name= _Instances[i].Name;
bool shapeFound= true;
if (toLower (CFile::getExtension (name)) == "pacs_prim")
if (toLowerAscii (CFile::getExtension (name)) == "pacs_prim")
{
nlwarning("EXPORT BUG: Can't read %s (not a shape), should not be part of .ig!", name.c_str());
continue;

@ -115,7 +115,7 @@ void CLandscapeIGManager::initIG(UScene *scene, const std::string &igDesc, UDriv
if (ig)
{
// add it to the map.
string tokId= toUpper(string(token));
string tokId= toUpperAscii(string(token));
_ZoneInstanceGroupMap[tokId]= CInstanceGroupElement(ig, token);
// Add a reference on the shapes
@ -129,7 +129,7 @@ void CLandscapeIGManager::initIG(UScene *scene, const std::string &igDesc, UDriv
_ig.getShapeName(i, shapeName);
if (!shapeName.empty ())
{
if (toLower(CFile::getExtension(shapeName)) != "pacs_prim")
if (toLowerAscii(CFile::getExtension(shapeName)) != "pacs_prim")
{
// Insert a new shape ?
if (_ShapeAdded.find(shapeName) == _ShapeAdded.end())
@ -295,7 +295,7 @@ UInstanceGroup *CLandscapeIGManager::getIG(const std::string &name) const
std::string CLandscapeIGManager::translateName(const std::string &name) const
{
std::string ret;
ret= toUpper(name + ".ig");
ret= toUpperAscii(name + ".ig");
return ret;
}
@ -364,7 +364,7 @@ void CLandscapeIGManager::reloadAllIgs()
const char *token= bkupIgFileNameList[i].c_str();
UInstanceGroup *ig = UInstanceGroup::createInstanceGroup(token);
// add it to the map.
string tokId= toUpper(token);
string tokId= toUpperAscii(token);
_ZoneInstanceGroupMap[tokId]= CInstanceGroupElement(ig, token);
// If was addedToScene before, re-add to scene now.

@ -665,7 +665,7 @@ void CPackedZone32::build(std::vector<const CTessFace*> &leaves,
{
CMatrix instanceMatrix;
igs[k]->getInstanceMatrix(l, instanceMatrix);
if (NLMISC::toLower(NLMISC::CFile::getExtension(igs[k]->getShapeName(l))) == "pacs_prim") continue;
if (NLMISC::toLowerAscii(NLMISC::CFile::getExtension(igs[k]->getShapeName(l))) == "pacs_prim") continue;
std::string stdShapeName = standardizeShapeName(igs[k]->getShapeName(l));
TShapeCache::const_iterator it = shapeCache.find(stdShapeName);
if (it != shapeCache.end())

@ -793,7 +793,7 @@ CTransformShape *CScene::createInstance(const string &shapeName)
if (pMB->getAutoAnim())
{
std::string animName = toLower(CFile::getFilenameWithoutExtension(shapeName));
std::string animName = toLowerAscii(CFile::getFilenameWithoutExtension(shapeName));
uint animID = _AutomaticAnimationSet->getAnimationIdByName(animName);
if (animID != CAnimationSet::NotFound)
{
@ -833,7 +833,7 @@ void CScene::createInstanceAsync(const string &shapeName, CTransformShape **pIns
if (_ShapeBank->getPresentState( shapeName ) != CShapeBank::Present)
{
// Load it from file asynchronously
_ShapeBank->loadAsync( toLower(shapeName), getDriver(), position, NULL, selectedTexture);
_ShapeBank->loadAsync( toLowerAscii(shapeName), getDriver(), position, NULL, selectedTexture);
}
}

@ -607,7 +607,7 @@ void CInstanceGroup::getShapeName (uint instanceIndex, std::string &shapeName) c
shapeName = _TransformName->transformName (instanceIndex, rInstanceInfo.InstanceName, rInstanceInfo.Name);
}
toLower(shapeName);
toLowerAscii(shapeName);
if (!shapeName.empty() && shapeName.find('.') == std::string::npos)
shapeName += ".shape";
}
@ -860,7 +860,7 @@ bool CInstanceGroup::addToSceneAsync (CScene& scene, IDriver *driver, uint selec
shapeName = _TransformName->transformName (i, rInstanceInfo.InstanceName, rInstanceInfo.Name);
}
toLower(shapeName);
toLowerAscii(shapeName);
if (!shapeName.empty() && shapeName.find('.') == std::string::npos)
shapeName += ".shape";
@ -920,7 +920,7 @@ void CInstanceGroup::stopAddToSceneAsync ()
shapeName = rInstanceInfo.Name;
}
toLower(shapeName);
toLowerAscii(shapeName);
_AddToSceneTempScene->getShapeBank()->cancelLoadAsync (shapeName);
}
}

@ -56,7 +56,7 @@ CShapeBank::~CShapeBank()
IShape*CShapeBank::addRef(const string &shapeNameNotLwr)
{
string shapeName= toLower(shapeNameNotLwr);
string shapeName= toLowerAscii(shapeNameNotLwr);
// get the shape info (must succeed)
TShapeInfoMap::iterator scfpmIt = ShapePtrToShapeInfo.find( getShapePtrFromShapeName( shapeName ) );
@ -434,7 +434,7 @@ bool CShapeBank::processWSUploadTexture (CWaitingShape &rWS, uint32 &nTotalUploa
CShapeBank::TShapeState CShapeBank::getPresentState (const string &shapeNameNotLwr)
{
string shapeName= toLower(shapeNameNotLwr);
string shapeName= toLowerAscii(shapeNameNotLwr);
// Is the shape is found in the shape map so return Present
TShapeMap::iterator smIt = ShapeMap.find (shapeName);
@ -450,7 +450,7 @@ CShapeBank::TShapeState CShapeBank::getPresentState (const string &shapeNameNotL
// ***************************************************************************
IShape *CShapeBank::getShape (const std::string &shapeNameNotLwr)
{
string shapeName= toLower(shapeNameNotLwr);
string shapeName= toLowerAscii(shapeNameNotLwr);
// Is the shape is found in the shape map so return Present
TShapeMap::iterator smIt = ShapeMap.find (shapeName);
@ -464,7 +464,7 @@ IShape *CShapeBank::getShape (const std::string &shapeNameNotLwr)
void CShapeBank::load (const string &shapeNameNotLwr)
{
string shapeName= toLower(shapeNameNotLwr);
string shapeName= toLowerAscii(shapeNameNotLwr);
TShapeMap::iterator smIt = ShapeMap.find(shapeName);
if( smIt == ShapeMap.end() )
@ -498,7 +498,7 @@ void CShapeBank::load (const string &shapeNameNotLwr)
void CShapeBank::loadAsync (const std::string &shapeNameNotLwr, IDriver *pDriver, const CVector &position, bool *bSignal, uint selectedTexture)
{
string shapeName= toLower(shapeNameNotLwr);
string shapeName= toLowerAscii(shapeNameNotLwr);
TShapeMap::iterator smIt = ShapeMap.find(shapeName);
if (smIt != ShapeMap.end())
@ -530,7 +530,7 @@ void CShapeBank::loadAsync (const std::string &shapeNameNotLwr, IDriver *pDriver
void CShapeBank::cancelLoadAsync (const std::string &shapeNameNotLwr)
{
string shapeName= toLower(shapeNameNotLwr);
string shapeName= toLowerAscii(shapeNameNotLwr);
TWaitingShapesMap::iterator wsmmIt = WaitingShapes.find(shapeName);
if (wsmmIt != WaitingShapes.end())
@ -600,7 +600,7 @@ bool CShapeBank::isShapeWaiting ()
void CShapeBank::add (const string &shapeNameNotLwr, IShape* pShp)
{
nlassert(pShp);
string shapeName= toLower(shapeNameNotLwr);
string shapeName= toLowerAscii(shapeNameNotLwr);
// request a system mem geometry copy?
if(pShp && _ShapeNeedingSystemGeometryCopy.find(shapeName)!=_ShapeNeedingSystemGeometryCopy.end())
@ -724,7 +724,7 @@ sint CShapeBank::getShapeCacheFreeSpace(const std::string &shapeCacheName) const
void CShapeBank::linkShapeToShapeCache(const string &shapeNameNotLwr, const string &shapeCacheName)
{
string shapeName= toLower(shapeNameNotLwr);
string shapeName= toLowerAscii(shapeNameNotLwr);
for(;;)
{
@ -857,7 +857,7 @@ void CShapeBank::preLoadShapes(const std::string &shapeCacheName,
return;
// lower case
string wildCard= toLower(wildCardNotLwr);
string wildCard= toLowerAscii(wildCardNotLwr);
// For all files
for(uint i=0;i<listFile.size();i++)
@ -866,7 +866,7 @@ void CShapeBank::preLoadShapes(const std::string &shapeCacheName,
if (progress)
progress->progress ((float)i/(float)listFile.size ());
string fileName= toLower(CFile::getFilename(listFile[i]));
string fileName= toLowerAscii(CFile::getFilename(listFile[i]));
// if the file is ok for the wildCard, process it
if( testWildCard(fileName.c_str(), wildCard.c_str()) )
{
@ -908,7 +908,7 @@ void CShapeBank::preLoadShapes(const std::string &shapeCacheName,
// ***************************************************************************
void CShapeBank::buildSystemGeometryForshape(const std::string &shapeName)
{
_ShapeNeedingSystemGeometryCopy.insert(toLower(shapeName));
_ShapeNeedingSystemGeometryCopy.insert(toLowerAscii(shapeName));
}

@ -229,7 +229,7 @@ void CShapeInfo::build(const CMeshBase &meshBase, const CMeshMRMGeom &meshGeom)
// ***************************************************************************
std::string standardizeShapeName(const std::string &name)
{
std::string result = NLMISC::toLower(name);
std::string result = NLMISC::toLowerAscii(name);
if (CFile::getExtension(result).empty())
{
result += ".shape";

@ -311,7 +311,7 @@ void CTextureFile::setMipMapSkipAtLoad(uint8 level)
// ***************************************************************************
std::string CTextureFile::getShareName() const
{
return toLower(_FileName);
return toLowerAscii(_FileName);
}

@ -275,7 +275,7 @@ sint CTileBank::getNumBitmap (CTile::TBitmap bitmap) const
{
std::vector<char> vect (str.length()+1);
memcpy (&*vect.begin(), str.c_str(), str.length()+1);
toLower(&*vect.begin());
toLowerAscii(&*vect.begin());
setString.insert (std::string (&*vect.begin()));
}
}
@ -600,7 +600,7 @@ void CTileBank::removeDisplacementMap (uint mapId)
uint CTileBank::getDisplacementMap (const string &fileName)
{
// Lower string
string lower=toLower(fileName);
string lower=toLowerAscii(fileName);
// Look for this texture filename
uint noiseTile;

@ -371,7 +371,7 @@ void CForm::warning (bool exception, const std::string &function, const char *fo
void CForm::getDependencies (std::set<std::string> &dependencies) const
{
// Add me
if (dependencies.insert (toLower(CFile::getFilename (_Filename))).second)
if (dependencies.insert (toLowerAscii(CFile::getFilename (_Filename))).second)
{
// Add parents
uint i;

@ -882,7 +882,7 @@ void CFormDfn::warning (bool exception, const std::string &function, const char
void CFormDfn::getDependencies (std::set<std::string> &dependencies) const
{
// Scan only if not already inserted
if (dependencies.insert (toLower(CFile::getFilename (_Filename))).second)
if (dependencies.insert (toLowerAscii(CFile::getFilename (_Filename))).second)
{
// Add parents
uint i;
@ -898,7 +898,7 @@ void CFormDfn::getDependencies (std::set<std::string> &dependencies) const
Entries[i].getDfnPtr ()->getDependencies (dependencies);
if (Entries[i].getTypePtr ())
{
dependencies.insert (toLower(CFile::getFilename (Entries[i].getFilename())));
dependencies.insert (toLowerAscii(CFile::getFilename (Entries[i].getFilename())));
}
}
}

@ -67,7 +67,7 @@ CFormLoader::~CFormLoader()
CType *CFormLoader::loadType (const std::string &filename)
{
// Lower string filename
string lowerStr = toLower(filename);
string lowerStr = toLowerAscii(filename);
lowerStr = CFile::getFilename (lowerStr);
// Already in the map ?
@ -137,7 +137,7 @@ CType *CFormLoader::loadType (const std::string &filename)
CFormDfn *CFormLoader::loadFormDfn (const std::string &filename, bool forceLoad)
{
// Lower string filename
string lowerStr = toLower(filename);
string lowerStr = toLowerAscii(filename);
lowerStr = CFile::getFilename (lowerStr);
// Already in the map ?
@ -203,7 +203,7 @@ CFormDfn *CFormLoader::loadFormDfn (const std::string &filename, bool forceLoad)
UForm *CFormLoader::loadForm (const std::string &filename)
{
// Lower string filename
string lowerStr = toLower((string)filename);
string lowerStr = toLowerAscii((string)filename);
lowerStr = CFile::getFilename (lowerStr);
// Already in the map ?

@ -73,13 +73,13 @@ namespace NLGUI
{
string allparam = Params;
skipBlankAtStart (allparam);
string param = toLower (ParamName);
string param = toLowerAscii (ParamName);
while (!allparam.empty())
{
std::string::size_type e = allparam.find('=');
if (e == std::string::npos || e == 0) break;
std::string::size_type p = allparam.find('|');
string tmp = NLMISC::toLower(allparam.substr(0,e));
string tmp = NLMISC::toLowerAscii(allparam.substr(0,e));
skipBlankAtEnd(tmp);
if (tmp == param)
{
@ -105,7 +105,7 @@ namespace NLGUI
std::string::size_type e = allparam.find('=');
if (e == std::string::npos || e == 0) break;
std::string::size_type p = allparam.find('|');
string tmp = NLMISC::toLower(allparam.substr(0,e));
string tmp = NLMISC::toLowerAscii(allparam.substr(0,e));
skipBlankAtEnd(tmp);
string tmp2 = allparam.substr(e+1,p-e-1);

@ -50,7 +50,7 @@ namespace NLGUI
pos = elements[i].find_first_of(':');
if (pos != std::string::npos)
{
std::string key = trim(toLower(elements[i].substr(0, pos)));
std::string key = trim(toLowerAscii(elements[i].substr(0, pos)));
std::string value = trim(elements[i].substr(pos+1));
styles.push_back(TStylePair(key, value));
}
@ -361,7 +361,7 @@ namespace NLGUI
while(pos < sel.size() && is_nmchar(sel[pos]))
pos++;
current.Element = toLower(sel.substr(start, pos - start));
current.Element = toLowerAscii(sel.substr(start, pos - start));
start = pos;
continue;
}
@ -374,7 +374,7 @@ namespace NLGUI
while(pos < sel.size() && is_nmchar(sel[pos]))
pos++;
current.Id = toLower(sel.substr(start, pos - start));
current.Id = toLowerAscii(sel.substr(start, pos - start));
start = pos;
}
else if (sel[pos] == '.')
@ -386,7 +386,7 @@ namespace NLGUI
while(pos < sel.size() && (is_nmchar(sel[pos]) || sel[pos] == '.'))
pos++;
current.setClass(toLower(sel.substr(start, pos - start)));
current.setClass(toLowerAscii(sel.substr(start, pos - start)));
start = pos;
}
else if (sel[pos] == '[')
@ -552,7 +552,7 @@ namespace NLGUI
}
}
std::string key = toLower(sel.substr(start, pos - start));
std::string key = toLowerAscii(sel.substr(start, pos - start));
if (key.empty())
{
failed = true;

@ -59,7 +59,7 @@ namespace NLGUI
void CCssSelector::setClass(const std::string &cls)
{
std::vector<std::string> parts;
NLMISC::splitString(toLower(cls), ".", parts);
NLMISC::splitString(toLowerAscii(cls), ".", parts);
for(uint i = 0; i< parts.size(); i++)
{
@ -80,7 +80,7 @@ namespace NLGUI
}
else
{
Attr.push_back(SAttribute(key, toLower(val), op, cs));
Attr.push_back(SAttribute(key, toLowerAscii(val), op, cs));
}
}
@ -146,7 +146,7 @@ namespace NLGUI
// case-insensitive compare, Attr.value is already lowercased
if (!Attr[i].caseSensitive)
{
value = toLower(value);
value = toLowerAscii(value);
}
switch(Attr[i].op)
@ -255,7 +255,7 @@ namespace NLGUI
if (start == std::string::npos) return;
std::string expr = toLower(pseudo.substr(start, end - start));
std::string expr = toLowerAscii(pseudo.substr(start, end - start));
if (expr.empty()) return;

@ -676,7 +676,7 @@ namespace NLGUI
else
if (it->first == "text-decoration" || it->first == "text-decoration-line")
{
std::string prop(toLower(it->second));
std::string prop(toLowerAscii(it->second));
style.Underlined = (prop.find("underline") != std::string::npos);
style.StrikeThrough = (prop.find("line-through") != std::string::npos);
}
@ -924,7 +924,7 @@ namespace NLGUI
{
// normalize
std::string image = trim(it->second);
if (toLower(image.substr(0, 4)) == "url(")
if (toLowerAscii(image.substr(0, 4)) == "url(")
{
image = image.substr(4, image.size()-5);
}
@ -934,7 +934,7 @@ namespace NLGUI
if (it->first == "background-repeat")
{
// normalize
std::string val = toLower(trim(it->second));
std::string val = toLowerAscii(trim(it->second));
std::vector<std::string> parts;
splitParams(val, ' ', parts);
// check for "repeat repeat"
@ -947,7 +947,7 @@ namespace NLGUI
if (it->first == "background-size")
{
// normalize
std::string val = toLower(trim(it->second));
std::string val = toLowerAscii(trim(it->second));
std::vector<std::string> parts;
splitParams(val, ' ', parts);
if (parts.size() == 2 && parts[0] == parts[1])
@ -999,7 +999,7 @@ namespace NLGUI
uint index = 0;
while(!failed && index < parts.size())
{
std::string val = toLower(parts[index]);
std::string val = toLowerAscii(parts[index]);
bool matches = false;
for(uint i = 0; i < nbProps; i++)
{
@ -1028,7 +1028,7 @@ namespace NLGUI
// second loop -> false && break
loop = !loop;
val = toLower(parts[next]);
val = toLowerAscii(parts[next]);
if (val == "center")
{
if (bgPositionX.empty()) bgPositionX = "center";
@ -1082,7 +1082,7 @@ namespace NLGUI
uint next = index + 1;
if (next < parts.size())
{
val = toLower(parts[next]);
val = toLowerAscii(parts[next]);
if (val == "cover" || val == "contain")
{
matches = true;
@ -1106,7 +1106,7 @@ namespace NLGUI
next++;
if (next < parts.size())
{
val = toLower(parts[next]);
val = toLowerAscii(parts[next]);
if (val == "auto")
v = "auto";
else if (getCssLength(fval, unit, val))
@ -1160,7 +1160,7 @@ namespace NLGUI
uint next = index + 1;
if (next < parts.size())
{
val = toLower(parts[next]);
val = toLowerAscii(parts[next]);
if (val == "repeat" || val == "space" || val == "round" || val == "no-repeat")
{
vert = val;
@ -1334,7 +1334,7 @@ namespace NLGUI
bool CCssStyle::tryBorderWidthShorthand(const std::string &prop, const std::string &value, TStyle &style) const
{
std::vector<std::string> parts;
splitParams(toLower(value), ' ', parts);
splitParams(toLowerAscii(value), ' ', parts);
float tmpf;
std::string unit;
@ -1371,7 +1371,7 @@ namespace NLGUI
bool CCssStyle::tryBorderStyleShorthand(const std::string &prop, const std::string &value, TStyle &style) const
{
std::vector<std::string> parts;
splitParams(toLower(value), ' ', parts);
splitParams(toLowerAscii(value), ' ', parts);
// verify that parts are valid
uint8 maxSize = (prop == "border" || prop == "border-style") ? 4 : 1;
@ -1420,7 +1420,7 @@ namespace NLGUI
bool CCssStyle::tryBorderColorShorthand(const std::string &prop, const std::string &value, TStyle &style) const
{
std::vector<std::string> parts;
splitParams(toLower(value), ' ', parts);
splitParams(toLowerAscii(value), ' ', parts);
CRGBA color;
// verify that parts are valid
@ -1465,7 +1465,7 @@ namespace NLGUI
TStyle borderStyle;
std::vector<std::string> parts;
splitParams(toLower(value), ' ', parts);
splitParams(toLowerAscii(value), ' ', parts);
for(uint index = 0; index < parts.size(); ++index)
{
@ -1530,7 +1530,7 @@ namespace NLGUI
void CCssStyle::expandPaddingShorthand(const std::string &value, TStyle &style) const
{
std::vector<std::string> parts;
splitParams(toLower(value), ' ', parts);
splitParams(toLowerAscii(value), ' ', parts);
uint8 t, r, b, l;
if (!getShorthandIndices(parts.size(), t, r, b, l))

@ -100,7 +100,7 @@ namespace NLGUI
CCtrlBase::TToolTipParentType CCtrlBase::stringToToolTipParent( const std::string &str )
{
std::string s = toLower( str );
std::string s = toLowerAscii( str );
if( s == "mouse" )
return TTMouse;
@ -573,6 +573,7 @@ namespace NLGUI
return itr2->second;
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
int CCtrlBase::luaSetTooltipUtf8(CLuaState &ls)
{
@ -585,5 +586,6 @@ namespace NLGUI
return 0;
}
#endif
}

@ -584,18 +584,18 @@ namespace NLGUI
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_l" );
if (prop)
{
_ListMenuLeft = NLMISC::toLower(std::string((const char *) prop));
_ListMenuLeft = NLMISC::toLowerAscii(std::string((const char *) prop));
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" );
if (prop)
{
_ListMenuRight = NLMISC::toLower(std::string((const char *) prop));
_ListMenuRight = NLMISC::toLowerAscii(std::string((const char *) prop));
}
// list menu on both clicks
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_b" );
if (prop)
{
setListMenuBoth(NLMISC::toLower(std::string((const char *) prop)));
setListMenuBoth(NLMISC::toLowerAscii(std::string((const char *) prop)));
}
prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen");

@ -210,21 +210,21 @@ namespace NLGUI
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" );
if (prop)
{
string TxName = NLMISC::toLower((const char *) prop);
string TxName = NLMISC::toLowerAscii((const char *) prop);
_TextureIdNormal.setTexture(TxName.c_str());
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_pushed" );
if (prop)
{
string TxName = NLMISC::toLower((const char *) prop);
string TxName = NLMISC::toLowerAscii((const char *) prop);
_TextureIdPushed.setTexture(TxName.c_str());
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_over" );
if (prop)
{
string TxName = NLMISC::toLower((const char *) prop);
string TxName = NLMISC::toLowerAscii((const char *) prop);
_TextureIdOver.setTexture(TxName.c_str());
}

@ -212,12 +212,12 @@ namespace NLGUI
CViewRenderer &rVR = *CViewRenderer::getInstance();
if(prop)
{
string sTmp = NLMISC::toLower((const char*)prop);
string sTmp = NLMISC::toLowerAscii((const char*)prop);
_Texture = rVR.createTexture (sTmp, 0, 0, 256, 64, false, false);
}
prop = (char*) xmlGetProp( node, (xmlChar*)"onchange" );
if (prop) _AHOnChange = NLMISC::toLower((const char*)prop);
if (prop) _AHOnChange = NLMISC::toLowerAscii((const char*)prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"onchange_params" );
if (prop) _AHOnChangeParams = string((const char*)prop);

@ -561,17 +561,17 @@ namespace NLGUI
// Read Action handlers
prop = (char*) xmlGetProp( node, (xmlChar*)"onscroll" );
if (prop) _AHOnScroll = NLMISC::toLower(prop.str());
if (prop) _AHOnScroll = NLMISC::toLowerAscii(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"params" );
if (prop) _AHOnScrollParams = string((const char*)prop);
//
prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollend" );
if (prop) _AHOnScrollEnd = NLMISC::toLower(prop.str());
if (prop) _AHOnScrollEnd = NLMISC::toLowerAscii(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"end_params" );
if (prop) _AHOnScrollEndParams = string((const char*)prop);
//
prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollcancel" );
if (prop) _AHOnScrollCancel = NLMISC::toLower(prop.str());
if (prop) _AHOnScrollCancel = NLMISC::toLowerAscii(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"cancel_params" );
if (prop) _AHOnScrollCancelParams = string((const char*)prop);

@ -542,7 +542,7 @@ namespace NLGUI
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" );
if (prop)
{
string TxName = toLower(std::string((const char *) prop));
string TxName = toLowerAscii(std::string((const char *) prop));
_TextureIdNormal[0].setTexture((TxName+"_l.tga").c_str());
_TextureIdNormal[1].setTexture((TxName+"_m.tga").c_str());
_TextureIdNormal[2].setTexture((TxName+"_r.tga").c_str());
@ -551,7 +551,7 @@ namespace NLGUI
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_pushed" );
if (prop)
{
string TxName = toLower(std::string((const char *) prop));
string TxName = toLowerAscii(std::string((const char *) prop));
_TextureIdPushed[0].setTexture((TxName+"_l.tga").c_str());
_TextureIdPushed[1].setTexture((TxName+"_m.tga").c_str());
_TextureIdPushed[2].setTexture((TxName+"_r.tga").c_str());
@ -560,7 +560,7 @@ namespace NLGUI
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_over" );
if (prop)
{
string TxName = toLower(std::string((const char *) prop));
string TxName = toLowerAscii(std::string((const char *) prop));
_TextureIdOver[0].setTexture((TxName+"_l.tga").c_str());
_TextureIdOver[1].setTexture((TxName+"_m.tga").c_str());
_TextureIdOver[2].setTexture((TxName+"_r.tga").c_str());
@ -1051,6 +1051,20 @@ namespace NLGUI
return std::string();
}
void CCtrlTextButton::setLocalize(bool localize)
{
if (_ViewText && !_IsViewTextId)
_ViewText->setLocalized(localize);
}
bool CCtrlTextButton::isLocalized() const
{
if (_ViewText && !_IsViewTextId)
return _ViewText->isLocalized();
return true;
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
void CCtrlTextButton::setTextAsUtf16 (const ucstring &text)
{
@ -1065,6 +1079,7 @@ namespace NLGUI
return CUtfStringView(_ViewText->getText()).toUtf16();
return ucstring("");
}
#endif
// ***************************************************************************
void CCtrlTextButton::setHardText (const std::string &text)

@ -45,7 +45,8 @@ namespace NLGUI
// Compare strings
static inline bool lt_text(const std::pair<int,std::string> &s1, const std::pair<int,std::string> &s2)
{
return toLower(s1.second) < toLower(s2.second);
// return toLower(s1.second) < toLower(s2.second);
return -NLMISC::compareCaseInsensitive(s1.second, s2.second);
}
std::string CDBGroupComboBox::measureMenu;
@ -360,11 +361,13 @@ namespace NLGUI
return empty;
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
ucstring CDBGroupComboBox::getTextAsUtf16(uint i) const
{
return ucstring::makeFromUtf8(getText(i));
}
#endif
// ***************************************************************************
uint CDBGroupComboBox::getTextId(uint i) const
@ -401,12 +404,14 @@ namespace NLGUI
else
return empty;
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
ucstring CDBGroupComboBox::getTextureAsUtf16(uint i) const
{
return ucstring::makeFromUtf8(getTexture(i));
}
#endif
// ***************************************************************************
void CDBGroupComboBox::setSelection(sint32 val)
@ -488,11 +493,13 @@ namespace NLGUI
return _ViewText->getText();
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
ucstring CDBGroupComboBox::getViewTextAsUtf16() const
{
return CUtfStringView(_ViewText->getText()).toUtf16();
}
#endif
// ***************************************************************************
CViewText *CDBGroupComboBox::getViewText()
@ -575,10 +582,16 @@ namespace NLGUI
{
const char *funcName = "addText";
CLuaIHM::checkArgCount(ls, funcName, 1);
#ifdef RYZOM_LUA_UCSTRING
CLuaIHM::checkArgTypeUCString(ls, funcName, 1);
ucstring text;
ucstring text; // Compatibility
nlverify(CLuaIHM::pop(ls, text));
addText(text.toUtf8()); // FIXME: Lua should just do UTF-8!
addText(text.toUtf8());
#else
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
string text = ls.toString(1);
addText(text);
#endif
return 0;
}
@ -588,10 +601,16 @@ namespace NLGUI
const char *funcName = "setText";
CLuaIHM::checkArgCount(ls, funcName, 2);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
#ifdef RYZOM_LUA_UCSTRING
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring text;
ucstring text; // Compatibility
nlverify(CLuaIHM::pop(ls, text));
setText((uint) ls.toInteger(1), text.toUtf8()); // FIXME: Lua should just do UTF-8!
setText((uint) ls.toInteger(1), text.toUtf8());
#else
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
string text = ls.toString(2);
setText((uint)ls.toInteger(1), text);
#endif
return 0;
}
@ -601,10 +620,16 @@ namespace NLGUI
const char *funcName = "insertText";
CLuaIHM::checkArgCount(ls, funcName, 2);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
#ifdef RYZOM_LUA_UCSTRING
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring text;
nlverify(CLuaIHM::pop(ls, text));
insertText((uint) ls.toInteger(1), text.toUtf8()); // FIXME: Lua should just do UTF-8!
#else
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
string text = ls.toString(2);
insertText((uint)ls.toInteger(1), text);
#endif
return 0;
}
@ -614,20 +639,30 @@ namespace NLGUI
const char *funcName = "setTexture";
CLuaIHM::checkArgCount(ls, funcName, 2);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
#ifdef RYZOM_LUA_UCSTRING
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring texture;
nlverify(CLuaIHM::pop(ls, texture));
setTexture((uint) ls.toInteger(1), texture.toUtf8()); // FIXME: Lua should just do UTF-8!
#else
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
string texture = ls.toString(2);
setTexture((uint)ls.toInteger(1), texture);
#endif
return 0;
}
// ***************************************************************************
int CDBGroupComboBox::luaGetText(CLuaState &ls)
{
const char *funcName = "setText";
const char *funcName = "getText";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CLuaIHM::push(ls, getText((uint) ls.toInteger(1)));
#ifdef RYZOM_LUA_UCSTRING
CLuaIHM::push(ls, getTextAsUtf16((uint) ls.toInteger(1)));
#else
ls.push(getText((uint)ls.toInteger(1)));
#endif
return 1;
}

@ -4016,6 +4016,7 @@ namespace NLGUI
}
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
void CGroupContainer::setUCTitleOpened(const ucstring &title)
{
@ -4051,6 +4052,7 @@ namespace NLGUI
{
return ucstring::makeFromUtf8(getTitleClosed());
}
#endif
// ***************************************************************************
void CGroupContainer::launch ()

@ -63,6 +63,7 @@ namespace NLGUI
_BlinkTime(0.f),
_CursorPos(0),
_MaxNumChar(std::numeric_limits<uint32>::max()),
_MaxNumBytes(0),
_MaxNumReturn(std::numeric_limits<uint32>::max()),
_MaxFloatPrec(20),
_MaxCharsSize(32768),
@ -149,6 +150,11 @@ namespace NLGUI
return toString( _MaxNumChar );
}
else
if( name == "max_num_bytes" )
{
return toString( _MaxNumBytes );
}
else
if( name == "max_num_return" )
{
return toString( _MaxNumReturn );
@ -321,6 +327,14 @@ namespace NLGUI
return;
}
else
if( name == "max_num_bytes" )
{
uint32 i;
if( fromString( value, i ) )
_MaxNumBytes = i;
return;
}
else
if( name == "max_num_return" )
{
uint32 i;
@ -474,6 +488,7 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "on_focus", BAD_CAST _AHOnFocus.c_str() );
xmlSetProp( node, BAD_CAST "on_focus_params", BAD_CAST _AHOnFocusParams.c_str() );
xmlSetProp( node, BAD_CAST "max_num_chars", BAD_CAST toString( _MaxNumChar ).c_str() );
xmlSetProp( node, BAD_CAST "max_num_bytes", BAD_CAST toString( _MaxNumBytes ).c_str() );
xmlSetProp( node, BAD_CAST "max_num_return", BAD_CAST toString( _MaxNumReturn ).c_str() );
xmlSetProp( node, BAD_CAST "max_chars_size", BAD_CAST toString( _MaxCharsSize ).c_str() );
xmlSetProp( node, BAD_CAST "enter_loose_focus", BAD_CAST toString( _LooseFocusOnEnter ).c_str() );
@ -591,6 +606,9 @@ namespace NLGUI
prop = (char*) xmlGetProp( cur, (xmlChar*)"max_num_chars" );
if (prop) fromString((const char*)prop, _MaxNumChar);
prop = (char*) xmlGetProp( cur, (xmlChar*)"max_num_bytes" );
if (prop) fromString((const char*)prop, _MaxNumBytes);
prop = (char*) xmlGetProp( cur, (xmlChar*)"max_num_return" );
if (prop) fromString((const char*)prop, _MaxNumReturn);
@ -629,7 +647,7 @@ namespace NLGUI
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" );
if (prop) _ListMenuRight = toLower((const char *) prop);
if (prop) _ListMenuRight = toLowerAscii((const char *) prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"max_historic" );
if (prop) fromString((const char*)prop, _MaxHistoric);
@ -969,6 +987,17 @@ namespace NLGUI
length = _MaxNumChar - (sint)_InputString.length();
}
::u32string toAdd = toAppend.substr(0, length);
if (_MaxNumBytes && length)
{
sint baseBytes = CUtfStringView(_InputString).toUtf8().length();
sint bytes = baseBytes + CUtfStringView(toAdd).toUtf8().length();
while (bytes > _MaxNumBytes)
{
length -= std::max((int)(bytes - _MaxNumBytes) >> 2, 1);
toAdd = toAdd.substr(0, length);
bytes = baseBytes + CUtfStringView(toAdd).toUtf8().length();
}
}
sint32 minPos;
sint32 maxPos;
if (_CurrSelection == this)
@ -1018,7 +1047,7 @@ namespace NLGUI
_CursorAtPreviousLineEnd = false;
if (_ClearOnEscape)
{
setInputStringAsUtf32(::u32string());
setInputStringRef(::u32string());
triggerOnChangeAH();
}
CWidgetManager::getInstance()->setCaptureKeyboard(NULL);
@ -1064,7 +1093,7 @@ namespace NLGUI
{
if (isKeyRETURN)
{
//ucstring copyStr= _InputString;
//u32string copyStr= _InputString;
//if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn)
if ((uint)std::count(_InputString.begin(), _InputString.end(), '\n') >= _MaxNumReturn)
break;
@ -1153,11 +1182,14 @@ namespace NLGUI
// verify max num char
if ((uint) _InputString.length() < _MaxNumChar)
{
makeTopWindow();
::u32string::iterator it = _InputString.begin() + _CursorPos;
_InputString.insert(it, c);
++ _CursorPos;
triggerOnChangeAH();
if (!_MaxNumBytes || CUtfStringView(_InputString + c).toUtf8().size() <= _MaxNumBytes)
{
makeTopWindow();
::u32string::iterator it = _InputString.begin() + _CursorPos;
_InputString.insert(it, c);
++_CursorPos;
triggerOnChangeAH();
}
}
if (isKeyRETURN)
{
@ -1182,7 +1214,7 @@ namespace NLGUI
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
if (!_CanUndo) return false;
_ModifiedInputString = _InputString;
setInputStringAsUtf32(_StartInputString);
setInputStringRef(_StartInputString);
_CanUndo = false;
_CanRedo = true;
setCursorPos((sint32)_InputString.length());
@ -1195,7 +1227,7 @@ namespace NLGUI
{
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
if (!_CanRedo) return false;
setInputStringAsUtf32(_ModifiedInputString);
setInputStringRef(_ModifiedInputString);
_CanUndo = true;
_CanRedo = false;
setCursorPos((sint32)_InputString.length());
@ -1306,7 +1338,7 @@ namespace NLGUI
default: break;
}
// update the text
setInputStringAsUtf32(_InputString);
setInputStringRef(_InputString);
// if event of type char or string, consider handle all of them
if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring )
@ -1635,9 +1667,9 @@ namespace NLGUI
// ----------------------------------------------------------------------------
void CGroupEditBox::setInputString(const std::string &str)
{
setInputStringAsUtf32(CUtfStringView(str).toUtf32());
setInputStringRef(CUtfStringView(str).toUtf32());
}
void CGroupEditBox::setInputStringAsUtf32(const ::u32string &str)
void CGroupEditBox::setInputStringRef(const ::u32string &str)
{
_InputString = str;
if (_CursorPos > (sint32) str.length())
@ -1761,6 +1793,7 @@ namespace NLGUI
return NLMISC::CUtfStringView(_InputString).toUtf8();
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
void CGroupEditBox::setInputStringAsUtf16(const ucstring &str)
{
@ -1772,6 +1805,7 @@ namespace NLGUI
{
return CUtfStringView(_InputString).toUtf16();
}
#endif
// ***************************************************************************
void CGroupEditBox::setCommand(const std::string &command, bool execute)
@ -1844,7 +1878,7 @@ namespace NLGUI
}
if (version < 1)
{
ucstring str;
ucstring str; // Compatibility
if (!f.isReading())
str = CUtfStringView(_InputString).toUtf16();
f.serial(str);
@ -1864,7 +1898,7 @@ namespace NLGUI
f.serial(_PrevNumLine);
if (f.isReading())
{
setInputStringAsUtf32(_InputString);
setInputStringRef(_InputString);
}
// serial selection
@ -1881,7 +1915,7 @@ namespace NLGUI
void CGroupEditBox::onQuit()
{
// clear the text and restore backup pos before final save
setInputStringAsUtf32(::u32string());
setInputStringRef(::u32string());
_CurrSelection = NULL;
}
@ -1889,7 +1923,7 @@ namespace NLGUI
void CGroupEditBox::onLoadConfig()
{
// config is not saved when there's an empty string, so restore that default state.
setInputStringAsUtf32(::u32string());
setInputStringRef(::u32string());
_CurrSelection = NULL;
_PrevNumLine = 1;
}
@ -1904,7 +1938,7 @@ namespace NLGUI
if (_DefaultInputString)
{
_DefaultInputString= false;
setInputStringAsUtf32(::u32string());
setInputStringRef(::u32string());
}
_CanRedo = false;
_CanUndo = false;

@ -89,7 +89,7 @@ namespace NLGUI
// Return URL with https is host is in HSTS list
static std::string upgradeInsecureUrl(const std::string &url)
{
if (toLower(url.substr(0, 7)) != "http://") {
if (toLowerAscii(url.substr(0, 7)) != "http://") {
return url;
}
@ -136,7 +136,7 @@ namespace NLGUI
if (pos == std::string::npos)
return;
std::string key = toLower(header.substr(0, pos));
std::string key = toLowerAscii(header.substr(0, pos));
if (pos != std::string::npos)
{
HeadersRecv[key] = header.substr(pos + 2);
@ -185,7 +185,7 @@ namespace NLGUI
bool hasHSTSHeader()
{
// ignore header if not secure connection
if (toLower(Url.substr(0, 8)) != "https://")
if (toLowerAscii(Url.substr(0, 8)) != "https://")
{
return false;
}
@ -552,7 +552,7 @@ namespace NLGUI
LOG_DL("curl easy handle %p created for '%s'", curl, download.url.c_str());
// https://
if (toLower(download.url.substr(0, 8)) == "https://")
if (toLowerAscii(download.url.substr(0, 8)) == "https://")
{
// if supported, use custom SSL context function to load certificates
NLWEB::CCurlCertificates::useCertificates(curl);
@ -1266,13 +1266,12 @@ namespace NLGUI
// TODO: 'content' should already be tokenized in css parser as it has all the functions for that
std::string content = trim(_Style.getStyle("content"));
if (toLower(content) == "none" || toLower(content) == "normal")
if (toLowerAscii(content) == "none" || toLowerAscii(content) == "normal")
{
_Style.popStyle();
return;
}
// TODO: use ucstring / ucchar as content is utf8 chars
std::string::size_type pos = 0;
while(pos < content.size())
{
@ -1297,7 +1296,7 @@ namespace NLGUI
// skip closing quote
pos++;
}
else if (content[pos] == 'u' && pos < content.size() - 6 && toLower(content.substr(pos, 4)) == "url(")
else if (content[pos] == 'u' && pos < content.size() - 6 && toLowerAscii(content.substr(pos, 4)) == "url(")
{
// url(/path-to/image.jpg) / "Alt!"
// url("/path to/image.jpg") / "Alt!"
@ -3440,7 +3439,7 @@ namespace NLGUI
result = url;
string tmp;
if (toLower(result).find("file:") == 0 && result.size() > 5)
if (toLowerAscii(result).find("file:") == 0 && result.size() > 5)
{
result = result.substr(5, result.size()-5);
}
@ -3461,7 +3460,7 @@ namespace NLGUI
{
// Normalize the path
if (isUrl)
//result = "file:"+toLower(CPath::standardizePath (CPath::getFullPath (CFile::getPath(result)))+CFile::getFilename(result));*/
//result = "file:"+toLowerAscii(CPath::standardizePath (CPath::getFullPath (CFile::getPath(result)))+CFile::getFilename(result));*/
result = "file:/"+tmp;
else
result = tmp;
@ -3695,7 +3694,7 @@ namespace NLGUI
{
// Text area ?
bool addEntry = false;
ucstring entryData;
string entryData;
if (form.Entries[i].TextArea)
{
// Get the edit box view
@ -3706,7 +3705,7 @@ namespace NLGUI
CGroupEditBox *editBox = dynamic_cast<CGroupEditBox*>(group);
if (editBox)
{
entryData = CUtfStringView(editBox->getViewText()->getText()).toUtf16();
entryData = editBox->getViewText()->getText();
addEntry = true;
}
}
@ -3723,7 +3722,7 @@ namespace NLGUI
else if (form.Entries[i].ComboBox)
{
CDBGroupComboBox *cb = form.Entries[i].ComboBox;
entryData.fromUtf8(form.Entries[i].SelectValues[cb->getSelection()]);
entryData = form.Entries[i].SelectValues[cb->getSelection()];
addEntry = true;
}
else if (form.Entries[i].SelectBox)
@ -3754,7 +3753,7 @@ namespace NLGUI
// Add this entry
if (addEntry)
{
formfields.add(form.Entries[i].Name, CI18N::encodeUTF8(entryData));
formfields.add(form.Entries[i].Name, entryData);
}
}
@ -3786,7 +3785,7 @@ namespace NLGUI
updateRefreshButton();
std::string filename;
if (toLower(uri).find("file:/") == 0)
if (toLowerAscii(uri).find("file:/") == 0)
{
filename = uri.substr(6, uri.size() - 6);
}
@ -3856,7 +3855,7 @@ namespace NLGUI
}
// https://
if (toLower(url.substr(0, 8)) == "https://")
if (toLowerAscii(url.substr(0, 8)) == "https://")
{
// if supported, use custom SSL context function to load certificates
NLWEB::CCurlCertificates::useCertificates(curl);
@ -5347,7 +5346,7 @@ namespace NLGUI
if (_Style.hasStyle("text-align"))
align = _Style.Current.TextAlign;
else if (elm.hasNonEmptyAttribute("align"))
align = toLower(elm.getAttribute("align"));
align = toLowerAscii(elm.getAttribute("align"));
if (align == "left")
cellParams.Align = CGroupCell::Left;
@ -5362,7 +5361,7 @@ namespace NLGUI
if (_Style.hasStyle("vertical-align"))
valign = _Style.Current.VerticalAlign;
else if (elm.hasNonEmptyAttribute("valign"))
valign = toLower(elm.getAttribute("valign"));
valign = toLowerAscii(elm.getAttribute("valign"));
if (valign == "top")
cellParams.VAlign = CGroupCell::Top;
@ -5859,7 +5858,7 @@ namespace NLGUI
// Build the form
CGroupHTML::CForm form;
// id check is case sensitive and auto id's are uppercase
form.id = toLower(trim(elm.getAttribute("id")));
form.id = toLowerAscii(trim(elm.getAttribute("id")));
if (form.id.empty())
{
form.id = toString("FORM%d", _Forms.size());
@ -6287,7 +6286,7 @@ namespace NLGUI
{
fromString(httpContent.substr(0, pos), _NextRefreshTime);
pos = toLower(httpContent).find("url=");
pos = toLowerAscii(httpContent).find("url=");
if (pos != string::npos)
_RefreshUrl = getAbsoluteUrl(httpContent.substr(pos + 4));
}

@ -1286,12 +1286,18 @@ namespace NLGUI
// ----------------------------------------------------------------------------
int CGroupList::luaAddTextChild(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "addTextChild", 1);
ucstring text;
const char *funcName = "addTextChild";
CLuaIHM::checkArgCount(ls, funcName, 1);
#ifdef RYZOM_LUA_UCSTRING
ucstring text; // Compatibility
if(CLuaIHM::pop(ls, text))
{
addTextChild(text.toUtf8()); // FIXME: Lua UTF-8
addTextChild(text.toUtf8());
}
#else
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
addTextChild(ls.toString(1));
#endif
return 0;
}
@ -1306,15 +1312,13 @@ namespace NLGUI
CLuaIHM::checkArgType(ls, funcName, 4, LUA_TNUMBER);
CLuaIHM::checkArgType(ls, funcName, 5, LUA_TNUMBER);
string text = ls.toString(1);
ucstring ucText;
ucText.fromUtf8(text);
uint r = (uint) ls.toInteger(2);
uint g = (uint) ls.toInteger(3);
uint b = (uint) ls.toInteger(4);
uint a = (uint) ls.toInteger(5);
addTextChild(ucText.toUtf8(), CRGBA(r, g, b, a)); // FIXME: Lua UTF-8
addTextChild(text, CRGBA(r, g, b, a));
return 0;
}

@ -1831,8 +1831,13 @@ namespace NLGUI
const char *funcName = "getLineId";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
std::string id = getLineId((uint) ls.toInteger(1));
#ifdef RYZOM_LUA_UCSTRING
ucstring id = getLineId((uint) ls.toInteger(1)); // Compatibility
CLuaIHM::push(ls, id);
#else
std::string id = getLineId((uint)ls.toInteger(1));
ls.push(id);
#endif
return 1;
}
@ -1861,13 +1866,21 @@ namespace NLGUI
{
const char *funcName = "addLine";
CLuaIHM::checkArgCount(ls, funcName, 4);
#ifdef RYZOM_LUA_UCSTRING
CLuaIHM::checkArgTypeUCString(ls, funcName, 1);
#else
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
#endif
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING);
ucstring arg1;
nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); // FIXME: Lua UTF-8
#ifdef RYZOM_LUA_UCSTRING
ucstring arg1; // Compatibility
nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1));
addLine(arg1.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4));
#else
addLine(ls.toString(1), ls.toString(2), ls.toString(3), ls.toString(4));
#endif
return 0;
}
@ -1876,14 +1889,22 @@ namespace NLGUI
{
const char *funcName = "addIconLine";
CLuaIHM::checkArgCount(ls, funcName, 5);
#ifdef RYZOM_LUA_UCSTRING
CLuaIHM::checkArgTypeUCString(ls, funcName, 1);
#else
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
#endif
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING);
ucstring arg1;
nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); // FIXME: Lua UTF-8
#ifdef RYZOM_LUA_UCSTRING
ucstring arg1; // Compatibility
nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1));
addLine(arg1.toUtf8(), ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5));
#else
addLine(ls.toString(1), ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5));
#endif
return 0;
}
@ -1893,13 +1914,21 @@ namespace NLGUI
const char *funcName = "addLineAtIndex";
CLuaIHM::checkArgCount(ls, funcName, 5);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
#ifdef RYZOM_LUA_UCSTRING
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
#else
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
#endif
CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING);
#ifdef RYZOM_LUA_UCSTRING
ucstring arg2;
nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); // FIXME: Lua UTF-8
nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2));
addLineAtIndex((uint) ls.toInteger(1), arg2.toUtf8(), ls.toString(3), ls.toString(4), ls.toString(5));
#else
addLineAtIndex((uint)ls.toInteger(1), ls.toString(2), ls.toString(3), ls.toString(4), ls.toString(5));
#endif
return 0;
}

@ -89,7 +89,7 @@ namespace NLGUI
}
}
parent.Children.push_back(CHtmlElement(CHtmlElement::ELEMENT_NODE, toLower((const char*)node->name)));
parent.Children.push_back(CHtmlElement(CHtmlElement::ELEMENT_NODE, toLowerAscii((const char*)node->name)));
CHtmlElement &elm = parent.Children.back();
elm.ID = element_number;
elm.parent = &parent;
@ -109,7 +109,7 @@ namespace NLGUI
elm.Attributes.clear();
for (xmlAttr *cur_attr = node->properties; cur_attr; cur_attr = cur_attr->next) {
std::string key(toLower((const char *)(cur_attr->name)));
std::string key(toLowerAscii((const char *)(cur_attr->name)));
std::string value;
if (cur_attr->children)
{
@ -124,7 +124,7 @@ namespace NLGUI
NLMISC::splitString(elm.getAttribute("class"), " ", parts);
for(uint i = 0; i<parts.size();++i)
{
elm.ClassNames.insert(toLower(trim(parts[i])));
elm.ClassNames.insert(toLowerAscii(trim(parts[i])));
}
}
@ -136,7 +136,7 @@ namespace NLGUI
bool useStyle = true;
if (elm.hasAttribute("media"))
{
std::string media = trim(toLower(elm.Attributes["media"]));
std::string media = trim(toLowerAscii(elm.Attributes["media"]));
useStyle = media.empty() || media.find("all") != std::string::npos || media.find("screen") != std::string::npos;
// <style media="ryzom"> for ingame browser
@ -154,7 +154,7 @@ namespace NLGUI
bool useStyle = true;
if (elm.hasAttribute("media"))
{
std::string media = trim(toLower(elm.Attributes["media"]));
std::string media = trim(toLowerAscii(elm.Attributes["media"]));
useStyle = media.empty() || media.find("all") != std::string::npos || media.find("screen") != std::string::npos;
// <style media="ryzom"> for ingame browser

@ -210,7 +210,7 @@ namespace NLGUI {
{
// max-age=<seconds>; includeSubdomains; preload;
std::vector<std::string> elements;
NLMISC::splitString(toLower(header), ";", elements);
NLMISC::splitString(toLowerAscii(header), ";", elements);
if (elements.empty()) return;
time_t currentTime;

@ -63,7 +63,7 @@ namespace NLGUI
if (ptr) _Dynamic = CInterfaceElement::convertBool (ptr);
ptr = xmlGetProp (cur, (xmlChar*)"type");
string sTmp = toLower(ptr.str());
string sTmp = toLowerAscii(ptr.str());
if (sTmp == "linear")
_Type = Track_Linear;
else if (sTmp == "bezier")

@ -320,7 +320,7 @@ namespace NLGUI
ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_sizeparent" );
if (ptr)
{
string idparent = NLMISC::toLower(ptr.str());
string idparent = NLMISC::toLowerAscii(ptr.str());
if (idparent != "parent")
{
if (parentGroup)

@ -119,13 +119,14 @@ namespace NLGUI
break;
case CReflectedProperty::UCString:
case CReflectedProperty::UCStringRef:
#ifdef RYZOM_LUA_UCSTRING
if (valueToAffect.toString())
{
(destElem.*(property.SetMethod.SetUCString))(ucstring::makeFromUtf8(valueToAffect.getString()));
}
else
#endif
{
return false;
}
break;

@ -83,7 +83,7 @@ namespace NLGUI
}
else
{
string name = NLMISC::toLower(string((const char*)ptr));
string name = NLMISC::toLowerAscii(string((const char*)ptr));
string value = (string((const char*)val));
_ParamValue[name].init(value);
}
@ -135,7 +135,7 @@ namespace NLGUI
// ***************************************************************************
const CInterfaceOptionValue &CInterfaceOptions::getValue(const string &sParamName) const
{
std::map<std::string, CInterfaceOptionValue>::const_iterator it = _ParamValue.find (toLower(sParamName));
std::map<std::string, CInterfaceOptionValue>::const_iterator it = _ParamValue.find (toLowerAscii(sParamName));
if (it != _ParamValue.end())
return it->second;
else

@ -1369,7 +1369,7 @@ namespace NLGUI
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
string stmp2 = toLower(string((const char*)ptr));
string stmp2 = toLowerAscii(string((const char*)ptr));
CInterfaceElement *pEltFound = NULL;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
@ -1379,7 +1379,7 @@ namespace NLGUI
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
string stmp = toLowerAscii(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
if (stmp == stmp2)
{
@ -1421,7 +1421,7 @@ namespace NLGUI
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
string stmp2 = toLower(string((const char*)ptr));
string stmp2 = toLowerAscii(string((const char*)ptr));
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
CInterfaceElement *pEltFound = NULL;
@ -1431,7 +1431,7 @@ namespace NLGUI
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
string stmp = toLowerAscii(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
if (stmp == stmp2)
{
pEltFound = pIG;
@ -1615,7 +1615,7 @@ namespace NLGUI
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
string stmp2 = toLower(string((const char*)ptr));
string stmp2 = toLowerAscii(string((const char*)ptr));
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
CInterfaceElement *pEltFound = NULL;
@ -1625,7 +1625,7 @@ namespace NLGUI
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
string stmp = toLowerAscii(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
if (stmp == stmp2)
{
@ -1693,8 +1693,8 @@ namespace NLGUI
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
string stmp = NLMISC::toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
string stmp2 = NLMISC::toLower(string((const char*)ptr));
string stmp = NLMISC::toLowerAscii(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
string stmp2 = NLMISC::toLowerAscii(string((const char*)ptr));
if (stmp == stmp2)
{
pEltFound = pIG;

@ -227,7 +227,7 @@ namespace NLGUI
pos++;
}
unit = toLower(str.substr(pos));
unit = toLowerAscii(str.substr(pos));
if (unit == "%" || unit == "rem" || unit == "em" || unit == "px" || unit == "pt")
{
std::string tmpstr = str.substr(0, pos);
@ -687,7 +687,7 @@ namespace NLGUI
}
// make sure domain is lowercase
chunks[0] = toLower(chunks[0]);
chunks[0] = toLowerAscii(chunks[0]);
if (chunks[0] != domain && chunks[0] != std::string("." + domain))
{

@ -100,11 +100,13 @@ using namespace NLMISC;
#define new DEBUG_NEW
#endif
#ifdef RYZOM_LUA_UCSTRING
// declare ostream << operator for ucstring -> registration of ucstring iin luabind will build a 'tostring' function from it
std::ostream &operator<<(std::ostream &str, const ucstring &value)
{
return str << value.toString();
}
#endif
namespace NLGUI
{
@ -172,6 +174,7 @@ namespace NLGUI
return true;
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
bool CLuaIHM::pop(CLuaState &ls, ucstring &dest)
{
@ -224,6 +227,7 @@ namespace NLGUI
obj.pushvalue();
#endif
}
#endif
// ***************************************************************************
// ***************************************************************************
@ -689,6 +693,7 @@ namespace NLGUI
.def_readwrite("A", &NLMISC::CRGBA::A)
];
#ifdef RYZOM_LUA_UCSTRING
// ucstring
module(L)
[
@ -709,6 +714,7 @@ namespace NLGUI
.def("toString", (std::string(ucstring::*)()const)&ucstring::toString)
//.def(self + other<ucstring>())
];
#endif
// CVector2f
module(L)
@ -1279,6 +1285,7 @@ namespace NLGUI
return 1;
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
int CLuaIHM::isUCString(CLuaState &ls)
{
@ -1313,6 +1320,7 @@ namespace NLGUI
CLuaIHM::push(ls, result);
return 1;
}
#endif
// ***************************************************************************
int CLuaIHM::concatString(CLuaState &ls)
@ -1511,6 +1519,7 @@ namespace NLGUI
ls.toString(stackIndex, str);
val= str;
}
#ifdef RYZOM_LUA_UCSTRING
else
{
// else this should be a ucstring
@ -1519,6 +1528,7 @@ namespace NLGUI
throw ELuaIHMException("You must set a string, number or ucstring to UI property '%s'", property.Name.c_str());
}
}
#endif
(target.*(property.SetMethod.SetUCString))(val);
return;
}
@ -1631,8 +1641,10 @@ namespace NLGUI
ls.registerFunc("getWindowSize", getWindowSize);
ls.registerFunc("getTextureSize", getTextureSize);
ls.registerFunc("disableModalWindow", disableModalWindow);
#ifdef RYZOM_LUA_UCSTRING
ls.registerFunc("isUCString", isUCString);
ls.registerFunc("concatUCString", concatUCString);
#endif
ls.registerFunc("concatString", concatString);
ls.registerFunc("tableToString", tableToString);
ls.registerFunc("getCurrentWindowUnder", getCurrentWindowUnder);
@ -1665,7 +1677,11 @@ namespace NLGUI
// inside i18n table
luabind::module(L, "i18n")
[
luabind::def("get", &CI18N::getAsUtf16), // FIXME: Lua UTF-8
#ifdef RYZOM_LUA_UCSTRING
luabind::def("get", &CI18N::getAsUtf16), // Compatibility
#else
luabind::def("get", &CI18N::get),
#endif
luabind::def("hasTranslation", &CI18N::hasTranslation)
];
// inside 'nlfile' table
@ -1843,6 +1859,7 @@ namespace NLGUI
return ret;
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
ucstring CLuaIHM::findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace)
{
@ -1870,7 +1887,7 @@ namespace NLGUI
//H_AUTO(Lua_CLuaIHM_findReplaceAll)
return findReplaceAll(str, search, ucstring::makeFromUtf8(replace));
}
#endif
// ***************************************************************************
void CLuaIHM::fails(CLuaState &ls, const char *format, ...)
@ -1957,6 +1974,7 @@ namespace NLGUI
}
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
void CLuaIHM::checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index)
{
@ -1973,7 +1991,7 @@ namespace NLGUI
fails(ls, "%s : argument %d of expected type ucstring has bad type : %s", funcName, index, ls.getTypename(ls.type(index)), ls.type(index));
}
}
#endif
// ***************************************************************************

@ -88,7 +88,7 @@ namespace NLGUI
host = authority.substr(2);
// case-insensitive
host = NLMISC::toLower(host);
host = NLMISC::toLowerAscii(host);
pos = host.find(":");
if (pos != npos)

@ -92,43 +92,43 @@ namespace NLGUI
_OffsetY = getY();
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_default");
if (prop) _TxDefault = NLMISC::toLower ((const char *) prop);
if (prop) _TxDefault = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_move_window");
if (prop) _TxMoveWindow = NLMISC::toLower ((const char *) prop);
if (prop) _TxMoveWindow = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BR_TL");
if (prop) _TxResizeBRTL = NLMISC::toLower ((const char *) prop);
if (prop) _TxResizeBRTL = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BL_TR");
if (prop) _TxResizeBLTR = NLMISC::toLower ((const char *) prop);
if (prop) _TxResizeBLTR = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_TB");
if (prop) _TxResizeTB = NLMISC::toLower ((const char *) prop);
if (prop) _TxResizeTB = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_LR");
if (prop) _TxResizeLR = NLMISC::toLower ((const char *) prop);
if (prop) _TxResizeLR = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_rotate");
if (prop) _TxRotate = NLMISC::toLower ((const char *) prop);
if (prop) _TxRotate = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_scale");
if (prop) _TxScale = NLMISC::toLower ((const char *) prop);
if (prop) _TxScale = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_colpick");
if (prop) _TxColPick = NLMISC::toLower ((const char *) prop);
if (prop) _TxColPick = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan");
if (prop) _TxPan = NLMISC::toLower ((const char *) prop);
if (prop) _TxPan = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan");
if (prop) _TxCanPan = NLMISC::toLower ((const char *) prop);
if (prop) _TxCanPan = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan_r2");
if (prop) _TxPanR2 = NLMISC::toLower ((const char *) prop);
if (prop) _TxPanR2 = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan_r2");
if (prop) _TxCanPanR2 = NLMISC::toLower ((const char *) prop);
if (prop) _TxCanPanR2 = NLMISC::toLowerAscii ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"color");
if (prop) _Color = convertColor(prop);

@ -312,7 +312,7 @@ namespace NLGUI
if (fonts.count(name) > 0)
driver->deleteTextContext(fonts[name]);
std::string fontFile = CPath::lookup(font, false);
std::string fontFile = NLMISC::startsWith(font, "ui") ? font : CPath::lookup(font, false);
if (fontFile.empty())
{
nlwarning("Font file '%s' not found", font.c_str());
@ -901,7 +901,7 @@ namespace NLGUI
image.UVMin.V = uvMinV;
image.UVMax.U = uvMaxU;
image.UVMax.V = uvMaxV;
sTGAname = toLower(string(tgaName));
sTGAname = toLowerAscii(string(tgaName));
string::size_type stripPng = sTGAname.find(".png");
if (stripPng != string::npos)
@ -974,11 +974,11 @@ namespace NLGUI
return;
}
// Look if already existing
string sLwrGTName = toLower(sGlobalTextureName);
string sLwrGTName = toLowerAscii(sGlobalTextureName);
TGlobalTextureList::iterator ite = _GlobalTextures.begin();
while (ite != _GlobalTextures.end())
{
if (toLower(ite->Name) == sLwrGTName)
if (toLowerAscii(ite->Name) == sLwrGTName)
break;
ite++;
}
@ -1017,11 +1017,11 @@ namespace NLGUI
return createTextureFromDataURL(sGlobalTextureName, uploadDXTC, bReleasable);
// Look if already existing
string sLwrGTName = toLower(sGlobalTextureName);
string sLwrGTName = toLowerAscii(sGlobalTextureName);
TGlobalTextureList::iterator ite = _GlobalTextures.begin();
while (ite != _GlobalTextures.end())
{
std::string sText = toLower(ite->Name);
std::string sText = toLowerAscii(ite->Name);
if (sText == sLwrGTName)
break;
ite++;
@ -1194,11 +1194,11 @@ namespace NLGUI
*/
NL3D::UTexture *CViewRenderer::getGlobalTexture(const std::string &name)
{
string sLwrGTName = NLMISC::toLower(name);
string sLwrGTName = NLMISC::toLowerAscii(name);
TGlobalTextureList::iterator ite = _GlobalTextures.begin();
while (ite != _GlobalTextures.end())
{
std::string sText = NLMISC::toLower(ite->Name);
std::string sText = NLMISC::toLowerAscii(ite->Name);
if (sText == sLwrGTName)
break;
ite++;
@ -1328,7 +1328,7 @@ namespace NLGUI
return -1;
// convert to lowCase
string nameLwr = toLower(sName);
string nameLwr = toLowerAscii(sName);
string::size_type stripPng = nameLwr.find(".png");
if (stripPng != string::npos)

@ -1425,11 +1425,13 @@ namespace NLGUI
}
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
void CViewText::setTextAsUtf16(const ucstring &text)
{
setText(text.toUtf8());
}
#endif
// ***************************************************************************
void CViewText::setTextLocalized(const std::string &text, bool localized)
@ -2452,11 +2454,13 @@ namespace NLGUI
endOfPreviousLine = !_Lines[line]->getLF();
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
void CViewText::setHardTextAsUtf16(const ucstring &ht)
{
setHardText(ht.toUtf8());
}
#endif
// ***************************************************************************
void CViewText::setHardText (const std::string &ht)
@ -2469,6 +2473,7 @@ namespace NLGUI
setText(ht);
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
ucstring CViewText::getTextAsUtf16() const
{
@ -2480,6 +2485,7 @@ namespace NLGUI
{
return CUtfStringView(getHardText()).toUtf16();
}
#endif
// ***************************************************************************
string CViewText::getColorAsString() const
@ -3386,11 +3392,13 @@ namespace NLGUI
}
}
#ifdef RYZOM_LUA_UCSTRING
// ***************************************************************************
void CViewText::setTextFormatTagedAsUtf16(const ucstring &text)
{
setTextFormatTaged(text.toUtf8());
}
#endif
// ***************************************************************************
void CViewText::setTextFormatTaged(const std::string &text)
@ -3484,10 +3492,12 @@ namespace NLGUI
nlwarning("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.c_str());
}
#ifdef RYZOM_LUA_UCSTRING
void CViewText::setSingleLineTextFormatTagedAsUtf16(const ucstring &text)
{
setSingleLineTextFormatTaged(text.toUtf8());
}
#endif
void CViewText::setSingleLineTextFormatTaged(const std::string &text)
{

@ -231,9 +231,7 @@ namespace NLGUI
// Modify the text?
if (_StringModifier)
{
ucstring tmp = ucstring::makeFromUtf8(result);
_StringModifier->onReceiveTextId(tmp); // FIXME: UTF-8
result = tmp.toUtf8();
_StringModifier->onReceiveTextId(result);
}
// Set the Text

@ -1250,7 +1250,7 @@ const IPrimitive *IPrimitive::getPrimitive (const std::string &absoluteOrRelativ
childName=path.substr(0,indexStr);
path.erase(0, indexStr);
}
childName=toUpper(childName);
childName=toUpperAscii(childName);
const IPrimitive*child=NULL;
uint childIndex;
for (childIndex=0;childIndex<cursor->getNumChildren();childIndex++)
@ -1259,7 +1259,7 @@ const IPrimitive *IPrimitive::getPrimitive (const std::string &absoluteOrRelativ
nlassert(child);
string name;
if ( child->getPropertyByName("class", name)
&& toUpper(name)==childName )
&& toUpperAscii(name)==childName )
break;
}
if (childIndex>=cursor->getNumChildren())

@ -353,7 +353,7 @@ bool CPrimitiveClass::read (xmlNodePtr primitiveNode,
// Read the file extension
parameter.FileExtension.clear();
CIXml::getPropertyString (parameter.FileExtension, paramNode, "FILE_EXTENSION");
parameter.FileExtension = toLower(parameter.FileExtension);
parameter.FileExtension = toLowerAscii(parameter.FileExtension);
// Autonaming preference
parameter.Autoname.clear();
@ -362,7 +362,7 @@ bool CPrimitiveClass::read (xmlNodePtr primitiveNode,
// Read the file extension
parameter.Folder.clear();
CIXml::getPropertyString (parameter.Folder, paramNode, "FOLDER");
parameter.Folder = toLower(parameter.Folder);
parameter.Folder = toLowerAscii(parameter.Folder);
// Read the combo values
for ( xmlNodePtr comboValueNode = CIXml::getFirstChildNode (paramNode, "COMBO_VALUES");
@ -427,7 +427,7 @@ bool CPrimitiveClass::read (xmlNodePtr primitiveNode,
for (uint i=0; i<files.size (); i++)
{
// Good extension ?
if (toLower(NLMISC::CFile::getExtension (files[i])) != parameter.FileExtension)
if (toLowerAscii(NLMISC::CFile::getExtension (files[i])) != parameter.FileExtension)
continue;
// Add a combo value
@ -438,7 +438,7 @@ bool CPrimitiveClass::read (xmlNodePtr primitiveNode,
CParameter::CConstStringValue &comboValue = insertResult.first->second;
// Get the filename without extension
string nameWithoutExt = toLower(NLMISC::CFile::getFilenameWithoutExtension (files[i]));
string nameWithoutExt = toLowerAscii(NLMISC::CFile::getFilenameWithoutExtension (files[i]));
// Add the values
comboValue.Values.push_back (nameWithoutExt);

@ -105,13 +105,13 @@ bool CPrimitiveConfigurations::belong (const IPrimitive &primitive) const
for (rules=0; rules<numRules; rules++)
{
const std::pair<std::string, std::string> &pairs = matchGroup.Pairs[rules];
string key = toLower(pairs.second);
string key = toLowerAscii(pairs.second);
// Get the property
string value;
if (primitive.getPropertyByName (pairs.first.c_str(), value))
{
if (toLower(value) == key)
if (toLowerAscii(value) == key)
continue;
}
@ -122,7 +122,7 @@ bool CPrimitiveConfigurations::belong (const IPrimitive &primitive) const
uint i;
for (i=0; i<array->size(); i++)
{
if (toLower((*array)[i]) == key)
if (toLowerAscii((*array)[i]) == key)
break;
}
if (i!=array->size())

@ -128,7 +128,7 @@ void CBigFile::CThreadFileArray::currentThreadFinished()
bool CBigFile::add (const std::string &sBigFileName, uint32 nOptions)
{
// Is already the same bigfile name ?
string bigfilenamealone = toLower(CFile::getFilename (sBigFileName));
string bigfilenamealone = toLowerAscii(CFile::getFilename (sBigFileName));
if (_BNPs.find(bigfilenamealone) != _BNPs.end())
{
nlwarning ("CBigFile::add : bigfile %s already added.", bigfilenamealone.c_str());
@ -315,7 +315,7 @@ bool CBigFile::BNP::readHeader(FILE *file)
BNPFile bnpfTmp;
bnpfTmp.Pos = nFilePos;
bnpfTmp.Size = nFileSize2;
tempMap.insert (make_pair(toLower(string(sFileName)), bnpfTmp));
tempMap.insert (make_pair(toLowerAscii(string(sFileName)), bnpfTmp));
}
else
{
@ -606,7 +606,7 @@ std::string CBigFile::getBigFileName(const std::string &sBigFileName) const
// ***************************************************************************
void CBigFile::list (const std::string &sBigFileName, std::vector<std::string> &vAllFiles)
{
string lwrFileName = toLower(sBigFileName);
string lwrFileName = toLowerAscii(sBigFileName);
if (_BNPs.find (lwrFileName) == _BNPs.end())
return;
vAllFiles.clear ();
@ -639,7 +639,7 @@ struct CBNPFileComp
// ***************************************************************************
bool CBigFile::getFileInternal (const std::string &sFileName, BNP *&zeBnp, BNPFile *&zeBnpFile)
{
string zeFileName, zeBigFileName, lwrFileName = toLower(sFileName);
string zeFileName, zeBigFileName, lwrFileName = toLowerAscii(sFileName);
string::size_type i, nPos = sFileName.find ('@');
if (nPos == string::npos)
{
@ -753,7 +753,7 @@ char *CBigFile::getFileNamePtr(const std::string &sFileName, const std::string &
vector<BNPFile>::iterator itNBPFile;
if (rbnp.Files.empty())
return NULL;
string lwrFileName = toLower(sFileName);
string lwrFileName = toLowerAscii(sFileName);
BNPFile temp_bnp_file;
temp_bnp_file.Name = (char*)lwrFileName.c_str();

@ -466,7 +466,7 @@ void CCommandRegistry::expand (std::string &commandName, NLMISC::CLog &log)
useprefix = false;
}
string lowerCommandName = toLower(commandName);
string lowerCommandName = toLowerAscii(commandName);
// Build the list of matching command names
vector<string> matchingnames;
{
@ -475,7 +475,7 @@ void CCommandRegistry::expand (std::string &commandName, NLMISC::CLog &log)
// list of global commands
for (TCommand::iterator comm = _Commands.begin(); comm != _Commands.end(); comm++)
{
string first = toLower((*comm).first);
string first = toLowerAscii((*comm).first);
if (first.find( lowerCommandName ) == 0)
{
matchingnames.push_back( (*comm).first );
@ -485,7 +485,7 @@ void CCommandRegistry::expand (std::string &commandName, NLMISC::CLog &log)
// list of object instance
for (TCommandsHandlers::TAToBMap::const_iterator it(_CommandsHandlers.getAToBMap().begin()); it != _CommandsHandlers.getAToBMap().end(); ++it)
{
string first = toLower(it->first);
string first = toLowerAscii(it->first);
if (first.find( lowerCommandName ) == 0)
{
matchingnames.push_back( it->first );
@ -507,7 +507,7 @@ void CCommandRegistry::expand (std::string &commandName, NLMISC::CLog &log)
for (TCommandHandlerClassInfo::TCommandsInfo::iterator it(chci._Commands.begin()); it != chci._Commands.end(); ++it)
{
string first = toLower(it->first);
string first = toLowerAscii(it->first);
if (first.find( lowerCommandName ) == 0)
{
matchingnames.push_back( it->first );

@ -577,7 +577,6 @@ uint32 fromHumanReadable (const std::string &str)
return 0;
}
NLMISC_CATEGORISED_COMMAND(nel,stohr, "Convert a second number into an human readable time", "<int>")
{
nlunreferenced(rawCommandString);
@ -594,6 +593,50 @@ NLMISC_CATEGORISED_COMMAND(nel,stohr, "Convert a second number into an human rea
return true;
}
NLMISC_CATEGORISED_COMMAND(nel, toLower, "Convert a string to lowercase", "<string>")
{
nlunreferenced(args);
nlunreferenced(quiet);
nlunreferenced(human);
log.displayNL("%s", toLower(rawCommandString).c_str());
return true;
}
NLMISC_CATEGORISED_COMMAND(nel, toUpper, "Convert a string to uppercase", "<string>")
{
nlunreferenced(args);
nlunreferenced(quiet);
nlunreferenced(human);
log.displayNL("%s", toUpper(rawCommandString).c_str());
return true;
}
NLMISC_CATEGORISED_COMMAND(nel, toLowerAscii, "Convert a string's ascii-characters to lowercase", "<string>")
{
nlunreferenced(args);
nlunreferenced(quiet);
nlunreferenced(human);
log.displayNL("%s", toLowerAscii(rawCommandString).c_str());
return true;
}
NLMISC_CATEGORISED_COMMAND(nel, toUpperAscii, "Convert a string's ascii-characters to uppercase", "<string>")
{
nlunreferenced(args);
nlunreferenced(quiet);
nlunreferenced(human);
log.displayNL("%s", toUpperAscii(rawCommandString).c_str());
return true;
}
#if 0
std::string toLower(const char *str)
@ -689,6 +732,102 @@ void toUpper(char *str)
}
}
std::string toLowerAscii(const std::string &str, char replacement)
{
std::string res;
res.reserve(str.size());
for (std::string::const_iterator it(str.begin()), end(str.end()); it != end; ++it)
{
char c = *it;
if ((sint8)(c + '\x01') < (sint8)(' ' + '\x01')) res += replacement;
else if (c >= 'A' && c <= 'Z') res += c + ('a' - 'A');
else res += c;
}
return res;
}
void toLowerAscii(char *str, char replacement)
{
for (ptrdiff_t i = 0; str[i]; ++i)
{
char c = str[i];
if ((sint8)(c + '\x01') < (sint8)(' ' + '\x01')) str[i] = replacement;
else if (c >= 'A' && c <= 'Z') str[i] = c + ('a' - 'A');
else str[i] = c;
}
}
std::string toUpperAscii(const std::string &str, char replacement)
{
std::string res;
res.reserve(str.size());
for (std::string::const_iterator it(str.begin()), end(str.end()); it != end; ++it)
{
char c = *it;
if ((sint8)(c + '\x01') < (sint8)(' ' + '\x01')) res += replacement;
else if (c >= 'a' && c <= 'z') res += c - ('a' - 'A');
else res += c;
}
return res;
}
void toUpperAscii(char *str, char replacement)
{
for (ptrdiff_t i = 0; str[i]; ++i)
{
char c = str[i];
if ((sint8)(c + '\x01') < (sint8)(' ' + '\x01')) str[i] = replacement;
else if (c >= 'a' && c <= 'z') str[i] = c - ('a' - 'A');
else str[i] = c;
}
}
std::string toLowerAscii(const std::string &str)
{
std::string res;
res.reserve(str.size());
for (std::string::const_iterator it(str.begin()), end(str.end()); it != end; ++it)
{
char c = *it;
if (c >= 'A' && c <= 'Z') res += c + ('a' - 'A');
else res += c;
}
return res;
}
void toLowerAscii(char *str)
{
for (ptrdiff_t i = 0; str[i]; ++i)
{
char c = str[i];
if (c >= 'A' && c <= 'Z') str[i] = c + ('a' - 'A');
else str[i] = c;
}
}
std::string toUpperAscii(const std::string &str)
{
std::string res;
res.reserve(str.size());
for (std::string::const_iterator it(str.begin()), end(str.end()); it != end; ++it)
{
char c = *it;
if (c >= 'a' && c <= 'z') res += c - ('a' - 'A');
else res += c;
}
return res;
}
void toUpperAscii(char *str)
{
for (ptrdiff_t i = 0; str[i]; ++i)
{
char c = str[i];
if (c >= 'a' && c <= 'z') str[i] = c - ('a' - 'A');
else str[i] = c;
}
}
std::string toHexa(const uint8 &b)
{
return toString("%02hhx", b);
@ -1052,7 +1191,7 @@ bool launchProgram(const std::string &programName, const std::string &arguments,
#ifdef NL_OS_MAC
// special OS X case with bundles
if (toLower(CFile::getExtension(programName)) == ".app")
if (toLowerAscii(CFile::getExtension(programName)) == ".app")
{
// we need to open bundles with "open" command
std::string command = NLMISC::toString("open \"%s\"", programName.c_str());
@ -1160,7 +1299,7 @@ bool launchProgramArray (const std::string &programName, const std::vector<std::
#ifdef NL_OS_MAC
// special OS X case with bundles
if (toLower(CFile::getExtension(programName)) == "app")
if (toLowerAscii(CFile::getExtension(programName)) == "app")
{
// we need to open bundles with "open" command
std::string command = NLMISC::toString("open \"%s\"", programName.c_str());

@ -444,7 +444,7 @@ std::string CI18N::getSystemLanguageCode ()
if (lang.size() > 1)
{
// only keep 2 first characters
lang = NLMISC::toLower(lang).substr(0, 2);
lang = NLMISC::toLowerAscii(lang).substr(0, 2);
// language code supported?
if (isLanguageCodeSupported(lang))
@ -466,7 +466,7 @@ bool CI18N::setSystemLanguageCode (const std::string &languageCode)
// be sure supported languages are initialized
initLanguages();
std::string lang = NLMISC::toLower(languageCode);
std::string lang = NLMISC::toLowerAscii(languageCode);
// specified language is really a code (2 characters)
if (lang.length() == 2)
@ -474,7 +474,7 @@ bool CI18N::setSystemLanguageCode (const std::string &languageCode)
// check if language code is supported
for(uint i = 0; i < _LanguageCodes.size(); ++i)
{
std::string code = NLMISC::toLower(_LanguageCodes[i]);
std::string code = NLMISC::toLowerAscii(_LanguageCodes[i]);
if (lang == code)
{
@ -490,7 +490,7 @@ bool CI18N::setSystemLanguageCode (const std::string &languageCode)
// check if language name is supported
for(uint i = 0; i < _LanguageNames.size(); ++i)
{
std::string name = NLMISC::toLower(_LanguageNames[i]);
std::string name = NLMISC::toLowerAscii(_LanguageNames[i]);
if (name == lang)
{

@ -180,7 +180,7 @@ bool CIXml::init (IStream &stream)
header[2] = buffer[2];
header[3] = buffer[3];
header[4] = '\0';
toLower(header);
toLowerAscii(header);
// Does it a xml stream ?
if (strcmp(header, "<?xm"))

@ -334,8 +334,8 @@ void CFileContainer::remapExtension (const string &ext1, const string &ext2, boo
{
nlassert(!_MemoryCompressed);
string ext1lwr = toLower(ext1);
string ext2lwr = toLower(ext2);
string ext1lwr = toLowerAscii(ext1);
string ext2lwr = toLowerAscii(ext2);
if (ext1lwr.empty() || ext2lwr.empty())
{
@ -417,7 +417,7 @@ void CFileContainer::remapFile (const std::string &file1, const std::string &fil
{
if (file1.empty()) return;
if (file2.empty()) return;
_RemappedFiles[toLower(file1)] = toLower(file2);
_RemappedFiles[toLowerAscii(file1)] = toLowerAscii(file2);
}
// ***************************************************************************
@ -497,7 +497,7 @@ string CFileContainer::lookup (const string &filename, bool throwException, bool
// Try to find in the map directories
// If filename contains a path, we get only the filename to look inside paths
string str = CFile::getFilename(toLower(filename));
string str = CFile::getFilename(toLowerAscii(filename));
// Remove end spaces
while ((!str.empty()) && (str[str.size()-1] == ' '))
@ -557,7 +557,7 @@ string CFileContainer::lookup (const string &filename, bool throwException, bool
// try with the remapping
for (uint j = 0; j < _Extensions.size(); j++)
{
if (toLower(CFile::getExtension (str)) == _Extensions[j].second)
if (toLowerAscii(CFile::getExtension (str)) == _Extensions[j].second)
{
string rs = _AlternativePaths[i] + CFile::getFilenameWithoutExtension (filename) + "." + _Extensions[j].first;
if ( CFile::fileExists(rs) )
@ -599,7 +599,7 @@ bool CPath::exists (const std::string &filename)
bool CFileContainer::exists (const std::string &filename)
{
// Try to find in the map directories
string str = toLower(filename);
string str = toLowerAscii(filename);
// Remove end spaces
while ((!str.empty()) && (str[str.size()-1] == ' '))
@ -1215,7 +1215,7 @@ void CFileContainer::addSearchFile (const string &file, bool remap, const string
// now, we have to see extension and insert in the map the remapped files
for (uint i = 0; i < _Extensions.size (); i++)
{
if (_Extensions[i].first == toLower(ext))
if (_Extensions[i].first == toLowerAscii(ext))
{
// need to remap
addSearchFile (newFile, true, _Extensions[i].second, progressCallBack);
@ -1372,7 +1372,7 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse,
NLMISC_BSWAP32(nFilePos);
#endif
string sTmp = toLower(string(FileName));
string sTmp = toLowerAscii(string(FileName));
if (sTmp.empty())
{
nlwarning ("PATH: CPath::addSearchBigFile(%s, %d, %d): can't add empty file, skip it", sBigFilename.c_str(), recurse, alternative);
@ -1380,7 +1380,7 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse,
}
string bigfilenamealone = CFile::getFilename (sBigFilename);
string filenamewoext = CFile::getFilenameWithoutExtension (sTmp);
string ext = toLower(CFile::getExtension(sTmp));
string ext = toLowerAscii(CFile::getExtension(sTmp));
insertFileInMap (sTmp, bigfilenamealone + "@" + sTmp, false, ext);
@ -1438,7 +1438,7 @@ void CFileContainer::addSearchStreamedPackage (const string &filename, bool recu
}
// Add the file itself
std::string packname = NLMISC::toLower(CFile::getFilename(filename));
std::string packname = NLMISC::toLowerAscii(CFile::getFilename(filename));
insertFileInMap(packname, filename, false, CFile::getExtension(filename));
// Add the package to the package manager
@ -1525,7 +1525,7 @@ void CFileContainer::addSearchXmlpackFile (const string &sXmlpackFilename, bool
string packfilenamealone = sXmlpackFilename;
string filenamewoext = CFile::getFilenameWithoutExtension (filenames[i]);
string ext = toLower(CFile::getExtension(filenames[i]));
string ext = toLowerAscii(CFile::getExtension(filenames[i]));
insertFileInMap (filenames[i], packfilenamealone + "@@" + filenames[i], false, ext);
@ -1570,7 +1570,7 @@ void CFileContainer::insertFileInMap (const string &filename, const string &file
{
nlassert(!_MemoryCompressed);
// find if the file already exist
TFiles::iterator it = _Files.find (toLower(filename));
TFiles::iterator it = _Files.find (toLowerAscii(filename));
if (it != _Files.end ())
{
string path = SSMpath.get((*it).second.idPath);
@ -1629,8 +1629,8 @@ void CFileContainer::insertFileInMap (const string &filename, const string &file
fe.idPath = SSMpath.add(sTmp);
fe.Name = filename;
_Files.insert (make_pair(toLower(filename), fe));
NL_DISPLAY_PATH("PATH: CPath::insertFileInMap(%s, %s, %d, %s): added", toLower(filename).c_str(), filepath.c_str(), remap, toLower(extension).c_str());
_Files.insert (make_pair(toLowerAscii(filename), fe));
NL_DISPLAY_PATH("PATH: CPath::insertFileInMap(%s, %s, %d, %s): added", toLowerAscii(filename).c_str(), filepath.c_str(), remap, toLowerAscii(extension).c_str());
}
}
@ -1690,13 +1690,13 @@ void CFileContainer::removeBigFiles(const std::vector<std::string> &bnpFilenames
TFiles::iterator fileIt, fileCurrIt;
for (uint k = 0; k < bnpFilenames.size(); ++k)
{
std::string completeBNPName = toLower(bnpFilenames[k]) + "@";
std::string completeBNPName = toLowerAscii(bnpFilenames[k]) + "@";
if (SSMpath.isAdded(completeBNPName))
{
bnpStrIds.insert(SSMpath.add(completeBNPName));
}
CBigFile::getInstance().remove(bnpFilenames[k]);
fileIt = _Files.find(toLower(bnpFilenames[k]));
fileIt = _Files.find(toLowerAscii(bnpFilenames[k]));
if (fileIt != _Files.end())
{
_Files.erase(fileIt);
@ -1825,7 +1825,7 @@ void CFileContainer::memoryUncompress()
fe.idPath = it->idPath;
fe.Remapped = it->Remapped;
_Files[toLower(CFile::getFilename(fe.Name))] = fe;
_Files[toLowerAscii(CFile::getFilename(fe.Name))] = fe;
}
contReset(_MCFiles);
_MemoryCompressed = false;

@ -226,7 +226,7 @@ bool CSheetId::buildSheetId(const char *sheetName, size_t sheetNameLen)
// When no sheet_id.bin is loaded, use dynamically assigned IDs.
if (_DontHaveSheetKnowledge)
{
std::string sheetNameLc = toLower(sheetName);
std::string sheetNameLc = toLowerAscii(sheetName);
std::map<std::string, uint32>::iterator it = _DevSheetNameToId.find(sheetNameLc);
if (it == _DevSheetNameToId.end())
{
@ -278,7 +278,7 @@ bool CSheetId::buildSheetId(const char *sheetName, size_t sheetNameLen)
c.Ptr = new char[sheetName.size() + 1];
#endif
strcpy(c.Ptr, sheetName);
toLower(c.Ptr);
toLowerAscii(c.Ptr);
itId = _SheetNameToId.find(c);
#ifndef alloca
@ -381,7 +381,7 @@ void CSheetId::loadSheetId()
{
tempVec[nNb].Ptr = _AllStrings.Ptr + nSize;
strcpy(_AllStrings.Ptr + nSize, it->second.c_str());
toLower(_AllStrings.Ptr + nSize);
toLowerAscii(_AllStrings.Ptr + nSize);
nSize += (uint32)it->second.size() + 1;
nNb++;
it++;
@ -422,7 +422,7 @@ void CSheetId::loadSheetId()
if (_FileExtensions[type].empty())
{
// find the file extension part of the given file name
_FileExtensions[type] = toLower(CFile::getExtension((*itStr).second.Ptr));
_FileExtensions[type] = toLowerAscii(CFile::getExtension((*itStr).second.Ptr));
}
nSize--;
}
@ -826,7 +826,7 @@ uint32 CSheetId::typeFromFileExtension(const std::string &fileExtension)
uint i;
for (i = 0; i < _FileExtensions.size(); i++)
if (toLower(fileExtension) == _FileExtensions[i])
if (toLowerAscii(fileExtension) == _FileExtensions[i])
return i;
return std::numeric_limits<uint32>::max();

@ -55,7 +55,7 @@ void CStreamedPackage::CEntry::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
void CStreamedPackage::makePath(std::string &result, const CHashKey &hash)
{
std::string lowerHash = NLMISC::toLower(hash.toString());
std::string lowerHash = NLMISC::toLowerAscii(hash.toString());
result = std::string("/") + lowerHash.substr(0, 2)
+ "/" + lowerHash.substr(2, 2)
+ "/" + lowerHash.substr(4);

@ -41,7 +41,7 @@ bool CStreamedPackageManager::loadPackage(const std::string &package)
{
nldebug("Load package '%s'", package.c_str());
std::string packname = NLMISC::toLower(CFile::getFilename(package));
std::string packname = NLMISC::toLowerAscii(CFile::getFilename(package));
m_Packages[packname] = CStreamedPackage();
std::map<std::string, CStreamedPackage>::iterator it = m_Packages.find(packname);
CStreamedPackage &p = it->second;

@ -90,7 +90,7 @@ bool fromString(const std::string &str, bool &val)
}
else
{
std::string strl = toLower(str);
std::string strl = toLowerAscii(str);
if (strl == "true" || strl == "yes")
{
val = true;

@ -1690,7 +1690,7 @@ bool CSystemInfo::getVideoInfo (std::string &deviceName, uint64 &driverVersion)
}
else
{
string::size_type pos = toLower(keyPath).find ("\\device");
string::size_type pos = toLowerAscii(keyPath).find ("\\device");
if (pos != string::npos)
keyPath = keyPath.substr (0, pos+1);
keyName = "ImagePath";
@ -1703,7 +1703,7 @@ bool CSystemInfo::getVideoInfo (std::string &deviceName, uint64 &driverVersion)
}
// Format the key path
if (toLower(keyPath).find ("\\registry\\machine") == 0)
if (toLowerAscii(keyPath).find ("\\registry\\machine") == 0)
{
keyPath = "HKEY_LOCAL_MACHINE" + keyPath.substr (strlen ("\\registry\\machine"));
}
@ -1733,7 +1733,7 @@ bool CSystemInfo::getVideoInfo (std::string &deviceName, uint64 &driverVersion)
HKEY keyRoot = HKEY_LOCAL_MACHINE;
for (i=0; i<sizeof(rootKeysH)/sizeof(HKEY); i++)
{
if (toUpper(keyPath).find (rootKeys[i]) == 0)
if (toUpperAscii(keyPath).find (rootKeys[i]) == 0)
{
keyPath = keyPath.substr (strlen (rootKeys[i]));
keyRoot = rootKeysH[i];

@ -18,6 +18,7 @@
// Project includes
#include <nel/misc/utf_string_view.h>
#include <nel/misc/stream.h>
// References:
// - https://twiserandom.com/unicode/unicode-encoding-utf-8-utf-16-utf-32/
@ -69,6 +70,44 @@ void CUtfStringView::append(std::string &str, u32char c)
appendUtf8(str, c);
}
void CUtfStringView::append(IStream &s, u32char c)
{
nlassert(!s.isReading());
std::string tmp;
tmp.reserve(4);
append(tmp, c);
s.serialBuffer((uint8 *)&tmp[0], tmp.size());
}
u32char CUtfStringView::get(IStream &s)
{
nlassert(s.isReading());
std::string tmp;
tmp.reserve(4);
uint8 c;
s.serial(c);
// Single byte
if (c < 0x80)
return c;
// Do a fast check of length
tmp += (char)c;
size_t len;
if ((c & 0xF0) == 0xF0) len = 4;
if ((c & 0xE0) == 0xE0) len = 3;
else len = 2;
// Read from stream
tmp.resize(len);
s.serialBuffer((uint8 *)&tmp[1], len - 1);
// Decode
const void *str = tmp.c_str();
return utf8Iterator(&str);
}
std::string CUtfStringView::toUtf8(bool reEncode) const
{
// Decode UTF and encode UTF-8
@ -135,6 +174,21 @@ std::string CUtfStringView::toAscii() const
return res;
}
std::string CUtfStringView::fromAscii(const std::string &str)
{
std::string res;
res.reserve(str.size());
for (std::string::const_iterator it(str.begin()), end(str.end()); it != end; ++it)
{
unsigned char c = *it;
if (c < 0x80)
res += (char)c;
else
res += '?';
}
return res;
}
std::wstring CUtfStringView::toWide() const
{
#ifdef NL_OS_WINDOWS

@ -24,6 +24,7 @@
#include "nel/misc/event_emitter.h"
#include "nel/misc/win_event_emitter.h"
#include "nel/misc/event_server.h"
#include "nel/misc/utf_string_view.h"
#ifdef NL_OS_WINDOWS
#include <windowsx.h>
@ -177,10 +178,28 @@ bool CWinEventEmitter::processMessage (HWND hWnd, uint32 msg, WPARAM wParam, LPA
{
//if (wParam < KeyCount)
//nlinfo("WM_CHAR with %u", wParam);
#ifndef WM_UNICHAR
// FIXME: Combine UTF-16 pairs
#endif
server->postEvent (new CEventChar ((ucchar)wParam, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this));
wchar_t c = (wchar_t)wParam;
if ((c & 0xFC00) == 0xD800)
{
_Utf16Pair = c;
}
else if (_Utf16Pair && (c & 0xFC00) == 0xDC00)
{
wchar_t cc[] = { _Utf16Pair, c, 0 };
_Utf16Pair = 0;
CUtfStringView cv = CUtfStringView(cc);
for (CUtfStringView::iterator it(cv.begin()), end(cv.end()); it != end; ++it)
server->postEvent(new CEventChar(*it, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this));
}
else
{
if (_Utf16Pair)
{
server->postEvent(new CEventChar(_Utf16Pair, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this));
_Utf16Pair = 0;
}
server->postEvent(new CEventChar(c, getKeyButton(_AltButton, _ShiftButton, _CtrlButton), this));
}
}
break;
/*case WM_IME_CHAR:

@ -225,7 +225,7 @@ bool sendEmail (const string &smtpServer, const string &from, const string &to,
formatedBody += "--Multipart_nel\r\n";
formatedBody += "Content-Disposition: attachment;\r\n";
string lext = toLower(ext);
string lext = toLowerAscii(ext);
if(lext == "tga")
{
formatedBody += "Content-Type: image/x-targa;\r\n";

@ -708,7 +708,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName,
// we create the log with service name filename ("test_service_ALIAS.log" for example)
string logname = LogDirectory.toString() + _LongName;
if (haveArg('N'))
logname += "_" + toLower(getArg('N'));
logname += "_" + toLowerAscii(getArg('N'));
logname += ".log";
fd.setParam (logname, false);
@ -956,7 +956,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName,
// Load the recording state from the config file
if ((var = ConfigFile.getVarPtr ("Rec")) != NULL)
{
string srecstate = toUpper(var->asString());
string srecstate = toUpperAscii(var->asString());
if ( srecstate == "RECORD" )
{
_RecordingState = CCallbackNetBase::Record;

@ -89,7 +89,7 @@ IAudioDecoder *IAudioDecoder::createAudioDecoder(const std::string &type, NLMISC
return NULL;
}
#else
std::string type_lower = toLower(type);
std::string type_lower = toLowerAscii(type);
if (type_lower == "ogg")
{
return new CAudioDecoderVorbis(stream, loop);
@ -124,7 +124,7 @@ bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, st
return CAudioDecoderFfmpeg::getInfo(&ifile, artist, title, length);
#else
std::string type = CFile::getExtension(filepath);
std::string type_lower = NLMISC::toLower(type);
std::string type_lower = NLMISC::toLowerAscii(type);
if (type_lower == "ogg")
{

@ -371,7 +371,7 @@ void CAudioMixerUser::init(uint maxTrack, bool useEax, bool useADPCM, IProgressC
/// Initialize the NeL Sound Driver with given driverName.
void CAudioMixerUser::initDriver(const std::string &driverName)
{
std::string dn = NLMISC::toLower(driverName);
std::string dn = NLMISC::toLowerAscii(driverName);
nldebug("AM: Init Driver '%s' ('%s')...", driverName.c_str(), dn.c_str());
ISoundDriver::TDriver driverType;

@ -90,7 +90,7 @@ bool CGroupControllerRoot::isReservedName(const std::string &nodeName)
CGroupController *CGroupControllerRoot::getGroupController(const std::string &path)
{
std::vector<std::string> pathNodes;
NLMISC::splitString(NLMISC::toLower(path), ":", pathNodes);
NLMISC::splitString(NLMISC::toLowerAscii(path), ":", pathNodes);
CGroupController *active = this;
if (pathNodes[0] != NLSOUND_GROUP_CONTROLLER_ROOT_PATH)
{

@ -340,7 +340,7 @@ namespace NLWEB
}
else
{
nldebug("Added certificate %s", entry.name.c_str());
// nldebug("Added certificate %s", entry.name.c_str());
}
}
}

@ -49,6 +49,7 @@ mkPath(log, fontExportDir)
for dir in FontSourceDirectories:
mkPath(log, DatabaseDirectory + "/" + dir)
copyFilesExtNoTreeIfNeeded(log, DatabaseDirectory + "/" + dir, fontExportDir, ".ttf")
copyFilesExtNoTreeIfNeeded(log, DatabaseDirectory + "/" + dir, fontExportDir, ".otf")
copyFilesExtNoTreeIfNeeded(log, DatabaseDirectory + "/" + dir, fontExportDir, ".afm")
copyFilesExtNoTreeIfNeeded(log, DatabaseDirectory + "/" + dir, fontExportDir, ".pfb")
copyFilesExtNoTreeIfNeeded(log, DatabaseDirectory + "/" + dir, fontExportDir, ".pfm")

@ -50,6 +50,7 @@ mkPath(log, fontExportDir)
printLog(log, ">>> Install font <<<")
copyFilesExtNoTreeIfNeeded(log, fontExportDir, installPath, ".ttf")
copyFilesExtNoTreeIfNeeded(log, fontExportDir, installPath, ".otf")
copyFilesExtNoTreeIfNeeded(log, fontExportDir, installPath, ".afm")
copyFilesExtNoTreeIfNeeded(log, fontExportDir, installPath, ".pfb")
copyFilesExtNoTreeIfNeeded(log, fontExportDir, installPath, ".pfm")

@ -42,7 +42,7 @@ extern CEventsListener EventsListener;
// Hierarchical timer
H_AUTO_DECL ( RZ_Client_Actions_Context_Mngr_Update )
static bool getParam (CBaseAction::CParameter::TType type, ucstring &paramName, ucstring &paramValue, const std::string &argu, uint paramId);
static bool getParam (CBaseAction::CParameter::TType type, string &paramName, string &paramValue, const std::string &argu, uint paramId);
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
@ -268,8 +268,8 @@ bool CActionsManager::isActionPresentInContext(const CAction::CName &name) const
const CBaseAction::CParameter &parameter = baseAction->Parameters[i];
if (parameter.Type == CBaseAction::CParameter::Constant)
{
ucstring paramName;
ucstring paramValue = parameter.DefaultValue;
string paramName;
string paramValue = parameter.DefaultValue;
// Get the param from the argu
getParam (parameter.Type, paramName, paramValue, name.Argu, i);
@ -277,7 +277,7 @@ bool CActionsManager::isActionPresentInContext(const CAction::CName &name) const
bool found = true;
for (uint k = 0; k < parameter.Values.size(); ++k)
{
if (parameter.Values[k].Value == paramValue.toUtf8())
if (parameter.Values[k].Value == paramValue)
{
if (!ActionsContext.matchContext(parameter.Values[k].Contexts)) return false;
found = true;
@ -656,7 +656,7 @@ CBaseAction::CParameter::CParameter ()
// ***************************************************************************
static bool getParam (CBaseAction::CParameter::TType type, ucstring &paramName, ucstring &paramValue, const std::string &argu, uint paramId)
static bool getParam (CBaseAction::CParameter::TType type, string &paramName, string &paramValue, const std::string &argu, uint paramId)
{
const string separator = "|";
const string equal_separator = "=";
@ -697,10 +697,7 @@ static bool getParam (CBaseAction::CParameter::TType type, ucstring &paramName,
}
// Value ?
if(type==CBaseAction::CParameter::User || type==CBaseAction::CParameter::UserName)
paramValue.fromUtf8(argu.substr(pos, end-pos));
else
paramValue = argu.substr(pos, end-pos);
paramValue = argu.substr(pos, end-pos);
// Ok
return true;
@ -708,10 +705,10 @@ static bool getParam (CBaseAction::CParameter::TType type, ucstring &paramName,
return false;
}
ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const
string CBaseAction::getActionLocalizedText(const CAction::CName &name) const
{
// Action base name
ucstring temp = CI18N::get(LocalizedName);
string temp = CI18N::get(LocalizedName);
// Get the parameter
uint i;
@ -719,8 +716,8 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const
{
bool parameterOk = false;
const CParameter &parameter = Parameters[i];
ucstring paramName;
ucstring paramValue;
string paramName;
string paramValue;
// Get the param from the argu
if (getParam (parameter.Type, paramName, paramValue, name.Argu, i))
@ -728,7 +725,7 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const
switch (parameter.Type)
{
case CParameter::Hidden:
if ((ucstring (parameter.DefaultValue) == paramValue) && (ucstring (parameter.Name) == paramName))
if ((parameter.DefaultValue == paramValue) && (parameter.Name == paramName))
parameterOk = true;
break;
case CParameter::Constant:
@ -738,7 +735,7 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const
{
// This value ?
const CParameter::CValue &value = parameter.Values[j];
if (ucstring(value.Value) == paramValue)
if (value.Value == paramValue)
{
temp += " ";
@ -771,7 +768,7 @@ ucstring CBaseAction::getActionLocalizedText (const CAction::CName &name) const
if (i==Parameters.size ())
return temp;
return ucstring("");
return string();
}
// ***************************************************************************
@ -816,8 +813,8 @@ const CActionsManager::CCategoryLocator *CActionsManager::getActionLocator (cons
{
bool parameterOk = false;
const CBaseAction::CParameter &parameter = baseAction.Parameters[i];
ucstring paramName;
ucstring paramValue;
string paramName;
string paramValue;
// Get the param from the argu
if (getParam (parameter.Type, paramName, paramValue, name.Argu, i))
@ -825,7 +822,7 @@ const CActionsManager::CCategoryLocator *CActionsManager::getActionLocator (cons
switch (parameter.Type)
{
case CBaseAction::CParameter::Hidden:
if ((ucstring (parameter.DefaultValue) == paramValue) && (ucstring (parameter.Name) == paramName))
if ((parameter.DefaultValue == paramValue) && (parameter.Name == paramName))
parameterOk = true;
break;
case CBaseAction::CParameter::Constant:
@ -835,7 +832,7 @@ const CActionsManager::CCategoryLocator *CActionsManager::getActionLocator (cons
for (j=0; j<parameter.Values.size (); j++)
{
const CBaseAction::CParameter::CValue &value = parameter.Values[j];
if (ucstring(value.Value) == paramValue)
if (value.Value == paramValue)
{
parameterOk = true;
break;
@ -911,11 +908,11 @@ bool CActionsManager::isActionDisplayForced(const CAction::CName &name) const
}
// ***************************************************************************
ucstring CActionsManager::getActionLocalizedText (const CAction::CName &name) const
string CActionsManager::getActionLocalizedText (const CAction::CName &name) const
{
const CBaseAction *baseAction= getBaseAction(name);
if(!baseAction)
return ucstring();
return string();
return baseAction->getActionLocalizedText(name);
}

@ -248,7 +248,7 @@ public:
std::string Contexts;
/// Get an action localized text
ucstring getActionLocalizedText (const CAction::CName &name) const;
std::string getActionLocalizedText (const CAction::CName &name) const;
// see if there's at least one set of parameters for which this action is usable in current context
bool isUsableInCurrentContext() const;
@ -417,7 +417,7 @@ public:
const TActionsForceDisplaySet &getActionsForceDisplaySet() const {return _ActionForceDisplay;}
/// Get an action localized text
ucstring getActionLocalizedText (const CAction::CName &name) const;
std::string getActionLocalizedText (const CAction::CName &name) const;
//@}

@ -65,7 +65,7 @@ void CAnimationFX::buildTrack(NL3D::UAnimationSet *as)
nlassert(Sheet != NULL);
if (!as) return;
if (Sheet->TrajectoryAnim.empty()) return;
std::string animName = NLMISC::toLower(Sheet->TrajectoryAnim);
std::string animName = NLMISC::toLowerAscii(Sheet->TrajectoryAnim);
uint id = as->getAnimationIdByName(animName);
NL3D::UAnimation *anim = NULL;
if (id != NL3D::UAnimationSet::NotFound)

@ -84,7 +84,7 @@ void initAutoAnimation()
file.getline(line, 512);
// Read the animation file
string animName = toLower(CFile::getFilenameWithoutExtension(line));
string animName = toLowerAscii(CFile::getFilenameWithoutExtension(line));
uint id = AutoAnimSet->addAnimation (line, animName.c_str ());
if (id == UAnimationSet::NotFound)
{

@ -19,6 +19,9 @@
#include "stdpch.h"
#include "bg_downloader_access.h"
#ifdef RYZOM_BG_DOWNLOADER
#include "global.h"
#include "login_patch.h"
//
@ -84,7 +87,7 @@ CBGDownloaderAccess::CBGDownloaderAccess()
//=====================================================
void CBGDownloaderAccess::clearCurrentMessage()
{
_CurrentMessage = ucstring();
_CurrentMessage = ucstring(); // OLD
_CurrentFilesToGet = 0;
_TotalFilesToGet = 0;
_PatchingSize = 0;
@ -194,7 +197,7 @@ void CBGDownloaderAccess::startTask(const BGDownloader::CTaskDesc &taskDesc, con
}
//=====================================================
bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const
bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const // OLD
{
if (_State == State_Finished)
{
@ -354,7 +357,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run()
{
shutdownDownloader();
Parent->_TaskResult = TaskResult_Error;
Parent->_ErrorMsg = ucstring(e.what());
Parent->_ErrorMsg = ucstring(e.what()); // OLD
Parent->_DownloadThreadPriority = ThreadPriority_DownloaderError;
}
catch(const NLMISC::EStream &e)
@ -362,7 +365,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run()
shutdownDownloader();
Parent->_TaskResult = TaskResult_Error;
nlwarning("BG DOWNLOADER PROTOCOL ERROR ! Stream error");
Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what());
Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what()); // OLD
Parent->_DownloadThreadPriority = ThreadPriority_DownloaderError;
}
catch (const EWaitMessageTimeoutException &e)
@ -370,7 +373,7 @@ void CBGDownloaderAccess::CDownloadCoTask::run()
shutdownDownloader();
Parent->_TaskResult = TaskResult_Error;
nlwarning("BG DOWNLOADER PROTOCOL ERROR ! Message timeout");
Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what());
Parent->_ErrorMsg = CI18N::get("uiBGD_ProtocolError") + ucstring(" : ") + ucstring(e.what()); // OLD
Parent->_DownloadThreadPriority = ThreadPriority_DownloaderError;
}
Parent->_State = State_Finished;
@ -614,7 +617,7 @@ TDownloaderMode CBGDownloaderAccess::CDownloadCoTask::getDownloaderMode()
void CBGDownloaderAccess::CDownloadCoTask::getTaskResult(TTaskResult &result,
uint32 &availablePatchs,
bool &mustLaunchBatFile,
ucstring &errorMsg
ucstring &errorMsg // OLD
)
{
sendSimpleMsg(CL_GetTaskResult);
@ -623,7 +626,7 @@ void CBGDownloaderAccess::CDownloadCoTask::getTaskResult(TTaskResult &result,
inMsg.serialEnum(result);
inMsg.serial(availablePatchs);
inMsg.serial(mustLaunchBatFile);
inMsg.serial(errorMsg);
inMsg.serial(errorMsg); // OLD
}
//=====================================================
@ -687,7 +690,7 @@ void CBGDownloaderAccess::CDownloadCoTask::shutdownDownloader()
}
}
CWinProcess::terminateProcessFromModuleName(BGDownloaderName); // for safety
Parent->_CurrentMessage = ucstring();
Parent->_CurrentMessage = ucstring(); // OLD
}
//=====================================================
@ -795,7 +798,7 @@ bool CBGDownloaderAccess::CDownloadCoTask::defaultMessageHandling(BGDownloader::
case BGD_Error:
{
Parent->_TaskResult = TaskResult_Error;
ucstring errorMsg;
ucstring errorMsg; // OLD
msg.serial(errorMsg);
throw EDownloadException(errorMsg.toUtf8());
}
@ -885,7 +888,7 @@ void CBGDownloaderAccess::startTask(const BGDownloader::CTaskDesc &taskDesc, con
}
//=====================================================
bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const
bool CBGDownloaderAccess::isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const // OLD
{
// TODO for Linux
return false;
@ -956,3 +959,5 @@ void unpauseBGDownloader()
DownloaderPaused = false;
}
}
#endif

@ -14,11 +14,12 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef RYZOM_BG_DOWNLOADER
#ifndef CL_BG_DOWNLOADER_ACCESS
#define CL_BG_DOWNLOADER_ACCESS
#include "nel/misc/singleton.h"
#include "nel/misc/ucstring.h"
#include "nel/misc/ucstring.h" // OLD
#include "nel/misc/inter_window_msg_queue.h"
#include "nel/misc/co_task.h"
//
@ -36,7 +37,7 @@ public:
void release();
// jobs
void startTask(const BGDownloader::CTaskDesc &taskDesc, const std::string &commandLine, bool showDownloader);
bool isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const;
bool isTaskEnded(BGDownloader::TTaskResult &result, ucstring &errorMsg) const; // OLD
// The following flag will be true after a 'patch' task has been completed successfully
bool getPatchCompletionFlag(bool clearFlag);
//
@ -50,7 +51,7 @@ public:
//
void update(); // call this at each frame to update the download process
// Get last displayed message by the background downloader
const ucstring &getCurrentMessage() const { return _CurrentMessage; }
const ucstring &getCurrentMessage() const { return _CurrentMessage; } // OLD
uint32 getCurrentFilesToGet() const { return _CurrentFilesToGet; }
uint32 getTotalFilesToGet() const { return _TotalFilesToGet; }
//
@ -66,17 +67,17 @@ public:
bool isDownloaderUIFrozen() const { return _FrozenUI; }
void requestDownloadThreadPriority(BGDownloader::TThreadPriority newPriority, bool freezeUI);
const ucstring &getLastErrorMessage() const { return _ErrorMsg; }
const ucstring &getLastErrorMessage() const { return _ErrorMsg; } // OLD
private:
enum TState { State_Idle, State_Patching, State_Finished };
TState _State;
ucstring _CurrentMessage;
ucstring _CurrentMessage; // OLD
#ifdef NL_OS_WINDOWS
NLMISC::CInterWindowMsgQueue _DownloaderMsgQueue;
#endif
ucstring _ErrorMsg;
ucstring _ErrorMsg; // OLD
std::string _CommandLine;
BGDownloader::TTaskResult _TaskResult;
uint32 _AvailablePatchs;
@ -122,7 +123,7 @@ private:
void getTaskResult(BGDownloader::TTaskResult &result,
uint32 &availablePatchs,
bool &mustLaunchBatFile,
ucstring &errorMsg
ucstring &errorMsg // OLD
);
void getDescFile();
BGDownloader::TDownloaderMode getDownloaderMode();
@ -146,3 +147,4 @@ void unpauseBGDownloader();
#endif
#endif

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// FIXME: Lost code
#if 0
#ifndef CL_CANDIDATE_H
@ -33,7 +34,7 @@ struct Candidate
NLMISC::CEntityId id;
std::string name;
std::string surname;
std::list<ucstring> program;
std::list<std::string> program;
uint32 nbVotes;
};

@ -617,7 +617,7 @@ uint32 CCharacterCL::buildEquipment(const CCharacterSheet::CEquipment &slot, SLO
{
// IS the item a valid one ?
CSheetId itemId;
if(itemId.buildSheetId(NLMISC::toLower(slot.getItem())))
if(itemId.buildSheetId(NLMISC::toLowerAscii(slot.getItem())))
{
// Is it stored in the database ?
CEntitySheet *entitySheet = SheetMngr.get(itemId);
@ -1105,7 +1105,7 @@ string CCharacterCL::automatonType() const // virtual
//-----------------------------------------------
void CCharacterCL::computeAutomaton()
{
_CurrentAutomaton = automatonType() + "_" + NLMISC::toLower(MBEHAV::modeToString(_Mode)) + ".automaton";
_CurrentAutomaton = automatonType() + "_" + NLMISC::toLowerAscii(MBEHAV::modeToString(_Mode)) + ".automaton";
}// computeAutomaton //
@ -10250,11 +10250,11 @@ NLMISC_COMMAND(setNamePosZ, "", "<low/high/normal> <value>")
CRaceStatsSheet *sheet = const_cast<CRaceStatsSheet*>(playerTarget->playerSheet());
if (sheet)
{
if (toLower(args[0]) == "low")
if (toLowerAscii(args[0]) == "low")
namePosZ = &sheet->GenderInfos[playerTarget->getGender()].NamePosZLow;
else if (toLower(args[0]) == "normal")
else if (toLowerAscii(args[0]) == "normal")
namePosZ = &sheet->GenderInfos[playerTarget->getGender()].NamePosZNormal;
else if (toLower(args[0]) == "high")
else if (toLowerAscii(args[0]) == "high")
namePosZ = &sheet->GenderInfos[playerTarget->getGender()].NamePosZHigh;
sheetName = sheet->Id.toString();
@ -10270,11 +10270,11 @@ NLMISC_COMMAND(setNamePosZ, "", "<low/high/normal> <value>")
CCharacterSheet *sheet = const_cast<CCharacterSheet*>(creatureTarget->getSheet());
if (sheet)
{
if (toLower(args[0]) == "low")
if (toLowerAscii(args[0]) == "low")
namePosZ = &sheet->NamePosZLow;
else if (toLower(args[0]) == "normal")
else if (toLowerAscii(args[0]) == "normal")
namePosZ = &sheet->NamePosZNormal;
else if (toLower(args[0]) == "high")
else if (toLowerAscii(args[0]) == "high")
namePosZ = &sheet->NamePosZHigh;
sheetName = sheet->Id.toString();
@ -10301,11 +10301,11 @@ NLMISC_COMMAND(setMyNamePosZ, "", "<low/high/normal> <value>")
CRaceStatsSheet *sheet = const_cast<CRaceStatsSheet*>(UserEntity->playerSheet());
if (sheet)
{
if (toLower(args[0]) == "low")
if (toLowerAscii(args[0]) == "low")
namePosZ = &sheet->GenderInfos[UserEntity->getGender()].NamePosZLow;
else if (toLower(args[0]) == "normal")
else if (toLowerAscii(args[0]) == "normal")
namePosZ = &sheet->GenderInfos[UserEntity->getGender()].NamePosZNormal;
else if (toLower(args[0]) == "high")
else if (toLowerAscii(args[0]) == "high")
namePosZ = &sheet->GenderInfos[UserEntity->getGender()].NamePosZHigh;
sheetName = sheet->Id.toString();

@ -302,7 +302,7 @@ int main(int argc, char **argv)
uint i;
for (i=0; i<files.size(); i++)
{
if (toLower(CFile::getExtension (files[i])) == "ttf")
if (toLowerAscii(CFile::getExtension (files[i])) == "ttf")
CFile::deleteFile (files[i]);
}
}

@ -1436,7 +1436,7 @@ void CClientConfig::setValues()
else if (stricmp(mode, "centeraround") == 0) p.Mode = SSysInfoParam::CenterAround;
else if (stricmp(mode, "around") == 0) p.Mode = SSysInfoParam::Around;
ClientCfg.SystemInfoParams[toLower(sic->asString(2 * k))] = p;
ClientCfg.SystemInfoParams[toLowerAscii(sic->asString(2 * k))] = p;
}
}
}
@ -1851,7 +1851,7 @@ void CClientConfig::setValues()
ClientCfg.HardwareCursors.clear ();
int iSz = pcvHardwareCursors->size();
for (int i = 0; i < iSz; i++)
ClientCfg.HardwareCursors.insert(toLower(pcvHardwareCursors->asString(i)));
ClientCfg.HardwareCursors.insert(toLowerAscii(pcvHardwareCursors->asString(i)));
}
else
{
@ -2018,7 +2018,7 @@ void CClientConfig::init(const string &configFileName)
}
// read the exising config file (don't parse it yet!)
ucstring content;
ucstring content; // UTF-16 and UTF-8 textfile support
NLMISC::CI18N::readTextFile(configFileName, content);
std::string contentUtf8 = content.toUtf8();

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save