Merge remote-tracking branch 'upstream/develop' into ryzomcore

This commit is contained in:
deed 2019-05-05 16:50:36 +02:00
commit 520b8d1bb9
264 changed files with 9421 additions and 7446 deletions

24
code/.clang-format Normal file
View file

@ -0,0 +1,24 @@
---
BasedOnStyle: WebKit
AllowShortFunctionsOnASingleLine: All
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
BreakBeforeBraces: Custom
BreakConstructorInitializersBeforeComma: 'false'
NamespaceIndentation: None
PointerAlignment: Right
SortIncludes: 'false'
TabWidth: '4'
UseTab: ForIndentation
...

23
code/.editorconfig Normal file
View file

@ -0,0 +1,23 @@
; Top-most EditorConfig file
root = true
; 4-column tab indentation
[*.cpp]
indent_style = tab
indent_size = 4
[*.c]
indent_style = tab
indent_size = 4
[*.h]
indent_style = tab
indent_size = 4
[*.py]
indent_style = tab
indent_size = 4
[*.config]
indent_style = space
indent_size = 2

View file

@ -11,18 +11,56 @@ if(MAXSDK_INCLUDE_DIR)
SET(MAXSDK_FIND_QUIETLY TRUE)
endif()
set(_pf_x86 "PROGRAMFILES(x86)")
FIND_PATH(MAXSDK_DIR
"include/maxversion.h"
HINTS
"$ENV{MAXSDK_DIR}"
PATHS
"$ENV{ADSK_3DSMAX_SDK_2021}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2020}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2019}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2018}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2017}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2016}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2015}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2014}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2013}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2012}/maxsdk"
"$ENV{3DSMAX_2011_SDK_PATH}/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2021 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2020 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2019 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2018 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2017 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2016 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2015 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2014 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2013 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2012 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2011 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2010 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2009 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2008 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 9 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3dsMax8/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2021 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2020 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2019 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2018 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2017 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2016 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2015 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2014 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2013 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2012 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2011 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3dsMax8/maxsdk"
)
FIND_PATH(MAXSDK_INCLUDE_DIR

View file

@ -16,10 +16,12 @@ IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
ELSE()
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
PATH_SUFFIXES mysql
PATH_SUFFIXES mysql mariadb
PATHS
/usr/include/mysql
/usr/include/mariadb
/usr/local/include/mysql
/usr/local/include/mariadb
/opt/local/include/mysql5/mysql
/opt/local/include/mysql55/mysql
/opt/local/include/mysql51/mysql
@ -27,28 +29,29 @@ ELSE()
$ENV{SystemDrive}/MySQL/*/include)
IF(WIN32 AND MSVC)
FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES libmysql mysqlclient
FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES libmysql mysqlclient libmariadb mariadbclient
PATHS
$ENV{ProgramFiles}/MySQL/*/lib/opt
$ENV{SystemDrive}/MySQL/*/lib/opt)
FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES libmysqld mysqlclientd
FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES libmysqld mysqlclientd libmariadb mariadbclient
PATHS
$ENV{ProgramFiles}/MySQL/*/lib/opt
$ENV{SystemDrive}/MySQL/*/lib/opt)
ELSE()
FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient
FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient mariadbclient
PATHS
/usr/lib
/usr/local/lib
/usr/lib/mariadb
/usr/lib/mysql
/usr/local/lib/mysql
/usr/local/lib/mariadb
/opt/local/lib/mysql5/mysql
/opt/local/lib/mysql55/mysql
/opt/local/lib/mysql51/mysql
)
FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES mysqlclientd
FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES mysqlclientd mariadbclientd
PATHS
/usr/lib
/usr/local/lib
@ -80,6 +83,10 @@ ELSE()
IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
SET(MYSQL_FOUND TRUE)
MESSAGE(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}")
IF (MYSQL_LIBRARIES MATCHES "libmariadb" OR MYSQL_LIBRARIES MATCHES "mariadbclient")
SET(MARIADB_FOUND TRUE)
MESSAGE(STATUS "Found MariaDB.")
ENDIF()
ELSE()
SET(MYSQL_FOUND FALSE)
MESSAGE(STATUS "MySQL not found.")

View file

@ -568,6 +568,11 @@ MACRO(NL_SETUP_BUILD)
ADD_PLATFORM_FLAGS("-DENABLE_LOGS")
ENDIF()
SET(CUSTOM_FLAGS "" CACHE STRING "Custom compile flags (useful for /MPn)")
IF(NOT ${CUSTOM_FLAGS} STREQUAL "")
ADD_PLATFORM_FLAGS(${CUSTOM_FLAGS})
ENDIF()
IF(MSVC)
# Ignore default include paths
ADD_PLATFORM_FLAGS("/X")

View file

@ -0,0 +1,150 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef CL_CSS_PARSER_H
#define CL_CSS_PARSER_H
#include "nel/misc/types_nl.h"
#include "nel/gui/css_style.h"
#include "nel/gui/css_selector.h"
namespace NLGUI
{
/**
* \brief CSS style parsing
* \date 2019-03-15 10:50 GMT
* \author Meelis Mägi (Nimetu)
*/
class CCssParser {
public:
// parse style declaration, eg "color: red; font-size: 10px;"
static TStyle parseDecls(const std::string &styleString);
// parse css stylesheet
void parseStylesheet(const std::string &cssString, std::vector<CCssStyle::SStyleRule> &rules);
private:
// stylesheet currently parsed
ucstring _Style;
// keep track of current position in _Style
size_t _Position;
std::vector<CCssStyle::SStyleRule> _Rules;
private:
// @media ( .. ) { .. }
void readAtRule();
// a#id.class[attr=val] { .. }
void readRule();
// move past whitespace
void skipWhitespace();
// skip valid IDENT
bool skipIdentifier();
// skip over {}, (), or [] block
void skipBlock();
// skip over string quoted with ' or "
void skipString();
// backslash escape
void escape();
// normalize newline chars and remove comments
void preprocess();
// parse selectors + combinators
std::vector<CCssSelector> parse_selector(const ucstring &sel, std::string &pseudoElement) const;
// parse selector and style
void parseRule(const ucstring &selectorString, const ucstring &styleString);
inline bool is_eof() const
{
return _Position >= _Style.size();
}
inline bool is_whitespace(ucchar ch) const
{
return (ch == (ucchar)' ' || ch == (ucchar)'\t' || ch == (ucchar)'\n');
}
inline bool is_hex(ucchar ch) const
{
return ((ch >= (ucchar)'0' && ch <= (ucchar)'9') ||
(ch >= (ucchar)'a' && ch <= (ucchar)'f') ||
(ch >= (ucchar)'A' && ch <= (ucchar)'F'));
}
inline bool maybe_escape() const
{
// escaping newline (\n) only allowed inside strings
return (_Style.size() - _Position) >= 1 && _Style[_Position] == (ucchar)'\\' && _Style[_Position+1] != '\n';
}
inline bool is_quote(ucchar ch) const
{
return ch== (ucchar)'"' || ch == (ucchar)'\'';
}
inline bool is_block_open(ucchar ch) const
{
return ch == (ucchar)'{' || ch == (ucchar)'[' || ch == (ucchar)'(';
}
inline bool is_block_close(ucchar ch, ucchar open) const
{
return ((open == '{' && ch == (ucchar)'}') ||
(open == '[' && ch == (ucchar)']') ||
(open == '(' && ch == (ucchar)')'));
}
inline bool is_comment_open() const
{
if (_Position+1 > _Style.size())
return false;
return _Style[_Position] == (ucchar)'/' && _Style[_Position+1] == (ucchar)'*';
}
inline bool is_nonascii(ucchar ch) const
{
return ch >= 0x80 /*&& ch <= 255*/;
}
inline bool is_alpha(ucchar ch) const
{
return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
}
inline bool is_digit(ucchar ch) const
{
return ch >= '0' && ch <= '9';
}
inline bool is_nmchar(ucchar ch) const
{
// checking escape here does not check if next char is '\n' or not
return ch == '_' || ch == '-' || is_alpha(ch) || is_digit(ch) || is_nonascii(ch) || ch == '\\'/*is_escape(ch)*/;
}
};
}//namespace
#endif // CL_CSS_PARSER_H

View file

@ -0,0 +1,107 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef CL_CSS_SELECTOR_H
#define CL_CSS_SELECTOR_H
#include "nel/misc/types_nl.h"
namespace NLGUI
{
class CHtmlElement;
/**
* \brief CSS selector
* \date 2019-03-15 10:50 GMT
* \author Meelis Mägi (Nimetu)
*/
class CCssSelector
{
public:
enum ECombinator {
NONE = 0,
GENERAL_CHILD,
ADJACENT_SIBLING,
GENERAL_SIBLING,
CHILD_OF
};
struct SAttribute {
std::string key;
std::string value;
char op; // =, ~, |, ^, $, *
SAttribute(const std::string &k, const std::string &v, char o)
:key(k),value(v),op(o)
{}
};
std::string Element;
std::string Id;
std::vector<std::string> Class;
std::vector<SAttribute> Attr;
std::vector<std::string> PseudoClass;
// css combinator or \0 missing (first element)
char Combinator;
public:
// TODO: rewrite for ECombinator enum
CCssSelector(std::string elm="", std::string id="", std::string cls="", char comb = '\0');
// helper for sorting
uint32 specificity() const;
// set classes used, eg 'class1 class2'
void setClass(const std::string &cls);
// add attribute to selector
// ' ' op means 'key exists, ignore value'
void addAttribute(const std::string &key, const std::string &val = "", char op = ' ');
// add pseudo class to selector, eg 'first-child'
void addPseudoClass(const std::string &key);
// true if no rules have been defined
bool empty() const
{
return Element.empty() && Id.empty() && Class.empty() && Attr.empty() && PseudoClass.empty();
}
// Test current selector to html DOM element
// NOTE: Does not check combinator
bool match(const CHtmlElement &elm) const;
private:
bool matchClass(const CHtmlElement &elm) const;
bool matchAttributes(const CHtmlElement &elm) const;
bool matchPseudoClass(const CHtmlElement &elm) const;
// match An+B rule to child index (1 based)
bool matchNth(sint childNr, sint a, sint b) const;
// parse nth-child string to 'a' and 'b' components
// :nth-child(odd)
// :nth-child(even)
// :nth-child(An+B)
// :nth-child(-An+b)
void parseNth(const std::string &pseudo, sint &a, sint &b) const;
};
}//namespace
#endif // CL_CSS_SELECTOR_H

View file

@ -0,0 +1,227 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef CL_CSS_STYLE_H
#define CL_CSS_STYLE_H
#include "nel/misc/types_nl.h"
#include "nel/misc/rgba.h"
#include "nel/gui/css_selector.h"
namespace NLGUI
{
class CHtmlElement;
typedef std::map<std::string, std::string> TStyle;
/**
* \brief CSS style rules
* \date 2019-03-15 10:50 GMT
* \author Meelis Mägi (Nimetu)
*/
class CStyleParams
{
public:
struct STextShadow
{
public:
STextShadow(bool enabled = false, bool outline = false, sint32 x=1, sint32 y=1, NLMISC::CRGBA color=NLMISC::CRGBA::Black)
: Enabled(enabled), Outline(outline), X(x), Y(y), Color(color)
{ }
bool Enabled;
bool Outline;
sint32 X;
sint32 Y;
NLMISC::CRGBA Color;
};
public:
CStyleParams () : FontFamily(""), TextColor(255,255,255,255), TextShadow()
{
FontSize=10;
FontWeight=400;
FontOblique=false;
Underlined=false;
StrikeThrough=false;
GlobalColor=false;
Width=-1;
Height=-1;
MaxWidth=-1;
MaxHeight=-1;
BorderWidth=1;
BackgroundColor=NLMISC::CRGBA::Black;
BackgroundColorOver=NLMISC::CRGBA::Black;
}
bool hasStyle(const std::string &key) const
{
return StyleRules.find(key) != StyleRules.end();
}
std::string getStyle(const std::string &key) const
{
TStyle::const_iterator it = StyleRules.find(key);
return (it != StyleRules.end() ? it->second : "");
}
public:
uint FontSize;
uint FontWeight;
bool FontOblique;
std::string FontFamily;
NLMISC::CRGBA TextColor;
STextShadow TextShadow;
bool GlobalColor;
bool Underlined;
bool StrikeThrough;
sint32 Width;
sint32 Height;
sint32 MaxWidth;
sint32 MaxHeight;
sint32 BorderWidth;
NLMISC::CRGBA BackgroundColor;
NLMISC::CRGBA BackgroundColorOver;
std::string WhiteSpace;
std::string TextAlign;
std::string VerticalAlign;
TStyle StyleRules;
};
class CCssStyle {
public:
struct SStyleRule {
std::vector<CCssSelector> Selector;
TStyle Properties;
// pseudo element like ':before'
std::string PseudoElement;
// returns selector specificity
uint specificity() const;
};
// 'browser' style, overwriten with '<html>'
CStyleParams Root;
// current element style
CStyleParams Current;
// known style rules sorted by specificity
std::vector<SStyleRule> _StyleRules;
private:
std::vector<CStyleParams> _StyleStack;
// test if str is one of "thin/medium/thick" and return its pixel value
bool scanCssLength(const std::string& str, uint32 &px) const;
// read style attribute
void getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams &current) const;
void getStyleParams(const TStyle &styleRules, CStyleParams &style, const CStyleParams &current) const;
// extract from styleRules into style.StyleRules (expand shorthand, normalize, calculate current font-size)
void normalize(const TStyle &styleRules, CStyleParams &style, const CStyleParams &current) const;
// apply style.StyleRyles
void apply(CStyleParams &style, const CStyleParams &current) const;
// merge src into dest by overwriting key in dest
void merge(TStyle &dst, const TStyle &src) const;
// match selector to dom path
bool match(const std::vector<CCssSelector> &selector, const CHtmlElement &elm) const;
// parse 'background' into 'background-color', 'background-image', etc
void parseBackgroundShorthand(const std::string &value, CStyleParams &style) const;
public:
void reset();
// parse <style>..</style> tag or css file content
void parseStylesheet(const std::string &styleString);
// set element style from matching css rules
void getStyleFor(CHtmlElement &elm) const;
inline uint getFontSizeSmaller() const
{
if (Current.FontSize < 5)
return 3;
return Current.FontSize-2;
}
sint styleStackIndex = 0;
inline void pushStyle()
{
styleStackIndex++;
_StyleStack.push_back(Current);
Current.Width=-1;
Current.Height=-1;
Current.MaxWidth=-1;
Current.MaxHeight=-1;
Current.BorderWidth=1;
Current.StyleRules.clear();
}
inline void popStyle()
{
styleStackIndex--;
if (_StyleStack.empty())
{
Current = Root;
}
else
{
Current = _StyleStack.back();
_StyleStack.pop_back();
}
}
// apply style to this.Root
void applyRootStyle(const std::string &styleString);
void applyRootStyle(const TStyle &styleRules);
// apply style to this.Current
void applyStyle(const std::string &styleString);
void applyStyle(const TStyle &styleRules);
void applyCssMinMax(sint32 &width, sint32 &height, sint32 minw=0, sint32 minh=0, sint32 maxw=0, sint32 maxh=0) const;
// check if current style property matches value
bool checkStyle(const std::string &key, const std::string &val) const
{
return Current.hasStyle(key) && Current.getStyle(key) == val;
}
bool hasStyle(const std::string &key) const
{
return Current.hasStyle(key);
}
std::string getStyle(const std::string &key) const
{
return Current.getStyle(key);
}
};
}//namespace
#endif // CL_CSS_STYLE_H

View file

@ -23,13 +23,12 @@
#include "nel/gui/group_tree.h"
#include "nel/gui/ctrl_button.h"
#include "nel/gui/group_table.h"
#include "nel/gui/libwww_types.h"
#include "nel/gui/html_element.h"
#include "nel/gui/css_style.h"
// forward declaration
typedef void CURLM;
typedef std::map<std::string, std::string> TStyle;
namespace NLGUI
{
class CCtrlButton;
@ -69,67 +68,15 @@ namespace NLGUI
/// Maximum concurrent MultiCurl connections per CGroupHTML instance
sint32 curlMaxConnections;
SWebOptions(): curlMaxConnections(2)
SWebOptions(): curlMaxConnections(5)
{
}
};
static SWebOptions options;
// text-shadow
struct STextShadow
{
public:
STextShadow(bool enabled = false, bool outline = false, sint32 x=1, sint32 y=1, NLMISC::CRGBA color=NLMISC::CRGBA::Black)
: Enabled(enabled), Outline(outline), X(x), Y(y), Color(color)
{ }
bool Enabled;
bool Outline;
sint32 X;
sint32 Y;
NLMISC::CRGBA Color;
};
class CStyleParams
{
public:
CStyleParams () : FontFamily(""), TextColor(255,255,255,255), TextShadow()
{
FontSize=10;
FontWeight=400;
FontOblique=false;
Underlined=false;
StrikeThrough=false;
GlobalColor=false;
Width=-1;
Height=-1;
MaxWidth=-1;
MaxHeight=-1;
BorderWidth=1;
BackgroundColor=NLMISC::CRGBA::Black;
BackgroundColorOver=NLMISC::CRGBA::Black;
}
uint FontSize;
uint FontWeight;
bool FontOblique;
std::string FontFamily;
NLMISC::CRGBA TextColor;
STextShadow TextShadow;
bool GlobalColor;
bool Underlined;
bool StrikeThrough;
sint32 Width;
sint32 Height;
sint32 MaxWidth;
sint32 MaxHeight;
sint32 BorderWidth;
NLMISC::CRGBA BackgroundColor;
NLMISC::CRGBA BackgroundColorOver;
};
// ImageDownload system
enum TDataType {ImgType= 0, BnpType};
enum TDataType {ImgType= 0, BnpType, StylesheetType};
enum TImageType {NormalImage=0, OverImage};
// Constructor
@ -150,8 +97,11 @@ namespace NLGUI
// Browse
virtual void browse (const char *url);
// load css from local file and insert into active stylesheet collection
void parseStylesheetFile(const std::string &fname);
// parse html string using libxml2 parser
virtual bool parseHtml(std::string htmlString);
bool parseHtml(const std::string &htmlString);
// Refresh
void refresh();
@ -162,13 +112,8 @@ namespace NLGUI
// Browse error
void browseError (const char *msg);
// stop browse
void stopBrowse ();
bool isBrowsing();
void clean() { stopBrowse(); updateRefreshButton(); removeContent(); }
// Update coords
void updateCoords();
@ -287,8 +232,6 @@ namespace NLGUI
int luaInsertText(CLuaState &ls);
int luaAddString(CLuaState &ls);
int luaAddImage(CLuaState &ls);
int luaBeginElement(CLuaState &ls);
int luaEndElement(CLuaState &ls);
int luaShowDiv(CLuaState &ls);
int luaParseHtml(CLuaState &ls);
int luaRenderHtml(CLuaState &ls);
@ -302,8 +245,6 @@ namespace NLGUI
REFLECT_LUA_METHOD("insertText", luaInsertText)
REFLECT_LUA_METHOD("addString", luaAddString)
REFLECT_LUA_METHOD("addImage", luaAddImage)
REFLECT_LUA_METHOD("beginElement", luaBeginElement)
REFLECT_LUA_METHOD("endElement", luaEndElement)
REFLECT_LUA_METHOD("showDiv", luaShowDiv)
REFLECT_LUA_METHOD("parseHtml", luaParseHtml)
REFLECT_LUA_METHOD("renderHtml", luaRenderHtml)
@ -316,26 +257,20 @@ namespace NLGUI
// \name callback from libwww
// Begin of the parsing of a HTML document
// Begin of the rendering of a HTML document
virtual void beginBuild ();
// End of the parsing of a HTML document
// End of the rendering of a HTML document
virtual void endBuild ();
// A new text block has been parsed
virtual void addText (const char * buf, int len);
// A new begin HTML element has been parsed (<IMG> for exemple)
virtual void beginElement (uint element_number, const std::vector<bool> &present, const std::vector<const char *> &value);
virtual void beginElement(CHtmlElement &elm);
// A new end HTML element has been parsed (</IMG> for exemple)
virtual void endElement (uint element_number);
// A new begin unparsed element has been found
virtual void beginUnparsedElement(const char *buffer, int length);
// A new end unparsed element has been found
virtual void endUnparsedElement(const char *buffer, int length);
virtual void endElement(CHtmlElement &elm);
// Add GET params to the url
virtual void addHTTPGetParams (std::string &url, bool trustedDomain);
@ -343,16 +278,12 @@ namespace NLGUI
// Add POST params to the libwww list
virtual void addHTTPPostParams (SFormFields &formfields, bool trustedDomain);
// the current request is terminated
virtual void requestTerminated();
// libxml2 html parser functions
void htmlElement(xmlNode *node, int element_number);
void htmlWalkDOM(xmlNode *a_node);
// Get Home URL
virtual std::string home();
// parse dom node and all child nodes recursively
void renderDOM(CHtmlElement &elm);
// Clear style stack and restore default style
void resetCssStyle();
@ -383,7 +314,7 @@ namespace NLGUI
void addString(const ucstring &str);
// Add an image in the current paragraph
void addImage(const std::string &id, const char *image, bool reloadImg=false, const CStyleParams &style = CStyleParams());
void addImage(const std::string &id, const std::string &img, bool reloadImg=false, const CStyleParams &style = CStyleParams());
// Add a text area in the current paragraph
CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength);
@ -422,6 +353,14 @@ namespace NLGUI
// Current URL
std::string _DocumentUrl;
std::string _DocumentDomain;
std::string _DocumentHtml; // not updated, only set by first render
// If true, then render _DocumentHtml on next update (replaces content)
bool _RenderNextTime;
// true if renderer is waiting for css files to finish downloading (link rel=stylesheet)
bool _WaitingForStylesheet;
// list of css file urls that are queued up for download
std::vector<std::string> _StylesheetQueue;
// Valid base href was found
bool _IgnoreBaseUrlTag;
// Fragment from loading url
@ -454,7 +393,6 @@ namespace NLGUI
// Browsing..
bool _Browsing;
bool _Connecting;
double _TimeoutValue; // the timeout in seconds
double _ConnectingTimeout;
sint _RedirectsRemaining;
@ -539,33 +477,13 @@ namespace NLGUI
// IL mode
bool _LI;
// Current active style
CStyleParams _Style;
// Default style
CStyleParams _StyleDefault;
// Nested style stack
std::vector<CStyleParams> _StyleParams;
inline void pushStyle()
{
_StyleParams.push_back(_Style);
}
inline void popStyle()
{
if (_StyleParams.empty())
_Style = _StyleDefault;
else
{
_Style = _StyleParams.back();
_StyleParams.pop_back();
}
}
inline uint getFontSizeSmaller() const
{
if (_Style.FontSize < 5)
return 3;
return _Style.FontSize-2;
}
// Keep track of current element style
CCssStyle _Style;
CHtmlElement _HtmlDOM;
CHtmlElement *_CurrentHTMLElement;
// Backup of CurrentHTMLElement->nextSibling before ::beginElement() is called
// for luaParseHtml() to insert nodes into right place in right order
CHtmlElement *_CurrentHTMLNextSibling;
// Current link
std::vector<std::string> _Link;
@ -629,14 +547,6 @@ namespace NLGUI
return _TR.back();
}
std::vector<STextShadow> _TextShadow;
inline STextShadow getTextShadow() const
{
if (_TextShadow.empty())
return STextShadow();
return _TextShadow.back();
}
// Forms
class CForm
{
@ -798,10 +708,6 @@ namespace NLGUI
typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap;
static TGroupHtmlByUIDMap _GroupHtmlByUID;
// read style attribute
void getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams &current);
void applyCssMinMax(sint32 &width, sint32 &height, sint32 minw=0, sint32 minh=0, sint32 maxw=0, sint32 maxh=0);
// load and render local html file (from bnp for example)
void doBrowseLocalFile(const std::string &filename);
@ -815,6 +721,11 @@ namespace NLGUI
void buildHTTPPostParams (SFormFields &formfields);
private:
friend class CHtmlParser;
// move src->Children into CurrentHtmlElement.parent.children element
void spliceFragment(std::list<CHtmlElement>::iterator src);
// decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str);
@ -834,10 +745,11 @@ namespace NLGUI
{
public:
CDataDownload(const std::string &u, const std::string &d, TDataType t, CViewBase *i, const std::string &s, const std::string &m, const CStyleParams &style = CStyleParams(), const TImageType imagetype = NormalImage)
: data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0)
: data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0), ConnectionTimeout(60)
{
if (t == ImgType) imgs.push_back(CDataImageDownload(i, style, imagetype));
}
~CDataDownload();
public:
CCurlWWWData *data;
@ -849,13 +761,16 @@ namespace NLGUI
uint32 redirects;
FILE *fp;
std::vector<CDataImageDownload> imgs;
uint32 ConnectionTimeout;
};
std::vector<CDataDownload> Curls;
std::list<CDataDownload> Curls;
CURLM *MultiCurl;
int RunningCurls;
bool startCurlDownload(CDataDownload &download);
void finishCurlDownload(const CDataDownload &download);
void pumpCurlQueue();
void initImageDownload();
void checkImageDownload();
@ -874,11 +789,103 @@ namespace NLGUI
bool addBnpDownload(std::string url, const std::string &action, const std::string &script, const std::string &md5sum);
std::string localBnpName(const std::string &url);
// add css file from <link href=".." rel="stylesheet"> to download queue
void addStylesheetDownload(std::vector<std::string> links);
// stop all curl downalods (html and data)
void releaseDownloads();
void checkDownloads();
// _CurlWWW download finished
void htmlDownloadFinished(bool success, const std::string &error);
// images, stylesheets, etc finished downloading
void dataDownloadFinished(bool success, const std::string &error, CDataDownload &data);
// HtmlType download finished
void htmlDownloadFinished(const std::string &content, const std::string &type, long code);
// stylesheet finished downloading. if local file does not exist, then it failed (404)
void cssDownloadFinished(const std::string &url, const std::string &local);
// read common table/tr/td parameters and push them to _CellParams
void getCellsParameters(const CHtmlElement &elm, bool inherit);
// render _HtmlDOM
void renderDocument();
// :before, :after rendering
void renderPseudoElement(const std::string &pseudo, const CHtmlElement &elm);
// apply background from current style (for html, body)
void applyBackground(const CHtmlElement &elm);
// HTML elements
void htmlA(const CHtmlElement &elm);
void htmlAend(const CHtmlElement &elm);
void htmlBASE(const CHtmlElement &elm);
void htmlBODY(const CHtmlElement &elm);
void htmlBR(const CHtmlElement &elm);
void htmlDD(const CHtmlElement &elm);
void htmlDDend(const CHtmlElement &elm);
//void htmlDEL(const CHtmlElement &elm);
void htmlDIV(const CHtmlElement &elm);
void htmlDIVend(const CHtmlElement &elm);
void htmlDL(const CHtmlElement &elm);
void htmlDLend(const CHtmlElement &elm);
void htmlDT(const CHtmlElement &elm);
void htmlDTend(const CHtmlElement &elm);
//void htmlEM(const CHtmlElement &elm);
void htmlFONT(const CHtmlElement &elm);
void htmlFORM(const CHtmlElement &elm);
void htmlH(const CHtmlElement &elm);
void htmlHend(const CHtmlElement &elm);
void htmlHEAD(const CHtmlElement &elm);
void htmlHEADend(const CHtmlElement &elm);
void htmlHR(const CHtmlElement &elm);
void htmlHTML(const CHtmlElement &elm);
void htmlI(const CHtmlElement &elm);
void htmlIend(const CHtmlElement &elm);
void htmlIMG(const CHtmlElement &elm);
void htmlINPUT(const CHtmlElement &elm);
void htmlLI(const CHtmlElement &elm);
void htmlLIend(const CHtmlElement &elm);
void htmlLUA(const CHtmlElement &elm);
void htmlLUAend(const CHtmlElement &elm);
void htmlMETA(const CHtmlElement &elm);
void htmlOBJECT(const CHtmlElement &elm);
void htmlOBJECTend(const CHtmlElement &elm);
void htmlOL(const CHtmlElement &elm);
void htmlOLend(const CHtmlElement &elm);
void htmlOPTION(const CHtmlElement &elm);
void htmlOPTIONend(const CHtmlElement &elm);
void htmlP(const CHtmlElement &elm);
void htmlPend(const CHtmlElement &elm);
void htmlPRE(const CHtmlElement &elm);
void htmlPREend(const CHtmlElement &elm);
void htmlSCRIPT(const CHtmlElement &elm);
void htmlSCRIPTend(const CHtmlElement &elm);
void htmlSELECT(const CHtmlElement &elm);
void htmlSELECTend(const CHtmlElement &elm);
//void htmlSMALL(const CHtmlElement &elm);
//void htmlSPAN(const CHtmlElement &elm);
//void htmlSTRONG(const CHtmlElement &elm);
void htmlSTYLE(const CHtmlElement &elm);
void htmlSTYLEend(const CHtmlElement &elm);
void htmlTABLE(const CHtmlElement &elm);
void htmlTABLEend(const CHtmlElement &elm);
void htmlTD(const CHtmlElement &elm);
void htmlTDend(const CHtmlElement &elm);
void htmlTEXTAREA(const CHtmlElement &elm);
void htmlTEXTAREAend(const CHtmlElement &elm);
void htmlTH(const CHtmlElement &elm);
void htmlTHend(const CHtmlElement &elm);
void htmlTITLE(const CHtmlElement &elm);
void htmlTITLEend(const CHtmlElement &elm);
void htmlTR(const CHtmlElement &elm);
void htmlTRend(const CHtmlElement &elm);
//void htmlU(const CHtmlElement &elm);
void htmlUL(const CHtmlElement &elm);
void htmlULend(const CHtmlElement &elm);
};
// adapter group that store y offset for inputs inside an html form

View file

@ -0,0 +1,86 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef CL_HTML_ELEMENT_H
#define CL_HTML_ELEMENT_H
#include "nel/misc/types_nl.h"
#include "nel/gui/css_style.h"
namespace NLGUI
{
/**
* \brief HTML element
* \date 2019-04-25 18:23 GMT
* \author Meelis Mägi (Nimetu)
*/
class CHtmlElement
{
public:
enum ENodeType {
NONE = 0,
ELEMENT_NODE = 1,
TEXT_NODE = 3,
};
uint ID; // libwww element enum
ENodeType Type;
std::string Value; // text node value or element node name
std::map<std::string, std::string> Attributes;
std::list<CHtmlElement> Children;
// class names for css matching
std::set<std::string> ClassNames;
// defined style and :before/:after pseudo elements
TStyle Style;
TStyle StyleBefore;
TStyle StyleAfter;
// hierarchy
CHtmlElement *parent;
CHtmlElement *previousSibling;
CHtmlElement *nextSibling;
// n'th ELEMENT_NODE in parent.Children, for :nth-child() rules
uint childIndex;
CHtmlElement(ENodeType type = NONE, std::string value = "");
// returns true if rhs is same pointer
friend bool operator==(const CHtmlElement &lhs, const CHtmlElement &rhs)
{
return &lhs == &rhs;
}
bool hasAttribute(const std::string &key) const;
bool hasNonEmptyAttribute(const std::string &key) const;
std::string getAttribute(const std::string &key) const;
bool hasClass(const std::string &key) const;
// update Children index/parent/next/prevSibling pointers
void reindexChilds();
// debug
std::string toString(bool tree = false, uint depth = 0) const;
};
}
#endif

View file

@ -0,0 +1,52 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef CL_HTML_PARSER_H
#define CL_HTML_PARSER_H
#include "nel/misc/types_nl.h"
namespace NLGUI
{
class CHtmlElement;
/**
* \brief HTML parsing
* \date 2019-03-15 10:50 GMT
* \author Meelis Mägi (Nimetu)
*/
class CHtmlParser
{
public:
bool parseHtml(std::string htmlString) const;
// parse html string into DOM, extract <style> tags into styleString, <link stylesheet> urls into links
void getDOM(std::string htmlString, CHtmlElement &parent, std::string &styleString, std::vector<std::string> &links) const;
private:
// iterate over libxml html tree, build DOM, and join all <style> tags together
void parseNode(xmlNode *a_node, CHtmlElement &parent, std::string &styleString, std::vector<std::string> &links) const;
// read <style> tag and add its content to styleString
void parseStyle(xmlNode *a_node, std::string &styleString) const;
// update parent/sibling in elm.Children
void reindexChilds(CHtmlElement &elm) const;
};
}
#endif

View file

@ -21,7 +21,6 @@
#define CL_LIB_WWW_H
#include "nel/misc/rgba.h"
#include "nel/gui/libwww_types.h"
// forward declaration to avoid curl.h inclusion everywhere
typedef void CURL;
@ -32,252 +31,152 @@ namespace NLGUI
class CCtrlScroll;
class CGroupList;
// ***************************************************************************
// List of HTML elements. Does not need to be sorted
typedef enum _HTMLElement {
HTML_HTML,
HTML_BODY,
// meta
HTML_BASE,
HTML_HEAD,
HTML_LINK,
HTML_META,
HTML_STYLE,
HTML_TITLE,
// content sectioning
HTML_ADDRESS,
HTML_ARTICLE,
HTML_ASIDE,
HTML_FOOTER,
HTML_HEADER,
HTML_H1,
HTML_H2,
HTML_H3,
HTML_H4,
HTML_H5,
HTML_H6,
HTML_HGROUP,
HTML_MAIN,
HTML_NAV,
HTML_SECTION,
// text content
HTML_BLOCKQUOTE,
HTML_DD,
HTML_DIR,
HTML_DIV,
HTML_DL,
HTML_DT,
HTML_FIGCAPTION,
HTML_FIGURE,
HTML_HR,
HTML_LI,
HTML_OL,
HTML_P,
HTML_PRE,
HTML_UL,
// inline text
HTML_A,
HTML_ABBR,
HTML_B,
HTML_BDI,
HTML_BDO,
HTML_BR,
HTML_CITE,
HTML_CODE,
HTML_DATA,
HTML_DFN,
HTML_EM,
HTML_I,
HTML_KBD,
HTML_MARK,
HTML_Q,
HTML_RB,
HTML_RP,
HTML_RT,
HTML_RTC,
HTML_RUBY,
HTML_S,
HTML_SAMP,
HTML_SMALL,
HTML_SPAN,
HTML_STRONG,
HTML_SUB,
HTML_SUP,
HTML_TIME,
HTML_TT,
HTML_U,
HTML_VAR,
HTML_WBR,
// image, multimedia
HTML_AREA,
HTML_AUDIO,
HTML_IMG,
HTML_MAP,
HTML_TRACK,
HTML_VIDEO,
// embedded content
HTML_APPLET,
HTML_EMBED,
HTML_IFRAME,
HTML_NOEMBED,
HTML_OBJECT,
HTML_PARAM,
HTML_PICTURE,
HTML_SOURCE,
// scripting
HTML_CANVAS,
HTML_NOSCRIPT,
HTML_SCRIPT,
// demarcating edits
HTML_DEL,
HTML_INS,
// table
HTML_CAPTION,
HTML_COL,
HTML_COLGROUP,
HTML_TABLE,
HTML_TBODY,
HTML_TD,
HTML_TFOOT,
HTML_TH,
HTML_THEAD,
HTML_TR,
// forms
HTML_BUTTON,
HTML_DATALIST,
HTML_FIELDSET,
HTML_FORM,
HTML_INPUT,
HTML_LABEL,
HTML_LEGEND,
HTML_METER,
HTML_OPTGROUP,
HTML_OPTION,
HTML_OUTPUT,
HTML_PROGRESS,
HTML_SELECT,
HTML_TEXTAREA,
// interactive elements
HTML_DETAILS,
HTML_DIALOG,
HTML_MENU,
HTML_MENUITEM,
HTML_SUMMARY,
// -- tags for ryzom --
HTML_FONT,
HTML_LUA,
// last entry for unknown elements
HTML_NB_ELEMENTS
} HTMLElement;
// Legacy function from libwww
SGML_dtd * HTML_dtd (void);
// Init the libwww
void initLibWWW();
// case insensitive lookup for HTMLElement enum by name
// return HTML_NB_ELEMENTS if no match
HTMLElement htmlElementLookup(const char *name);
// ***************************************************************************
// Some DTD table
// Here, modify the DTD table to change the HTML parser (add new tags for exemples)
#undef HTML_ATTR
#define HTML_ATTR(t,a) MY_HTML_##t##_##a
enum
{
HTML_ATTR(HTML,DIR) = 0,
HTML_ATTR(HTML,LANG),
HTML_ATTR(HTML,VERSION),
HTML_ATTR(HTML,STYLE),
};
enum
{
HTML_ATTR(A,ACCESSKEY) = 0,
HTML_ATTR(A,CHARSET),
HTML_ATTR(A,CLASS),
HTML_ATTR(A,COORDS),
HTML_ATTR(A,DIR),
HTML_ATTR(A,HREF),
HTML_ATTR(A,HREFLANG),
HTML_ATTR(A,ID),
HTML_ATTR(A,NAME),
HTML_ATTR(A,REL),
HTML_ATTR(A,REV),
HTML_ATTR(A,SHAPE),
HTML_ATTR(A,STYLE),
HTML_ATTR(A,TABINDEX),
HTML_ATTR(A,TARGET),
HTML_ATTR(A,TYPE),
HTML_ATTR(A,TITLE),
HTML_ATTR(A,Z_ACTION_CATEGORY),
HTML_ATTR(A,Z_ACTION_PARAMS),
HTML_ATTR(A,Z_ACTION_SHORTCUT),
};
enum
{
HTML_ATTR(TABLE,ALIGN) = 0,
HTML_ATTR(TABLE,BGCOLOR),
HTML_ATTR(TABLE,BORDER),
HTML_ATTR(TABLE,BORDERCOLOR),
HTML_ATTR(TABLE,CELLPADDING),
HTML_ATTR(TABLE,CELLSPACING),
HTML_ATTR(TABLE,CLASS),
HTML_ATTR(TABLE,DIR),
HTML_ATTR(TABLE,FRAME),
HTML_ATTR(TABLE,ID),
HTML_ATTR(TABLE,L_MARGIN),
HTML_ATTR(TABLE,LANG),
HTML_ATTR(TABLE,NOWRAP),
HTML_ATTR(TABLE,RULES),
HTML_ATTR(TABLE,SUMMARY),
HTML_ATTR(TABLE,STYLE),
HTML_ATTR(TABLE,TITLE),
HTML_ATTR(TABLE,VALIGN),
HTML_ATTR(TABLE,WIDTH)
};
enum
{
HTML_ATTR(TR,ALIGN) = 0,
HTML_ATTR(TR,BGCOLOR),
HTML_ATTR(TR,L_MARGIN),
HTML_ATTR(TR,NOWRAP),
HTML_ATTR(TR,VALIGN),
HTML_ATTR(TR,STYLE),
};
enum
{
HTML_ATTR(TD,ABBR) = 0,
HTML_ATTR(TD,ALIGN),
HTML_ATTR(TD,AXIS),
HTML_ATTR(TD,BGCOLOR),
HTML_ATTR(TD,CHAR),
HTML_ATTR(TD,CHAROFF),
HTML_ATTR(TD,CLASS),
HTML_ATTR(TD,COLSPAN),
HTML_ATTR(TD,DIR),
HTML_ATTR(TD,ID),
HTML_ATTR(TD,HEADERS),
HTML_ATTR(TD,HEIGHT),
HTML_ATTR(TD,L_MARGIN),
HTML_ATTR(TD,LANG),
HTML_ATTR(TD,NOWRAP),
HTML_ATTR(TD,ROWSPAN),
HTML_ATTR(TD,SCOPE),
HTML_ATTR(TD,STYLE),
HTML_ATTR(TD,TITLE),
HTML_ATTR(TD,VALIGN),
HTML_ATTR(TD,WIDTH),
};
enum
{
HTML_ATTR(IMG,ALIGN) = 0,
HTML_ATTR(IMG,ALT),
HTML_ATTR(IMG,BORDER),
HTML_ATTR(IMG,CLASS),
HTML_ATTR(IMG,DIR),
HTML_ATTR(IMG,GLOBAL_COLOR),
HTML_ATTR(IMG,HEIGHT),
HTML_ATTR(IMG,HSPACE),
HTML_ATTR(IMG,ID),
HTML_ATTR(IMG,ISMAP),
HTML_ATTR(IMG,LANG),
HTML_ATTR(IMG,LONGDESC),
HTML_ATTR(IMG,SRC),
HTML_ATTR(IMG,STYLE),
HTML_ATTR(IMG,TITLE),
HTML_ATTR(IMG,USEMAP),
HTML_ATTR(IMG,VSPACE),
HTML_ATTR(IMG,WIDTH),
// not sorted to keep enum values
HTML_ATTR(IMG,DATA_OVER_SRC),
};
enum
{
HTML_ATTR(INPUT,ACCEPT) = 0,
HTML_ATTR(INPUT,ACCESSKEY),
HTML_ATTR(INPUT,ALIGN),
HTML_ATTR(INPUT,ALT),
HTML_ATTR(INPUT,CHECKED),
HTML_ATTR(INPUT,CLASS),
HTML_ATTR(INPUT,DIR),
HTML_ATTR(INPUT,DISABLED),
HTML_ATTR(INPUT,GLOBAL_COLOR),
HTML_ATTR(INPUT,ID),
HTML_ATTR(INPUT,LANG),
HTML_ATTR(INPUT,MAXLENGTH),
HTML_ATTR(INPUT,NAME),
HTML_ATTR(INPUT,READONLY),
HTML_ATTR(INPUT,SIZE),
HTML_ATTR(INPUT,SRC),
HTML_ATTR(INPUT,STYLE),
HTML_ATTR(INPUT,TABINDEX),
HTML_ATTR(INPUT,TITLE),
HTML_ATTR(INPUT,TYPE),
HTML_ATTR(INPUT,USEMAP),
HTML_ATTR(INPUT,VALUE),
HTML_ATTR(INPUT,Z_BTN_TMPL),
HTML_ATTR(INPUT,Z_INPUT_TMPL),
HTML_ATTR(INPUT,Z_INPUT_WIDTH),
};
enum
{
HTML_ATTR(TEXTAREA,CLASS) = 0,
HTML_ATTR(TEXTAREA,COLS),
HTML_ATTR(TEXTAREA,DIR),
HTML_ATTR(TEXTAREA,DISABLED),
HTML_ATTR(TEXTAREA,ID),
HTML_ATTR(TEXTAREA,LANG),
HTML_ATTR(TEXTAREA,MAXLENGTH),
HTML_ATTR(TEXTAREA,NAME),
HTML_ATTR(TEXTAREA,READONLY),
HTML_ATTR(TEXTAREA,ROWS),
HTML_ATTR(TEXTAREA,STYLE),
HTML_ATTR(TEXTAREA,TABINDEX),
HTML_ATTR(TEXTAREA,TITLE),
HTML_ATTR(TEXTAREA,Z_INPUT_TMPL),
};
enum
{
HTML_ATTR(P,QUICK_HELP_CONDITION) = 0,
HTML_ATTR(P,QUICK_HELP_EVENTS),
HTML_ATTR(P,QUICK_HELP_LINK),
HTML_ATTR(P,NAME),
HTML_ATTR(P,STYLE),
};
enum
{
HTML_ATTR(DIV,CLASS) = 0,
HTML_ATTR(DIV,ID),
HTML_ATTR(DIV,NAME),
HTML_ATTR(DIV,STYLE),
};
enum
{
HTML_ATTR(SPAN,CLASS) = 0,
HTML_ATTR(SPAN,ID),
HTML_ATTR(SPAN,STYLE),
};
enum
{
HTML_ATTR(H1,CLASS) = 0,
HTML_ATTR(H1,ID),
HTML_ATTR(H1,STYLE),
};
enum
{
HTML_ATTR(H2,CLASS) = 0,
HTML_ATTR(H2,ID),
HTML_ATTR(H2,STYLE),
};
enum
{
HTML_ATTR(H3,CLASS) = 0,
HTML_ATTR(H3,ID),
HTML_ATTR(H3,STYLE),
};
enum
{
HTML_ATTR(H4,CLASS) = 0,
HTML_ATTR(H4,ID),
HTML_ATTR(H4,STYLE),
};
enum
{
HTML_ATTR(H5,CLASS) = 0,
HTML_ATTR(H5,ID),
HTML_ATTR(H5,STYLE),
};
enum
{
HTML_ATTR(H6,CLASS) = 0,
HTML_ATTR(H6,ID),
HTML_ATTR(H6,STYLE),
};
#undef HTML_ATTR
// Read HTML color value from src and set dest
// Can handle #rgb(a), #rrggbb(aa) or rgb()/rgba(), hsl(), hsla() formats
// or color name directly
bool scanHTMLColor(const char *src, NLMISC::CRGBA &dest);
// ***************************************************************************
// Read a CSS length value, return true if one of supported units '%, rem, em, px, pt'
@ -292,6 +191,9 @@ namespace NLGUI
// Parse a HTML color
NLMISC::CRGBA getColor (const char *color);
// return css color in rgba() format
std::string getRGBAString(const NLMISC::CRGBA &color);
// ***************************************************************************
const std::string &setCurrentDomain(const std::string &uri);

File diff suppressed because it is too large Load diff

View file

@ -276,6 +276,17 @@ template <class T> T trimRightWhiteSpaces (const T &str)
return str.substr (0, end);
}
// if both first and last char are quotes (' or "), then remove them
template <class T> T trimQuotes (const T &str)
{
typename T::size_type size = str.size();
if (size == 0)
return str;
if (str[0] != str[size-1] && (str[0] != '"' || str[0] != '\''))
return str;
return str.substr(1, size - 1);
}
//////////////////////////////////////////////////////////////////////////
// **** DEPRECATED *****: PLEASE DON'T USE THESE METHODS BUT FUNCTIONS ABOVE toLower() and toUpper()
//////////////////////////////////////////////////////////////////////////
@ -303,28 +314,23 @@ inline sint nlstricmp(const std::string &lhs, const std::string &rhs) { return s
inline sint nlstricmp(const std::string &lhs, const char *rhs) { return stricmp(lhs.c_str(),rhs); }
inline sint nlstricmp(const char *lhs, const std::string &rhs) { return stricmp(lhs,rhs.c_str()); }
// macros helper to convert UTF-8 std::string and wchar_t*
#define wideToUtf8(str) (ucstring((ucchar*)str).toUtf8())
#define utf8ToWide(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str())
// macros helper to convert UTF-8 std::string and TCHAR*
#ifdef _UNICODE
#define tStrToUtf8(str) (ucstring((ucchar*)(LPCWSTR)str).toUtf8())
#define utf8ToTStr(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str())
#else
#define tStrToUtf8(str) (std::string((LPCSTR)str))
#define utf8ToTStr(str) (str.c_str())
#if (NL_COMP_VC_VERSION <= 90)
inline float nlroundf(float x)
{
return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f);
}
#define roundf(x) NLMISC::nlroundf(x)
#endif
// wrapper for fopen to be able to open files with an UTF-8 filename
FILE* nlfopen(const std::string &filename, const std::string &mode);
// Wrapper for fopen to be able to open files with an UTF-8 filename
FILE *nlfopen(const std::string &filename, const std::string &mode);
/** Signed 64 bit fseek. Same interface as fseek
*/
int nlfseek64( FILE *stream, sint64 offset, int origin );
int nlfseek64(FILE *stream, sint64 offset, int origin);
// Retrieve position in a file, same interface as ftell
sint64 nlftell64(FILE *stream);
sint64 nlftell64(FILE *stream);
/**
* Base class for all NeL exception.

View file

@ -242,54 +242,11 @@ inline bool fromString(const std::string &str, sint64 &val) { bool ret = sscanf(
inline bool fromString(const std::string &str, float &val) { bool ret = sscanf(str.c_str(), "%f", &val) == 1; if (!ret) val = 0.0f; return ret; }
inline bool fromString(const std::string &str, double &val) { bool ret = sscanf(str.c_str(), "%lf", &val) == 1; if (!ret) val = 0.0; return ret; }
inline bool fromString(const std::string &str, bool &val)
{
if (str.length() == 1)
{
const char c = str[0];
// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, anything else is undefined.
// (str[0] == '1' || (str[0] & 0xD2) == 0x50)
// - Kaetemi
switch(c)
{
case '1':
case 't':
case 'T':
case 'y':
case 'Y':
val = true;
break;
case '0':
case 'f':
case 'F':
case 'n':
case 'N':
val = false;
break;
default:
val = false;
return false;
}
}
else
{
if (str == "true" || str == "yes")
{
val = true;
}
else if (str == "false" || str == "no")
{
val = false;
}
else
{
val = false;
return false;
}
}
return true;
}
bool fromString(const std::string &str, bool &val);
inline bool fromString(const std::string &str, std::string &val) { val = str; return true; }
@ -300,6 +257,105 @@ inline bool fromString(const std::string &str, uint &val) { return sscanf(str.c_
inline bool fromString(const std::string &str, sint &val) { return sscanf(str.c_str(), "%d", &val) == 1; }
#endif // NL_COMP_VC6
// Convert local codepage to UTF-8
// On Windows, the local codepage is undetermined
// On Linux, the local codepage is always UTF-8 (no-op)
std::string mbcsToUtf8(const char *str, size_t len = 0);
std::string mbcsToUtf8(const std::string &str);
// Convert wide codepage to UTF-8
// On Windows, the wide codepage is UTF-16
// On Linux, the wide codepage is UTF-32
std::string wideToUtf8(const wchar_t *str, size_t len = 0);
std::string wideToUtf8(const std::wstring &str);
// Convert UTF-8 to wide character set
std::wstring utf8ToWide(const char *str, size_t len = 0);
std::wstring utf8ToWide(const std::string &str);
// Convert UTF-8 to local multibyte character set
std::string utf8ToMbcs(const char *str, size_t len = 0);
std::string utf8ToMbcs(const std::string &str);
// Convert wide to local multibyte character set
std::string wideToMbcs(const wchar_t *str, size_t len = 0);
std::string wideToMbcs(const std::wstring &str);
// Convert local multibyte to wide character set
std::wstring mbcsToWide(const char *str, size_t len = 0);
std::wstring mbcsToWide(const std::string &str);
inline const char *asCStr(const char *str) { return str; }
inline const char *asCStr(const std::string &str) { return str.c_str(); }
inline const wchar_t *asCStr(const wchar_t *str) { return str; }
inline const wchar_t *asCStr(const std::wstring &str) { return str.c_str(); }
#if defined(NL_OS_WINDOWS)
#define nlUtf8ToMbcs(str) (NLMISC::utf8ToMbcs(str).c_str())
#define nlMbcsToUtf8(str) (NLMISC::mbcsToUtf8(str).c_str())
#else
#define nlUtf8ToMbcs(str) (NLMISC::asCStr(str))
#define nlMbcsToUtf8(str) (NLMISC::asCStr(str))
#endif
#define nlWideToUtf8(str) (NLMISC::wideToUtf8(str).c_str())
#define nlUtf8ToWide(str) (NLMISC::utf8ToWide(str).c_str())
#define nlWideToMbcs(str) (NLMISC::wideToMbcs(str).c_str())
#define nlMbcsToWide(str) (NLMISC::mbcsToWide(str).c_str())
// On Windows, tstring is either local multibyte or utf-16 wide
// On Linux, tstring is always utf-8
#if defined(NL_OS_WINDOWS) && (defined(UNICODE) || defined(_UNICODE))
typedef std::wstring tstring;
typedef wchar_t tchar;
inline std::string tStrToUtf8(const tchar *str) { return wideToUtf8((const wchar_t *)str); }
inline std::string tStrToUtf8(const tstring &str) { return wideToUtf8((const std::wstring &)str); }
inline std::wstring tStrToWide(const tchar *str) { return (const wchar_t *)str; }
inline std::wstring tStrToWide(const tstring &str) { return (const std::wstring &)str; }
inline std::string tStrToMbcs(const tchar *str) { return wideToMbcs((const wchar_t *)str); }
inline std::string tStrToMbcs(const tstring &str) { return wideToMbcs((const std::wstring &)str); }
#define nlTStrToUtf8(str) (NLMISC::tStrToUtf8(str).c_str())
#define nlTStrToWide(str) ((const wchar_t *)NLMISC::asCStr(str))
#define nlTStrToMbcs(str) (NLMISC::tStrToMbcs(str).c_str())
inline tstring utf8ToTStr(const char *str) {return (const tstring &)utf8ToWide(str); }
inline tstring utf8ToTStr(const std::string &str) { return (const tstring &)utf8ToWide(str); }
inline tstring wideToTStr(const wchar_t *str) { return (const tchar *)str; }
inline tstring wideToTStr(const std::wstring &str) { return (const tstring &)str; }
inline tstring mbcsToTStr(const char *str) { return (const tstring &)mbcsToWide(str); }
inline tstring mbcsToTStr(const std::string &str) { return (const tstring &)mbcsToWide(str); }
#define nlUtf8ToTStr(str) (NLMISC::utf8ToTStr(str).c_str())
#define nlWideToTStr(str) ((const tchar *)NLMISC::asCStr(str))
#define nlMbcsToTStr(str) (NLMISC::mbcsToTStr(str).c_str())
#else
typedef std::string tstring;
typedef char tchar;
inline std::string tStrToUtf8(const tchar *str) { return mbcsToUtf8((const char *)str); }
inline std::string tStrToUtf8(const tstring &str) { return mbcsToUtf8((const std::string &)str); }
inline std::wstring tStrToWide(const tchar *str) { return mbcsToWide((const char *)str); }
inline std::wstring tStrToWide(const tstring &str) { return mbcsToWide((const std::string &)str); }
inline std::string tStrToMbcs(const tchar *str) { return (const char *)str; }
inline std::string tStrToMbcs(const tstring &str) { return (const std::string &)str; }
#if defined(NL_OS_WINDOWS)
#define nlTStrToUtf8(str) (NLMISC::tStrToUtf8(str).c_str())
#else
#define nlTStrToUtf8(str) ((const char *)NLMISC::asCStr(str))
#endif
#define nlTStrToWide(str) (NLMISC::tStrToWide(str).c_str())
#define nlTStrToMbcs(str) ((const char *)NLMISC::asCStr(str))
inline tstring utf8ToTStr(const char *str) { return (const tstring &)utf8ToMbcs(str); }
inline tstring utf8ToTStr(const std::string &str) { return (const tstring &)utf8ToMbcs(str); }
inline tstring wideToTStr(const wchar_t *str) { return (const tstring &)wideToMbcs(str); }
inline tstring wideToTStr(const std::wstring &str) { return (const tstring &)wideToMbcs(str); }
inline tstring mbcsToTStr(const char *str) { return (const tchar *)str; }
inline tstring mbcsToTStr(const std::string &str) { return (const tstring &)str; }
#if defined(NL_OS_WINDOWS)
#define nlUtf8ToTStr(str) (NLMISC::utf8ToTStr(str).c_str())
#else
#define nlUtf8ToTStr(str) ((const tchar *)NLMISC::asCStr(str))
#endif
#define nlWideToTStr(str) (NLMISC::wideToTStr(str).c_str())
#define nlMbcsToTStr(str) ((const tchar *)NLMISC::asCStr(str))
#endif
} // NLMISC

View file

@ -70,10 +70,10 @@ public:
static void setRootKey(const std::string &root);
/// Read a value from registry.
static std::string getRegKey(const std::string &Entry);
static std::string getRegKey(const std::string &entry);
/// Write a value to registry.
static bool setRegKey(const std::string &ValueName, const std::string &Value);
static bool setRegKey(const std::string &valueName, const std::string &value);
/// Get desktop current color depth without using UDriver.
static uint getCurrentColorDepth();

View file

@ -173,6 +173,12 @@
# define NL_NO_EXCEPTION_SPECS
#endif
#if defined(NL_COMP_VC) && (NL_COMP_VC_VERSION >= 140)
#define nlmove(v) std::move(v)
#else
#define nlmove(v) (v)
#endif
// gcc 3.4 introduced ISO C++ with tough template rules
//
// NL_ISO_SYNTAX can be used using #if NL_ISO_SYNTAX or #if !NL_ISO_SYNTAX
@ -220,6 +226,7 @@
# if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# pragma warning (disable : 4005) // don't warn on redefinitions caused by xp platform sdk
# endif // NL_COMP_VC8 || NL_COMP_VC9
# pragma warning (disable : 26495) // Variable is uninitialized. Always initialize a member variable. (On purpose for performance.)
#endif // NL_OS_WINDOWS
@ -519,6 +526,15 @@ template<> struct hash<uint64>
*/
typedef uint16 ucchar;
#if defined(NL_OS_WINDOWS) && (defined(UNICODE) || defined(_UNICODE))
#define nltmain wmain
#define nltWinMain wWinMain
#else
#define nltmain main
#if defined(NL_OS_WINDOWS)
#define nltWinMain WinMain
#endif
#endif
// To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234)
#ifdef NL_COMP_VC

View file

@ -54,7 +54,17 @@ struct HINSTANCE__;
typedef struct HINSTANCE__ *HINSTANCE;
typedef char CHAR;
typedef wchar_t WCHAR;
typedef CHAR *LPSTR;
typedef WCHAR *LPWSTR;
#if defined(UNICODE) || defined(_UNICODE)
typedef LPWSTR LPTSTR;
#else
typedef LPSTR LPTSTR;
#endif
#endif
namespace NLNET
@ -117,11 +127,11 @@ class IServiceUpdatable;
#if defined(NL_OS_WINDOWS) && defined(_WINDOWS)
#define NLNET_SERVICE_MAIN(__ServiceClassName, __ServiceShortName, __ServiceLongName, __ServicePort, __ServiceCallbackArray, __ConfigDir, __LogDir) \
\
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) \
int APIENTRY nltWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) \
{ \
NLMISC::CApplicationContext serviceContext; \
__ServiceClassName *scn = new __ServiceClassName; \
scn->setArgs (lpCmdLine); \
scn->setArgs (nlTStrToUtf8(lpCmdLine)); \
createDebug(NULL,!scn->haveLongArg("nolog"));\
scn->setCallbackArray (__ServiceCallbackArray, sizeof(__ServiceCallbackArray)/sizeof(__ServiceCallbackArray[0])); \
sint retval = scn->main (__ServiceShortName, __ServiceLongName, __ServicePort, __ConfigDir, __LogDir, __DATE__ " " __TIME__); \
@ -132,7 +142,7 @@ int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
#else
#define NLNET_SERVICE_MAIN(__ServiceClassName, __ServiceShortName, __ServiceLongName, __ServicePort, __ServiceCallbackArray, __ConfigDir, __LogDir) \
\
int main(int argc, const char **argv) \
int nltmain(int argc, const NLMISC::tchar **argv) \
{ \
NLMISC::CApplicationContext serviceContext; \
__ServiceClassName *scn = new __ServiceClassName; \
@ -340,6 +350,9 @@ public:
/// Sets the command line and init _Args variable. You must call this before calling main()
void setArgs (int argc, const char **argv);
/// Sets the command line and init _Args variable. You must call this before calling main()
void setArgs (int argc, const wchar_t **argv);
/// Sets the command line and init _Args variable. You must call this before calling main()
void setArgs (const char *args);

View file

@ -18,6 +18,8 @@
#define NLSOUND_AUDIO_DECODER_MP3_H
#include <nel/misc/types_nl.h>
#if (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */
#include <nel/sound/audio_decoder.h>
// disable drmp3_init_file()
@ -91,6 +93,8 @@ public:
} /* namespace NLSOUND */
#endif /* (NL_COMP_VC_VERSION > 90) */
#endif // NLSOUND_AUDIO_DECODER_MP3_H
/* end of file */

View file

@ -1810,7 +1810,7 @@ emptyProc CDriverD3D::getWindowProc()
IDriver::TMessageBoxId CDriverD3D::systemMessageBox (const char* message, const char* title, TMessageBoxType type, TMessageBoxIcon icon)
{
switch (::MessageBoxW (_HWnd, utf8ToWide(message), utf8ToWide(title), ((type==retryCancelType)?MB_RETRYCANCEL:
switch (::MessageBoxW(_HWnd, nlUtf8ToWide(message), nlUtf8ToWide(title), ((type == retryCancelType) ? MB_RETRYCANCEL :
(type==yesNoCancelType)?MB_YESNOCANCEL:
(type==okCancelType)?MB_OKCANCEL:
(type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE:

View file

@ -2644,7 +2644,7 @@ IDriver::TMessageBoxId CDriverGL::systemMessageBox (const char* message, const c
{
H_AUTO_OGL(CDriverGL_systemMessageBox)
#ifdef NL_OS_WINDOWS
switch (::MessageBoxW (NULL, utf8ToWide(message), utf8ToWide(title), ((type==retryCancelType)?MB_RETRYCANCEL:
switch (::MessageBoxW(NULL, nlUtf8ToWide(message), nlUtf8ToWide(title), ((type == retryCancelType) ? MB_RETRYCANCEL :
(type==yesNoCancelType)?MB_YESNOCANCEL:
(type==okCancelType)?MB_OKCANCEL:
(type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE:

View file

@ -25,6 +25,8 @@ using namespace NLMISC;
#define new DEBUG_NEW
#endif
void vertex_buffer_heap_dummy_cpp() { }
// This code is not used actually and doesn't compile
// just preproc comment it
#if 0

View file

@ -0,0 +1,716 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#include "stdpch.h"
#include <string>
#include "nel/misc/types_nl.h"
#include "nel/gui/css_parser.h"
#include "nel/gui/css_style.h"
#include "nel/gui/css_selector.h"
using namespace NLMISC;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLGUI
{
// ***************************************************************************
// Parse style declarations style, eg. "color:red; font-size: 10px;"
//
// key is converted to lowercase
// value is left as is
TStyle CCssParser::parseDecls(const std::string &styleString)
{
TStyle styles;
std::vector<std::string> elements;
NLMISC::splitString(styleString, ";", elements);
for(uint i = 0; i < elements.size(); ++i)
{
std::string::size_type pos;
pos = elements[i].find_first_of(':');
if (pos != std::string::npos)
{
std::string key = trim(toLower(elements[i].substr(0, pos)));
std::string value = trim(elements[i].substr(pos+1));
styles[key] = value;
}
}
return styles;
}
// ***************************************************************************
// Parse stylesheet, eg content from main.css file
//
// Return all found rules
void CCssParser::parseStylesheet(const std::string &cssString, std::vector<CCssStyle::SStyleRule> &result)
{
_Rules.clear();
_Style.clear();
_Style.fromUtf8(cssString);
preprocess();
_Position = 0;
while(!is_eof())
{
skipWhitespace();
if (_Style[_Position] == (ucchar)'@')
readAtRule();
else
readRule();
}
result.insert(result.end(), _Rules.begin(), _Rules.end());
_Rules.clear();
}
// ***************************************************************************
// Parse selector with style string
// selector: "a#id .class"
// style: "color: red; font-size: 10px;"
//
// @internal
void CCssParser::parseRule(const ucstring &selectorString, const ucstring &styleString)
{
std::vector<ucstring> selectors;
NLMISC::explode(selectorString, ucstring(","), selectors);
TStyle props;
props = parseDecls(styleString.toUtf8());
// duplicate props to each selector in selector list,
// example 'div > p, h1' creates 'div>p' and 'h1'
for(uint i=0; i<selectors.size(); ++i)
{
CCssStyle::SStyleRule rule;
rule.Selector = parse_selector(trim(selectors[i]), rule.PseudoElement);
rule.Properties = props;
if (!rule.Selector.empty())
{
_Rules.push_back(rule);
}
}
}
// ***************************************************************************
// Skip over at-rule
// @import ... ;
// @charset ... ;
// @media query { .. }
//
// @internal
void CCssParser::readAtRule()
{
// skip '@'
_Position++;
// skip 'import', 'media', etc
skipIdentifier();
// skip at-rule statement
while(!is_eof() && _Style[_Position] != (ucchar)';')
{
if (maybe_escape())
{
escape();
}
else if (is_quote(_Style[_Position]))
{
skipString();
}
else if (is_block_open(_Style[_Position]))
{
bool mustBreak = (_Style[_Position] == '{');
skipBlock();
if(mustBreak)
{
break;
}
}
else
{
_Position++;
}
}
// skip ';' or '}'
_Position++;
}
// ***************************************************************************
// skip over "elm#id.selector[attr]:peseudo, .sel2 { rule }" block
// @internal
void CCssParser::readRule()
{
size_t start;
// selector
start = _Position;
while(!is_eof())
{
if (maybe_escape())
_Position++;
else if (is_quote(_Style[_Position]))
skipString();
else if (_Style[_Position] == (ucchar)'[')
skipBlock();
else if (_Style[_Position] == (ucchar)'{')
break;
else
_Position++;
}
if (!is_eof())
{
ucstring selector;
selector.append(_Style, start, _Position - start);
skipWhitespace();
// declaration block
start = _Position;
skipBlock();
if (_Position <= _Style.size())
{
ucstring rules;
rules.append(_Style, start + 1, _Position - start - 2);
parseRule(selector, rules);
}
}
}
// ***************************************************************************
// skip over \abcdef escaped sequence or escaped newline char
// @internal
void CCssParser::escape()
{
// skip '\'
_Position++;
if (is_hex(_Style[_Position]))
{
// TODO: '\abc def' should be considered one string
for(uint i=0; i<6 && is_hex(_Style[_Position]); i++)
_Position++;
if (_Style[_Position] == (ucchar)' ')
_Position++;
}
else if (_Style[_Position] != 0x0A)
_Position++;
}
// ***************************************************************************
// @internal
bool CCssParser::skipIdentifier()
{
size_t start = _Position;
bool valid = true;
while(!is_eof() && valid)
{
if (maybe_escape())
{
escape();
continue;
}
else if (is_alpha(_Style[_Position]))
{
// valid
}
else if (is_digit(_Style[_Position]))
{
if (_Position == start)
{
// cannot start with digit
valid = false;
}
else if ((_Position - start) == 0 && _Style[_Position-1] == (ucchar)'-')
{
// cannot start with -#
valid = false;
}
}
else if (_Style[_Position] == (ucchar)'_')
{
// valid
}
else if (_Style[_Position] >= 0x0080)
{
// valid
}
else if (_Style[_Position] == (ucchar)'-')
{
if ((_Position - start) == 1 && _Style[_Position-1] == (ucchar)'-')
{
// cannot start with --
valid = false;
}
}
else
{
// we're done
break;
}
_Position++;
}
return valid && !is_eof();
}
// ***************************************************************************
// skip over (..), [..], or {..} blocks
// @internal
void CCssParser::skipBlock()
{
ucchar startChar = _Style[_Position];
// block start
_Position++;
while(!is_eof() && !is_block_close(_Style[_Position], startChar))
{
if (maybe_escape())
// skip backslash and next char
_Position += 2;
else if (is_quote(_Style[_Position]))
skipString();
else if (is_block_open(_Style[_Position]))
skipBlock();
else
_Position++;
}
// block end
_Position++;
}
// ***************************************************************************
// skip over quoted string
// @internal
void CCssParser::skipString()
{
ucchar endChar = _Style[_Position];
// quote start
_Position++;
while(!is_eof() && _Style[_Position] != endChar)
{
if (maybe_escape())
_Position++;
_Position++;
}
// quote end
_Position++;
}
// ***************************************************************************
// @internal
void CCssParser::skipWhitespace()
{
while(!is_eof() && is_whitespace(_Style[_Position]))
_Position++;
}
// ***************************************************************************
// parse selector list
// @internal
std::vector<CCssSelector> CCssParser::parse_selector(const ucstring &sel, std::string &pseudoElement) const
{
std::vector<CCssSelector> result;
CCssSelector current;
pseudoElement.clear();
bool failed = false;
ucstring::size_type start = 0, pos = 0;
while(pos < sel.size())
{
ucstring uc;
uc = sel[pos];
if (is_nmchar(sel[pos]) && current.empty())
{
pos++;
while(pos < sel.size() && is_nmchar(sel[pos]))
pos++;
current.Element = toLower(sel.substr(start, pos - start).toUtf8());
start = pos;
continue;
}
if(sel[pos] == '#')
{
pos++;
start=pos;
while(pos < sel.size() && is_nmchar(sel[pos]))
pos++;
current.Id = toLower(sel.substr(start, pos - start).toUtf8());
start = pos;
}
else if (sel[pos] == '.')
{
pos++;
start=pos;
// .classA.classB
while(pos < sel.size() && (is_nmchar(sel[pos]) || sel[pos] == '.'))
pos++;
current.setClass(toLower(sel.substr(start, pos - start).toUtf8()));
start = pos;
}
else if (sel[pos] == '[')
{
pos++;
start = pos;
if (is_whitespace(sel[pos]))
{
while(pos < sel.size() && is_whitespace(sel[pos]))
pos++;
start = pos;
}
ucstring key;
ucstring value;
ucchar op = ' ';
// key
while(pos < sel.size() && is_nmchar(sel[pos]))
pos++;
key = sel.substr(start, pos - start);
if (pos == sel.size()) break;
if (is_whitespace(sel[pos]))
{
while(pos < sel.size() && is_whitespace(sel[pos]))
pos++;
if (pos == sel.size()) break;
}
if (sel[pos] == ']')
{
current.addAttribute(key.toUtf8());
}
else
{
// operand
op = sel[pos];
if (op == '~' || op == '|' || op == '^' || op == '$' || op == '*')
{
pos++;
if (pos == sel.size()) break;
}
// invalid rule?, eg [attr^value]
if (sel[pos] != '=')
{
while(pos < sel.size() && sel[pos] != ']')
pos++;
if (pos == sel.size()) break;
start = pos;
}
else
{
// skip '='
pos++;
if (is_whitespace(sel[pos]))
{
while(pos < sel.size() && is_whitespace(sel[pos]))
pos++;
if (pos == sel.size()) break;
}
// value
start = pos;
bool quote = false;
char quoteOpen;
while(pos < sel.size())
{
if (sel[pos] == '\'' || sel[pos] == '"')
{
// value is quoted
start = pos;
pos++;
while(pos < sel.size() && sel[pos] != sel[start])
{
if (sel[pos] == '\\')
{
pos++;
}
pos++;
}
if (pos == sel.size()) break;
value = sel.substr(start + 1, pos - start - 1);
break;
}
else if (sel[pos] == '\\')
{
pos++;
}
else if (!quote && sel[pos] == ']')
{
// unquoted value
value = sel.substr(start, pos - start);
break;
}
pos++;
} // while 'value'
// TODO: scan for sel[pos] == ']'
if (pos == sel.size()) break;
// whitespace between quote and ], ie '[ attr $= "val" ]'
if (sel[pos] != ']')
{
while(pos < sel.size() && sel[pos] != ']')
pos++;
}
if (pos == sel.size()) break;
current.addAttribute(key.toUtf8(), value.toUtf8(), (char)op);
} // op error
} // no value
// skip ']'
pos++;
start = pos;
}
else if (sel[pos] == ':')
{
pos++;
start=pos;
// pseudo element, eg '::before'
if (pos < sel.size() && sel[pos] == ':')
{
pos++;
}
// :first-child
// :nth-child(2n+0)
// :not(h1, div#main)
// :not(:nth-child(2n+0))
// has no support for quotes, eg :not(h1[attr=")"]) fails
while(pos < sel.size() && (is_nmchar(sel[pos]) || sel[pos] == '('))
{
if (sel[pos] == '(')
{
uint open = 1;
pos++;
while(pos < sel.size() && open > 0)
{
if (sel[pos] == ')')
open--;
else if (sel[pos] == '(')
open++;
pos++;
}
break;
}
else
{
pos++;
}
}
std::string key = toLower(sel.substr(start, pos - start).toUtf8());
if (key.empty())
{
failed = true;
break;
}
if (key[0] == ':' || key == "after" || key == "before" || key == "cue" || key == "first-letter" || key == "first-line")
{
if (!pseudoElement.empty())
{
failed = true;
break;
}
if (key[0] != ':')
{
pseudoElement = ":" + key;
}
else
{
pseudoElement = key;
}
}
else
{
current.addPseudoClass(key);
}
start = pos;
}
else if (!current.empty())
{
// pseudo element like ':before' can only be set on the last selector
// user action pseudo classes can be used after pseudo element (ie, :focus, :hover)
// there is no support for those and its safe to just fail the selector
if (!result.empty() && !pseudoElement.empty())
{
failed = true;
break;
}
// start new selector as combinator is part of next selector
result.push_back(current);
current = CCssSelector();
// detect and remove whitespace around combinator, eg ' > '
bool isSpace = is_whitespace(sel[pos]);;
while(pos < sel.size() && is_whitespace(sel[pos]))
pos++;
if (sel[pos] == '>' || sel[pos] == '+' || sel[pos] == '~')
{
current.Combinator = sel[pos];
pos++;
while(pos < sel.size() && is_whitespace(sel[pos]))
pos++;
}
else if (isSpace)
{
current.Combinator = ' ';
}
else
{
// unknown
current.Combinator = sel[pos];
pos++;
}
start = pos;
}
else
{
pos++;
}
}
if (failed)
{
result.clear();
}
else if (result.empty() || !current.empty())
{
// pseudo element like ':before' can only be set on the last selector
if (!result.empty() && !pseudoElement.empty())
{
// failed
result.clear();
}
else
{
result.push_back(current);
}
}
return result;
}
// ***************************************************************************
// @internal
void CCssParser::preprocess()
{
_Position = 0;
size_t start;
size_t charsLeft;
bool quote = false;
ucchar quoteChar;
while(!is_eof())
{
charsLeft = _Style.size() - _Position - 1;
// FF, CR
if (_Style[_Position] == 0x0C || _Style[_Position] == 0x0D)
{
uint len = 1;
// CR, LF
if (charsLeft >= 1 && _Style[_Position] == 0x0D && _Style[_Position+1] == 0x0A)
len++;
ucstring tmp;
tmp += 0x000A;
_Style.replace(_Position, 1, tmp);
}
else if (_Style[_Position] == 0x00)
{
// Unicode replacement character
_Style[_Position] = 0xFFFD;
}
else
{
// strip comments for easier parsing
if (_Style[_Position] == '\\')
{
_Position++;
}
else if (is_quote(_Style[_Position]))
{
if (!quote)
quoteChar = _Style[_Position];
if (quote && _Style[_Position] == quoteChar)
quote = !quote;
}
else if (!quote && is_comment_open())
{
size_t pos = _Style.find(ucstring("*/"), _Position + 2);
if (pos == std::string::npos)
pos = _Style.size();
_Style.erase(_Position, pos - _Position + 2);
ucstring uc;
uc = _Style[_Position];
// _Position is already at correct place
continue;
}
}
_Position++;
}
}
} // namespace

View file

@ -0,0 +1,314 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#include "stdpch.h"
#include <string>
#include "nel/misc/types_nl.h"
#include "nel/gui/css_selector.h"
#include "nel/gui/html_element.h"
using namespace NLMISC;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLGUI
{
CCssSelector::CCssSelector(std::string elm, std::string id, std::string cls, char comb)
: Element(elm), Id(id), Class(), Attr(), PseudoClass(), Combinator(comb)
{
if (!cls.empty())
{
setClass(cls);
}
}
uint32 CCssSelector::specificity() const
{
uint ret = 0;
if (!Element.empty() && Element != "*") ret += 0x000001;
// Pseudo Element is added in CCssStyle
//if (!PseudoElement.empty()) ret += 0x000001;
if (!Class.empty()) ret += 0x000100 * Class.size();
if (!Attr.empty()) ret += 0x000100 * Attr.size();
// TODO: has different cases
if (!PseudoClass.empty()) ret += 0x000100 * PseudoClass.size();
if (!Id.empty()) ret += 0x010000;
return ret;
}
void CCssSelector::setClass(const std::string &cls)
{
std::vector<std::string> parts;
NLMISC::splitString(toLower(cls), ".", parts);
for(uint i = 0; i< parts.size(); i++)
{
std::string cname = trim(parts[i]);
if (!cname.empty())
{
Class.push_back(cname);
}
}
}
void CCssSelector::addAttribute(const std::string &key, const std::string &val, char op)
{
Attr.push_back(SAttribute(key, val, op));
}
void CCssSelector::addPseudoClass(const std::string &key)
{
if (key.empty()) return;
PseudoClass.push_back(key);
}
bool CCssSelector::match(const CHtmlElement &elm) const
{
if (!Element.empty() && Element != "*" && Element != elm.Value)
{
return false;
}
if (!Id.empty() && Id != elm.getAttribute("id"))
{
return false;
}
if (!Class.empty() && !matchClass(elm))
{
return false;
}
if (!Attr.empty() && !matchAttributes(elm))
{
return false;
}
if (!PseudoClass.empty() && !matchPseudoClass(elm))
{
return false;
}
return true;
}
bool CCssSelector::matchClass(const CHtmlElement &elm) const
{
// make sure all class names we have, other has as well
for(uint i = 0; i< Class.size(); ++i)
{
if (!elm.hasClass(Class[i]))
{
return false;
}
}
return true;
}
bool CCssSelector::matchAttributes(const CHtmlElement &elm) const
{
// TODO: refactor into matchAttributeSelector
for(uint i = 0; i< Attr.size(); ++i)
{
if (!elm.hasAttribute(Attr[i].key)) return false;
std::string value = elm.getAttribute(Attr[i].key);
switch(Attr[i].op)
{
case '=':
if (Attr[i].value != value) return false;
break;
case '~':
{
// exact match to any of whitespace separated words from element attribute
if (Attr[i].value.empty()) return false;
std::vector<std::string> parts;
NLMISC::splitString(value, " ", parts);
bool found = false;
for(uint j = 0; j < parts.size(); j++)
{
if (Attr[i].value == parts[j])
{
found = true;
break;
}
}
if (!found) return false;
}
break;
case '|':
// exact value, or start with val+'-'
if (value != Attr[i].value && value.find(Attr[i].value + "-") == std::string::npos) return false;
break;
case '^':
// prefix, starts with
if (Attr[i].value.empty()) return false;
if (value.find(Attr[i].value) != 0) return false;
break;
case '$':
// suffic, ends with
if (Attr[i].value.empty() || value.size() < Attr[i].value.size()) return false;
if (Attr[i].value == value.substr(value.size() - Attr[i].value.size())) return false;
break;
case '*':
if (Attr[i].value.empty()) return false;
if (value.find(Attr[i].value) == std::string::npos) return false;
break;
case ' ':
// contains key, ignore value
break;
default:
// unknown comparison
return false;
}
}
return true;
}
bool CCssSelector::matchPseudoClass(const CHtmlElement &elm) const
{
for(uint i = 0; i< PseudoClass.size(); i++)
{
if (PseudoClass[i] == "root")
{
// ':root' is just 'html' with higher specificity
if (elm.Value != "html") return false;
}
else if (PseudoClass[i] == "only-child")
{
if (elm.parent && !elm.parent->Children.empty()) return false;
}
else
{
if (PseudoClass[i] == "first-child")
{
if (elm.previousSibling) return false;
}
else if (PseudoClass[i] == "last-child")
{
if (elm.nextSibling) return false;
}
else if (PseudoClass[i].find("nth-child(") != std::string::npos)
{
sint a, b;
// TODO: there might be multiple :nth-child() on single selector, so current can't cache it
parseNth(PseudoClass[i], a, b);
// 1st child should be '1' and not '0'
if (!matchNth(elm.childIndex+1, a, b)) return false;
}
else
{
return false;
}
}
}
return true;
}
void CCssSelector::parseNth(const std::string &pseudo, sint &a, sint &b) const
{
a = 0;
b = 0;
std::string::size_type start = pseudo.find_first_of("(") + 1;
std::string::size_type end = pseudo.find_first_of(")");
if (start == std::string::npos) return;
std::string expr = toLower(pseudo.substr(start, end - start));
if (expr.empty()) return;
if (expr == "even")
{
// 2n+0
a = 2;
b = 0;
}
else if (expr == "odd")
{
// 2n+1
a = 2;
b = 1;
}
else
{
// -An+B, An+B, An-B
std::string::size_type pos;
start = 0;
pos = expr.find_first_of("n", start);
if (pos == std::string::npos)
{
fromString(expr, b);
}
else if (pos == 0)
{
// 'n' == '1n'
a = 1;
}
else if (expr[0] == '-' && pos == 1)
{
// '-n' == '-1n'
a = -1;
}
else
{
fromString(expr.substr(start, pos - start), a);
}
start = pos;
pos = expr.find_first_of("+-", start);
if (pos != std::string::npos && (expr[pos] == '+' || expr[pos] == '-'))
{
// copy with sign char
fromString(expr.substr(pos, end - pos), b);
}
}
}
bool CCssSelector::matchNth(sint childNr, sint a, sint b) const
{
if (a == 0)
{
return childNr == b;
}
else if (a > 0)
{
return childNr >= b && (childNr - b) % a == 0;
}
else
{
// a is negative from '-An+B'
return childNr <= b && (b - childNr) % (-a) == 0;
}
}
} // namespace

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -843,6 +843,19 @@ namespace NLGUI
ratio -= _Columns[i].TableRatio;
}
// force table width to fit all columns
// if width is set, then use column min width
if (ForceWidthMin > 0)
tableWidthMax = std::min(_LastParentW - borderWidth, std::max(tableWidthMax, tableWidth));
else
tableWidthMax = std::min(_LastParentW - borderWidth, std::max(tableWidthMax, tableMaxContentWidth));
if (tableWidthMax < 0)
tableWidthMax = 0;
if (tableWidthMax < tableWidthMin)
std::swap(tableWidthMin, tableWidthMax);
// Eval table size with all percent cells resized
sint32 tableWidthSizeAfterPercent = tableWidth;
for (i=0; i<_Columns.size(); i++)

View file

@ -0,0 +1,168 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#include "stdpch.h"
#include "nel/gui/html_element.h"
using namespace std;
using namespace NLMISC;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLGUI
{
// ***************************************************************************
CHtmlElement::CHtmlElement(ENodeType type, std::string value)
: ID(0), Type(type), Value(value), parent(NULL), previousSibling(NULL), nextSibling(NULL), childIndex(0)
{}
// ***************************************************************************
bool CHtmlElement::hasAttribute(const std::string &key) const
{
return Attributes.find(key) != Attributes.end();
}
// ***************************************************************************
bool CHtmlElement::hasNonEmptyAttribute(const std::string &key) const
{
return !getAttribute(key).empty();
}
// ***************************************************************************
std::string CHtmlElement::getAttribute(const std::string &key) const
{
std::map<std::string, std::string>::const_iterator it = Attributes.find(key);
return (it != Attributes.end() ? it->second : "");
}
// ***************************************************************************
bool CHtmlElement::hasClass(const std::string &key) const
{
return ClassNames.find(key) != ClassNames.end();
}
// ***************************************************************************
void CHtmlElement::reindexChilds()
{
uint index = 0;
CHtmlElement *prev = NULL;
std::list<CHtmlElement>::iterator it;
for(it = Children.begin(); it != Children.end(); ++it)
{
if (it->Type == ELEMENT_NODE)
{
it->parent = this;
it->previousSibling = prev;
it->nextSibling = NULL;
if (prev)
{
prev->nextSibling = &(*it);
}
it->childIndex = index;
index++;
prev = &(*it);
}
}
}
// ***************************************************************************
std::string CHtmlElement::toString(bool tree, uint depth) const
{
std::string result;
if (depth > 0)
{
result = NLMISC::toString("[%d]", depth);
result.append(depth, '-');
}
if (Type == NONE || Type == ELEMENT_NODE)
{
result += "<" + Value;
for(std::map<std::string, std::string>::const_iterator it = Attributes.begin(); it != Attributes.end(); ++it)
{
if (it->first == "class")
{
result += " class=\"";
for(std::set<std::string>::const_iterator it2 = ClassNames.begin(); it2 != ClassNames.end(); ++it2)
{
if (it2 != ClassNames.begin())
{
result += " ";
}
result += *it2;
}
result += "\"";
}
else
{
result += " " + it->first + "=\"" + it->second + "\"";
}
}
result += NLMISC::toString(" data-debug=\"childIndex: %d\"", childIndex);
result += ">";
if (tree)
{
result += "\n";
for(std::list<CHtmlElement>::const_iterator it = Children.begin(); it != Children.end(); ++it)
{
result += it->toString(tree, depth+1);
}
if (depth > 0)
{
result += NLMISC::toString("[%d]", depth);
result.append(depth, '-');
}
result += "</" + Value + ">\n";
}
}
else
{
if (Value.find("\n") == std::string::npos)
{
result += "{" + Value + "}";
}
else
{
result += "{";
std::string::size_type start = 0;
std::string::size_type pos = Value.find_first_of("\n\r\t");
while(pos != std::string::npos)
{
result += Value.substr(start, pos - start);
if (Value[pos] == '\n')
{
result += "";
}
else if (Value[pos] == '\t')
{
result += "";
}
start = pos+1;
pos = Value.find_first_of("\n\r\t", start);
}
result += "}";
}
if (tree) result += "\n";
}
return result;
};
} // namespace

View file

@ -17,13 +17,14 @@
#include "stdpch.h"
#include "nel/gui/html_parser.h"
#include <string>
#include <libxml/HTMLparser.h>
#include "nel/misc/types_nl.h"
#include "nel/gui/libwww.h"
#include "nel/gui/group_html.h"
#include "nel/gui/lua_ihm.h"
using namespace std;
using namespace NLMISC;
@ -34,83 +35,162 @@ using namespace NLMISC;
namespace NLGUI
{
// ***************************************************************************
void CGroupHTML::htmlElement(xmlNode *node, int element_number)
void CHtmlParser::parseStyle(xmlNode *a_node, std::string &styleString) const
{
SGML_dtd *HTML_DTD = HTML_dtd ();
if (element_number < HTML_ELEMENTS)
xmlNode *node = a_node;
while(node)
{
CXMLAutoPtr ptr;
// load attributes into libwww structs
std::vector<bool> present;
std::vector<const char *>value;
std::string strvalues[MAX_ATTRIBUTES];
present.resize(30, false);
value.resize(30);
uint nbAttributes = std::min(MAX_ATTRIBUTES, HTML_DTD->tags[element_number].number_of_attributes);
for(uint i=0; i<nbAttributes; i++)
if (node->type == XML_CDATA_SECTION_NODE)
{
std::string name;
name = toLower(std::string(HTML_DTD->tags[element_number].attributes[i].name));
ptr = xmlGetProp(node, (const xmlChar *)name.c_str());
if (ptr)
{
// copy xmlChar to string (xmlChar will be released)
strvalues[i] = (const char *)(ptr);
// now use string pointer in value[] array
value[i] = strvalues[i].c_str();
present[i] = true;
}
styleString += (const char*)node->content;
}
else
{
nlwarning("<style> tag has child elements other than cdata[%d]", node->type);
}
beginElement(element_number, present, value);
}
else
{
beginUnparsedElement((const char *)(node->name), xmlStrlen(node->name));
}
// recursive - text content / child nodes
htmlWalkDOM(node->children);
// closing tag
if (element_number < HTML_ELEMENTS)
{
endElement(element_number);
}
else
{
endUnparsedElement((const char *)(node->name), xmlStrlen(node->name));
node = node->next;
}
}
// ***************************************************************************
// recursive function to walk html document
void CGroupHTML::htmlWalkDOM(xmlNode *a_node)
void CHtmlParser::parseNode(xmlNode *a_node, CHtmlElement &parent, std::string &styleString, std::vector<std::string> &links) const
{
SGML_dtd *HTML_DTD = HTML_dtd ();
uint childIndex = 0;
uint element_number;
xmlNode *node = a_node;
while(node)
{
if (node->type == XML_TEXT_NODE)
{
addText((const char *)(node->content), xmlStrlen(node->content));
parent.Children.push_back(CHtmlElement(CHtmlElement::TEXT_NODE, (const char*)(node->content)));
}
else
if (node->type == XML_ELEMENT_NODE)
{
// find libwww tag
for(element_number = 0; element_number<HTML_ELEMENTS; ++element_number)
// find html element
element_number = htmlElementLookup((const char*)node->name);
// get pointer to previous sibling
CHtmlElement *prevSibling = NULL;
if (!parent.Children.empty())
{
if (xmlStrncasecmp(node->name, (const xmlChar *)HTML_DTD->tags[element_number].name.c_str(), xmlStrlen(node->name)) == 0)
break;
// skip text nodes
for(std::list<CHtmlElement>::reverse_iterator it = parent.Children.rbegin(); it != parent.Children.rend(); ++it)
{
if (it->Type == CHtmlElement::ELEMENT_NODE)
{
prevSibling = &(*it);
break;
}
}
}
htmlElement(node, element_number);
parent.Children.push_back(CHtmlElement(CHtmlElement::ELEMENT_NODE, toLower((const char*)node->name)));
CHtmlElement &elm = parent.Children.back();
elm.ID = element_number;
elm.parent = &parent;
elm.childIndex = childIndex;
// previous/next sibling that is ELEMENT_NODE
elm.previousSibling = prevSibling;
if (prevSibling)
{
prevSibling->nextSibling = &parent.Children.back();
}
childIndex++;
// TODO: harvest <link type="css">, <style>, <img>
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 value;
if (cur_attr->children)
{
value = (const char *)(cur_attr->children->content);
}
elm.Attributes[key] = value;
}
if (elm.hasAttribute("class"))
{
std::vector<std::string> parts;
NLMISC::splitString(elm.getAttribute("class"), " ", parts);
for(uint i = 0; i<parts.size();++i)
{
elm.ClassNames.insert(toLower(trim(parts[i])));
}
}
if (elm.Value == "style")
{
// <style type="text/css" media="all, screen">
// ...
// </style>
bool useStyle = true;
if (elm.hasAttribute("media"))
{
std::string media = trim(toLower(elm.Attributes["media"]));
useStyle = media.empty() || media.find("all") != std::string::npos || media.find("screen") != std::string::npos;
// <style media="ryzom"> for ingame browser
useStyle = useStyle || media == "ryzom";
}
if (useStyle)
{
parseStyle(node->children, styleString);
}
// style tag is kept in dom
}
if (elm.Value == "link" && elm.getAttribute("rel") == "stylesheet")
{
bool useStyle = true;
if (elm.hasAttribute("media"))
{
std::string media = trim(toLower(elm.Attributes["media"]));
useStyle = media.empty() || media.find("all") != std::string::npos || media.find("screen") != std::string::npos;
// <style media="ryzom"> for ingame browser
useStyle = useStyle || media == "ryzom";
}
if (useStyle)
{
links.push_back(elm.getAttribute("href"));
}
// link tag is kept in dom
}
else if (node->children)
{
parseNode(node->children, elm, styleString, links);
// must cleanup nested tags that libxml2 does not fix
// dt without end tag: <dl><dt><dt></dl>
// dd without end tag: <dl><dd><dd></dl>
if (!elm.Children.empty() && (elm.Value == "dt" || elm.Value == "dd"))
{
std::string tag = elm.Value;
std::list<CHtmlElement>::iterator it;
for(it = elm.Children.begin(); it != elm.Children.end(); ++it)
{
if (it->Type == CHtmlElement::ELEMENT_NODE && it->Value == tag)
{
// relocate this and remaining elements over to parent
parent.Children.splice(parent.Children.end(), elm.Children, it, elm.Children.end());
break;
}
}
elm.reindexChilds();
parent.reindexChilds();
}
}
}
// move into next sibling
@ -297,13 +377,13 @@ namespace NLGUI
}
// ***************************************************************************
bool CGroupHTML::parseHtml(std::string htmlString)
void CHtmlParser::getDOM(std::string htmlString, CHtmlElement &dom, std::string &styleString, std::vector<std::string> &links) const
{
htmlParserCtxtPtr parser = htmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL, XML_CHAR_ENCODING_UTF8);
if (!parser)
{
nlwarning("Creating html parser context failed");
return false;
return;
}
htmlCtxtUseOptions(parser, HTML_PARSE_NOBLANKS | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING | HTML_PARSE_NONET);
@ -314,43 +394,28 @@ namespace NLGUI
htmlParseChunk(parser, htmlString.c_str(), htmlString.size(), 0);
htmlParseChunk(parser, "", 0, 1);
bool success = true;
if (parser->myDoc)
{
xmlNode *root = xmlDocGetRootElement(parser->myDoc);
if (root)
{
htmlWalkDOM(root);
styleString.clear();
parseNode(root, dom, styleString, links);
}
else
{
nlwarning("html root node failed");
success = false;
}
xmlFreeDoc(parser->myDoc);
}
else
{
nlwarning("htmlstring parsing failed");
success = false;
}
htmlFreeParserCtxt(parser);
return success;
}
// ***************************************************************************
int CGroupHTML::luaParseHtml(CLuaState &ls)
{
const char *funcName = "parseHtml";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
std::string html = ls.toString(1);
parseHtml(html);
return 0;
}
}

View file

@ -29,6 +29,167 @@ using namespace NLMISC;
namespace NLGUI
{
struct CNameToHtmlElement
{
HTMLElement ID;
const char* Name;
CNameToHtmlElement(HTMLElement id, const char*name)
: ID(id), Name(name) {}
};
// sorted list of HTML_ELEMENT enum to TAG name
static CNameToHtmlElement htmlElementToName[] =
{
CNameToHtmlElement(HTML_A, "a"),
CNameToHtmlElement(HTML_ABBR, "abbr"),
CNameToHtmlElement(HTML_ADDRESS, "address"),
CNameToHtmlElement(HTML_APPLET, "applet"),
CNameToHtmlElement(HTML_AREA, "area"),
CNameToHtmlElement(HTML_ARTICLE, "article"),
CNameToHtmlElement(HTML_ASIDE, "aside"),
CNameToHtmlElement(HTML_AUDIO, "audio"),
CNameToHtmlElement(HTML_B, "b"),
CNameToHtmlElement(HTML_BASE, "base"),
CNameToHtmlElement(HTML_BDI, "bdi"),
CNameToHtmlElement(HTML_BDO, "bdo"),
CNameToHtmlElement(HTML_BLOCKQUOTE, "blockquote"),
CNameToHtmlElement(HTML_BODY, "body"),
CNameToHtmlElement(HTML_BR, "br"),
CNameToHtmlElement(HTML_BUTTON, "button"),
CNameToHtmlElement(HTML_CANVAS, "canvas"),
CNameToHtmlElement(HTML_CAPTION, "caption"),
CNameToHtmlElement(HTML_CITE, "cite"),
CNameToHtmlElement(HTML_CODE, "code"),
CNameToHtmlElement(HTML_COL, "col"),
CNameToHtmlElement(HTML_COLGROUP, "colgroup"),
CNameToHtmlElement(HTML_DATA, "data"),
CNameToHtmlElement(HTML_DATALIST, "datalist"),
CNameToHtmlElement(HTML_DD, "dd"),
CNameToHtmlElement(HTML_DEL, "del"),
CNameToHtmlElement(HTML_DETAILS, "details"),
CNameToHtmlElement(HTML_DFN, "dfn"),
CNameToHtmlElement(HTML_DIALOG, "dialog"),
CNameToHtmlElement(HTML_DIR, "dir"),
CNameToHtmlElement(HTML_DIV, "div"),
CNameToHtmlElement(HTML_DL, "dl"),
CNameToHtmlElement(HTML_DT, "dt"),
CNameToHtmlElement(HTML_EM, "em"),
CNameToHtmlElement(HTML_EMBED, "embed"),
CNameToHtmlElement(HTML_FIELDSET, "fieldset"),
CNameToHtmlElement(HTML_FIGCAPTION, "figcaption"),
CNameToHtmlElement(HTML_FIGURE, "figure"),
CNameToHtmlElement(HTML_FONT, "font"),
CNameToHtmlElement(HTML_FOOTER, "footer"),
CNameToHtmlElement(HTML_FORM, "form"),
CNameToHtmlElement(HTML_H1, "h1"),
CNameToHtmlElement(HTML_H2, "h2"),
CNameToHtmlElement(HTML_H3, "h3"),
CNameToHtmlElement(HTML_H4, "h4"),
CNameToHtmlElement(HTML_H5, "h5"),
CNameToHtmlElement(HTML_H6, "h6"),
CNameToHtmlElement(HTML_HEAD, "head"),
CNameToHtmlElement(HTML_HEADER, "header"),
CNameToHtmlElement(HTML_HGROUP, "hgroup"),
CNameToHtmlElement(HTML_HR, "hr"),
CNameToHtmlElement(HTML_HTML, "html"),
CNameToHtmlElement(HTML_I, "i"),
CNameToHtmlElement(HTML_IFRAME, "iframe"),
CNameToHtmlElement(HTML_IMG, "img"),
CNameToHtmlElement(HTML_INPUT, "input"),
CNameToHtmlElement(HTML_INS, "ins"),
CNameToHtmlElement(HTML_KBD, "kbd"),
CNameToHtmlElement(HTML_LABEL, "label"),
CNameToHtmlElement(HTML_LEGEND, "legend"),
CNameToHtmlElement(HTML_LI, "li"),
CNameToHtmlElement(HTML_LINK, "link"),
CNameToHtmlElement(HTML_LUA, "lua"),
CNameToHtmlElement(HTML_MAIN, "main"),
CNameToHtmlElement(HTML_MAP, "map"),
CNameToHtmlElement(HTML_MARK, "mark"),
CNameToHtmlElement(HTML_MENU, "menu"),
CNameToHtmlElement(HTML_MENUITEM, "menuitem"),
CNameToHtmlElement(HTML_META, "meta"),
CNameToHtmlElement(HTML_METER, "meter"),
CNameToHtmlElement(HTML_NAV, "nav"),
CNameToHtmlElement(HTML_NOEMBED, "noembed"),
CNameToHtmlElement(HTML_NOSCRIPT, "noscript"),
CNameToHtmlElement(HTML_OBJECT, "object"),
CNameToHtmlElement(HTML_OL, "ol"),
CNameToHtmlElement(HTML_OPTGROUP, "optgroup"),
CNameToHtmlElement(HTML_OPTION, "option"),
CNameToHtmlElement(HTML_OUTPUT, "output"),
CNameToHtmlElement(HTML_P, "p"),
CNameToHtmlElement(HTML_PARAM, "param"),
CNameToHtmlElement(HTML_PICTURE, "picture"),
CNameToHtmlElement(HTML_PRE, "pre"),
CNameToHtmlElement(HTML_PROGRESS, "progress"),
CNameToHtmlElement(HTML_Q, "q"),
CNameToHtmlElement(HTML_RB, "rb"),
CNameToHtmlElement(HTML_RP, "rp"),
CNameToHtmlElement(HTML_RT, "rt"),
CNameToHtmlElement(HTML_RTC, "rtc"),
CNameToHtmlElement(HTML_RUBY, "ruby"),
CNameToHtmlElement(HTML_S, "s"),
CNameToHtmlElement(HTML_SAMP, "samp"),
CNameToHtmlElement(HTML_SCRIPT, "script"),
CNameToHtmlElement(HTML_SECTION, "section"),
CNameToHtmlElement(HTML_SELECT, "select"),
CNameToHtmlElement(HTML_SMALL, "small"),
CNameToHtmlElement(HTML_SOURCE, "source"),
CNameToHtmlElement(HTML_SPAN, "span"),
CNameToHtmlElement(HTML_STRONG, "strong"),
CNameToHtmlElement(HTML_STYLE, "style"),
CNameToHtmlElement(HTML_SUB, "sub"),
CNameToHtmlElement(HTML_SUMMARY, "summary"),
CNameToHtmlElement(HTML_SUP, "sup"),
CNameToHtmlElement(HTML_TABLE, "table"),
CNameToHtmlElement(HTML_TBODY, "tbody"),
CNameToHtmlElement(HTML_TD, "td"),
CNameToHtmlElement(HTML_TEXTAREA, "textarea"),
CNameToHtmlElement(HTML_TFOOT, "tfoot"),
CNameToHtmlElement(HTML_TH, "th"),
CNameToHtmlElement(HTML_THEAD, "thead"),
CNameToHtmlElement(HTML_TIME, "time"),
CNameToHtmlElement(HTML_TITLE, "title"),
CNameToHtmlElement(HTML_TR, "tr"),
CNameToHtmlElement(HTML_TRACK, "track"),
CNameToHtmlElement(HTML_TT, "tt"),
CNameToHtmlElement(HTML_U, "u"),
CNameToHtmlElement(HTML_UL, "ul"),
CNameToHtmlElement(HTML_VAR, "var"),
CNameToHtmlElement(HTML_VIDEO, "video"),
CNameToHtmlElement(HTML_WBR, "wbr")
};
HTMLElement htmlElementLookup(const char* name)
{
uint end = sizeofarray(htmlElementToName);
uint mid = end >> 1;
sint ret;
while(mid < end)
{
sint ret = nlstricmp(name, htmlElementToName[mid].Name);
if (ret == 0)
{
return htmlElementToName[mid].ID;
}
else if (ret < 0)
{
// lower half
end = mid;
mid = end >> 1;
}
else
{
// upper half
mid++;
mid += (end - mid) >> 1;
}
}
// not found
return HTML_NB_ELEMENTS;
}
// ***************************************************************************
@ -40,258 +201,6 @@ namespace NLGUI
// ***************************************************************************
// Some DTD table
// Here, modify the DTD table to change the HTML parser (add new tags for examples)
#undef HTML_ATTR
#define HTML_ATTR(a,b) { (char*) #b }
HTAttr html_attr[] =
{
HTML_ATTR(HTML,DIR),
HTML_ATTR(HTML,LANG),
HTML_ATTR(HTML,VERSION),
HTML_ATTR(HTML,STYLE),
{ 0 }
};
HTAttr a_attr[] =
{
HTML_ATTR(A,ACCESSKEY),
HTML_ATTR(A,CHARSET),
HTML_ATTR(A,CLASS),
HTML_ATTR(A,COORDS),
HTML_ATTR(A,DIR),
HTML_ATTR(A,HREF),
HTML_ATTR(A,HREFLANG),
HTML_ATTR(A,ID),
HTML_ATTR(A,NAME),
HTML_ATTR(A,REL),
HTML_ATTR(A,REV),
HTML_ATTR(A,SHAPE),
HTML_ATTR(A,STYLE),
HTML_ATTR(A,TABINDEX),
HTML_ATTR(A,TARGET),
HTML_ATTR(A,TYPE),
HTML_ATTR(A,TITLE),
HTML_ATTR(A,Z_ACTION_CATEGORY),
HTML_ATTR(A,Z_ACTION_PARAMS),
HTML_ATTR(A,Z_ACTION_SHORTCUT),
{ 0 }
};
HTAttr table_attr[] =
{
HTML_ATTR(TABLE,ALIGN),
HTML_ATTR(TABLE,BGCOLOR),
HTML_ATTR(TABLE,BORDER),
HTML_ATTR(TABLE,BORDERCOLOR),
HTML_ATTR(TABLE,CELLPADDING),
HTML_ATTR(TABLE,CELLSPACING),
HTML_ATTR(TABLE,CLASS),
HTML_ATTR(TABLE,DIR),
HTML_ATTR(TABLE,FRAME),
HTML_ATTR(TABLE,ID),
HTML_ATTR(TABLE,L_MARGIN),
HTML_ATTR(TABLE,LANG),
HTML_ATTR(TABLE,NOWRAP),
HTML_ATTR(TABLE,RULES),
HTML_ATTR(TABLE,SUMMARY),
HTML_ATTR(TABLE,STYLE),
HTML_ATTR(TABLE,TITLE),
HTML_ATTR(TABLE,VALIGN),
HTML_ATTR(TABLE,WIDTH),
{ 0 }
};
HTAttr tr_attr[] =
{
HTML_ATTR(TR,ALIGN),
HTML_ATTR(TR,BGCOLOR),
HTML_ATTR(TR,L_MARGIN),
HTML_ATTR(TR,NOWRAP),
HTML_ATTR(TR,VALIGN),
HTML_ATTR(TR,STYLE),
{ 0 }
};
HTAttr td_attr[] =
{
HTML_ATTR(TD,ABBR),
HTML_ATTR(TD,ALIGN),
HTML_ATTR(TD,AXIS),
HTML_ATTR(TD,BGCOLOR),
HTML_ATTR(TD,CHAR),
HTML_ATTR(TD,CHAROFF),
HTML_ATTR(TD,CLASS),
HTML_ATTR(TD,COLSPAN),
HTML_ATTR(TD,DIR),
HTML_ATTR(TD,ID),
HTML_ATTR(TD,HEADERS),
HTML_ATTR(TD,HEIGHT),
HTML_ATTR(TD,L_MARGIN),
HTML_ATTR(TD,LANG),
HTML_ATTR(TD,NOWRAP),
HTML_ATTR(TD,ROWSPAN),
HTML_ATTR(TD,SCOPE),
HTML_ATTR(TD,STYLE),
HTML_ATTR(TD,TITLE),
HTML_ATTR(TD,VALIGN),
HTML_ATTR(TD,WIDTH),
{ 0 }
};
HTAttr img_attr[] =
{
HTML_ATTR(IMG,ALIGN),
HTML_ATTR(IMG,ALT),
HTML_ATTR(IMG,BORDER),
HTML_ATTR(IMG,CLASS),
HTML_ATTR(IMG,DIR),
HTML_ATTR(IMG,GLOBAL_COLOR),
HTML_ATTR(IMG,HEIGHT),
HTML_ATTR(IMG,HSPACE),
HTML_ATTR(IMG,ID),
HTML_ATTR(IMG,ISMAP),
HTML_ATTR(IMG,LANG),
HTML_ATTR(IMG,LONGDESC),
HTML_ATTR(IMG,SRC),
HTML_ATTR(IMG,STYLE),
HTML_ATTR(IMG,TITLE),
HTML_ATTR(IMG,USEMAP),
HTML_ATTR(IMG,VSPACE),
HTML_ATTR(IMG,WIDTH),
// not sorted to keep enum values
HTML_ATTR(IMG,DATA-OVER-SRC),
{ 0 }
};
HTAttr input_attr[] =
{
HTML_ATTR(INPUT,ACCEPT),
HTML_ATTR(INPUT,ACCESSKEY),
HTML_ATTR(INPUT,ALIGN),
HTML_ATTR(INPUT,ALT),
HTML_ATTR(INPUT,CHECKED),
HTML_ATTR(INPUT,CLASS),
HTML_ATTR(INPUT,DIR),
HTML_ATTR(INPUT,DISABLED),
HTML_ATTR(INPUT,GLOBAL_COLOR),
HTML_ATTR(INPUT,ID),
HTML_ATTR(INPUT,LANG),
HTML_ATTR(INPUT,MAXLENGTH),
HTML_ATTR(INPUT,NAME),
HTML_ATTR(INPUT,READONLY),
HTML_ATTR(INPUT,SIZE),
HTML_ATTR(INPUT,SRC),
HTML_ATTR(INPUT,STYLE),
HTML_ATTR(INPUT,TABINDEX),
HTML_ATTR(INPUT,TITLE),
HTML_ATTR(INPUT,TYPE),
HTML_ATTR(INPUT,USEMAP),
HTML_ATTR(INPUT,VALUE),
HTML_ATTR(INPUT,Z_BTN_TMPL),
HTML_ATTR(INPUT,Z_INPUT_TMPL),
HTML_ATTR(INPUT,Z_INPUT_WIDTH),
{ 0 }
};
HTAttr textarea_attr[] =
{
HTML_ATTR(TEXTAREA,CLASS),
HTML_ATTR(TEXTAREA,COLS),
HTML_ATTR(TEXTAREA,DIR),
HTML_ATTR(TEXTAREA,DISABLED),
HTML_ATTR(TEXTAREA,ID),
HTML_ATTR(TEXTAREA,LANG),
HTML_ATTR(TEXTAREA,MAXLENGTH),
HTML_ATTR(TEXTAREA,NAME),
HTML_ATTR(TEXTAREA,READONLY),
HTML_ATTR(TEXTAREA,ROWS),
HTML_ATTR(TEXTAREA,STYLE),
HTML_ATTR(TEXTAREA,TABINDEX),
HTML_ATTR(TEXTAREA,TITLE),
HTML_ATTR(TEXTAREA,Z_INPUT_TMPL),
{ 0 }
};
HTAttr p_attr[] =
{
HTML_ATTR(P,QUICK_HELP_CONDITION),
HTML_ATTR(P,QUICK_HELP_EVENTS),
HTML_ATTR(P,QUICK_HELP_LINK),
HTML_ATTR(P,NAME),
HTML_ATTR(P,STYLE),
{ 0 }
};
HTAttr div_attr[] =
{
HTML_ATTR(DIV,CLASS),
HTML_ATTR(DIV,ID),
HTML_ATTR(DIV,NAME),
HTML_ATTR(DIV,STYLE),
{ 0 }
};
HTAttr span_attr[] =
{
HTML_ATTR(SPAN,CLASS),
HTML_ATTR(SPAN,ID),
HTML_ATTR(SPAN,STYLE),
{ 0 }
};
HTAttr h1_attr[] =
{
HTML_ATTR(H1,CLASS),
HTML_ATTR(H1,ID),
HTML_ATTR(H1,STYLE),
{ 0 }
};
HTAttr h2_attr[] =
{
HTML_ATTR(H2,CLASS),
HTML_ATTR(H2,ID),
HTML_ATTR(H2,STYLE),
{ 0 }
};
HTAttr h3_attr[] =
{
HTML_ATTR(H3,CLASS),
HTML_ATTR(H3,ID),
HTML_ATTR(H3,STYLE),
{ 0 }
};
HTAttr h4_attr[] =
{
HTML_ATTR(H4,CLASS),
HTML_ATTR(H4,ID),
HTML_ATTR(H4,STYLE),
{ 0 }
};
HTAttr h5_attr[] =
{
HTML_ATTR(H5,CLASS),
HTML_ATTR(H5,ID),
HTML_ATTR(H5,STYLE),
{ 0 }
};
HTAttr h6_attr[] =
{
HTML_ATTR(H6,CLASS),
HTML_ATTR(H6,ID),
HTML_ATTR(H6,STYLE),
{ 0 }
};
// ***************************************************************************
bool getCssLength (float &value, std::string &unit, const std::string &str)
{
@ -345,6 +254,373 @@ namespace NLGUI
}
}
static bool isHexa(char c)
{
return isdigit(c) || (tolower(c) >= 'a' && tolower(c) <= 'f');
}
static uint8 convertHexa(char c)
{
return (uint8) (tolower(c) - (isdigit(c) ? '0' : ('a' - 10)));
}
// scan a color component, and return pointer to next position
static const char *scanColorComponent(const char *src, uint8 &intensity)
{
if (!src) return NULL;
if (!isHexa(*src)) return NULL;
uint8 value = convertHexa(*src++) << 4;
if (!isHexa(*src)) return NULL;
value += convertHexa(*src++);
intensity = value;
return src;
}
static float hueToRgb(float m1, float m2, float h)
{
if (h < 0) h += 1.0f;
if (h > 1) h -= 1.0f;
if (h*6 < 1.0f) return m1 + (m2 - m1)*h*6;
if (h*2 < 1.0f) return m2;
if (h*3 < 2.0f) return m1 + (m2 - m1) * (2.0f/3.0f - h)*6;
return m1;
}
static void hslToRgb(float h, float s, float l, CRGBA &result)
{
float m1, m2;
if (l <= 0.5f)
m2 = l * (s + 1.0f);
else
m2 = l + s - l * s;
m1 = l*2 - m2;
result.R = 255 * hueToRgb(m1, m2, h + 1.0f/3.0f);
result.G = 255 * hueToRgb(m1, m2, h);
result.B = 255 * hueToRgb(m1, m2, h - 1.0f/3.0f);
result.A = 255;
}
class CNameToCol
{
public:
const char *Name;
CRGBA Color;
CNameToCol(const char *name, CRGBA color) : Name(name), Color(color) {}
};
static CNameToCol htmlColorNameToRGBA[] =
{
CNameToCol("AliceBlue", CRGBA(0xF0, 0xF8, 0xFF)),
CNameToCol("AntiqueWhite", CRGBA(0xFA, 0xEB, 0xD7)),
CNameToCol("Aqua", CRGBA(0x00, 0xFF, 0xFF)),
CNameToCol("Aquamarine", CRGBA(0x7F, 0xFF, 0xD4)),
CNameToCol("Azure", CRGBA(0xF0, 0xFF, 0xFF)),
CNameToCol("Beige", CRGBA(0xF5, 0xF5, 0xDC)),
CNameToCol("Bisque", CRGBA(0xFF, 0xE4, 0xC4)),
CNameToCol("Black", CRGBA(0x00, 0x00, 0x00)),
CNameToCol("BlanchedAlmond", CRGBA(0xFF, 0xEB, 0xCD)),
CNameToCol("Blue", CRGBA(0x00, 0x00, 0xFF)),
CNameToCol("BlueViolet", CRGBA(0x8A, 0x2B, 0xE2)),
CNameToCol("Brown", CRGBA(0xA5, 0x2A, 0x2A)),
CNameToCol("BurlyWood", CRGBA(0xDE, 0xB8, 0x87)),
CNameToCol("CadetBlue", CRGBA(0x5F, 0x9E, 0xA0)),
CNameToCol("Chartreuse", CRGBA(0x7F, 0xFF, 0x00)),
CNameToCol("Chocolate", CRGBA(0xD2, 0x69, 0x1E)),
CNameToCol("Coral", CRGBA(0xFF, 0x7F, 0x50)),
CNameToCol("CornflowerBlue", CRGBA(0x64, 0x95, 0xED)),
CNameToCol("Cornsilk", CRGBA(0xFF, 0xF8, 0xDC)),
CNameToCol("Crimson", CRGBA(0xDC, 0x14, 0x3C)),
CNameToCol("Cyan", CRGBA(0x00, 0xFF, 0xFF)),
CNameToCol("DarkBlue", CRGBA(0x00, 0x00, 0x8B)),
CNameToCol("DarkCyan", CRGBA(0x00, 0x8B, 0x8B)),
CNameToCol("DarkGoldenRod", CRGBA(0xB8, 0x86, 0x0B)),
CNameToCol("DarkGray", CRGBA(0xA9, 0xA9, 0xA9)),
CNameToCol("DarkGreen", CRGBA(0x00, 0x64, 0x00)),
CNameToCol("DarkKhaki", CRGBA(0xBD, 0xB7, 0x6B)),
CNameToCol("DarkMagenta", CRGBA(0x8B, 0x00, 0x8B)),
CNameToCol("DarkOliveGreen", CRGBA(0x55, 0x6B, 0x2F)),
CNameToCol("Darkorange", CRGBA(0xFF, 0x8C, 0x00)),
CNameToCol("DarkOrchid", CRGBA(0x99, 0x32, 0xCC)),
CNameToCol("DarkRed", CRGBA(0x8B, 0x00, 0x00)),
CNameToCol("DarkSalmon", CRGBA(0xE9, 0x96, 0x7A)),
CNameToCol("DarkSeaGreen", CRGBA(0x8F, 0xBC, 0x8F)),
CNameToCol("DarkSlateBlue", CRGBA(0x48, 0x3D, 0x8B)),
CNameToCol("DarkSlateGray", CRGBA(0x2F, 0x4F, 0x4F)),
CNameToCol("DarkTurquoise", CRGBA(0x00, 0xCE, 0xD1)),
CNameToCol("DarkViolet", CRGBA(0x94, 0x00, 0xD3)),
CNameToCol("DeepPink", CRGBA(0xFF, 0x14, 0x93)),
CNameToCol("DeepSkyBlue", CRGBA(0x00, 0xBF, 0xFF)),
CNameToCol("DimGray", CRGBA(0x69, 0x69, 0x69)),
CNameToCol("DodgerBlue", CRGBA(0x1E, 0x90, 0xFF)),
CNameToCol("Feldspar", CRGBA(0xD1, 0x92, 0x75)),
CNameToCol("FireBrick", CRGBA(0xB2, 0x22, 0x22)),
CNameToCol("FloralWhite", CRGBA(0xFF, 0xFA, 0xF0)),
CNameToCol("ForestGreen", CRGBA(0x22, 0x8B, 0x22)),
CNameToCol("Fuchsia", CRGBA(0xFF, 0x00, 0xFF)),
CNameToCol("Gainsboro", CRGBA(0xDC, 0xDC, 0xDC)),
CNameToCol("GhostWhite", CRGBA(0xF8, 0xF8, 0xFF)),
CNameToCol("Gold", CRGBA(0xFF, 0xD7, 0x00)),
CNameToCol("GoldenRod", CRGBA(0xDA, 0xA5, 0x20)),
CNameToCol("Gray", CRGBA(0x80, 0x80, 0x80)),
CNameToCol("Green", CRGBA(0x00, 0x80, 0x00)),
CNameToCol("GreenYellow", CRGBA(0xAD, 0xFF, 0x2F)),
CNameToCol("HoneyDew", CRGBA(0xF0, 0xFF, 0xF0)),
CNameToCol("HotPink", CRGBA(0xFF, 0x69, 0xB4)),
CNameToCol("IndianRed ", CRGBA(0xCD, 0x5C, 0x5C)),
CNameToCol("Indigo ", CRGBA(0x4B, 0x00, 0x82)),
CNameToCol("Ivory", CRGBA(0xFF, 0xFF, 0xF0)),
CNameToCol("Khaki", CRGBA(0xF0, 0xE6, 0x8C)),
CNameToCol("Lavender", CRGBA(0xE6, 0xE6, 0xFA)),
CNameToCol("LavenderBlush", CRGBA(0xFF, 0xF0, 0xF5)),
CNameToCol("LawnGreen", CRGBA(0x7C, 0xFC, 0x00)),
CNameToCol("LemonChiffon", CRGBA(0xFF, 0xFA, 0xCD)),
CNameToCol("LightBlue", CRGBA(0xAD, 0xD8, 0xE6)),
CNameToCol("LightCoral", CRGBA(0xF0, 0x80, 0x80)),
CNameToCol("LightCyan", CRGBA(0xE0, 0xFF, 0xFF)),
CNameToCol("LightGoldenRodYellow", CRGBA(0xFA, 0xFA, 0xD2)),
CNameToCol("LightGrey", CRGBA(0xD3, 0xD3, 0xD3)),
CNameToCol("LightGreen", CRGBA(0x90, 0xEE, 0x90)),
CNameToCol("LightPink", CRGBA(0xFF, 0xB6, 0xC1)),
CNameToCol("LightSalmon", CRGBA(0xFF, 0xA0, 0x7A)),
CNameToCol("LightSeaGreen", CRGBA(0x20, 0xB2, 0xAA)),
CNameToCol("LightSkyBlue", CRGBA(0x87, 0xCE, 0xFA)),
CNameToCol("LightSlateBlue", CRGBA(0x84, 0x70, 0xFF)),
CNameToCol("LightSlateGray", CRGBA(0x77, 0x88, 0x99)),
CNameToCol("LightSteelBlue", CRGBA(0xB0, 0xC4, 0xDE)),
CNameToCol("LightYellow", CRGBA(0xFF, 0xFF, 0xE0)),
CNameToCol("Lime", CRGBA(0x00, 0xFF, 0x00)),
CNameToCol("LimeGreen", CRGBA(0x32, 0xCD, 0x32)),
CNameToCol("Linen", CRGBA(0xFA, 0xF0, 0xE6)),
CNameToCol("Magenta", CRGBA(0xFF, 0x00, 0xFF)),
CNameToCol("Maroon", CRGBA(0x80, 0x00, 0x00)),
CNameToCol("MediumAquaMarine", CRGBA(0x66, 0xCD, 0xAA)),
CNameToCol("MediumBlue", CRGBA(0x00, 0x00, 0xCD)),
CNameToCol("MediumOrchid", CRGBA(0xBA, 0x55, 0xD3)),
CNameToCol("MediumPurple", CRGBA(0x93, 0x70, 0xD8)),
CNameToCol("MediumSeaGreen", CRGBA(0x3C, 0xB3, 0x71)),
CNameToCol("MediumSlateBlue", CRGBA(0x7B, 0x68, 0xEE)),
CNameToCol("MediumSpringGreen", CRGBA(0x00, 0xFA, 0x9A)),
CNameToCol("MediumTurquoise", CRGBA(0x48, 0xD1, 0xCC)),
CNameToCol("MediumVioletRed", CRGBA(0xC7, 0x15, 0x85)),
CNameToCol("MidnightBlue", CRGBA(0x19, 0x19, 0x70)),
CNameToCol("MintCream", CRGBA(0xF5, 0xFF, 0xFA)),
CNameToCol("MistyRose", CRGBA(0xFF, 0xE4, 0xE1)),
CNameToCol("Moccasin", CRGBA(0xFF, 0xE4, 0xB5)),
CNameToCol("NavajoWhite", CRGBA(0xFF, 0xDE, 0xAD)),
CNameToCol("Navy", CRGBA(0x00, 0x00, 0x80)),
CNameToCol("OldLace", CRGBA(0xFD, 0xF5, 0xE6)),
CNameToCol("Olive", CRGBA(0x80, 0x80, 0x00)),
CNameToCol("OliveDrab", CRGBA(0x6B, 0x8E, 0x23)),
CNameToCol("Orange", CRGBA(0xFF, 0xA5, 0x00)),
CNameToCol("OrangeRed", CRGBA(0xFF, 0x45, 0x00)),
CNameToCol("Orchid", CRGBA(0xDA, 0x70, 0xD6)),
CNameToCol("PaleGoldenRod", CRGBA(0xEE, 0xE8, 0xAA)),
CNameToCol("PaleGreen", CRGBA(0x98, 0xFB, 0x98)),
CNameToCol("PaleTurquoise", CRGBA(0xAF, 0xEE, 0xEE)),
CNameToCol("PaleVioletRed", CRGBA(0xD8, 0x70, 0x93)),
CNameToCol("PapayaWhip", CRGBA(0xFF, 0xEF, 0xD5)),
CNameToCol("PeachPuff", CRGBA(0xFF, 0xDA, 0xB9)),
CNameToCol("Peru", CRGBA(0xCD, 0x85, 0x3F)),
CNameToCol("Pink", CRGBA(0xFF, 0xC0, 0xCB)),
CNameToCol("Plum", CRGBA(0xDD, 0xA0, 0xDD)),
CNameToCol("PowderBlue", CRGBA(0xB0, 0xE0, 0xE6)),
CNameToCol("Purple", CRGBA(0x80, 0x00, 0x80)),
CNameToCol("Red", CRGBA(0xFF, 0x00, 0x00)),
CNameToCol("RosyBrown", CRGBA(0xBC, 0x8F, 0x8F)),
CNameToCol("RoyalBlue", CRGBA(0x41, 0x69, 0xE1)),
CNameToCol("SaddleBrown", CRGBA(0x8B, 0x45, 0x13)),
CNameToCol("Salmon", CRGBA(0xFA, 0x80, 0x72)),
CNameToCol("SandyBrown", CRGBA(0xF4, 0xA4, 0x60)),
CNameToCol("SeaGreen", CRGBA(0x2E, 0x8B, 0x57)),
CNameToCol("SeaShell", CRGBA(0xFF, 0xF5, 0xEE)),
CNameToCol("Sienna", CRGBA(0xA0, 0x52, 0x2D)),
CNameToCol("Silver", CRGBA(0xC0, 0xC0, 0xC0)),
CNameToCol("SkyBlue", CRGBA(0x87, 0xCE, 0xEB)),
CNameToCol("SlateBlue", CRGBA(0x6A, 0x5A, 0xCD)),
CNameToCol("SlateGray", CRGBA(0x70, 0x80, 0x90)),
CNameToCol("Snow", CRGBA(0xFF, 0xFA, 0xFA)),
CNameToCol("SpringGreen", CRGBA(0x00, 0xFF, 0x7F)),
CNameToCol("SteelBlue", CRGBA(0x46, 0x82, 0xB4)),
CNameToCol("Tan", CRGBA(0xD2, 0xB4, 0x8C)),
CNameToCol("Teal", CRGBA(0x00, 0x80, 0x80)),
CNameToCol("Thistle", CRGBA(0xD8, 0xBF, 0xD8)),
CNameToCol("Tomato", CRGBA(0xFF, 0x63, 0x47)),
CNameToCol("Turquoise", CRGBA(0x40, 0xE0, 0xD0)),
CNameToCol("Violet", CRGBA(0xEE, 0x82, 0xEE)),
CNameToCol("VioletRed", CRGBA(0xD0, 0x20, 0x90)),
CNameToCol("Wheat", CRGBA(0xF5, 0xDE, 0xB3)),
CNameToCol("White", CRGBA(0xFF, 0xFF, 0xFF)),
CNameToCol("WhiteSmoke", CRGBA(0xF5, 0xF5, 0xF5)),
CNameToCol("Yellow", CRGBA(0xFF, 0xFF, 0x00)),
CNameToCol("YellowGreen", CRGBA(0x9A, 0xCD, 0x32))
};
// scan a color from a HTML form (#rrggbb format)
bool scanHTMLColor(const char *src, CRGBA &dest)
{
if (!src || *src == '\0') return false;
if (*src == '#')
{
++src;
if (strlen(src) == 3 || strlen(src) == 4)
{
bool hasAlpha = (strlen(src) == 4);
// check RGB for valid hex
if (isHexa(src[0]) && isHexa(src[1]) && isHexa(src[2]))
{
// check optional A for valid hex
if (hasAlpha && !isHexa(src[3])) return false;
dest.R = convertHexa(src[0]);
dest.G = convertHexa(src[1]);
dest.B = convertHexa(src[2]);
dest.R = dest.R << 4 | dest.R;
dest.G = dest.G << 4 | dest.G;
dest.B = dest.B << 4 | dest.B;
if (hasAlpha)
{
dest.A = convertHexa(src[3]);
dest.A = dest.A << 4 | dest.A;
}
else
dest.A = 255;
return true;
}
return false;
}
CRGBA result;
src = scanColorComponent(src, result.R); if (!src) return false;
src = scanColorComponent(src, result.G); if (!src) return false;
src = scanColorComponent(src, result.B); if (!src) return false;
src = scanColorComponent(src, result.A);
if (!src)
{
// Alpha is optional
result.A = 255;
}
dest = result;
return true;
}
// TODO: CSS Colors Level 4 support
// Whitespace syntax, aliases: rgb == rgba, hsl == hsla
// rgb(51 170 51 / 0.4) /* 40% opaque green */
// rgb(51 170 51 / 40%) /* 40% opaque green */
if (strnicmp(src, "rgb(", 4) == 0 || strnicmp(src, "rgba(", 5) == 0)
{
src += 4;
if (*src == '(') src++;
std::vector<std::string> parts;
NLMISC::splitString(src, ",", parts);
if (parts.size() >= 3)
{
CRGBA result;
sint tmpv;
float tmpf;
// R
if (getPercentage(tmpv, tmpf, parts[0].c_str())) tmpv = 255 * tmpf;
clamp(tmpv, 0, 255);
result.R = tmpv;
// G
if (getPercentage(tmpv, tmpf, parts[1].c_str())) tmpv = 255 * tmpf;
clamp(tmpv, 0, 255);
result.G = tmpv;
// B
if (getPercentage(tmpv, tmpf, parts[2].c_str())) tmpv = 255 * tmpf;
clamp(tmpv, 0, 255);
result.B = tmpv;
// A
if (parts.size() == 4)
{
if (!fromString(parts[3], tmpf)) return false;
if (parts[3].find_first_of("%") != std::string::npos)
tmpf /= 100;
tmpv = 255 * tmpf;
clamp(tmpv, 0, 255);
result.A = tmpv;
}
else
result.A = 255;
dest = result;
return true;
}
return false;
}
if (strnicmp(src, "hsl(", 4) == 0 || strnicmp(src, "hsla(", 5) == 0)
{
src += 4;
if (*src == '(') src++;
std::vector<std::string> parts;
NLMISC::splitString(src, ",", parts);
if (parts.size() >= 3)
{
sint tmpv;
float h, s, l;
// hue
if (!fromString(parts[0], tmpv)) return false;
tmpv = ((tmpv % 360) + 360) % 360;
h = (float) tmpv / 360.0f;
// saturation
if (!getPercentage(tmpv, s, parts[1].c_str())) return false;
clamp(s, 0.0f, 1.0f);
// lightness
if (!getPercentage(tmpv, l, parts[2].c_str())) return false;
clamp(l, 0.0f, 1.0f);
CRGBA result;
hslToRgb(h, s, l, result);
// A
if (parts.size() == 4)
{
float tmpf;
if (!fromString(parts[3], tmpf)) return false;
if (parts[3].find_first_of("%") != std::string::npos)
tmpf /= 100;
clamp(tmpf, 0.0f, 1.0f);
result.A = 255 * tmpf;
}
dest = result;
return true;
}
return false;
}
{
// slow but should suffice for now
for(uint k = 0; k < sizeofarray(htmlColorNameToRGBA); ++k)
{
if (nlstricmp(src, htmlColorNameToRGBA[k].Name) == 0)
{
dest = htmlColorNameToRGBA[k].Color;
return true;
}
}
return false;
}
}
// ***************************************************************************
CRGBA getColor (const char *color)
@ -381,6 +657,11 @@ namespace NLGUI
return dst;
}
std::string getRGBAString(const CRGBA &color)
{
return toString("rgba(%d, %d, %d, %.1f)", color.R, color.G, color.B, color.A / 255.f);
}
// update HTTPCookies list
static void receiveCookie(const char *nsformat, const std::string &domain, bool trusted)
{
@ -501,58 +782,6 @@ namespace NLGUI
}
}
void initLibWWW()
{
static bool initialized = false;
if (!initialized)
{
// Change the HTML DTD
SGML_dtd *HTML_DTD = HTML_dtd ();
HTML_DTD->tags[HTML_HTML].attributes = html_attr;
HTML_DTD->tags[HTML_HTML].number_of_attributes = sizeof(html_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TABLE].attributes = table_attr;
HTML_DTD->tags[HTML_TABLE].number_of_attributes = sizeof(table_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TR].attributes = tr_attr;
HTML_DTD->tags[HTML_TR].number_of_attributes = sizeof(tr_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TD].attributes = td_attr;
HTML_DTD->tags[HTML_TD].number_of_attributes = sizeof(td_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TH].attributes = td_attr;
HTML_DTD->tags[HTML_TH].number_of_attributes = sizeof(td_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_IMG].attributes = img_attr;
HTML_DTD->tags[HTML_IMG].number_of_attributes = sizeof(img_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_INPUT].attributes = input_attr;
HTML_DTD->tags[HTML_INPUT].number_of_attributes = sizeof(input_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TEXTAREA].attributes = textarea_attr;
HTML_DTD->tags[HTML_TEXTAREA].number_of_attributes = sizeof(textarea_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_P].attributes = p_attr;
HTML_DTD->tags[HTML_P].number_of_attributes = sizeof(p_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_A].attributes = a_attr;
HTML_DTD->tags[HTML_A].number_of_attributes = sizeof(a_attr) / sizeof(HTAttr) - 1;
//HTML_DTD->tags[HTML_I].attributes = a_attr;
HTML_DTD->tags[HTML_I].number_of_attributes = 0;
HTML_DTD->tags[HTML_DIV].attributes = div_attr;
HTML_DTD->tags[HTML_DIV].number_of_attributes = sizeof(div_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_SPAN].attributes = span_attr;
HTML_DTD->tags[HTML_SPAN].number_of_attributes = sizeof(span_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_H1].attributes = h1_attr;
HTML_DTD->tags[HTML_H1].number_of_attributes = sizeof(h1_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_H2].attributes = h2_attr;
HTML_DTD->tags[HTML_H2].number_of_attributes = sizeof(h2_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_H3].attributes = h3_attr;
HTML_DTD->tags[HTML_H3].number_of_attributes = sizeof(h3_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_H4].attributes = h4_attr;
HTML_DTD->tags[HTML_H4].number_of_attributes = sizeof(h4_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_H5].attributes = h5_attr;
HTML_DTD->tags[HTML_H5].number_of_attributes = sizeof(h5_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_H6].attributes = h6_attr;
HTML_DTD->tags[HTML_H6].number_of_attributes = sizeof(h6_attr) / sizeof(HTAttr) - 1;
// Initialized
initialized = true;
}
}
// ***************************************************************************
}

View file

@ -1,802 +0,0 @@
/**
libwww Copyright Notice
[This notice should be placed within redistributed or derivative software
code when appropriate. This particular formulation of W3C's notice for
inclusion in libwww code became active on August 14 1998.]
LIBWWW COPYRIGHT NOTICE
libwww: W3C's implementation of HTTP can be found at:
http://www.w3.org/Library/
Copyright ¨ 1995-2002 World Wide Web Consortium,
(Massachusetts Institute of Technology, Institut
National de Recherche en Informatique et en
Automatique, Keio University). All Rights Reserved.
This program is distributed under the W3C's
Intellectual Property License. This program is
distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See W3C License
http://www.w3.org/Consortium/Legal/ for more details.
Copyright ¨ 1995 CERN. "This product includes computer
software created and made available by CERN. This
acknowledgment shall be mentioned in full in any
product which includes the CERN computer software
included herein or parts thereof."
****************************************************************************/
#include "stdpch.h"
#include "nel/gui/libwww_types.h"
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLGUI
{
/*
** ATTRIBUTE DEFINITION MACROS (see HTMLPDTD.h)
*/
/*
* redefine the macros, so that the "stringized" attribute name
* is generated
*/
#undef HTML_ATTR
#define HTML_ATTR(t,a) { (char *) #a }
#undef HTML_ATTRIBUTES
#define HTML_ATTRIBUTES(t) { 0 }
/*
** ATTRIBUTE LISTS
*/
static HTAttr no_attr[1] = {
{ 0 }
};
static HTAttr body_attr[HTML_BODY_ATTRIBUTES+1] = { /* to catch images */
HTML_ATTR(BODY,ALINK),
HTML_ATTR(BODY,BACKGROUND),
HTML_ATTR(BODY,BGCOLOR),
HTML_ATTR(BODY,CLASS),
HTML_ATTR(BODY,DIR),
HTML_ATTR(BODY,ID),
HTML_ATTR(BODY,LANG),
HTML_ATTR(BODY,LINK),
HTML_ATTR(BODY,STYLE),
HTML_ATTR(BODY,TEXT),
HTML_ATTR(BODY,TITLE),
HTML_ATTR(BODY,VLINK),
HTML_ATTRIBUTES(BODY)
};
static HTAttr frame_attr[HTML_FRAME_ATTRIBUTES+1] = { /* frame attributes */
HTML_ATTR(FRAME,CLASS),
HTML_ATTR(FRAME,FRAMEBORDER),
HTML_ATTR(FRAME,ID),
HTML_ATTR(FRAME,NAME),
HTML_ATTR(FRAME,MARGINHEIGHT),
HTML_ATTR(FRAME,MARGINWIDTH),
HTML_ATTR(FRAME,NORESIZE),
HTML_ATTR(FRAME,LONGDESC),
HTML_ATTR(FRAME,SCROLLING),
HTML_ATTR(FRAME,SRC),
HTML_ATTR(FRAME,STYLE),
HTML_ATTR(FRAME,TARGET),
HTML_ATTR(FRAME,TITLE),
HTML_ATTRIBUTES(FRAME)
};
static HTAttr frameset_attr[HTML_FRAMESET_ATTRIBUTES+1] = { /* frameset attributes */
HTML_ATTR(FRAMESET,CLASS),
HTML_ATTR(FRAMESET,COLS),
HTML_ATTR(FRAMESET,ID),
HTML_ATTR(FRAMESET,ROWS),
HTML_ATTR(FRAMESET,STYLE),
HTML_ATTR(FRAMESET,TITLE),
HTML_ATTRIBUTES(FRAMESET)
};
static HTAttr a_attr[HTML_A_ATTRIBUTES+1] = { /* Anchor attributes */
HTML_ATTR(A,ACCESSKEY),
HTML_ATTR(A,CHARSET),
HTML_ATTR(A,CLASS),
HTML_ATTR(A,COORDS),
HTML_ATTR(A,DIR),
HTML_ATTR(A,HREF),
HTML_ATTR(A,HREFLANG),
HTML_ATTR(A,ID),
HTML_ATTR(A,NAME),
HTML_ATTR(A,REL),
HTML_ATTR(A,REV),
HTML_ATTR(A,SHAPE),
HTML_ATTR(A,STYLE),
HTML_ATTR(A,TABINDEX),
HTML_ATTR(A,TARGET),
HTML_ATTR(A,TYPE),
HTML_ATTR(A,TITLE),
HTML_ATTRIBUTES(A)
};
static HTAttr applet_attr[HTML_APPLET_ATTRIBUTES+1] = {
HTML_ATTR(APPLET,ALIGN),
HTML_ATTR(APPLET,ALT),
HTML_ATTR(APPLET,ARCHIVE),
HTML_ATTR(APPLET,CLASS),
HTML_ATTR(APPLET,CODE),
HTML_ATTR(APPLET,CODEBASE),
HTML_ATTR(APPLET,HEIGHT),
HTML_ATTR(APPLET,HSPACE),
HTML_ATTR(APPLET,ID),
HTML_ATTR(APPLET,NAME),
HTML_ATTR(APPLET,OBJECT),
HTML_ATTR(APPLET,STYLE),
HTML_ATTR(APPLET,TITLE),
HTML_ATTR(APPLET,VSPACE),
HTML_ATTR(APPLET,WIDTH),
HTML_ATTRIBUTES(APPLET)
};
static HTAttr area_attr[HTML_AREA_ATTRIBUTES+1] = { /* Area attributes */
HTML_ATTR(AREA,ACCESSKEY),
HTML_ATTR(AREA,ALT),
HTML_ATTR(AREA,CLASS),
HTML_ATTR(AREA,COORDS),
HTML_ATTR(AREA,DIR),
HTML_ATTR(AREA,HREF),
HTML_ATTR(AREA,ID),
HTML_ATTR(AREA,NAME),
HTML_ATTR(AREA,NOHREF),
HTML_ATTR(AREA,LANG),
HTML_ATTR(AREA,SHAPE),
HTML_ATTR(AREA,STYLE),
HTML_ATTR(AREA,TABINDEX),
HTML_ATTR(AREA,TARGET),
HTML_ATTR(AREA,TITLE),
HTML_ATTRIBUTES(AREA)
};
static HTAttr base_attr[HTML_BASE_ATTRIBUTES+1] = { /* BASE attributes */
HTML_ATTR(BASE,HREF),
HTML_ATTR(BASE,TARGET),
HTML_ATTRIBUTES(BASE)
};
static HTAttr bdo_attr[HTML_BDO_ATTRIBUTES+1] = {
HTML_ATTR(BDO,CLASS),
HTML_ATTR(BDO,DIR),
HTML_ATTR(BDO,ID),
HTML_ATTR(BDO,LANG),
HTML_ATTR(BDO,STYLE),
HTML_ATTR(BDO,TITLE),
HTML_ATTRIBUTES(BDO)
};
static HTAttr bq_attr[HTML_BQ_ATTRIBUTES+1] = {
HTML_ATTR(BQ,CITE),
HTML_ATTR(BQ,CLASS),
HTML_ATTR(BQ,DIR),
HTML_ATTR(BQ,ID),
HTML_ATTR(BQ,LANG),
HTML_ATTR(BQ,STYLE),
HTML_ATTR(BQ,TITLE),
HTML_ATTRIBUTES(BQ)
};
static HTAttr br_attr[HTML_BR_ATTRIBUTES+1] = {
HTML_ATTR(BR,CLASS),
HTML_ATTR(BR,CLEAR),
HTML_ATTR(BR,ID),
HTML_ATTR(BR,STYLE),
HTML_ATTR(BR,TITLE),
HTML_ATTRIBUTES(BR)
};
static HTAttr button_attr[HTML_BUTTON_ATTRIBUTES+1] = {
HTML_ATTR(BUTTON,ACCESSKEY),
HTML_ATTR(BUTTON,CLASS),
HTML_ATTR(BUTTON,DIR),
HTML_ATTR(BUTTON,DISABLED),
HTML_ATTR(BUTTON,ID),
HTML_ATTR(BUTTON,LANG),
HTML_ATTR(BUTTON,NAME),
HTML_ATTR(BUTTON,STYLE),
HTML_ATTR(BUTTON,TABINDEX),
HTML_ATTR(BUTTON,TITLE),
HTML_ATTR(BUTTON,TYPE),
HTML_ATTR(BUTTON,VALUE),
HTML_ATTRIBUTES(BUTTON),
};
static HTAttr col_attr[HTML_COL_ATTRIBUTES+1] = {
HTML_ATTR(COL,CLASS),
HTML_ATTR(COL,DIR),
HTML_ATTR(COL,ID),
HTML_ATTR(COL,LANG),
HTML_ATTR(COL,SPAN),
HTML_ATTR(COL,STYLE),
HTML_ATTR(COL,TITLE),
HTML_ATTR(COL,WIDTH),
HTML_ATTRIBUTES(COL)
};
static HTAttr changes_attr[HTML_CHANGES_ATTRIBUTES+1] = {
HTML_ATTR(CHANGES,CITE),
HTML_ATTR(CHANGES,CLASS),
HTML_ATTR(CHANGES,DATETIME),
HTML_ATTR(CHANGES,DIR),
HTML_ATTR(CHANGES,ID),
HTML_ATTR(CHANGES,LANG),
HTML_ATTR(CHANGES,STYLE),
HTML_ATTR(CHANGES,TITLE),
HTML_ATTRIBUTES(CHANGES)
};
static HTAttr font_attr[HTML_FONT_ATTRIBUTES+1] = {
HTML_ATTR(FONT,CLASS),
HTML_ATTR(FONT,COLOR),
HTML_ATTR(FONT,DIR),
HTML_ATTR(FONT,FACE),
HTML_ATTR(FONT,ID),
HTML_ATTR(FONT,LANG),
HTML_ATTR(FONT,SIZE),
HTML_ATTR(FONT,STYLE),
HTML_ATTR(FONT,TITLE),
HTML_ATTRIBUTES(FONT)
};
static HTAttr form_attr[HTML_FORM_ATTRIBUTES+1] = {
HTML_ATTR(FORM,ACCEPT),
{ (char *) "ACCEPT-CHARSET" }, /* HTML_ATTR(FORM,ACCEPT_CHARSET) */
HTML_ATTR(FORM,ACTION),
HTML_ATTR(FORM,CLASS),
HTML_ATTR(FORM,DIR),
HTML_ATTR(FORM,ENCTYPE),
HTML_ATTR(FORM,ID),
HTML_ATTR(FORM,LANG),
HTML_ATTR(FORM,METHOD),
HTML_ATTR(FORM,STYLE),
HTML_ATTR(FORM,TARGET),
HTML_ATTR(FORM,TITLE),
HTML_ATTRIBUTES(FORM)
};
static HTAttr gen_attr[HTML_GEN_ATTRIBUTES+1] = { /* General, for many things */
HTML_ATTR(GEN,CLASS),
HTML_ATTR(GEN,DIR),
HTML_ATTR(GEN,ID),
HTML_ATTR(GEN,LANG),
HTML_ATTR(GEN,STYLE),
HTML_ATTR(GEN,TITLE),
HTML_ATTRIBUTES(GEN)
};
static HTAttr block_attr[HTML_BLOCK_ATTRIBUTES+1] = { /* DIV, SPAN, H1-H6 */
HTML_ATTR(BLOCK,ALIGN),
HTML_ATTR(BLOCK,CLASS),
HTML_ATTR(BLOCK,DIR),
HTML_ATTR(BLOCK,ID),
HTML_ATTR(BLOCK,LANG),
HTML_ATTR(BLOCK,STYLE),
HTML_ATTR(BLOCK,TITLE),
HTML_ATTRIBUTES(BLOCK)
};
static HTAttr head_attr[HTML_HEAD_ATTRIBUTES+1] = {
HTML_ATTR(HEAD,DIR),
HTML_ATTR(HEAD,LANG),
HTML_ATTR(HEAD,PROFILE),
HTML_ATTRIBUTES(HEAD)
};
static HTAttr hr_attr[HTML_HR_ATTRIBUTES+1] = {
HTML_ATTR(HR,ALIGN),
HTML_ATTR(HR,CLASS),
HTML_ATTR(HR,DIR),
HTML_ATTR(HR,ID),
HTML_ATTR(HR,LANG),
HTML_ATTR(HR,NOSHADE),
HTML_ATTR(HR,SIZE),
HTML_ATTR(HR,STYLE),
HTML_ATTR(HR,TITLE),
HTML_ATTR(HR,WIDTH),
HTML_ATTRIBUTES(HR)
};
static HTAttr html_attr[HTML_HTML_ATTRIBUTES+1] = {
HTML_ATTR(HTML,DIR),
HTML_ATTR(HTML,LANG),
HTML_ATTR(HTML,VERSION),
HTML_ATTRIBUTES(HTML)
};
static HTAttr iframe_attr[HTML_IFRAME_ATTRIBUTES+1] = {
HTML_ATTR(IFRAME,ALIGN),
HTML_ATTR(IFRAME,CLASS),
HTML_ATTR(IFRAME,FRAMEBORDER),
HTML_ATTR(IFRAME,HEIGHT),
HTML_ATTR(IFRAME,ID),
HTML_ATTR(IFRAME,LONGDESC),
HTML_ATTR(IFRAME,MARGINHEIGHT),
HTML_ATTR(IFRAME,MARGINWIDTH),
HTML_ATTR(IFRAME,NAME),
HTML_ATTR(IFRAME,SCROLLING),
HTML_ATTR(IFRAME,SRC),
HTML_ATTR(IFRAME,STYLE),
HTML_ATTR(IFRAME,TARGET),
HTML_ATTR(IFRAME,TITLE),
HTML_ATTR(IFRAME,WIDTH),
HTML_ATTRIBUTES(IFRAME)
};
static HTAttr img_attr[HTML_IMG_ATTRIBUTES+1] = { /* IMG attributes */
HTML_ATTR(IMG,ALIGN),
HTML_ATTR(IMG,ALT),
HTML_ATTR(IMG,BORDER),
HTML_ATTR(IMG,CLASS),
HTML_ATTR(IMG,DIR),
HTML_ATTR(IMG,HEIGHT),
HTML_ATTR(IMG,HSPACE),
HTML_ATTR(IMG,ID),
HTML_ATTR(IMG,ISMAP),
HTML_ATTR(IMG,LANG),
HTML_ATTR(IMG,LONGDESC),
HTML_ATTR(IMG,SRC),
HTML_ATTR(IMG,STYLE),
HTML_ATTR(IMG,TITLE),
HTML_ATTR(IMG,USEMAP),
HTML_ATTR(IMG,VSPACE),
HTML_ATTR(IMG,WIDTH),
HTML_ATTRIBUTES(IMG)
};
static HTAttr input_attr[HTML_INPUT_ATTRIBUTES+1] = {
HTML_ATTR(INPUT,ACCEPT),
HTML_ATTR(INPUT,ACCESSKEY),
HTML_ATTR(INPUT,ALIGN),
HTML_ATTR(INPUT,ALT),
HTML_ATTR(INPUT,CHECKED),
HTML_ATTR(INPUT,CLASS),
HTML_ATTR(INPUT,DIR),
HTML_ATTR(INPUT,DISABLED),
HTML_ATTR(INPUT,ID),
HTML_ATTR(INPUT,LANG),
HTML_ATTR(INPUT,MAXLENGTH),
HTML_ATTR(INPUT,NAME),
HTML_ATTR(INPUT,READONLY),
HTML_ATTR(INPUT,SIZE),
HTML_ATTR(INPUT,SRC),
HTML_ATTR(INPUT,STYLE),
HTML_ATTR(INPUT,TABINDEX),
HTML_ATTR(INPUT,TITLE),
HTML_ATTR(INPUT,TYPE),
HTML_ATTR(INPUT,USEMAP),
HTML_ATTR(INPUT,VALUE),
HTML_ATTRIBUTES(INPUT)
};
static HTAttr isindex_attr[HTML_ISINDEX_ATTRIBUTES+1] = {
HTML_ATTR(ISINDEX,CLASS),
HTML_ATTR(ISINDEX,DIR),
HTML_ATTR(ISINDEX,ID),
HTML_ATTR(ISINDEX,LANG),
HTML_ATTR(ISINDEX,PROMPT),
HTML_ATTR(ISINDEX,STYLE),
HTML_ATTR(ISINDEX,TITLE),
HTML_ATTRIBUTES(ISINDEX)
};
static HTAttr label_attr[HTML_LABEL_ATTRIBUTES+1] = {
HTML_ATTR(LABEL,ACCESSKEY),
HTML_ATTR(LABEL,CLASS),
HTML_ATTR(LABEL,DIR),
HTML_ATTR(LABEL,FOR),
HTML_ATTR(LABEL,ID),
HTML_ATTR(LABEL,LANG),
HTML_ATTR(LABEL,STYLE),
HTML_ATTR(LABEL,TITLE),
HTML_ATTRIBUTES(LABEL)
};
static HTAttr legend_attr[HTML_LEGEND_ATTRIBUTES+1] = {
HTML_ATTR(LEGEND,ACCESSKEY),
HTML_ATTR(LEGEND,ALIGN),
HTML_ATTR(LEGEND,CLASS),
HTML_ATTR(LEGEND,DIR),
HTML_ATTR(LEGEND,ID),
HTML_ATTR(LEGEND,LANG),
HTML_ATTR(LEGEND,STYLE),
HTML_ATTR(LEGEND,TITLE),
HTML_ATTRIBUTES(LEGEND)
};
static HTAttr li_attr[HTML_LI_ATTRIBUTES+1] = {
HTML_ATTR(LI,CLASS),
HTML_ATTR(LI,COMPACT),
HTML_ATTR(LI,DIR),
HTML_ATTR(LI,ID),
HTML_ATTR(LI,LANG),
HTML_ATTR(LI,STYLE),
HTML_ATTR(LI,TITLE),
HTML_ATTR(LI,TYPE),
HTML_ATTR(LI,VALUE),
HTML_ATTRIBUTES(LI)
};
static HTAttr link_attr[HTML_LINK_ATTRIBUTES+1] = { /* link attributes */
HTML_ATTR(LINK,CHARSET),
HTML_ATTR(LINK,CLASS),
HTML_ATTR(LINK,DIR),
HTML_ATTR(LINK,HREF),
HTML_ATTR(LINK,HREFLANG),
HTML_ATTR(LINK,ID),
HTML_ATTR(LINK,LANG),
HTML_ATTR(LINK,MEDIA),
HTML_ATTR(LINK,REL),
HTML_ATTR(LINK,REV),
HTML_ATTR(LINK,STYLE),
HTML_ATTR(LINK,TARGET),
HTML_ATTR(LINK,TITLE),
HTML_ATTR(LINK,TYPE),
HTML_ATTRIBUTES(LINK)
};
static HTAttr map_attr[HTML_MAP_ATTRIBUTES+1] = {
HTML_ATTR(MAP,CLASS),
HTML_ATTR(MAP,DIR),
HTML_ATTR(MAP,ID),
HTML_ATTR(MAP,LANG),
HTML_ATTR(MAP,NAME),
HTML_ATTR(MAP,STYLE),
HTML_ATTR(MAP,TITLE),
HTML_ATTRIBUTES(MAP)
};
static HTAttr meta_attr[HTML_META_ATTRIBUTES+1] = {
HTML_ATTR(META,CONTENT),
HTML_ATTR(META,DIR),
{ (char *)"HTTP-EQUIV" }, /* HTML_ATTR(META,HTTP_EQUIV) */
HTML_ATTR(META,LANG),
HTML_ATTR(META,NAME),
HTML_ATTR(META,SCHEME),
HTML_ATTRIBUTES(META)
};
static HTAttr nextid_attr[HTML_NEXTID_ATTRIBUTES+1] = {
{ (char *)"N" },
{ 0 } /* Terminate list */
};
static HTAttr object_attr[HTML_OBJECT_ATTRIBUTES+1] = { /* object attributes */
HTML_ATTR(OBJECT,ALIGN),
HTML_ATTR(OBJECT,ARCHIVE),
HTML_ATTR(OBJECT,BORDER),
HTML_ATTR(OBJECT,CLASS),
HTML_ATTR(OBJECT,CLASSID),
HTML_ATTR(OBJECT,CODEBASE),
HTML_ATTR(OBJECT,CODETYPE),
HTML_ATTR(OBJECT,DATA),
HTML_ATTR(OBJECT,DECLARE),
HTML_ATTR(OBJECT,DIR),
HTML_ATTR(OBJECT,HEIGHT),
HTML_ATTR(OBJECT,HSPACE),
HTML_ATTR(OBJECT,ID),
HTML_ATTR(OBJECT,LANG),
HTML_ATTR(OBJECT,NAME),
HTML_ATTR(OBJECT,STANDBY),
HTML_ATTR(OBJECT,STYLE),
HTML_ATTR(OBJECT,TABINDEX),
HTML_ATTR(OBJECT,TITLE),
HTML_ATTR(OBJECT,TYPE),
HTML_ATTR(OBJECT,USEMAP),
HTML_ATTR(OBJECT,VSPACE),
HTML_ATTR(OBJECT,WIDTH),
HTML_ATTRIBUTES(OBJECT)
};
static HTAttr ol_attr[HTML_OL_ATTRIBUTES+1] = {
HTML_ATTR(OL,CLASS),
HTML_ATTR(OL,COMPACT),
HTML_ATTR(OL,DIR),
HTML_ATTR(OL,ID),
HTML_ATTR(OL,LANG),
HTML_ATTR(OL,START),
HTML_ATTR(OL,STYLE),
HTML_ATTR(OL,TITLE),
HTML_ATTR(OL,TYPE),
HTML_ATTRIBUTES(OL)
};
static HTAttr optgroup_attr[HTML_OPTGROUP_ATTRIBUTES+1] = {
HTML_ATTR(OPTGROUP,CLASS),
HTML_ATTR(OPTGROUP,DISABLED),
HTML_ATTR(OPTGROUP,DIR),
HTML_ATTR(OPTGROUP,ID),
HTML_ATTR(OPTGROUP,LABEL),
HTML_ATTR(OPTGROUP,LANG),
HTML_ATTR(OPTGROUP,STYLE),
HTML_ATTR(OPTGROUP,TITLE),
HTML_ATTRIBUTES(OPTGROUP)
};
static HTAttr option_attr[HTML_OPTION_ATTRIBUTES+1] = {
HTML_ATTR(OPTION,CLASS),
HTML_ATTR(OPTION,DISABLED),
HTML_ATTR(OPTION,DIR),
HTML_ATTR(OPTION,ID),
HTML_ATTR(OPTION,LABEL),
HTML_ATTR(OPTION,LANG),
HTML_ATTR(OPTION,SELECTED),
HTML_ATTR(OPTION,STYLE),
HTML_ATTR(OPTION,TITLE),
HTML_ATTR(OPTION,VALUE),
HTML_ATTRIBUTES(OPTION)
};
static HTAttr param_attr[HTML_PARAM_ATTRIBUTES+1] = {
HTML_ATTR(PARAM,ID),
HTML_ATTR(PARAM,NAME),
HTML_ATTR(PARAM,TYPE),
HTML_ATTR(PARAM,VALUE),
HTML_ATTR(PARAM,VALUETYPE),
HTML_ATTRIBUTES(PARAM)
};
static HTAttr pre_attr[HTML_PRE_ATTRIBUTES+1] = {
HTML_ATTR(PRE,CLASS),
HTML_ATTR(PRE,DIR),
HTML_ATTR(PRE,ID),
HTML_ATTR(PRE,LANG),
HTML_ATTR(PRE,STYLE),
HTML_ATTR(PRE,TITLE),
HTML_ATTR(PRE,WIDTH),
HTML_ATTRIBUTES(PRE)
};
static HTAttr script_attr[HTML_SCRIPT_ATTRIBUTES+1] = {
HTML_ATTR(SCRIPT,CHARSET),
HTML_ATTR(SCRIPT,DEFER),
HTML_ATTR(SCRIPT,LANGUAGE),
HTML_ATTR(SCRIPT,SRC),
HTML_ATTR(SCRIPT,TYPE),
HTML_ATTRIBUTES(SCRIPT)
};
static HTAttr select_attr[HTML_SELECT_ATTRIBUTES+1] = {
HTML_ATTR(SELECT,CLASS),
HTML_ATTR(SELECT,DIR),
HTML_ATTR(SELECT,DISABLED),
HTML_ATTR(SELECT,ID),
HTML_ATTR(SELECT,LANG),
HTML_ATTR(SELECT,MULTIPLE),
HTML_ATTR(SELECT,NAME),
HTML_ATTR(SELECT,SIZE),
HTML_ATTR(SELECT,STYLE),
HTML_ATTR(SELECT,TABINDEX),
HTML_ATTR(SELECT,TITLE),
HTML_ATTRIBUTES(SELECT)
};
static HTAttr style_attr[HTML_STYLE_ATTRIBUTES+1] = {
HTML_ATTR(STYLE,DIR),
HTML_ATTR(STYLE,LANG),
HTML_ATTR(STYLE,MEDIA),
HTML_ATTR(STYLE,TITLE),
HTML_ATTR(STYLE,TYPE),
HTML_ATTRIBUTES(STYLE)
};
static HTAttr table_attr[HTML_TABLE_ATTRIBUTES+1] = {
HTML_ATTR(TABLE,ALIGN),
HTML_ATTR(TABLE,BGCOLOR),
HTML_ATTR(TABLE,BORDER),
HTML_ATTR(TABLE,CELLPADDING),
HTML_ATTR(TABLE,CELLSPACING),
HTML_ATTR(TABLE,CLASS),
HTML_ATTR(TABLE,DIR),
HTML_ATTR(TABLE,FRAME),
HTML_ATTR(TABLE,ID),
HTML_ATTR(TABLE,LANG),
HTML_ATTR(TABLE,RULES),
HTML_ATTR(TABLE,SUMMARY),
HTML_ATTR(TABLE,STYLE),
HTML_ATTR(TABLE,TITLE),
HTML_ATTR(TABLE,WIDTH),
HTML_ATTRIBUTES(TABLE)
};
static HTAttr tele_attr[HTML_TELE_ATTRIBUTES+1] = {
HTML_ATTR(TELE,ALIGN),
HTML_ATTR(TELE,CHAR),
HTML_ATTR(TELE,CHAROFF),
HTML_ATTR(TELE,CLASS),
HTML_ATTR(TELE,DIR),
HTML_ATTR(TELE,ID),
HTML_ATTR(TELE,LANG),
HTML_ATTR(TELE,STYLE),
HTML_ATTR(TELE,TITLE),
HTML_ATTR(TELE,VALIGN),
HTML_ATTRIBUTES(TELE)
};
static HTAttr td_attr[HTML_TD_ATTRIBUTES+1] = {
HTML_ATTR(TD,ABBR),
HTML_ATTR(TD,ALIGN),
HTML_ATTR(TD,AXIS),
HTML_ATTR(TD,BGCOLOR),
HTML_ATTR(TD,CHAR),
HTML_ATTR(TD,CHAROFF),
HTML_ATTR(TD,CLASS),
HTML_ATTR(TD,COLSPAN),
HTML_ATTR(TD,DIR),
HTML_ATTR(TD,ID),
HTML_ATTR(TD,HEADERS),
HTML_ATTR(TD,HEIGHT),
HTML_ATTR(TD,LANG),
HTML_ATTR(TD,NOWRAP),
HTML_ATTR(TD,ROWSPAN),
HTML_ATTR(TD,SCOPE),
HTML_ATTR(TD,STYLE),
HTML_ATTR(TD,TITLE),
HTML_ATTR(TD,VALIGN),
HTML_ATTR(TD,WIDTH),
HTML_ATTRIBUTES(TD)
};
static HTAttr textarea_attr[HTML_TEXTAREA_ATTRIBUTES+1] = {
HTML_ATTR(TEXTAREA,CLASS),
HTML_ATTR(TEXTAREA,COLS),
HTML_ATTR(TEXTAREA,DIR),
HTML_ATTR(TEXTAREA,DISABLED),
HTML_ATTR(TEXTAREA,ID),
HTML_ATTR(TEXTAREA,LANG),
HTML_ATTR(TEXTAREA,NAME),
HTML_ATTR(TEXTAREA,READONLY),
HTML_ATTR(TEXTAREA,ROWS),
HTML_ATTR(TEXTAREA,STYLE),
HTML_ATTR(TEXTAREA,TABINDEX),
HTML_ATTR(TEXTAREA,TITLE),
HTML_ATTRIBUTES(TEXTAREA)
};
static HTAttr title_attr[HTML_TITLE_ATTRIBUTES+1] = {
HTML_ATTR(TITLE,DIR),
HTML_ATTR(TITLE,LANG),
HTML_ATTRIBUTES(TITLE)
};
static HTAttr ul_attr[HTML_UL_ATTRIBUTES+1] = {
HTML_ATTR(UL,CLASS),
HTML_ATTR(UL,COMPACT),
HTML_ATTR(UL,DIR),
HTML_ATTR(UL,ID),
HTML_ATTR(UL,LANG),
HTML_ATTR(UL,STYLE),
HTML_ATTR(UL,TITLE),
HTML_ATTR(UL,TYPE),
HTML_ATTRIBUTES(UL)
};
/*
** ELEMENTS
** Must match definitions in HTMLPDTD.html!
** Must be in alphabetical order.
**
** Name, Attributes, content
*/
static HTTag tags[HTML_ELEMENTS] = {
{ "A" , a_attr, HTML_A_ATTRIBUTES },
{ "ABBR" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "ACRONYM" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "ADDRESS" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "APPLET" , applet_attr, HTML_APPLET_ATTRIBUTES },
{ "AREA" , area_attr, HTML_AREA_ATTRIBUTES },
{ "B" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "BASE" , base_attr, HTML_BASE_ATTRIBUTES },
{ "BASEFONT", font_attr, HTML_FONT_ATTRIBUTES },
{ "BDO" , bdo_attr, HTML_BDO_ATTRIBUTES },
{ "BIG" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "BLOCKQUOTE", bq_attr, HTML_BQ_ATTRIBUTES },
{ "BODY" , body_attr, HTML_BODY_ATTRIBUTES },
{ "BR" , br_attr, HTML_BR_ATTRIBUTES },
{ "BUTTON" , button_attr, HTML_BUTTON_ATTRIBUTES },
{ "CAPTION" , block_attr, HTML_BLOCK_ATTRIBUTES },
{ "CENTER" , no_attr, 0 },
{ "CITE" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "CODE" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "COL" , col_attr, HTML_COL_ATTRIBUTES },
{ "COLGROUP", col_attr, HTML_COL_ATTRIBUTES },
{ "DD" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "DEL" , changes_attr, HTML_CHANGES_ATTRIBUTES },
{ "DFN" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "DIR" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "DIV" , block_attr, HTML_BLOCK_ATTRIBUTES },
{ "DL" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "DT" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "EM" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "FIELDSET", gen_attr, HTML_GEN_ATTRIBUTES },
{ "FONT" , font_attr, HTML_FONT_ATTRIBUTES },
{ "FORM" , form_attr, HTML_FORM_ATTRIBUTES },
{ "FRAME" , frame_attr, HTML_FRAME_ATTRIBUTES },
{ "FRAMESET", frameset_attr,HTML_FRAMESET_ATTRIBUTES },
{ "H1" , block_attr, HTML_BLOCK_ATTRIBUTES },
{ "H2" , block_attr, HTML_BLOCK_ATTRIBUTES },
{ "H3" , block_attr, HTML_BLOCK_ATTRIBUTES },
{ "H4" , block_attr, HTML_BLOCK_ATTRIBUTES },
{ "H5" , block_attr, HTML_BLOCK_ATTRIBUTES },
{ "H6" , block_attr, HTML_BLOCK_ATTRIBUTES },
{ "HEAD" , head_attr, HTML_HEAD_ATTRIBUTES },
{ "HR" , hr_attr, HTML_HR_ATTRIBUTES },
{ "HTML" , html_attr, HTML_HTML_ATTRIBUTES },
{ "I" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "IFRAME" , iframe_attr, HTML_IFRAME_ATTRIBUTES },
{ "IMG" , img_attr, HTML_IMG_ATTRIBUTES },
{ "INPUT" , input_attr, HTML_INPUT_ATTRIBUTES },
{ "INS" , changes_attr, HTML_CHANGES_ATTRIBUTES },
{ "ISINDEX" , isindex_attr, HTML_ISINDEX_ATTRIBUTES },
{ "KBD" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "LABEL" , label_attr, HTML_LABEL_ATTRIBUTES },
{ "LEGEND" , legend_attr, HTML_LEGEND_ATTRIBUTES },
{ "LI" , li_attr, HTML_LI_ATTRIBUTES },
{ "LINK" , link_attr, HTML_LINK_ATTRIBUTES },
{ "MAP" , map_attr, HTML_MAP_ATTRIBUTES },
{ "MENU" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "META" , meta_attr, HTML_META_ATTRIBUTES },
{ "NEXTID" , nextid_attr, 1 },
{ "NOFRAMES", gen_attr, HTML_GEN_ATTRIBUTES },
{ "NOSCRIPT", gen_attr, HTML_GEN_ATTRIBUTES },
{ "OBJECT" , object_attr, HTML_OBJECT_ATTRIBUTES },
{ "OL" , ol_attr, HTML_OL_ATTRIBUTES },
{ "OPTGROUP", optgroup_attr,HTML_OPTGROUP_ATTRIBUTES },
{ "OPTION" , option_attr, HTML_OPTION_ATTRIBUTES },
{ "P" , block_attr, HTML_BLOCK_ATTRIBUTES },
{ "PARAM" , param_attr, HTML_PARAM_ATTRIBUTES },
{ "PRE" , pre_attr, HTML_PRE_ATTRIBUTES },
{ "Q" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "S" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "SAMP" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "SCRIPT" , script_attr, HTML_SCRIPT_ATTRIBUTES },
{ "SELECT" , select_attr, HTML_SELECT_ATTRIBUTES },
{ "SMALL" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "SPAN" , block_attr, HTML_BLOCK_ATTRIBUTES },
{ "STRIKE" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "STRONG" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "STYLE" , style_attr, HTML_STYLE_ATTRIBUTES },
{ "SUB" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "SUP" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "TABLE" , table_attr, HTML_TABLE_ATTRIBUTES },
{ "TBODY" , tele_attr, HTML_TELE_ATTRIBUTES },
{ "TD" , td_attr, HTML_TD_ATTRIBUTES },
{ "TEXTAREA", textarea_attr,HTML_TEXTAREA_ATTRIBUTES },
{ "TFOOT" , tele_attr, HTML_TELE_ATTRIBUTES },
{ "TH" , td_attr, HTML_TD_ATTRIBUTES },
{ "THEAD" , tele_attr, HTML_TELE_ATTRIBUTES },
{ "TITLE" , title_attr, HTML_TITLE_ATTRIBUTES },
{ "TR" , tele_attr, HTML_TELE_ATTRIBUTES },
{ "TT" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "U" , gen_attr, HTML_GEN_ATTRIBUTES },
{ "UL" , ul_attr, HTML_UL_ATTRIBUTES },
{ "VAR" , gen_attr, HTML_GEN_ATTRIBUTES },
};
static SGML_dtd HTMLP_dtd = {
tags,
HTML_ELEMENTS
};
static SGML_dtd * DTD = &HTMLP_dtd;
SGML_dtd * HTML_dtd (void)
{
return DTD;
}
}// namespace

View file

@ -115,7 +115,7 @@ namespace NLGUI
{
#if !FINAL_VERSION
#ifdef NL_OS_WINDOWS
ShellExecuteW(NULL, utf8ToWide(operation), utf8ToWide(fileName), utf8ToWide(parameters), NULL, SW_SHOWDEFAULT);
ShellExecuteW(NULL, nlUtf8ToWide(operation), nlUtf8ToWide(fileName), nlUtf8ToWide(parameters), NULL, SW_SHOWDEFAULT);
#endif
#endif
}

View file

@ -911,7 +911,7 @@ static bool createProcess(const std::string &programName, const std::string &arg
}
// or 0 for a window
BOOL res = CreateProcessW(sProgramName, utf8ToWide(args), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL /* current dir */, &si, &pi);
BOOL res = CreateProcessW(sProgramName, (LPWSTR)nlUtf8ToWide(args), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL /* current dir */, &si, &pi);
if (sProgramName)
{
@ -1453,7 +1453,7 @@ void displayDwordBits( uint32 b, uint nbits, sint beginpos, bool displayBegin, N
FILE* nlfopen(const std::string &filename, const std::string &mode)
{
#ifdef NL_OS_WINDOWS
return _wfopen(utf8ToWide(filename), utf8ToWide(mode));
return _wfopen(nlUtf8ToWide(filename), nlUtf8ToWide(mode));
#else
return fopen(filename.c_str(), mode.c_str());
#endif
@ -1632,7 +1632,7 @@ static bool openDocWithExtension (const std::string &document, const std::string
{
#ifdef NL_OS_WINDOWS
// First try ShellExecute()
HINSTANCE result = ShellExecuteW(NULL, L"open", utf8ToWide(document), NULL, NULL, SW_SHOWDEFAULT);
HINSTANCE result = ShellExecuteW(NULL, L"open", nlUtf8ToWide(document), NULL, NULL, SW_SHOWDEFAULT);
// If it failed, get the .htm regkey and lookup the program
if ((uintptr_t)result <= HINSTANCE_ERROR)
@ -1640,7 +1640,7 @@ static bool openDocWithExtension (const std::string &document, const std::string
wchar_t key[MAX_PATH + MAX_PATH];
// get the type of the extension
if (GetRegKey(HKEY_CLASSES_ROOT, utf8ToWide("." + ext), key) == ERROR_SUCCESS)
if (GetRegKey(HKEY_CLASSES_ROOT, nlUtf8ToWide("." + ext), key) == ERROR_SUCCESS)
{
lstrcatW(key, L"\\shell\\open\\command");

View file

@ -1431,7 +1431,7 @@ int getLastError()
std::string formatErrorMessage(int errorCode)
{
#ifdef NL_OS_WINDOWS
LPVOID lpMsgBuf = NULL;
LPWSTR lpMsgBuf = NULL;
DWORD len = FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
@ -1439,7 +1439,7 @@ std::string formatErrorMessage(int errorCode)
NULL,
errorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPWSTR) &lpMsgBuf,
(LPWSTR)(&lpMsgBuf),
0,
NULL
);

View file

@ -286,14 +286,14 @@ void CStdDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mess
// WARNING: READ THIS !!!!!!!!!!!!!!!! ///////////////////////////
// If at the release time, it freezes here, it's a microsoft bug:
// http://support.microsoft.com/support/kb/articles/q173/2/60.asp
OutputDebugStringW(utf8ToWide(str2));
OutputDebugStringW(nlUtf8ToWide(str2));
}
else
{
sint count = 0;
uint n = (uint)strlen(message);
std::string s(&str2.c_str()[0], (str2.size() - n));
OutputDebugStringW(utf8ToWide(s));
OutputDebugStringW(nlUtf8ToWide(s));
for(;;)
{
@ -301,14 +301,14 @@ void CStdDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mess
if((n - count) < maxOutString )
{
s = std::string(&message[count], (n - count));
OutputDebugStringW(utf8ToWide(s));
OutputDebugStringW(nlUtf8ToWide(s));
OutputDebugStringW(L"\n");
break;
}
else
{
s = std::string(&message[count] , count + maxOutString);
OutputDebugStringW(utf8ToWide(s));
OutputDebugStringW(nlUtf8ToWide(s));
OutputDebugStringW(L"\n\t\t\t");
count += maxOutString;
}
@ -323,13 +323,13 @@ void CStdDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mess
if (pos+1000 < args.CallstackAndLog.size ())
{
splited = args.CallstackAndLog.substr (pos, 1000);
OutputDebugStringW(utf8ToWide(splited));
OutputDebugStringW(nlUtf8ToWide(splited));
pos += 1000;
}
else
{
splited = args.CallstackAndLog.substr (pos);
OutputDebugStringW(utf8ToWide(splited));
OutputDebugStringW(nlUtf8ToWide(splited));
break;
}
}

View file

@ -32,7 +32,7 @@ NL_LIB_HANDLE nlLoadLibrary(const std::string &libName)
{
NL_LIB_HANDLE res = 0;
#ifdef NL_OS_WINDOWS
res = LoadLibraryW(utf8ToWide(libName));
res = LoadLibraryW(nlUtf8ToWide(libName));
#elif defined(NL_OS_UNIX)
res = dlopen(libName.c_str(), RTLD_NOW);
#else

View file

@ -157,6 +157,14 @@ bool CIFile::open(const std::string &path, bool text)
close();
if ((_IsInBigFile || _IsInXMLPackFile) && path.find('@') == string::npos)
{
// CIFile can be reused to load file from bnp and from regular files.
// Last open happened to be inside bnp and close() may not set _F to NULL.
// Opening regular file will fail as _F points to bnp file.
_F = NULL;
}
// can't open empty filename
if(path.empty ())
return false;
@ -185,7 +193,7 @@ bool CIFile::open(const std::string &path, bool text)
// Bigfile or xml pack access requested ?
string::size_type pos;
if (!CFile::fileExists(path) && (pos = path.find('@')) != string::npos)
if ((pos = path.find('@')) != string::npos)
{
// check for a double @ to identify XML pack file
if (pos+1 < path.size() && path[pos+1] == '@')
@ -237,7 +245,9 @@ bool CIFile::open(const std::string &path, bool text)
}
}
}
else
// not in bnp, but may have '@' in the name
if (_F == NULL)
{
_IsInBigFile = false;
_IsInXMLPackFile = false;

View file

@ -700,7 +700,7 @@ bool CFileContainer::setCurrentPath (const std::string &path)
int res;
//nldebug("Change current path to '%s' (current path is '%s')", path.c_str(), getCurrentPath().c_str());
#ifdef NL_OS_WINDOWS
res = _wchdir(utf8ToWide(path));
res = _wchdir(nlUtf8ToWide(path));
#else
res = chdir(path.c_str());
#endif
@ -792,7 +792,7 @@ dirent *readdir (DIR *dir)
// first visit in this directory : FindFirstFile()
if (hFind == NULL)
{
hFind = FindFirstFileW (utf8ToWide(CPath::standardizePath(sDir) + "*"), &findData);
hFind = FindFirstFileW(nlUtf8ToWide(CPath::standardizePath(sDir) + "*"), &findData);
}
// directory already visited : FindNextFile()
else
@ -1914,7 +1914,7 @@ string CFile::getPath (const string &filename)
bool CFile::isDirectory (const string &filename)
{
#ifdef NL_OS_WINDOWS
DWORD res = GetFileAttributesW(utf8ToWide(filename));
DWORD res = GetFileAttributesW(nlUtf8ToWide(filename));
if (res == INVALID_FILE_ATTRIBUTES)
{
// nlwarning ("PATH: '%s' is not a valid file or directory name", filename.c_str ());
@ -1937,7 +1937,7 @@ bool CFile::isDirectory (const string &filename)
bool CFile::isExists (const string &filename)
{
#ifdef NL_OS_WINDOWS
return GetFileAttributesW(utf8ToWide(filename)) != INVALID_FILE_ATTRIBUTES;
return GetFileAttributesW(nlUtf8ToWide(filename)) != INVALID_FILE_ATTRIBUTES;
#else // NL_OS_WINDOWS
struct stat buf;
return stat (filename.c_str (), &buf) == 0;
@ -2017,7 +2017,7 @@ uint32 CFile::getFileSize (const std::string &filename)
{
#if defined (NL_OS_WINDOWS)
struct _stat buf;
int result = _wstat (utf8ToWide(filename), &buf);
int result = _wstat(nlUtf8ToWide(filename), &buf);
#elif defined (NL_OS_UNIX)
struct stat buf;
int result = stat (filename.c_str (), &buf);
@ -2068,7 +2068,7 @@ uint32 CFile::getFileModificationDate(const std::string &filename)
// Use the WIN32 API to read the file times in UTC
// create a file handle (this does not open the file)
HANDLE h = CreateFileW(utf8ToWide(fn), 0, 0, NULL, OPEN_EXISTING, 0, 0);
HANDLE h = CreateFileW(nlUtf8ToWide(fn), 0, 0, NULL, OPEN_EXISTING, 0, 0);
if (h == INVALID_HANDLE_VALUE)
{
nlwarning("Can't get modification date on file '%s' : %s", fn.c_str(), NLMISC::formatErrorMessage(NLMISC::getLastError()).c_str());
@ -2138,7 +2138,7 @@ bool CFile::setFileModificationDate(const std::string &filename, uint32 modTime)
// Use the WIN32 API to set the file times in UTC
// create a file handle (this does not open the file)
HANDLE h = CreateFileW(utf8ToWide(fn), GENERIC_WRITE|GENERIC_READ, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
HANDLE h = CreateFileW(nlUtf8ToWide(fn), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
if (h == INVALID_HANDLE_VALUE)
{
nlwarning("Can't set modification date on file '%s' (error accessing file) : %s", fn.c_str(), NLMISC::formatErrorMessage(NLMISC::getLastError()).c_str());
@ -2223,7 +2223,7 @@ uint32 CFile::getFileCreationDate(const std::string &filename)
#if defined (NL_OS_WINDOWS)
struct _stat buf;
int result = _wstat(utf8ToWide(fn), &buf);
int result = _wstat(nlUtf8ToWide(fn), &buf);
#elif defined (NL_OS_UNIX)
struct stat buf;
int result = stat(fn.c_str (), &buf);
@ -2357,7 +2357,7 @@ static bool CopyMoveFile(const std::string &dest, const std::string &src, bool c
else
{
#ifdef NL_OS_WINDOWS
if (MoveFileW(utf8ToWide(ssrc), utf8ToWide(sdest)) == 0)
if (MoveFileW(nlUtf8ToWide(ssrc), nlUtf8ToWide(sdest)) == 0)
{
sint lastError = NLMISC::getLastError();
nlwarning ("PATH: CopyMoveFile error: can't link/move '%s' into '%s', error %u (%s)",
@ -2482,7 +2482,7 @@ bool CFile::moveFile(const std::string &dest, const std::string &src)
bool CFile::createDirectory(const std::string &filename)
{
#ifdef NL_OS_WINDOWS
return _wmkdir(utf8ToWide(filename))==0;
return _wmkdir(nlUtf8ToWide(filename)) == 0;
#else
// Set full permissions....
return mkdir(filename.c_str(), 0xFFFF)==0;
@ -2751,7 +2751,7 @@ bool CFile::deleteFile(const std::string &filename)
{
setRWAccess(filename);
#ifdef NL_OS_WINDOWS
sint res = _wunlink(utf8ToWide(filename));
sint res = _wunlink(nlUtf8ToWide(filename));
#else
sint res = unlink(filename.c_str());
#endif
@ -2770,7 +2770,7 @@ bool CFile::deleteDirectory(const std::string &filename)
{
setRWAccess(filename);
#ifdef NL_OS_WINDOWS
sint res = _wrmdir(utf8ToWide(filename));
sint res = _wrmdir(nlUtf8ToWide(filename));
#else
sint res = rmdir(filename.c_str());
#endif

View file

@ -17,23 +17,24 @@
#include "stdmisc.h"
#include "nel/misc/string_common.h"
#include "nel/misc/sstring.h"
using namespace std;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLMISC
{
string addSlashR (const string &str)
string addSlashR(const string &str)
{
string formatedStr;
// replace \n with \r\n
for (uint i = 0; i < str.size(); i++)
{
if (str[i] == '\n' && i > 0 && str[i-1] != '\r')
if (str[i] == '\n' && i > 0 && str[i - 1] != '\r')
{
formatedStr += '\r';
}
@ -42,7 +43,7 @@ string addSlashR (const string &str)
return formatedStr;
}
string removeSlashR (const string &str)
string removeSlashR(const string &str)
{
string formatedStr;
// remove \r
@ -54,4 +55,267 @@ string removeSlashR (const string &str)
return formatedStr;
}
bool fromString(const std::string &str, bool &val)
{
if (str.length() == 1)
{
const char c = str[0];
switch (c)
{
case '1':
case 't':
case 'T':
case 'y':
case 'Y':
val = true;
break;
case '0':
case 'f':
case 'F':
case 'n':
case 'N':
val = false;
break;
default:
val = false;
return false;
}
}
else
{
std::string strl = toLower(str);
if (strl == "true" || strl == "yes")
{
val = true;
}
else if (strl == "false" || strl == "no")
{
val = false;
}
else
{
val = false;
return false;
}
}
return true;
}
#if defined(NL_OS_WINDOWS)
std::string winWideToCp(const wchar_t *str, size_t len, UINT cp)
{
if (!len)
len = wcslen(str);
if (!len)
return std::string();
// Convert from wide to codepage
char *tmp = (char *)_malloca((len + 1) * 4);
if (!tmp)
return std::string();
int tmpLen = WideCharToMultiByte(cp, 0,
str, (int)(len + 1),
tmp, (int)((len + 1) * 4),
NULL, NULL);
if (tmpLen <= 1)
{
_freea(tmp);
return std::string();
}
std::string res = tmp;
_freea(tmp);
return res;
}
std::string winCpToCp(const char *str, size_t len, UINT srcCp, UINT dstCp)
{
if (!len)
len = strlen(str);
if (!len)
return std::string();
// First convert from codepage to wide
wchar_t *tmp = (wchar_t *)_malloca((len + 1) * 4);
if (!tmp)
return std::string();
int tmpLen = MultiByteToWideChar(srcCp, MB_PRECOMPOSED,
str, (int)(len + 1), /* include null-termination */
tmp, (int)((len + 1) * 4));
if (tmpLen <= 1)
{
_freea(tmp);
return std::string();
}
// Then convert from wide to codepage
std::string res = winWideToCp(tmp, (size_t)tmpLen - 1, dstCp); /* tmpLen includes null-term */
_freea(tmp);
return res;
}
std::wstring winCpToWide(const char *str, size_t len, UINT cp)
{
if (!len)
len = strlen(str);
if (!len)
return std::wstring();
// Convert from codepage to wide
wchar_t *tmp = (wchar_t *)_malloca((len + 1) * 4);
if (!tmp)
return std::wstring();
int tmpLen = MultiByteToWideChar(cp, MB_PRECOMPOSED,
str, (int)(len + 1), /* include null-termination */
tmp, (int)((len + 1) * 4));
if (tmpLen <= 1)
{
_freea(tmp);
return std::wstring();
}
std::wstring res = tmp;
_freea(tmp);
return res;
}
#endif
// Convert local codepage to UTF-8
// On Windows, the local codepage is undetermined
// On Linux, the local codepage is always UTF-8 (no-op)
std::string mbcsToUtf8(const char *str, size_t len)
{
#if defined(NL_OS_WINDOWS)
UINT codePage = GetACP();
// Windows 10 allows setting the local codepage to UTF-8
if (codePage == CP_UTF8) /* 65001 */
return str;
return winCpToCp(str, len, CP_ACP, CP_UTF8);
#else
return str; /* no-op */
#endif
}
std::string mbcsToUtf8(const std::string &str)
{
#if defined(NL_OS_WINDOWS)
if (str.empty())
return str;
UINT codePage = GetACP();
// Windows 10 allows setting the local codepage to UTF-8
if (codePage == CP_UTF8) /* 65001 */
return str;
return winCpToCp(str.c_str(), str.size(), CP_ACP, CP_UTF8);
#else
return str; /* no-op */
#endif
}
// Convert wide codepage to UTF-8
// On Windows, the wide codepage is UTF-16
// On Linux, the wide codepage is UTF-32
std::string wideToUtf8(const wchar_t *str, size_t len)
{
#if defined(NL_OS_WINDOWS)
return winWideToCp(str, len, CP_UTF8);
#else
// TODO: UTF-32 to UTF-8
nlassert(false);
#endif
}
std::string wideToUtf8(const std::wstring &str)
{
return wideToUtf8(str.c_str(), str.size());
}
// Convert UTF-8 to wide character set
std::wstring utf8ToWide(const char *str, size_t len)
{
#if defined(NL_OS_WINDOWS)
return winCpToWide(str, len, CP_UTF8);
#else
// TODO: UTF-32 to UTF-8
nlassert(false);
#endif
}
std::wstring utf8ToWide(const std::string &str)
{
return utf8ToWide(str.c_str(), str.size());
}
// Convert UTF-8 to local multibyte character set
std::string utf8ToMbcs(const char *str, size_t len)
{
#if defined(NL_OS_WINDOWS)
UINT codePage = GetACP();
// Windows 10 allows setting the local codepage to UTF-8
if (codePage == CP_UTF8) /* 65001 */
return str;
return winCpToCp(str, len, CP_UTF8, CP_ACP);
#else
return str; /* no-op */
#endif
}
std::string utf8ToMbcs(const std::string &str)
{
#if defined(NL_OS_WINDOWS)
if (str.empty())
return str;
UINT codePage = GetACP();
// Windows 10 allows setting the local codepage to UTF-8
if (codePage == CP_UTF8) /* 65001 */
return str;
return winCpToCp(str.c_str(), str.size(), CP_UTF8, CP_ACP);
#else
return str; /* no-op */
#endif
}
// Convert wide to local multibyte character set
std::string wideToMbcs(const wchar_t *str, size_t len)
{
#if defined(NL_OS_WINDOWS)
return winWideToCp(str, len, CP_ACP);
#else
return wideToUtf8(str, len);
#endif
}
std::string wideToMbcs(const std::wstring &str)
{
#if defined(NL_OS_WINDOWS)
return winWideToCp(str.c_str(), str.size(), CP_ACP);
#else
return wideToUtf8(str);
#endif
}
// Convert local multibyte to wide character set
std::wstring mbcsToWide(const char *str, size_t len)
{
#if defined(NL_OS_WINDOWS)
return winCpToWide(str, len, CP_ACP);
#else
return utf8ToWide(str, len);
#endif
}
std::wstring mbcsToWide(const std::string &str)
{
#if defined(NL_OS_WINDOWS)
return winCpToWide(str.c_str(), str.size(), CP_ACP);
#else
return utf8ToWide(str);
#endif
}
}

View file

@ -1460,7 +1460,7 @@ uint64 CSystemInfo::availableHDSpace (const string &filename)
return (uint64)stfs.f_bavail * (uint64)stfs.f_bsize;
#else
ULARGE_INTEGER freeSpace = {0};
BOOL bRes = ::GetDiskFreeSpaceExW(utf8ToWide(path), &freeSpace, NULL, NULL);
BOOL bRes = ::GetDiskFreeSpaceExW(nlUtf8ToWide(path), &freeSpace, NULL, NULL);
if (!bRes) return 0;
return (uint64)freeSpace.QuadPart;

View file

@ -323,58 +323,55 @@ void CSystemUtils::setRootKey(const std::string &root)
RootKey = root;
}
string CSystemUtils::getRegKey(const string &Entry)
string CSystemUtils::getRegKey(const string &entry)
{
string ret;
#ifdef NL_OS_WINDOWS
HKEY hkey;
if (RegOpenKeyExW(HKEY_CURRENT_USER, utf8ToWide(RootKey), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
if (RegOpenKeyExW(HKEY_CURRENT_USER, nlUtf8ToWide(RootKey), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
{
DWORD dwType = 0L;
DWORD dwSize = KeyMaxLength;
wchar_t Buffer[KeyMaxLength];
wchar_t buffer[KeyMaxLength];
if (RegQueryValueExW(hkey, utf8ToWide(Entry), NULL, &dwType, (LPBYTE)Buffer, &dwSize) != ERROR_SUCCESS)
if (RegQueryValueExW(hkey, nlUtf8ToWide(entry), NULL, &dwType, (LPBYTE)buffer, &dwSize) != ERROR_SUCCESS)
{
nlwarning("Can't get the reg key '%s'", Entry.c_str());
nlwarning("Can't get the reg key '%s'", entry.c_str());
}
else
{
ret = wideToUtf8(Buffer);
ret = wideToUtf8(buffer);
}
RegCloseKey(hkey);
}
else
{
nlwarning("Can't get the reg key '%s'", Entry.c_str());
nlwarning("Can't get the reg key '%s'", entry.c_str());
}
#endif
return ret;
}
bool CSystemUtils::setRegKey(const string &ValueName, const string &Value)
bool CSystemUtils::setRegKey(const string &valueName, const string &value)
{
bool res = false;
#ifdef NL_OS_WINDOWS
HKEY hkey;
DWORD dwDisp;
if (RegCreateKeyExW(HKEY_CURRENT_USER, utf8ToWide(RootKey), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisp) == ERROR_SUCCESS)
if (RegCreateKeyExW(HKEY_CURRENT_USER, nlUtf8ToWide(RootKey), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisp) == ERROR_SUCCESS)
{
ucstring utf16Value = ucstring::makeFromUtf8(Value);
// we must use the real Unicode string size in bytes
DWORD size = (utf16Value.length() + 1) * 2;
if (RegSetValueExW(hkey, utf8ToWide(ValueName), 0L, REG_SZ, (const BYTE *)utf16Value.c_str(), size) == ERROR_SUCCESS)
std::wstring wvalue = nlUtf8ToWide(value);
if (RegSetValueExW(hkey, nlUtf8ToWide(valueName), 0, REG_SZ, (const BYTE *)wvalue.c_str(), (wvalue.size() + 1) * sizeof(WCHAR)) == ERROR_SUCCESS)
res = true;
RegCloseKey(hkey);
}
else
{
nlwarning("Can't set the reg key '%s' '%s'", ValueName.c_str(), Value.c_str());
nlwarning("Can't set the reg key '%s' '%s'", valueName.c_str(), value.c_str());
}
#endif

View file

@ -298,7 +298,7 @@ void CWinDisplayer::updateLabels ()
}
}
SendMessageW ((HWND)access.value()[i].Hwnd, WM_SETTEXT, 0, (LPARAM) utf8ToWide(n));
SendMessageW((HWND)access.value()[i].Hwnd, WM_SETTEXT, 0, (LPARAM)nlUtf8ToWide(n));
access.value()[i].NeedUpdate = false;
}
}

View file

@ -492,6 +492,13 @@ void IService::setArgs (int argc, const char **argv)
}
}
void IService::setArgs(int argc, const wchar_t **argv)
{
for (sint i = 0; i < argc; i++)
{
_Args.push_back(nlWideToUtf8(argv[i]));
}
}
void cbLogFilter (CConfigFile::CVar &var)
{

View file

@ -103,10 +103,12 @@ IAudioDecoder *IAudioDecoder::createAudioDecoder(const std::string &type, NLMISC
{
return new CAudioDecoderVorbis(stream, loop);
}
#if (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */
else if (type_lower == "mp3")
{
return new CAudioDecoderMP3(stream, loop);
}
#endif
else
{
nlwarning("Music file type unknown: '%s'", type_lower.c_str());
@ -144,6 +146,7 @@ bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, st
nlwarning("Unable to open: '%s'", filepath.c_str());
}
#if (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */
else if (type_lower == "mp3")
{
CIFile ifile;
@ -154,6 +157,7 @@ bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, st
nlwarning("Unable to open: '%s'", filepath.c_str());
}
#endif
else
{
nlwarning("Music file type unknown: '%s'", type_lower.c_str());

View file

@ -17,6 +17,8 @@
#include "stdsound.h"
#if (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */
#include <nel/sound/audio_decoder_mp3.h>
#define DR_MP3_IMPLEMENTATION
@ -221,4 +223,6 @@ void CAudioDecoderMP3::setLooping(bool loop)
} /* namespace NLSOUND */
#endif /* (NL_COMP_VC_VERSION > 90) */
/* end of file */

View file

@ -36,8 +36,11 @@ NL_ADD_LIB_SUFFIX(${NLDRV_AL_LIB})
IF(WIN32)
# Find and include EFX-Util on Windows.
FIND_PACKAGE(EFXUtil)
INCLUDE_DIRECTORIES(${EFXUTIL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(${NLDRV_AL_LIB} ${EFXUTIL_LIBRARY})
IF(EFXUTIL_FOUND)
INCLUDE_DIRECTORIES(${EFXUTIL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(${NLDRV_AL_LIB} ${EFXUTIL_LIBRARY})
ADD_DEFINITIONS(-DEFX_CREATIVE_AVAILABLE=1)
ENDIF()
ENDIF()
IF(WITH_PCH)

View file

@ -17,12 +17,12 @@
#ifndef NL_EXT_AL_H
#define NL_EXT_AL_H
#ifdef NL_OS_WINDOWS
# define EFX_CREATIVE_AVAILABLE 1
# define EAX_AVAILABLE 0
#else
# define EFX_CREATIVE_AVAILABLE 0
# define EAX_AVAILABLE 0
#ifndef EFX_CREATIVE_AVAILABLE
#define EFX_CREATIVE_AVAILABLE 0
#endif
#ifndef EAX_AVAILABLE
#define EAX_AVAILABLE 0
#endif
#if EAX_AVAILABLE

View file

@ -226,7 +226,7 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD
*/
#ifdef NL_OS_WINDOWS
wchar_t buffer[1024], *ptr;
uint len = SearchPathW (NULL, utf8ToWide(dllName), NULL, 1023, buffer, &ptr);
uint len = SearchPathW (NULL, nlUtf8ToWide(dllName), NULL, 1023, buffer, &ptr);
if( len )
nlinfo ("Using the library '%s' that is in the directory: '%s'", dllName.c_str(), wideToUtf8(buffer).c_str());
#endif

View file

@ -201,9 +201,9 @@ void LoadSceneScript (const char *ScriptName, CScene* pScene, vector<SDispCS> &D
// Main
// ---------------------------------------------------------------------------
#ifdef NL_OS_WINDOWS
int CALLBACK WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
int APIENTRY nltWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
#else // NL_OS_WINDOWS
int main(int argc, char **argv)
int nltmain(int argc, NLMISC::tchar **argv)
#endif // NL_OS_WINDOWS
{
double rGlobalTime = 0;

View file

@ -38,6 +38,8 @@
#include "nel/ligo/ligo_error.h"
#include "nel/misc/path.h"
#include "../../plugin_max/nel_3dsmax_shared/string_common.h"
using namespace std;
using namespace NLMISC;
extern HINSTANCE hInstance;
@ -126,13 +128,13 @@ bool CMaxToLigo::loadLigoConfigFile (CLigoConfig& config, Interface& it, bool di
{
// Get the path
TCHAR sModulePath[256];
int res=GetModuleFileName(hModule, sModulePath, 256);
int res = GetModuleFileName(hModule, sModulePath, 256);
// Success ?
if (res)
{
// Path
std::string path = NLMISC::CFile::getPath(tStrToUtf8(sModulePath) + "ligoscape.cfg");
std::string path = NLMISC::CFile::getPath(MCharStrToUtf8(sModulePath) + "ligoscape.cfg");
try
{
@ -164,16 +166,19 @@ void CMaxToLigo::errorMessage(const std::string &msg, const std::string &title,
if (dialog)
{
// Dialog message
MessageBox (it.GetMAXHWnd(), utf8ToTStr(msg), utf8ToTStr(title), MB_OK|MB_ICONEXCLAMATION);
ucstring ucmsg, uctitle;
ucmsg.fromUtf8(msg);
uctitle.fromUtf8(title);
MessageBoxW(it.GetMAXHWnd(), (LPCWSTR)ucmsg.c_str(), (LPCWSTR)uctitle.c_str(), MB_OK | MB_ICONEXCLAMATION);
}
else
{
// Text message
mprintf (utf8ToTStr(msg + "\n"));
mprintf(_M("%s\n"), MaxTStrFromUtf8(msg).data());
}
// Output in log
nlwarning ("LIGO ERROR : %s", msg.c_str());
nlwarning("LIGO ERROR : %s", msg.c_str());
}
// ***************************************************************************

View file

@ -155,7 +155,7 @@ Value* export_material_cf (Value** arg_list, int count)
nlassert (node);
// The second arg
const std::string fileName = tStrToUtf8(arg_list[1]->to_string());
const std::string fileName = MCharStrToUtf8(arg_list[1]->to_string());
// The third arg
bool checkOnly = (arg_list[2]->to_bool() != FALSE);
@ -321,12 +321,12 @@ Value* export_transition_cf (Value** arg_list, int count)
nlassert (is_array(nodes));
// The second arg
std::string fileName = tStrToUtf8(arg_list[1]->to_string());
std::string fileName = MCharStrToUtf8(arg_list[1]->to_string());
// The second arg
string matFilename[2];
matFilename[0] = tStrToUtf8(arg_list[2]->to_string());
matFilename[1] = tStrToUtf8(arg_list[3]->to_string());
matFilename[0] = MCharStrToUtf8(arg_list[2]->to_string());
matFilename[1] = MCharStrToUtf8(arg_list[3]->to_string());
// The third arg
bool checkOnly = (arg_list[4]->to_bool() != FALSE);
@ -696,7 +696,7 @@ Value* check_zone_with_material_cf (Value** arg_list, int count)
nlassert (node);
// The second arg
string fileName = tStrToUtf8(arg_list[1]->to_string());
string fileName = MCharStrToUtf8(arg_list[1]->to_string());
// The fourth arg
bool errorInDialog = (arg_list[2]->to_bool() != FALSE);
@ -830,7 +830,7 @@ Value* check_zone_with_transition_cf (Value** arg_list, int count)
nlassert (node);
// The second arg
string fileName = tStrToUtf8(arg_list[1]->to_string());
string fileName = MCharStrToUtf8(arg_list[1]->to_string());
// The second arg
int transitionNumber = arg_list[2]->to_int();
@ -998,7 +998,7 @@ Value* export_zone_cf (Value** arg_list, int count)
nlassert (node);
// The second arg
string fileName = tStrToUtf8(arg_list[1]->to_string());
string fileName = MCharStrToUtf8(arg_list[1]->to_string());
// The thrid arg
Array *array = (Array*)arg_list[2];
@ -1043,8 +1043,8 @@ Value* export_zone_cf (Value** arg_list, int count)
type_check (cell->get(2), String, message);
// Get the strings
categories[i].first = tStrToUtf8(cell->get(1)->to_string());
categories[i].second = tStrToUtf8(cell->get(2)->to_string());
categories[i].first = MCharStrToUtf8(cell->get(1)->to_string());
categories[i].second = MCharStrToUtf8(cell->get(2)->to_string());
}
// Get a Object pointer
@ -1352,7 +1352,7 @@ Value* get_error_string_cf (Value** arg_list, int count)
int errorCode = arg_list[0]->to_int()-1;
// Error code
return new String (utf8ToTStr(CLigoError::getStringError ((CLigoError::TError)errorCode)));
return new String(MaxTStrFromUtf8(CLigoError::getStringError ((CLigoError::TError)errorCode)));
}
// ***************************************************************************
@ -1367,7 +1367,7 @@ Value* set_directory_cf (Value** arg_list, int count)
type_check(arg_list[0], String, message);
// The first arg
const std::string dir = tStrToUtf8(arg_list[0]->to_string());
const std::string dir = MCharStrToUtf8(arg_list[0]->to_string());
// Set the directory
return (chdir (dir.c_str())==0)?&true_value:&false_value;
@ -1859,7 +1859,7 @@ Value* make_snapshot_cf (Value** arg_list, int count)
nlassert (node);
// The second arg
string fileName = tStrToUtf8(arg_list[1]->to_string());
string fileName = MCharStrToUtf8(arg_list[1]->to_string());
// The thrid arg
int xMin = arg_list[2]->to_int();

View file

@ -158,7 +158,7 @@ void CAnimationSetDlg::OnAddAnimation ()
}
catch (const Exception& e)
{
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
MessageBox (nlUtf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
}
}
}
@ -199,7 +199,7 @@ void CAnimationSetDlg::OnAddSkelWt()
}
catch (const Exception& e)
{
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
}
@ -234,7 +234,7 @@ void CAnimationSetDlg::refresh (BOOL update)
for (i=0; i<_ObjView->getNumInstance (); i++)
{
std::string name = NLMISC::CFile::getFilenameWithoutExtension(_ObjView->getInstance(i)->Saved.ShapeFilename);
EditedObject.InsertString (-1, utf8ToTStr(name));
EditedObject.InsertString(-1, nlUtf8ToTStr(name));
}
// Get edited object
@ -268,7 +268,7 @@ void CAnimationSetDlg::refresh (BOOL update)
CAnimation *anim = object->AnimationSet.getAnimation (object->AnimationSet.getAnimationIdByName (name));
// Insert an intem
HTREEITEM item=Tree.InsertItem(utf8ToTStr(name));
HTREEITEM item = Tree.InsertItem(nlUtf8ToTStr(name));
Tree.SetItemData (item, i);
nlassert (item!=NULL);
@ -279,7 +279,7 @@ void CAnimationSetDlg::refresh (BOOL update)
while (ite!=setString.end())
{
// Add this string
HTREEITEM newItem = Tree.InsertItem (utf8ToTStr(*ite), item);
HTREEITEM newItem = Tree.InsertItem(nlUtf8ToTStr(*ite), item);
Tree.SetItemData (newItem, 0xffffffff);
// Get the track
@ -303,7 +303,7 @@ void CAnimationSetDlg::refresh (BOOL update)
name = toString("%s (%f - %f)", typeid(*track).name(), track->getBeginTime(), track->getEndTime());
}
HTREEITEM keyItem = Tree.InsertItem(utf8ToTStr(name), newItem);
HTREEITEM keyItem = Tree.InsertItem(nlUtf8ToTStr(name), newItem);
Tree.SetItemData(keyItem, 0xffffffff);
ite++;
@ -320,7 +320,7 @@ void CAnimationSetDlg::refresh (BOOL update)
CSkeletonWeight *swt = object->AnimationSet.getSkeletonWeight(object->AnimationSet.getSkeletonWeightIdByName(name));
// Insert an intem
HTREEITEM item=SkelTree.InsertItem(utf8ToTStr(name));
HTREEITEM item = SkelTree.InsertItem(nlUtf8ToTStr(name));
nlassert (item!=NULL);
// Get number of node in this skeleton weight
@ -332,7 +332,7 @@ void CAnimationSetDlg::refresh (BOOL update)
std::string percent = toString("%s (%f%%)", swt->getNodeName(n).c_str(), swt->getNodeWeight(n)*100);
// Add this string
SkelTree.InsertItem (utf8ToTStr(percent), item);
SkelTree.InsertItem(nlUtf8ToTStr(percent), item);
}
}
@ -340,7 +340,7 @@ void CAnimationSetDlg::refresh (BOOL update)
for (i=0; i<object->Saved.PlayList.size(); i++)
{
// Insert an intem
int item=PlayList.InsertString (-1, utf8ToTStr(object->Saved.PlayList[i]));
int item = PlayList.InsertString(-1, nlUtf8ToTStr(object->Saved.PlayList[i]));
nlassert (item!=LB_ERR);
}
}

View file

@ -355,7 +355,7 @@ void CAttribDlg::init(HBITMAP bitmap, sint x, sint y, CWnd *pParent)
for (uint k = 0; k < getNumScheme(); ++k)
{
m_Scheme.InsertString(k, utf8ToTStr(getSchemeName(k)));
m_Scheme.InsertString(k, nlUtf8ToTStr(getSchemeName(k)));
}

View file

@ -33,7 +33,7 @@ CChooseName::CChooseName(const CString &initialName, CWnd* pParent /*=NULL*/)
std::string CChooseName::getName()
{
return tStrToUtf8(m_Name);
return NLMISC::tStrToUtf8(m_Name);
}
void CChooseName::DoDataExchange(CDataExchange* pDX)

View file

@ -53,10 +53,10 @@ void CChoosePoolID::OnOK()
CString val;
GetDlgItem(IDC_POOL_ID)->GetWindowText(val);
if (NLMISC::fromString(tStrToUtf8(val), PoolID))
if (NLMISC::fromString(NLMISC::tStrToUtf8(val), PoolID))
{
GetDlgItem(IDC_POOL_NAME)->GetWindowText(val);
Name = tStrToUtf8(val);
Name = NLMISC::tStrToUtf8(val);
CDialog::OnOK();
}
else
@ -71,8 +71,8 @@ BOOL CChoosePoolID::OnInitDialog()
std::string val = NLMISC::toString(PoolID);
GetDlgItem(IDC_POOL_ID)->SetWindowText(utf8ToTStr(val));
GetDlgItem(IDC_POOL_NAME)->SetWindowText(utf8ToTStr(Name));
GetDlgItem(IDC_POOL_ID)->SetWindowText(nlUtf8ToTStr(val));
GetDlgItem(IDC_POOL_NAME)->SetWindowText(nlUtf8ToTStr(Name));
if (_FreezeID)
{

View file

@ -72,7 +72,7 @@ BOOL CCreateFileDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowText((LPCTSTR) _Title);
GetDlgItem(IDC_LOCATION)->SetWindowText(utf8ToTStr(_DefaultBasePath));
GetDlgItem(IDC_LOCATION)->SetWindowText(nlUtf8ToTStr(_DefaultBasePath));
if (!_DefaultBasePath.empty())
{
GetDlgItem(IDC_FILENAME)->SetFocus();
@ -90,10 +90,10 @@ void CCreateFileDlg::OnOK()
{
CString filename;
GetDlgItem(IDC_FILENAME)->GetWindowText(filename);
_Filename = tStrToUtf8(filename);
_Filename = NLMISC::tStrToUtf8(filename);
CString location;
GetDlgItem(IDC_LOCATION)->GetWindowText(location);
_Path = tStrToUtf8(location);
_Path = NLMISC::tStrToUtf8(location);
if (_Path.empty())
{
localizedMessageBox(*this, IDS_EMPTY_PATH, IDS_ERROR, MB_ICONEXCLAMATION);

View file

@ -173,7 +173,7 @@ void CDirectionAttr::OnDestroy()
void CDirectionAttr::OnGlobalDirection()
{
nlassert(_DirectionWrapper);
CChooseName chooseName(utf8ToTStr(_DirectionWrapper->getGlobalVectorValueName()));
CChooseName chooseName(nlUtf8ToTStr(_DirectionWrapper->getGlobalVectorValueName()));
if (chooseName.DoModal() == IDOK)
{

View file

@ -76,7 +76,7 @@ std::string CEditEx::getString() const
{
TCHAR buf[128];
GetWindowText(buf, sizeof(buf));
return tStrToUtf8(buf);
return NLMISC::tStrToUtf8(buf);
}
void CEditEx::setSInt(sint value)

View file

@ -89,7 +89,7 @@ bool CEditMorphMeshDlg::getShapeNameFromDlg(std::string &name)
NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName()));
*/
name = tStrToUtf8(fd.GetPathName());
name = NLMISC::tStrToUtf8(fd.GetPathName());
return true;
}
@ -123,7 +123,7 @@ void CEditMorphMeshDlg::OnAdd()
_CM->setShapes(&shapeNames[0], (uint)shapeNames.size());
std::vector<sint> numVerts;
_CM->getShapeNumVerts(numVerts);
m_MeshList.AddString(utf8ToTStr(getShapeDescStr(index, numVerts[index])));
m_MeshList.AddString(nlUtf8ToTStr(getShapeDescStr(index, numVerts[index])));
GetDlgItem(IDC_REMOVE)->EnableWindow(TRUE);
}
touchPSState();
@ -253,7 +253,7 @@ void CEditMorphMeshDlg::updateMeshList()
m_MeshList.ResetContent();
for (uint k = 0; k < _CM->getNumShapes(); ++k)
{
m_MeshList.AddString(utf8ToTStr(getShapeDescStr(k, numVerts[k])));
m_MeshList.AddString(nlUtf8ToTStr(getShapeDescStr(k, numVerts[k])));
}
m_MeshList.SetCurSel(0);
updateValidFlag();
@ -310,12 +310,12 @@ std::string CEditMorphMeshDlg::getShapeDescStr(uint shapeIndex, sint numVerts) c
{
CString verts;
verts.LoadString(IDS_VERTICES);
std::string msg = _CM->getShape(shapeIndex) + " (" + NLMISC::toString(numVerts) + " " + tStrToUtf8(verts) + ")";
std::string msg = _CM->getShape(shapeIndex) + " (" + NLMISC::toString(numVerts) + " " + NLMISC::tStrToUtf8(verts) + ")";
return msg;
}
else
{
std::string result = _CM->getShape(shapeIndex) + " (" + tStrToUtf8(CMeshDlg::getShapeErrorString(numVerts)) + ")";
std::string result = _CM->getShape(shapeIndex) + " (" + NLMISC::tStrToUtf8(CMeshDlg::getShapeErrorString(numVerts)) + ")";
return result;
}
}

View file

@ -195,7 +195,7 @@ void CEditPSSound::OnChangeSoundName()
{
nlassert(_Sound);
UpdateData();
_Sound->setSoundName(NLMISC::CSheetId(tStrToUtf8(m_SoundName), "sound"));
_Sound->setSoundName(NLMISC::CSheetId(NLMISC::tStrToUtf8(m_SoundName), "sound"));
updateModifiedFlag();
}
@ -209,7 +209,7 @@ void CEditPSSound::OnSpawn()
// play the currently selected sound
void CEditPSSound::OnPlaySound()
{
CSoundSystem::play(tStrToUtf8(m_SoundName));
CSoundSystem::play(NLMISC::tStrToUtf8(m_SoundName));
}
void CEditPSSound::OnMute()

View file

@ -317,7 +317,7 @@ inline void CEditableRangeT<float>::value2CString(float value, CString &dest)
inline const TCHAR *CEditableRangeT<float>::string2value(const CString &value, float &result)
{
if (NLMISC::fromString(tStrToUtf8(value), result))
if (NLMISC::fromString(NLMISC::tStrToUtf8(value), result))
{
return NULL;
}
@ -344,7 +344,7 @@ inline void CEditableRangeT<uint32>::value2CString(uint32 value, CString &dest)
inline const TCHAR *CEditableRangeT<uint32>::string2value(const CString &value, uint32 &result)
{
sint32 tmp;
if (NLMISC::fromString(tStrToUtf8(value), tmp))
if (NLMISC::fromString(NLMISC::tStrToUtf8(value), tmp))
{
if (value.Find(_T("-")) > -1)
{
@ -380,7 +380,7 @@ inline void CEditableRangeT<sint32>::value2CString(sint32 value, CString &dest)
inline const TCHAR *CEditableRangeT<sint32>::string2value(const CString &value, sint32 &result)
{
sint32 tmp;
if (NLMISC::fromString(tStrToUtf8(value), tmp))
if (NLMISC::fromString(NLMISC::tStrToUtf8(value), tmp))
{
result = tmp;
return NULL;

View file

@ -85,7 +85,7 @@ void CEmitterDlg::initEmittedType()
NL3D::CPSLocated *loc = dynamic_cast<NL3D::CPSLocated *>(ps->getProcess(k));
if (loc) // is this a located
{
m_EmittedTypeCtrl.AddString(utf8ToTStr(loc->getName()));
m_EmittedTypeCtrl.AddString(nlUtf8ToTStr(loc->getName()));
_LocatedList.push_back(loc);
if (loc == _Emitter->getEmittedType())
{

View file

@ -119,7 +119,7 @@ void CLBExternIDDlg::OnChangeIdValue()
TCHAR buf[6];
::memset(buf, 0, 6);
GetDlgItem(IDC_ID_VALUE)->GetWindowText(buf, 6);
_ID = StringToID(tStrToUtf8(buf).c_str());
_ID = StringToID(NLMISC::tStrToUtf8(buf).c_str());
if (_ID)
{
GetDlgItem(IDOK)->EnableWindow(TRUE);

View file

@ -114,7 +114,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent)
// z-test
((CButton *) GetDlgItem(IDC_ZTEST))->SetCheck(material->isZTestEnabled() ? BST_CHECKED : BST_UNCHECKED);
// z-bias
GetDlgItem(IDC_ZBIAS)->SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", -material->getZBias())));
GetDlgItem(IDC_ZBIAS)->SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", -material->getZBias())));
}
else
{

View file

@ -322,7 +322,7 @@ void CLocatedProperties::goPostRender()
_MaxNbParticles->update();
}
// in all cases, show the current number of particles being used
GetDlgItem(IDC_CURR_NUM_PARTS)->SetWindowText(utf8ToTStr(NLMISC::toString(_Located->getSize())));
GetDlgItem(IDC_CURR_NUM_PARTS)->SetWindowText(nlUtf8ToTStr(NLMISC::toString(_Located->getSize())));
}
//****************************************************************************************************************

View file

@ -112,7 +112,7 @@ void CLocatedTargetDlg::OnAddTarget()
nlassert(loc);
_LBTarget->attachTarget(loc);
m_AvailableTargets.DeleteString(indexs[k] - k);
int l = m_Targets.AddString(utf8ToTStr(loc->getName()));
int l = m_Targets.AddString(nlUtf8ToTStr(loc->getName()));
m_Targets.SetItemData(l, (DWORD_PTR) loc);
}
UpdateData(FALSE);
@ -135,7 +135,7 @@ void CLocatedTargetDlg::OnRemoveTarget()
nlassert(loc);
_LBTarget->detachTarget(loc);
m_Targets.DeleteString(indexs[k] - k);
int l = m_AvailableTargets.AddString(utf8ToTStr(loc->getName()));
int l = m_AvailableTargets.AddString(nlUtf8ToTStr(loc->getName()));
m_AvailableTargets.SetItemData(l, (DWORD_PTR) loc);
}
@ -159,7 +159,7 @@ BOOL CLocatedTargetDlg::OnInitDialog()
// fill the box thta tells us what the target are
for(k = 0; k < nbTarg; ++k)
{
m_Targets.AddString(utf8ToTStr(_LBTarget->getTarget(k)->getName()));
m_Targets.AddString(nlUtf8ToTStr(_LBTarget->getTarget(k)->getName()));
m_Targets.SetItemData(k, (DWORD_PTR) _LBTarget->getTarget(k));
targetSet.insert(_LBTarget->getTarget(k));
};
@ -179,7 +179,7 @@ BOOL CLocatedTargetDlg::OnInitDialog()
{
if (targetSet.find(loc) == targetSet.end())
{
int l = m_AvailableTargets.AddString(utf8ToTStr(loc->getName()));
int l = m_AvailableTargets.AddString(nlUtf8ToTStr(loc->getName()));
m_AvailableTargets.SetItemData(l, (DWORD_PTR) loc);
}
}

View file

@ -592,7 +592,7 @@ void CMainFrame::OnFileLoadconfig()
}
catch (const Exception& e)
{
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
else
@ -764,7 +764,7 @@ void CMainFrame::OnFileSaveconfig()
}
catch (const Exception& e)
{
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
else
@ -1443,7 +1443,7 @@ void CMainFrame::OnUpdateSceneCamera(CCmdUI* pCmdUI)
CInstanceInfo *instance = ObjView->getInstance (ObjView->getCameraInstance (pCmdUI->m_nID - ID_SCENE_CAMERA_FIRST));
nlassert (instance->Camera);
std::string text = NLMISC::toString("Camera %s", instance->Saved.ShapeFilename.c_str());
pCmdUI->SetText(utf8ToTStr(text));
pCmdUI->SetText(nlUtf8ToTStr(text));
}
else
{

View file

@ -94,7 +94,7 @@ void CMeshDlg::OnBrowseShape()
if (fd.DoModal() == IDOK)
{
// Add to the path
std::string fullPath = tStrToUtf8(fd.GetPathName());
std::string fullPath = NLMISC::tStrToUtf8(fd.GetPathName());
std::string fname = NLMISC::CFile::getFilenameWithoutExtension(fullPath);
std::string ext = NLMISC::CFile::getExtension(fullPath);
@ -104,12 +104,12 @@ void CMeshDlg::OnBrowseShape()
try
{
_ShapeParticle->setShape(fname + "." + ext);
m_ShapeName = utf8ToTStr(fname + "." + ext);
m_ShapeName = nlUtf8ToTStr(fname + "." + ext);
touchPSState();
}
catch (const NLMISC::Exception &e)
{
MessageBox(utf8ToTStr(e.what()), _T("shape loading error"));
MessageBox(nlUtf8ToTStr(e.what()), _T("shape loading error"));
}
updateMeshErrorString();
@ -159,7 +159,7 @@ void CMeshDlg::updateForMorph()
GetDlgItem(IDC_SHAPE_NAME)->EnableWindow(!enable);
if (!enable)
{
m_ShapeName = utf8ToTStr(cm->getShape());
m_ShapeName = nlUtf8ToTStr(cm->getShape());
}
else
{

View file

@ -165,19 +165,19 @@ void CMultiTexDlg::readValues(bool alternate)
char buf[128];
if (!alternate)
{
GetDlgItem(IDC_U_SPEED_1)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).x)));
GetDlgItem(IDC_V_SPEED_1)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).y)));
GetDlgItem(IDC_U_SPEED_2)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).x)));
GetDlgItem(IDC_V_SPEED_2)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).y)));
GetDlgItem(IDC_U_SPEED_1)->SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).x)));
GetDlgItem(IDC_V_SPEED_1)->SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).y)));
GetDlgItem(IDC_U_SPEED_2)->SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).x)));
GetDlgItem(IDC_V_SPEED_2)->SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).y)));
}
else
{
if (_MTP->isAlternateTexEnabled())
{
GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).x)));
GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).y)));
GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).x)));
GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).y)));
GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).x)));
GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).y)));
GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).x)));
GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).y)));
}
else
{
@ -188,7 +188,7 @@ void CMultiTexDlg::readValues(bool alternate)
}
}
GetDlgItem(IDC_BUMP_FACTOR)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getBumpFactor())));
GetDlgItem(IDC_BUMP_FACTOR)->SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.3f", _MTP->getBumpFactor())));
}

View file

@ -535,7 +535,7 @@ void CObjectViewer::loadConfigFile()
}
catch (const Exception& e)
{
::MessageBox (NULL, utf8ToTStr(e.what()), _T("Objectviewer.cfg"), MB_OK|MB_ICONEXCLAMATION);
::MessageBox(NULL, nlUtf8ToTStr(e.what()), _T("Objectviewer.cfg"), MB_OK | MB_ICONEXCLAMATION);
}
}
@ -823,7 +823,7 @@ bool CObjectViewer::initUI (HWND parent)
catch (const NLMISC::EStream &e)
{
std::string msg = toString("Unable to load the default scheme bank file : %s", e.what());
::MessageBox(NULL, utf8ToTStr(msg), _T("Object Viewer"), MB_ICONEXCLAMATION);
::MessageBox(NULL, nlUtf8ToTStr(msg), _T("Object Viewer"), MB_ICONEXCLAMATION);
}
}
iF.close();
@ -840,7 +840,7 @@ bool CObjectViewer::initUI (HWND parent)
catch (const Exception& e)
{
std::string msg = toString("Error while loading default.ovcgf : %s", e.what());
::MessageBox (NULL, utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
::MessageBox(NULL, nlUtf8ToTStr(msg), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
@ -1312,7 +1312,7 @@ void CObjectViewer::go ()
);
// Display
_MainFrame->StatusBar.SetWindowText (utf8ToTStr(msgBar));
_MainFrame->StatusBar.SetWindowText(nlUtf8ToTStr(msgBar));
// Display Vegetable info.
if(_VegetableDlg!=NULL)
@ -1794,7 +1794,7 @@ void CObjectViewer::serial (NLMISC::IStream& f)
{
// Error message
std::string message = toString("File not found %s", readed[i].ShapeFilename.c_str());
_MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(message), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
// Stop loading
break;
@ -1829,7 +1829,7 @@ void CObjectViewer::serial (NLMISC::IStream& f)
{
// Error message
std::string message = toString("Error loading shape %s: %s", readed[i].ShapeFilename.c_str(), e.what());
_MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(message), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
// Stop loading
break;
@ -1899,7 +1899,7 @@ bool CObjectViewer::loadInstanceGroup(const std::string &igFilename)
{
// clean
delete ig;
_MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
return false;
}
}
@ -1907,7 +1907,7 @@ bool CObjectViewer::loadInstanceGroup(const std::string &igFilename)
{
// Create a message
std::string msg = toString("Can't open the file %s for reading.", igFilename.c_str());
_MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(msg), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
return false;
}
@ -1962,7 +1962,7 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const std:
}
catch (const Exception& e)
{
_MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
// error
skelError=true;
@ -1972,7 +1972,7 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const std:
{
// Create a message
std::string msg = NLMISC::toString("Can't open the file %s for reading.", skeleton.c_str());
_MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(msg), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
// error
skelError=true;
@ -2015,7 +2015,7 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const std:
}
catch (const Exception& e)
{
_MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
continue;
}
}
@ -2023,7 +2023,7 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const std:
{
// Create a message
std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str());
_MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(msg), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
continue;
}
@ -2848,7 +2848,7 @@ void CObjectViewer::enableDynamicObjectLightingTest(NLPACS::CGlobalRetriever *gl
if (!_ObjectLightTestShape.empty())
{
string str= string("Path not found for Light Test Shape: ") + _ObjectLightTestShape;
::MessageBox(NULL, utf8ToTStr(str.c_str()), _T("Dynamic Object Light Test"), MB_OK|MB_ICONEXCLAMATION);
::MessageBox(NULL, nlUtf8ToTStr(str.c_str()), _T("Dynamic Object Light Test"), MB_OK | MB_ICONEXCLAMATION);
}
// disable.
_ObjectLightTest= NULL;
@ -3223,7 +3223,7 @@ bool CObjectViewer::createVegetableLandscape()
// close the progress dialog
dlgProgress.DestroyWindow();
MessageBox(_MainFrame->m_hWnd, utf8ToTStr(e.what()), _T("Failed to Load landscape"), MB_OK | MB_APPLMODAL);
MessageBox(_MainFrame->m_hWnd, nlUtf8ToTStr(e.what()), _T("Failed to Load landscape"), MB_OK | MB_APPLMODAL);
// remove first possibly created collisions objects.
if(_VegetableCollisionEntity)
@ -3557,7 +3557,7 @@ void CObjectViewer::loadAnimation(const std::string &fileName, uint instance)
{
// Create a message
std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str());
_MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(msg), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
@ -3587,7 +3587,7 @@ void CObjectViewer::loadSWT (const std::string &fileName, uint instance)
{
// Create a message
std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str());
_MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(msg), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
@ -3771,14 +3771,14 @@ void CObjectViewer::shootScene()
else
{
std::string message = toString("Can't open the file %s for writing.", filenamefinal.c_str());
_MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(message), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
break;
}
}
catch (const Exception &e)
{
std::string message = toString("Error during writing of the file %s: %s", filenamefinal.c_str(), e.what());
_MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox(nlUtf8ToTStr(message), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
break;
}
}

View file

@ -428,7 +428,7 @@ bool CParticleDlg::savePSAs(HWND parent, CParticleWorkspace::CNode &psNode ,cons
}
else
{
::MessageBox(parent, utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
::MessageBox(parent, nlUtf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
return false;
}
}
@ -474,7 +474,7 @@ bool CParticleDlg::loadPS(HWND parent, CParticleWorkspace::CNode &psNode, TLoadP
{
case Silent: return false; // no op
case ReportError:
::MessageBox(parent, utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION);
::MessageBox(parent, nlUtf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_OK | MB_ICONEXCLAMATION);
return true;
break;
case ReportErrorSkippable:
@ -549,7 +549,7 @@ void CParticleDlg::OnCreateNewPsWorkspace()
}
catch(const NLMISC::EStream &e)
{
MessageBox(utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
}
closeWorkspace();
_PW = newPW;
@ -567,7 +567,7 @@ void CParticleDlg::OnLoadPSWorkspace()
CFileDialog fd( TRUE, _T(".pws"), _T("*.pws"), 0, szFilter);
INT_PTR result = fd.DoModal();
if (result != IDOK) return;
loadWorkspace(tStrToUtf8(fd.GetPathName()));
loadWorkspace(NLMISC::tStrToUtf8(fd.GetPathName()));
}
//**************************************************************************************************************************
@ -585,7 +585,7 @@ void CParticleDlg::loadWorkspace(const std::string &fullPath)
}
catch(const NLMISC::EStream &e)
{
MessageBox(utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
setStatusBarText(CString(e.what()));
return;
}
@ -635,7 +635,7 @@ void CParticleDlg::saveWorkspaceStructure()
}
catch(const NLMISC::EStream &e)
{
localizedMessageBox(*this, utf8ToTStr(e.what()), IDS_ERROR, MB_ICONEXCLAMATION);
localizedMessageBox(*this, nlUtf8ToTStr(e.what()), IDS_ERROR, MB_ICONEXCLAMATION);
setStatusBarText(CString(e.what()));
}
}

View file

@ -213,7 +213,7 @@ HTREEITEM CParticleTreeCtrl::buildTreeFromPS(CParticleWorkspace::CNode &node, H
if (node.isLoaded())
{
// bind particle system icon
HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, utf8ToTStr(computeCaption(node)), PSIconParticleSystem, PSIconParticleSystem, 0, 0, NULL, rootHandle, prevSibling);
HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, nlUtf8ToTStr(computeCaption(node)), PSIconParticleSystem, PSIconParticleSystem, 0, 0, NULL, rootHandle, prevSibling);
// set the param (doesn't seems to work during first creation)
SetItemData(psRoot, (LPARAM) nt);
// now, create each located
@ -228,7 +228,7 @@ HTREEITEM CParticleTreeCtrl::buildTreeFromPS(CParticleWorkspace::CNode &node, H
else
{
// bind a bitmap that say that the PS hasn't been loaded
HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, utf8ToTStr(computeCaption(node)), PSIconParticleSystemNotLoaded, PSIconParticleSystemNotLoaded, 0, 0, NULL, rootHandle, prevSibling);
HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, nlUtf8ToTStr(computeCaption(node)), PSIconParticleSystemNotLoaded, PSIconParticleSystemNotLoaded, 0, 0, NULL, rootHandle, prevSibling);
SetItemData(psRoot, (LPARAM) nt);
return psRoot;
}
@ -242,7 +242,7 @@ void CParticleTreeCtrl::buildTreeFromWorkSpace(CParticleWorkspace &ws)
CNodeType *nt = new CNodeType(&ws);
_NodeTypes.push_back(nt);
// bind particle system icon
HTREEITEM rootHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, utf8ToTStr(computeCaption(ws)), PSIconWorkspace, PSIconWorkspace, 0, 0, NULL, NULL, TVI_LAST);
HTREEITEM rootHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, nlUtf8ToTStr(computeCaption(ws)), PSIconWorkspace, PSIconWorkspace, 0, 0, NULL, NULL, TVI_LAST);
// set the param (doesn't seems to work during first creation)
SetItemData(rootHandle, (LPARAM) nt);
// now, create each particle system
@ -259,7 +259,7 @@ void CParticleTreeCtrl::createNodeFromLocated(NL3D::CPSLocated *loc, HTREEITEM
CNodeType *nt = new CNodeType(loc);
_NodeTypes.push_back(nt);
// bind located icon
HTREEITEM nodeHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM |TVIF_TEXT, utf8ToTStr(loc->getName()) , PSIconLocated, PSIconLocated, 0, 0, (LPARAM) nt, rootHandle, TVI_LAST);
HTREEITEM nodeHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, nlUtf8ToTStr(loc->getName()), PSIconLocated, PSIconLocated, 0, 0, (LPARAM)nt, rootHandle, TVI_LAST);
// now, insert each object that is bound to the located
for (uint l = 0; l < loc->getNbBoundObjects(); ++l)
{
@ -273,7 +273,7 @@ void CParticleTreeCtrl::createNodeFromLocatedBindable(NL3D::CPSLocatedBindable *
// we ordered the image so that they match the type for a located bindable (force, particles, collision zones...)
CNodeType *nt = new CNodeType(lb);
_NodeTypes.push_back(nt);
InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT , utf8ToTStr(lb->getName()) , lb->getType(), lb->getType(), PSIconForce, PSIconForce, (LPARAM) nt, rootHandle, TVI_LAST);
InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, nlUtf8ToTStr(lb->getName()), lb->getType(), lb->getType(), PSIconForce, PSIconForce, (LPARAM)nt, rootHandle, TVI_LAST);
}
@ -1004,7 +1004,7 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA
nlassert(ownerNode);
// Add search path for the texture
NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())));
NLMISC::CPath::addSearchPath(NLMISC::CFile::getPath(NLMISC::tStrToUtf8(fd.GetPathName())));
CUniquePtr<NL3D::CShapeBank> sb(new NL3D::CShapeBank);
CParticleSystemModel *psm = NULL;
@ -1012,9 +1012,9 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA
{
NL3D::CShapeStream ss;
NLMISC::CIFile inputFile;
inputFile.open(tStrToUtf8(fd.GetPathName()));
inputFile.open(NLMISC::tStrToUtf8(fd.GetPathName()));
ss.serial(inputFile);
std::string shapeName = NLMISC::CFile::getFilename(tStrToUtf8(fd.GetPathName()));
std::string shapeName = NLMISC::CFile::getFilename(NLMISC::tStrToUtf8(fd.GetPathName()));
sb->add(shapeName, ss.getShapePointer());
NL3D::CShapeBank *oldSB = CNELU::Scene->getShapeBank();
CNELU::Scene->setShapeBank(sb.get());
@ -1039,7 +1039,7 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA
}
catch(const NLMISC::EStream &e)
{
MessageBox(utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_OK | MB_ICONEXCLAMATION);
return TRUE;
}
ownerNode->setResetAutoCountFlag(false);
@ -1096,10 +1096,10 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA
_ParticleDlg->StartStopDlg->stop();
std::string fileName = nt->PS->getFilename();
static TCHAR BASED_CODE szFilter[] = _T("ps & shapes files(*.ps;*.shape)|*.ps; *.shape||");
CFileDialog fd(FALSE, _T(".ps"), utf8ToTStr(fileName), OFN_OVERWRITEPROMPT, szFilter, this);
CFileDialog fd(FALSE, _T(".ps"), nlUtf8ToTStr(fileName), OFN_OVERWRITEPROMPT, szFilter, this);
if (fd.DoModal() == IDOK)
{
_ParticleDlg->savePSAs(*this, *nt->PS, tStrToUtf8(fd.GetPathName()), false);
_ParticleDlg->savePSAs(*this, *nt->PS, NLMISC::tStrToUtf8(fd.GetPathName()), false);
}
}
}
@ -1249,7 +1249,7 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA
}
getOwnerNode(nt)->setModified(true);
// TODO : an enum for CPSLocatedBindable::getType would be better...
InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, utf8ToTStr(toCreate->getName()), toCreate->getType(), toCreate->getType(), 0, 0, (LPARAM) newNt, father, lastSon);
InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, nlUtf8ToTStr(toCreate->getName()), toCreate->getType(), toCreate->getType(), 0, 0, (LPARAM)newNt, father, lastSon);
touchPSState(nt);
Invalidate();
_ParticleDlg->StartStopDlg->resetAutoCount(getOwnerNode(nt));
@ -1280,7 +1280,7 @@ std::pair<CParticleTreeCtrl::CNodeType *, HTREEITEM> CParticleTreeCtrl::createL
CNodeType *newNt = new CNodeType(loc);
_NodeTypes.push_back(newNt);
// insert item in tree
HTREEITEM insertedItem = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, utf8ToTStr(name), PSIconLocated, PSIconLocated, 0, 0, (LPARAM) newNt, headItem, TVI_LAST);
HTREEITEM insertedItem = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, nlUtf8ToTStr(name), PSIconLocated, PSIconLocated, 0, 0, (LPARAM)newNt, headItem, TVI_LAST);
touchPSState(newNt);
return std::make_pair(newNt, insertedItem);
}
@ -1299,7 +1299,7 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
{
case CNodeType::workspace:
{
nt->WS->setName(tStrToUtf8(info->item.pszText));
nt->WS->setName(NLMISC::tStrToUtf8(info->item.pszText));
workspaceModifiedFlagChanged(*nt->WS); // change name (this may be called twice because of the modification callback, but this doesn't matter)
}
break;
@ -1311,10 +1311,10 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
}
else
{
nt->PS->getPSPointer()->setName(tStrToUtf8(info->item.pszText));
nt->PS->getPSPointer()->setName(NLMISC::tStrToUtf8(info->item.pszText));
nt->PS->setModified(true);
}
this->SetItemText(info->item.hItem, utf8ToTStr(computeCaption(*nt->PS)));
this->SetItemText(info->item.hItem, nlUtf8ToTStr(computeCaption(*nt->PS)));
}
break;
case CNodeType::located:
@ -1322,7 +1322,7 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
nlassert(getOwnerNode(nt));
getOwnerNode(nt)->setModified(true);
this->SetItemText(info->item.hItem, info->item.pszText);
nt->Loc->setName(tStrToUtf8(info->item.pszText));
nt->Loc->setName(NLMISC::tStrToUtf8(info->item.pszText));
}
break;
case CNodeType::locatedBindable:
@ -1330,7 +1330,7 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
nlassert(getOwnerNode(nt));
getOwnerNode(nt)->setModified(true);
this->SetItemText(info->item.hItem, info->item.pszText);
nt->Bind->setName(tStrToUtf8(info->item.pszText));
nt->Bind->setName(NLMISC::tStrToUtf8(info->item.pszText));
}
break;
}
@ -1466,7 +1466,7 @@ void CParticleTreeCtrl::updateCaption(CParticleWorkspace::CNode &node)
HTREEITEM item = getTreeItem(&node);
if (!item) return;
// update name of ps to dipslay a star in front of it (this tells that the ps has been modified)
SetItemText(item, utf8ToTStr(computeCaption(node)));
SetItemText(item, nlUtf8ToTStr(computeCaption(node)));
}
//****************************************************************************************************************
@ -1545,7 +1545,7 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws)
while (pos)
{
CString path = fd.GetNextPathName(pos);
CParticleWorkspace::CNode *node = pws.addNode(tStrToUtf8(path));
CParticleWorkspace::CNode *node = pws.addNode(NLMISC::tStrToUtf8(path));
if (!node)
{
if (diplayNodeAlreadyInserted)
@ -1558,7 +1558,7 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws)
}
else
{
MessageBox(CString(utf8ToTStr(NLMISC::CFile::getFilename(tStrToUtf8(path)))) + getStrRsc(IDS_PS_ALREADY_INSERTED), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION);
MessageBox(CString(nlUtf8ToTStr(NLMISC::CFile::getFilename(NLMISC::tStrToUtf8(path)))) + getStrRsc(IDS_PS_ALREADY_INSERTED), getStrRsc(IDS_ERROR), MB_OK | MB_ICONEXCLAMATION);
}
}
continue;
@ -1593,7 +1593,7 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws)
}
}
// update modified state
SetItemText(GetRootItem(), utf8ToTStr(computeCaption(pws)));
SetItemText(GetRootItem(), nlUtf8ToTStr(computeCaption(pws)));
}
}
@ -1736,7 +1736,7 @@ void CParticleTreeCtrl::OnBeginlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
switch (nt->Type)
{
case CNodeType::workspace:
pEdit->SetWindowText(utf8ToTStr(nt->WS->getName()));
pEdit->SetWindowText(nlUtf8ToTStr(nt->WS->getName()));
break;
case CNodeType::particleSystem:
{
@ -1747,18 +1747,18 @@ void CParticleTreeCtrl::OnBeginlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
}
else
{
pEdit->SetWindowText(utf8ToTStr(nt->PS->getPSPointer()->getName()));
pEdit->SetWindowText(nlUtf8ToTStr(nt->PS->getPSPointer()->getName()));
}
}
break;
case CNodeType::located:
{
pEdit->SetWindowText(utf8ToTStr(nt->Loc->getName()));
pEdit->SetWindowText(nlUtf8ToTStr(nt->Loc->getName()));
}
break;
case CNodeType::locatedBindable:
{
pEdit->SetWindowText(utf8ToTStr(nt->Bind->getName()));
pEdit->SetWindowText(nlUtf8ToTStr(nt->Bind->getName()));
}
break;
}
@ -1855,10 +1855,10 @@ void CParticleTreeCtrl::updateAllCaptions()
switch(nt->Type)
{
case CNodeType::particleSystem:
SetItemText(curr, utf8ToTStr(computeCaption(*nt->PS)));
SetItemText(curr, nlUtf8ToTStr(computeCaption(*nt->PS)));
break;
case CNodeType::workspace:
SetItemText(curr, utf8ToTStr(computeCaption(*nt->WS)));
SetItemText(curr, nlUtf8ToTStr(computeCaption(*nt->WS)));
break;
case CNodeType::located:
case CNodeType::locatedBindable:

View file

@ -371,13 +371,13 @@ CParticleWorkspace::CNode *CParticleWorkspace::addNode(const std::string &filena
TCHAR resultPath[MAX_PATH];
std::string dosPath = NLMISC::CPath::standardizeDosPath(getPath());
std::string relativePath;
if (!PathRelativePathTo(resultPath, utf8ToTStr(dosPath), FILE_ATTRIBUTE_DIRECTORY, utf8ToTStr(filenameWithFullPath), 0))
if (!PathRelativePathTo(resultPath, nlUtf8ToTStr(dosPath), FILE_ATTRIBUTE_DIRECTORY, nlUtf8ToTStr(filenameWithFullPath), 0))
{
relativePath = filenameWithFullPath;
}
else
{
relativePath = tStrToUtf8(resultPath);
relativePath = NLMISC::tStrToUtf8(resultPath);
}
if (relativePath.size() >= 2)

View file

@ -74,7 +74,7 @@ BOOL CPickSound::OnInitDialog()
for (TNameVect::iterator it = _Names.begin(); it != _Names.end(); ++it)
{
m_NameList.AddString(utf8ToTStr((*it).toString()));
m_NameList.AddString(nlUtf8ToTStr((*it).toString()));
}
_Timer = SetTimer (1, 100, NULL);
@ -111,7 +111,7 @@ void CPickSound::OnSelchange()
nlassert(m_NameList.GetTextLen(m_NameList.GetCurSel()) < 1024);
m_NameList.GetText(m_NameList.GetCurSel(), str);
_CurrName = NLMISC::CSheetId(tStrToUtf8(str), "sound");
_CurrName = NLMISC::CSheetId(NLMISC::tStrToUtf8(str), "sound");
}
@ -123,7 +123,7 @@ void CPickSound::OnPlaySound()
stopCurrSource();
CString sName;
m_NameList.GetText(curSel, sName);
CSoundSystem::create(tStrToUtf8(sName));
CSoundSystem::create(NLMISC::tStrToUtf8(sName));
}
//========================================================================================
@ -159,7 +159,7 @@ void CPickSound::OnDblclkList()
stopCurrSource();
CString sName;
m_NameList.GetText(curSel, sName);
_CurrSource = CSoundSystem::create(tStrToUtf8(sName));
_CurrSource = CSoundSystem::create(NLMISC::tStrToUtf8(sName));
}
//========================================================================================

View file

@ -126,7 +126,7 @@ void CPrecomputedRotationsDlg::OnUpdateMinRotSpeed()
nlassert(_RotatedParticle);
UpdateData();
float newValue, valueMin, valueMax;
if (NLMISC::fromString(tStrToUtf8(m_RotSpeedMin), newValue))
if (NLMISC::fromString(NLMISC::tStrToUtf8(m_RotSpeedMin), newValue))
{
uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax);
valueMin = newValue;
@ -146,7 +146,7 @@ void CPrecomputedRotationsDlg::OnUpdateMaxRotSpeed()
nlassert(_RotatedParticle);
UpdateData();
float newValue, valueMin, valueMax;
if (NLMISC::fromString(tStrToUtf8(m_RotSpeedMax), newValue))
if (NLMISC::fromString(NLMISC::tStrToUtf8(m_RotSpeedMax), newValue))
{
uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax);
valueMax = newValue;
@ -167,7 +167,7 @@ void CPrecomputedRotationsDlg::OnUpdateNbModels()
UpdateData();
float valueMin, valueMax;
sint32 newNbModels;
bool valid = (NLMISC::fromString(tStrToUtf8(m_NbModels), newNbModels) && newNbModels > 0);
bool valid = (NLMISC::fromString(NLMISC::tStrToUtf8(m_NbModels), newNbModels) && newNbModels > 0);
if (dynamic_cast<NL3D::CPSConstraintMesh *>(_RotatedParticle))
{
valid &= (newNbModels < NL3D::ConstraintMeshMaxNumPrerotatedModels);

View file

@ -120,7 +120,7 @@ void CPSMoverDlg::OnUpdateXpos()
UpdateData();
NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex];
float x;
if (NLMISC::fromString(tStrToUtf8(m_X), x))
if (NLMISC::fromString(NLMISC::tStrToUtf8(m_X), x))
{
pos.x = x;
updateListener();
@ -137,7 +137,7 @@ void CPSMoverDlg::OnUpdateYpos()
UpdateData();
NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex];
float y;
if (NLMISC::fromString(tStrToUtf8(m_Y), y))
if (NLMISC::fromString(NLMISC::tStrToUtf8(m_Y), y))
{
pos.y = y;
updateListener();
@ -154,7 +154,7 @@ void CPSMoverDlg::OnUpdateZpos()
UpdateData();
NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex];
float z;
if (NLMISC::fromString(tStrToUtf8(m_Z), z))
if (NLMISC::fromString(NLMISC::tStrToUtf8(m_Z), z))
{
pos.z = z;
updateListener();
@ -178,7 +178,7 @@ BOOL CPSMoverDlg::OnInitDialog()
{
if (dynamic_cast<NL3D::IPSMover *>(_EditedLocated->getBoundObject(k)))
{
uint insertedLine = m_SubComponentCtrl.AddString(utf8ToTStr(_EditedLocated->getBoundObject(k)->getName()));
uint insertedLine = m_SubComponentCtrl.AddString(nlUtf8ToTStr(_EditedLocated->getBoundObject(k)->getName()));
m_SubComponentCtrl.SetItemData(insertedLine, (DWORD_PTR) _EditedLocated->getBoundObject(k));
++nbCandidates;
}

View file

@ -84,7 +84,7 @@ void CSchemeBankDlg::buildList()
SchemeManager.getSchemes(_Type, schemes);
for (TSchemeVect::const_iterator it = schemes.begin(); it != schemes.end(); ++it)
{
int index = m_SchemeList.AddString(utf8ToTStr(it->first));
int index = m_SchemeList.AddString(nlUtf8ToTStr(it->first));
m_SchemeList.SetItemData(index, (DWORD_PTR) it->second);
}
@ -99,18 +99,18 @@ void CSchemeBankDlg::OnSaveBank()
if (fd.DoModal() == IDOK)
{
// Add search path for the texture
NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())));
NLMISC::CPath::addSearchPath(NLMISC::CFile::getPath(NLMISC::tStrToUtf8(fd.GetPathName())));
try
{
NLMISC::COFile iF;
iF.open(tStrToUtf8(fd.GetFileName()));
iF.open(NLMISC::tStrToUtf8(fd.GetFileName()));
iF.serial(SchemeManager);
}
catch (const std::exception &e)
{
std::string message = NLMISC::toString("Error saving scheme bank : %s", e.what());
MessageBox(utf8ToTStr(message), _T("Object viewer"), MB_ICONEXCLAMATION | MB_OK);
MessageBox(nlUtf8ToTStr(message), _T("Object viewer"), MB_ICONEXCLAMATION | MB_OK);
return;
}
}
@ -124,20 +124,20 @@ void CSchemeBankDlg::OnLoadBank()
if (fd.DoModal() == IDOK)
{
// Add search path for the texture
NLMISC::CPath::addSearchPath(NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())));
NLMISC::CPath::addSearchPath(NLMISC::CFile::getPath(NLMISC::tStrToUtf8(fd.GetPathName())));
CSchemeManager sm;
try
{
NLMISC::CIFile iF;
iF.open(NLMISC::CPath::lookup(tStrToUtf8(fd.GetFileName())));
iF.open(NLMISC::CPath::lookup(NLMISC::tStrToUtf8(fd.GetFileName())));
iF.serial(sm);
SchemeManager.swap(sm);
}
catch (const std::exception &e)
{
std::string message = NLMISC::toString("Error loading scheme bank : %s", e.what());
MessageBox(utf8ToTStr(message), _T("Object viewer"), MB_ICONEXCLAMATION | MB_OK);
MessageBox(nlUtf8ToTStr(message), _T("Object viewer"), MB_ICONEXCLAMATION | MB_OK);
return;
}
buildList();
@ -167,7 +167,7 @@ void CSchemeBankDlg::OnRename()
SchemeManager.rename(scheme, cn.getName());
int curSel = m_SchemeList.GetCurSel();
m_SchemeList.DeleteString(curSel);
int insertedPos = m_SchemeList.InsertString(curSel, utf8ToTStr(cn.getName()));
int insertedPos = m_SchemeList.InsertString(curSel, nlUtf8ToTStr(cn.getName()));
m_SchemeList.SetCurSel(insertedPos);
m_SchemeList.Invalidate();
}

View file

@ -77,14 +77,14 @@ BOOL CSelectString::OnInitDialog()
CDialog::OnInitDialog();
// Change title
SetWindowText (utf8ToTStr(Title));
SetWindowText(nlUtf8ToTStr(Title));
// Empty button ?
EmptyCtrl.ShowWindow (Empty?SW_SHOW:SW_HIDE);
// Add string
for (uint s=0; s<Strings.size(); s++)
ListCtrl.InsertString (-1, utf8ToTStr(Strings[s]));
ListCtrl.InsertString(-1, nlUtf8ToTStr(Strings[s]));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE

View file

@ -209,7 +209,7 @@ void CSkeletonScaleDlg::setSkeletonToEdit(NL3D::CSkeletonModel *skel, const std
name = tabStr + name;
// append to the list
_BoneList.AddString(utf8ToTStr(name));
_BoneList.AddString(nlUtf8ToTStr(name));
}
}
@ -404,7 +404,7 @@ void CSkeletonScaleDlg::applyScaleSlider(sint scrollValue)
// update marker text
std::string str = NLMISC::toString("%d%%", (sint)(factor*100));
_StaticScaleMarkers[_SliderEdited]->SetWindowText(utf8ToTStr(str));
_StaticScaleMarkers[_SliderEdited]->SetWindowText(nlUtf8ToTStr(str));
}
// ***************************************************************************
@ -717,7 +717,7 @@ void CSkeletonScaleDlg::updateScalesFromText(UINT ctrlId)
return;
// get the scale info
std::string str = tStrToUtf8(*_ScaleEdits[sid]);
std::string str = NLMISC::tStrToUtf8(*_ScaleEdits[sid]);
if(str.empty())
return;
float f;
@ -846,13 +846,13 @@ void CSkeletonScaleDlg::OnSsdButtonSaveas()
return;
// choose the file
CFileDialog fd(FALSE, _T("skel"), utf8ToTStr(_SkeletonFileName), OFN_OVERWRITEPROMPT, _T("SkelFiles (*.skel)|*.skel|All Files (*.*)|*.*||"), this) ;
CFileDialog fd(FALSE, _T("skel"), nlUtf8ToTStr(_SkeletonFileName), OFN_OVERWRITEPROMPT, _T("SkelFiles (*.skel)|*.skel|All Files (*.*)|*.*||"), this);
fd.m_ofn.lpstrTitle = _T("Save As Skeleton");
if (fd.DoModal() == IDOK)
{
NLMISC::COFile f;
if( f.open(tStrToUtf8(fd.GetPathName())) )
if (f.open(NLMISC::tStrToUtf8(fd.GetPathName())))
{
if(saveCurrentInStream(f))
{
@ -862,7 +862,7 @@ void CSkeletonScaleDlg::OnSsdButtonSaveas()
}
// bkup the valid fileName (new file edited)
_SkeletonFileName= tStrToUtf8(fd.GetPathName());
_SkeletonFileName = NLMISC::tStrToUtf8(fd.GetPathName());
_StaticFileName= _SkeletonFileName.c_str();
UpdateData(FALSE);
}
@ -1228,13 +1228,13 @@ void CSkeletonScaleDlg::OnSsdButtonSaveScale()
std::string defaultFileName = _SkeletonFileName;
NLMISC::strFindReplace(defaultFileName, ".skel", ".scale");
CFileDialog fd(FALSE, _T("scale"), utf8ToTStr(defaultFileName), OFN_OVERWRITEPROMPT, _T("SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||"), this) ;
CFileDialog fd(FALSE, _T("scale"), nlUtf8ToTStr(defaultFileName), OFN_OVERWRITEPROMPT, _T("SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||"), this);
fd.m_ofn.lpstrTitle = _T("Save As Skeleton Scale File");
if (fd.DoModal() == IDOK)
{
NLMISC::COFile f;
if (f.open(tStrToUtf8(fd.GetPathName())))
if (f.open(NLMISC::tStrToUtf8(fd.GetPathName())))
{
saveSkelScaleInStream(f);
}
@ -1256,13 +1256,13 @@ void CSkeletonScaleDlg::OnSsdButtonLoadScale()
std::string defaultFileName= _SkeletonFileName;
NLMISC::strFindReplace(defaultFileName, ".skel", ".scale");
CFileDialog fd(TRUE, _T("scale"), utf8ToTStr(defaultFileName), 0, _T("SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||"), this) ;
CFileDialog fd(TRUE, _T("scale"), nlUtf8ToTStr(defaultFileName), 0, _T("SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||"), this);
fd.m_ofn.lpstrTitle= _T("Load a Skeleton Scale File");
if (fd.DoModal() == IDOK)
{
NLMISC::CIFile f;
if (f.open(tStrToUtf8(fd.GetPathName())))
if (f.open(NLMISC::tStrToUtf8(fd.GetPathName())))
{
loadSkelScaleFromStream(f);
}

View file

@ -472,7 +472,7 @@ void CSlotDlg::setWindowName ()
}
}
GetDlgItem (IDC_SLOT_NAME)->SetWindowText (utf8ToTStr(tmp));
GetDlgItem(IDC_SLOT_NAME)->SetWindowText(nlUtf8ToTStr(tmp));
}
// ***************************************************************************

View file

@ -183,7 +183,7 @@ void CSnapshotToolDlg::fromRegistry()
for (uint k = 0; k < filterList.size(); ++k)
{
m_Filters.AddString(utf8ToTStr(filterList[k]));
m_Filters.AddString(nlUtf8ToTStr(filterList[k]));
}
integralTypeFromRegistry(hKey, _T("RecurseSubFolder"), (int &) m_RecurseSubFolder, FALSE);
@ -597,7 +597,7 @@ void CSnapshotToolDlg::OnTimer(UINT_PTR nIDEvent)
try
{
CShapeStream ss;
m_Log.AddString(utf8ToTStr(_FilteredFiles[0]));
m_Log.AddString(nlUtf8ToTStr(_FilteredFiles[0]));
CIFile stream(_FilteredFiles[0]);
ss.serial(stream);
nlassert(ss.getShapePointer());

View file

@ -78,7 +78,7 @@ void CSoundAnimDlg::handle()
{
float sec = _AnimationDlg->getTime();
std::string text = toString("time: %.3f", sec);
GetDlgItem(IDC_SOUNDANIMINFO)->SetWindowText(utf8ToTStr(text));
GetDlgItem(IDC_SOUNDANIMINFO)->SetWindowText(nlUtf8ToTStr(text));
_AnimView.updateCursor();
}
@ -136,7 +136,7 @@ void CSoundAnimDlg::updateSounds()
for (iter = sounds.begin(); iter != sounds.end(); iter++)
{
list->AddString(utf8ToTStr((*iter).toString()));
list->AddString(nlUtf8ToTStr((*iter).toString()));
}
list->UpdateData();

View file

@ -217,7 +217,7 @@ void CSoundAnimView::save()
// Create a dialog
TCHAR BASED_CODE szFilter[] = _T("NeL Sound Animations (*.sound_anim)|*.sound_anim|All Files (*.*)|*.*||");
CFileDialog fileDlg( FALSE, _T(".sound_anim"), utf8ToTStr(filename), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter);
CFileDialog fileDlg(FALSE, _T(".sound_anim"), nlUtf8ToTStr(filename), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);
if (fileDlg.DoModal() == IDOK)
{
@ -236,7 +236,7 @@ void CSoundAnimView::save()
}
catch (const Exception& e)
{
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
}

View file

@ -231,13 +231,13 @@ void CStartStopParticleSystem::updateUIFromState()
{
if (!_ActiveNode->getParentSkelName().empty())
{
GetDlgItem(IDC_STICK_BONE)->SetWindowText(utf8ToTStr(_ActiveNode->getParentBoneName() + "." + _ActiveNode->getParentBoneName()));
GetDlgItem(IDC_STICK_BONE)->SetWindowText(nlUtf8ToTStr(_ActiveNode->getParentBoneName() + "." + _ActiveNode->getParentBoneName()));
}
else
{
GetDlgItem(IDC_STICK_BONE)->SetWindowText(_T(""));
}
GetDlgItem(IDC_ACTIVE_PS)->SetWindowText(utf8ToTStr(_ActiveNode->getFilename()));
GetDlgItem(IDC_ACTIVE_PS)->SetWindowText(nlUtf8ToTStr(_ActiveNode->getFilename()));
GetDlgItem(IDC_ENABLE_AUTO_COUNT)->EnableWindow(TRUE);
((CButton *) GetDlgItem(IDC_ENABLE_AUTO_COUNT))->SetCheck(getCurrPS()->getAutoCountFlag() ? 1 : 0);
GetDlgItem(IDC_RESET_COUNT)->EnableWindow((_ActiveNode->getPSPointer()->getAutoCountFlag() && !_ActiveNode->getResetAutoCountFlag()) ? TRUE : FALSE);
@ -844,7 +844,7 @@ void CStartStopParticleSystem::OnLinkToSkeleton()
uint boneIndex;
std::string parentSkelName;
std::string parentBoneName;
if (ov->chooseBone(tStrToUtf8(chooseBoneForPS), skel, boneIndex, &parentSkelName, &parentBoneName))
if (ov->chooseBone(NLMISC::tStrToUtf8(chooseBoneForPS), skel, boneIndex, &parentSkelName, &parentBoneName))
{
_ParticleDlg->stickPSToSkeleton(_ActiveNode, skel, boneIndex, parentSkelName, parentBoneName);
}
@ -1017,11 +1017,11 @@ void CStartStopParticleSystem::OnBrowseAnim()
}
}
std::vector<std::string> animList(animSet.begin(), animSet.end());
CSelectString st(animList, tStrToUtf8(getStrRsc(IDS_SELECT_ANIMATION)), this, false);
CSelectString st(animList, NLMISC::tStrToUtf8(getStrRsc(IDS_SELECT_ANIMATION)), this, false);
if (st.DoModal() == IDOK && st.Selection != -1)
{
m_TriggerAnim = animList[st.Selection].c_str();
_ActiveNode->setTriggerAnim(tStrToUtf8(m_TriggerAnim));
_ActiveNode->setTriggerAnim(NLMISC::tStrToUtf8(m_TriggerAnim));
GetDlgItem(IDC_CLEAR_ANIM)->EnableWindow(!_ActiveNode->getTriggerAnim().empty());
}
_ParticleDlg->ParticleTreeCtrl->updateCaption(*_ActiveNode);

View file

@ -23,8 +23,13 @@
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#define _WIN32_WINNT 0x0501
#ifdef _WIN64
#define _WIN32_WINNT 0x0600
#else
#define _WIN32_WINNT 0x0500
#endif
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions

View file

@ -179,22 +179,22 @@ void CTextureChooser::OnBrowseTexture()
{
texName = (static_cast<NL3D::CTextureFile *>(_Wrapper->get()))->getFileName();
}
CFileDialog fd(TRUE, _T(".tga"), utf8ToTStr(texName), 0, NULL, this);
CFileDialog fd(TRUE, _T(".tga"), nlUtf8ToTStr(texName), 0, NULL, this);
if (fd.DoModal() == IDOK)
{
// Add search path for the texture
NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())));
NLMISC::CPath::addSearchPath(NLMISC::CFile::getPath(NLMISC::tStrToUtf8(fd.GetPathName())));
try
{
NL3D::CTextureFile *tf = new NL3D::CTextureFile(tStrToUtf8(fd.GetFileName()));
NL3D::CTextureFile *tf = new NL3D::CTextureFile(NLMISC::tStrToUtf8(fd.GetFileName()));
_Wrapper->setAndUpdateModifiedFlag(tf);
_Texture = tf;
textureToBitmap();
}
catch (const NLMISC::Exception &e)
{
MessageBox(utf8ToTStr(e.what()), _T("error loading texture"));
MessageBox(nlUtf8ToTStr(e.what()), _T("error loading texture"));
}
}

View file

@ -249,7 +249,7 @@ BOOL CVegetableCopyDlg::OnInitDialog()
uint num= _VegetableDlg->getNumVegetables();
for(uint i=0; i<num; i++)
{
VegetableList.AddString(utf8ToTStr(_VegetableDlg->getVegetableName(i)));
VegetableList.AddString(nlUtf8ToTStr(_VegetableDlg->getVegetableName(i)));
}

View file

@ -100,7 +100,7 @@ void CVegetableDensityPage::setVegetableToEdit(NL3D::CVegetable *vegetable)
{
// Init ShapeName
// ----------
StaticVegetableShape.SetWindowText(utf8ToTStr(_Vegetable->ShapeName));
StaticVegetableShape.SetWindowText(nlUtf8ToTStr(_Vegetable->ShapeName));
// init Creation Distance.
// ----------
@ -228,7 +228,7 @@ void CVegetableDensityPage::updateAngleMinFromEditText()
TCHAR stmp[256];
AngleMinEdit.GetWindowText(stmp, 256);
float angleMin;
NLMISC::fromString(tStrToUtf8(stmp), angleMin);
NLMISC::fromString(NLMISC::tStrToUtf8(stmp), angleMin);
NLMISC::clamp(angleMin, -90, 90);
// make a sinus, because 90 => 1, and -90 =>-1
float cosAngleMin= (float)sin(angleMin*NLMISC::Pi/180.f);
@ -252,7 +252,7 @@ void CVegetableDensityPage::updateAngleMaxFromEditText()
TCHAR stmp[256];
AngleMaxEdit.GetWindowText(stmp, 256);
float angleMax;
NLMISC::fromString(tStrToUtf8(stmp), angleMax);
NLMISC::fromString(NLMISC::tStrToUtf8(stmp), angleMax);
NLMISC::clamp(angleMax, -90, 90);
// make a sinus, because 90 => 1, and -90 =>-1
float cosAngleMax= (float)sin(angleMax*NLMISC::Pi/180.f);
@ -523,10 +523,10 @@ void CVegetableDensityPage::OnButtonVegetableBrowse()
if (fd.DoModal() == IDOK)
{
// Add to the path
std::string fileName = tStrToUtf8(fd.GetFileName());
std::string fileName = NLMISC::tStrToUtf8(fd.GetFileName());
// Add search path for the .veget
std::string path = NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName()));
std::string path = NLMISC::CFile::getPath(NLMISC::tStrToUtf8(fd.GetPathName()));
NLMISC::CPath::addSearchPath (path);
try
@ -546,7 +546,7 @@ void CVegetableDensityPage::OnButtonVegetableBrowse()
}
catch (const NLMISC::EPathNotFound &ep)
{
MessageBox(utf8ToTStr(ep.what()), _T("Can't open file"));
MessageBox(nlUtf8ToTStr(ep.what()), _T("Can't open file"));
}
}
}

View file

@ -196,7 +196,7 @@ void CVegetableDlg::updateCurSelVegetableName()
_Vegetables[id].updateVegetableName();
// replace name in the listBox: must delete, and re-insert
VegetableList.DeleteString(id);
VegetableList.InsertString(id, utf8ToTStr(_Vegetables[id].VegetableName));
VegetableList.InsertString(id, nlUtf8ToTStr(_Vegetables[id].VegetableName));
VegetableList.SetCurSel(id);
}
}
@ -349,14 +349,14 @@ bool CVegetableDlg::loadVegetableSet(NL3D::CTileVegetableDesc &vegetSet, const
ok= true;
if( f.open(tStrToUtf8(fd.GetPathName())))
if (f.open(NLMISC::tStrToUtf8(fd.GetPathName())))
{
try
{
// read the vegetable
f.serial(vegetSet);
// bkup fileName.
_LastVegetSetName = tStrToUtf8(fd.GetFileName());
_LastVegetSetName = NLMISC::tStrToUtf8(fd.GetFileName());
}
catch(const NLMISC::EStream &)
{
@ -439,7 +439,7 @@ void CVegetableDlg::appendVegetableSet(NL3D::CTileVegetableDesc &vegetSet)
_Vegetables[id].initVegetable(veget);
// update view
VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName));
VegetableList.AddString(nlUtf8ToTStr(_Vegetables[id].VegetableName));
}
}
}
@ -529,7 +529,7 @@ void CVegetableDlg::OnButtonVegetableAdd()
_Vegetables[id].initDefaultVegetable();
// update view
VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName));
VegetableList.AddString(nlUtf8ToTStr(_Vegetables[id].VegetableName));
// update 3D view
refreshVegetableDisplay();
@ -559,7 +559,7 @@ void CVegetableDlg::OnButtonVegetableInsert()
_Vegetables[id].initDefaultVegetable();
// update view
VegetableList.InsertString(id, utf8ToTStr(_Vegetables[id].VegetableName));
VegetableList.InsertString(id, nlUtf8ToTStr(_Vegetables[id].VegetableName));
// update 3D view
refreshVegetableDisplay();
@ -611,7 +611,7 @@ void CVegetableDlg::OnButtonVegetableLoadDesc()
{
NLMISC::CIFile f;
if( f.open(tStrToUtf8(fd.GetPathName())) )
if (f.open(NLMISC::tStrToUtf8(fd.GetPathName())))
{
NL3D::CVegetable veget;
try
@ -624,7 +624,7 @@ void CVegetableDlg::OnButtonVegetableLoadDesc()
_Vegetables[id].initVegetable(veget);
// update view
VegetableList.AddString(utf8ToTStr(_Vegetables[id].VegetableName));
VegetableList.AddString(nlUtf8ToTStr(_Vegetables[id].VegetableName));
// update 3D view
refreshVegetableDisplay();
@ -651,13 +651,13 @@ void CVegetableDlg::OnButtonVegetableSaveDesc()
std::string fileName= _Vegetables[id].VegetableName + ".vegetdesc";
CFileDialog fd(FALSE, _T("vegetdesc"), utf8ToTStr(fileName), OFN_OVERWRITEPROMPT, _T("VegetDescFiles (*.vegetdesc)|*.vegetdesc|All Files (*.*)|*.*||"), this) ;
CFileDialog fd(FALSE, _T("vegetdesc"), nlUtf8ToTStr(fileName), OFN_OVERWRITEPROMPT, _T("VegetDescFiles (*.vegetdesc)|*.vegetdesc|All Files (*.*)|*.*||"), this);
fd.m_ofn.lpstrTitle = _T("Save Vegetable Descriptor");
if (fd.DoModal() == IDOK)
{
NLMISC::COFile f;
if( f.open(tStrToUtf8(fd.GetPathName())) )
if (f.open(NLMISC::tStrToUtf8(fd.GetPathName())))
{
try
{
@ -722,13 +722,13 @@ void CVegetableDlg::OnButtonVegetableSaveSet()
buildVegetableSet(vegetSet);
// Then try to save it.
CFileDialog fd(FALSE, _T("vegetset"), utf8ToTStr(_LastVegetSetName), OFN_OVERWRITEPROMPT, _T("VegetSetFiles (*.vegetset)|*.vegetset|All Files (*.*)|*.*||"), this) ;
CFileDialog fd(FALSE, _T("vegetset"), nlUtf8ToTStr(_LastVegetSetName), OFN_OVERWRITEPROMPT, _T("VegetSetFiles (*.vegetset)|*.vegetset|All Files (*.*)|*.*||"), this);
fd.m_ofn.lpstrTitle = _T("Save Vegetable Set");
if (fd.DoModal() == IDOK)
{
NLMISC::COFile f;
if( f.open(tStrToUtf8(fd.GetPathName())) )
if (f.open(NLMISC::tStrToUtf8(fd.GetPathName())))
{
try
{

View file

@ -33,7 +33,7 @@ void CDirectEditableRangeFloat::init(uint32 x, uint32 y, CWnd *pParent)
CRect rect;
rect.SetRect(x, y+10, x+dx, y+25);
_StaticText.Create(utf8ToTStr(_Title), WS_CHILD | WS_VISIBLE, rect, pParent);
_StaticText.Create(nlUtf8ToTStr(_Title), WS_CHILD | WS_VISIBLE, rect, pParent);
_StaticText.SetFont(pParent->GetFont());
}

View file

@ -154,7 +154,7 @@ BOOL CVegetableNoiseValueDlg::OnInitDialog()
// Set the name.
NoiseValueName.SetWindowText(utf8ToTStr(_TitleName));
NoiseValueName.SetWindowText(nlUtf8ToTStr(_TitleName));
// if previously setuped, setup now the noiseValue.
@ -264,5 +264,5 @@ void CVegetableNoiseValueDlg::applyScaleSlider(sint scrollValue)
_RandValue->updateValueFromReader();
// update marker text
StaticScaleMarker.SetWindowText(utf8ToTStr(NLMISC::toString("%d%%", (sint)(factor * 100))));
StaticScaleMarker.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%d%%", (sint)(factor * 100))));
}

View file

@ -63,7 +63,7 @@ BOOL CVegetableSelectDlg::OnInitDialog()
uint num= _VegetableDlg->getNumVegetables();
for(uint i=0; i<num; i++)
{
VegetableList.AddString(utf8ToTStr(_VegetableDlg->getVegetableName(i)));
VegetableList.AddString(nlUtf8ToTStr(_VegetableDlg->getVegetableName(i)));
}
return TRUE; // return TRUE unless you set the focus to a control

View file

@ -73,19 +73,19 @@ void CVegetableWindDlg::updateView()
// update Power.
a= _ObjViewer->getVegetableWindPower();
StaticPower.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a)));
StaticPower.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a)));
NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_POWER);
SliderPower.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_POWER));
// update BendStart.
a= _ObjViewer->getVegetableWindBendStart();
StaticBendStart.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a)));
StaticBendStart.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a)));
NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART);
SliderBendStart.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART));
// update Frequency.
a= _ObjViewer->getVegetableWindFrequency();
StaticFrequency.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a)));
StaticFrequency.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a)));
NLMISC::clamp(a, 0, NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY);
SliderFrequency.SetPos((sint)(a*NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE / NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY));
@ -129,20 +129,20 @@ void CVegetableWindDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBa
{
a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_POWER / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE;
_ObjViewer->setVegetableWindPower(a);
StaticPower.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a)));
StaticPower.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a)));
}
else if(sliderCtrl == &SliderBendStart)
{
a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE;
_ObjViewer->setVegetableWindBendStart(a);
StaticBendStart.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a)));
StaticBendStart.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a)));
}
else if(sliderCtrl == &SliderFrequency)
{
a= (float)nPos * NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY / NL_VEGETABLE_EDIT_WIND_SLIDER_RANGE;
_ObjViewer->setVegetableWindFrequency(a);
StaticFrequency.SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", a)));
StaticFrequency.SetWindowText(nlUtf8ToTStr(NLMISC::toString("%.2f", a)));
}
}
else

View file

@ -166,7 +166,7 @@ BOOL CWaterPoolEditor::OnInitDialog()
int CWaterPoolEditor::addPool(uint32 ID)
{
std::string poolId = NLMISC::toString("%d (%s)", ID, _Wpm->getPoolByID(ID).getName().c_str());
int index = m_PoolList.AddString(utf8ToTStr(poolId));
int index = m_PoolList.AddString(nlUtf8ToTStr(poolId));
nlassert(index != LB_ERR);
m_PoolList.SetItemData(index, ID);
return index;
@ -357,7 +357,7 @@ void CWaterPoolEditor::OnLoadPool()
{
NLMISC::CIXml iXml;
NLMISC::CIFile iF;
if (iF.open(tStrToUtf8(fileDlg.GetPathName())))
if (iF.open(NLMISC::tStrToUtf8(fileDlg.GetPathName())))
{
if (iXml.init (iF))
{
@ -369,17 +369,17 @@ void CWaterPoolEditor::OnLoadPool()
else
{
iF.close();
MessageBox (utf8ToTStr(NLMISC::toString("Unable to init xml stream from file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(NLMISC::toString("Unable to init xml stream from file: %s", NLMISC::tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
else
{
MessageBox (utf8ToTStr(NLMISC::toString("Unable to open file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(NLMISC::toString("Unable to open file: %s", NLMISC::tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
catch (const NLMISC::Exception& e)
{
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
}
@ -395,7 +395,7 @@ void CWaterPoolEditor::OnSavePool()
{
NLMISC::COXml oXml;
NLMISC::COFile oF;
if (oF.open(tStrToUtf8(fileDlg.GetPathName())))
if (oF.open(NLMISC::tStrToUtf8(fileDlg.GetPathName())))
{
if (oXml.init (&oF))
{
@ -406,17 +406,17 @@ void CWaterPoolEditor::OnSavePool()
else
{
oF.close();
MessageBox (utf8ToTStr(NLMISC::toString("Unable to init xml stream from file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(NLMISC::toString("Unable to init xml stream from file: %s", NLMISC::tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
else
{
MessageBox (utf8ToTStr(NLMISC::toString("Unable to open file: %s", tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(NLMISC::toString("Unable to open file: %s", NLMISC::tStrToUtf8(fileDlg.GetPathName()).c_str())), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}
catch (const NLMISC::Exception& e)
{
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
MessageBox(nlUtf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK | MB_ICONEXCLAMATION);
}
}

View file

@ -23,8 +23,13 @@
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#define _WIN32_WINNT 0x0501
#ifdef _WIN64
#define _WIN32_WINNT 0x0600
#else
#define _WIN32_WINNT 0x0500
#endif
#include <windows.h>

View file

@ -18,3 +18,5 @@
// and not in this file
#include "stdafx.h"
void nlmax_shared_stdafx_dummy() { }

View file

@ -72,3 +72,5 @@ NEL_3DSMAX_SHARED_API NLMISC::INelContext &GetSharedNelContext()
}
return NLMISC::INelContext::getInstance();
}
/* end of file */

View file

@ -25,3 +25,5 @@ class CPatchAllocator;
extern NEL_3DSMAX_SHARED_API CPatchAllocator& GetAllocator();
extern NEL_3DSMAX_SHARED_API NLMISC::INelContext &GetSharedNelContext();
/* end of file */

View file

@ -0,0 +1,75 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef NLMAX_STRING_COMMON_H
#define NLMAX_STRING_COMMON_H
#include <nel/misc/ucstring.h>
#if (MAX_VERSION_MAJOR < 15)
#define GET_OBJECT_NAME_CONST
#define NOTIFY_REF_PARAMS Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message
#define NOTIFY_REF_PROPAGATE , BOOL propagate
#define nl_p_end end
#else
#define GET_OBJECT_NAME_CONST const
#define NOTIFY_REF_PARAMS const Interval &changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message, BOOL propagate
#define nl_p_end p_end
#endif
static TSTR MaxTStrFromUtf8(const std::string &src)
{
TSTR dst;
#if (MAX_VERSION_MAJOR < 15)
ucstring uc;
uc.fromUtf8(src);
dst = (const mwchar_t *)uc.c_str();
#else
dst.FromUTF8(src.c_str());
#endif
return dst;
}
static std::string MaxTStrToUtf8(const TSTR& src)
{
#if (MAX_VERSION_MAJOR < 15)
#ifdef _UNICODE
ucstring uc(src.data());
return uc.toUtf8();
#else
WStr ws = src;
ucstring uc((const ucchar *)ws.data());
return uc.toUtf8();
#endif
#else
return src.ToUTF8().data();
#endif
}
static std::string MCharStrToUtf8(const MCHAR *src)
{
#ifdef _UNICODE
ucstring uc((const ucchar *)src);
return uc.toUtf8();
#else
ucstring uc((const ucchar *)WStr(src).data());
return uc.toUtf8();
#endif
}
#endif /* #ifndef NLMAX_STRING_COMMON_H */
/* end of file */

View file

@ -94,7 +94,7 @@ INT_PTR CALLBACK OptionsDialogCallback (
else
SendMessage( GetDlgItem(hwndDlg,IDC_SHADOW), BM_SETCHECK, BST_UNCHECKED, 0 );
SendMessage( GetDlgItem(hwndDlg,IDC_EDITEXPORTLIGHTING), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(theExportSceneStruct.sExportLighting));
SendMessage( GetDlgItem(hwndDlg,IDC_EDITEXPORTLIGHTING), WM_SETTEXT, 0, (LPARAM)MaxTStrFromUtf8(theExportSceneStruct.sExportLighting).data());
if( theExportSceneStruct.nExportLighting == 0 )
SendMessage( GetDlgItem(hwndDlg,IDC_RADIONORMALEXPORTLIGHTING), BM_SETCHECK, BST_CHECKED, 0 );
@ -102,7 +102,7 @@ INT_PTR CALLBACK OptionsDialogCallback (
if( theExportSceneStruct.nExportLighting == 1 )
SendMessage( GetDlgItem(hwndDlg,IDC_RADIORADIOSITYEXPORTLIGHTING), BM_SETCHECK, BST_CHECKED, 0 );
SendMessage( GetDlgItem(hwndDlg,IDC_EDITLUMELSIZE), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(toString(theExportSceneStruct.rLumelSize)));
SendMessage( GetDlgItem(hwndDlg,IDC_EDITLUMELSIZE), WM_SETTEXT, 0, (LPARAM)MaxTStrFromUtf8(toString(theExportSceneStruct.rLumelSize)).data());
if( theExportSceneStruct.nOverSampling == 1 )
SendMessage( GetDlgItem(hwndDlg,IDC_RADIOSS1), BM_SETCHECK, BST_CHECKED, 0 );
@ -132,8 +132,8 @@ INT_PTR CALLBACK OptionsDialogCallback (
else
SendMessage( GetDlgItem(hwndDlg,IDC_TEST_SURFACE_LIGHT), BM_SETCHECK, BST_UNCHECKED, 0 );
SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLSIZE), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(toString(theExportSceneStruct.SurfaceLightingCellSize)));
SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLDELTAZ), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(toString(theExportSceneStruct.SurfaceLightingDeltaZ)));
SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLSIZE), WM_SETTEXT, 0, (LPARAM)MaxTStrFromUtf8(toString(theExportSceneStruct.SurfaceLightingCellSize)).data());
SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLDELTAZ), WM_SETTEXT, 0, (LPARAM)MaxTStrFromUtf8(toString(theExportSceneStruct.SurfaceLightingDeltaZ)).data());
}
break;
@ -148,7 +148,7 @@ INT_PTR CALLBACK OptionsDialogCallback (
if( theCNelExport.SelectDir(hwndDlg, _T("LightMaps Directory"), sTemp ) )
{
theExportSceneStruct.sExportLighting = sTemp;
SendMessage( GetDlgItem(hwndDlg, IDC_EDITEXPORTLIGHTING), WM_SETTEXT, 0, (LPARAM)utf8ToTStr(theExportSceneStruct.sExportLighting) );
SendMessage(GetDlgItem(hwndDlg, IDC_EDITEXPORTLIGHTING), WM_SETTEXT, 0, (LPARAM)MaxTStrFromUtf8(theExportSceneStruct.sExportLighting).data());
}
}
break;
@ -180,7 +180,7 @@ INT_PTR CALLBACK OptionsDialogCallback (
TCHAR tmp[1024];
SendMessage( GetDlgItem(hwndDlg,IDC_EDITEXPORTLIGHTING), WM_GETTEXT, 1024, (LPARAM)tmp );
theExportSceneStruct.sExportLighting = tStrToUtf8(tmp);
theExportSceneStruct.sExportLighting = MCharStrToUtf8(tmp);
if( SendMessage( GetDlgItem(hwndDlg,IDC_RADIONORMALEXPORTLIGHTING), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
theExportSceneStruct.nExportLighting = 0;
@ -189,7 +189,7 @@ INT_PTR CALLBACK OptionsDialogCallback (
theExportSceneStruct.nExportLighting = 1;
SendMessage( GetDlgItem(hwndDlg,IDC_EDITLUMELSIZE), WM_GETTEXT, 1024, (LPARAM)tmp );
NLMISC::fromString(tStrToUtf8(tmp), theExportSceneStruct.rLumelSize);
NLMISC::fromString(MCharStrToUtf8(tmp), theExportSceneStruct.rLumelSize);
if( SendMessage( GetDlgItem(hwndDlg,IDC_RADIOSS1), BM_GETCHECK, 0, 0 ) == BST_CHECKED )
theExportSceneStruct.nOverSampling = 1;
@ -214,10 +214,10 @@ INT_PTR CALLBACK OptionsDialogCallback (
theExportSceneStruct.bTestSurfaceLighting= (SendMessage( GetDlgItem(hwndDlg,IDC_TEST_SURFACE_LIGHT), BM_GETCHECK, 0, 0 ) == BST_CHECKED);
SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLSIZE), WM_GETTEXT, 1024, (LPARAM)tmp );
NLMISC::fromString(tStrToUtf8(tmp), theExportSceneStruct.SurfaceLightingCellSize);
NLMISC::fromString(MCharStrToUtf8(tmp), theExportSceneStruct.SurfaceLightingCellSize);
SendMessage( GetDlgItem(hwndDlg,IDC_EDITCELLDELTAZ), WM_GETTEXT, 1024, (LPARAM)tmp );
NLMISC::fromString(tStrToUtf8(tmp), theExportSceneStruct.SurfaceLightingDeltaZ);
NLMISC::fromString(MCharStrToUtf8(tmp), theExportSceneStruct.SurfaceLightingDeltaZ);
// End the dialog
EndDialog(hwndDlg, TRUE);
@ -354,7 +354,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
if (RPO::isZone (*pNode, time))
{
// Save path
std::string sSavePath = tStrToUtf8(pNode->GetName());
std::string sSavePath = MCharStrToUtf8(pNode->GetName());
// Choose a file to export
if (!CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_DONTEXPORT, 0))
@ -364,15 +364,15 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
if (!theCNelExport.exportZone (sSavePath, *pNode, time))
{
// Error message
std::string sErrorMsg = toString("Error exporting the zone %s in the file\n%s", tStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str());
MessageBox (hWnd, utf8ToTStr(sErrorMsg), L"NeL export", MB_OK|MB_ICONEXCLAMATION);
std::string sErrorMsg = toString("Error exporting the zone %s in the file\n%s", MCharStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str());
MessageBox (hWnd, MaxTStrFromUtf8(sErrorMsg), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION);
}
}
}
else if (CExportNel::isVegetable (*pNode, time))
{
// Save path
std::string sSavePath = tStrToUtf8(pNode->GetName());
std::string sSavePath = MCharStrToUtf8(pNode->GetName());
// Choose a file to export
if (!CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_DONTEXPORT, 0))
@ -382,8 +382,8 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
if (!theCNelExport.exportVegetable (sSavePath.c_str(), *pNode, time))
{
// Error message
std::string sErrorMsg = toString("Error exporting the vegetable %s in the file\n%s", tStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str());
MessageBox (hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION);
std::string sErrorMsg = toString("Error exporting the vegetable %s in the file\n%s", MCharStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str());
MessageBox (hWnd, MaxTStrFromUtf8(sErrorMsg), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION);
}
}
}
@ -391,7 +391,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
else if (CExportNel::isLodCharacter (*pNode, time))
{
// Save path
std::string sSavePath = tStrToUtf8(pNode->GetName());
std::string sSavePath = MCharStrToUtf8(pNode->GetName());
// Choose a file to export
if (!CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_DONTEXPORT, 0))
@ -401,8 +401,8 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
if (!theCNelExport.exportLodCharacter (sSavePath, *pNode, time))
{
// Error message
std::string sErrorMsg = toString("Error exporting the lod character %s in the file\n%s", tStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str());
MessageBox (hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION);
std::string sErrorMsg = toString("Error exporting the lod character %s in the file\n%s", MCharStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str());
MessageBox (hWnd, MaxTStrFromUtf8(sErrorMsg).data(), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION);
}
}
}
@ -410,7 +410,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
else if (CExportNel::isMesh (*pNode, time))
{
// Save path
std::string sSavePath = tStrToUtf8(pNode->GetName());
std::string sSavePath = MCharStrToUtf8(pNode->GetName());
// Choose a file to export
if (!CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_DONTEXPORT, 0))
@ -424,8 +424,8 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
if (!theCNelExport.exportMesh (sSavePath, *pNode, time))
{
// Error message
std::string sErrorMsg = toString("Error exporting the mesh %s in the file\n%s", tStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str());
MessageBox (hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION);
std::string sErrorMsg = toString("Error exporting the mesh %s in the file\n%s", MCharStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str());
MessageBox (hWnd, MaxTStrFromUtf8(sErrorMsg).data(), _T("NeL export"), MB_OK|MB_ICONEXCLAMATION);
}
// Delete the skeleton pointer
if (pSkinShape)
@ -463,7 +463,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
// Name of the node
// Save path
std::string sSavePath = tStrToUtf8((*vectNode.begin())->GetName());
std::string sSavePath = MCharStrToUtf8((*vectNode.begin())->GetName());
// Choose a file to export
if (theCNelExport.SelectFileForSave (hWnd, _T("Save animations..."), (LOWORD(wParam)==ID_SAVE_MODEL_ANIM)?animModelFilter:animModelFilter,
@ -473,8 +473,8 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
if (!theCNelExport.exportAnim (sSavePath, vectNode, time, LOWORD(wParam)==ID_SAVE_SCENE_ANIM))
{
// Error message
std::string sErrorMsg = toString("Error exporting animation %s in the file\n%s", tStrToUtf8((*vectNode.begin())->GetName()).c_str(), sSavePath.c_str());
MessageBox(hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION);
std::string sErrorMsg = toString("Error exporting animation %s in the file\n%s", MCharStrToUtf8((*vectNode.begin())->GetName()).c_str(), sSavePath.c_str());
MessageBox(hWnd, MaxTStrFromUtf8(sErrorMsg).data(), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION);
}
}
}
@ -566,7 +566,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
nlassert (vectNode.size()!=0);
// Save path
std::string sSavePath = tStrToUtf8((*vectNode.begin())->GetName());
std::string sSavePath = MCharStrToUtf8((*vectNode.begin())->GetName());
if (theCNelExport.SelectFileForSave (hWnd, _T("Save SWT..."), SWTFilter, sSavePath))
{
@ -574,8 +574,8 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
if (!theCNelExport.exportSWT (sSavePath, vectNode))
{
// Error message
std::string sErrorMsg = toString("Error exporting SWT %s in the file\n%s", tStrToUtf8((*vectNode.begin())->GetName()).c_str(), sSavePath.c_str());
MessageBox(hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION);
std::string sErrorMsg = toString("Error exporting SWT %s in the file\n%s", MCharStrToUtf8((*vectNode.begin())->GetName()).c_str(), sSavePath.c_str());
MessageBox(hWnd, MaxTStrFromUtf8(sErrorMsg).data(), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION);
}
}
}
@ -588,7 +588,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
nlassert (theIP);
theCNelExport.init (false, true, theIP, true);
std::string sConfigFileName = tStrToUtf8(theCNelExport._Ip->GetDir(APP_PLUGCFG_DIR)) + "\\NelExportScene.cfg";
std::string sConfigFileName = MCharStrToUtf8(theCNelExport._Ip->GetDir(APP_PLUGCFG_DIR)) + "\\NelExportScene.cfg";
// Do a modal dialog box to choose the scene export options
if( DialogBox( hInstance,
@ -647,7 +647,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
theCNelExport.getSelectedNode (vectNode);
nlassert (vectNode.size()!=0);
std::string sSavePath = tStrToUtf8((*vectNode.begin())->GetName());
std::string sSavePath = MCharStrToUtf8((*vectNode.begin())->GetName());
if (theCNelExport.SelectFileForSave (hWnd, _T("Save Instance group"), InstanceGroupFilter, sSavePath))
{
@ -656,7 +656,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
{
// Error message
std::string sErrorMsg = toString("Error exporting instance group %s", sSavePath.c_str());
MessageBox(hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION);
MessageBox(hWnd, MaxTStrFromUtf8(sErrorMsg).data(), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION);
}
}
}
@ -690,8 +690,8 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
if (!theCNelExport.exportSkeleton (sSavePath, pNode, theCNelExport._Ip->GetTime()))
{
// Error message
std::string sErrorMsg = toString("Error exporting skeleton %s in the file\n%s", tStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str());
MessageBox(hWnd, utf8ToTStr(sErrorMsg), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION);
std::string sErrorMsg = toString("Error exporting skeleton %s in the file\n%s", MCharStrToUtf8(pNode->GetName()).c_str(), sSavePath.c_str());
MessageBox(hWnd, MaxTStrFromUtf8(sErrorMsg).data(), _T("NeL export"), MB_OK | MB_ICONEXCLAMATION);
}
}
}
@ -736,7 +736,7 @@ static INT_PTR CALLBACK CNelExportDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LP
}
catch(const std::exception &e)
{
::MessageBox(hWnd, utf8ToTStr(e.what()), _T("Error"), MB_OK | MB_ICONEXCLAMATION);
::MessageBoxA(hWnd, e.what(), "Error", MB_OK | MB_ICONEXCLAMATION);
}
}
}
@ -820,7 +820,7 @@ void CNelExport::getSelectedNode (std::vector<INode*>& vectNode)
void CNelExport::initOptions()
{
// Initialization of theExportSceneStruct
std::string sConfigFileName = tStrToUtf8(theCNelExport._Ip->GetDir(APP_PLUGCFG_DIR)) + "\\NelExportScene.cfg";
std::string sConfigFileName = MCharStrToUtf8(theCNelExport._Ip->GetDir(APP_PLUGCFG_DIR)) + "\\NelExportScene.cfg";
// MessageBox (hWnd, sConfigFileName, "sConfigFileName", MB_OK|MB_ICONEXCLAMATION);
if( CFile::fileExists(sConfigFileName) )

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