diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 66547c701..2098fb2ec 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -61,7 +61,7 @@ SET(NL_VERSION_MAJOR 0) SET(NL_VERSION_MINOR 12) SET(NL_VERSION_PATCH 0) SET(YEAR "2004-${CURRENT_YEAR}") -SET(AUTHOR "Winchgate and The Ryzom Core Community") +SET(AUTHOR "Winch Gate and The Ryzom Core Community") SET(RYZOM_VERSION_MAJOR 2) SET(RYZOM_VERSION_MINOR 9) diff --git a/code/CMakeModules/AndroidToolChain.cmake b/code/CMakeModules/AndroidToolChain.cmake index 81d9fe566..7135400e2 100644 --- a/code/CMakeModules/AndroidToolChain.cmake +++ b/code/CMakeModules/AndroidToolChain.cmake @@ -22,13 +22,8 @@ IF(NOT TARGET_CPU) SET(TARGET_CPU "armv7") ENDIF() -SET(ARMV7_HARD_FLOAT OFF) - IF(TARGET_CPU STREQUAL "armv7") SET(LIBRARY_ARCHITECTURE "armeabi-v7a") - IF(ARMV7_HARD_FLOAT) - SET(LIBRARY_ARCHITECTURE "${LIBRARY_ARCHITECTURE}-hard") - ENDIF() SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(TOOLCHAIN_ARCH "arm") SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi") @@ -123,6 +118,12 @@ MACRO(SEARCH_TOOLCHAIN _COMPILER) ENDFOREACH() ENDIF() + # try prefixes without version + SET(_TOOLCHAIN_WITHOUT_VERSION "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}") + IF(EXISTS ${_TOOLCHAIN_WITHOUT_VERSION}) + LIST(APPEND ${_COMPILER}_TOOLCHAIN_VERSIONS "default") + ENDIF() + IF(NOT ${_COMPILER}_TOOLCHAIN_VERSIONS) MESSAGE(FATAL_ERROR "No Android ${_COMPILER} toolchain found in default search path ${NDK_ROOT}/toolchains") ENDIF() @@ -136,7 +137,15 @@ MACRO(SEARCH_TOOLCHAIN _COMPILER) LIST(GET ${_COMPILER}_TOOLCHAIN_VERSIONS 0 ${_COMPILER}_TOOLCHAIN_VERSION) ENDIF() - SET(${_COMPILER}_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}-${${_COMPILER}_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}") + MESSAGE(STATUS "TOOLCHAIN_PREFIX = ${${_COMPILER}_TOOLCHAIN_VERSION}") + + IF("${${_COMPILER}_TOOLCHAIN_VERSION}" STREQUAL "default") + MESSAGE(STATUS "default") + SET(${_COMPILER}_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}/prebuilt/${TOOLCHAIN_HOST}") + ELSE() + MESSAGE(STATUS "not default") + SET(${_COMPILER}_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}-${${_COMPILER}_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}") + ENDIF() IF(NOT EXISTS "${${_COMPILER}_TOOLCHAIN_ROOT}") FILE(GLOB _TOOLCHAIN_PREFIXES "${${_COMPILER}_TOOLCHAIN_ROOT}*") @@ -192,7 +201,7 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) MACRO(SET_TOOLCHAIN_BINARY_LLVM _NAME _BINARY) - SET(${_NAME} ${CLANG_TOOLCHAIN_ROOT}/bin/${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE ) + SET(${_NAME} ${CLANG_TOOLCHAIN_ROOT}/bin/${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE) ENDMACRO() MACRO(SET_TOOLCHAIN_BINARY_GCC _NAME _BINARY) @@ -214,6 +223,14 @@ IF(CLANG) SET_TOOLCHAIN_BINARY_LLVM(CMAKE_ASM_COMPILER llvm-as) SET_TOOLCHAIN_BINARY_LLVM(CMAKE_AR llvm-ar) SET_TOOLCHAIN_BINARY_LLVM(CMAKE_LINKER clang++) + + IF(NOT EXISTS "${CMAKE_ASM_COMPILER}") + SET_TOOLCHAIN_BINARY_GCC(CMAKE_ASM_COMPILER as) + ENDIF() + + IF(NOT EXISTS "${CMAKE_AR}") + SET_TOOLCHAIN_BINARY_GCC(CMAKE_AR ar) + ENDIF() ELSE() MESSAGE(STATUS "Using GCC compiler") diff --git a/code/CMakeModules/FindLuabind.cmake b/code/CMakeModules/FindLuabind.cmake index 64fd5e1cf..c21d64e4f 100644 --- a/code/CMakeModules/FindLuabind.cmake +++ b/code/CMakeModules/FindLuabind.cmake @@ -124,7 +124,7 @@ 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) + ENDIF() LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua51) LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua51d) @@ -134,7 +134,7 @@ IF(WITH_LUA50) IF(WITH_STLPORT) LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua50) LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua50d) - ENDIF(WITH_STLPORT) + ENDIF() LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua50) LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua50d) @@ -195,7 +195,7 @@ IF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR) SET(LUABIND_FOUND TRUE) SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_DEBUG}) ENDIF(LUABIND_LIBRARY_RELEASE AND LUABIND_LIBRARY_DEBUG) -ENDIF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR) +ENDIF() IF(LUABIND_FOUND) SET(LUABIND_INCLUDE_DIR ${LUABIND_INCLUDE_DIR} ${Boost_INCLUDE_DIR}) @@ -203,17 +203,17 @@ IF(LUABIND_FOUND) FIND_FILE(LUABIND_VERSION_FILE luabind/version.hpp PATHS ${LUABIND_INCLUDE_DIR}) IF(LUABIND_VERSION_FILE) SET(LUABIND_DEFINITIONS "-DHAVE_LUABIND_VERSION") - ENDIF(LUABIND_VERSION_FILE) + ENDIF() FIND_CORRECT_LUA_VERSION() IF(NOT Luabind_FIND_QUIETLY) MESSAGE(STATUS "Found Luabind: ${LUABIND_LIBRARIES}") ENDIF(NOT Luabind_FIND_QUIETLY) -ELSE(LUABIND_FOUND) +ELSE() IF(NOT Luabind_FIND_QUIETLY) MESSAGE(STATUS "Warning: Unable to find Luabind!") - ENDIF(NOT Luabind_FIND_QUIETLY) + ENDIF() ENDIF(LUABIND_FOUND) MARK_AS_ADVANCED(LUABIND_LIBRARY_RELEASE LUABIND_LIBRARY_DEBUG Boost_LIB_DIAGNOSTIC_DEFINITIONS) diff --git a/code/CMakeModules/FindWindowsSDK.cmake b/code/CMakeModules/FindWindowsSDK.cmake index b91c932f8..43864c6a6 100644 --- a/code/CMakeModules/FindWindowsSDK.cmake +++ b/code/CMakeModules/FindWindowsSDK.cmake @@ -366,19 +366,34 @@ FIND_PATH(WINSDK_LIBRARY_DIR ComCtl32.lib ) IF(WINSDK_UCRT_DIR) - # directory where UCRT headers are found - FIND_PATH(WINSDK_UCRT_INCLUDE_DIR corecrt.h - HINTS - ${WINSDK_UCRT_DIR}/Include/10.0.10056.0/ucrt - ${WINSDK_UCRT_DIR}/Include/10.0.10150.0/ucrt - ) + # determine exact UCRT version + SET(WINSDK_UCRT_INCLUDE_ROOT_DIR ${WINSDK_UCRT_DIR}/Include) + SET(WINSDK_UCRT_LIB_ROOT_DIR ${WINSDK_UCRT_DIR}/Lib) - # directory where UCRT libraries are found - FIND_PATH(WINSDK_UCRT_LIBRARY_DIR ucrt.lib - HINTS - ${WINSDK_UCRT_DIR}/Lib/10.0.10056.0/ucrt/${WINSDK8_SUFFIX} - ${WINSDK_UCRT_DIR}/Lib/10.0.10150.0/ucrt/${WINSDK8_SUFFIX} - ) + FILE(GLOB UCRT_SUBDIRS RELATIVE ${WINSDK_UCRT_INCLUDE_ROOT_DIR} ${WINSDK_UCRT_INCLUDE_ROOT_DIR}/*) + SET(UCRT_VERSION) + + FOREACH(UCRT_SUBDIR ${UCRT_SUBDIRS}) + IF(NOT UCRT_VERSION OR UCRT_SUBDIR VERSION_GREATER UCRT_VERSION) + SET(UCRT_VERSION ${UCRT_SUBDIR}) + ENDIF() + ENDFOREACH() + + IF(UCRT_VERSION) + MESSAGE(STATUS "Using Windows UCRT ${UCRT_VERSION}") + + # directory where UCRT headers are found + FIND_PATH(WINSDK_UCRT_INCLUDE_DIR corecrt.h + HINTS + ${WINSDK_UCRT_INCLUDE_ROOT_DIR}/${UCRT_VERSION}/ucrt + ) + + # directory where UCRT libraries are found + FIND_PATH(WINSDK_UCRT_LIBRARY_DIR ucrt.lib + HINTS + ${WINSDK_UCRT_LIB_ROOT_DIR}/${UCRT_VERSION}/ucrt/${WINSDK8_SUFFIX} + ) + ENDIF() ENDIF() # signtool is used to sign executables diff --git a/code/CMakeModules/iOSToolChain.cmake b/code/CMakeModules/iOSToolChain.cmake index bccfc0236..610045e33 100644 --- a/code/CMakeModules/iOSToolChain.cmake +++ b/code/CMakeModules/iOSToolChain.cmake @@ -177,26 +177,26 @@ ENDIF() # set the architecture for iOS - using ARCHS_STANDARD_32_BIT sets armv7,armv7s and appears to be XCode's standard. # The other value that works is ARCHS_UNIVERSAL_IPHONE_OS but that sets armv7 only IF(ARCHS) - SET(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE string "Build architecture for iOS") + SET(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE STRING "Build architecture for iOS") ENDIF() # Set the find root to the iOS developer roots and to user defined paths -set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} $ENV{EXTERNAL_IOS_PATH} CACHE string "iOS find search path root") +SET(CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} ${CMAKE_SOURCE_DIR}/external $ENV{EXTERNAL_IOS_PATH} CACHE STRING "iOS find search path root") # default to searching for frameworks first -set (CMAKE_FIND_FRAMEWORK FIRST) +SET(CMAKE_FIND_FRAMEWORK FIRST) # set up the default search directories for frameworks -set (CMAKE_SYSTEM_FRAMEWORK_PATH +SET(CMAKE_SYSTEM_FRAMEWORK_PATH ${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks ${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks ${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks ) # only search the iOS sdks, not the remainder of the host filesystem -set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) -set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # determinate location for bin utils based on CMAKE_FIND_ROOT_PATH include(CMakeFindBinUtils) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 4339c0520..941351315 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -246,11 +246,12 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) ### OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" OFF) - IF(WIN32) + # only enable STLport for VC++ 2010 and less + IF(WIN32 AND MSVC_VERSION LESS 1600) OPTION(WITH_STLPORT "With STLport support." ON ) - ELSE(WIN32) + ELSE() OPTION(WITH_STLPORT "With STLport support." OFF) - ENDIF(WIN32) + ENDIF() OPTION(BUILD_DASHBOARD "Build to the CDash dashboard" OFF) @@ -321,7 +322,7 @@ MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) OPTION(WITH_RYZOM_CLIENT "Build Ryzom Core Client" ON ) OPTION(WITH_RYZOM_TOOLS "Build Ryzom Core Tools" ON ) OPTION(WITH_RYZOM_SERVER "Build Ryzom Core Services" ON ) - OPTION(WITH_RYZOM_SOUND "Enable Ryzom Core Sound" ON ) + OPTION(WITH_RYZOM_INSTALLER "Build Ryzom Installer" OFF) ### # Optional support @@ -534,31 +535,31 @@ MACRO(NL_SETUP_BUILD) # without inlining it's unusable, use custom optimizations again SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") ELSEIF(MSVC12) - ADD_PLATFORM_FLAGS("/Gy- /MP") + ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") # /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") + ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") # /Ox is working with VC++ 2012, 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(MSVC10) - ADD_PLATFORM_FLAGS("/Gy- /MP") + ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") # /Ox is working with VC++ 2010, 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(MSVC90) - ADD_PLATFORM_FLAGS("/Gy- /MP") + ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") # don't use a /O[012x] flag if you want custom optimizations SET(RELEASE_CFLAGS "/Ob2 /Oi /Ot /Oy /GT /GF /GS- ${RELEASE_CFLAGS}") # without inlining it's unusable, use custom optimizations again SET(DEBUG_CFLAGS "/Ob1 /GF- ${DEBUG_CFLAGS}") ELSEIF(MSVC80) - ADD_PLATFORM_FLAGS("/Gy- /Wp64") + ADD_PLATFORM_FLAGS("/Gy- /Wp64 /Zm1000") # don't use a /O[012x] flag if you want custom optimizations SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") # without inlining it's unusable, use custom optimizations again @@ -567,7 +568,7 @@ MACRO(NL_SETUP_BUILD) MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") ENDIF(MSVC14) - 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 /wd4250") IF(TARGET_X64) # Fix a bug with Intellisense diff --git a/code/nel/include/nel/3d/zone.h b/code/nel/include/nel/3d/zone.h index 9c60013a8..4aaaea53b 100644 --- a/code/nel/include/nel/3d/zone.h +++ b/code/nel/include/nel/3d/zone.h @@ -163,7 +163,7 @@ public: /** There is (OrderS/2+1) * (OrderT/2+1) tiles light influence. * It indicates which static pointLight influence each corner of a TessBlock (block of 2*2 tiles). * - * If size()==0, suppose no light influence. but CZone::retrieve() always return a + * If empty(), suppose no light influence. but CZone::retrieve() always return a * size() == (OrderS/2+1) * (OrderT/2+1). * * They are stored in line first order, from S=0 to 1, and T=0 to 1. diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 635136220..6b8212c6e 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -39,7 +39,6 @@ namespace NLGUI class CGroupParagraph; extern std::string CurrentCookie; - extern std::string HTTPCurrentDomain; // HTML group /** @@ -78,7 +77,7 @@ namespace NLGUI class CStyleParams { public: - CStyleParams () : TextColor(255,255,255,255) + CStyleParams () : FontFamily(""), TextColor(255,255,255,255) { FontSize=10; FontWeight=400; @@ -93,6 +92,7 @@ namespace NLGUI uint FontSize; uint FontWeight; bool FontOblique; + std::string FontFamily; NLMISC::CRGBA TextColor; bool Underlined; bool StrikeThrough; @@ -282,9 +282,6 @@ namespace NLGUI // A new text block has been parsed virtual void addText (const char * buf, int len); - // A link has been parsed - virtual void addLink (uint element_number, const std::vector &present, const std::vector &value); - // A new begin HTML element has been parsed ( for exemple) virtual void beginElement (uint element_number, const std::vector &present, const std::vector &value); @@ -376,6 +373,7 @@ namespace NLGUI std::string _URL; // Current URL std::string _DocumentUrl; + std::string _DocumentDomain; // Valid base href was found bool _IgnoreBaseUrlTag; // Fragment from loading url @@ -511,6 +509,15 @@ namespace NLGUI return _GlobalColor.back(); } + // Current font name + std::vector _FontFamily; + inline const char* getFontFamily() const + { + if (_FontFamily.empty()) + return ""; + return _FontFamily.back().c_str(); + } + // Current font size std::vector _FontSize; inline uint getFontSize() const diff --git a/code/nel/include/nel/gui/url_parser.h b/code/nel/include/nel/gui/url_parser.h index b47e67b37..758f1d340 100644 --- a/code/nel/include/nel/gui/url_parser.h +++ b/code/nel/include/nel/gui/url_parser.h @@ -51,7 +51,8 @@ namespace NLGUI public: std::string scheme; - std::string domain; + std::string authority; + std::string host; std::string path; std::string query; std::string hash; diff --git a/code/nel/include/nel/gui/view_renderer.h b/code/nel/include/nel/gui/view_renderer.h index a54708b04..3c643bf39 100644 --- a/code/nel/include/nel/gui/view_renderer.h +++ b/code/nel/include/nel/gui/view_renderer.h @@ -586,8 +586,12 @@ namespace NLGUI static NL3D::UDriver *driver; static NL3D::UTextContext *textcontext; + typedef CHashMap< std::string, NL3D::UTextContext* > TFontsList; + static TFontsList fonts; + public: - static NL3D::UTextContext* getTextContext(){ return textcontext; } + static NL3D::UTextContext* getTextContext(const std::string &name=""); + static bool registerFont(const std::string &name, const std::string &font); /// Set of hw cursor images static std::set< std::string > *hwCursors; diff --git a/code/nel/include/nel/gui/view_text.h b/code/nel/include/nel/gui/view_text.h index 35069a9ea..a00932667 100644 --- a/code/nel/include/nel/gui/view_text.h +++ b/code/nel/include/nel/gui/view_text.h @@ -80,6 +80,7 @@ namespace NLGUI /// Set void setText (const ucstring &text); + void setFontName (const std::string &name); void setFontSize (sint nFontSize); void setEmbolden (bool nEmbolden); void setOblique (bool nOblique); @@ -94,6 +95,7 @@ namespace NLGUI void setMultiLineClipEndSpace (bool state); // use it for multiline edit box for instance void setFirstLineX (uint firstLineX); void setMultiMaxLine(uint l) { _MultiMaxLine = l; } + void setMultiMinLine(uint l) { _MultiMinLine = l; } // Force only a subset of letter to be displayed. Default is 0/0xFFFFFFFF void enableStringSelection(uint start, uint end); @@ -103,6 +105,7 @@ namespace NLGUI ucstring getText() const { return _Text; } sint getFontSize() const; + std::string getFontName() const { return _FontName; } bool getEmbolden() { return _Embolden; } bool getOblique() { return _Oblique; } NLMISC::CRGBA getColor() { return _Color; } @@ -114,6 +117,8 @@ namespace NLGUI sint getMultiLineSpace() const { return _MultiLineSpace; } bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; } uint32 getMultiMaxLine() const { return _MultiMaxLine; } + uint32 getMultiMinLine() const { return _MultiMinLine; } + uint32 getMultiMinOffsetY() const; // get current Hint font width, in pixels uint getFontWidth() const; @@ -224,6 +229,8 @@ namespace NLGUI uint _Index; /// info on the computed String associated to this text control NL3D::UTextContext::CStringInfo _Info; + /// Font name to get TextContext + std::string _FontName; /// the font size sint _FontSize; bool _Embolden; @@ -259,6 +266,7 @@ namespace NLGUI sint _MultiLineSpace; sint _LastMultiLineMaxW; uint32 _MultiMaxLine; + uint32 _MultiMinLine; /// FormatTag handling @@ -316,7 +324,7 @@ namespace NLGUI CFormatInfo Format; public: // build from a string, using the current text context - void build(const ucstring &text, uint numSpaces= 0); + void build(const ucstring &text, NL3D::UTextContext &textContext, uint numSpaces= 0); }; typedef std::vector TWordVect; @@ -327,9 +335,9 @@ namespace NLGUI // ctor CLine(); // Clear the line & remove text contexts - void clear(); + void clear(NL3D::UTextContext &textContext); // Add a new word (and its context) in the line + a number of spaces to append at the end of the line - void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth); + void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth, NL3D::UTextContext &textContext); void addWord(const CWord &word, uint fontWidth); uint getNumWords() const { return (uint)_Words.size(); } CWord &getWord(uint index) { return _Words[index]; } diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index cfb51af8e..2f9220cda 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -442,6 +442,7 @@ namespace NLGUI OptionTimeoutMessages, OptionTimeoutContext, OptionTimeoutContextHtml, + OptionMonospaceFont, NumSystemOptions }; diff --git a/code/nel/include/nel/misc/cdb.h b/code/nel/include/nel/misc/cdb.h index bc02dc85b..46fcc4849 100644 --- a/code/nel/include/nel/misc/cdb.h +++ b/code/nel/include/nel/misc/cdb.h @@ -120,9 +120,9 @@ public: */ std::string toString() const { - if (_Ids.size()==0) return std::string(""); + if (_Ids.empty()) return std::string(""); std::string str=_Ids[0]; - for (unsigned i=1; i<_Ids.size(); i++) + for (uint i=1; i<_Ids.size(); i++) str +=std::string(":")+ _Ids[i]; return str; } diff --git a/code/nel/src/3d/driver.cpp b/code/nel/src/3d/driver.cpp index 9bd23f815..3ba0178f2 100644 --- a/code/nel/src/3d/driver.cpp +++ b/code/nel/src/3d/driver.cpp @@ -50,14 +50,14 @@ IDriver::~IDriver() { CSynchronized::CAccessor access(&_SyncTexDrvInfos); TTexDrvInfoPtrMap &rTexDrvInfos = access.value(); - nlassert( rTexDrvInfos.size() == 0 ); + nlassert(rTexDrvInfos.empty()); } - nlassert(_TexDrvShares.size()==0); - nlassert(_MatDrvInfos.size()==0); - nlassert(_VBDrvInfos.size()==0); - nlassert(_IBDrvInfos.size()==0); - nlassert(_GPUPrgDrvInfos.size()==0); + nlassert(_TexDrvShares.empty()); + nlassert(_MatDrvInfos.empty()); + nlassert(_VBDrvInfos.empty()); + nlassert(_IBDrvInfos.empty()); + nlassert(_GPUPrgDrvInfos.empty()); } diff --git a/code/nel/src/3d/driver/direct3d/CMakeLists.txt b/code/nel/src/3d/driver/direct3d/CMakeLists.txt index 125815dc0..d74bdeceb 100644 --- a/code/nel/src/3d/driver/direct3d/CMakeLists.txt +++ b/code/nel/src/3d/driver/direct3d/CMakeLists.txt @@ -4,7 +4,7 @@ NL_TARGET_DRIVER(nel_drv_direct3d_win ${SRC}) INCLUDE_DIRECTORIES(BEFORE ${DXSDK_INCLUDE_DIR}) -TARGET_LINK_LIBRARIES(nel_drv_direct3d_win nel3d nelmisc ${DXSDK_D3DX9_LIBRARY} ${DXSDK_D3D9_LIBRARY} ${DXSDK_DINPUT_LIBRARY} ${DXSDK_GUID_LIBRARY}) +TARGET_LINK_LIBRARIES(nel_drv_direct3d_win nel3d nelmisc ${DXSDK_D3DX9_LIBRARY} ${DXSDK_D3D9_LIBRARY}) NL_DEFAULT_PROPS(nel_drv_direct3d_win "NeL, Driver, Video: Direct3D") NL_ADD_RUNTIME_FLAGS(nel_drv_direct3d_win) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp index ad5bb04b9..2b7fa8fa9 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_vertex.cpp @@ -125,7 +125,7 @@ uint8 *CVBDrvInfosD3D::lock (uint begin, uint end, bool readOnly) } else { - nlinfo("Buffer %s at %x is Locked", (*it)->VertexBufferPtr->getName().c_str(), (int) *it); + nlinfo("Buffer %s at %p is Locked", (*it)->VertexBufferPtr->getName().c_str(), *it); } } } diff --git a/code/nel/src/3d/driver/opengl/GL/glext.h b/code/nel/src/3d/driver/opengl/GL/glext.h index ea6c7c396..47b435bce 100644 --- a/code/nel/src/3d/driver/opengl/GL/glext.h +++ b/code/nel/src/3d/driver/opengl/GL/glext.h @@ -6,7 +6,7 @@ extern "C" { #endif /* -** Copyright (c) 2013-2015 The Khronos Group Inc. +** Copyright (c) 2013-2016 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -33,7 +33,7 @@ extern "C" { ** used to make the header, and the header can be found at ** http://www.opengl.org/registry/ ** -** Khronos $Revision: 32155 $ on $Date: 2015-10-22 23:25:39 -0400 (Thu, 22 Oct 2015) $ +** Khronos $Revision: 32957 $ on $Date: 2016-06-09 17:03:08 -0400 (Thu, 09 Jun 2016) $ */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -53,7 +53,7 @@ extern "C" { #define GLAPI extern #endif -#define GL_GLEXT_VERSION 20151022 +#define GL_GLEXT_VERSION 20160609 /* Generated C header for: * API: gl @@ -5596,6 +5596,10 @@ GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLf #define GL_AMD_shader_atomic_counter_ops 1 #endif /* GL_AMD_shader_atomic_counter_ops */ +#ifndef GL_AMD_shader_explicit_vertex_parameter +#define GL_AMD_shader_explicit_vertex_parameter 1 +#endif /* GL_AMD_shader_explicit_vertex_parameter */ + #ifndef GL_AMD_shader_stencil_export #define GL_AMD_shader_stencil_export 1 #endif /* GL_AMD_shader_stencil_export */ @@ -8636,6 +8640,20 @@ GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei s #endif #endif /* GL_EXT_vertex_weighting */ +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + #ifndef GL_EXT_x11_sync_object #define GL_EXT_x11_sync_object 1 #define GL_SYNC_X11_FENCE_EXT 0x90E1 @@ -9129,6 +9147,17 @@ GLAPI void APIENTRY glBlendBarrierNV (void); #define GL_NV_blend_square 1 #endif /* GL_NV_blend_square */ +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + #ifndef GL_NV_command_list #define GL_NV_command_list 1 #define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 @@ -9231,6 +9260,17 @@ GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat valu #endif #endif /* GL_NV_conservative_raster_dilate */ +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + #ifndef GL_NV_copy_depth_to_color #define GL_NV_copy_depth_to_color 1 #define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E @@ -10223,6 +10263,11 @@ GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, #endif #endif /* GL_NV_register_combiners2 */ +#ifndef GL_NV_robustness_video_memory_purge +#define GL_NV_robustness_video_memory_purge 1 +#define GL_PURGED_CONTEXT_RESET_NV 0x92BB +#endif /* GL_NV_robustness_video_memory_purge */ + #ifndef GL_NV_sample_locations #define GL_NV_sample_locations 1 #define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D @@ -10255,6 +10300,10 @@ GLAPI void APIENTRY glResolveDepthValuesNV (void); #define GL_NV_shader_atomic_float 1 #endif /* GL_NV_shader_atomic_float */ +#ifndef GL_NV_shader_atomic_float64 +#define GL_NV_shader_atomic_float64 1 +#endif /* GL_NV_shader_atomic_float64 */ + #ifndef GL_NV_shader_atomic_fp16_vector #define GL_NV_shader_atomic_fp16_vector 1 #endif /* GL_NV_shader_atomic_fp16_vector */ @@ -10318,6 +10367,10 @@ GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLs #define GL_NV_shader_thread_shuffle 1 #endif /* GL_NV_shader_thread_shuffle */ +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + #ifndef GL_NV_tessellation_program5 #define GL_NV_tessellation_program5 1 #define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 @@ -11088,6 +11141,26 @@ GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot #define GL_NV_viewport_array2 1 #endif /* GL_NV_viewport_array2 */ +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + #ifndef GL_OML_interlace #define GL_OML_interlace 1 #define GL_INTERLACE_OML 0x8980 diff --git a/code/nel/src/3d/driver/opengl/GL/glxext.h b/code/nel/src/3d/driver/opengl/GL/glxext.h index 227045ad9..dce029046 100644 --- a/code/nel/src/3d/driver/opengl/GL/glxext.h +++ b/code/nel/src/3d/driver/opengl/GL/glxext.h @@ -6,7 +6,7 @@ extern "C" { #endif /* -** Copyright (c) 2013-2015 The Khronos Group Inc. +** Copyright (c) 2013-2016 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -33,10 +33,10 @@ extern "C" { ** used to make the header, and the header can be found at ** http://www.opengl.org/registry/ ** -** Khronos $Revision: 31597 $ on $Date: 2015-06-25 16:32:35 -0400 (Thu, 25 Jun 2015) $ +** Khronos $Revision: 32889 $ on $Date: 2016-05-31 07:09:51 -0400 (Tue, 31 May 2016) $ */ -#define GLX_GLXEXT_VERSION 20150623 +#define GLX_GLXEXT_VERSION 20160531 /* Generated C header for: * API: glx @@ -317,6 +317,11 @@ void glXFreeContextEXT (Display *dpy, GLXContext context); #endif #endif /* GLX_EXT_import_context */ +#ifndef GLX_EXT_libglvnd +#define GLX_EXT_libglvnd 1 +#define GLX_VENDOR_NAMES_EXT 0x20F6 +#endif /* GLX_EXT_libglvnd */ + #ifndef GLX_EXT_stereo_tree #define GLX_EXT_stereo_tree 1 typedef struct { @@ -543,6 +548,11 @@ int glXBindVideoDeviceNV (Display *dpy, unsigned int video_slot, unsigned int vi #endif #endif /* GLX_NV_present_video */ +#ifndef GLX_NV_robustness_video_memory_purge +#define GLX_NV_robustness_video_memory_purge 1 +#define GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x20F7 +#endif /* GLX_NV_robustness_video_memory_purge */ + #ifndef GLX_NV_swap_group #define GLX_NV_swap_group 1 typedef Bool ( *PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group); diff --git a/code/nel/src/3d/driver/opengl/GL/wglext.h b/code/nel/src/3d/driver/opengl/GL/wglext.h index 912e31c64..8c39b96cf 100644 --- a/code/nel/src/3d/driver/opengl/GL/wglext.h +++ b/code/nel/src/3d/driver/opengl/GL/wglext.h @@ -6,7 +6,7 @@ extern "C" { #endif /* -** Copyright (c) 2013-2015 The Khronos Group Inc. +** Copyright (c) 2013-2016 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -33,7 +33,7 @@ extern "C" { ** used to make the header, and the header can be found at ** http://www.opengl.org/registry/ ** -** Khronos $Revision: 31597 $ on $Date: 2015-06-25 16:32:35 -0400 (Thu, 25 Jun 2015) $ +** Khronos $Revision: 32686 $ on $Date: 2016-04-19 21:08:44 -0400 (Tue, 19 Apr 2016) $ */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -41,7 +41,7 @@ extern "C" { #include #endif -#define WGL_WGLEXT_VERSION 20150623 +#define WGL_WGLEXT_VERSION 20160419 /* Generated C header for: * API: wgl diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 8ad9228ef..6ab0e3336 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -676,8 +676,8 @@ bool CDriverGL::setupDisplay() } #endif - // Reset the vbl interval - setSwapVBLInterval(_Interval); + // Get initial VBL interval + _Interval = getSwapVBLInterval(); return true; } @@ -2288,16 +2288,22 @@ void CDriverGL::setSwapVBLInterval(uint interval) H_AUTO_OGL(CDriverGL_setSwapVBLInterval); if (!_Initialized) + { + nlwarning("OpenGL driver not initialized when calling setSwapVBLInterval"); return; + } bool res = true; + // don't try to change VBL if interval didn't change + if (_Interval == interval) return; + #ifdef USE_OPENGLES - res = eglSwapInterval(_EglDisplay, _Interval) == EGL_TRUE; + res = eglSwapInterval(_EglDisplay, interval) == EGL_TRUE; #elif defined(NL_OS_WINDOWS) if(_Extensions.WGLEXTSwapControl) { - res = nwglSwapIntervalEXT(_Interval) == TRUE; + res = nwglSwapIntervalEXT(interval) == TRUE; } #elif defined(NL_OS_MAC) [_ctx setValues:(GLint*)&interval forParameter:NSOpenGLCPSwapInterval]; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp index d9850a039..373c501bf 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -1991,24 +1991,32 @@ bool registerWGlExtensions(CGlExtensions &ext, HDC hDC) if (ext.WGLNVGPUAffinity) { - uint i = 0; + uint gpuIndex = 0; HGPUNV hGPU; - while(nwglEnumGpusNV(i, &hGPU)) + // list all GPUs + while (nwglEnumGpusNV(gpuIndex, &hGPU)) { uint j = 0; - PGPU_DEVICE lpGpuDevice = NULL; + _GPU_DEVICE gpuDevice; + gpuDevice.cb = sizeof(gpuDevice); - while(nwglEnumGpuDevicesNV(hGPU, j, lpGpuDevice)) + // list all devices connected to GPU + while(nwglEnumGpuDevicesNV(hGPU, j, &gpuDevice)) { - nlinfo("Device: %s - %s - flags: %u", lpGpuDevice->DeviceName, lpGpuDevice->DeviceString, lpGpuDevice->Flags); + nlinfo("Device: %s / %s / flags: %u", gpuDevice.DeviceName, gpuDevice.DeviceString, (uint)gpuDevice.Flags); + + if (gpuDevice.Flags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) + { + nlinfo("Virtual screen: (%d,%d)-(%d,%d)", (sint)gpuDevice.rcVirtualScreen.left, (sint)gpuDevice.rcVirtualScreen.top, (sint)gpuDevice.rcVirtualScreen.right, (sint)gpuDevice.rcVirtualScreen.bottom); + } ++j; } - ++i; + ++gpuIndex; } } diff --git a/code/nel/src/3d/dru.cpp b/code/nel/src/3d/dru.cpp index bb86d8b84..fd3e77404 100644 --- a/code/nel/src/3d/dru.cpp +++ b/code/nel/src/3d/dru.cpp @@ -528,7 +528,7 @@ void CDRU::drawTrianglesUnlit(const NLMISC::CTriangleUV *trilist, sint ntris, // *************************************************************************** void CDRU::drawTrianglesUnlit(const std::vector &trilist, CMaterial &mat, IDriver& driver) { - if(trilist.size()==0) + if(trilist.empty()) return; CDRU::drawTrianglesUnlit( &(*trilist.begin()), (uint)trilist.size(), mat, driver); @@ -570,7 +570,7 @@ void CDRU::drawLinesUnlit(const NLMISC::CLine *linelist, sint nlines, CMateria // *************************************************************************** void CDRU::drawLinesUnlit(const std::vector &linelist, CMaterial &mat, IDriver& driver) { - if(linelist.size()==0) + if(linelist.empty()) return; CDRU::drawLinesUnlit( &(*linelist.begin()), (sint)linelist.size(), mat, driver); } diff --git a/code/nel/src/3d/landscape.cpp b/code/nel/src/3d/landscape.cpp index ccdeabc34..d588fa424 100644 --- a/code/nel/src/3d/landscape.cpp +++ b/code/nel/src/3d/landscape.cpp @@ -2859,7 +2859,7 @@ void CLandscape::setupAutomaticLightDir(const CVector &lightDir) // *************************************************************************** CVector CLandscape::getHeightFieldDeltaZ(float x, float y) const { - if(_HeightField.ZPatchs.size()==0) + if(_HeightField.ZPatchs.empty()) return CVector::Null; // map to _HeightField coordinates. diff --git a/code/nel/src/3d/landscapevb_allocator.cpp b/code/nel/src/3d/landscapevb_allocator.cpp index 43c38ab64..c6815ea05 100644 --- a/code/nel/src/3d/landscapevb_allocator.cpp +++ b/code/nel/src/3d/landscapevb_allocator.cpp @@ -134,7 +134,7 @@ void CLandscapeVBAllocator::resetReallocation() uint CLandscapeVBAllocator::allocateVertex() { // if no more free, allocate. - if( _VertexFreeMemory.size()==0 ) + if( _VertexFreeMemory.empty() ) { // enlarge capacity. uint newResize; diff --git a/code/nel/src/3d/mesh.cpp b/code/nel/src/3d/mesh.cpp index a533632c5..0d3095182 100644 --- a/code/nel/src/3d/mesh.cpp +++ b/code/nel/src/3d/mesh.cpp @@ -52,7 +52,7 @@ namespace NL3D static NLMISC::CAABBoxExt makeBBox(const std::vector &Vertices) { NLMISC::CAABBox ret; - nlassert(Vertices.size()); + nlassert(!Vertices.empty()); ret.setCenter(Vertices[0]); for(sint i=0;i<(sint)Vertices.size();i++) { @@ -167,7 +167,7 @@ void CMeshGeom::build (CMesh::CMeshBuild &m, uint numMaxMaterial) sint i; // Empty geometry? - if(m.Vertices.size()==0 || m.Faces.size()==0) + if(m.Vertices.empty() || m.Faces.empty()) { _VBuffer.setNumVertices(0); _VBuffer.setName("CMeshGeom"); @@ -436,7 +436,7 @@ void CMeshGeom::build (CMesh::CMeshBuild &m, uint numMaxMaterial) } // Set the vertex buffer preferred memory - bool avoidVBHard= _Skinned || ( _MeshMorpher && _MeshMorpher->BlendShapes.size()>0 ); + bool avoidVBHard= _Skinned || ( _MeshMorpher && !_MeshMorpher->BlendShapes.empty() ); _VBuffer.setPreferredMemory (avoidVBHard?CVertexBuffer::RAMPreferred:CVertexBuffer::StaticPreferred, false); // End!! @@ -638,7 +638,7 @@ void CMeshGeom::render(IDriver *drv, CTransformShape *trans, float polygonCount, for(uint mb=0;mb<_MatrixBlocks.size();mb++) { CMatrixBlock &mBlock= _MatrixBlocks[mb]; - if(mBlock.RdrPass.size()==0) + if(mBlock.RdrPass.empty()) continue; // Global alpha ? @@ -790,7 +790,7 @@ void CMeshGeom::renderSkin(CTransformShape *trans, float alphaMRM) for(uint mb=0;mb<_MatrixBlocks.size();mb++) { CMatrixBlock &mBlock= _MatrixBlocks[mb]; - if(mBlock.RdrPass.size()==0) + if(mBlock.RdrPass.empty()) continue; // Render all pass. @@ -840,7 +840,7 @@ void CMeshGeom::renderSimpleWithMaterial(IDriver *drv, const CMatrix &worldMatri for(uint mb=0;mb<_MatrixBlocks.size();mb++) { CMatrixBlock &mBlock= _MatrixBlocks[mb]; - if(mBlock.RdrPass.size()==0) + if(mBlock.RdrPass.empty()) continue; // Render all pass. @@ -998,10 +998,10 @@ void CMeshGeom::compileRunTime() _PreciseClipping= _BBox.getRadius() >= NL3D_MESH_PRECISE_CLIP_THRESHOLD; // Support MeshBlockRendering only if not skinned/meshMorphed. - bool supportMeshBlockRendering= !_Skinned && _MeshMorpher->BlendShapes.size()==0; + bool supportMeshBlockRendering= !_Skinned && _MeshMorpher->BlendShapes.empty(); // true only if one matrix block, and at least one rdrPass. - supportMeshBlockRendering= supportMeshBlockRendering && _MatrixBlocks.size()==1 && _MatrixBlocks[0].RdrPass.size()>0; + supportMeshBlockRendering= supportMeshBlockRendering && _MatrixBlocks.size()==1 && !_MatrixBlocks[0].RdrPass.empty(); if (supportMeshBlockRendering && _MeshVertexProgram) { supportMeshBlockRendering = supportMeshBlockRendering && _MeshVertexProgram->supportMeshBlockRendering(); @@ -1021,7 +1021,7 @@ void CMeshGeom::compileRunTime() if(supportMBRPerMaterial) _SupportMBRFlags|= MBRSortPerMaterial; - bool avoidVBHard= _Skinned || ( _MeshMorpher && _MeshMorpher->BlendShapes.size()>0 ); + bool avoidVBHard= _Skinned || ( _MeshMorpher && !_MeshMorpher->BlendShapes.empty() ); _VBuffer.setPreferredMemory (avoidVBHard?CVertexBuffer::RAMPreferred:CVertexBuffer::StaticPreferred, false); } diff --git a/code/nel/src/3d/mesh_morpher.cpp b/code/nel/src/3d/mesh_morpher.cpp index 4d7ed8255..39f44a130 100644 --- a/code/nel/src/3d/mesh_morpher.cpp +++ b/code/nel/src/3d/mesh_morpher.cpp @@ -407,9 +407,10 @@ void CMeshMorpher::updateRawSkin (CVertexBuffer *vbOri, rFactor*= 0.01f; uint32 numVertices= (uint32)rBS.VertRefs.size(); // don't know why, but cases happen where deltaNorm not empty while deltaPos is - bool hasPos= rBS.deltaPos.size()>0; - bool hasNorm= rBS.deltaNorm.size()>0; - bool hasUV= rBS.deltaUV.size()>0; + bool hasPos = !rBS.deltaPos.empty(); + bool hasNorm = !rBS.deltaNorm.empty(); + bool hasUV = !rBS.deltaUV.empty(); + for (j = 0; j < numVertices; ++j) { // Get the vertex Index in the VBufferFinal diff --git a/code/nel/src/3d/mesh_mrm.cpp b/code/nel/src/3d/mesh_mrm.cpp index 999b3b62d..e5b61c966 100644 --- a/code/nel/src/3d/mesh_mrm.cpp +++ b/code/nel/src/3d/mesh_mrm.cpp @@ -180,7 +180,7 @@ void CMeshMRMGeom::CLod::optimizeTriangleOrder() static NLMISC::CAABBoxExt makeBBox(const std::vector &Vertices) { NLMISC::CAABBox ret; - nlassert(Vertices.size()); + nlassert(!Vertices.empty()); ret.setCenter(Vertices[0]); for(sint i=0;i<(sint)Vertices.size();i++) { @@ -236,7 +236,7 @@ void CMeshMRMGeom::build(CMesh::CMeshBuild &m, std::vector uint numMaxMaterial, const CMRMParameters ¶ms) { // Empty geometry? - if(m.Vertices.size()==0 || m.Faces.size()==0) + if(m.Vertices.empty() || m.Faces.empty()) { _VBufferFinal.setNumVertices(0); _VBufferFinal.reserve(0); @@ -308,7 +308,7 @@ void CMeshMRMGeom::build(CMesh::CMeshBuild &m, std::vector _LevelDetail.MaxFaceUsed= 0; _LevelDetail.MinFaceUsed= 0; // Count of primitive block - if(_Lods.size()>0) + if (!_Lods.empty()) { uint pb; // Compute MinFaces. @@ -469,7 +469,7 @@ void CMeshMRMGeom::applyGeomorph(std::vector &geoms, float alpha void CMeshMRMGeom::applyGeomorphWithVBHardPtr(std::vector &geoms, float alphaLod, uint8 *vertexDestPtr) { // no geomorphs? quit. - if(geoms.size()==0) + if(geoms.empty()) return; clamp(alphaLod, 0.f, 1.f); @@ -900,7 +900,7 @@ inline sint CMeshMRMGeom::chooseLod(float alphaMRM, float &alphaLod) void CMeshMRMGeom::render(IDriver *drv, CTransformShape *trans, float polygonCount, uint32 rdrFlags, float globalAlpha) { nlassert(drv); - if(_Lods.size()==0) + if(_Lods.empty()) return; @@ -922,7 +922,7 @@ void CMeshMRMGeom::render(IDriver *drv, CTransformShape *trans, float polygonCou // Render the choosen Lod. CLod &lod= _Lods[numLod]; - if(lod.RdrPass.size()==0) + if(lod.RdrPass.empty()) return; @@ -1104,7 +1104,7 @@ void CMeshMRMGeom::renderSkin(CTransformShape *trans, float alphaMRM) { H_AUTO( NL3D_MeshMRMGeom_renderSkin ); - if(_Lods.size()==0) + if(_Lods.empty()) return; @@ -1126,7 +1126,7 @@ void CMeshMRMGeom::renderSkin(CTransformShape *trans, float alphaMRM) // Render the choosen Lod. CLod &lod= _Lods[numLod]; - if(lod.RdrPass.size()==0) + if(lod.RdrPass.empty()) return; @@ -1295,7 +1295,7 @@ sint CMeshMRMGeom::renderSkinGroupGeom(CMeshMRMInstance *mi, float alphaMRM, uin // Render the choosen Lod. CLod &lod= _Lods[numLod]; - if(lod.RdrPass.size()==0) + if(lod.RdrPass.empty()) // return no vertices added return 0; @@ -1942,7 +1942,7 @@ void CMeshMRMGeom::loadFirstLod(NLMISC::IStream &f) // If empty MRM, quit. - if(_LodInfos.size()==0) + if(_LodInfos.empty()) return; /* If the version is <4, then SkinWeights are serialised per Lod. @@ -2431,7 +2431,7 @@ void CMeshMRMGeom::compileRunTime() _PreciseClipping= _BBox.getRadius() >= NL3D_MESH_PRECISE_CLIP_THRESHOLD; // Compute if can support SkinGrouping rendering - if(_Lods.size()==0 || !_Skinned) + if(_Lods.empty() || !_Skinned) { _SupportSkinGrouping= false; _SupportShadowSkinGrouping= false; @@ -2451,7 +2451,7 @@ void CMeshMRMGeom::compileRunTime() } // Support MeshBlockRendering only if not skinned/meshMorphed. - _SupportMeshBlockRendering= !_Skinned && _MeshMorpher.BlendShapes.size()==0; + _SupportMeshBlockRendering= !_Skinned && _MeshMorpher.BlendShapes.empty(); // \todo yoyo: support later MeshVertexProgram _SupportMeshBlockRendering= _SupportMeshBlockRendering && _MeshVertexProgram==NULL; @@ -3367,7 +3367,7 @@ void CMeshMRMGeom::updateRawSkinNormal(bool enabled, CMeshMRMInstance *mi, sint // Case of MeshMorpher //======== - if(_MeshMorpher.BlendShapes.size()>0) + if(!_MeshMorpher.BlendShapes.empty()) { skinLod.VertexRemap.resize((uint32)vertexFinalRemap.size()); diff --git a/code/nel/src/3d/mesh_mrm_skin.cpp b/code/nel/src/3d/mesh_mrm_skin.cpp index 23ff04fee..7bba5d370 100644 --- a/code/nel/src/3d/mesh_mrm_skin.cpp +++ b/code/nel/src/3d/mesh_mrm_skin.cpp @@ -55,7 +55,7 @@ namespace NL3D void CMeshMRMGeom::applySkin(CLod &lod, const CSkeletonModel *skeleton) { nlassert(_Skinned); - if(_SkinWeights.size()==0) + if(_SkinWeights.empty()) return; // get vertexPtr. diff --git a/code/nel/src/3d/mesh_mrm_skin_template.cpp b/code/nel/src/3d/mesh_mrm_skin_template.cpp index 4a9e11106..63a0b67e8 100644 --- a/code/nel/src/3d/mesh_mrm_skin_template.cpp +++ b/code/nel/src/3d/mesh_mrm_skin_template.cpp @@ -380,7 +380,7 @@ static void applyArraySkinTangentSpaceT(uint numMatrixes, uint32 *infPtr, CMesh: void CMeshMRMGeom::applySkinWithNormal(CLod &lod, const CSkeletonModel *skeleton) { nlassert(_Skinned); - if(_SkinWeights.size()==0) + if(_SkinWeights.empty()) return; // get vertexPtr / normalOff. @@ -446,7 +446,7 @@ void CMeshMRMGeom::applySkinWithTangentSpace(CLod &lod, const CSkeletonModel *sk uint tangentSpaceTexCoord) { nlassert(_Skinned); - if(_SkinWeights.size()==0) + if(_SkinWeights.empty()) return; // get vertexPtr / normalOff / tangent space offset. @@ -1468,7 +1468,7 @@ void CMeshMRMGeom::applyArrayRawSkinNormal4(CRawVertexNormalSkin4 *src, uint8 * void CMeshMRMGeom::applyRawSkinWithNormal(CLod &lod, CRawSkinNormalCache &rawSkinLod, const CSkeletonModel *skeleton, uint8 *vbHard, float alphaLod) { nlassert(_Skinned); - if(_SkinWeights.size()==0) + if(_SkinWeights.empty()) return; // Some assert diff --git a/code/nel/src/3d/mesh_mrm_skinned.cpp b/code/nel/src/3d/mesh_mrm_skinned.cpp index 6af29bf73..11a1b41fc 100644 --- a/code/nel/src/3d/mesh_mrm_skinned.cpp +++ b/code/nel/src/3d/mesh_mrm_skinned.cpp @@ -160,7 +160,7 @@ void CMeshMRMSkinnedGeom::CLod::buildPrimitiveBlock(uint renderPass, const CInde static NLMISC::CAABBoxExt makeBBox(const std::vector &Vertices) { NLMISC::CAABBox ret; - nlassert(Vertices.size()); + nlassert(!Vertices.empty()); ret.setCenter(Vertices[0]); for(sint i=0;i<(sint)Vertices.size();i++) { @@ -211,7 +211,7 @@ void CMeshMRMSkinnedGeom::build(CMesh::CMeshBuild &m, uint numMaxMaterial, const CMRMParameters ¶ms) { // Empty geometry? - if(m.Vertices.size()==0 || m.Faces.size()==0) + if(m.Vertices.empty() || m.Faces.empty()) { _VBufferFinal.clear(); _Lods.clear(); @@ -261,7 +261,7 @@ void CMeshMRMSkinnedGeom::build(CMesh::CMeshBuild &m, _LevelDetail.MaxFaceUsed= 0; _LevelDetail.MinFaceUsed= 0; // Count of primitive block - if(_Lods.size()>0) + if(!_Lods.empty()) { uint pb; // Compute MinFaces. @@ -421,7 +421,7 @@ void CMeshMRMSkinnedGeom::applyGeomorph(std::vector &geoms, floa void CMeshMRMSkinnedGeom::applyGeomorphWithVBHardPtr(std::vector &geoms, float alphaLod) { // no geomorphs? quit. - if(geoms.size()==0) + if(geoms.empty()) return; clamp(alphaLod, 0.f, 1.f); @@ -579,7 +579,7 @@ inline sint CMeshMRMSkinnedGeom::chooseLod(float alphaMRM, float &alphaLod) void CMeshMRMSkinnedGeom::render(IDriver *drv, CTransformShape *trans, float polygonCount, uint32 rdrFlags, float globalAlpha) { nlassert(drv); - if(_Lods.size()==0) + if(_Lods.empty()) return; @@ -597,7 +597,7 @@ void CMeshMRMSkinnedGeom::render(IDriver *drv, CTransformShape *trans, float pol // Render the choosen Lod. CLod &lod= _Lods[numLod]; - if(lod.RdrPass.size()==0) + if(lod.RdrPass.empty()) return; @@ -757,7 +757,7 @@ sint CMeshMRMSkinnedGeom::renderSkinGroupGeom(CMeshMRMSkinnedInstance *mi, float // Render the choosen Lod. CLod &lod= _Lods[numLod]; - if(lod.RdrPass.size()==0) + if(lod.RdrPass.empty()) // return no vertices added return 0; diff --git a/code/nel/src/3d/mrm_builder.cpp b/code/nel/src/3d/mrm_builder.cpp index 1002436d7..3035aa78b 100644 --- a/code/nel/src/3d/mrm_builder.cpp +++ b/code/nel/src/3d/mrm_builder.cpp @@ -3119,7 +3119,7 @@ bool CMRMBuilder::buildMRMSewingMeshes(const CMesh::CMeshBuild &mbuild, uint nWa { nlassert(nWantedLods>=1); nlassert(divisor>=1); - if(mbuild.Interfaces.size()==0) + if(mbuild.Interfaces.empty()) return false; // must have same size if(mbuild.InterfaceLinks.size()!=mbuild.Vertices.size()) diff --git a/code/nel/src/3d/patch.cpp b/code/nel/src/3d/patch.cpp index 799e5b8a3..4b0253ead 100644 --- a/code/nel/src/3d/patch.cpp +++ b/code/nel/src/3d/patch.cpp @@ -604,7 +604,8 @@ void CPatch::addRefTessBlocks() uint i; TessBlockRefCount++; - if(TessBlocks.size()==0) + + if (TessBlocks.empty()) { // Allocate the tessblocks. //========== @@ -1629,7 +1630,7 @@ void CPatch::serial(NLMISC::IStream &f) // then just copy to TileColors. TileColors.resize(tmpArray.size()); - if(TileColors.size()>0) + if(!TileColors.empty()) { memcpy(&TileColors[0], &tmpArray[0], TileColors.size()*sizeof(CTileColor)); } diff --git a/code/nel/src/3d/patch_render.cpp b/code/nel/src/3d/patch_render.cpp index bc74648d3..ee916a3fe 100644 --- a/code/nel/src/3d/patch_render.cpp +++ b/code/nel/src/3d/patch_render.cpp @@ -1452,7 +1452,7 @@ void CPatch::computeSoftwareGeomorphAndAlpha() // Need only to fill CTessVertex, so do it only for FarVertices // Hence Geomorph is done twice on edges of patches!!. // If not too near for precise, fast compute of geomorph. - if( TessBlocks.size()==0 ) + if( TessBlocks.empty() ) { // Just update all vertices of master block. computeGeomorphVertexList(MasterBlock.FarVertexList); diff --git a/code/nel/src/3d/patchdlm_context.cpp b/code/nel/src/3d/patchdlm_context.cpp index 53d580e66..f7d2236e8 100644 --- a/code/nel/src/3d/patchdlm_context.cpp +++ b/code/nel/src/3d/patchdlm_context.cpp @@ -540,7 +540,7 @@ bool CPatchDLMContext::generate(CPatch *patch, CTextureDLM *textureDLM, CPatch #ifndef NL_DLM_TILE_RES // retrieve patch tileColor pointer. - nlassert(_Patch->TileColors.size()>0); + nlassert(!_Patch->TileColors.empty()); CTileColor *tileColor= &_Patch->TileColors[0]; // skip 1 tiles colors per column and per row @@ -898,7 +898,7 @@ void CPatchDLMContext::compileLighting(TCompileType compType, CRGBA modulateCt if(! (_IsSrcTextureFullBlack && _IsDstTextureFullBlack) ) { // if lightMap allocated - if(_LightMap.size()>0 && _DLMTexture) + if(!_LightMap.empty() && _DLMTexture) { // If the srcTexture is full black (ie no pointLight influence touch it), if(_IsSrcTextureFullBlack) diff --git a/code/nel/src/3d/ps_face.cpp b/code/nel/src/3d/ps_face.cpp index 63909287d..e87459acf 100644 --- a/code/nel/src/3d/ps_face.cpp +++ b/code/nel/src/3d/ps_face.cpp @@ -226,7 +226,7 @@ void CPSFace::step(TPSProcessPass pass) else if (pass == PSMotion) { - if (_PrecompBasis.size()) // do we use precomputed basis ? + if (!_PrecompBasis.empty()) // do we use precomputed basis ? { // rotate all precomputed basis for (CPSVector< CPlaneBasisPair >::V::iterator it = _PrecompBasis.begin(); it != _PrecompBasis.end(); ++it) @@ -394,7 +394,7 @@ void CPSFace::deleteElement(uint32 index) NL_PS_FUNC(CPSFace_deleteElement) CPSQuad::deleteElement(index); deletePlaneBasisElement(index); - if (_PrecompBasis.size()) // do we use precomputed basis ? + if (!_PrecompBasis.empty()) // do we use precomputed basis ? { // replace ourself by the last element... _IndexInPrecompBasis[index] = _IndexInPrecompBasis[_Owner->getSize() - 1]; @@ -407,7 +407,7 @@ void CPSFace::resize(uint32 size) NL_PS_FUNC(CPSFace_resize) nlassert(size < (1 << 16)); resizePlaneBasis(size); - if (_PrecompBasis.size()) // do we use precomputed basis ? + if (!_PrecompBasis.empty()) // do we use precomputed basis ? { _IndexInPrecompBasis.resize(size); } diff --git a/code/nel/src/3d/ps_mesh.cpp b/code/nel/src/3d/ps_mesh.cpp index f473a79ee..5002f0054 100644 --- a/code/nel/src/3d/ps_mesh.cpp +++ b/code/nel/src/3d/ps_mesh.cpp @@ -1994,7 +1994,7 @@ void CPSConstraintMesh::deleteElement(uint32 index) deleteSizeElement(index); deletePlaneBasisElement(index); // TODO : avoid code cuplication with CPSFace ... - if (_PrecompBasis.size()) // do we use precomputed basis ? + if (!_PrecompBasis.empty()) // do we use precomputed basis ? { // replace ourself by the last element... _IndexInPrecompBasis[index] = _IndexInPrecompBasis[_Owner->getSize() - 1]; @@ -2011,7 +2011,7 @@ void CPSConstraintMesh::resize(uint32 size) resizeSize(size); resizePlaneBasis(size); // TODO : avoid code cuplication with CPSFace ... - if (_PrecompBasis.size()) // do we use precomputed basis ? + if (!_PrecompBasis.empty()) // do we use precomputed basis ? { _IndexInPrecompBasis.resize(size); } diff --git a/code/nel/src/3d/quad_effect.cpp b/code/nel/src/3d/quad_effect.cpp index 8b40a786c..a6c75c99d 100644 --- a/code/nel/src/3d/quad_effect.cpp +++ b/code/nel/src/3d/quad_effect.cpp @@ -229,7 +229,7 @@ void CQuadEffect::processPoly(const TPoint2DVect &poly static TRasters rDest; float currY; makeRasters(poly, quadWidth, quadHeight, rDest, currY); - if (dest.size()) + if (!dest.empty()) { TRasters::const_iterator it, endIt = rDest.end(); for (it = rDest.begin(); it != endIt; ++it) diff --git a/code/nel/src/3d/shadow_map_manager.cpp b/code/nel/src/3d/shadow_map_manager.cpp index 0c9f7ba8b..e3f8fde99 100644 --- a/code/nel/src/3d/shadow_map_manager.cpp +++ b/code/nel/src/3d/shadow_map_manager.cpp @@ -705,7 +705,7 @@ void CShadowMapManager::renderProject(CScene *scene) } driver->activeVertexBuffer (CopyQuads); - if (_ShadowCasters.size()>0) + if (!_ShadowCasters.empty()) { // get the transform to compute shadow map. CTransform *sc= _ShadowCasters[0]; diff --git a/code/nel/src/3d/texture_dlm.cpp b/code/nel/src/3d/texture_dlm.cpp index 2c8603859..3e7695936 100644 --- a/code/nel/src/3d/texture_dlm.cpp +++ b/code/nel/src/3d/texture_dlm.cpp @@ -119,7 +119,7 @@ bool CTextureDLM::canCreateLightMap(uint w, uint h) return true; // If empty, test if there is an empty block. - return _EmptyBlocks.size()>0; + return !_EmptyBlocks.empty(); } @@ -166,7 +166,7 @@ bool CTextureDLM::createLightMap(uint w, uint h, uint &x, uint &y) if(_FreeBlocks[lMapType]==NULL) { // list is empty => allocate a block from _EmptyBlocks. - nlassert(_EmptyBlocks.size()>0); + nlassert(!_EmptyBlocks.empty()); // pop a block from empty list CBlock *block= &_Blocks[_EmptyBlocks.back()]; diff --git a/code/nel/src/3d/tile_bank.cpp b/code/nel/src/3d/tile_bank.cpp index 4c1ba1c23..d4e26ab06 100644 --- a/code/nel/src/3d/tile_bank.cpp +++ b/code/nel/src/3d/tile_bank.cpp @@ -108,7 +108,7 @@ void CTileBank::serial(NLMISC::IStream &f) throw(NLMISC::EStream) if (f.isReading()) { // Checks - nlassert (_DisplacementMap.size()>0); + nlassert (!_DisplacementMap.empty()); // Set first empty _DisplacementMap[0].setEmpty (); @@ -543,7 +543,7 @@ CTileNoiseMap *CTileBank::getTileNoiseMap (uint tileNumber, uint tileSubNoise) } } - if (_DisplacementMap.size()==0 || _DisplacementMap[0]._TileNoiseMap) + if (_DisplacementMap.empty() || _DisplacementMap[0]._TileNoiseMap) return NULL; // Checks diff --git a/code/nel/src/3d/vegetable_blend_layer_model.cpp b/code/nel/src/3d/vegetable_blend_layer_model.cpp index a1df0d89d..44754add2 100644 --- a/code/nel/src/3d/vegetable_blend_layer_model.cpp +++ b/code/nel/src/3d/vegetable_blend_layer_model.cpp @@ -71,7 +71,7 @@ void CVegetableBlendLayerModel::render(IDriver *driver) nlassert(VegetableManager); - if(SortBlocks.size()==0) + if(SortBlocks.empty()) return; // Setup VegetableManager renderState (like pre-setuped material) diff --git a/code/nel/src/3d/vegetable_manager.cpp b/code/nel/src/3d/vegetable_manager.cpp index 640d5e77f..e479a5e62 100644 --- a/code/nel/src/3d/vegetable_manager.cpp +++ b/code/nel/src/3d/vegetable_manager.cpp @@ -1019,12 +1019,12 @@ void CVegetableManager::reserveIgCompile(CVegetableInstanceGroup *ig, const CV { CVegetableInstanceGroup::CVegetableRdrPass &vegetRdrPass= ig->_RdrPass[rdrPass]; nlassert(vegetRdrPass.TriangleIndices.getNumIndexes()==0); - nlassert(vegetRdrPass.TriangleLocalIndices.size()==0); - nlassert(vegetRdrPass.Vertices.size()==0); - nlassert(vegetRdrPass.LightedInstances.size()==0); + nlassert(vegetRdrPass.TriangleLocalIndices.empty()); + nlassert(vegetRdrPass.Vertices.empty()); + nlassert(vegetRdrPass.LightedInstances.empty()); } // Do the same for all quadrants of the zsort rdrPass. - nlassert(ig->_TriangleQuadrantOrderArray.size()==0); + nlassert(ig->_TriangleQuadrantOrderArray.empty()); nlassert(ig->_TriangleQuadrantOrderNumTriangles==0); @@ -2553,7 +2553,7 @@ bool CVegetableManager::updateLightingIGPart() } CVegetableInstanceGroup::CVegetableRdrPass &vegetRdrPass= _ULRootIg->_RdrPass[_ULCurrentIgRdrPass]; - // if all instances are processed for this pass (especially if size()==0 !!) + // if all instances are processed for this pass (especially if empty() !!) if(_ULCurrentIgInstance>= vegetRdrPass.LightedInstances.size()) { // skip to the next rdrPass. diff --git a/code/nel/src/3d/vegetablevb_allocator.cpp b/code/nel/src/3d/vegetablevb_allocator.cpp index 29a03b51d..f5c833d8a 100644 --- a/code/nel/src/3d/vegetablevb_allocator.cpp +++ b/code/nel/src/3d/vegetablevb_allocator.cpp @@ -186,7 +186,7 @@ bool CVegetableVBAllocator::exceedMaxVertexInBufferHard(uint numAddVerts) cons uint CVegetableVBAllocator::allocateVertex() { // if no more free, allocate. - if( _VertexFreeMemory.size()==0 ) + if( _VertexFreeMemory.empty() ) { // enlarge capacity. uint newResize; diff --git a/code/nel/src/3d/water_model.cpp b/code/nel/src/3d/water_model.cpp index fb53100cb..e6ae132e1 100644 --- a/code/nel/src/3d/water_model.cpp +++ b/code/nel/src/3d/water_model.cpp @@ -500,7 +500,7 @@ void CWaterModel::traverseRender() sint startY; projPoly.computeBorders(rasters, startY); - if (rasters.size()) + if (!rasters.empty()) { //===========================// // perform Water animation // diff --git a/code/nel/src/3d/zone.cpp b/code/nel/src/3d/zone.cpp index c601f0fa4..263c61539 100644 --- a/code/nel/src/3d/zone.cpp +++ b/code/nel/src/3d/zone.cpp @@ -1126,7 +1126,7 @@ void CZone::refineAll() { nlassert(Compiled); - if(Patchs.size()==0) + if(Patchs.empty()) return; // DO NOT do a forceNoRenderClip(), to avoid big allocation of Near/Far VB vertices in driver. @@ -1150,7 +1150,7 @@ void CZone::averageTesselationVertices() { nlassert(Compiled); - if(Patchs.size()==0) + if(Patchs.empty()) return; // averageTesselationVertices of ALL patchs. @@ -1250,8 +1250,10 @@ void CZone::resetRenderFarAndDeleteVBFV() void CZone::forceMergeAtTileLevel() { CPatch *pPatch=0; - if(Patchs.size()>0) + + if (!Patchs.empty()) pPatch= &(*Patchs.begin()); + for(sint n=(sint)Patchs.size();n>0;n--, pPatch++) { pPatch->forceMergeAtTileLevel(); @@ -1446,7 +1448,7 @@ void CZone::applyHeightField(const CLandscape &landScape) vector patchs; // no patch, do nothing. - if(Patchs.size()==0) + if(Patchs.empty()) return; // 0. Unpack patchs to Bezier Patchs. diff --git a/code/nel/src/3d/zone_lighter.cpp b/code/nel/src/3d/zone_lighter.cpp index f5549e66a..c70ad0ba2 100644 --- a/code/nel/src/3d/zone_lighter.cpp +++ b/code/nel/src/3d/zone_lighter.cpp @@ -3113,7 +3113,7 @@ void CZoneLighter::addWaterShape(CWaterShape *shape, const NLMISC::CMatrix &MT) // *********************************************************** void CZoneLighter::makeQuadGridFromWaterShapes(NLMISC::CAABBox zoneBBox) { - if (!_WaterShapes.size()) return; + if (_WaterShapes.empty()) return; NLMISC::CAABBox tmpBox; diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp index 2fb19a9fc..c292d5473 100644 --- a/code/nel/src/gui/ctrl_text_button.cpp +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -43,8 +43,8 @@ namespace NLGUI _BmpLeftW= _BmpMiddleW= _BmpRightW= _BmpH= 0; _WMargin= 0; _WMin= 0; - _TextX= -2; - _TextY= -2; + _TextX= 0; + _TextY= 0; _Setuped= false; _ViewText= NULL; _IsViewTextId= false; @@ -602,7 +602,7 @@ namespace NLGUI _WMin= max(_WMin, _BmpLeftW + _BmpMiddleW + _BmpRightW); // TextY - _TextY= -2; + _TextY= 0; prop = (char*) xmlGetProp( cur, (xmlChar*)"text_y" ); if (prop) { diff --git a/code/nel/src/gui/group_header.cpp b/code/nel/src/gui/group_header.cpp index d166b539b..908aa183e 100644 --- a/code/nel/src/gui/group_header.cpp +++ b/code/nel/src/gui/group_header.cpp @@ -159,7 +159,7 @@ namespace NLGUI } // resize H - if(entries.size()>0) + if (!entries.empty()) { CInterfaceGroup *colEnclosing = entries[0]->getTargetColumn(); if (colEnclosing && !colEnclosing->getGroups().empty()) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 2c225b3ce..f64fc631c 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -50,11 +50,12 @@ using namespace std; using namespace NLMISC; -// Default timeout to connect a server -#define DEFAULT_RYZOM_CONNECTION_TIMEOUT (30.0) +// Default maximum time the request is allowed to take +#define DEFAULT_RYZOM_CONNECTION_TIMEOUT (300.0) // Allow up to 10 redirects, then give up #define DEFAULT_RYZOM_REDIRECT_LIMIT (10) // +#define FONT_WEIGHT_NORMAL 400 #define FONT_WEIGHT_BOLD 700 namespace NLGUI @@ -316,6 +317,11 @@ namespace NLGUI curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true); curl_easy_setopt(curl, CURLOPT_URL, finalUrl.c_str()); + std::string userAgent = options.appName + "/" + options.appVersion; + curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); + + sendCookies(curl, _DocumentDomain, _TrustedDomain); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite); @@ -338,14 +344,7 @@ namespace NLGUI #ifdef LOG_DL nlwarning("Init Image Download"); #endif - /* - // Get current flag - int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); - // Turn on leak-checking bit - tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF; - // Set flag to the new value - _CrtSetDbgFlag( tmpFlag ); - */ + string pathName = "cache"; if ( ! CFile::isExists( pathName ) ) CFile::createDirectory( pathName ); @@ -506,7 +505,7 @@ namespace NLGUI } else { - receiveCookies(_CurlWWW->Request, HTTPCurrentDomain, _TrustedDomain); + receiveCookies(_CurlWWW->Request, _DocumentDomain, _TrustedDomain); // redirect, get the location and try browse again // we cant use curl redirection because 'addHTTPGetParams()' must be called on new destination @@ -533,7 +532,7 @@ namespace NLGUI } else { - receiveCookies(_CurlWWW->Request, HTTPCurrentDomain, _TrustedDomain); + receiveCookies(_CurlWWW->Request, _DocumentDomain, _TrustedDomain); _RedirectsRemaining = DEFAULT_RYZOM_REDIRECT_LIMIT; @@ -628,32 +627,6 @@ namespace NLGUI curl_multi_cleanup(MultiCurl); } - /* - void dolibcurltest() - { - nlwarning("start libcurl test"); - - initImageDownload(); - - addImageDownload("http://www.ryzom.com/en/"); - addImageDownload("http://www.ryzom.com/fr/"); - addImageDownload("http://www.ryzom.com/de/"); - - do - { - checkImageDownload(); - nlwarning("continue to sleep"); - nlSleep(300); - } - while(RunningCurls); - - releaseImageDownload(); - - nlwarning("end libcurl test"); - } - */ - - class CGroupListAdaptor : public CInterfaceGroup { public: @@ -726,10 +699,6 @@ namespace NLGUI // Build a UTF8 string string inputString(buf, buf+len); - // inputString.resize (len); - // uint i; - // for (i=0; i<(uint)len; i++) - // inputString[i] = buf[i]; if (_ParsingLua && _TrustedDomain) { @@ -747,7 +716,6 @@ namespace NLGUI ucstring tmp; tmp.reserve(len); uint ucLen = (uint)inputUCString.size(); - //uint ucLenWithoutSpace = 0; for (uint i=0; i &present, const std::vector &value) - { - if (_Browsing) - { - if (element_number == HTML_A) - { - registerAnchorName(MY_HTML_A); - - // #fragment works with both ID and NAME so register both - if (present[MY_HTML_A_NAME] && value[MY_HTML_A_NAME]) - _AnchorName.push_back(value[MY_HTML_A_NAME]); - - if (present[MY_HTML_A_HREF] && value[MY_HTML_A_HREF]) - { - string suri = value[MY_HTML_A_HREF]; - if(suri.find("ah:") == 0) - { - if (_TrustedDomain) - _Link.push_back (suri); - else - _Link.push_back (""); - } - else if (_TrustedDomain && suri[0] == '#' && _LuaHrefHack) - { - // Direct url (hack for lua beginElement) - _Link.push_back (suri.substr(1)); - } - else - { - // convert href from "?key=val" into "http://domain.com/?key=val" - _Link.push_back(getAbsoluteUrl(suri)); - } - - for(uint8 i = MY_HTML_A_ACCESSKEY; i < MY_HTML_A_Z_ACTION_SHORTCUT; i++) - { - if (present[i] && value[i]) - { - string title = value[i]; - // nlinfo("key %d = %s", i, title.c_str()); - } - } - //nlinfo("key of TITLE is : %d", MY_HTML_A_Z_ACTION_PARAMS); - if (present[MY_HTML_A_Z_ACTION_PARAMS] && value[MY_HTML_A_Z_ACTION_PARAMS]) - { - string title = value[MY_HTML_A_Z_ACTION_PARAMS]; - _LinkTitle.push_back(title); - } - else - _LinkTitle.push_back(""); - } - else - { - _Link.push_back(""); - _LinkTitle.push_back(""); - } - - - } - } - } - - // *************************************************************************** - #define getCellsParameters(prefix,inherit) \ {\ CGroupHTML::CCellParams cellParams; \ @@ -872,7 +762,7 @@ namespace NLGUI cellParams = _CellParams.back(); \ } \ if (present[prefix##_BGCOLOR] && value[prefix##_BGCOLOR]) \ - cellParams.BgColor = getColor (value[prefix##_BGCOLOR]); \ + scanHTMLColor(value[prefix##_BGCOLOR], cellParams.BgColor); \ if (present[prefix##_L_MARGIN] && value[prefix##_L_MARGIN]) \ fromString(value[prefix##_L_MARGIN], cellParams.LeftMargin); \ if (present[prefix##_NOWRAP]) \ @@ -923,6 +813,30 @@ namespace NLGUI return src; } + static float hueToRgb(float m1, float m2, float h) + { + if (h < 0) h += 1.0f; + if (h > 1) h -= 1.0f; + if (h*6 < 1.0f) return m1 + (m2 - m1)*h*6; + if (h*2 < 1.0f) return m2; + if (h*3 < 2.0f) return m1 + (m2 - m1) * (2.0f/3.0f - h)*6; + return m1; + } + + static void hslToRgb(float h, float s, float l, CRGBA &result) + { + float m1, m2; + if (l <= 0.5f) + m2 = l * (s + 1.0f); + else + m2 = l + s - l * s; + m1 = l*2 - m2; + + result.R = 255 * hueToRgb(m1, m2, h + 1.0f/3.0f); + result.G = 255 * hueToRgb(m1, m2, h); + result.B = 255 * hueToRgb(m1, m2, h - 1.0f/3.0f); + } + class CNameToCol { public: @@ -1085,6 +999,37 @@ namespace NLGUI if (*src == '#') { ++src; + if (strlen(src) == 3 || strlen(src) == 4) + { + bool hasAlpha = (strlen(src) == 4); + // check RGB for valid hex + if (isHexa(src[0]) && isHexa(src[1]) && isHexa(src[2])) + { + // check optional A for valid hex + if (hasAlpha && !isHexa(src[3])) return false; + + dest.R = convertHexa(src[0]); + dest.G = convertHexa(src[1]); + dest.B = convertHexa(src[2]); + + dest.R = dest.R << 4 | dest.R; + dest.G = dest.G << 4 | dest.G; + dest.B = dest.B << 4 | dest.B; + + if (hasAlpha) + { + dest.A = convertHexa(src[3]); + dest.A = dest.A << 4 | dest.A; + } + else + dest.A = 255; + + return true; + } + + return false; + } + CRGBA result; src = scanColorComponent(src, result.R); if (!src) return false; src = scanColorComponent(src, result.G); if (!src) return false; @@ -1098,7 +1043,101 @@ namespace NLGUI dest = result; return true; } - else + + if (strnicmp(src, "rgb(", 4) == 0 || strnicmp(src, "rgba(", 5) == 0) + { + src += 4; + if (*src == '(') src++; + + vector parts; + NLMISC::splitString(src, ",", parts); + if (parts.size() >= 3) + { + CRGBA result; + sint tmpv; + float tmpf; + + // R + if (getPercentage(tmpv, tmpf, parts[0].c_str())) tmpv = 255 * tmpf; + clamp(tmpv, 0, 255); + result.R = tmpv; + + // G + if (getPercentage(tmpv, tmpf, parts[1].c_str())) tmpv = 255 * tmpf; + clamp(tmpv, 0, 255); + result.G = tmpv; + + // B + if (getPercentage(tmpv, tmpf, parts[2].c_str())) tmpv = 255 * tmpf; + clamp(tmpv, 0, 255); + result.B = tmpv; + + // A + if (parts.size() == 4) + { + if (!fromString(parts[3], tmpf)) return false; + if (parts[3].find_first_of("%") != std::string::npos) + tmpf /= 100; + + tmpv = 255 * tmpf; + clamp(tmpv, 0, 255); + result.A = tmpv; + } + else + result.A = 255; + + dest = result; + return true; + } + + return false; + } + + if (strnicmp(src, "hsl(", 4) == 0 || strnicmp(src, "hsla(", 5) == 0) + { + src += 4; + if (*src == '(') src++; + + vector parts; + NLMISC::splitString(src, ",", parts); + if (parts.size() >= 3) + { + sint tmpv; + float h, s, l; + // hue + if (!fromString(parts[0], tmpv)) return false; + tmpv = ((tmpv % 360) + 360) % 360; + h = (float) tmpv / 360.0f; + + // saturation + if (!getPercentage(tmpv, s, parts[1].c_str())) return false; + clamp(s, 0.0f, 1.0f); + + // lightness + if (!getPercentage(tmpv, l, parts[2].c_str())) return false; + clamp(l, 0.0f, 1.0f); + + CRGBA result; + hslToRgb(h, s, l, result); + + // A + if (parts.size() == 4) + { + float tmpf; + if (!fromString(parts[3], tmpf)) return false; + if (parts[3].find_first_of("%") != std::string::npos) + tmpf /= 100; + clamp(tmpf, 0.0f, 1.0f); + result.A = 255 * tmpf; + } + + dest = result; + return true; + } + + return false; + } + { // slow but should suffice for now for(uint k = 0; k < sizeofarray(htmlColorNameToRGBA); ++k) @@ -1166,7 +1205,7 @@ namespace NLGUI pos = toLower(content).find("url="); if (pos != string::npos) - _RefreshUrl = content.substr(pos + 4); + _RefreshUrl = getAbsoluteUrl(content.substr(pos + 4)); } _NextRefreshTime += timeSec; @@ -1176,7 +1215,10 @@ namespace NLGUI break; case HTML_A: { + registerAnchorName(MY_HTML_A); + CStyleParams style; + style.FontFamily = getFontFamily(); style.FontSize = getFontSize(); style.TextColor = LinkColor; style.Underlined = true; @@ -1185,21 +1227,45 @@ namespace NLGUI if (present[HTML_A_STYLE] && value[HTML_A_STYLE]) getStyleParams(value[HTML_A_STYLE], style); + _FontFamily.push_back(style.FontFamily); _FontSize.push_back(style.FontSize); _TextColor.push_back(style.TextColor); _FontUnderlined.push_back(style.Underlined); _FontStrikeThrough.push_back(style.StrikeThrough); _GlobalColor.push_back(LinkColorGlobalColor); _A.push_back(true); + _Link.push_back (""); + _LinkTitle.push_back(""); + _LinkClass.push_back(""); + // #fragment works with both ID and NAME so register both + if (present[MY_HTML_A_NAME] && value[MY_HTML_A_NAME]) + _AnchorName.push_back(value[MY_HTML_A_NAME]); if (present[MY_HTML_A_TITLE] && value[MY_HTML_A_TITLE]) - _LinkTitle.push_back(value[MY_HTML_A_TITLE]); + _LinkTitle.back() = value[MY_HTML_A_TITLE]; if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS]) - _LinkClass.push_back(value[MY_HTML_A_CLASS]); - + _LinkClass.back() = value[MY_HTML_A_CLASS]; + if (present[MY_HTML_A_HREF] && value[MY_HTML_A_HREF]) + { + string suri = value[MY_HTML_A_HREF]; + if(suri.find("ah:") == 0) + { + if (_TrustedDomain) + _Link.back() = suri; + } + else if (_TrustedDomain && suri[0] == '#' && _LuaHrefHack) + { + // Direct url (hack for lua beginElement) + _Link.back() = suri.substr(1); + } + else + { + // convert href from "?key=val" into "http://domain.com/?key=val" + _Link.back() = getAbsoluteUrl(suri); + } + } } break; - case HTML_DIV: { _BlockLevelElement.push_back(true); @@ -1286,7 +1352,6 @@ namespace NLGUI } } break; - case HTML_FONT: { bool found = false; @@ -1323,8 +1388,9 @@ namespace NLGUI { if (present[HTML_BODY_BGCOLOR] && value[HTML_BODY_BGCOLOR]) { - CRGBA bgColor = getColor (value[HTML_BODY_BGCOLOR]); - setBackgroundColor (bgColor); + CRGBA bgColor; + if (scanHTMLColor(value[HTML_BODY_BGCOLOR], bgColor)) + setBackgroundColor (bgColor); } string style; @@ -1504,14 +1570,25 @@ namespace NLGUI if (present[MY_HTML_INPUT_ALT] && value[MY_HTML_INPUT_ALT]) tooltip = value[MY_HTML_INPUT_ALT]; + // by default not inherited, font family defaults to system font + CStyleParams style; + style.TextColor = TextColor; + style.FontSize = TextFontSize; + style.FontWeight = FONT_WEIGHT_NORMAL; + style.FontOblique = false; + + if (present[MY_HTML_INPUT_STYLE] && value[MY_HTML_INPUT_STYLE]) + getStyleParams(value[MY_HTML_INPUT_STYLE], style); + + _TextColor.push_back(style.TextColor); + _FontFamily.push_back(style.FontFamily); + _FontSize.push_back(style.FontSize); + _FontWeight.push_back(style.FontWeight); + _FontOblique.push_back(style.FontOblique); + string type = toLower(value[MY_HTML_INPUT_TYPE]); if (type == "image") { - CStyleParams style; - // width, height from inline css - if (present[MY_HTML_INPUT_STYLE] && value[MY_HTML_INPUT_STYLE]) - getStyleParams(value[MY_HTML_INPUT_STYLE], style); - // The submit button string name; string normal; @@ -1602,9 +1679,6 @@ namespace NLGUI getParagraph()->addChild (buttonGroup); paragraphChange (); } - - // addButton (CCtrlTextButton::PushButton, name, normal, pushed.empty()?normal:pushed, over, - // globalColor, "html_submit_form", param.c_str(), tooltip); } else if (type == "text") { @@ -1722,6 +1796,12 @@ namespace NLGUI _Forms.back().Entries.push_back (entry); } } + + popIfNotEmpty(_FontFamily); + popIfNotEmpty(_FontSize); + popIfNotEmpty(_TextColor); + popIfNotEmpty(_FontWeight); + popIfNotEmpty(_FontOblique); } } break; @@ -1834,7 +1914,29 @@ namespace NLGUI newParagraph(PBeginSpace); break; case HTML_PRE: - _PRE.push_back(true); + { + CStyleParams style; + style.TextColor = getTextColor(); + style.FontFamily = "monospace"; + style.FontSize = getFontSize(); + style.FontWeight = getFontWeight(); + style.FontOblique = getFontOblique(); + style.Underlined = getFontUnderlined(); + style.StrikeThrough = getFontStrikeThrough(); + + if (present[HTML_PRE_STYLE] && value[HTML_PRE_STYLE]) + getStyleParams(value[HTML_PRE_STYLE], style); + + _TextColor.push_back(style.TextColor); + _FontFamily.push_back(style.FontFamily); + _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); + + _PRE.push_back(true); + } break; case HTML_TABLE: { @@ -1851,7 +1953,7 @@ namespace NLGUI if (present[MY_HTML_TABLE_BORDER] && value[MY_HTML_TABLE_BORDER]) fromString(value[MY_HTML_TABLE_BORDER], table->Border); if (present[MY_HTML_TABLE_BORDERCOLOR] && value[MY_HTML_TABLE_BORDERCOLOR]) - table->BorderColor = getColor (value[MY_HTML_TABLE_BORDERCOLOR]); + scanHTMLColor(value[MY_HTML_TABLE_BORDERCOLOR], table->BorderColor); if (present[MY_HTML_TABLE_CELLSPACING] && value[MY_HTML_TABLE_CELLSPACING]) fromString(value[MY_HTML_TABLE_CELLSPACING], table->CellSpacing); if (present[MY_HTML_TABLE_CELLPADDING] && value[MY_HTML_TABLE_CELLPADDING]) @@ -1958,9 +2060,27 @@ namespace NLGUI } break; case HTML_TEXTAREA: + _PRE.push_back(true); + // Got one form ? if (!(_Forms.empty())) { + // not inherited by default, font family defaults to system font + CStyleParams style; + style.TextColor = TextColor; + style.FontWeight = FONT_WEIGHT_NORMAL; + style.FontOblique = false; + style.FontSize = TextFontSize; + + if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) + getStyleParams(value[MY_HTML_TEXTAREA_STYLE], style); + + _TextColor.push_back(style.TextColor); + _FontFamily.push_back(style.FontFamily); + _FontSize.push_back(style.FontSize); + _FontWeight.push_back(style.FontWeight); + _FontOblique.push_back(style.FontOblique); + // read general property string templateName; @@ -2043,6 +2163,7 @@ namespace NLGUI { CStyleParams style; style.TextColor = getTextColor(); + style.FontFamily = getFontFamily(); style.FontSize = getFontSize(); style.FontWeight = getFontWeight(); style.FontOblique = getFontOblique(); @@ -2053,6 +2174,7 @@ namespace NLGUI getStyleParams(value[MY_HTML_SPAN_STYLE], style); _TextColor.push_back(style.TextColor); + _FontFamily.push_back(style.FontFamily); _FontSize.push_back(style.FontSize); _FontWeight.push_back(style.FontWeight); _FontOblique.push_back(style.FontOblique); @@ -2207,6 +2329,7 @@ namespace NLGUI popIfNotEmpty (_FontSize); break; case HTML_A: + popIfNotEmpty (_FontFamily); popIfNotEmpty (_FontSize); popIfNotEmpty (_TextColor); popIfNotEmpty (_FontUnderlined); @@ -2232,6 +2355,13 @@ namespace NLGUI endParagraph(); break; case HTML_PRE: + popIfNotEmpty (_FontFamily); + popIfNotEmpty (_FontSize); + popIfNotEmpty (_FontWeight); + popIfNotEmpty (_FontOblique); + popIfNotEmpty (_TextColor); + popIfNotEmpty (_FontUnderlined); + popIfNotEmpty (_FontStrikeThrough); popIfNotEmpty (_PRE); break; case HTML_DIV: @@ -2277,7 +2407,15 @@ namespace NLGUI entry.TextArea = textArea; _Forms.back().Entries.push_back (entry); } + + popIfNotEmpty (_FontFamily); + popIfNotEmpty (_FontSize); + popIfNotEmpty (_FontWeight); + popIfNotEmpty (_FontOblique); + popIfNotEmpty (_TextColor); } + + popIfNotEmpty (_PRE); } break; case HTML_TITLE: @@ -2437,6 +2575,7 @@ namespace NLGUI } break; case HTML_SPAN: + popIfNotEmpty (_FontFamily); popIfNotEmpty (_FontSize); popIfNotEmpty (_FontWeight); popIfNotEmpty (_FontOblique); @@ -2548,6 +2687,7 @@ namespace NLGUI _SelectOption = false; _GroupListAdaptor = NULL; _DocumentUrl = ""; + _DocumentDomain = ""; _UrlFragment.clear(); _RefreshUrl.clear(); _NextRefreshTime = 0.0; @@ -3907,6 +4047,7 @@ namespace NLGUI // Compatible with current parameters ? if (!skipLine && (getTextColor() == _CurrentViewLink->getColor()) && + (getFontFamily() == _CurrentViewLink->getFontName()) && (getFontSize() == (uint)_CurrentViewLink->getFontSize()) && (getFontUnderlined() == _CurrentViewLink->getUnderlined()) && (getFontStrikeThrough() == _CurrentViewLink->getStrikeThrough()) && @@ -3971,6 +4112,7 @@ namespace NLGUI } newLink->setText(tmpStr); newLink->setColor(getTextColor()); + newLink->setFontName(getFontFamily()); newLink->setFontSize(getFontSize()); newLink->setEmbolden(embolden); newLink->setOblique(getFontOblique()); @@ -4062,7 +4204,7 @@ namespace NLGUI // *************************************************************************** - CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const char *name, uint /* rows */, uint cols, bool multiLine, const ucstring &content, uint maxlength) + CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength) { // In a paragraph ? if (!_Paragraph) @@ -4077,11 +4219,18 @@ namespace NLGUI { // Not added ? std::vector > templateParams; - templateParams.push_back (std::pair ("w", toString (cols*12))); - //templateParams.push_back (std::pair ("h", toString (rows*12))); + templateParams.push_back (std::pair ("w", toString (cols*getFontSize()))); templateParams.push_back (std::pair ("id", name)); templateParams.push_back (std::pair ("prompt", "")); templateParams.push_back (std::pair ("multiline", multiLine?"true":"false")); + templateParams.push_back (std::pair ("fontsize", toString (getFontSize()))); + templateParams.push_back (std::pair ("color", getTextColor().toString())); + if (getFontWeight() >= FONT_WEIGHT_BOLD) + templateParams.push_back (std::pair ("fontweight", "bold")); + if (getFontOblique()) + templateParams.push_back (std::pair ("fontstyle", "oblique")); + if (multiLine) + templateParams.push_back (std::pair ("multi_min_line", toString(rows))); templateParams.push_back (std::pair ("want_return", multiLine?"true":"false")); templateParams.push_back (std::pair ("enter_recover_focus", "false")); if (maxlength > 0) @@ -4279,7 +4428,6 @@ namespace NLGUI ctrlButton->setToolTipParent(TTMouse); ctrlButton->setToolTipParentPosRef(Hotspot_TTAuto); ctrlButton->setToolTipPosRef(Hotspot_TTAuto); - ctrlButton->setActionOnLeftClickParams(tooltip); } getParagraph()->addChild (ctrlButton); @@ -4657,9 +4805,12 @@ namespace NLGUI string finalUrl; bool isLocal = lookupLocalFile (finalUrl, _URL.c_str(), true); - // Save new url _URL = finalUrl; + CUrlParser uri (_URL); + _TrustedDomain = isTrustedDomain(uri.host); + _DocumentDomain = uri.host; + // file is probably from bnp (ingame help) if (isLocal) { @@ -4667,8 +4818,6 @@ namespace NLGUI } else { - _TrustedDomain = isTrustedDomain(setCurrentDomain(finalUrl)); - SFormFields formfields; if (_PostNextTime) { @@ -4704,9 +4853,11 @@ namespace NLGUI // Ref the form CForm &form = _Forms[_PostFormId]; - // Save new url _URL = form.Action; - _TrustedDomain = isTrustedDomain(setCurrentDomain(_URL)); + + CUrlParser uri(_URL); + _TrustedDomain = isTrustedDomain(uri.host); + _DocumentDomain = uri.host; for (i=0; i markup for image downloads if (type.find("image/") == 0 && content.size() > 0) { @@ -5468,15 +5617,11 @@ namespace NLGUI value.insert(value.begin() + (uint)it.nextKey().toInteger(), buffer); } + // ingame lua scripts from browser are using url scheme + // reason unknown + _LuaHrefHack = true; beginElement(element_number, present, value); - if (element_number == HTML_A) - { - // ingame lua scripts from browser are using url scheme - // reason unknown - _LuaHrefHack = true; - addLink(element_number, present, value); - _LuaHrefHack = false; - } + _LuaHrefHack = false; return 0; } @@ -5637,23 +5782,45 @@ namespace NLGUI { if (it->first == "font-size") { - float tmp; - sint size = 0; - getPercentage (size, tmp, it->second.c_str()); - if (size > 0) - style.FontSize = size; + if (it->second == "inherit") + style.FontSize = getFontSize(); + else + { + 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 == "inherit") + style.FontOblique = getFontOblique(); + else if (it->second == "italic" || it->second == "oblique") style.FontOblique = true; } else + if (it->first == "font-family") + { + if (it->second == "inherit") + style.FontFamily = getFontFamily(); + else + if (it->second == "monospace") + style.FontFamily = "monospace"; + else + style.FontFamily = ""; + } + else if (it->first == "font-weight") { // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight uint weight = 400; + if (it->second == "inherit") + weight = getFontWeight(); + else if (it->second == "normal") weight = 400; else @@ -5686,7 +5853,10 @@ namespace NLGUI } else if (it->first == "color") - scanHTMLColor(it->second.c_str(), style.TextColor); + if (it->second == "inherit") + style.TextColor = getTextColor(); + else + scanHTMLColor(it->second.c_str(), style.TextColor); else if (it->first == "text-decoration" || it->first == "text-decoration-line") { @@ -5827,7 +5997,6 @@ namespace NLGUI { std::string ret; sint32 number = Value; - bool upper = false; if (Type == "disc") { diff --git a/code/nel/src/gui/group_html_parser.cpp b/code/nel/src/gui/group_html_parser.cpp index de96a63ea..5f6873477 100644 --- a/code/nel/src/gui/group_html_parser.cpp +++ b/code/nel/src/gui/group_html_parser.cpp @@ -61,11 +61,6 @@ namespace NLGUI } } - if (element_number == HTML_A) - { - addLink(element_number, present, value); - } - beginElement(element_number, present, value); } else diff --git a/code/nel/src/gui/group_tab.cpp b/code/nel/src/gui/group_tab.cpp index ca876c25e..69ccce046 100644 --- a/code/nel/src/gui/group_tab.cpp +++ b/code/nel/src/gui/group_tab.cpp @@ -262,7 +262,7 @@ namespace NLGUI { tabB->setId(string("tab") + NLMISC::toString(_Buttons.size())); - if(_Buttons.size()==0) + if(_Buttons.empty()) { tabB->setParentPos(NULL); tabB->setParentPosRef(Hotspot_TL); @@ -453,7 +453,7 @@ namespace NLGUI // *************************************************************************** void CGroupTab::updateFirstTabButton() { - if(!_HideOutTabs || (_Selection<0) || (_Buttons.size()==0) || (_Parent->getWReal()<0) + if(!_HideOutTabs || (_Selection<0) || _Buttons.empty() || (_Parent->getWReal()<0) || _FirstTabIndex>=(sint)_Buttons.size()) return; diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 739e807c8..068d827bf 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -193,7 +193,7 @@ namespace NLGUI xmlKeepBlanksDefault(0); //parse all interface files and build a single xml document xmlNodePtr globalEnclosing; - nlassert (strings.size()); + nlassert (!strings.empty()); CIXml read; string nextFileName; static const char *SCRIPT_AS_STRING = "