ryzomcore/v0.12.0

hg/compatibility ryzomcore/v0.12.0
kaetemi 10 years ago
commit 24b6e3923d

@ -2,7 +2,7 @@
# #
# Ryzom Core # Ryzom Core
# Authors: Nevrax and the Ryzom Core Community # Authors: Nevrax and the Ryzom Core Community
# Version: 0.11.3 # Version: 0.12.0
# #
# Notes: # Notes:
# * Changing install location: add -DCMAKE_INSTALL_PREFIX:PATH=/my/new/path # * Changing install location: add -DCMAKE_INSTALL_PREFIX:PATH=/my/new/path
@ -47,8 +47,8 @@ CHECK_OUT_OF_SOURCE()
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(RyzomCore CXX C) PROJECT(RyzomCore CXX C)
SET(NL_VERSION_MAJOR 0) SET(NL_VERSION_MAJOR 0)
SET(NL_VERSION_MINOR 11) SET(NL_VERSION_MINOR 12)
SET(NL_VERSION_PATCH 3) SET(NL_VERSION_PATCH 0)
SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}") SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}")
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@ -112,16 +112,20 @@ IF(WITH_STATIC_LIBXML2)
SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC) SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC)
ENDIF(WITH_STATIC_LIBXML2) ENDIF(WITH_STATIC_LIBXML2)
IF(WITH_LIBXML2_ICONV)
FIND_PACKAGE(Iconv REQUIRED)
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES})
ENDIF(WITH_LIBXML2_ICONV)
IF(WITH_STATIC) IF(WITH_STATIC)
# libxml2 could need winsock2 library # libxml2 could need winsock2 library
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB}) SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB})
# on Mac OS X libxml2 requires iconv and liblzma # on Mac OS X libxml2 requires iconv and liblzma
IF(APPLE) IF(APPLE)
FIND_PACKAGE(Iconv REQUIRED)
FIND_PACKAGE(LibLZMA REQUIRED) FIND_PACKAGE(LibLZMA REQUIRED)
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES} ${LIBLZMA_LIBRARIES}) SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${LIBLZMA_LIBRARIES})
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
ENDIF(APPLE) ENDIF(APPLE)
ENDIF(WITH_STATIC) ENDIF(WITH_STATIC)
@ -152,9 +156,11 @@ IF(WITH_NEL)
FIND_PACKAGE(Luabind REQUIRED) FIND_PACKAGE(Luabind REQUIRED)
FIND_PACKAGE(CURL REQUIRED) FIND_PACKAGE(CURL REQUIRED)
IF(WIN32 OR CURL_LIBRARIES MATCHES "\\.a") IF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
SET(CURL_STATIC ON) SET(CURL_STATIC ON)
ENDIF(WIN32 OR CURL_LIBRARIES MATCHES "\\.a") ELSE((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
SET(CURL_STATIC OFF)
ENDIF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
IF(CURL_STATIC) IF(CURL_STATIC)
SET(CURL_DEFINITIONS -DCURL_STATICLIB) SET(CURL_DEFINITIONS -DCURL_STATICLIB)

@ -1,4 +1,4 @@
# - Try to find Iconv on Mac OS X # - Try to find Iconv
# Once done this will define # Once done this will define
# #
# ICONV_FOUND - system has Iconv # ICONV_FOUND - system has Iconv
@ -6,8 +6,6 @@
# ICONV_LIBRARIES - Link these to use Iconv # ICONV_LIBRARIES - Link these to use Iconv
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const # ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
# #
IF(APPLE)
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
include(CheckCSourceCompiles) include(CheckCSourceCompiles)
@ -16,25 +14,9 @@ IF(APPLE)
SET(ICONV_FIND_QUIETLY TRUE) SET(ICONV_FIND_QUIETLY TRUE)
ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
IF(APPLE) FIND_PATH(ICONV_INCLUDE_DIR iconv.h HINTS /sw/include/ PATHS /opt/local)
FIND_PATH(ICONV_INCLUDE_DIR iconv.h
PATHS
/opt/local/include/
NO_CMAKE_SYSTEM_PATH
)
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c
PATHS
/opt/local/lib/
NO_CMAKE_SYSTEM_PATH
)
ENDIF(APPLE)
FIND_PATH(ICONV_INCLUDE_DIR iconv.h PATHS /opt/local/include /sw/include)
string(REGEX REPLACE "(.*)/include/?" "\\1" ICONV_INCLUDE_BASE_DIR "${ICONV_INCLUDE_DIR}")
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c HINTS "${ICONV_INCLUDE_BASE_DIR}/lib" PATHS /opt/local/lib) FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c PATHS /opt/local)
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
SET(ICONV_FOUND TRUE) SET(ICONV_FOUND TRUE)
@ -80,4 +62,3 @@ IF(APPLE)
ICONV_LIBRARIES ICONV_LIBRARIES
ICONV_SECOND_ARGUMENT_IS_CONST ICONV_SECOND_ARGUMENT_IS_CONST
) )
ENDIF(APPLE)

@ -38,7 +38,7 @@ ELSEIF(WIN32)
ENDIF(UNIX) ENDIF(UNIX)
FIND_LIBRARY(LIBOVR_LIBRARY FIND_LIBRARY(LIBOVR_LIBRARY
NAMES ovr NAMES ovr libovr
PATHS PATHS
$ENV{LIBOVR_DIR}/${LIBOVR_LIBRARY_BUILD_PATH} $ENV{LIBOVR_DIR}/${LIBOVR_LIBRARY_BUILD_PATH}
/usr/local/lib /usr/local/lib

@ -69,14 +69,48 @@ FIND_PATH(LUABIND_INCLUDE_DIR
/opt/include /opt/include
) )
SET(LIBRARY_NAME_RELEASE luabind libluabind) SET(LIBRARY_NAME_RELEASE)
SET(LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd) SET(LIBRARY_NAME_DEBUG)
IF(WITH_LUA52)
IF(WITH_STLPORT)
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua52)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua52d)
ENDIF(WITH_STLPORT)
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua52)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua52d)
ENDIF()
IF(WITH_LUA51)
IF(WITH_STLPORT)
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua51)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua51d)
ENDIF(WITH_STLPORT)
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua51)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua51d)
ENDIF()
IF(WITH_LUA50)
IF(WITH_STLPORT) IF(WITH_STLPORT)
SET(LIBRARY_NAME_RELEASE luabind_stlport ${LIBRARY_NAME_RELEASE}) LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua50)
SET(LIBRARY_NAME_DEBUG luabind_stlportd ${LIBRARY_NAME_DEBUG}) LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua50d)
ENDIF(WITH_STLPORT) ENDIF(WITH_STLPORT)
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua50)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua50d)
ENDIF()
IF(WITH_STLPORT)
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlportd)
ENDIF(WITH_STLPORT)
# generic libraries names
LIST(APPEND LIBRARY_NAME_RELEASE luabind libluabind)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd)
FIND_LIBRARY(LUABIND_LIBRARY_RELEASE FIND_LIBRARY(LUABIND_LIBRARY_RELEASE
NAMES ${LIBRARY_NAME_RELEASE} NAMES ${LIBRARY_NAME_RELEASE}
PATHS PATHS

@ -62,7 +62,7 @@ IF(MSVC12)
IF(NOT MSVC12_REDIST_DIR) IF(NOT MSVC12_REDIST_DIR)
# If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist # If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC12_REDIST_DIR "${EXTERNAL_PATH}/redist") SET(MSVC12_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC11_REDIST_DIR) ENDIF(NOT MSVC12_REDIST_DIR)
ELSEIF(MSVC11) ELSEIF(MSVC11)
DETECT_VC_VERSION("11.0") DETECT_VC_VERSION("11.0")
SET(MSVC_TOOLSET "110") SET(MSVC_TOOLSET "110")

@ -255,6 +255,16 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
ELSE(WITH_STATIC) ELSE(WITH_STATIC)
OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF) OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF)
ENDIF(WITH_STATIC) ENDIF(WITH_STATIC)
IF (WITH_STATIC)
OPTION(WITH_STATIC_CURL "With static curl" ON )
ELSE(WITH_STATIC)
OPTION(WITH_STATIC_CURL "With static curl" OFF)
ENDIF(WITH_STATIC)
IF(APPLE)
OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" ON )
ELSE(APPLE)
OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" OFF)
ENDIF(APPLE)
OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF) OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF)
IF(WIN32) IF(WIN32)
OPTION(WITH_EXTERNAL "With provided external." ON ) OPTION(WITH_EXTERNAL "With provided external." ON )
@ -363,6 +373,7 @@ MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
### ###
OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON ) OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON )
OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF) OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF)
OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF)
ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS) MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
@ -557,9 +568,15 @@ MACRO(NL_SETUP_BUILD)
# Ignore default include paths # Ignore default include paths
ADD_PLATFORM_FLAGS("/X") ADD_PLATFORM_FLAGS("/X")
IF(MSVC11) IF(MSVC12)
ADD_PLATFORM_FLAGS("/Gy- /MP") ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2010, but custom optimizations don't exist # /Ox is working with VC++ 2013, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC11)
ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2012, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again # without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
@ -581,9 +598,9 @@ MACRO(NL_SETUP_BUILD)
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again # without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}") SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}")
ELSE(MSVC11) ELSE(MSVC12)
MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
ENDIF(MSVC11) ENDIF(MSVC12)
ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250") ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250")

@ -83,4 +83,3 @@ IF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN)
ENDIF(WITH_NEL_TOOLS) ENDIF(WITH_NEL_TOOLS)
ADD_SUBDIRECTORY(tools) ADD_SUBDIRECTORY(tools)
ENDIF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) ENDIF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN)

@ -1422,7 +1422,6 @@ protected:
private: private:
bool _StaticMemoryToVRAM; bool _StaticMemoryToVRAM;
}; };
// -------------------------------------------------- // --------------------------------------------------

@ -54,11 +54,13 @@ public:
/** generate and return a bitmap /** generate and return a bitmap
* \param c the unicode char * \param c the unicode char
* \param size size of the generated font in ??? format * \param size size of the generated font in ??? format
* \param embolden set embolden style (bold)
* \param oblique set oblique style (slanted, italic)
* \param width width of the generated bitmap, this value is set by this function * \param width width of the generated bitmap, this value is set by this function
* \param height height of the generated bitmap, this value is set by this function * \param height height of the generated bitmap, this value is set by this function
* \param pitch pitch of the generated bitmap (+ or - the number of bytes per row), this value is set by this function * \param pitch pitch of the generated bitmap (+ or - the number of bytes per row), this value is set by this function
*/ */
uint8 *getBitmap (ucchar c, uint32 size, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex); uint8 *getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex);
/** returns the width and height of a character using a specific size and /** returns the width and height of a character using a specific size and
* *

@ -102,6 +102,8 @@ public:
* \param fontGen font generator * \param fontGen font generator
* \param color primitive blocks color * \param color primitive blocks color
* \param fontSize font size * \param fontSize font size
* \param embolden font style bold
* \param oblique font style slanted (italic)
* \param desc display descriptor (screen size, font ratio) * \param desc display descriptor (screen size, font ratio)
* \param output computed string * \param output computed string
* \param keep800x600Ratio true if you want that CFontManager look at Driver window size, and resize fontSize so it keeps same size... * \param keep800x600Ratio true if you want that CFontManager look at Driver window size, and resize fontSize so it keeps same size...
@ -110,6 +112,8 @@ public:
CFontGenerator *fontGen, CFontGenerator *fontGen,
const NLMISC::CRGBA &color, const NLMISC::CRGBA &color,
uint32 fontSize, uint32 fontSize,
bool embolden,
bool oblique,
IDriver *driver, IDriver *driver,
CComputedString& output, CComputedString& output,
bool keep800x600Ratio= true); bool keep800x600Ratio= true);
@ -121,6 +125,8 @@ public:
CFontGenerator *fontGen, CFontGenerator *fontGen,
const NLMISC::CRGBA &color, const NLMISC::CRGBA &color,
uint32 fontSize, uint32 fontSize,
bool embolden,
bool oblique,
IDriver *driver, IDriver *driver,
CComputedString &output, CComputedString &output,
bool keep800x600Ratio= true); bool keep800x600Ratio= true);
@ -132,6 +138,8 @@ public:
CFontGenerator *fontGen, CFontGenerator *fontGen,
const NLMISC::CRGBA &color, const NLMISC::CRGBA &color,
uint32 fontSize, uint32 fontSize,
bool embolden,
bool oblique,
IDriver *driver, IDriver *driver,
CComputedString &output, CComputedString &output,
bool keep800x600Ratio= true); bool keep800x600Ratio= true);

@ -74,6 +74,10 @@ public:
void setFontSize (uint32 fontSize) { _FontSize = fontSize; } void setFontSize (uint32 fontSize) { _FontSize = fontSize; }
void setEmbolden (bool b) { _Embolden = b; }
void setOblique (bool b) { _Oblique = b; }
void setHotSpot (CComputedString::THotSpot hotSpot) { _HotSpot = hotSpot; } void setHotSpot (CComputedString::THotSpot hotSpot) { _HotSpot = hotSpot; }
void setScaleX (float scaleX) { _ScaleX = scaleX; } void setScaleX (float scaleX) { _ScaleX = scaleX; }
@ -101,6 +105,10 @@ public:
uint32 getFontSize () const { return _FontSize; } uint32 getFontSize () const { return _FontSize; }
bool getEmbolden () const { return _Embolden; }
bool getOblique () const { return _Oblique; }
CComputedString::THotSpot getHotSpot() const { return _HotSpot; } CComputedString::THotSpot getHotSpot() const { return _HotSpot; }
float getScaleX() const { return _ScaleX; } float getScaleX() const { return _ScaleX; }
@ -240,7 +248,7 @@ public:
nlassert(_FontGen); nlassert(_FontGen);
// compute the string just one time // compute the string just one time
_FontManager->computeString (ucstr, _FontGen, _Color, _FontSize, _Driver, _TempString, _Keep800x600Ratio); _FontManager->computeString (ucstr, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, _TempString, _Keep800x600Ratio);
// draw shaded // draw shaded
if (_Shaded) if (_Shaded)
@ -279,7 +287,7 @@ public:
// compute the string just one time // compute the string just one time
char *str; char *str;
NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize); NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize);
_FontManager->computeString (str, _FontGen, _Color, _FontSize, _Driver, _TempString, _Keep800x600Ratio); _FontManager->computeString (str, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, _TempString, _Keep800x600Ratio);
// draw shaded // draw shaded
if (_Shaded) if (_Shaded)
@ -334,7 +342,7 @@ public:
*/ */
void computeString (const std::string& s, CComputedString& output) void computeString (const std::string& s, CComputedString& output)
{ {
_FontManager->computeString (s, _FontGen, _Color, _FontSize, _Driver, output, _Keep800x600Ratio); _FontManager->computeString (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
} }
/** /**
@ -345,12 +353,12 @@ public:
*/ */
void computeString (const ucstring& s, CComputedString& output) void computeString (const ucstring& s, CComputedString& output)
{ {
_FontManager->computeString (s, _FontGen, _Color, _FontSize, _Driver, output, _Keep800x600Ratio); _FontManager->computeString (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
} }
void computeStringInfo (const ucstring& s, CComputedString& output) void computeStringInfo (const ucstring& s, CComputedString& output)
{ {
_FontManager->computeStringInfo (s, _FontGen, _Color, _FontSize, _Driver, output, _Keep800x600Ratio); _FontManager->computeStringInfo (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
} }
/// Debug : write to the disk the texture cache /// Debug : write to the disk the texture cache
@ -381,6 +389,10 @@ private:
/// Font size; /// Font size;
uint32 _FontSize; uint32 _FontSize;
bool _Embolden;
bool _Oblique;
/// Current text color /// Current text color
NLMISC::CRGBA _Color; NLMISC::CRGBA _Color;

@ -66,6 +66,10 @@ public:
void setColor(NLMISC::CRGBA color); void setColor(NLMISC::CRGBA color);
void setFontSize(uint32 fontSize); void setFontSize(uint32 fontSize);
uint32 getFontSize() const; uint32 getFontSize() const;
void setEmbolden(bool b);
bool getEmbolden() const;
void setOblique(bool b);
bool getOblique() const;
void setHotSpot(THotSpot hotSpot); void setHotSpot(THotSpot hotSpot);
THotSpot getHotSpot() const; THotSpot getHotSpot() const;
void setScaleX(float scaleX); void setScaleX(float scaleX);

@ -43,6 +43,8 @@ public:
ucchar Char; ucchar Char;
CFontGenerator *FontGenerator; CFontGenerator *FontGenerator;
sint Size; sint Size;
bool Embolden;
bool Oblique;
// The less recently used infos // The less recently used infos
@ -66,6 +68,8 @@ public:
ucchar Char; ucchar Char;
CFontGenerator *FontGenerator; CFontGenerator *FontGenerator;
sint Size; sint Size;
bool Embolden;
bool Oblique;
uint32 getVal(); uint32 getVal();
//bool operator < (const SLetterKey&k) const; //bool operator < (const SLetterKey&k) const;

@ -137,6 +137,24 @@ public:
* \return the font size * \return the font size
*/ */
virtual uint32 getFontSize () const = 0; virtual uint32 getFontSize () const = 0;
/**
* set embolden (bold) state
* \param embolden the embbolden state
*/
virtual void setEmbolden (bool b) = 0;
/**
* \return the embolden state
*/
virtual bool getEmbolden () const = 0;
/**
* set oblique (italic) state
* \param oblique the oblique state
*/
virtual void setOblique (bool b) = 0;
/**
* \return the oblique state
*/
virtual bool getOblique () const = 0;
/** /**
* set the hot spot * set the hot spot
* \param fonSize the font size * \param fonSize the font size

@ -50,6 +50,8 @@ namespace NLGUI
// see interface.txt for meaning of auto // see interface.txt for meaning of auto
_ToolTipParentPosRef= Hotspot_TTAuto; _ToolTipParentPosRef= Hotspot_TTAuto;
_ToolTipPosRef= Hotspot_TTAuto; _ToolTipPosRef= Hotspot_TTAuto;
_EventX = 0;
_EventY = 0;
resizer = false; resizer = false;
} }
@ -70,6 +72,9 @@ namespace NLGUI
bool handleEvent (const NLGUI::CEventDescriptor &event); bool handleEvent (const NLGUI::CEventDescriptor &event);
sint32 getEventX() { return _EventX; }
sint32 getEventY() { return _EventY; }
virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; } virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; }
/// Debug /// Debug
@ -181,6 +186,9 @@ namespace NLGUI
static std::map< std::string, std::map< std::string, std::string > > AHCache; static std::map< std::string, std::map< std::string, std::string > > AHCache;
bool resizer; bool resizer;
sint32 _EventX;
sint32 _EventY;
}; };
} }

@ -60,7 +60,7 @@ namespace NLGUI
void setText(uint i, const ucstring &text); void setText(uint i, const ucstring &text);
void insertText(uint i, const ucstring &text); void insertText(uint i, const ucstring &text);
const ucstring &getText(uint i) const; const ucstring &getText(uint i) const;
const uint &getTextId(uint i) const; uint getTextId(uint i) const;
uint getTextPos(uint nId) const; uint getTextPos(uint nId) const;
const ucstring &getTexture(uint i) const; const ucstring &getTexture(uint i) const;
void removeText(uint nPos); void removeText(uint nPos);

@ -17,7 +17,6 @@
#ifndef CL_GROUP_HTML_H #ifndef CL_GROUP_HTML_H
#define CL_GROUP_HTML_H #define CL_GROUP_HTML_H
#define CURL_STATICLIB 1
#include <curl/curl.h> #include <curl/curl.h>
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
@ -107,7 +106,7 @@ namespace NLGUI
void refresh(); void refresh();
// submit form // submit form
void submitForm (uint formId, const char *submitButtonName); void submitForm (uint formId, const char *submitButtonType, const char *submitButtonName, const char *submitButtonValue, sint32 x, sint32 y);
// Browse error // Browse error
void browseError (const char *msg); void browseError (const char *msg);
@ -328,7 +327,11 @@ namespace NLGUI
bool _BrowseNextTime; bool _BrowseNextTime;
bool _PostNextTime; bool _PostNextTime;
uint _PostFormId; uint _PostFormId;
std::string _PostFormSubmitType;
std::string _PostFormSubmitButton; std::string _PostFormSubmitButton;
std::string _PostFormSubmitValue;
sint32 _PostFormSubmitX;
sint32 _PostFormSubmitY;
// Browsing.. // Browsing..
bool _Browsing; bool _Browsing;
@ -422,6 +425,38 @@ namespace NLGUI
return _FontSize.back(); return _FontSize.back();
} }
std::vector<uint> _FontWeight;
inline uint getFontWeight() const
{
if (_FontWeight.empty())
return 400;
return _FontWeight.back();
}
std::vector<bool> _FontOblique;
inline uint getFontOblique() const
{
if (_FontOblique.empty())
return false;
return _FontOblique.back();
}
std::vector<bool> _FontUnderlined;
inline uint getFontUnderlined() const
{
if (_FontUnderlined.empty())
return false;
return _FontUnderlined.back();
}
std::vector<bool> _FontStrikeThrough;
inline uint getFontStrikeThrough() const
{
if (_FontStrikeThrough.empty())
return false;
return _FontStrikeThrough.back();
}
// Current link // Current link
std::vector<std::string> _Link; std::vector<std::string> _Link;
inline const char *getLink() const inline const char *getLink() const
@ -541,6 +576,26 @@ namespace NLGUI
}; };
std::vector<CCellParams> _CellParams; std::vector<CCellParams> _CellParams;
class CStyleParams
{
public:
CStyleParams () : TextColor(255,255,255,255)
{
FontSize=10;
FontWeight=400;
FontOblique=false;
Underlined=false;
StrikeThrough=false;
}
uint FontSize;
uint FontWeight;
bool FontOblique;
NLMISC::CRGBA TextColor;
bool Underlined;
bool StrikeThrough;
};
// Indentation // Indentation
uint _Indent; uint _Indent;
@ -610,8 +665,10 @@ namespace NLGUI
typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap; typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap;
static TGroupHtmlByUIDMap _GroupHtmlByUID; static TGroupHtmlByUIDMap _GroupHtmlByUID;
private: // read style attribute
void getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit = true);
private:
// decode all HTML entities // decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str); static ucstring decodeHTMLEntities(const ucstring &str);

@ -218,6 +218,13 @@ namespace NLGUI
HTML_ATTR(DIV,STYLE), HTML_ATTR(DIV,STYLE),
}; };
enum
{
HTML_ATTR(SPAN,CLASS) = 0,
HTML_ATTR(SPAN,ID),
HTML_ATTR(SPAN,STYLE),
};
#undef HTML_ATTR #undef HTML_ATTR

@ -285,8 +285,7 @@ namespace NLGUI
class CLuaHashMapTraits class CLuaHashMapTraits
{ {
public: public:
static const size_t bucket_size = 4; enum { bucket_size = 4, min_buckets = 8, };
static const size_t min_buckets = 8;
CLuaHashMapTraits() CLuaHashMapTraits()
{} {}

@ -81,6 +81,8 @@ namespace NLGUI
void setText (const ucstring &text); void setText (const ucstring &text);
void setFontSize (sint nFontSize); void setFontSize (sint nFontSize);
void setEmbolden (bool nEmbolden);
void setOblique (bool nOblique);
void setColor (const NLMISC::CRGBA &color); void setColor (const NLMISC::CRGBA &color);
void setShadow (bool bShadow); void setShadow (bool bShadow);
void setShadowOutline (bool bShadowOutline); void setShadowOutline (bool bShadowOutline);
@ -101,6 +103,8 @@ namespace NLGUI
ucstring getText() const { return _Text; } ucstring getText() const { return _Text; }
sint getFontSize() const; sint getFontSize() const;
bool getEmbolden() { return _Embolden; }
bool getOblique() { return _Oblique; }
NLMISC::CRGBA getColor() { return _Color; } NLMISC::CRGBA getColor() { return _Color; }
bool getShadow() { return _Shadow; } bool getShadow() { return _Shadow; }
bool getShadowOutline() { return _ShadowOutline; } bool getShadowOutline() { return _ShadowOutline; }
@ -125,6 +129,8 @@ namespace NLGUI
uint getLastLineW () const; uint getLastLineW () const;
void setUnderlined (bool underlined) { _Underlined = underlined; } void setUnderlined (bool underlined) { _Underlined = underlined; }
bool getUnderlined () const { return _Underlined; } bool getUnderlined () const { return _Underlined; }
void setStrikeThrough (bool linethrough) { _StrikeThrough = linethrough; }
bool getStrikeThrough () const { return _StrikeThrough; }
// true if the viewText is a single line clamped. // true if the viewText is a single line clamped.
bool isSingleLineTextClamped() const {return _SingleLineTextClamped;} bool isSingleLineTextClamped() const {return _SingleLineTextClamped;}
@ -220,6 +226,8 @@ namespace NLGUI
NL3D::UTextContext::CStringInfo _Info; NL3D::UTextContext::CStringInfo _Info;
/// the font size /// the font size
sint _FontSize; sint _FontSize;
bool _Embolden;
bool _Oblique;
// width of the font in pixel. Just a Hint for tabing format (computed with '_') // width of the font in pixel. Just a Hint for tabing format (computed with '_')
uint _FontWidth; uint _FontWidth;
// height of the font in pixel. // height of the font in pixel.
@ -374,6 +382,7 @@ namespace NLGUI
bool _TextSelection : 1; bool _TextSelection : 1;
bool _InvalidTextContext : 1; bool _InvalidTextContext : 1;
bool _Underlined : 1; bool _Underlined : 1;
bool _StrikeThrough : 1;
bool _ContinuousUpdate : 1; bool _ContinuousUpdate : 1;
bool _Setuped : 1; bool _Setuped : 1;

@ -88,6 +88,8 @@ namespace NLMISC
virtual void setNoAssert(bool noAssert) =0; virtual void setNoAssert(bool noAssert) =0;
virtual bool getAlreadyCreateSharedAmongThreads() =0; virtual bool getAlreadyCreateSharedAmongThreads() =0;
virtual void setAlreadyCreateSharedAmongThreads(bool b) =0; virtual void setAlreadyCreateSharedAmongThreads(bool b) =0;
virtual bool isWindowedApplication() = 0;
virtual void setWindowedApplication(bool b = true) = 0;
//@} //@}
protected: protected:
/// Called by derived class to finalize initialisation of context /// Called by derived class to finalize initialisation of context
@ -131,6 +133,8 @@ namespace NLMISC
virtual void setNoAssert(bool noAssert); virtual void setNoAssert(bool noAssert);
virtual bool getAlreadyCreateSharedAmongThreads(); virtual bool getAlreadyCreateSharedAmongThreads();
virtual void setAlreadyCreateSharedAmongThreads(bool b); virtual void setAlreadyCreateSharedAmongThreads(bool b);
virtual bool isWindowedApplication();
virtual void setWindowedApplication(bool b);
private: private:
/// Singleton registry /// Singleton registry
@ -147,6 +151,7 @@ namespace NLMISC
bool DebugNeedAssert; bool DebugNeedAssert;
bool NoAssert; bool NoAssert;
bool AlreadyCreateSharedAmongThreads; bool AlreadyCreateSharedAmongThreads;
bool WindowedApplication;
}; };
/** This class implements the context interface for the a library module. /** This class implements the context interface for the a library module.
@ -183,6 +188,8 @@ namespace NLMISC
virtual void setNoAssert(bool noAssert); virtual void setNoAssert(bool noAssert);
virtual bool getAlreadyCreateSharedAmongThreads(); virtual bool getAlreadyCreateSharedAmongThreads();
virtual void setAlreadyCreateSharedAmongThreads(bool b); virtual void setAlreadyCreateSharedAmongThreads(bool b);
virtual bool isWindowedApplication();
virtual void setWindowedApplication(bool b);
private: private:
/// Pointer to the application context. /// Pointer to the application context.

@ -61,8 +61,7 @@ public:
class CClassIdHashMapTraits class CClassIdHashMapTraits
{ {
public: public:
static const size_t bucket_size = 4; enum { bucket_size = 4, min_buckets = 8, };
static const size_t min_buckets = 8;
inline size_t operator() ( const CClassId& classId ) const inline size_t operator() ( const CClassId& classId ) const
{ {
return ((((uint64)classId >> 32)|0xFFFFFFFF) ^ (((uint64)classId|0xFFFFFFFF) & 0xFFFFFFFF)); return ((((uint64)classId >> 32)|0xFFFFFFFF) ^ (((uint64)classId|0xFFFFFFFF) & 0xFFFFFFFF));

@ -347,7 +347,7 @@ std::string formatThousands(const std::string& s);
/// This function executes a program in the background and returns instantly (used for example to launch services in AES). /// This function executes a program in the background and returns instantly (used for example to launch services in AES).
/// The program will be launched in the current directory /// The program will be launched in the current directory
bool launchProgram (const std::string &programName, const std::string &arguments); bool launchProgram (const std::string &programName, const std::string &arguments, bool log = true);
/// This function kills a program using his pid (on unix, it uses the kill() POSIX function) /// This function kills a program using his pid (on unix, it uses the kill() POSIX function)
bool killProgram(uint32 pid); bool killProgram(uint32 pid);

@ -351,7 +351,9 @@ void setCrashAlreadyReported(bool state);
// removed because we always check assert (even in release mode) #if defined (NL_OS_WINDOWS) && defined (NL_DEBUG) // removed because we always check assert (even in release mode) #if defined (NL_OS_WINDOWS) && defined (NL_DEBUG)
#if defined(NL_OS_WINDOWS) #if defined(NL_OS_WINDOWS)
#define NLMISC_BREAKPOINT __debugbreak(); #define NLMISC_BREAKPOINT __debugbreak()
#elif defined(NL_OS_UNIX) && defined(NL_COMP_GCC)
#define NLMISC_BREAKPOINT __builtin_trap()
#else #else
#define NLMISC_BREAKPOINT abort() #define NLMISC_BREAKPOINT abort()
#endif #endif

@ -22,6 +22,21 @@
#ifdef NL_OS_WINDOWS // for win32 os only #ifdef NL_OS_WINDOWS // for win32 os only
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#ifndef _WIN32_WINDOWS
# define _WIN32_WINDOWS 0x0410
#endif
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400
#endif
#ifndef WINVER
# define WINVER 0x0400
#endif
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <windows.h> #include <windows.h>

@ -575,13 +575,16 @@ public:
// Traits for hash_map using CEntityId // Traits for hash_map using CEntityId
struct CEntityIdHashMapTraits struct CEntityIdHashMapTraits
{ {
static const size_t bucket_size = 4; enum { bucket_size = 4, min_buckets = 8, };
static const size_t min_buckets = 8;
CEntityIdHashMapTraits() { } CEntityIdHashMapTraits() { }
size_t operator() (const NLMISC::CEntityId &id ) const size_t operator() (const NLMISC::CEntityId &id ) const
{ {
uint64 hash64 = id.getUniqueId(); uint64 hash64 = id.getUniqueId();
return size_t(hash64) ^ size_t( hash64 >> 32 ); #if (HAVE_X86_64)
return (size_t)hash64;
#else
return (size_t)hash64 ^ (size_t)(hash64 >> 32);
#endif
//return size_t(id.getShortId()); //return size_t(id.getShortId());
} }
bool operator() (const NLMISC::CEntityId &id1, const NLMISC::CEntityId &id2) const bool operator() (const NLMISC::CEntityId &id1, const NLMISC::CEntityId &id2) const

@ -42,11 +42,7 @@ class CGtkDisplayer : public NLMISC::CWindowDisplayer
{ {
public: public:
CGtkDisplayer (const char *displayerName = "") : CWindowDisplayer(displayerName) CGtkDisplayer (const char *displayerName = "");
{
needSlashR = false;
createLabel ("@Clear|CLEAR");
}
virtual ~CGtkDisplayer (); virtual ~CGtkDisplayer ();

@ -27,6 +27,21 @@
#include "nel/misc/mem_stream.h" #include "nel/misc/mem_stream.h"
#include "nel/misc/dummy_window.h" #include "nel/misc/dummy_window.h"
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#ifndef _WIN32_WINDOWS
# define _WIN32_WINDOWS 0x0410
#endif
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400
#endif
#ifndef WINVER
# define WINVER 0x0400
#endif
#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <windows.h> #include <windows.h>
namespace NLMISC namespace NLMISC

@ -343,7 +343,7 @@ public:
/** Adds a search path. /** Adds a search path.
* The path is a directory "c:/temp" all files in the directory will be included (and recursively if asked) * The path is a directory "c:/temp" all files in the directory will be included (and recursively if asked)
* *
* Alternative directories are not pre-cached (instead of non Alternative files) and will used when a file is not found in the standard directories. * Alternative directories are not pre-cached (instead of non Alternative files) and will be used when a file is not found in the standard directories.
* For example, local data will be in the cached directories and server repository files will be in the Alternative files. If a new file is not * For example, local data will be in the cached directories and server repository files will be in the Alternative files. If a new file is not
* found in the local data, we'll try to find it on the repository. * found in the local data, we'll try to find it on the repository.
* *

@ -21,25 +21,38 @@
namespace NLMISC { namespace NLMISC {
/** Display a custom message box. #if FINAL_VERSION
#define NL_REPORT_SYNCHRONOUS false
#define NL_REPORT_DEFAULT NLMISC::ReportAbort
#else
#define NL_REPORT_SYNCHRONOUS true
#define NL_REPORT_DEFAULT NLMISC::ReportBreak
#endif
enum TReportResult
{
// See also crash_report_widget.h EReturnValue
ReportAlwaysIgnore = 21,
ReportIgnore = 22,
ReportAbort = 23,
ReportBreak = 24
};
/** Display a crash report
* *
* \param title set the title of the report. If empty, it'll display "NeL report". * \param title set the title of the report. If empty, it'll display "NeL report"
* \param header message displayed before the edit text box. If empty, it displays the default message. * \param subject extended title of the report
* \param body message displayed in the edit text box. This string will be sent by email. * \param body message displayed in the edit text box. This string will be sent to the crash report tool
* \param debugButton 0 for disabling it, 1 for enable with default behaviors (generate a breakpoint), 2 for enable with no behavior * \param attachment binary file to attach. This is a filename
* \param synchronous use system() and wait for the crash tool exit code, passes -dev flag; otherwise return defaultResult immediately
* \param sendReport hide 'dont send' button, or auto enable 'send report' checkbox
* *
* * \return the button clicked or defaultResult
*
* \return the button clicked or error
*/ */
TReportResult report(const std::string &title, const std::string &subject, const std::string &body, const std::string &attachment, bool synchronous, bool sendReport, TReportResult defaultResult);
enum TReportResult { ReportDebug, ReportIgnore, ReportQuit, ReportError }; /// Set the Url of the web service used to post crash reports to. String is copied
void setReportPostUrl(const char *postUrl);
TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const std::string &attachedFile = "");
/** call this in the main of your appli to enable email: setReportEmailFunction (sendEmail);
*/
void setReportEmailFunction (void *emailFunction);
} // NLMISC } // NLMISC

@ -248,8 +248,7 @@ private :
class CSheetIdHashMapTraits class CSheetIdHashMapTraits
{ {
public: public:
static const size_t bucket_size = 4; enum { bucket_size = 4, min_buckets = 8, };
static const size_t min_buckets = 8;
inline size_t operator() ( const CSheetId& sheetId ) const inline size_t operator() ( const CSheetId& sheetId ) const
{ {
return sheetId.asInt() >> 5; return sheetId.asInt() >> 5;

@ -937,21 +937,21 @@ inline CSString operator+(const CSString& s0,const CSString& s1)
*/ */
inline CSString operator+(char s0,const CSString& s1) inline CSString operator+(char s0,const CSString& s1)
{ {
return CSString(s0)+s1; return CSString(s0) + s1.c_str();
} }
inline CSString operator+(const char* s0,const CSString& s1) inline CSString operator+(const char* s0,const CSString& s1)
{ {
return CSString(s0)+s1; return CSString(s0) + s1.c_str();
} }
#ifndef NL_COMP_VC10 #if !defined(NL_COMP_VC) || (NL_COMP_VC_VERSION <= 100)
// TODO: check if it can be disabled for other compilers too // TODO: check if it can be disabled for other compilers too
inline CSString operator+(const std::string& s0,const CSString& s1) inline CSString operator+(const std::string& s0,const CSString& s1)
{ {
return s0+static_cast<const std::string&>(s1); return s0+static_cast<const std::string&>(s1);
} }
#endif // NL_COMP_VC10 #endif
} // NLMISC } // NLMISC

@ -20,6 +20,7 @@
#include "types_nl.h" #include "types_nl.h"
#include <cstdio> #include <cstdio>
#include <cstring>
#include <cstdarg> #include <cstdarg>
#include <errno.h> #include <errno.h>
@ -264,6 +265,40 @@ inline bool fromString(const std::string &str, bool &val)
return true; return true;
} }
inline bool fromString(const char *str, uint32 &val) { if (strstr(str, "-") != NULL) { val = 0; return false; } char *end; unsigned long v; errno = 0; v = strtoul(str, &end, 10); if (errno || v > UINT_MAX || end == str) { val = 0; return false; } else { val = (uint32)v; return true; } }
inline bool fromString(const char *str, sint32 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > INT_MAX || v < INT_MIN || end == str) { val = 0; return false; } else { val = (sint32)v; return true; } }
inline bool fromString(const char *str, uint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > UCHAR_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint8)v; return true; } }
inline bool fromString(const char *str, sint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SCHAR_MAX || v < SCHAR_MIN || end == str) { val = 0; return false; } else { val = (sint8)v; return true; } }
inline bool fromString(const char *str, uint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > USHRT_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint16)v; return true; } }
inline bool fromString(const char *str, sint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SHRT_MAX || v < SHRT_MIN || end == str) { val = 0; return false; } else { val = (sint16)v; return true; } }
inline bool fromString(const char *str, uint64 &val) { bool ret = sscanf(str, "%"NL_I64"u", &val) == 1; if (!ret) val = 0; return ret; }
inline bool fromString(const char *str, sint64 &val) { bool ret = sscanf(str, "%"NL_I64"d", &val) == 1; if (!ret) val = 0; return ret; }
inline bool fromString(const char *str, float &val) { bool ret = sscanf(str, "%f", &val) == 1; if (!ret) val = 0.0f; return ret; }
inline bool fromString(const char *str, double &val) { bool ret = sscanf(str, "%lf", &val) == 1; if (!ret) val = 0.0; return ret; }
inline bool fromString(const char *str, bool &val)
{
switch (str[0])
{
case '1':
case 't':
case 'y':
case 'T':
case 'Y':
val = true;
return true;
case '0':
case 'f':
case 'n':
case 'F':
case 'N':
val = false;
return true;
}
return false;
}
inline bool fromString(const std::string &str, std::string &val) { val = str; return true; } inline bool fromString(const std::string &str, std::string &val) { val = str; return true; }
// stl vectors of bool use bit reference and not real bools, so define the operator for bit reference // stl vectors of bool use bit reference and not real bools, so define the operator for bit reference

@ -39,8 +39,7 @@ typedef const std::string *TStringId;
// Traits for hash_map using CStringId // Traits for hash_map using CStringId
struct CStringIdHashMapTraits struct CStringIdHashMapTraits
{ {
static const size_t bucket_size = 4; enum { bucket_size = 4, min_buckets = 8, };
static const size_t min_buckets = 8;
CStringIdHashMapTraits() { } CStringIdHashMapTraits() { }
size_t operator() (const NLMISC::TStringId &stringId) const size_t operator() (const NLMISC::TStringId &stringId) const
{ {

@ -77,6 +77,10 @@ public:
/// Get desktop current color depth without using UDriver. /// Get desktop current color depth without using UDriver.
static uint getCurrentColorDepth(); static uint getCurrentColorDepth();
/// Detect whether the current process is a windowed application. Return true if definitely yes, false if unknown
static bool detectWindowedApplication();
}; };
} // NLMISC } // NLMISC

@ -53,7 +53,10 @@
# endif # endif
# ifdef _MSC_VER # ifdef _MSC_VER
# define NL_COMP_VC # define NL_COMP_VC
# if _MSC_VER >= 1700 # if _MSC_VER >= 1800
# define NL_COMP_VC12
# define NL_COMP_VC_VERSION 120
# elif _MSC_VER >= 1700
# define NL_COMP_VC11 # define NL_COMP_VC11
# define NL_COMP_VC_VERSION 110 # define NL_COMP_VC_VERSION 110
# elif _MSC_VER >= 1600 # elif _MSC_VER >= 1600
@ -414,6 +417,12 @@ extern void operator delete[](void *p) throw();
# define CHashMap stdext::hash_map # define CHashMap stdext::hash_map
# define CHashSet stdext::hash_set # define CHashSet stdext::hash_set
# define CHashMultiMap stdext::hash_multimap # define CHashMultiMap stdext::hash_multimap
#elif defined(NL_COMP_VC) && (NL_COMP_VC_VERSION >= 100)
# include <unordered_map>
# include <unordered_set>
# define CHashMap ::std::unordered_map
# define CHashSet ::std::unordered_set
# define CHashMultiMap ::std::unordered_multimap
#elif defined(NL_COMP_GCC) // GCC4 #elif defined(NL_COMP_GCC) // GCC4
# include <ext/hash_map> # include <ext/hash_map>
# include <ext/hash_set> # include <ext/hash_set>
@ -454,7 +463,11 @@ typedef uint16 ucchar;
// To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234) // To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234)
#ifdef NL_COMP_VC #ifdef NL_COMP_VC
# if (NL_COMP_VC_VERSION >= 80) # if (NL_COMP_VC_VERSION >= 120)
# define INT64_CONSTANT(c) (c##LL)
# define SINT64_CONSTANT(c) (c##LL)
# define UINT64_CONSTANT(c) (c##ULL)
# elif (NL_COMP_VC_VERSION >= 80)
# define INT64_CONSTANT(c) (c##LL) # define INT64_CONSTANT(c) (c##LL)
# define SINT64_CONSTANT(c) (c##LL) # define SINT64_CONSTANT(c) (c##LL)
# define UINT64_CONSTANT(c) (c##LL) # define UINT64_CONSTANT(c) (c##LL)

@ -355,8 +355,7 @@ namespace NLMISC
// Traits for hash_map using CEntityId // Traits for hash_map using CEntityId
struct CUCStringHashMapTraits struct CUCStringHashMapTraits
{ {
static const size_t bucket_size = 4; enum { bucket_size = 4, min_buckets = 8, };
static const size_t min_buckets = 8;
CUCStringHashMapTraits() { } CUCStringHashMapTraits() { }
size_t operator() (const ucstring &id ) const size_t operator() (const ucstring &id ) const
{ {
@ -364,7 +363,7 @@ struct CUCStringHashMapTraits
} }
bool operator() (const ucstring &id1, const ucstring &id2) const bool operator() (const ucstring &id1, const ucstring &id2) const
{ {
return id1.size() < id2.size(); return id1 < id2;
} }
}; };

@ -0,0 +1,74 @@
// Public domain hash functions
#ifndef NLMISC_WANG_HASH_H
#define NLMISC_WANG_HASH_H
#include "types_nl.h"
namespace NLMISC {
// http://burtleburtle.net/bob/hash/integer.html
inline uint32 wangHash(uint32 a)
{
a = (a ^ 61) ^ (a >> 16);
a = a + (a << 3);
a = a ^ (a >> 4);
a = a * 0x27d4eb2d;
a = a ^ (a >> 15);
return a;
}
// http://naml.us/blog/2012/03
inline uint64 wangHash64(uint64 key)
{
key = (~key) + (key << 21); // key = (key << 21) - key - 1;
key = key ^ (key >> 24);
key = (key + (key << 3)) + (key << 8); // key * 265
key = key ^ (key >> 14);
key = (key + (key << 2)) + (key << 4); // key * 21
key = key ^ (key >> 28);
key = key + (key << 31);
return key;
}
// http://naml.us/blog/2012/03 Inverse 64-bit wang hash
inline uint64 wangHash64Inv(uint64 key)
{
uint64 tmp;
// Invert key = key + (key << 31)
tmp = key - (key << 31);
key = key - (tmp << 31);
// Invert key = key ^ (key >> 28)
tmp = key^key >> 28;
key = key^tmp >> 28;
// Invert key *= 21
key *= 14933078535860113213u;
// Invert key = key ^ (key >> 14)
tmp = key^key >> 14;
tmp = key^tmp >> 14;
tmp = key^tmp >> 14;
key = key^tmp >> 14;
// Invert key *= 265
key *= 15244667743933553977u;
// Invert key = key ^ (key >> 24)
tmp = key^key >> 24;
key = key^tmp >> 24;
// Invert key = (~key) + (key << 21)
tmp = ~key;
tmp = ~(key - (tmp << 21));
tmp = ~(key - (tmp << 21));
key = ~(key - (tmp << 21));
return key;
}
} /* namespace NLMISC */
#endif // NLMISC_WANG_HASH_H

@ -21,8 +21,19 @@
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #ifndef WIN32_LEAN_AND_MEAN
#ifndef NL_COMP_MINGW # define WIN32_LEAN_AND_MEAN
#endif
#ifndef _WIN32_WINDOWS
# define _WIN32_WINDOWS 0x0410
#endif
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400
#endif
#ifndef WINVER
# define WINVER 0x0400
#endif
#ifndef NOMINMAX
# define NOMINMAX # define NOMINMAX
#endif #endif
#include <windows.h> #include <windows.h>
@ -46,11 +57,7 @@ class CWinDisplayer : public NLMISC::CWindowDisplayer
{ {
public: public:
CWinDisplayer (const char *displayerName = "") : CWindowDisplayer(displayerName), Exit(false) CWinDisplayer(const char *displayerName = "");
{
needSlashR = true;
createLabel ("@Clear|CLEAR");
}
virtual ~CWinDisplayer (); virtual ~CWinDisplayer ();

@ -31,7 +31,7 @@ public:
~CXMLAutoPtr() { destroy(); } ~CXMLAutoPtr() { destroy(); }
operator const char *() const { return _Value; } operator const char *() const { return _Value; }
operator bool() const { return _Value != NULL; } operator bool() const { return _Value != NULL; }
operator std::string() const { return std::string(_Value); } inline std::string str() const { return _Value; }
bool operator ! () const { return _Value == NULL; } bool operator ! () const { return _Value == NULL; }
operator const unsigned char *() const { return (const unsigned char *) _Value; } operator const unsigned char *() const { return (const unsigned char *) _Value; }
char operator * () const { nlassert(_Value); return *_Value; } char operator * () const { nlassert(_Value); return *_Value; }

@ -218,13 +218,13 @@ public:
static bool isServiceInitialized() { return _Instance != NULL; } static bool isServiceInitialized() { return _Instance != NULL; }
/// Returns the current service short name (ie: TS) /// Returns the current service short name (ie: TS)
const std::string &getServiceShortName () const { return _ShortName; }; const std::string &getServiceShortName () const { return _ShortName; }
/// Returns the current service long name (ie: test_serivce) /// Returns the current service long name (ie: test_serivce)
const std::string &getServiceLongName () const { return _LongName; }; const std::string &getServiceLongName () const { return _LongName; }
/// Returns the current service alias name setted by AES /// Returns the current service alias name setted by AES
const std::string &getServiceAliasName () const { return _AliasName; }; const std::string &getServiceAliasName () const { return _AliasName; }
/// Returns the current service unified name that is alias/short-id or short-id if alias is empty /// Returns the current service unified name that is alias/short-id or short-id if alias is empty
std::string getServiceUnifiedName () const; std::string getServiceUnifiedName () const;
@ -242,10 +242,10 @@ public:
uint32 getLaunchingDate () const; uint32 getLaunchingDate () const;
/// Return true if this service don't use the NS (naming service) /// Return true if this service don't use the NS (naming service)
bool getDontUseNS() const { return _DontUseNS; }; bool getDontUseNS() const { return _DontUseNS; }
/// Return true if this service don't use the AES (admin executor service) /// Return true if this service don't use the AES (admin executor service)
bool getDontUseAES() const { return _DontUseAES; }; bool getDontUseAES() const { return _DontUseAES; }
/// Returns arguments of the program pass from the user to the program using parameters (ie: "myprog param1 param2") /// Returns arguments of the program pass from the user to the program using parameters (ie: "myprog param1 param2")
const NLMISC::CVectorSString &getArgs () const { return _Args; } const NLMISC::CVectorSString &getArgs () const { return _Args; }

@ -42,8 +42,7 @@ namespace NLSOUND {
template <class Pointer> template <class Pointer>
struct THashPtr : public std::unary_function<const Pointer &, size_t> struct THashPtr : public std::unary_function<const Pointer &, size_t>
{ {
static const size_t bucket_size = 4; enum { bucket_size = 4, min_buckets = 8, };
static const size_t min_buckets = 8;
size_t operator () (const Pointer &ptr) const size_t operator () (const Pointer &ptr) const
{ {
//CHashSet<uint>::hasher h; //CHashSet<uint>::hasher h;

@ -71,6 +71,19 @@ struct CContextMatcher
return memcmp(JokersValues, other.JokersValues, sizeof(uint32)*NbJoker) == 0; return memcmp(JokersValues, other.JokersValues, sizeof(uint32)*NbJoker) == 0;
} }
bool operator<(const CContextMatcher &other) const
{
if (UseRandom)
if (RandomValue != other.RandomValue)
return RandomValue < other.RandomValue;
int cmp = memcmp(JokersValues, other.JokersValues, sizeof(uint32) * NbJoker);
if (cmp != 0)
return cmp < 0;
return false;
}
size_t getHashValue() const size_t getHashValue() const
{ {
return size_t(HashValue); return size_t(HashValue);
@ -82,18 +95,16 @@ struct CContextMatcher
struct CHash : public std::unary_function<CContextMatcher, size_t> struct CHash : public std::unary_function<CContextMatcher, size_t>
{ {
static const size_t bucket_size = 4; enum { bucket_size = 4, min_buckets = 8, };
static const size_t min_buckets = 8;
size_t operator () (const CContextMatcher &patternMatcher) const size_t operator () (const CContextMatcher &patternMatcher) const
{ {
return patternMatcher.getHashValue(); return patternMatcher.getHashValue();
} }
bool operator() (const CContextMatcher &patternMatcher1, const CContextMatcher &patternMatcher2) const bool operator() (const CContextMatcher &patternMatcher1, const CContextMatcher &patternMatcher2) const
{ {
return patternMatcher1.getHashValue() < patternMatcher2.getHashValue(); return patternMatcher1 < patternMatcher2;
} }
}; };
}; };

@ -79,16 +79,16 @@ int main(int argc, char **argv)
// 4th is the size of the font. 5th is a pointer to the video driver. // 4th is the size of the font. 5th is a pointer to the video driver.
// 6th is the resulting computed string. // 6th is the resulting computed string.
CComputedString csRotation; CComputedString csRotation;
fontManager.computeString ("cs Rotation", tc.getFontGenerator(), CRGBA(255,255,255), 70, CNELU::Driver, csRotation); fontManager.computeString ("cs Rotation", tc.getFontGenerator(), CRGBA(255,255,255), 70, false, false, CNELU::Driver, csRotation);
CComputedString cs3d; CComputedString cs3d;
fontManager.computeString ("cs 3d", tc.getFontGenerator(), CRGBA(255,127,0), 75, CNELU::Driver, cs3d); fontManager.computeString ("cs 3d", tc.getFontGenerator(), CRGBA(255,127,0), 75, false, false, CNELU::Driver, cs3d);
// generate an Unicode string. // generate an Unicode string.
ucstring ucs("cs Unicode String"); ucstring ucs("cs Unicode String");
CComputedString csUnicode; CComputedString csUnicode;
fontManager.computeString (ucs, tc.getFontGenerator(), CRGBA(32,64,127), 75, CNELU::Driver, csUnicode); fontManager.computeString (ucs, tc.getFontGenerator(), CRGBA(32,64,127), 75, false, false, CNELU::Driver, csUnicode);
// look at event example // look at event example
CNELU::EventServer.addEmitter(CNELU::Driver->getEventEmitter()); CNELU::EventServer.addEmitter(CNELU::Driver->getEventEmitter());

@ -18,9 +18,14 @@
#include <stdlib.h> #include <stdlib.h>
// contains all debug features // contains all debug features
#include "nel/misc/debug.h" #include <nel/misc/debug.h>
#include <nel/misc/report.h>
using namespace NLMISC; void repeatederror()
{
// hit always ignore to surpress this error for the duration of the program
nlassert(false && "hit always ignore");
}
int main(int /* argc */, char ** /* argv */) int main(int /* argc */, char ** /* argv */)
{ {
@ -36,7 +41,11 @@ int main (int /* argc */, char ** /* argv */)
// in release mode, this function does nothing by default. you have to add a displayer // in release mode, this function does nothing by default. you have to add a displayer
// manually, or put true in the parameter to say to the function that you want it to // manually, or put true in the parameter to say to the function that you want it to
// add the default displayers // add the default displayers
createDebug (); NLMISC::createDebug();
// enable the crash report tool
NLMISC::INelContext::getInstance().setWindowedApplication(true);
NLMISC::setReportPostUrl("http://ryzomcore.org/crash_report/");
// display debug information, that will be skipped in release mode. // display debug information, that will be skipped in release mode.
nldebug("nldebug() %d", 1); nldebug("nldebug() %d", 1);
@ -63,12 +72,16 @@ int main (int /* argc */, char ** /* argv */)
{ {
nlerror("nlerror() %d", 4); nlerror("nlerror() %d", 4);
} }
catch(const EFatalError &) catch (const NLMISC::EFatalError &)
{ {
// just continue... // just continue...
nlinfo("nlerror() generated an EFatalError exception, just ignore it"); nlinfo("nlerror() generated an EFatalError exception, just ignore it");
} }
// keep repeating the same error
for (int i = 0; i < 32; ++i)
repeatederror();
printf("\nPress <return> to exit\n"); printf("\nPress <return> to exit\n");
getchar(); getchar();

@ -98,8 +98,7 @@ struct CClient
struct TInetAddressHash struct TInetAddressHash
{ {
static const size_t bucket_size = 4; enum { bucket_size = 4, min_buckets = 8, };
static const size_t min_buckets = 8;
inline bool operator() (const NLNET::CInetAddress &x1, const NLNET::CInetAddress &x2) const inline bool operator() (const NLNET::CInetAddress &x1, const NLNET::CInetAddress &x2) const
{ {

@ -1327,6 +1327,10 @@ const D3DFORMAT FinalPixelFormat[ITexture::UploadFormatCount][CDriverD3D::FinalP
bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay) bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay)
{ {
H_AUTO_D3D(CDriver3D_setDisplay); H_AUTO_D3D(CDriver3D_setDisplay);
if (!mode.OffScreen)
NLMISC::INelContext::getInstance().setWindowedApplication(true);
if (!_D3D) if (!_D3D)
return false; return false;
#ifndef NL_NO_ASM #ifndef NL_NO_ASM
@ -1509,9 +1513,6 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r
} }
} }
// _D3D->CreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &parameters, &_DeviceInterface);
// Check some caps // Check some caps
D3DCAPS9 caps; D3DCAPS9 caps;
if (_DeviceInterface->GetDeviceCaps(&caps) == D3D_OK) if (_DeviceInterface->GetDeviceCaps(&caps) == D3D_OK)

@ -67,6 +67,16 @@ IF(UNIX AND NOT APPLE)
ADD_DEFINITIONS(-DHAVE_XCURSOR) ADD_DEFINITIONS(-DHAVE_XCURSOR)
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xcursor_LIB}) TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xcursor_LIB})
ENDIF(X11_Xcursor_FOUND) ENDIF(X11_Xcursor_FOUND)
IF(X11_Xext_FOUND)
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xext_LIB})
ENDIF(X11_Xext_FOUND)
# libraries needed to be linked while linking to static X11 libraries
FIND_LIBRARY(XCB_LIBRARY
NAMES xcb
HINTS ${X11_LIB_SEARCH_PATH})
IF(XCB_LIBRARY)
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XCB_LIBRARY})
ENDIF(XCB_LIBRARY)
ENDIF(UNIX AND NOT APPLE) ENDIF(UNIX AND NOT APPLE)
IF(WITH_PCH) IF(WITH_PCH)

@ -435,11 +435,7 @@ bool CDriverGL::setupDisplay()
glViewport(0,0,_CurrentMode.Width,_CurrentMode.Height); glViewport(0,0,_CurrentMode.Width,_CurrentMode.Height);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
#ifdef USE_OPENGLES
glOrthof(0.f,_CurrentMode.Width,_CurrentMode.Height,0.f,-1.0f,1.0f);
#else
glOrtho(0,_CurrentMode.Width,_CurrentMode.Height,0,-1.0f,1.0f); glOrtho(0,_CurrentMode.Width,_CurrentMode.Height,0,-1.0f,1.0f);
#endif
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
#ifndef USE_OPENGLES #ifndef USE_OPENGLES
@ -725,11 +721,7 @@ bool CDriverGL::activeFrameBufferObject(ITexture * tex)
} }
else else
{ {
#ifdef USE_OPENGLES
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
#else
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
#endif
return true; return true;
} }
} }
@ -2178,7 +2170,7 @@ void CDriverGL::flush()
// *************************************************************************** // ***************************************************************************
void CDriverGL::setSwapVBLInterval(uint interval) void CDriverGL::setSwapVBLInterval(uint interval)
{ {
H_AUTO_OGL(CDriverGL_setSwapVBLInterval) H_AUTO_OGL(CDriverGL_setSwapVBLInterval);
if (!_Initialized) if (!_Initialized)
return; return;

@ -40,6 +40,24 @@ extern "C" {
#define GL_ADD_SIGNED_EXT GL_ADD_SIGNED #define GL_ADD_SIGNED_EXT GL_ADD_SIGNED
#define GL_INTERPOLATE_EXT GL_INTERPOLATE #define GL_INTERPOLATE_EXT GL_INTERPOLATE
#define GL_BUMP_ENVMAP_ATI GL_INTERPOLATE #define GL_BUMP_ENVMAP_ATI GL_INTERPOLATE
#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES
#define GL_RENDERBUFFER_EXT GL_RENDERBUFFER_OES
#define GL_DEPTH24_STENCIL8_EXT GL_DEPTH24_STENCIL8_OES
#define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES
#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0_OES
#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT_OES
#define GL_STENCIL_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT_OES
#define GL_ARRAY_BUFFER_ARB GL_ARRAY_BUFFER
#define GL_TEXTURE0_ARB GL_TEXTURE0
#define GL_ALPHA8 GL_ALPHA
#define GL_LUMINANCE8_ALPHA8 GL_LUMINANCE_ALPHA
#define GL_LUMINANCE8 GL_LUMINANCE
#define GL_RGBA8 GL_RGBA
#define GL_RGB8 GL_RGB
#define GL_STATIC_DRAW_ARB GL_STATIC_DRAW
#define GL_DYNAMIC_DRAW_ARB GL_DYNAMIC_DRAW
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES
@ -48,6 +66,31 @@ extern "C" {
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES
#define nglGenRenderbuffersEXT nglGenRenderbuffersOES
#define nglBindRenderbufferEXT nglBindRenderbufferOES
#define nglDeleteRenderbuffersEXT nglDeleteRenderbuffersOES
#define nglRenderbufferStorageEXT nglRenderbufferStorageOES
#define nglGenFramebuffersEXT nglGenFramebuffersOES
#define nglBindFramebufferEXT nglBindFramebufferOES
#define nglFramebufferTexture2DEXT nglFramebufferTexture2DOES
#define nglFramebufferRenderbufferEXT nglFramebufferRenderbufferOES
#define nglCheckFramebufferStatusEXT nglCheckFramebufferStatusOES
#define nglDeleteBuffersARB glDeleteBuffers
#define nglIsBufferARB glIsBuffer
#define nglDeleteRenderbuffersEXT nglDeleteRenderbuffersOES
#define nglBindFramebufferEXT nglBindFramebufferOES
#define nglDeleteFramebuffersEXT nglDeleteFramebuffersOES
#define nglUnmapBufferARB nglUnmapBufferOES
#define nglActiveTextureARB glActiveTexture
#define nglClientActiveTextureARB glClientActiveTexture
#define nglBindBufferARB glBindBuffer
#define nglGenBuffersARB glGenBuffers
#define nglBufferDataARB glBufferData
#define glFrustum glFrustumf
#define glOrtho glOrthof
#define glDepthRange glDepthRangef
#else #else
#if defined(NL_OS_MAC) #if defined(NL_OS_MAC)

@ -37,19 +37,11 @@ void CDriverGL::setFrustum(float left, float right, float bottom, float top, flo
if (perspective) if (perspective)
{ {
#ifdef USE_OPENGLES
glFrustumf(left,right,bottom,top,znear,zfar);
#else
glFrustum(left,right,bottom,top,znear,zfar); glFrustum(left,right,bottom,top,znear,zfar);
#endif
} }
else else
{ {
#ifdef USE_OPENGLES
glOrthof(left,right,bottom,top,znear,zfar);
#else
glOrtho(left,right,bottom,top,znear,zfar); glOrtho(left,right,bottom,top,znear,zfar);
#endif
} }
_ProjMatDirty = true; _ProjMatDirty = true;

@ -155,11 +155,7 @@ void CDriverGLStates::forceDefaults(uint nbStages)
for(stage=0;stage<nbStages; stage++) for(stage=0;stage<nbStages; stage++)
{ {
// disable texturing. // disable texturing.
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
@ -188,13 +184,8 @@ void CDriverGLStates::forceDefaults(uint nbStages)
} }
// ActiveTexture current texture to 0. // ActiveTexture current texture to 0.
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB); nglActiveTextureARB(GL_TEXTURE0_ARB);
nglClientActiveTextureARB(GL_TEXTURE0_ARB); nglClientActiveTextureARB(GL_TEXTURE0_ARB);
#endif
_CurrentActiveTextureARB= 0; _CurrentActiveTextureARB= 0;
_CurrentClientActiveTextureARB= 0; _CurrentClientActiveTextureARB= 0;
@ -622,11 +613,7 @@ void CDriverGLStates::updateDepthRange()
float delta = _ZBias * (_DepthRangeFar - _DepthRangeNear); float delta = _ZBias * (_DepthRangeFar - _DepthRangeNear);
#ifdef USE_OPENGLES
glDepthRangef(delta + _DepthRangeNear, delta + _DepthRangeFar);
#else
glDepthRange(delta + _DepthRangeNear, delta + _DepthRangeFar); glDepthRange(delta + _DepthRangeNear, delta + _DepthRangeFar);
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -835,11 +822,7 @@ void CDriverGLStates::activeTextureARB(uint stage)
if( _CurrentActiveTextureARB != stage ) if( _CurrentActiveTextureARB != stage )
{ {
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentActiveTextureARB= stage; _CurrentActiveTextureARB= stage;
} }
@ -850,11 +833,7 @@ void CDriverGLStates::forceActiveTextureARB(uint stage)
{ {
H_AUTO_OGL(CDriverGLStates_forceActiveTextureARB); H_AUTO_OGL(CDriverGLStates_forceActiveTextureARB);
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentActiveTextureARB= stage; _CurrentActiveTextureARB= stage;
} }
@ -958,11 +937,7 @@ void CDriverGLStates::clientActiveTextureARB(uint stage)
if( _CurrentClientActiveTextureARB != stage ) if( _CurrentClientActiveTextureARB != stage )
{ {
#ifdef USE_OPENGLES
glClientActiveTexture(GL_TEXTURE0+stage);
#else
nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage); nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentClientActiveTextureARB= stage; _CurrentClientActiveTextureARB= stage;
} }
} }
@ -1121,11 +1096,7 @@ void CDriverGLStates::forceBindARBVertexBuffer(uint objectID)
{ {
H_AUTO_OGL(CDriverGLStates_forceBindARBVertexBuffer) H_AUTO_OGL(CDriverGLStates_forceBindARBVertexBuffer)
#ifdef USE_OPENGLES
glBindBuffer(GL_ARRAY_BUFFER, objectID);
#else
nglBindBufferARB(GL_ARRAY_BUFFER_ARB, objectID); nglBindBufferARB(GL_ARRAY_BUFFER_ARB, objectID);
#endif
_CurrARBVertexBuffer = objectID; _CurrARBVertexBuffer = objectID;
} }

@ -93,19 +93,6 @@ CTextureDrvInfosGL::~CTextureDrvInfosGL()
{ {
_Driver->_TextureUsed[TextureUsedIdx] = NULL; _Driver->_TextureUsed[TextureUsedIdx] = NULL;
} }
#ifdef USE_OPENGLES
if (InitFBO)
{
nglDeleteFramebuffersOES(1, &FBOId);
if(AttachDepthStencil)
{
nglDeleteRenderbuffersOES(1, &DepthFBOId);
if(!UsePackedDepthStencil)
nglDeleteRenderbuffersOES(1, &StencilFBOId);
}
}
#endif
} }
CDepthStencilFBO::CDepthStencilFBO(CDriverGL *driver, uint width, uint height) CDepthStencilFBO::CDepthStencilFBO(CDriverGL *driver, uint width, uint height)
@ -175,53 +162,6 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
AttachDepthStencil = !((CTextureBloom*)tex)->isMode2D(); AttachDepthStencil = !((CTextureBloom*)tex)->isMode2D();
} }
#ifdef USE_OPENGLES
// generate IDs
nglGenFramebuffersOES(1, &FBOId);
if(AttachDepthStencil)
{
nglGenRenderbuffersOES(1, &DepthFBOId);
if(UsePackedDepthStencil)
StencilFBOId = DepthFBOId;
else
nglGenRenderbuffersOES(1, &StencilFBOId);
}
//nldebug("3D: using depth %d and stencil %d", DepthFBOId, StencilFBOId);
// initialize FBO
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, FBOId);
nglFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, TextureMode, ID, 0);
// attach depth/stencil render to FBO
// note: for some still unkown reason it's impossible to add
// a stencil buffer as shown in the respective docs (see
// opengl.org extension registry). Until a safe approach to add
// them is found, there will be no attached stencil for the time
// being, aside of using packed depth+stencil buffers.
if(AttachDepthStencil)
{
if(UsePackedDepthStencil)
{
//nldebug("3D: using packed depth stencil");
nglBindRenderbufferOES(GL_RENDERBUFFER_OES, StencilFBOId);
nglRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH24_STENCIL8_OES, tex->getWidth(), tex->getHeight());
}
else
{
nglBindRenderbufferOES(GL_RENDERBUFFER_OES, DepthFBOId);
nglRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT24_OES, tex->getWidth(), tex->getHeight());
/*
nglBindRenderbufferEXT(GL_RENDERBUFFER_OES, StencilFBOId);
nglRenderbufferStorageEXT(GL_RENDERBUFFER_OES, GL_STENCIL_INDEX8_EXT, tex->getWidth(), tex->getHeight());
*/
}
nglFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, DepthFBOId);
nldebug("3D: glFramebufferRenderbufferExt(depth:24) = %X", nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
nglFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, StencilFBOId);
nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
}
#else
// generate IDs // generate IDs
nglGenFramebuffersEXT(1, &FBOId); nglGenFramebuffersEXT(1, &FBOId);
@ -253,15 +193,10 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
GL_RENDERBUFFER_EXT, DepthStencilFBO->StencilFBOId); GL_RENDERBUFFER_EXT, DepthStencilFBO->StencilFBOId);
nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); nldebug("3D: glFramebufferRenderbufferExt(stencil:8) = %X", nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
} }
#endif
// check status // check status
GLenum status; GLenum status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
#ifdef USE_OPENGLES
status = (GLenum) nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
#else
status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
#endif
switch(status) { switch(status) {
#ifdef GL_FRAMEBUFFER_COMPLETE_EXT #ifdef GL_FRAMEBUFFER_COMPLETE_EXT
case GL_FRAMEBUFFER_COMPLETE_EXT: case GL_FRAMEBUFFER_COMPLETE_EXT:
@ -361,11 +296,8 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
// clean up resources if allocation failed // clean up resources if allocation failed
if (!InitFBO) if (!InitFBO)
{ {
#ifdef USE_OPENGLES
nglDeleteFramebuffersOES(1, &FBOId);
#else
nglDeleteFramebuffersEXT(1, &FBOId); nglDeleteFramebuffersEXT(1, &FBOId);
#endif
if (AttachDepthStencil) if (AttachDepthStencil)
{ {
DepthStencilFBO = NULL; DepthStencilFBO = NULL;
@ -385,22 +317,14 @@ bool CTextureDrvInfosGL::activeFrameBufferObject(ITexture * tex)
if(initFrameBufferObject(tex)) if(initFrameBufferObject(tex))
{ {
glBindTexture(TextureMode, 0); glBindTexture(TextureMode, 0);
#ifdef USE_OPENGLES
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, FBOId);
#else
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId); nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId);
#endif
} }
else else
return false; return false;
} }
else else
{ {
#ifdef USE_OPENGLES
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
#else
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
#endif
} }
return true; return true;
@ -508,11 +432,7 @@ GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed)
break; break;
} }
#ifdef USE_OPENGLES
return GL_RGBA;
#else
return GL_RGBA8; return GL_RGBA8;
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -521,11 +441,7 @@ static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt)
H_AUTO_OGL(getGlSrcTextureFormat) H_AUTO_OGL(getGlSrcTextureFormat)
// Is destination format is alpha or lumiance ? // Is destination format is alpha or lumiance ?
#ifdef USE_OPENGLES
if ((glfmt==GL_ALPHA)||(glfmt==GL_LUMINANCE_ALPHA)||(glfmt==GL_LUMINANCE))
#else
if ((glfmt==GL_ALPHA8)||(glfmt==GL_LUMINANCE8_ALPHA8)||(glfmt==GL_LUMINANCE8)) if ((glfmt==GL_ALPHA8)||(glfmt==GL_LUMINANCE8_ALPHA8)||(glfmt==GL_LUMINANCE8))
#endif
{ {
switch(tex.getPixelFormat()) switch(tex.getPixelFormat())
{ {
@ -578,19 +494,9 @@ uint CDriverGL::computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const
H_AUTO_OGL(CDriverGL_computeMipMapMemoryUsage) H_AUTO_OGL(CDriverGL_computeMipMapMemoryUsage)
switch(glfmt) switch(glfmt)
{ {
#ifdef GL_RGBA8
case GL_RGBA8: return w*h* 4; case GL_RGBA8: return w*h* 4;
#endif
#ifdef GL_RGBA
case GL_RGBA: return w*h* 4;
#endif
// Well this is ugly, but simple :). GeForce 888 is stored as 32 bits. // Well this is ugly, but simple :). GeForce 888 is stored as 32 bits.
#ifdef GL_RGB8
case GL_RGB8: return w*h* 4; case GL_RGB8: return w*h* 4;
#endif
#ifdef GL_RGB
case GL_RGB: return w*h* 4;
#endif
#ifdef GL_RGBA4 #ifdef GL_RGBA4
case GL_RGBA4: return w*h* 2; case GL_RGBA4: return w*h* 2;
#endif #endif
@ -600,24 +506,9 @@ uint CDriverGL::computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const
#ifdef GL_RGB5 #ifdef GL_RGB5
case GL_RGB5: return w*h* 2; case GL_RGB5: return w*h* 2;
#endif #endif
#ifdef GL_LUMINANCE8
case GL_LUMINANCE8: return w*h* 1; case GL_LUMINANCE8: return w*h* 1;
#endif
#ifdef GL_LUMINANCE
case GL_LUMINANCE: return w*h* 1;
#endif
#ifdef GL_ALPHA8
case GL_ALPHA8: return w*h* 1; case GL_ALPHA8: return w*h* 1;
#endif
#ifdef GL_ALPHA
case GL_ALPHA: return w*h* 1;
#endif
#ifdef GL_LUMINANCE8_ALPHA8
case GL_LUMINANCE8_ALPHA8: return w*h* 2; case GL_LUMINANCE8_ALPHA8: return w*h* 2;
#endif
#ifdef GL_LUMINANCE_ALPHA
case GL_LUMINANCE_ALPHA: return w*h* 2;
#endif
#ifdef GL_COMPRESSED_RGB_S3TC_DXT1_EXT #ifdef GL_COMPRESSED_RGB_S3TC_DXT1_EXT
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return w*h /2; case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return w*h /2;
#endif #endif

@ -1216,11 +1216,7 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
GLuint vertexBufferID; GLuint vertexBufferID;
glGetError(); glGetError();
#ifdef USE_OPENGLES
glGenBuffers(1, &vertexBufferID);
#else
nglGenBuffersARB(1, &vertexBufferID); nglGenBuffersARB(1, &vertexBufferID);
#endif
if (glGetError() != GL_NO_ERROR) return NULL; if (glGetError() != GL_NO_ERROR) return NULL;
_Driver->_DriverGLStates.forceBindARBVertexBuffer(vertexBufferID); _Driver->_DriverGLStates.forceBindARBVertexBuffer(vertexBufferID);
@ -1229,7 +1225,8 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
{ {
case CVertexBuffer::AGPVolatile: case CVertexBuffer::AGPVolatile:
#ifdef USE_OPENGLES #ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STREAM_DRAW); // TODO: GL_STREAM_DRAW doesn't exist in OpenGL ES 1.x
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else #else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STREAM_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STREAM_DRAW_ARB);
#endif #endif
@ -1259,11 +1256,7 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
} }
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
#ifdef USE_OPENGLES
glDeleteBuffers(1, &vertexBufferID);
#else
nglDeleteBuffersARB(1, &vertexBufferID); nglDeleteBuffersARB(1, &vertexBufferID);
#endif
return NULL; return NULL;
} }
@ -1306,13 +1299,10 @@ void CVertexArrayRangeARB::updateLostBuffers()
{ {
nlassert((*it)->_VertexObjectId); nlassert((*it)->_VertexObjectId);
GLuint id = (GLuint) (*it)->_VertexObjectId; GLuint id = (GLuint) (*it)->_VertexObjectId;
#ifdef USE_OPENGLES
nlassert(glIsBuffer(id));
glDeleteBuffers(1, &id);
#else
nlassert(nglIsBufferARB(id)); nlassert(nglIsBufferARB(id));
nglDeleteBuffersARB(1, &id); nglDeleteBuffersARB(1, &id);
#endif
(*it)->_VertexObjectId = 0; (*it)->_VertexObjectId = 0;
(*it)->VB->setLocation(CVertexBuffer::NotResident); (*it)->VB->setLocation(CVertexBuffer::NotResident);
} }
@ -1361,13 +1351,8 @@ CVertexBufferHardARB::~CVertexBufferHardARB()
if (_VertexObjectId) if (_VertexObjectId)
{ {
GLuint id = (GLuint) _VertexObjectId; GLuint id = (GLuint) _VertexObjectId;
#ifdef USE_OPENGLES
nlassert(glIsBuffer(id));
glDeleteBuffers(1, &id);
#else
nlassert(nglIsBufferARB(id)); nlassert(nglIsBufferARB(id));
nglDeleteBuffersARB(1, &id); nglDeleteBuffersARB(1, &id);
#endif
} }
if (_VertexArrayRange) if (_VertexArrayRange)
{ {
@ -1412,12 +1397,7 @@ void *CVertexBufferHardARB::lock()
} }
// recreate a vb // recreate a vb
GLuint vertexBufferID; GLuint vertexBufferID;
#ifdef USE_OPENGLES
glGenBuffers(1, &vertexBufferID);
#else
nglGenBuffersARB(1, &vertexBufferID); nglGenBuffersARB(1, &vertexBufferID);
#endif
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
@ -1429,42 +1409,30 @@ void *CVertexBufferHardARB::lock()
{ {
case CVertexBuffer::AGPVolatile: case CVertexBuffer::AGPVolatile:
#ifdef USE_OPENGLES #ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STREAM_DRAW); // TODO: GL_STREAM_DRAW doesn't exist in OpenGL ES 1.x
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else #else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STREAM_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STREAM_DRAW_ARB);
#endif #endif
break; break;
case CVertexBuffer::StaticPreferred: case CVertexBuffer::StaticPreferred:
if (_Driver->getStaticMemoryToVRAM()) if (_Driver->getStaticMemoryToVRAM())
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB);
#endif
else else
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
#endif
break; break;
// case CVertexBuffer::AGPPreferred: // case CVertexBuffer::AGPPreferred:
default: default:
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
#endif
break; break;
} }
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
_Driver->incrementResetCounter(); _Driver->incrementResetCounter();
#ifdef USE_OPENGLES
glDeleteBuffers(1, &vertexBufferID);
#else
nglDeleteBuffersARB(1, &vertexBufferID); nglDeleteBuffersARB(1, &vertexBufferID);
#endif
return &_DummyVB[0];; return &_DummyVB[0];;
} }
_VertexObjectId = vertexBufferID; _VertexObjectId = vertexBufferID;
@ -1567,12 +1535,10 @@ void CVertexBufferHardARB::unlock()
#ifdef USE_OPENGLES #ifdef USE_OPENGLES
if (_Driver->_Extensions.OESMapBuffer) if (_Driver->_Extensions.OESMapBuffer)
#endif
{ {
unmapOk = nglUnmapBufferOES(GL_ARRAY_BUFFER);
}
#else
unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB); unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
#endif }
#ifdef NL_DEBUG #ifdef NL_DEBUG
_Unmapping = false; _Unmapping = false;

@ -453,7 +453,6 @@ bool CDriverGL::setupEXTVertexShader(const CVPParser::TProgram &program, GLuint
// clear last error // clear last error
GLenum glError = glGetError(); GLenum glError = glGetError();
//variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_NORMALIZED_RANGE_EXT, 1);
//variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_NORMALIZED_RANGE_EXT, 1); //variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_NORMALIZED_RANGE_EXT, 1);
// allocate the symbols // allocate the symbols

@ -603,6 +603,9 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
{ {
H_AUTO_OGL(CDriverGL_setDisplay) H_AUTO_OGL(CDriverGL_setDisplay)
if (!mode.OffScreen)
NLMISC::INelContext::getInstance().setWindowedApplication(true);
_win = EmptyWindow; _win = EmptyWindow;
_CurrentMode = mode; _CurrentMode = mode;
@ -627,10 +630,15 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
// Offscreen mode ? // Offscreen mode ?
if (_CurrentMode.OffScreen) if (_CurrentMode.OffScreen)
{ {
#if 0 if (!createWindow(mode)) return false;
if (!createWindow(mode))
return false; HWND tmpHWND = _win;
int width = mode.Width;
int height = mode.Height;
#ifdef USE_OPENGLES
// TODO: implement for OpenGL ES 1.x
#else
// resize the window // resize the window
RECT rc; RECT rc;
SetRect (&rc, 0, 0, width, height); SetRect (&rc, 0, 0, width, height);
@ -1437,8 +1445,17 @@ bool CDriverGL::createWindow(const GfxMode &mode)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
// create the OpenGL window // create the OpenGL window
window = CreateWindowW(L"NLClass", L"NeL Window", WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, DWORD dwStyle = WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
CW_USEDEFAULT, CW_USEDEFAULT, mode.Width, mode.Height, HWND_DESKTOP, NULL, GetModuleHandle(NULL), NULL); int pos = CW_USEDEFAULT;
HWND hwndParent = HWND_DESKTOP;
if (mode.OffScreen)
{
dwStyle &= ~WS_VISIBLE;
pos = 0;
hwndParent = NULL;
}
window = CreateWindowW(L"NLClass", L"NeL Window", dwStyle,
pos, pos, mode.Width, mode.Height, hwndParent, NULL, GetModuleHandle(NULL), NULL);
if (window == EmptyWindow) if (window == EmptyWindow)
{ {
@ -1469,7 +1486,7 @@ bool CDriverGL::createWindow(const GfxMode &mode)
[[CocoaApplicationDelegate alloc] initWithDriver:this]; [[CocoaApplicationDelegate alloc] initWithDriver:this];
// set the application delegate, this will handle window/app close events // set the application delegate, this will handle window/app close events
[NSApp setDelegate:appDelegate]; [NSApp setDelegate:(id<NSFileManagerDelegate>)appDelegate];
// bind the close button of the window to applicationShouldTerminate // bind the close button of the window to applicationShouldTerminate
id closeButton = [cocoa_window standardWindowButton:NSWindowCloseButton]; id closeButton = [cocoa_window standardWindowButton:NSWindowCloseButton];

@ -270,28 +270,14 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
return false; return false;
} }
// first event about mouse movement after setting to emulateRawMode
if(_setToEmulateRawMode &&
(event.type == NSMouseMoved ||
event.type == NSLeftMouseDragged ||
event.type == NSRightMouseDragged))
{
// do not report because it reflects wrapping pointer to 0.5/0.5
_setToEmulateRawMode = false;
return false;
}
// convert the modifiers for nel to pass them with the events // convert the modifiers for nel to pass them with the events
NLMISC::TKeyButton modifiers = NLMISC::TKeyButton modifiers = modifierFlagsToNelKeyButton([event modifierFlags]);
modifierFlagsToNelKeyButton([event modifierFlags]);
switch(event.type) switch(event.type)
{ {
case NSLeftMouseDown: case NSLeftMouseDown:
{ {
server->postEvent(new NLMISC::CEventMouseDown( server->postEvent(new NLMISC::CEventMouseDown(mousePos.x, mousePos.y, (NLMISC::TMouseButton)(NLMISC::leftButton | modifiers), this));
mousePos.x, mousePos.y,
(NLMISC::TMouseButton)(NLMISC::leftButton | modifiers), this));
} }
break; break;
case NSLeftMouseUp: case NSLeftMouseUp:
@ -319,15 +305,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
{ {
NLMISC::CEvent* nelEvent; NLMISC::CEvent* nelEvent;
// when emulating raw mode, send the delta in a CGDMouseMove event nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y, (NLMISC::TMouseButton)modifiers, this);
if(_emulateRawMode)
nelEvent = new NLMISC::CGDMouseMove(
this, NULL /* no mouse device */, event.deltaX, -event.deltaY);
// normally send position in a CEventMouseMove
else
nelEvent = new NLMISC::CEventMouseMove(
mousePos.x, mousePos.y, (NLMISC::TMouseButton)modifiers, this);
server->postEvent(nelEvent); server->postEvent(nelEvent);
break; break;
@ -336,15 +314,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
{ {
NLMISC::CEvent* nelEvent; NLMISC::CEvent* nelEvent;
// when emulating raw mode, send the delta in a CGDMouseMove event nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y, (NLMISC::TMouseButton)(NLMISC::leftButton | modifiers), this);
if(_emulateRawMode)
nelEvent = new NLMISC::CGDMouseMove(
this, NULL /* no mouse device */, event.deltaX, -event.deltaY);
// normally send position in a CEventMouseMove
else
nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y,
(NLMISC::TMouseButton)(NLMISC::leftButton | modifiers), this);
server->postEvent(nelEvent); server->postEvent(nelEvent);
break; break;
@ -353,15 +323,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
{ {
NLMISC::CEvent* nelEvent; NLMISC::CEvent* nelEvent;
// when emulating raw mode, send the delta in a CGDMouseMove event nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y, (NLMISC::TMouseButton)(NLMISC::rightButton | modifiers), this);
if(_emulateRawMode)
nelEvent = new NLMISC::CGDMouseMove(
this, NULL /* no mouse device */, event.deltaX, -event.deltaY);
// normally send position in a CEventMouseMove
else
nelEvent = new NLMISC::CEventMouseMove(mousePos.x, mousePos.y,
(NLMISC::TMouseButton)(NLMISC::rightButton | modifiers), this);
server->postEvent(nelEvent); server->postEvent(nelEvent);
break; break;
@ -434,12 +396,6 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
} }
} }
if(_emulateRawMode && _driver && (event.type == NSMouseMoved ||
event.type == NSLeftMouseDragged || event.type == NSRightMouseDragged))
{
_driver->setMousePos(0.5, 0.5);
}
return true; return true;
} }
@ -492,17 +448,4 @@ void CCocoaEventEmitter::submitEvents(CEventServer& server, bool /* allWins */)
_server = &server; _server = &server;
} }
void CCocoaEventEmitter::emulateMouseRawMode(bool enable)
{
_emulateRawMode = enable;
if(_emulateRawMode)
{
_setToEmulateRawMode = true;
if(_driver)
_driver->setMousePos(0.5, 0.5);
}
}
} }

@ -31,8 +31,6 @@ namespace NLMISC
class CCocoaEventEmitter : public IEventEmitter class CCocoaEventEmitter : public IEventEmitter
{ {
bool _emulateRawMode;
bool _setToEmulateRawMode;
bool _eventLoop; bool _eventLoop;
NL3D::IDriver* _driver; NL3D::IDriver* _driver;
CocoaOpenGLView* _glView; CocoaOpenGLView* _glView;
@ -42,8 +40,6 @@ class CCocoaEventEmitter : public IEventEmitter
public: public:
CCocoaEventEmitter() : CCocoaEventEmitter() :
_emulateRawMode(false),
_setToEmulateRawMode(false),
_driver(NULL), _driver(NULL),
_glView(nil), _glView(nil),
_server(NULL) { } _server(NULL) { }

@ -100,7 +100,6 @@ private:
std::map<TKey, bool> _PressedKeys; std::map<TKey, bool> _PressedKeys;
XIM _im; XIM _im;
XIC _ic; XIC _ic;
bool _emulateRawMode;
NL3D::IDriver* _driver; NL3D::IDriver* _driver;
CUnixEventServer _InternalServer; CUnixEventServer _InternalServer;
ucstring _CopiedString; ucstring _CopiedString;

@ -31,6 +31,7 @@ using namespace std;
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include FT_SYNTHESIS_H
// for freetype 2.0 // for freetype 2.0
#ifdef FTERRORS_H #ifdef FTERRORS_H
@ -171,7 +172,7 @@ void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &hei
height = _Face->glyph->metrics.height >> 6; height = _Face->glyph->metrics.height >> 6;
} }
uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex) uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex)
{ {
FT_Error error; FT_Error error;
@ -209,6 +210,16 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, uint32 &width, uint32 &
return NULL; return NULL;
} }
if (embolden)
{
FT_GlyphSlot_Embolden(_Face->glyph);
}
if (oblique)
{
FT_GlyphSlot_Oblique(_Face->glyph);
}
// convert to an anti-aliased bitmap // convert to an anti-aliased bitmap
error = FT_Render_Glyph (_Face->glyph, ft_render_mode_normal); error = FT_Render_Glyph (_Face->glyph, ft_render_mode_normal);
if (error) if (error)
@ -389,7 +400,7 @@ void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &hei
HFONT hFont = NULL; HFONT hFont = NULL;
uint32 CurrentFontSize = 0; uint32 CurrentFontSize = 0;
uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex) uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex)
{ {
/* FT_Error error; /* FT_Error error;

@ -64,6 +64,8 @@ void CFontManager::computeString (const std::string &s,
CFontGenerator *fontGen, CFontGenerator *fontGen,
const NLMISC::CRGBA &color, const NLMISC::CRGBA &color,
uint32 fontSize, uint32 fontSize,
bool embolden,
bool oblique,
IDriver *driver, IDriver *driver,
CComputedString &output, CComputedString &output,
bool keep800x600Ratio) bool keep800x600Ratio)
@ -71,7 +73,7 @@ void CFontManager::computeString (const std::string &s,
// static to avoid reallocation // static to avoid reallocation
static ucstring ucs; static ucstring ucs;
ucs= s; ucs= s;
computeString(ucs, fontGen, color, fontSize, driver, output, keep800x600Ratio); computeString(ucs, fontGen, color, fontSize, embolden, oblique, driver, output, keep800x600Ratio);
} }
@ -80,6 +82,8 @@ void CFontManager::computeString (const ucstring &s,
CFontGenerator *fontGen, CFontGenerator *fontGen,
const NLMISC::CRGBA &color, const NLMISC::CRGBA &color,
uint32 fontSize, uint32 fontSize,
bool embolden,
bool oblique,
IDriver *driver, IDriver *driver,
CComputedString &output, CComputedString &output,
bool keep800x600Ratio) bool keep800x600Ratio)
@ -147,6 +151,8 @@ void CFontManager::computeString (const ucstring &s,
k.Char = s[i]; k.Char = s[i];
k.FontGenerator = fontGen; k.FontGenerator = fontGen;
k.Size = fontSize; k.Size = fontSize;
k.Embolden = embolden;
k.Oblique = oblique;
CTextureFont::SLetterInfo *pLI = pTexFont->getLetterInfo (k); CTextureFont::SLetterInfo *pLI = pTexFont->getLetterInfo (k);
if(pLI != NULL) if(pLI != NULL)
{ {
@ -227,6 +233,8 @@ void CFontManager::computeStringInfo ( const ucstring &s,
CFontGenerator *fontGen, CFontGenerator *fontGen,
const NLMISC::CRGBA &color, const NLMISC::CRGBA &color,
uint32 fontSize, uint32 fontSize,
bool embolden,
bool oblique,
IDriver *driver, IDriver *driver,
CComputedString &output, CComputedString &output,
bool keep800x600Ratio ) bool keep800x600Ratio )
@ -259,6 +267,8 @@ void CFontManager::computeStringInfo ( const ucstring &s,
k.Char = s[i]; k.Char = s[i];
k.FontGenerator = fontGen; k.FontGenerator = fontGen;
k.Size = fontSize; k.Size = fontSize;
k.Embolden = embolden;
k.Oblique = oblique;
pLI = pTexFont->getLetterInfo (k); pLI = pTexFont->getLetterInfo (k);
if(pLI != NULL) if(pLI != NULL)
{ {

@ -583,7 +583,6 @@ void CLandscape::setDriver(IDriver *drv)
// Does the driver has sufficient requirements for Vegetable??? // Does the driver has sufficient requirements for Vegetable???
// only if VP supported by GPU, and Only if max vertices allowed. // only if VP supported by GPU, and Only if max vertices allowed.
_DriverOkForVegetable = _VertexShaderOk && (_Driver->getMaxVerticesByVertexBufferHard()>=(uint)NL3D_LANDSCAPE_VEGETABLE_MAX_AGP_VERTEX_MAX); _DriverOkForVegetable = _VertexShaderOk && (_Driver->getMaxVerticesByVertexBufferHard()>=(uint)NL3D_LANDSCAPE_VEGETABLE_MAX_AGP_VERTEX_MAX);
} }
} }

@ -611,7 +611,6 @@ void CLandscapeVBAllocator::setupVBFormatAndVertexProgram(bool withVertexProgr
nlverify(_Driver->compileVertexProgram(_VertexProgram[1])); nlverify(_Driver->compileVertexProgram(_VertexProgram[1]));
} }
} }
} }

@ -392,7 +392,6 @@ bool CMeshVPWindTree::begin(IDriver *driver, CScene *scene, CMeshBaseInstance *m
sint numPls= renderTrav->getNumVPLights()-1; sint numPls= renderTrav->getNumVPLights()-1;
clamp(numPls, 0, CRenderTrav::MaxVPLight-1); clamp(numPls, 0, CRenderTrav::MaxVPLight-1);
// Enable normalize only if requested by user. Because lighting don't manage correct "scale lighting" // Enable normalize only if requested by user. Because lighting don't manage correct "scale lighting"
uint idVP= (SpecularLighting?2:0) + (driver->isForceNormalize()?1:0) ; uint idVP= (SpecularLighting?2:0) + (driver->isForceNormalize()?1:0) ;
// correct VP id for correct unmber of pls. // correct VP id for correct unmber of pls.

@ -277,6 +277,8 @@ void CPSUtil::print(IDriver *driver, const std::string &text, CFontGenerator &fg
&fg, &fg,
col, col,
16, 16,
false,
false,
driver, driver,
cptedString); cptedString);

@ -592,11 +592,9 @@ void CScene::renderPart(UScene::TRenderPart rp, bool doHrcPass, bool doTrav, boo
// //
nlassert(CurrentCamera); nlassert(CurrentCamera);
// update models. // update models.
updateModels(); updateModels();
// Use the camera to setup Clip / Render pass. // Use the camera to setup Clip / Render pass.
float left, right, bottom, top, znear, zfar; float left, right, bottom, top, znear, zfar;
CurrentCamera->getFrustum(left, right, bottom, top, znear, zfar); CurrentCamera->getFrustum(left, right, bottom, top, znear, zfar);

@ -31,6 +31,8 @@ CTextContext::CTextContext()
_FontGen = NULL; _FontGen = NULL;
_FontSize = 12; _FontSize = 12;
_Embolden = false;
_Oblique = false;
_Color = NLMISC::CRGBA(0,0,0); _Color = NLMISC::CRGBA(0,0,0);
@ -81,7 +83,7 @@ uint32 CTextContext::textPush (const char *format, ...)
// compute the string. // compute the string.
uint32 index = _CacheFreePlaces[_CacheNbFreePlaces-1]; uint32 index = _CacheFreePlaces[_CacheNbFreePlaces-1];
CComputedString &strToFill = _CacheStrings[index]; CComputedString &strToFill = _CacheStrings[index];
_FontManager->computeString (str, _FontGen, _Color, _FontSize, _Driver, strToFill, _Keep800x600Ratio); _FontManager->computeString (str, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio);
_CacheNbFreePlaces--; _CacheNbFreePlaces--;
@ -109,7 +111,7 @@ uint32 CTextContext::textPush (const ucstring &str)
nlassert (index < _CacheStrings.size()); nlassert (index < _CacheStrings.size());
CComputedString &strToFill = _CacheStrings[index]; CComputedString &strToFill = _CacheStrings[index];
_FontManager->computeString (str, _FontGen, _Color _FontManager->computeString (str, _FontGen, _Color
, _FontSize, _Driver, strToFill, _Keep800x600Ratio); , _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio);
_CacheNbFreePlaces--; _CacheNbFreePlaces--;

@ -100,6 +100,30 @@ uint32 CTextContextUser::getFontSize() const
return _TextContext.getFontSize(); return _TextContext.getFontSize();
} }
void CTextContextUser::setEmbolden(bool b)
{
H_AUTO2;
_TextContext.setEmbolden(b);
}
bool CTextContextUser::getEmbolden() const
{
H_AUTO2;
return _TextContext.getEmbolden();
}
void CTextContextUser::setOblique(bool b)
{
H_AUTO2;
_TextContext.setOblique(b);
}
bool CTextContextUser::getOblique() const
{
H_AUTO2;
return _TextContext.getOblique();
}
void CTextContextUser::setHotSpot(THotSpot hotSpot) void CTextContextUser::setHotSpot(THotSpot hotSpot)
{ {
H_AUTO2; H_AUTO2;

@ -47,11 +47,14 @@ const int NbLine[TEXTUREFONT_NBCATEGORY] = { 4, 6, 4, 1 }; // Based on textsize
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
inline uint32 CTextureFont::SLetterKey::getVal() inline uint32 CTextureFont::SLetterKey::getVal()
{ {
// this limits Size to 6bits
// Large sizes already render wrong when many
// different glyphs are used due to limited texture atlas
uint8 eb = ((uint)Embolden) + ((uint)Oblique << 1);
if (FontGenerator == NULL) if (FontGenerator == NULL)
return Char + ((Size&255)<<16); return Char + ((Size&255)<<16) + (eb << 22);
else else
return Char + ((Size&255)<<16) + ((FontGenerator->getUID()&0xFF)<<24); return Char + ((Size&255)<<16) + (eb << 22) + ((FontGenerator->getUID()&0xFF)<<24);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -86,6 +89,8 @@ CTextureFont::CTextureFont()
rLetter.Char = 0xffff; rLetter.Char = 0xffff;
rLetter.FontGenerator = NULL; rLetter.FontGenerator = NULL;
rLetter.Size= 0; rLetter.Size= 0;
rLetter.Embolden = false;
rLetter.Oblique = false;
// The less recently used infos // The less recently used infos
if (j < Letters[i].size()-1) if (j < Letters[i].size()-1)
@ -164,7 +169,7 @@ void CTextureFont::rebuildLetter (sint cat, sint x, sint y)
sint posy = catTopY + y * Categories[cat]; sint posy = catTopY + y * Categories[cat];
uint32 pitch = 0; uint32 pitch = 0;
uint8 *bitmap = rLetter.FontGenerator->getBitmap ( rLetter.Char, rLetter.Size, uint8 *bitmap = rLetter.FontGenerator->getBitmap ( rLetter.Char, rLetter.Size, rLetter.Embolden, rLetter.Oblique,
rLetter.CharWidth, rLetter.CharHeight, rLetter.CharWidth, rLetter.CharHeight,
pitch, rLetter.Left, rLetter.Top, pitch, rLetter.Left, rLetter.Top,
rLetter.AdvX, rLetter.GlyphIndex ); rLetter.AdvX, rLetter.GlyphIndex );
@ -303,7 +308,7 @@ CTextureFont::SLetterInfo* CTextureFont::getLetterInfo (SLetterKey& k)
// \todo mat : Temp !!! Try to use freetype cache // \todo mat : Temp !!! Try to use freetype cache
uint32 nPitch, nGlyphIndex; uint32 nPitch, nGlyphIndex;
sint32 nLeft, nTop, nAdvX; sint32 nLeft, nTop, nAdvX;
k.FontGenerator->getBitmap (k.Char, k.Size, width, height, nPitch, nLeft, nTop, k.FontGenerator->getBitmap (k.Char, k.Size, k.Embolden, k.Oblique, width, height, nPitch, nLeft, nTop,
nAdvX, nGlyphIndex ); nAdvX, nGlyphIndex );
// Add 1 pixel space for black border to get correct category // Add 1 pixel space for black border to get correct category
@ -323,6 +328,8 @@ CTextureFont::SLetterInfo* CTextureFont::getLetterInfo (SLetterKey& k)
k2.Char = Back[cat]->Char; k2.Char = Back[cat]->Char;
k2.FontGenerator = Back[cat]->FontGenerator; k2.FontGenerator = Back[cat]->FontGenerator;
k2.Size = Back[cat]->Size; k2.Size = Back[cat]->Size;
k2.Embolden = Back[cat]->Embolden;
k2.Oblique = Back[cat]->Oblique;
itAccel = Accel.find (k2.getVal()); itAccel = Accel.find (k2.getVal());
if (itAccel != Accel.end()) if (itAccel != Accel.end())
@ -336,6 +343,8 @@ CTextureFont::SLetterInfo* CTextureFont::getLetterInfo (SLetterKey& k)
Back[cat]->Char = k.Char; Back[cat]->Char = k.Char;
Back[cat]->FontGenerator = k.FontGenerator; Back[cat]->FontGenerator = k.FontGenerator;
Back[cat]->Size = k.Size; Back[cat]->Size = k.Size;
Back[cat]->Embolden = k.Embolden;
Back[cat]->Oblique = k.Oblique;
Back[cat]->CharWidth = width; Back[cat]->CharWidth = width;
Back[cat]->CharHeight = height; Back[cat]->CharHeight = height;
Back[cat]->Top = nTop; Back[cat]->Top = nTop;

@ -44,19 +44,19 @@ NLMISC_COMMAND(setWaterPool, "Setup a pool of water in the water pool manager",
} }
if (numArgs == 3) if (numArgs == 3)
{ {
whmb.FilterWeight = ::atof(args[2].c_str()); NLMISC::fromString(args[2], whmb.FilterWeight);
} }
if (numArgs == 4) if (numArgs == 4)
{ {
whmb.UnitSize = ::atof(args[3].c_str()); NLMISC::fromString(args[3], whmb.UnitSize);
} }
if (numArgs == 5) if (numArgs == 5)
{ {
whmb.WaveIntensity = ::atof(args[4].c_str()); NLMISC::fromString(args[4], whmb.WaveIntensity);
} }
if (numArgs == 4) if (numArgs == 4)
{ {
whmb.WavePeriod = ::atof(args[5].c_str()); NLMISC::fromString(args[5], whmb.WavePeriod);
} }
// create the water pool // create the water pool
GetWaterPoolManager().createWaterPool(whmb); GetWaterPoolManager().createWaterPool(whmb);

@ -73,7 +73,7 @@ pair<string, uint32> CZoneSearch::getZoneName(uint x, uint y, uint cx, uint cy)
sprintf(name, "%d_%c%c.zonel", zoneY, firstLetter, secondLetter); sprintf(name, "%d_%c%c.zonel", zoneY, firstLetter, secondLetter);
return make_pair<string, uint32>(string(name), distance); return std::pair<string, uint32>(string(name), distance);
} }

@ -6,7 +6,7 @@ SOURCE_GROUP("src" FILES ${SRC})
NL_TARGET_LIB(nelgui ${SRC} ${HEADERS}) NL_TARGET_LIB(nelgui ${SRC} ${HEADERS})
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${LIBWWW_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${LIBWWW_INCLUDE_DIR} ${CURL_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${LIBXML2_LIBRARIES} ${LIBWWW_LIBRARIES} ${CURL_LIBRARIES}) TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${LIBXML2_LIBRARIES} ${LIBWWW_LIBRARIES} ${CURL_LIBRARIES})
SET_TARGET_PROPERTIES(nelgui PROPERTIES LINK_INTERFACE_LIBRARIES "") SET_TARGET_PROPERTIES(nelgui PROPERTIES LINK_INTERFACE_LIBRARIES "")

@ -701,6 +701,11 @@ namespace NLGUI
//pIM->submitEvent ("button_click:"+getId()); //pIM->submitEvent ("button_click:"+getId());
} }
*/ */
// top-right corner is EventX=0, EventY=0
_EventX = eventDesc.getX() - _XReal;
_EventY = (_YReal + _HReal) - eventDesc.getY();
runLeftClickAction(); runLeftClickAction();
if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example) if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example)

@ -519,17 +519,17 @@ namespace NLGUI
// Read Action handlers // Read Action handlers
prop = (char*) xmlGetProp( node, (xmlChar*)"onscroll" ); prop = (char*) xmlGetProp( node, (xmlChar*)"onscroll" );
if (prop) _AHOnScroll = NLMISC::strlwr(prop); if (prop) _AHOnScroll = NLMISC::strlwr(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"params" ); prop = (char*) xmlGetProp( node, (xmlChar*)"params" );
if (prop) _AHOnScrollParams = string((const char*)prop); if (prop) _AHOnScrollParams = string((const char*)prop);
// //
prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollend" ); prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollend" );
if (prop) _AHOnScrollEnd = NLMISC::strlwr(prop); if (prop) _AHOnScrollEnd = NLMISC::strlwr(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"end_params" ); prop = (char*) xmlGetProp( node, (xmlChar*)"end_params" );
if (prop) _AHOnScrollEndParams = string((const char*)prop); if (prop) _AHOnScrollEndParams = string((const char*)prop);
// //
prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollcancel" ); prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollcancel" );
if (prop) _AHOnScrollCancel = NLMISC::strlwr(prop); if (prop) _AHOnScrollCancel = NLMISC::strlwr(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"cancel_params" ); prop = (char*) xmlGetProp( node, (xmlChar*)"cancel_params" );
if (prop) _AHOnScrollCancelParams = string((const char*)prop); if (prop) _AHOnScrollCancelParams = string((const char*)prop);
@ -538,9 +538,9 @@ namespace NLGUI
prop = (char*) xmlGetProp( node, (xmlChar*)"target" ); prop = (char*) xmlGetProp( node, (xmlChar*)"target" );
if (prop) if (prop)
{ {
CInterfaceGroup *group = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(prop)); CInterfaceGroup *group = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(prop.str()));
if(group == NULL) if(group == NULL)
group = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(this->getId(), prop)); group = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(this->getId(), prop.str()));
if(group != NULL) if(group != NULL)
setTarget (group); setTarget (group);

@ -268,7 +268,7 @@ namespace NLGUI
void CDBGroupComboBox::addText(const ucstring &text) void CDBGroupComboBox::addText(const ucstring &text)
{ {
dirt(); dirt();
_Texts.push_back(make_pair(_Texts.size(), text)); _Texts.push_back(make_pair((uint)_Texts.size(), text));
_Textures.push_back(std::string()); _Textures.push_back(std::string());
} }
@ -330,7 +330,7 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
const uint &CDBGroupComboBox::getTextId(uint i) const uint CDBGroupComboBox::getTextId(uint i) const
{ {
static uint null = 0; static uint null = 0;
if(i<_Texts.size()) if(i<_Texts.size())

@ -999,7 +999,8 @@ namespace NLGUI
break; break;
// OTHER // OTHER
default: default:
if ((rEDK.getChar() == KeyRETURN) && !_WantReturn) bool isKeyRETURN = !rEDK.getKeyCtrl() && rEDK.getChar() == KeyRETURN;
if (isKeyRETURN && !_WantReturn)
{ {
// update historic. // update historic.
if(_MaxHistoric) if(_MaxHistoric)
@ -1030,9 +1031,9 @@ namespace NLGUI
// If the char is not alphanumeric -> return. // If the char is not alphanumeric -> return.
// if(!isalnum(ec.Char)) // if(!isalnum(ec.Char))
// return // return
if( (rEDK.getChar()>=32) || (rEDK.getChar() == KeyRETURN) ) if( (rEDK.getChar()>=32) || isKeyRETURN )
{ {
if (rEDK.getChar() == KeyRETURN) if (isKeyRETURN)
{ {
ucstring copyStr= _InputString; ucstring copyStr= _InputString;
if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn) if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn)
@ -1049,7 +1050,7 @@ namespace NLGUI
cutSelection(); cutSelection();
} }
ucchar c = (rEDK.getChar() == KeyRETURN)?'\n':rEDK.getChar(); ucchar c = isKeyRETURN ? '\n' : rEDK.getChar();
if (isFiltered(c)) return; if (isFiltered(c)) return;
switch(_EntryType) switch(_EntryType)
{ {
@ -1128,7 +1129,7 @@ namespace NLGUI
++ _CursorPos; ++ _CursorPos;
triggerOnChangeAH(); triggerOnChangeAH();
} }
if (rEDK.getChar() == KeyRETURN) if (isKeyRETURN)
{ {
CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams);
} }

@ -485,7 +485,7 @@ namespace NLGUI
string fullstyle = style[1]; string fullstyle = style[1];
for (uint j=2; j < style.size(); j++) for (uint j=2; j < style.size(); j++)
fullstyle += ":"+style[j]; fullstyle += ":"+style[j];
styles[trim(style[0])] = fullstyle; styles[trim(style[0])] = trim(fullstyle);
} }
} }
@ -894,7 +894,20 @@ namespace NLGUI
switch(element_number) switch(element_number)
{ {
case HTML_A: case HTML_A:
_TextColor.push_back(LinkColor); {
CStyleParams style;
style.FontSize = getFontSize();
style.TextColor = LinkColor;
style.Underlined = true;
style.StrikeThrough = getFontStrikeThrough();
if (present[HTML_A_STYLE] && value[HTML_A_STYLE])
getStyleParams(value[HTML_A_STYLE], style);
_FontSize.push_back(style.FontSize);
_TextColor.push_back(style.TextColor);
_FontUnderlined.push_back(style.Underlined);
_FontStrikeThrough.push_back(style.StrikeThrough);
_GlobalColor.push_back(LinkColorGlobalColor); _GlobalColor.push_back(LinkColorGlobalColor);
_A.push_back(true); _A.push_back(true);
@ -903,6 +916,7 @@ namespace NLGUI
if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS]) if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS])
_LinkClass.push_back(value[MY_HTML_A_CLASS]); _LinkClass.push_back(value[MY_HTML_A_CLASS]);
}
break; break;
case HTML_DIV: case HTML_DIV:
@ -1217,7 +1231,7 @@ namespace NLGUI
normal = value[MY_HTML_INPUT_SRC]; normal = value[MY_HTML_INPUT_SRC];
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name; string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=image";
// Add the ctrl button // Add the ctrl button
addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over, addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over,
@ -1241,7 +1255,15 @@ namespace NLGUI
text = value[MY_HTML_INPUT_VALUE]; text = value[MY_HTML_INPUT_VALUE];
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name; string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=submit";
if (text.size() > 0)
{
// escape AH param separator
string tmp = text;
while(NLMISC::strFindReplace(tmp, "|", "&#124;"))
;
param = param + "|submit_button_value=" + tmp;
}
// Add the ctrl button // Add the ctrl button
if (!_Paragraph) if (!_Paragraph)
@ -1626,6 +1648,28 @@ namespace NLGUI
_Object = true; _Object = true;
break; break;
case HTML_SPAN:
{
CStyleParams style;
style.TextColor = getTextColor();
style.FontSize = getFontSize();
style.FontWeight = getFontWeight();
style.FontOblique = getFontOblique();
style.Underlined = getFontUnderlined();
style.StrikeThrough = getFontStrikeThrough();
if (present[MY_HTML_SPAN_STYLE] && value[MY_HTML_SPAN_STYLE])
getStyleParams(value[MY_HTML_SPAN_STYLE], style);
_TextColor.push_back(style.TextColor);
_FontSize.push_back(style.FontSize);
_FontWeight.push_back(style.FontWeight);
_FontOblique.push_back(style.FontOblique);
_FontUnderlined.push_back(style.Underlined);
_FontStrikeThrough.push_back(style.StrikeThrough);
}
break;
case HTML_STYLE: case HTML_STYLE:
_IgnoreText = true; _IgnoreText = true;
break; break;
@ -1647,7 +1691,10 @@ namespace NLGUI
popIfNotEmpty (_FontSize); popIfNotEmpty (_FontSize);
break; break;
case HTML_A: case HTML_A:
popIfNotEmpty (_FontSize);
popIfNotEmpty (_TextColor); popIfNotEmpty (_TextColor);
popIfNotEmpty (_FontUnderlined);
popIfNotEmpty (_FontStrikeThrough);
popIfNotEmpty (_GlobalColor); popIfNotEmpty (_GlobalColor);
popIfNotEmpty (_A); popIfNotEmpty (_A);
popIfNotEmpty (_Link); popIfNotEmpty (_Link);
@ -1755,6 +1802,14 @@ namespace NLGUI
popIfNotEmpty (_UL); popIfNotEmpty (_UL);
} }
break; break;
case HTML_SPAN:
popIfNotEmpty (_FontSize);
popIfNotEmpty (_FontWeight);
popIfNotEmpty (_FontOblique);
popIfNotEmpty (_TextColor);
popIfNotEmpty (_FontUnderlined);
popIfNotEmpty (_FontStrikeThrough);
break;
case HTML_STYLE: case HTML_STYLE:
_IgnoreText = false; _IgnoreText = false;
break; break;
@ -3069,6 +3124,7 @@ namespace NLGUI
// Text added ? // Text added ?
bool added = false; bool added = false;
bool embolden = getFontWeight() >= 700;
// Number of child in this paragraph // Number of child in this paragraph
if (_CurrentViewLink) if (_CurrentViewLink)
@ -3078,6 +3134,10 @@ namespace NLGUI
if (!skipLine && if (!skipLine &&
(getTextColor() == _CurrentViewLink->getColor()) && (getTextColor() == _CurrentViewLink->getColor()) &&
(getFontSize() == (uint)_CurrentViewLink->getFontSize()) && (getFontSize() == (uint)_CurrentViewLink->getFontSize()) &&
(getFontUnderlined() == _CurrentViewLink->getUnderlined()) &&
(getFontStrikeThrough() == _CurrentViewLink->getStrikeThrough()) &&
(embolden == _CurrentViewLink->getEmbolden()) &&
(getFontOblique() == _CurrentViewLink->getOblique()) &&
(getLink() == _CurrentViewLink->Link) && (getLink() == _CurrentViewLink->Link) &&
(getGlobalColor() == _CurrentViewLink->getModulateGlobalColor())) (getGlobalColor() == _CurrentViewLink->getModulateGlobalColor()))
{ {
@ -3133,12 +3193,15 @@ namespace NLGUI
if (!newLink->Link.empty()) if (!newLink->Link.empty())
{ {
newLink->setHTMLView (this); newLink->setHTMLView (this);
newLink->setUnderlined (true);
} }
} }
newLink->setText(tmpStr); newLink->setText(tmpStr);
newLink->setColor(getTextColor()); newLink->setColor(getTextColor());
newLink->setFontSize(getFontSize()); newLink->setFontSize(getFontSize());
newLink->setEmbolden(embolden);
newLink->setOblique(getFontOblique());
newLink->setUnderlined(getFontUnderlined());
newLink->setStrikeThrough(getFontStrikeThrough());
newLink->setMultiLineSpace((uint)((float)getFontSize()*LineSpaceFontFactor)); newLink->setMultiLineSpace((uint)((float)getFontSize()*LineSpaceFontFactor));
newLink->setMultiLine(true); newLink->setMultiLine(true);
newLink->setModulateGlobalColor(getGlobalColor()); newLink->setModulateGlobalColor(getGlobalColor());
@ -3414,6 +3477,10 @@ namespace NLGUI
_TextColor.clear(); _TextColor.clear();
_GlobalColor.clear(); _GlobalColor.clear();
_FontSize.clear(); _FontSize.clear();
_FontWeight.clear();
_FontOblique.clear();
_FontUnderlined.clear();
_FontStrikeThrough.clear();
_Indent = 0; _Indent = 0;
_LI = false; _LI = false;
_UL.clear(); _UL.clear();
@ -3638,14 +3705,18 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupHTML::submitForm (uint formId, const char *submitButtonName) void CGroupHTML::submitForm (uint formId, const char *submitButtonType, const char *submitButtonName, const char *submitButtonValue, sint32 x, sint32 y)
{ {
// Form id valid ? // Form id valid ?
if (formId < _Forms.size()) if (formId < _Forms.size())
{ {
_PostNextTime = true; _PostNextTime = true;
_PostFormId = formId; _PostFormId = formId;
_PostFormSubmitType = submitButtonType;
_PostFormSubmitButton = submitButtonName; _PostFormSubmitButton = submitButtonName;
_PostFormSubmitValue = submitButtonValue;
_PostFormSubmitX = x;
_PostFormSubmitY = y;
} }
} }
@ -3918,9 +3989,22 @@ namespace NLGUI
} }
} }
if (_PostFormSubmitType == "image")
{
// Add the button coordinates // Add the button coordinates
HTParseFormInput(formfields, (_PostFormSubmitButton + "_x=0").c_str()); if (_PostFormSubmitButton.find_first_of("[") == string::npos)
HTParseFormInput(formfields, (_PostFormSubmitButton + "_y=0").c_str()); {
HTParseFormInput(formfields, (_PostFormSubmitButton + "_x=" + NLMISC::toString(_PostFormSubmitX)).c_str());
HTParseFormInput(formfields, (_PostFormSubmitButton + "_y=" + NLMISC::toString(_PostFormSubmitY)).c_str());
}
else
{
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + NLMISC::toString(_PostFormSubmitX)).c_str());
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + NLMISC::toString(_PostFormSubmitY)).c_str());
}
}
else
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + _PostFormSubmitValue).c_str());
// Add custom params // Add custom params
addHTTPPostParams(formfields, _TrustedDomain); addHTTPPostParams(formfields, _TrustedDomain);
@ -4565,5 +4649,84 @@ namespace NLGUI
return result; return result;
} }
// ***************************************************************************
// CGroupHTML::CStyleParams style;
// style.FontSize; // font-size: 10px;
// style.TextColor; // color: #ABCDEF;
// style.Underlined; // text-decoration: underline; text-decoration-line: underline;
// style.StrikeThrough; // text-decoration: line-through; text-decoration-line: line-through;
void CGroupHTML::getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit)
{
TStyle styles = parseStyle(styleString);
TStyle::iterator it;
for (it=styles.begin(); it != styles.end(); ++it)
{
if (it->first == "font-size")
{
float tmp;
sint size = 0;
getPercentage (size, tmp, it->second.c_str());
if (size > 0)
style.FontSize = size;
}
else
if (it->first == "font-style")
{
if (it->second == "italic" || it->second == "oblique")
style.FontOblique = true;
}
else
if (it->first == "font-weight")
{
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
uint weight = 400;
if (it->second == "normal")
weight = 400;
else
if (it->second == "bold")
weight = 700;
else
if (it->second == "lighter")
{
const uint lighter[] = {100, 100, 100, 100, 100, 400, 400, 700, 700};
int index = getFontWeight() / 100 - 1;
clamp(index, 1, 9);
weight = lighter[index-1];
}
else
if (it->second == "bolder")
{
const uint bolder[] = {400, 400, 400, 700, 700, 900, 900, 900, 900};
uint index = getFontWeight() / 100 + 1;
clamp(index, 1, 9);
weight = bolder[index-1];
}
else
if (fromString(it->second, weight))
{
weight = (weight / 100);
clamp(weight, 1, 9);
weight *= 100;
}
style.FontWeight = weight;
}
else
if (it->first == "color")
scanHTMLColor(it->second.c_str(), style.TextColor);
else
if (it->first == "text-decoration" || it->first == "text-decoration-line")
{
std::string prop(strlwr(it->second));
style.Underlined = (prop.find("underline") != std::string::npos);
style.StrikeThrough = (prop.find("line-through") != std::string::npos);
}
}
if (inherit)
{
style.Underlined = getFontUnderlined() || style.Underlined;
style.StrikeThrough = getFontStrikeThrough() || style.StrikeThrough;
}
}
} }

@ -2200,7 +2200,7 @@ namespace NLGUI
if( editorMode ) if( editorMode )
_Extends = std::string( (const char*)prop ); _Extends = std::string( (const char*)prop );
CGroupMenu *gm = dynamic_cast<CGroupMenu *>(CWidgetManager::getInstance()->getElementFromId(prop)); CGroupMenu *gm = dynamic_cast<CGroupMenu *>(CWidgetManager::getInstance()->getElementFromId(prop.str()));
if (!gm) if (!gm)
{ {
gm = dynamic_cast<CGroupMenu *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:" + std::string((const char*)prop))); gm = dynamic_cast<CGroupMenu *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:" + std::string((const char*)prop)));

@ -55,7 +55,7 @@ namespace NLGUI
if (ptr) _Dynamic = CInterfaceElement::convertBool (ptr); if (ptr) _Dynamic = CInterfaceElement::convertBool (ptr);
ptr = xmlGetProp (cur, (xmlChar*)"type"); ptr = xmlGetProp (cur, (xmlChar*)"type");
string sTmp = ptr; string sTmp = ptr.str();
sTmp = strlwr(sTmp); sTmp = strlwr(sTmp);
if (sTmp == "linear") if (sTmp == "linear")
_Type = Track_Linear; _Type = Track_Linear;
@ -74,7 +74,7 @@ namespace NLGUI
} }
// //
if (!CInterfaceLink::splitLinkTargets (ptr, parentGroup, _Targets)) if (!CInterfaceLink::splitLinkTargets (ptr.str(), parentGroup, _Targets))
{ {
nlwarning ("no target for track"); nlwarning ("no target for track");
return false; return false;
@ -194,7 +194,7 @@ namespace NLGUI
fromString((const char*)time, fAnimTime); fromString((const char*)time, fAnimTime);
TAnimationTime animTime = fAnimTime * CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat(); TAnimationTime animTime = fAnimTime * CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat();
double animValue; double animValue;
fromString(value, animValue); fromString(value.str(), animValue);
// Depending on the type of the track add the key // Depending on the type of the track add the key
switch(_Type) switch(_Type)

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

@ -664,7 +664,7 @@ namespace NLGUI
//if it begins with a #, it is a reference in the instance attribute //if it begins with a #, it is a reference in the instance attribute
if (strchr(ptr, '#') != NULL) if (strchr(ptr, '#') != NULL)
{ {
string LastProp = ptr; string LastProp = ptr.str();
string NewProp =""; string NewProp ="";
string RepProp; string RepProp;
@ -796,7 +796,7 @@ namespace NLGUI
return false; return false;
} }
sint32 size; sint32 size;
fromString(cSize, size); fromString(cSize.str(), size);
if (size <= 0) if (size <= 0)
{ {
// todo hulud interface syntax error // todo hulud interface syntax error
@ -929,7 +929,7 @@ namespace NLGUI
nlwarning("<CInterfaceParser::parseLink> Can't read the expression for a link node"); nlwarning("<CInterfaceParser::parseLink> Can't read the expression for a link node");
return false; return false;
} }
std::string expr = ptr; std::string expr = ptr.str();
std::vector<CInterfaceLink::CTargetInfo> targets; std::vector<CInterfaceLink::CTargetInfo> targets;
@ -1119,13 +1119,13 @@ namespace NLGUI
nlinfo ("options has no name"); nlinfo ("options has no name");
return false; return false;
} }
string optionsName = ptr; string optionsName = ptr.str();
// herit if possible // herit if possible
ptr = (char*) xmlGetProp( cur, (xmlChar*)"herit" ); ptr = (char*) xmlGetProp( cur, (xmlChar*)"herit" );
if (ptr) if (ptr)
{ {
string optionsParentName = ptr; string optionsParentName = ptr.str();
CInterfaceOptions *io = wm->getOptions( optionsParentName ); CInterfaceOptions *io = wm->getOptions( optionsParentName );
if( io != NULL ) if( io != NULL )
options->copyBasicMap( *io ); options->copyBasicMap( *io );
@ -1771,7 +1771,7 @@ namespace NLGUI
{ {
CInterfaceExprValue res; CInterfaceExprValue res;
if (CInterfaceExpr::eval(ptrVal2, res)) if (CInterfaceExpr::eval(ptrVal2.str(), res))
{ {
if (!res.toString()) if (!res.toString())
{ {
@ -1807,7 +1807,7 @@ namespace NLGUI
nlwarning ("no id in a procedure"); nlwarning ("no id in a procedure");
return false; return false;
} }
string procId= ptr; string procId= ptr.str();
if (_ProcedureMap.find(procId) != _ProcedureMap.end()) if (_ProcedureMap.find(procId) != _ProcedureMap.end())
{ {
@ -2171,7 +2171,7 @@ namespace NLGUI
//get the property value //get the property value
ptr = (char*)xmlGetProp( cur, props->name); ptr = (char*)xmlGetProp( cur, props->name);
nlassert(ptr); nlassert(ptr);
string propVal= ptr; string propVal= ptr.str();
string newPropVal; string newPropVal;
// solve define of this prop // solve define of this prop
@ -2328,7 +2328,7 @@ namespace NLGUI
nlinfo ("anim has no id"); nlinfo ("anim has no id");
return false; return false;
} }
string animId = ptr; string animId = ptr.str();
pAnim = new CInterfaceAnim; pAnim = new CInterfaceAnim;
if (pAnim->parse (cur, parentGroup)) if (pAnim->parse (cur, parentGroup))

@ -233,6 +233,14 @@ namespace NLGUI
{ 0 } { 0 }
}; };
HTAttr span_attr[] =
{
HTML_ATTR(SPAN,CLASS),
HTML_ATTR(SPAN,ID),
HTML_ATTR(SPAN,STYLE),
{ 0 }
};
// *************************************************************************** // ***************************************************************************
void _VerifyLibWWW(const char *function, bool ok, const char *file, int line) void _VerifyLibWWW(const char *function, bool ok, const char *file, int line)
@ -699,6 +707,8 @@ namespace NLGUI
HTML_DTD->tags[HTML_I].number_of_attributes = 0; HTML_DTD->tags[HTML_I].number_of_attributes = 0;
HTML_DTD->tags[HTML_DIV].attributes = div_attr; 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_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;
// Set a request timeout // Set a request timeout
// HTHost_setEventTimeout (30000); // HTHost_setEventTimeout (30000);

@ -44,6 +44,7 @@ namespace NLGUI
{ {
_CaseMode = CaseNormal; _CaseMode = CaseNormal;
_Underlined = false; _Underlined = false;
_StrikeThrough = false;
_ContinuousUpdate = false; _ContinuousUpdate = false;
_Active = true; _Active = true;
_X = 0; _X = 0;
@ -58,6 +59,8 @@ namespace NLGUI
_FontSize = 12 + _FontSize = 12 +
CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32(); CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32();
_Embolden = false;
_Oblique = false;
_Color = CRGBA(255,255,255,255); _Color = CRGBA(255,255,255,255);
_Shadow = false; _Shadow = false;
_ShadowOutline = false; _ShadowOutline = false;
@ -157,6 +160,10 @@ namespace NLGUI
_PosRef = vt._PosRef; _PosRef = vt._PosRef;
_FontSize = vt._FontSize; _FontSize = vt._FontSize;
_Embolden = vt._Embolden;
_Oblique = vt._Oblique;
_Underlined = vt._Underlined;
_StrikeThrough = vt._StrikeThrough;
_Color = vt._Color; _Color = vt._Color;
_Shadow = vt._Shadow; _Shadow = vt._Shadow;
_ShadowOutline = vt._ShadowOutline; _ShadowOutline = vt._ShadowOutline;
@ -221,6 +228,21 @@ namespace NLGUI
); );
} }
else else
if( name == "fontweight" )
{
if (_Embolden)
return "bold";
return "normal";
}
if( name == "fontstyle" )
{
if (_Oblique)
return "oblique";
return "normal";
}
else
if( name == "shadow" ) if( name == "shadow" )
{ {
return toString( _Shadow ); return toString( _Shadow );
@ -286,6 +308,11 @@ namespace NLGUI
return toString( _Underlined ); return toString( _Underlined );
} }
else else
if( name == "strikthrough" )
{
return toString( _StrikeThrough );
}
else
if( name == "case_mode" ) if( name == "case_mode" )
{ {
return toString( uint32( _CaseMode ) ); return toString( uint32( _CaseMode ) );
@ -358,6 +385,20 @@ namespace NLGUI
return true; return true;
} }
else else
if( name == "fontweight" )
{
if (value == "bold")
_Embolden = true;
return true;
}
if( name == "fontstyle" )
{
if( value == "oblique" )
_Oblique = true;
return true;
}
else
if( name == "shadow" ) if( name == "shadow" )
{ {
bool b; bool b;
@ -444,6 +485,14 @@ namespace NLGUI
return true; return true;
} }
else else
if( name == "strikethrough" )
{
bool b;
if( fromString( value, b ) )
_StrikeThrough = b;
return true;
}
else
if( name == "case_mode" ) if( name == "case_mode" )
{ {
uint32 i; uint32 i;
@ -533,6 +582,16 @@ namespace NLGUI
_FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32() _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32()
).c_str() ); ).c_str() );
std::string fontweight("normal");
if (_Embolden)
fontweight = "bold";
xmlSetProp( node, BAD_CAST "fontweight", BAD_CAST fontweight.c_str() );
std::string fontstyle("normal");
if (_Oblique)
fontstyle = "oblique";
xmlSetProp( node, BAD_CAST "fontstyle", BAD_CAST fontstyle.c_str() );
xmlSetProp( node, BAD_CAST "shadow", BAD_CAST toString( _Shadow ).c_str() ); xmlSetProp( node, BAD_CAST "shadow", BAD_CAST toString( _Shadow ).c_str() );
xmlSetProp( node, BAD_CAST "shadow_outline", BAD_CAST toString( _ShadowOutline ).c_str() ); xmlSetProp( node, BAD_CAST "shadow_outline", BAD_CAST toString( _ShadowOutline ).c_str() );
xmlSetProp( node, BAD_CAST "shadow_color", BAD_CAST toString( _ShadowColor ).c_str() ); xmlSetProp( node, BAD_CAST "shadow_color", BAD_CAST toString( _ShadowColor ).c_str() );
@ -561,6 +620,7 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "multi_line_maxw_only", BAD_CAST toString( _MultiLineMaxWOnly ).c_str() ); xmlSetProp( node, BAD_CAST "multi_line_maxw_only", BAD_CAST toString( _MultiLineMaxWOnly ).c_str() );
xmlSetProp( node, BAD_CAST "multi_max_line", BAD_CAST toString( _MultiMaxLine ).c_str() ); xmlSetProp( node, BAD_CAST "multi_max_line", BAD_CAST toString( _MultiMaxLine ).c_str() );
xmlSetProp( node, BAD_CAST "underlined", BAD_CAST toString( _Underlined ).c_str() ); xmlSetProp( node, BAD_CAST "underlined", BAD_CAST toString( _Underlined ).c_str() );
xmlSetProp( node, BAD_CAST "strikethrough", BAD_CAST toString( _StrikeThrough ).c_str() );
xmlSetProp( node, BAD_CAST "case_mode", BAD_CAST toString( uint32( _CaseMode ) ).c_str() ); xmlSetProp( node, BAD_CAST "case_mode", BAD_CAST toString( uint32( _CaseMode ) ).c_str() );
xmlSetProp( node, BAD_CAST "over_extend_view_text", BAD_CAST toString( _OverExtendViewText ).c_str() ); xmlSetProp( node, BAD_CAST "over_extend_view_text", BAD_CAST toString( _OverExtendViewText ).c_str() );
xmlSetProp( node, BAD_CAST "over_extend_parent_rect", xmlSetProp( node, BAD_CAST "over_extend_parent_rect",
@ -614,6 +674,22 @@ namespace NLGUI
_FontSize += CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); _FontSize += CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32();
} }
prop = (char*) xmlGetProp( cur, (xmlChar*)"fontweight" );
_Embolden = false;
if (prop)
{
if (nlstricmp("bold", (const char*)prop) == 0) _Embolden = true;
else nlwarning("<CViewText::parse> bad fontweight '%s'", (const char *)prop);
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"fontstyle" );
_Oblique = false;
if (prop)
{
if (nlstricmp("oblique", (const char *) prop) == 0) _Oblique = true;
else nlwarning("<CViewText::parse> bad fontstyle '%s'", (const char *)prop);
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"shadow" ); prop = (char*) xmlGetProp( cur, (xmlChar*)"shadow" );
_Shadow = false; _Shadow = false;
if (prop) if (prop)
@ -668,6 +744,11 @@ namespace NLGUI
if (prop) if (prop)
_Underlined = convertBool(prop); _Underlined = convertBool(prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"strikethrough" );
_StrikeThrough = false;
if (prop)
_StrikeThrough = convertBool(prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"case_mode" ); prop = (char*) xmlGetProp( cur, (xmlChar*)"case_mode" );
_CaseMode = CaseNormal; _CaseMode = CaseNormal;
if (prop) if (prop)
@ -887,6 +968,8 @@ namespace NLGUI
TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeOutline (_ShadowOutline);
TextContext->setShadeColor (shcol); TextContext->setShadeColor (shcol);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
TextContext->setEmbolden (_Embolden);
TextContext->setOblique (_Oblique);
float y = (float)(_YReal) * ooh; // y is expressed in scree, coordinates [0..1] float y = (float)(_YReal) * ooh; // y is expressed in scree, coordinates [0..1]
//y += _LinesInfos[_LinesInfos.size()-1].StringLine / h; //y += _LinesInfos[_LinesInfos.size()-1].StringLine / h;
@ -953,7 +1036,7 @@ namespace NLGUI
// skip spaces before current word // skip spaces before current word
float firstSpace = currWord.NumSpaces * currLine.getSpaceWidth(); float firstSpace = currWord.NumSpaces * currLine.getSpaceWidth();
sint line_width = 0; sint line_width = 0;
if (_Underlined) if (_Underlined || _StrikeThrough)
{ {
line_width = (sint)floorf(currLine.getWidthWithoutSpaces() + currLine.getSpaceWidth()); line_width = (sint)floorf(currLine.getWidthWithoutSpaces() + currLine.getSpaceWidth());
line_width -= (sint)floorf(firstSpace); line_width -= (sint)floorf(firstSpace);
@ -971,6 +1054,9 @@ namespace NLGUI
if (_Underlined) if (_Underlined)
rVR.drawRotFlipBitmap (_RenderLayer, (sint)floorf(px), y_line, line_width, 1, 0, false, rVR.getBlankTextureId(), col); rVR.drawRotFlipBitmap (_RenderLayer, (sint)floorf(px), y_line, line_width, 1, 0, false, rVR.getBlankTextureId(), col);
if (_StrikeThrough)
rVR.drawRotFlipBitmap (_RenderLayer, (sint)floorf(px), y_line + (_FontHeight / 2), line_width, 1, 0, false, rVR.getBlankTextureId(), col);
// skip word // skip word
px += currWord.Info.StringWidth; px += currWord.Info.StringWidth;
} }
@ -1002,6 +1088,8 @@ namespace NLGUI
TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeOutline (_ShadowOutline);
TextContext->setShadeColor (shcol); TextContext->setShadeColor (shcol);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
TextContext->setEmbolden (_Embolden);
TextContext->setOblique (_Oblique);
if(_LetterColors!=NULL && !TextContext->isSameLetterColors(_LetterColors, _Index)) if(_LetterColors!=NULL && !TextContext->isSameLetterColors(_LetterColors, _Index))
@ -1032,6 +1120,9 @@ namespace NLGUI
if (_Underlined) if (_Underlined)
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_FontLegHeight-2, _WReal, 1, 0, false, rVR.getBlankTextureId(), col); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_FontLegHeight-2, _WReal, 1, 0, false, rVR.getBlankTextureId(), col);
if (_StrikeThrough)
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+(_FontLegHeight/2), _WReal, 1, 0, false, rVR.getBlankTextureId(), col);
// reset selection // reset selection
if(_TextSelection) if(_TextSelection)
TextContext->resetStringSelection(_Index); TextContext->resetStringSelection(_Index);
@ -1154,6 +1245,22 @@ namespace NLGUI
return _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); return _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32();
} }
// ***************************************************************************
void CViewText::setEmbolden (bool embolden)
{
_Embolden = embolden;
computeFontSize ();
invalidateContent();
}
// ***************************************************************************
void CViewText::setOblique (bool oblique)
{
_Oblique = oblique;
computeFontSize ();
invalidateContent();
}
// *************************************************************************** // ***************************************************************************
void CViewText::setColor(const NLMISC::CRGBA & color) void CViewText::setColor(const NLMISC::CRGBA & color)
{ {
@ -1679,6 +1786,8 @@ namespace NLGUI
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
TextContext->setEmbolden (_Embolden);
TextContext->setOblique (_Oblique);
// default state // default state
_SingleLineTextClamped= false; _SingleLineTextClamped= false;
@ -2000,6 +2109,8 @@ namespace NLGUI
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
TextContext->setEmbolden (_Embolden);
TextContext->setOblique (_Oblique);
// CViewRenderer &rVR = *CViewRenderer::getInstance(); // CViewRenderer &rVR = *CViewRenderer::getInstance();
height = getFontHeight(); height = getFontHeight();
// //
@ -2132,6 +2243,8 @@ namespace NLGUI
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
TextContext->setEmbolden (_Embolden);
TextContext->setOblique (_Oblique);
// find the line where the character is // find the line where the character is
// CViewRenderer &rVR = *CViewRenderer::getInstance(); // CViewRenderer &rVR = *CViewRenderer::getInstance();
uint charPos = 0; uint charPos = 0;
@ -2407,6 +2520,8 @@ namespace NLGUI
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
TextContext->setEmbolden (_Embolden);
TextContext->setOblique (_Oblique);
TCharPos linePos = 0; TCharPos linePos = 0;
while (linePos < _Text.length()) while (linePos < _Text.length())
@ -2492,6 +2607,8 @@ namespace NLGUI
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
TextContext->setEmbolden (_Embolden);
TextContext->setOblique (_Oblique);
// Current position in text // Current position in text
TCharPos currPos = 0; TCharPos currPos = 0;
@ -2544,6 +2661,8 @@ namespace NLGUI
TextContext->setShaded (_Shadow); TextContext->setShaded (_Shadow);
TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeOutline (_ShadowOutline);
TextContext->setFontSize (_FontSize); TextContext->setFontSize (_FontSize);
TextContext->setEmbolden (_Embolden);
TextContext->setOblique (_Oblique);
// Letter size // Letter size
UTextContext::CStringInfo si = TextContext->getStringInfo(ucstring("|")); // for now we can't now that directly from UTextContext UTextContext::CStringInfo si = TextContext->getStringInfo(ucstring("|")); // for now we can't now that directly from UTextContext

@ -2207,7 +2207,7 @@ namespace NLGUI
} }
// Manage complex "Enter" // Manage complex "Enter"
if (eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyRETURN) if( eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyRETURN && !eventDesc.getKeyCtrl() )
{ {
// If the top window has Enter AH // If the top window has Enter AH
CInterfaceGroup *tw= getTopWindow(); CInterfaceGroup *tw= getTopWindow();

@ -1,6 +1,176 @@
FILE(GLOB SRC *.cpp *.h config_file/*.cpp config_file/*.h) FILE(GLOB SRC *.cpp *.h config_file/*.cpp config_file/*.h)
FILE(GLOB HEADERS ../../include/nel/misc/*.h) FILE(GLOB HEADERS ../../include/nel/misc/*.h)
FILE(GLOB NLMISC_CDB
cdb.cpp ../../include/nel/misc/cdb.h
cdb_*.cpp ../../include/nel/misc/cdb_*.h
)
FILE(GLOB NLMISC_EVENT
events.cpp ../../include/nel/misc/events.h
event_*.cpp ../../include/nel/misc/event_*.h
*_event_*.cpp ../../include/nel/misc/*_event_*.h
)
FILE(GLOB NLMISC_DEBUG
debug.cpp ../../include/nel/misc/debug.h
report.cpp ../../include/nel/misc/report.h
log.cpp ../../include/nel/misc/log.h
)
FILE(GLOB NLMISC_FILESYSTEM
async_file_manager.cpp ../../include/nel/misc/async_file_manager.h
file.cpp ../../include/nel/misc/file.h
path.cpp ../../include/nel/misc/path.h
big_file.cpp ../../include/nel/misc/big_file.h
*_xml.cpp ../../include/nel/misc/*_xml.h
xml_*.cpp ../../include/nel/misc/xml_*.h
)
FILE(GLOB NLMISC_STREAM
*_stream.cpp ../../include/nel/misc/*_stream.h
stream.cpp ../../include/nel/misc/stream.h
stream_*.cpp ../../include/nel/misc/stream_*.h
)
FILE(GLOB NLMISC_DISPLAYER
displayer.cpp ../../include/nel/misc/displayer.h
*_displayer.cpp ../../include/nel/misc/*_displayer.h
)
FILE(GLOB NLMISC_MATH
plane.cpp ../../include/nel/misc/plane.h
../../include/nel/misc/plane_inline.h
polygon.cpp ../../include/nel/misc/polygon.h
quad.cpp ../../include/nel/misc/quad.h
quat.cpp ../../include/nel/misc/quat.h
rect.cpp ../../include/nel/misc/rect.h
rgba.cpp ../../include/nel/misc/rgba.h
triangle.cpp ../../include/nel/misc/triangle.h
uv.cpp ../../include/nel/misc/uv.h
vector*.cpp ../../include/nel/misc/vector*.h
aabbox.cpp ../../include/nel/misc/aabbox.h
algo.cpp ../../include/nel/misc/algo.h
bsphere.cpp ../../include/nel/misc/bsphere.h
fast_floor.cpp ../../include/nel/misc/fast_floor.h
geom_ext.cpp ../../include/nel/misc/geom_ext.h
line.cpp ../../include/nel/misc/line.h
matrix.cpp ../../include/nel/misc/matrix.h
)
FILE(GLOB NLMISC_PLATFORM
*_nl.cpp ../../include/nel/misc/*_nl.h
common.cpp ../../include/nel/misc/common.h
app_context.cpp ../../include/nel/misc/app_context.h
check_fpu.cpp ../../include/nel/misc/check_fpu.h
cpu_time_stat.cpp ../../include/nel/misc/cpu_time_stat.h
dummy_window.cpp ../../include/nel/misc/dummy_window.h
dynloadlib.cpp ../../include/nel/misc/dynloadlib.h
fast_mem.cpp ../../include/nel/misc/fast_mem.h
inter_window_msg_queue.cpp ../../include/nel/misc/inter_window_msg_queue.h
system_*.cpp ../../include/nel/misc/system_*.h
win32_util.cpp ../../include/nel/misc/win32_util.h
win_tray.cpp ../../include/nel/misc/win_tray.h
)
FILE(GLOB NLMISC_GENERIC
../../include/nel/misc/array_2d.h
*_memory.cpp ../../include/nel/misc/*_memory.h
buf_fifo.cpp ../../include/nel/misc/buf_fifo.h
../../include/nel/misc/callback.h
*_allocator.cpp ../../include/nel/misc/*_allocator.h
../../include/nel/misc/enum_bitset.h
fast_id_map.cpp ../../include/nel/misc/fast_id_map.h
hierarchical_timer.cpp ../../include/nel/misc/hierarchical_timer.h
../../include/nel/misc/historic.h
../../include/nel/misc/mutable_container.h
../../include/nel/misc/random.h
smart_ptr.cpp ../../include/nel/misc/smart_ptr.h
../../include/nel/misc/smart_ptr_inline.h
../../include/nel/misc/resource_ptr.h
../../include/nel/misc/resource_ptr_inline.h
bit_set.cpp ../../include/nel/misc/bit_set.h
stop_watch.cpp ../../include/nel/misc/stop_watch.h
../../include/nel/misc/twin_map.h
object_vector.cpp ../../include/nel/misc/object_vector.h
../../include/nel/misc/singleton.h
speaker_listener.cpp ../../include/nel/misc/speaker_listener.h
../../include/nel/misc/static_map.h
stl_block_list.cpp ../../include/nel/misc/stl_block_list.h
)
FILE(GLOB NLMISC_UTILITY
config_file.cpp ../../include/nel/misc/config_file.h
cf_*.cpp ../../include/nel/misc/cf_*.h
config_file/config_file.cpp config_file/config_file.h
config_file/cf_*.cpp config_file/cf_*.h
class_id.cpp ../../include/nel/misc/class_id.h
class_registry.cpp ../../include/nel/misc/class_registry.h
cmd_args.cpp ../../include/nel/misc/cmd_args.h
command.cpp ../../include/nel/misc/command.h
eid_translator.cpp ../../include/nel/misc/eid_translator.h
entity_id.cpp ../../include/nel/misc/entity_id.h
eval_num_expr.cpp ../../include/nel/misc/eval_num_expr.h
factory.cpp ../../include/nel/misc/factory.h
grid_traversal.cpp ../../include/nel/misc/grid_traversal.h
mouse_smoother.cpp ../../include/nel/misc/mouse_smoother.h
noise_value.cpp ../../include/nel/misc/noise_value.h
progress_callback.cpp ../../include/nel/misc/progress_callback.h
sheet_id.cpp ../../include/nel/misc/sheet_id.h
variable.cpp ../../include/nel/misc/variable.h
value_smoother.cpp ../../include/nel/misc/value_smoother.h
)
FILE(GLOB NLMISC_STRING
string_*.cpp ../../include/nel/misc/string_*.h
../../include/nel/misc/ucstring.h
unicode.cpp
sstring.cpp ../../include/nel/misc/sstring.h
)
FILE(GLOB NLMISC_I18N
diff_tool.cpp ../../include/nel/misc/diff_tool.h
i18n.cpp ../../include/nel/misc/i18n.h
words_dictionary.cpp ../../include/nel/misc/words_dictionary.h
)
FILE(GLOB NLMISC_THREAD
co_task.cpp ../../include/nel/misc/co_task.h
mutex.cpp ../../include/nel/misc/mutex.h
*_thread.cpp ../../include/nel/misc/*_thread.h
task_*.cpp ../../include/nel/misc/task_*.h
reader_writer.cpp ../../include/nel/misc/reader_writer.h
tds.cpp ../../include/nel/misc/tds.h
thread.cpp ../../include/nel/misc/thread.h
)
FILE(GLOB NLMISC_BITMAP
bitmap.cpp ../../include/nel/misc/bitmap.h
bitmap_*.cpp
)
FILE(GLOB NLMISC_CRYPT
md5.cpp ../../include/nel/misc/md5.h
sha1.cpp ../../include/nel/misc/sha1.h
)
SOURCE_GROUP("" FILES ${SRC} ${HEADERS})
SOURCE_GROUP("cdb" FILES ${NLMISC_CDB})
SOURCE_GROUP("event" FILES ${NLMISC_EVENT})
SOURCE_GROUP("debug" FILES ${NLMISC_DEBUG})
SOURCE_GROUP("platform" FILES ${NLMISC_PLATFORM})
SOURCE_GROUP("filesystem" FILES ${NLMISC_FILESYSTEM})
SOURCE_GROUP("stream" FILES ${NLMISC_STREAM})
SOURCE_GROUP("displayer" FILES ${NLMISC_DISPLAYER})
SOURCE_GROUP("math" FILES ${NLMISC_MATH})
SOURCE_GROUP("generic" FILES ${NLMISC_GENERIC})
SOURCE_GROUP("utility" FILES ${NLMISC_UTILITY})
SOURCE_GROUP("bitmap" FILES ${NLMISC_BITMAP})
SOURCE_GROUP("thread" FILES ${NLMISC_THREAD})
SOURCE_GROUP("i18n" FILES ${NLMISC_I18N})
SOURCE_GROUP("crypt" FILES ${NLMISC_CRYPT})
SOURCE_GROUP("string" FILES ${NLMISC_STRING})
NL_TARGET_LIB(nelmisc ${HEADERS} ${SRC}) NL_TARGET_LIB(nelmisc ${HEADERS} ${SRC})
IF(WITH_GTK) IF(WITH_GTK)

@ -114,6 +114,7 @@ CApplicationContext::CApplicationContext()
DebugNeedAssert = false; DebugNeedAssert = false;
NoAssert = false; NoAssert = false;
AlreadyCreateSharedAmongThreads = false; AlreadyCreateSharedAmongThreads = false;
WindowedApplication = false;
contextReady(); contextReady();
} }
@ -242,6 +243,16 @@ void CApplicationContext::setAlreadyCreateSharedAmongThreads(bool b)
AlreadyCreateSharedAmongThreads = b; AlreadyCreateSharedAmongThreads = b;
} }
bool CApplicationContext::isWindowedApplication()
{
return WindowedApplication;
}
void CApplicationContext::setWindowedApplication(bool b)
{
WindowedApplication = b;
}
CLibraryContext::CLibraryContext(INelContext &applicationContext) CLibraryContext::CLibraryContext(INelContext &applicationContext)
: _ApplicationContext(&applicationContext) : _ApplicationContext(&applicationContext)
{ {
@ -430,6 +441,16 @@ void CLibraryContext::setAlreadyCreateSharedAmongThreads(bool b)
_ApplicationContext->setAlreadyCreateSharedAmongThreads(b); _ApplicationContext->setAlreadyCreateSharedAmongThreads(b);
} }
bool CLibraryContext::isWindowedApplication()
{
return _ApplicationContext->isWindowedApplication();
}
void CLibraryContext::setWindowedApplication(bool b)
{
_ApplicationContext->setWindowedApplication(b);
}
void initNelLibrary(NLMISC::CLibrary &lib) void initNelLibrary(NLMISC::CLibrary &lib)
{ {
nlassert(lib.isLibraryLoaded()); nlassert(lib.isLibraryLoaded());

@ -43,20 +43,7 @@
#else //NL_USE_THREAD_COTASK #else //NL_USE_THREAD_COTASK
// some platform specifics // some platform specifics
#if defined (NL_OS_WINDOWS) #if defined (NL_OS_WINDOWS)
//# define _WIN32_WINNT 0x0500
# define NL_WIN_CALLBACK CALLBACK # define NL_WIN_CALLBACK CALLBACK
// Visual .NET won't allow Fibers for a Windows version older than 2000. However the basic features are sufficient for us, we want to compile them for all Windows >= 95
# if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0400)
# ifdef _WIN32_WINNT
# undef _WIN32_WINNT
# endif
# define _WIN32_WINNT 0x0400
# endif
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
# define NL_WIN_CALLBACK # define NL_WIN_CALLBACK
# include <ucontext.h> # include <ucontext.h>

@ -20,10 +20,7 @@
#include "nel/misc/common.h" #include "nel/misc/common.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW # include <ShellAPI.h>
# define NOMINMAX
# endif
# include <windows.h>
# include <io.h> # include <io.h>
# include <tchar.h> # include <tchar.h>
#elif defined NL_OS_UNIX #elif defined NL_OS_UNIX
@ -670,7 +667,7 @@ bool abortProgram(uint32 pid)
#endif #endif
} }
bool launchProgram (const std::string &programName, const std::string &arguments) bool launchProgram(const std::string &programName, const std::string &arguments, bool log)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
@ -722,6 +719,7 @@ bool launchProgram (const std::string &programName, const std::string &arguments
{ {
LPVOID lpMsgBuf; LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
if (log)
nlwarning("LAUNCH: Failed launched '%s' with arg '%s' err %d: '%s'", programName.c_str(), arguments.c_str(), GetLastError(), lpMsgBuf); nlwarning("LAUNCH: Failed launched '%s' with arg '%s' err %d: '%s'", programName.c_str(), arguments.c_str(), GetLastError(), lpMsgBuf);
LocalFree(lpMsgBuf); LocalFree(lpMsgBuf);
CloseHandle( pi.hProcess ); CloseHandle( pi.hProcess );
@ -779,6 +777,7 @@ bool launchProgram (const std::string &programName, const std::string &arguments
if (status == -1) if (status == -1)
{ {
char *err = strerror (errno); char *err = strerror (errno);
if (log)
nlwarning("LAUNCH: Failed launched '%s' with arg '%s' err %d: '%s'", programName.c_str(), arguments.c_str(), errno, err); nlwarning("LAUNCH: Failed launched '%s' with arg '%s' err %d: '%s'", programName.c_str(), arguments.c_str(), errno, err);
} }
else if (status == 0) else if (status == 0)
@ -799,6 +798,7 @@ bool launchProgram (const std::string &programName, const std::string &arguments
return true; return true;
} }
#else #else
if (log)
nlwarning ("LAUNCH: launchProgram() not implemented"); nlwarning ("LAUNCH: launchProgram() not implemented");
#endif #endif

@ -17,28 +17,8 @@
#include "stdmisc.h" #include "stdmisc.h"
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#ifdef HAVE_NELCONFIG_H
# include "nelconfig.h"
#endif // HAVE_NELCONFIG_H
#include "nel/misc/log.h"
#include "nel/misc/displayer.h"
#include "nel/misc/mem_displayer.h"
#include "nel/misc/command.h"
#include "nel/misc/report.h"
#include "nel/misc/path.h"
#include "nel/misc/variable.h"
#include "nel/misc/system_info.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# define _WIN32_WINDOWS 0x0410
# ifndef NL_COMP_MINGW
# define WINVER 0x0400
# define NOMINMAX
# endif
# include <windows.h>
# include <direct.h> # include <direct.h>
# include <tchar.h> # include <tchar.h>
# include <imagehlp.h> # include <imagehlp.h>
@ -59,6 +39,22 @@
# include <errno.h> # include <errno.h>
#endif #endif
#include "nel/misc/debug.h"
#ifdef HAVE_NELCONFIG_H
# include "nelconfig.h"
#endif // HAVE_NELCONFIG_H
#include "nel/misc/log.h"
#include "nel/misc/displayer.h"
#include "nel/misc/mem_displayer.h"
#include "nel/misc/command.h"
#include "nel/misc/report.h"
#include "nel/misc/path.h"
#include "nel/misc/variable.h"
#include "nel/misc/system_info.h"
#include "nel/misc/system_utils.h"
#define NL_NO_DEBUG_FILES 1 #define NL_NO_DEBUG_FILES 1
using namespace std; using namespace std;
@ -83,7 +79,8 @@ using namespace std;
#define LOG_IN_FILE NEL_LOG_IN_FILE #define LOG_IN_FILE NEL_LOG_IN_FILE
// If true, debug system will trap crash even if the application is in debugger // If true, debug system will trap crash even if the application is in debugger
static const bool TrapCrashInDebugger = false; //static const bool TrapCrashInDebugger = false;
static const bool TrapCrashInDebugger = true;
#ifdef DEBUG_NEW #ifdef DEBUG_NEW
#define new DEBUG_NEW #define new DEBUG_NEW
@ -552,8 +549,8 @@ public:
{ {
// yoyo: allow only to send the crash report once. Because users usually click ignore, // yoyo: allow only to send the crash report once. Because users usually click ignore,
// which create noise into list of bugs (once a player crash, it will surely continues to do it). // which create noise into list of bugs (once a player crash, it will surely continues to do it).
bool i = false; report(progname + shortExc, subject, _Reason, NL_CRASH_DUMP_FILE, true, !isCrashAlreadyReported(), ReportAbort);
report (progname+shortExc, "", subject, _Reason, true, 1, true, 1, !isCrashAlreadyReported(), i, NL_CRASH_DUMP_FILE); // TODO: Does this need to be synchronous? Why does this not handle the report result?
// no more sent mail for crash // no more sent mail for crash
setCrashAlreadyReported(true); setCrashAlreadyReported(true);
@ -1196,10 +1193,10 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
if (TrapCrashInDebugger || !IsDebuggerPresent ()) if (TrapCrashInDebugger || !IsDebuggerPresent ())
#endif
{ {
DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD"); DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD");
} }
#endif
#if LOG_IN_FILE #if LOG_IN_FILE
if (logInFile) if (logInFile)
@ -1227,6 +1224,9 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog)
#endif // LOG_IN_FILE #endif // LOG_IN_FILE
DefaultMemDisplayer = new CMemDisplayer ("DEFAULT_MD"); DefaultMemDisplayer = new CMemDisplayer ("DEFAULT_MD");
if (NLMISC::CSystemUtils::detectWindowedApplication())
INelContext::getInstance().setWindowedApplication(true);
initDebug2(logInFile); initDebug2(logInFile);
INelContext::getInstance().setAlreadyCreateSharedAmongThreads(true); INelContext::getInstance().setAlreadyCreateSharedAmongThreads(true);

@ -18,6 +18,10 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#ifndef NL_OS_WINDOWS
# define IsDebuggerPresent() false
#endif
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# include <io.h> # include <io.h>
# include <fcntl.h> # include <fcntl.h>
@ -35,19 +39,6 @@
#include "nel/misc/debug.h" #include "nel/misc/debug.h"
#ifdef NL_OS_WINDOWS
// these defines is for IsDebuggerPresent(). it'll not compile on windows 95
// just comment this and the IsDebuggerPresent to compile on windows 95
# define _WIN32_WINDOWS 0x0410
# ifndef NL_COMP_MINGW
# define WINVER 0x0400
# define NOMINMAX
# endif
# include <windows.h>
#else
# define IsDebuggerPresent() false
#endif
#include "nel/misc/displayer.h" #include "nel/misc/displayer.h"
using namespace std; using namespace std;
@ -529,7 +520,7 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes
// in release "<Msg>" // in release "<Msg>"
void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message) void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message)
{ {
#ifdef NL_OS_WINDOWS //#ifdef NL_OS_WINDOWS
bool needSpace = false; bool needSpace = false;
// stringstream ss; // stringstream ss;
@ -689,38 +680,34 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m
// which create noise into list of bugs (once a player crash, it will surely continues to do it). // which create noise into list of bugs (once a player crash, it will surely continues to do it).
std::string filename = getLogDirectory() + NL_CRASH_DUMP_FILE; std::string filename = getLogDirectory() + NL_CRASH_DUMP_FILE;
if (ReportDebug == report (args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)), "", subject, body, true, 2, true, 1, !isCrashAlreadyReported(), IgnoreNextTime, filename.c_str())) TReportResult reportResult = report(args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)),
subject, body, filename, NL_REPORT_SYNCHRONOUS, !isCrashAlreadyReported(), NL_REPORT_DEFAULT);
switch (reportResult)
{ {
case ReportAlwaysIgnore:
IgnoreNextTime = true;
break;
case ReportBreak:
INelContext::getInstance().setDebugNeedAssert(true); INelContext::getInstance().setDebugNeedAssert(true);
break;
case ReportAbort:
# ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
// disable the Windows popup telling that the application aborted and disable the dr watson report.
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
# endif
# endif
abort();
break;
} }
// no more sent mail for crash // no more sent mail for crash
setCrashAlreadyReported(true); setCrashAlreadyReported(true);
} }
/* // Check the envvar NEL_IGNORE_ASSERT
if (getenv ("NEL_IGNORE_ASSERT") == NULL)
{
// Ask the user to continue, debug or ignore
int result = MessageBox (NULL, ss2.str().c_str (), logTypeToString(args.LogType, true), MB_ABORTRETRYIGNORE | MB_ICONSTOP);
if (result == IDABORT)
{
// Exit the program now
exit (EXIT_FAILURE);
} }
else if (result == IDRETRY)
{
// Give the debugger a try
DebugNeedAssert = true;
}
else if (result == IDIGNORE)
{
// Continue, do nothing
}
}
*/ }
#endif //#endif
} }

@ -32,6 +32,7 @@
#pragma comment(lib, "gthread-1.3.lib") #pragma comment(lib, "gthread-1.3.lib")
#endif #endif
#include "nel/misc/app_context.h"
#include "nel/misc/path.h" #include "nel/misc/path.h"
#include "nel/misc/command.h" #include "nel/misc/command.h"
#include "nel/misc/thread.h" #include "nel/misc/thread.h"
@ -59,6 +60,14 @@ static GtkWidget *hrootbox = NULL, *scrolled_win2 = NULL;
// Functions // Functions
// //
CGtkDisplayer (const char *displayerName) : CWindowDisplayer(displayerName)
{
needSlashR = false;
createLabel ("@Clear|CLEAR");
INelContext::getInstance().setWindowedApplication(true);
}
CGtkDisplayer::~CGtkDisplayer () CGtkDisplayer::~CGtkDisplayer ()
{ {
if (_Init) if (_Init)

@ -19,11 +19,7 @@
#include "nel/misc/log.h" #include "nel/misc/log.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <process.h> # include <process.h>
# include <windows.h>
#else #else
# include <unistd.h> # include <unistd.h>
#endif #endif

@ -24,10 +24,6 @@
#include "nel/misc/debug.h" #include "nel/misc/debug.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
# include <imagehlp.h> # include <imagehlp.h>
# pragma comment(lib, "imagehlp.lib") # pragma comment(lib, "imagehlp.lib")
# ifdef NL_OS_WIN64 # ifdef NL_OS_WIN64
@ -103,7 +99,7 @@ static string getFuncInfo (DWORD_TYPE funcAddr, DWORD_TYPE stackAddr)
if (stop==0 && (parse[i] == ',' || parse[i] == ')')) if (stop==0 && (parse[i] == ',' || parse[i] == ')'))
{ {
char tmp[32]; char tmp[32];
sprintf (tmp, "=0x%p", *((ULONG*)(stackAddr) + 2 + pos++)); sprintf(tmp, "=0x%p", *((DWORD_TYPE*)(stackAddr) + 2 + pos++));
str += tmp; str += tmp;
} }
str += parse[i]; str += parse[i];

@ -41,15 +41,6 @@ using namespace std;
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
// these defines are for IsDebuggerPresent(). It'll not compile on windows 95
// just comment this and the IsDebuggerPresent to compile on windows 95
#define _WIN32_WINDOWS 0x0410
#ifndef NL_COMP_MINGW
# define WINVER 0x0400
# define NOMINMAX
#endif
#include <windows.h>
#ifdef DEBUG_NEW #ifdef DEBUG_NEW
#define new DEBUG_NEW #define new DEBUG_NEW
#endif #endif

@ -17,8 +17,8 @@
#include "stdmisc.h" #include "stdmisc.h"
#include <nel/misc/types_nl.h> #include "nel/misc/types_nl.h"
#include <nel/misc/debug.h> #include "nel/misc/debug.h"
#ifdef NL_OS_UNIX #ifdef NL_OS_UNIX

@ -25,10 +25,6 @@
#include "nel/misc/xml_pack.h" #include "nel/misc/xml_pack.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
# include <sys/types.h> # include <sys/types.h>
# include <sys/stat.h> # include <sys/stat.h>
# include <direct.h> # include <direct.h>
@ -858,6 +854,8 @@ string getname (dirent *de)
void CPath::getPathContent (const string &path, bool recurse, bool wantDir, bool wantFile, vector<string> &result, class IProgressCallback *progressCallBack, bool showEverything) void CPath::getPathContent (const string &path, bool recurse, bool wantDir, bool wantFile, vector<string> &result, class IProgressCallback *progressCallBack, bool showEverything)
{ {
getInstance()->_FileContainer.getPathContent(path, recurse, wantDir, wantFile, result, progressCallBack, showEverything); getInstance()->_FileContainer.getPathContent(path, recurse, wantDir, wantFile, result, progressCallBack, showEverything);
sort(result.begin(), result.end());
} }
void CFileContainer::getPathContent (const string &path, bool recurse, bool wantDir, bool wantFile, vector<string> &result, class IProgressCallback *progressCallBack, bool showEverything) void CFileContainer::getPathContent (const string &path, bool recurse, bool wantDir, bool wantFile, vector<string> &result, class IProgressCallback *progressCallBack, bool showEverything)
@ -900,10 +898,10 @@ void CFileContainer::getPathContent (const string &path, bool recurse, bool want
if (isdirectory(de)) if (isdirectory(de))
{ {
// skip CVS and .svn directory // skip CVS, .svn and .hg directory
if ((!showEverything) && (fn == "CVS" || fn == ".svn")) if ((!showEverything) && (fn == "CVS" || fn == ".svn" || fn == ".hg"))
{ {
NL_DISPLAY_PATH("PATH: CPath::getPathContent(%s, %d, %d, %d): skip CVS and .svn directory", path.c_str(), recurse, wantDir, wantFile); NL_DISPLAY_PATH("PATH: CPath::getPathContent(%s, %d, %d, %d): skip CVS, .svn and .hg directory", path.c_str(), recurse, wantDir, wantFile);
continue; continue;
} }
@ -939,10 +937,10 @@ void CFileContainer::getPathContent (const string &path, bool recurse, bool want
closedir (dir); closedir (dir);
#ifndef NL_OS_WINDOWS #ifndef NL_OS_WINDOWS
BasePathgetPathContent = ""; BasePathgetPathContent.clear();
#endif #endif
// let s recurse // let's recurse
for (uint i = 0; i < recursPath.size (); i++) for (uint i = 0; i < recursPath.size (); i++)
{ {
// Progress bar // Progress bar
@ -960,8 +958,6 @@ void CFileContainer::getPathContent (const string &path, bool recurse, bool want
progressCallBack->popCropedValues (); progressCallBack->popCropedValues ();
} }
} }
sort(result.begin(), result.end());
} }
void CPath::removeAllAlternativeSearchPath () void CPath::removeAllAlternativeSearchPath ()
@ -1037,6 +1033,9 @@ void CFileContainer::addSearchPath (const string &path, bool recurse, bool alter
{ {
// find all path and subpath // find all path and subpath
getPathContent (newPath, recurse, true, false, pathsToProcess, progressCallBack); getPathContent (newPath, recurse, true, false, pathsToProcess, progressCallBack);
// sort files
sort(pathsToProcess.begin(), pathsToProcess.end());
} }
for (uint p = 0; p < pathsToProcess.size(); p++) for (uint p = 0; p < pathsToProcess.size(); p++)
@ -1082,7 +1081,10 @@ void CFileContainer::addSearchPath (const string &path, bool recurse, bool alter
// find all files in the path and subpaths // find all files in the path and subpaths
getPathContent (newPath, recurse, false, true, filesToProcess, progressCallBack); getPathContent (newPath, recurse, false, true, filesToProcess, progressCallBack);
// Progree bar // sort files
sort(filesToProcess.begin(), filesToProcess.end());
// Progress bar
if (progressCallBack) if (progressCallBack)
{ {
progressCallBack->popCropedValues (); progressCallBack->popCropedValues ();

@ -16,346 +16,209 @@
#include "stdmisc.h" #include "stdmisc.h"
#include <stdlib.h>
#include <sstream>
#include "nel/misc/common.h" #include "nel/misc/common.h"
#include "nel/misc/ucstring.h" #include "nel/misc/ucstring.h"
#include "nel/misc/report.h" #include "nel/misc/report.h"
#include "nel/misc/path.h" #include "nel/misc/path.h"
#include "nel/misc/file.h"
#ifdef NL_OS_WINDOWS #include "nel/misc/system_utils.h"
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
# include <windowsx.h>
# include <winuser.h>
#endif // NL_OS_WINDOWS
#define NL_NO_DEBUG_FILES 1
using namespace std;
#ifdef DEBUG_NEW #ifdef DEBUG_NEW
#define new DEBUG_NEW #define new DEBUG_NEW
#endif #endif
namespace NLMISC #define NL_REPORT_POST_URL_ENVVAR "NL_REPORT_POST_URL"
{
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
static HWND sendReport=NULL; #define NL_CRASH_REPORT_TOOL "crash_report.exe"
#else
#define NL_CRASH_REPORT_TOOL "crash_report"
#endif #endif
#define NL_DEBUG_REPORT 0
// Set to 1 if you want command line report tool
#define NL_REPORT_CONSOLE 0
// Set to 1 if you want command line report tool even when the debugger is present
#define NL_REPORT_CONSOLE_DEBUGGER 1
//old doesn't work on visual c++ 7.1 due to default parameter typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile = "", bool onlyCheck = false); namespace NLMISC
typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile, bool onlyCheck);
#define DELETE_OBJECT(a) if((a)!=NULL) { DeleteObject (a); a = NULL; }
static TEmailFunction EmailFunction = NULL;
void setReportEmailFunction (void *emailFunction)
{ {
EmailFunction = (TEmailFunction)emailFunction;
void setReportPostUrl(const char *postUrl)
{
#if NL_DEBUG_REPORT
if (INelContext::isContextInitialised())
nldebug("Set report post url to '%s'", postUrl);
#endif
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
if (sendReport) SetEnvironmentVariableA(NL_REPORT_POST_URL_ENVVAR, postUrl);
EnableWindow(sendReport, FALSE); #else
setenv(NL_REPORT_POST_URL_ENVVAR, postUrl, 1);
#endif #endif
} }
#ifndef NL_OS_WINDOWS inline const char *getReportPostURL()
// GNU/Linux, do nothing
void report ()
{ {
} #ifdef NL_OS_WINDOWS
static char buf[512];
buf[0] = '\0';
int res = GetEnvironmentVariableA(NL_REPORT_POST_URL_ENVVAR, buf, sizeof(buf));
if (res <= 0 || res > 511) return NULL;
if (buf[0] == '\0') return NULL;
return buf;
#else #else
char *res = getenv(NL_REPORT_POST_URL_ENVVAR);
// Windows specific version if (res == NULL || res[0] == '\0') return NULL;
return res;
static string Body;
static string Subject;
static string AttachedFile;
static HWND checkIgnore=NULL;
static HWND debug=NULL;
static HWND ignore=NULL;
static HWND quit=NULL;
static HWND dialog=NULL;
static bool NeedExit;
static TReportResult Result;
static bool IgnoreNextTime;
static bool CanSendMailReport= false;
static bool DebugDefaultBehavior, QuitDefaultBehavior;
static void sendEmail()
{
if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED)
{
bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false);
if (res)
{
// EnableWindow(sendReport, FALSE);
// MessageBox (dialog, "The email was successfully sent", "email", MB_OK);
#ifndef NL_NO_DEBUG_FILES
CFile::createEmptyFile(getLogDirectory() + "report_sent");
#endif
}
else
{
#ifndef NL_NO_DEBUG_FILES
CFile::createEmptyFile(getLogDirectory() + "report_failed");
#endif #endif
// MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR);
} }
}
else
{
#ifndef NL_NO_DEBUG_FILES
CFile::createEmptyFile(getLogDirectory() + "report_refused");
#endif
}
}
static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
//MSGFILTER *pmf;
if (message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED) TReportResult report(const std::string &title, const std::string &subject, const std::string &body, const std::string &attachment, bool synchronous, bool sendReport, TReportResult defaultResult)
{
if ((HWND) lParam == checkIgnore)
{
IgnoreNextTime = !IgnoreNextTime;
}
else if ((HWND) lParam == debug)
{
sendEmail();
NeedExit = true;
Result = ReportDebug;
if (DebugDefaultBehavior)
{
NLMISC_BREAKPOINT;
}
}
else if ((HWND) lParam == ignore)
{ {
sendEmail(); std::string reportPath;
NeedExit = true; if (!body.empty())
Result = ReportIgnore;
}
else if ((HWND) lParam == quit)
{ {
sendEmail(); std::stringstream reportFile;
NeedExit = true; reportFile << getLogDirectory();
Result = ReportQuit; reportFile << "nel_report_";
reportFile << (int)time(NULL);
if (QuitDefaultBehavior) reportFile << ".log";
reportPath = CFile::findNewFile(reportFile.str());
std::ofstream f;
f.open(reportPath.c_str());
if (!f.good())
{ {
// ace: we cannot call exit() because it's call the static object dtor and can crash the application #if NL_DEBUG_REPORT
// if the dtor call order is not good. if (INelContext::isContextInitialised())
//exit(EXIT_SUCCESS); nldebug("Failed to write report log to '%s'", reportPath.c_str());
#ifdef NL_OS_WINDOWS
#ifndef NL_COMP_MINGW
// disable the Windows popup telling that the application aborted and disable the dr watson report.
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif #endif
#endif reportPath.clear();
// quit without calling atexit or static object dtors.
abort();
}
}
/*else if ((HWND) lParam == sendReport)
{
if (EmailFunction != NULL)
{
bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false);
if (res)
{
EnableWindow(sendReport, FALSE);
MessageBox (dialog, "The email was successfully sent", "email", MB_OK);
CFile::createEmptyFile(getLogDirectory() + "report_sent");
} }
else else
{ {
MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); f << body;
} f.close();
}
}*/
}
else if (message == WM_CHAR)
{
if (wParam == 27)
{
// ESC -> ignore
sendEmail();
NeedExit = true;
Result = ReportIgnore;
} }
} }
return DefWindowProc (hWnd, message, wParam, lParam); if (((INelContext::isContextInitialised()
} && INelContext::getInstance().isWindowedApplication())
|| CSystemUtils::detectWindowedApplication())
TReportResult report (const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile) && CFile::isExists(NL_CRASH_REPORT_TOOL))
{ {
// register the window std::stringstream params;
static bool AlreadyRegister = false; params << NL_CRASH_REPORT_TOOL;
if(!AlreadyRegister)
{
WNDCLASSW wc;
memset (&wc,0,sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(NULL);
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszClassName = L"NLReportWindow";
wc.lpszMenuName = NULL;
if (!RegisterClassW(&wc)) return ReportError;
AlreadyRegister = true;
}
ucstring formatedTitle = title.empty() ? ucstring("NeL report") : ucstring(title); if (!reportPath.empty())
params << " -log \"" << reportPath << "\"";
if (!subject.empty())
params << " -attachment \"" << attachment << "\"";
// create the window if (!title.empty())
dialog = CreateWindowW (L"NLReportWindow", (LPCWSTR)formatedTitle.c_str(), WS_DLGFRAME | WS_CAPTION /*| WS_THICKFRAME*/, CW_USEDEFAULT, CW_USEDEFAULT, 456, 400, NULL, NULL, GetModuleHandle(NULL), NULL); params << " -title \"" << title << "\"";
// create the font if (!subject.empty())
HFONT font = CreateFont (-12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); params << " -subject \"" << subject << "\"";
Subject = subject; const char *reportPostUrl = getReportPostURL();
AttachedFile = attachedFile; if (reportPostUrl)
params << " -host \"" << reportPostUrl << "\"";
// create the edit control if (synchronous)
HWND edit = CreateWindowW (L"EDIT", NULL, WS_BORDER | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_READONLY | ES_LEFT | ES_MULTILINE, 7, 70, 429, 212, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); params << " -dev";
SendMessage (edit, WM_SETFONT, (WPARAM) font, TRUE);
// set the edit text limit to lot of :) if (sendReport)
SendMessage (edit, EM_LIMITTEXT, ~0U, 0); params << " -sendreport";
Body = addSlashR (body);
// set the message in the edit text std::string paramsStr = params.str();
SendMessage (edit, WM_SETTEXT, (WPARAM)0, (LPARAM)Body.c_str());
if (enableCheckIgnore) if (synchronous)
{ {
// create the combo box control TReportResult result = (TReportResult)::system(paramsStr.c_str());
checkIgnore = CreateWindowW (L"BUTTON", L"Don't display this report again", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_CHECKBOX, 7, 290, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL); if (result != ReportAlwaysIgnore
SendMessage (checkIgnore, WM_SETFONT, (WPARAM) font, TRUE); && result != ReportIgnore
&& result != ReportAbort
if(ignoreNextTime) && result != ReportBreak)
{ {
SendMessage (checkIgnore, BM_SETCHECK, BST_CHECKED, 0); #if NL_DEBUG_REPORT
if (INelContext::isContextInitialised())
nldebug("Return default result, invalid return code %i", (int)result);
#endif
return defaultResult;
} }
return result;
} }
else
// create the debug button control
debug = CreateWindowW (L"BUTTON", L"Debug", WS_CHILD | WS_VISIBLE, 7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (debug, WM_SETFONT, (WPARAM) font, TRUE);
if (debugButton == 0)
EnableWindow(debug, FALSE);
// create the ignore button control
ignore = CreateWindowW (L"BUTTON", L"Ignore", WS_CHILD | WS_VISIBLE, 75+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (ignore, WM_SETFONT, (WPARAM) font, TRUE);
if (ignoreButton == 0)
EnableWindow(ignore, FALSE);
// create the quit button control
quit = CreateWindowW (L"BUTTON", L"Quit", WS_CHILD | WS_VISIBLE, 75+75+7+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (quit, WM_SETFONT, (WPARAM) font, TRUE);
if (quitButton == 0)
EnableWindow(quit, FALSE);
// create the debug button control
sendReport = CreateWindowW (L"BUTTON", L"Don't send the report", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 7, 315+32, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (sendReport, WM_SETFONT, (WPARAM) font, TRUE);
string formatedHeader;
if (header.empty())
{ {
formatedHeader = "This application stopped to display this report."; NLMISC::launchProgram(NL_CRASH_REPORT_TOOL, paramsStr,
NL_DEBUG_REPORT ? INelContext::isContextInitialised() : false); // Only log if required, avoid infinite loop
return defaultResult;
}
} }
else else
{ {
formatedHeader = header; #if NL_DEBUG_REPORT
if (INelContext::isContextInitialised() && !CFile::isExists(NL_CRASH_REPORT_TOOL))
nldebug("Crash report tool '%s' does not exist", NL_CRASH_REPORT_TOOL);
#endif
#if defined(NL_OS_WINDOWS) && !FINAL_VERSION && !NL_REPORT_CONSOLE_DEBUGGER
if (IsDebuggerPresent())
{
return defaultResult;
} }
// ace don't do that because it s slow to try to send a mail
//CanSendMailReport = sendReportButton && EmailFunction != NULL && EmailFunction("", "", "", "", "", true);
CanSendMailReport = sendReportButton && EmailFunction != NULL;
if (CanSendMailReport)
formatedHeader += " Send report will only email the contents of the box below. Please, send it to help us (it could take few minutes to send the email, be patient).";
else else
EnableWindow(sendReport, FALSE); #endif
if (synchronous)
ucstring uc = ucstring::makeFromUtf8(formatedHeader);
// create the label control
HWND label = CreateWindowW (L"STATIC", (LPCWSTR)uc.c_str(), WS_CHILD | WS_VISIBLE /*| SS_WHITERECT*/, 7, 7, 429, 51, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
SendMessage (label, WM_SETFONT, (WPARAM) font, TRUE);
DebugDefaultBehavior = debugButton==1;
QuitDefaultBehavior = quitButton==1;
IgnoreNextTime = ignoreNextTime;
// show until the cursor really show :)
while (ShowCursor(TRUE) < 0)
;
SetWindowPos (dialog, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
SetFocus(dialog);
SetForegroundWindow(dialog);
NeedExit = false;
while(!NeedExit)
{ {
MSG msg; #if NL_REPORT_CONSOLE
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) // An interactive console based report
printf("\n");
if (!title.empty())
printf("%s\n", title.c_str());
else
printf("NeL report\n");
printf("\n");
if (!subject.empty())
printf("\tsubject: '%s'\n", subject.c_str());
if (!body.empty())
printf("\tbody: '%s'\n", reportPath.c_str());
if (!attachment.empty())
printf("\tattachment: '%s'\n", attachment.c_str());
for (;;)
{
printf("\n");
printf("Always Ignore (S), Ignore (I), Abort (A), Break (B)?\n"); // S for Surpress
printf("> ");
int c = getchar();
getchar();
switch (c)
{
case 'S':
case 's':
return ReportAlwaysIgnore;
case 'I':
case 'i':
return ReportIgnore;
case 'A':
case 'a':
return ReportAbort;
case 'B':
case 'b':
return ReportBreak;
}
}
#else
return defaultResult;
#endif
}
else
{ {
TranslateMessage(&msg); return defaultResult;
DispatchMessageW(&msg);
} }
nlSleep (1);
} }
// set the user result
ignoreNextTime = IgnoreNextTime;
ShowWindow(dialog, SW_HIDE);
DELETE_OBJECT(sendReport)
DELETE_OBJECT(quit)
DELETE_OBJECT(ignore)
DELETE_OBJECT(debug)
DELETE_OBJECT(checkIgnore)
DELETE_OBJECT(edit)
DELETE_OBJECT(label)
DELETE_OBJECT(dialog)
return Result;
} }
#endif
} // NLMISC } // NLMISC

@ -19,12 +19,7 @@
#include "nel/misc/shared_memory.h" #include "nel/misc/shared_memory.h"
#include "nel/misc/debug.h" #include "nel/misc/debug.h"
#ifdef NL_OS_WINDOWS #ifndef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
# define NOMINMAX
# endif
# include <windows.h>
#else
# include <sys/types.h> # include <sys/types.h>
# include <sys/ipc.h> # include <sys/ipc.h>
# include <sys/shm.h> # include <sys/shm.h>

@ -1731,7 +1731,9 @@ namespace NLMISC
double CSString::atof() const double CSString::atof() const
{ {
return ::atof(c_str()); double val;
NLMISC::fromString(*this, val);
return val;
} }
bool CSString::readFromFile(const CSString& fileName) bool CSString::readFromFile(const CSString& fileName)

@ -42,12 +42,20 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#ifdef _WIN32 #include <nel/misc/types_nl.h>
# ifndef __MINGW32__
#ifdef NL_OS_WINDOWS
# define WIN32_LEAN_AND_MEAN
# define _WIN32_WINDOWS 0x0410
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400
# endif
# ifndef NL_COMP_MINGW
# define WINVER 0x0400
# define NOMINMAX # define NOMINMAX
# endif # endif
# include <WinSock2.h> # include <WinSock2.h>
# include <windows.h> # include <Windows.h>
#endif #endif
#endif // NL_STDMISC_H #endif // NL_STDMISC_H

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

Loading…
Cancel
Save