diff --git a/.gitignore b/.gitignore index eda61148c..8fa21a42c 100644 --- a/.gitignore +++ b/.gitignore @@ -223,6 +223,7 @@ code/ryzom/server/src/ryzom_admin_service/ryzom_admin_service code/ryzom/server/src/ryzom_naming_service/ryzom_naming_service code/ryzom/server/src/ryzom_welcome_service/ryzom_welcome_service code/ryzom/server/src/tick_service/tick_service + # WebTT temp dir code/ryzom/tools/server/www/webtt/app/tmp @@ -243,14 +244,14 @@ code/ryzom/tools/server/ryzom_ams/old -#tools and external dir's +# Tools and external directories external external_vc14 external_stlport nel_tools* ryzom_tools* -#Dumps +# Dumps *.dmp code/nel/tools/build_gamedata/processes/ai_wmap/ai_build_wmap.cfg diff --git a/.hgignore b/.hgignore new file mode 100644 index 000000000..990487a2a --- /dev/null +++ b/.hgignore @@ -0,0 +1,268 @@ +syntax: glob + +# Various build directories +bin +obj +Debug +Release +ReleaseDebug +DebugFast +ReleaseDebugStatic +DebugFastStatic + +# Test and application directories +screenshots +release +test +Temp + +# NeL cache +*.packed_sheets + +# Ryzom save +save_shard +last_loaded_char.bin +*.binprim +*.string_cache +graphs_output +default_c + +# Windows compile +*.exe +*.dll +*.lib +*.obj + +# Linux compile +*.a +*.la +*.lo +*.Po +*.Plo +*.o +*.so +*.so.* +*_debug +*.pc +*.gch + +# Mac OS X compile +*.dylib + +# Log dump files +report_refused +report_failed +exception_catched +*.stat +*.log +log.txt + +# Max plugin extensions +*.dlx +*.dlm +*.dlu + +# makeall build +.mode_static + +# cmake build files & directories +CMakeFiles +CMakeCache.txt +cmake_install.cmake +CTestTestfile.cmake +CPackConfig.cmake +CPackSourceConfig.cmake +.libs + +# Linux garbage +Makefile* +aclocal.m4 +config.guess +config.sub +configure +depcomp +config.h.in +nelconfig.h.in +install-sh +ltmain.sh +missing +ylwrap +*.mk + +# Visual Studio garbage +*.opensdf +UpgradeLog*.XML +_UpgradeReport_Files +BuildLog.htm +mt.dep +ipch +*.suo +*.ncb +*.user +*.ilk +*.pdb +*.aps +*.exp +*.idb +*.sdf + +# Mac OS X garbage +.DS_Store + +# Ryzom server garbage +aes_alias_name.cfg +aes_nagios_report.txt +aes_state.txt +*.launch_ctrl +*.state +*.start_count + +# Vim and kwrite cache +*~ + +# Kdevelop4 garbage +*.kdev4 +.kdev4 + +# intellij project folder +.idea/ + +# Python cache +*.pyd +*.pyc + +# Qt compiler +moc_*.cpp +*.moc + +# Misc garbage +*.rej +*.orig +*.cachefile +*.cache +*.patch +*.7z +3rdParty +.svn +thumbs.db +Thumbs.db +*.tpl.php +.SyncID +.SyncIgnore +.SyncArchive + +# build +code/nel/build/* +code/nelns/build/* +code/snowballs/build/* +code/ryzom/build/* +code/build/* +code/build-2010/* +build/* +install/* +build_vc* +code/nel/tools/build_gamedata/configuration/buildsite.py + +# Linux nel compile +code/nel/build/nel-config +code/nel/config.status +code/nel/include/nelconfig.h +code/nel/include/stamp-h1 +code/nel/libtool +code/nel/nel-config +code/nel/samples/3d/cluster_viewer/cluster_viewer +code/nel/samples/3d/font/font +code/nel/samples/georges/georges +code/nel/samples/misc/command/command +code/nel/samples/misc/configfile/configfile +code/nel/samples/misc/debug/debug +code/nel/samples/misc/i18n/i18n +code/nel/samples/misc/log/log +code/nel/samples/misc/strings/strings +code/nel/samples/net/chat/chatclient +code/nel/samples/net/chat/chatserver +code/nel/samples/net/login_system/nls_frontend_service +code/nel/samples/net/login_system/nls_login_client +code/nel/samples/net/udp/udp_bench_client +code/nel/samples/net/udp/udp_bench_service +code/nel/samples/pacs/pacs_sample +code/nel/tools/3d/build_coarse_mesh/build_coarse_mesh +code/nel/tools/3d/build_far_bank/build_far_bank +code/nel/tools/3d/build_smallbank/build_smallbank +code/nel/tools/3d/ig_lighter/ig_lighter +code/nel/tools/3d/zone_dependencies/zone_dependencies +code/nel/tools/3d/zone_ig_lighter/zone_ig_lighter +code/nel/tools/3d/zone_lighter/zone_lighter +code/nel/tools/3d/zone_welder/zone_welder +code/nel/tools/misc/bnp_make/bnp_make +code/nel/tools/misc/disp_sheet_id/disp_sheet_id +code/nel/tools/misc/make_sheet_id/make_sheet_id +code/nel/tools/misc/xml_packer/xml_packer +code/nel/tools/pacs/build_ig_boxes/build_ig_boxes +code/nel/tools/pacs/build_indoor_rbank/build_indoor_rbank +code/nel/tools/pacs/build_rbank/build_rbank +code/ryzom/common/data_leveldesign/leveldesign/game_element/xp_table/skills.skill_tree +code/ryzom/common/data_leveldesign/leveldesign/game_element/xp_table/xptable.xp_table +code/ryzom/tools/server/sql/ryzom_admin_default_data.sql + + +# Linux server compile +code/ryzom/server/src/entities_game_service/entities_game_service +code/ryzom/server/src/frontend_service/frontend_service +code/ryzom/server/src/gpm_service/gpm_service +code/ryzom/server/src/input_output_service/input_output_service +code/ryzom/server/src/mirror_service/mirror_service +code/ryzom/server/src/ryzom_admin_service/ryzom_admin_service +code/ryzom/server/src/ryzom_naming_service/ryzom_naming_service +code/ryzom/server/src/ryzom_welcome_service/ryzom_welcome_service +code/ryzom/server/src/tick_service/tick_service +# WebTT temp dir +code/ryzom/tools/server/www/webtt/app/tmp + +# AMS ignore +code/web/public_php/ams/is_installed +code/web/docs/ams/html +code/web/public_php/ams/templates_c +code/ryzom/tools/server/ryzom_ams/drupal +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/autoload +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/configs +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/cron +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/img +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/plugins +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/smarty +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/translations +code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/libinclude.php +code/ryzom/tools/server/ryzom_ams/old + + + +#tools and external dir's +external +external_stlport +nel_tools* +ryzom_tools* + +#personal projects +personal/ + +#Dumps +*.dmp + +code/nel/tools/build_gamedata/processes/ai_wmap/ai_build_wmap.cfg +code/nel/tools/build_gamedata/processes/sheets/sheets_packer.cfg +code/nel/tools/build_gamedata/processes/rbank/build_rbank.cfg +code/nel/tools/build_gamedata/processes/zone/debug_zone_dependencies.cfg +code/web/public_php/config.php +code/web/public_php/is_installed +code/web/public_php/ams/files +code/web/public_php/db_version_lib +code/web/public_php/db_version_shard +code/web/public_php/db_version_tool +code/web/public_php/db_version_web +code/web/public_php/role_service +code/web/public_php/role_support +code/web/public_php/role_domain +code/web/public_php/db_version_ring +code/web/public_php/config_user.php +code/nel/tools/build_gamedata/processes/pz/build_world_packed_col.cfg +code/nel/tools/build_gamedata/processes/cartographer/island_screenshots.cfg diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 43054b63e..4e5292f2a 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -53,8 +53,8 @@ ENDIF() CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(RyzomCore CXX C) -SET(NL_VERSION_MAJOR 0) -SET(NL_VERSION_MINOR 12) +SET(NL_VERSION_MAJOR 1) +SET(NL_VERSION_MINOR 0) SET(NL_VERSION_PATCH 0) SET(YEAR "2004-${CURRENT_YEAR}") SET(AUTHOR "Winch Gate and The Ryzom Core Community") @@ -91,12 +91,12 @@ NL_SETUP_NELNS_DEFAULT_OPTIONS() NL_SETUP_RYZOM_DEFAULT_OPTIONS() NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS() -NL_SETUP_PREFIX_PATHS() -RYZOM_SETUP_PREFIX_PATHS() - NL_SETUP_BUILD() NL_SETUP_BUILD_FLAGS() +NL_SETUP_PREFIX_PATHS() +RYZOM_SETUP_PREFIX_PATHS() + #----------------------------------------------------------------------------- #Platform specifics @@ -172,6 +172,7 @@ ENDIF() IF(APPLE) FIND_LIBRARY(CARBON_FRAMEWORK Carbon) FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation) + FIND_LIBRARY(SECURITY_FRAMEWORK Security) IF(APPLE_CERTIFICATE) # Find codesign_allocate @@ -196,214 +197,10 @@ IF(APPLE) ENDIF() ENDIF() -MACRO(ADD_QT_LIBRARY _NAME) - IF(WIN32) - SET(_PREFIX "Qt5") - SET(_EXT "lib") - ELSE() - SET(_PREFIX "libQt5") - SET(_EXT "a") - ENDIF() - SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}.${_EXT}") - IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB}) - ENDIF() - SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}") - IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB}) - ENDIF() -ENDMACRO() - -MACRO(ADD_QT_PLUGIN _TYPE _NAME) - IF(WIN32) - SET(_PREFIX "") - SET(_EXT "lib") - ELSE() - SET(_PREFIX "lib") - SET(_EXT "a") - ENDIF() - SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}.${_EXT}") - IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB}) - ENDIF() - SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}") - IF(EXISTS ${_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB}) - ENDIF() -ENDMACRO() +INCLUDE(FindHelpers) IF(WITH_QT5) - CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR) - - SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR}) - - FIND_PACKAGE(Qt5Core QUIET) - - IF(Qt5Core_FOUND) - # Check if we are using Qt static or shared libraries - GET_TARGET_PROPERTY(_FILE Qt5::Core IMPORTED_LOCATION_RELEASE) - - SET(QT_VERSION "${Qt5Core_VERSION_STRING}") - SET(_VERSION "${QT_VERSION}") - - IF(_FILE MATCHES "\\.(lib|a)$") - SET(QT_STATIC ON) - SET(_VERSION "${_VERSION} static version") - ELSE() - SET(QT_STATIC OFF) - SET(_VERSION "${_VERSION} shared version") - ENDIF() - - MESSAGE(STATUS "Found Qt ${_VERSION}") - - # These variables are not defined with Qt5 CMake modules - SET(QT_BINARY_DIR "${_qt5Core_install_prefix}/bin") - SET(QT_LIBRARY_DIR "${_qt5Core_install_prefix}/lib") - SET(QT_PLUGINS_DIR "${_qt5Core_install_prefix}/plugins") - SET(QT_TRANSLATIONS_DIR "${_qt5Core_install_prefix}/translations") - - # Fix wrong include directories with Qt 5 under Mac OS X - INCLUDE_DIRECTORIES("${_qt5Core_install_prefix}/include") - - FIND_PACKAGE(Qt5Gui) - FIND_PACKAGE(Qt5Widgets) - FIND_PACKAGE(Qt5OpenGL) - FIND_PACKAGE(Qt5Xml) - FIND_PACKAGE(Qt5LinguistTools) - FIND_PACKAGE(Qt5Network) - - IF(QT_STATIC) - ADD_DEFINITIONS(-DQT_STATICPLUGIN) - - SET(QT_LIBRARIES Qt5::Widgets) - - # Gui - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Gui Qt5::OpenGL) - - ADD_QT_LIBRARY(PrintSupport) - - IF(WIN32) - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${WINSDK_LIBRARY_DIR}/Imm32.lib - ${WINSDK_LIBRARY_DIR}/OpenGL32.lib - ${WINSDK_LIBRARY_DIR}/WinMM.Lib) - ADD_QT_PLUGIN(platforms qwindows) - ADD_QT_LIBRARY(PlatformSupport) - ELSEIF(APPLE) - # Cups needs .dylib - SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib) - FIND_LIBRARY(CUPS_LIBRARY cups) - SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES}) - - FIND_LIBRARY(IOKIT_FRAMEWORK IOKit) - FIND_LIBRARY(COCOA_FRAMEWORK Cocoa) - FIND_LIBRARY(SYSTEMCONFIGURATION_FRAMEWORK SystemConfiguration) - FIND_LIBRARY(OPENGL_FRAMEWORK NAMES OpenGL) - - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${CUPS_LIBRARY} - ${COCOA_FRAMEWORK} - ${SYSTEMCONFIGURATION_FRAMEWORK} - ${IOKIT_FRAMEWORK} - ${OPENGL_FRAMEWORK}) - - ADD_QT_PLUGIN(printsupport cocoaprintersupport) - ADD_QT_PLUGIN(platforms qcocoa) - ADD_QT_LIBRARY(PlatformSupport) - ELSE() - # order is very important there - ADD_QT_PLUGIN(platforms qxcb) - ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration) - - ADD_QT_LIBRARY(XcbQpa) - ADD_QT_LIBRARY(PlatformSupport) - SET(QT_LIBRARIES ${QT_LIBRARIES} -lX11-xcb -lXi -lSM -lICE -lxcb -lGL -lxcb-glx) - IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a") - SET(QT_LIBRARIES ${QT_LIBRARIES} "${QT_LIBRARY_DIR}/libxcb-static.a") - ENDIF() - SET(QT_LIBRARIES ${QT_LIBRARIES} -lfontconfig) - ADD_QT_LIBRARY(DBus) - ENDIF() - - ADD_QT_PLUGIN(imageformats qgif) - ADD_QT_PLUGIN(imageformats qicns) - ADD_QT_PLUGIN(imageformats qico) - ADD_QT_PLUGIN(imageformats qjpeg) - - # harfbuzz is needed since Qt 5.3 - IF(UNIX) - SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzzng.a") - ELSEIF(WIN32) - SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib") - ENDIF() - IF(EXISTS ${HB_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${HB_LIB}) - ENDIF() - - # freetype is needed since Qt 5.5 - FIND_PACKAGE(Freetype) - - IF(FREETYPE_FOUND) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIBRARIES}) - ELSE() - IF(UNIX) - SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a") - ELSEIF(WIN32) - SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib") - ENDIF() - IF(EXISTS ${FREETYPE_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIB}) - ENDIF() - ENDIF() - - ADD_QT_PLUGIN(accessible qtaccessiblewidgets) - - SET(QT_LIBRARIES ${QT_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARY}) - - # Network - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Network Qt5::Xml) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) - - IF(WIN32) - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${WINSDK_LIBRARY_DIR}/Crypt32.lib - ${WINSDK_LIBRARY_DIR}/WS2_32.Lib - ${WINSDK_LIBRARY_DIR}/IPHlpApi.Lib) - ENDIF() - - # Core - SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Core) - - # pcre is needed since Qt 5.5 - IF(UNIX) - SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a") - ELSEIF(WIN32) - SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib") - ENDIF() - IF(EXISTS ${PCRE_LIB}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${PCRE_LIB}) - ENDIF() - - IF(APPLE) - FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre) - - FIND_LIBRARY(SECURITY_FRAMEWORK Security) - - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${PCRE_LIBRARY} - ${FOUNDATION_FRAMEWORK} - ${CARBON_FRAMEWORK} - ${SECURITY_FRAMEWORK}) - ELSEIF(UNIX) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -ldl -lrt) - ENDIF() - ELSE() - SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core) - ENDIF() - ELSE() - MESSAGE(WARNING "Unable to find Qt 5") - ENDIF() + FIND_QT5() ENDIF() IF(WITH_QT) @@ -435,22 +232,41 @@ IF(WITH_NEL) IF(CURL_STATIC) SET(CURL_DEFINITIONS -DCURL_STATICLIB) - SET(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) - SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) + LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) + LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES}) - IF(UNIX) + IF(WIN32) + LIST(APPEND CURL_LIBRARIES Crypt32 Cryptui) + ELSE() # CURL depends on libidn FIND_LIBRARY(IDN_LIBRARY idn) IF(IDN_LIBRARY) - SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${IDN_LIBRARY}) + LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY}) ENDIF() - # CURL Macports version depends on libidn, libintl and libiconv too + # CURL Macports version can depend on libidn, libidn2, libintl, libpsl and libiconv too IF(APPLE) FIND_LIBRARY(INTL_LIBRARY intl) IF(INTL_LIBRARY) - SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${INTL_LIBRARY}) + LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY}) ENDIF() + + FIND_LIBRARY(IDN2_LIBRARY idn2) + IF(IDN2_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${IDN2_LIBRARY}) + ENDIF() + + FIND_LIBRARY(PSL_LIBRARY psl) + IF(PSL_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${PSL_LIBRARY}) + ENDIF() + + FIND_LIBRARY(UNISTRING_LIBRARY unistring) + IF(UNISTRING_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${UNISTRING_LIBRARY}) + ENDIF() + + LIST(APPEND CURL_LIBRARIES ${SECURITY_FRAMEWORK}) ENDIF() ENDIF() ENDIF() @@ -458,6 +274,19 @@ IF(WITH_NEL) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include) ADD_SUBDIRECTORY(nel) + + # Aliases for targets + SET(NELMISC_LIBRARIES nelmisc) + SET(NELNET_LIBRARIES nelnet) + SET(NELLIGO_LIBRARIES nelligo) + SET(NELGEORGES_LIBRARIES nelgeorges) + SET(NEL3D_LIBRARIES nel3d) + SET(NELGUI_LIBRARIES nelgui) + SET(NELSOUND_LIBRARIES nelsound) +ELSE() +# FIND_PACKAGE(NeL COMPONENTS 3d misc pacs sound nimp REQUIRED) + FIND_PACKAGE(NeL REQUIRED) + INCLUDE_DIRECTORIES(${NEL_INCLUDE_DIRS}) ENDIF() IF(WITH_RYZOM) @@ -480,6 +309,10 @@ IF(WITH_STUDIO) ADD_SUBDIRECTORY(studio) ENDIF() +IF(WITH_PERSONAL) + ADD_SUBDIRECTORY(personal) +ENDIF() + # To build the documention, you will have to enable it # and then do the equivalent of "make DoxygenDoc". IF(BUILD_DOCUMENTATION) diff --git a/code/CMakeModules/FindHelpers.cmake b/code/CMakeModules/FindHelpers.cmake new file mode 100644 index 000000000..bc38354f4 --- /dev/null +++ b/code/CMakeModules/FindHelpers.cmake @@ -0,0 +1,959 @@ +MACRO(CONVERT_NUMBER_VERSION _VERSION_NUMBER _BASE _OUT) + SET(${_OUT}) + SET(_NUMBER ${_VERSION_NUMBER}) + WHILE(_NUMBER GREATER 0) + MATH(EXPR _TEMP "${_NUMBER} % ${_BASE}") + LIST(APPEND ${_OUT} ${_TEMP}) + MATH(EXPR _NUMBER "${_NUMBER} / ${_BASE}") + ENDWHILE() +ENDMACRO(CONVERT_NUMBER_VERSION) + +FUNCTION(JOIN VALUES GLUE OUTPUT) + STRING(REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}") + STRING(REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping + SET(${OUTPUT} "${_TMP_STR}" PARENT_SCOPE) +ENDFUNCTION() + +MACRO(PARSE_VERSION_OTHER FILENAME) + IF(EXISTS ${FILENAME}) + SET(_FILTER_ARRAY ${ARGN}) + JOIN("${_FILTER_ARRAY}" "|" _FILTER_REGEX) + FILE(STRINGS ${FILENAME} _FILE REGEX "(${_FILTER_REGEX})[: \t=\(\)\"]+([0-9.]+)") + + IF(_FILE) + FOREACH(_LINE ${_FILE}) + FOREACH(_VAR ${_FILTER_ARRAY}) + IF("${${_VAR}}" STREQUAL "") + STRING(REGEX REPLACE "^.*${_VAR}[: \t=\(\)\"]+([0-9.]+).*$" "\\1" ${_VAR} "${_LINE}") + IF(${_VAR} STREQUAL "${_LINE}") + SET(${_VAR}) + ENDIF() + IF(NOT ${_VAR} AND NOT STREQUAL "0") + SET(${_VAR} 0) + ENDIF() + ENDIF() + ENDFOREACH() + ENDFOREACH() + ENDIF() + ENDIF() +ENDMACRO() + +# macro to define FIND_PACKAGE options with a different package name +MACRO(FIX_PACKAGE_OPTIONS OLDNAME NEWNAME) + # append other options if needed + SET(_OPTIONS COMPONENTS REQUIRED QUIETLY) + + # process each options + FOREACH(_OPTION ${_OPTIONS}) + SET(OLD_OPTION ${OLDNAME}_FIND_${_OPTION}) + IF(DEFINED ) + SET(NEW_OPTION ${NEWNAME}_FIND_${_OPTION}) + SET(${NEW_OPTION} ${OLD_OPTION}) + ENDIF() + ENDFOREACH() +ENDMACRO() + +MACRO(FIND_PACKAGE_HELPER NAME INCLUDE) + # Looks for a directory containing NAME. + # + # NAME is the name of the library, lowercase and uppercase can be mixed + # It should be EXACTLY (same case) the same part as XXXX in FindXXXX.cmake + # + # INCLUDE is the file to check for includes + # + # Following parameters are optional variables and must be prefixed by: + # + # RELEASE is the list of libraries to check in release mode + # DEBUG is the list of libraries to check in debug mode + # SUFFIXES is the PATH_SUFFIXES to check for include file + # QUIET don't display anything + # VERBOSE display more details if not found + # REQUIRED throw an error if not found + # DIR is the base directory where to look for + # + # The first match will be used in the specified order and next matches will be ignored + # + # The following values are defined + # NAME_INCLUDE_DIR - where to find NAME + # NAME_LIBRARIES - link against these to use NAME + # NAME_FOUND - True if NAME is available. + + SET(_PARAMS ${ARGN}) + + SET(_RELEASE_LIBRARIES) + SET(_DEBUG_LIBRARIES) + SET(_SUFFIXES) + SET(_BASE_DIRECTORIES) + + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_VERBOSE OFF) + SET(_IS_DIR OFF) + + IF(_PARAMS) + FOREACH(_PARAM ${_PARAMS}) + IF(_PARAM STREQUAL "RELEASE") + SET(_IS_RELEASE ON) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "DEBUG") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG ON) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "SUFFIXES") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + SET(_IS_SUFFIXES ON) + ELSEIF(_PARAM STREQUAL "QUIET") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + SET(${NAME}_FIND_QUIETLY ON) + ELSEIF(_PARAM STREQUAL "VERBOSE") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + SET(_IS_VERBOSE ON) + ELSEIF(_PARAM STREQUAL "REQUIRED") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR OFF) + SET(${NAME}_FIND_REQUIRED ON) + ELSEIF(_PARAM STREQUAL "DIR") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_SUFFIXES OFF) + SET(_IS_DIR ON) + ELSE() + IF(_IS_RELEASE) + LIST(APPEND _RELEASE_LIBRARIES ${_PARAM}) + ELSEIF(_IS_DEBUG) + LIST(APPEND _DEBUG_LIBRARIES ${_PARAM}) + ELSEIF(_IS_SUFFIXES) + LIST(APPEND _SUFFIXES ${_PARAM}) + ELSEIF(_IS_DIR) + LIST(APPEND _BASE_DIRECTORIES ${_PARAM}) + ELSE() + MESSAGE(STATUS "parameter ${_PARAM} with no prefix") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + # Fixes names if invalid characters are found + IF("${NAME}" MATCHES "^[a-zA-Z0-9]+$") + SET(_NAME_FIXED ${NAME}) + ELSE() + # if invalid characters are detected, replace them by valid ones + STRING(REPLACE "+" "p" _NAME_FIXED ${NAME}) + ENDIF() + + # Create uppercase and lowercase versions of NAME + STRING(TOUPPER ${NAME} _UPNAME) + STRING(TOLOWER ${NAME} _LOWNAME) + + STRING(TOUPPER ${_NAME_FIXED} _UPNAME_FIXED) + STRING(TOLOWER ${_NAME_FIXED} _LOWNAME_FIXED) + + SET(_SUFFIXES ${_SUFFIXES} ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME}) + +# Don't use pkg-config +# IF(NOT WIN32 AND NOT IOS) +# FIND_PACKAGE(PkgConfig QUIET) +# SET(_MODULES ${_LOWNAME} ${_RELEASE_LIBRARIES}) +# LIST(REMOVE_DUPLICATES _MODULES) +# IF(PKG_CONFIG_EXECUTABLE) +# PKG_SEARCH_MODULE(PKG_${_NAME_FIXED} QUIET ${_MODULES}) +# ENDIF() +# ENDIF() + + SET(_INCLUDE_PATHS) + SET(_LIBRARY_PATHS) + + # Check for root directories passed to CMake with -DXXX_DIR=... + IF(DEFINED ${_UPNAME_FIXED}_DIR) + SET(_TMP ${${_UPNAME_FIXED}_DIR}) + GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE) + LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP}) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(DEFINED ${_UPNAME}_DIR) + SET(_TMP ${${_UPNAME}_DIR}) + LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP}) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(_BASE_DIRECTORIES) + FOREACH(_DIR ${_BASE_DIRECTORIES}) + IF(_DIR) + LIST(APPEND _INCLUDE_PATHS ${_DIR}/include ${_DIR}) + LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_DIR} as root directory") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + IF(UNIX) + # Append UNIX standard include paths + SET(_UNIX_INCLUDE_PATHS) + + # Append multiarch include paths + IF(CMAKE_LIBRARY_ARCHITECTURE) + LIST(APPEND _UNIX_INCLUDE_PATHS + /usr/local/include/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/include/${CMAKE_LIBRARY_ARCHITECTURE}) + ENDIF() + + LIST(APPEND _UNIX_INCLUDE_PATHS + /usr/local/include + /usr/include + /sw/include + /opt/local/include + /opt/csw/include + /opt/include) + ENDIF() + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Searching header ${INCLUDE} in: ${_INCLUDE_PATHS} with suffixes ${_SUFFIXES}") + ENDIF() + + # Search for include directory + FIND_PATH(${_UPNAME_FIXED}_INCLUDE_DIR + NAMES ${INCLUDE} + HINTS + ${PKG_${_NAME_FIXED}_INCLUDE_DIRS} + ${_INCLUDE_PATHS} + $ENV{${_UPNAME}_DIR}/include + $ENV{${_UPNAME_FIXED}_DIR}/include + $ENV{${_UPNAME}_DIR} + $ENV{${_UPNAME_FIXED}_DIR} + PATHS + ${_UNIX_INCLUDE_PATHS} + PATH_SUFFIXES + ${_SUFFIXES} + DOC "Include path for ${NAME}" + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_INCLUDE_DIR) + MESSAGE(STATUS "${INCLUDE} found in ${${_UPNAME_FIXED}_INCLUDE_DIR}") + ELSE() + MESSAGE(STATUS "${INCLUDE} not found") + ENDIF() + ENDIF() + + # Append environment variables XXX_DIR + LIST(APPEND _LIBRARY_PATHS + $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX} + $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX}) + + IF(UNIX) + SET(_UNIX_LIBRARY_PATHS) + + # Append multiarch libraries paths + IF(CMAKE_LIBRARY_ARCHITECTURE) + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}) + ENDIF() + + # Append UNIX standard libraries paths + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib + /usr/lib + /lib + /usr/local/X11R6/lib + /usr/X11R6/lib + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib${LIB_SUFFIX}) + ENDIF() + + LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED}) + LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d) + + # Under Windows, some libs may need the lib prefix + IF(WIN32) + SET(_LIBS ${_RELEASE_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _RELEASE_LIBRARIES lib${_LIB}) + ENDFOREACH() + + SET(_LIBS ${_DEBUG_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _DEBUG_LIBRARIES lib${_LIB}) + ENDFOREACH() + ENDIF() + + LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES) + LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES) + + # Search for release library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE + NAMES + ${_RELEASE_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}") + ELSE() + MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}") + ENDIF() + ENDIF() + + # Search for debug library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG + NAMES + ${_DEBUG_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}") + ELSE() + MESSAGE(STATUS "${NAME} debug library not found") + ENDIF() + ENDIF() + + SET(${_UPNAME_FIXED}_FOUND OFF) + + IF(${_UPNAME_FIXED}_INCLUDE_DIR) + # Set also _INCLUDE_DIRS + SET(${_UPNAME_FIXED}_INCLUDE_DIRS ${${_UPNAME_FIXED}_INCLUDE_DIR}) + ENDIF() + + # Library has been found if at least only one library and include are found + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Release and debug libraries found + SET(${_UPNAME_FIXED}_FOUND ON) + SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + # Release library found + SET(${_UPNAME_FIXED}_FOUND ON) + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Debug library found + SET(${_UPNAME_FIXED}_FOUND ON) + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + ENDIF() + + IF(${_UPNAME_FIXED}_FOUND) + IF(NOT ${NAME}_FIND_QUIETLY) + MESSAGE(STATUS "Found ${NAME}: ${${_UPNAME_FIXED}_LIBRARIES}") + ENDIF() + ELSE() + IF(${NAME}_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Error: Unable to find ${NAME}!") + ENDIF() + IF(NOT ${NAME}_FIND_QUIETLY) + MESSAGE(STATUS "Warning: Unable to find ${NAME}!") + ENDIF() + ENDIF() + + MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG) +ENDMACRO() + +MACRO(MESSAGE_VERSION_PACKAGE_HELPER NAME VERSION) + MESSAGE(STATUS "Found ${NAME} ${VERSION}: ${ARGN}") +ENDMACRO() + +MACRO(FIND_LIBRARY_HELPER NAME) + # Looks for libraries. + # + # NAME is the name of the library, lowercase and uppercase can be mixed + # + # Following parameters are optional variables and must be prefixed by: + # + # RELEASE is the list of libraries to check in release mode + # DEBUG is the list of libraries to check in debug mode + # VERBOSE display more details if not found + # REQUIRED throw an error if not found + # DIR is the base directory where to look for + # + # The first match will be used in the specified order and next matches will be ignored + # + # The following values are defined + # NAME_LIBRARIES - link against these to use NAME + + SET(_PARAMS ${ARGN}) + + SET(_RELEASE_LIBRARIES) + SET(_DEBUG_LIBRARIES) + SET(_BASE_DIRECTORIES) + + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_VERBOSE OFF) + SET(_IS_DIR OFF) + + IF(_PARAMS) + FOREACH(_PARAM ${_PARAMS}) + IF(_PARAM STREQUAL "RELEASE") + SET(_IS_RELEASE ON) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "DEBUG") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG ON) + SET(_IS_DIR OFF) + ELSEIF(_PARAM STREQUAL "VERBOSE") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + SET(_IS_VERBOSE ON) + ELSEIF(_PARAM STREQUAL "REQUIRED") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR OFF) + SET(${NAME}_FIND_REQUIRED ON) + ELSEIF(_PARAM STREQUAL "DIR") + SET(_IS_RELEASE OFF) + SET(_IS_DEBUG OFF) + SET(_IS_DIR ON) + ELSE() + IF(_IS_RELEASE) + LIST(APPEND _RELEASE_LIBRARIES ${_PARAM}) + ELSEIF(_IS_DEBUG) + LIST(APPEND _DEBUG_LIBRARIES ${_PARAM}) + ELSEIF(_IS_DIR) + LIST(APPEND _BASE_DIRECTORIES ${_PARAM}) + ELSE() + MESSAGE(STATUS "parameter ${_PARAM} with no prefix") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + # Fixes names if invalid characters are found + IF("${NAME}" MATCHES "^[a-zA-Z0-9]+$") + SET(_NAME_FIXED ${NAME}) + ELSE() + # if invalid characters are detected, replace them by valid ones + STRING(REPLACE "+" "p" _NAME_FIXED ${NAME}) + ENDIF() + + # Create uppercase and lowercase versions of NAME + STRING(TOUPPER ${NAME} _UPNAME) + STRING(TOLOWER ${NAME} _LOWNAME) + + STRING(TOUPPER ${_NAME_FIXED} _UPNAME_FIXED) + STRING(TOLOWER ${_NAME_FIXED} _LOWNAME_FIXED) + + SET(_LIBRARY_PATHS) + + # Check for root directories passed to CMake with -DXXX_DIR=... + IF(DEFINED ${_UPNAME_FIXED}_DIR) + SET(_TMP ${${_UPNAME_FIXED}_DIR}) + GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(DEFINED ${_UPNAME}_DIR) + SET(_TMP ${${_UPNAME}_DIR}) + LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}") + ENDIF() + ENDIF() + + IF(_BASE_DIRECTORIES) + FOREACH(_DIR ${_BASE_DIRECTORIES}) + IF(_DIR) + LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX}) + + IF(_IS_VERBOSE) + MESSAGE(STATUS "Using ${_DIR} as root directory") + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + + # Append environment variables XXX_DIR + LIST(APPEND _LIBRARY_PATHS + $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX} + $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX}) + + IF(UNIX) + SET(_UNIX_LIBRARY_PATHS) + + # Append multiarch libraries paths + IF(CMAKE_LIBRARY_ARCHITECTURE) + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}) + ENDIF() + + # Append UNIX standard libraries paths + LIST(APPEND _UNIX_LIBRARY_PATHS + /usr/local/lib + /usr/lib + /lib + /usr/local/X11R6/lib + /usr/X11R6/lib + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib${LIB_SUFFIX}) + ENDIF() + + LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED}) + LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d) + + # Under Windows, some libs may need the lib prefix + IF(WIN32) + SET(_LIBS ${_RELEASE_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _RELEASE_LIBRARIES lib${_LIB}) + ENDFOREACH() + + SET(_LIBS ${_DEBUG_LIBRARIES}) + FOREACH(_LIB ${_LIBS}) + LIST(APPEND _DEBUG_LIBRARIES lib${_LIB}) + ENDFOREACH() + ENDIF() + + LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES) + LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES) + + # Search for release library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE + NAMES + ${_RELEASE_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}") + ELSE() + MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}") + ENDIF() + ENDIF() + + # Search for debug library + FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG + NAMES + ${_DEBUG_LIBRARIES} + HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS} + PATHS + ${_LIBRARY_PATHS} + ${_UNIX_LIBRARY_PATHS} + NO_CMAKE_SYSTEM_PATH + ) + + IF(_IS_VERBOSE) + IF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}") + ELSE() + MESSAGE(STATUS "${NAME} debug library not found") + ENDIF() + ENDIF() + + # Library has been found if at least only one library and include are found + IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Release and debug libraries found + SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE) + # Release library found + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE}) + ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG) + # Debug library found + SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG}) + ENDIF() + + MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG) +ENDMACRO() + +MACRO(FIND_LIBCURL) + IF(NOT CURL_FOUND) + FIND_PACKAGE(CURL REQUIRED) + + IF(WIN32 OR CURL_LIBRARY MATCHES "\\.a" OR WITH_STATIC_CURL) + SET(CURL_STATIC ON) + ELSE() + SET(CURL_STATIC OFF) + ENDIF() + + IF(CURL_STATIC) + SET(CURL_DEFINITIONS -DCURL_STATICLIB) + + IF(UNIX) + # CURL can depend on libidn + FIND_LIBRARY(IDN_LIBRARY idn) + IF(IDN_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY}) + ENDIF() + + # CURL Macports version can depend on libidn, libintl and libiconv too + IF(APPLE) + FIND_LIBRARY(INTL_LIBRARY intl) + IF(INTL_LIBRARY) + LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY}) + ENDIF() + ELSE() + # Only used by libcurl under Linux + FIND_PACKAGE(OpenSSL REQUIRED) + + #IF(WIN32) + # SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib) + #ENDIF() + + # Only Linux version of libcurl depends on OpenSSL + LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) + LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES}) + ENDIF() + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() + +MACRO(FIND_LIBXML2) + IF(NOT LIBXML2_FOUND) + FIND_PACKAGE(LibXml2 REQUIRED) + + IF(WIN32 OR WITH_STATIC_LIBXML2) + LIST(APPEND LIBXML2_DEFINITIONS -DLIBXML_STATIC) + ENDIF() + + IF(WITH_LIBXML2_ICONV) + FIND_PACKAGE(Iconv REQUIRED) +# LIST(APPEND CURL_INCLUDE_DIRS ${ICONV_INCLUDE_DIR}) + LIST(APPEND LIBXML2_LIBRARIES ${ICONV_LIBRARIES}) + ENDIF() + + IF(WITH_STATIC) + # libxml2 could need winsock2 library + IF(WIN32) + FIND_LIBRARY(WINSOCK2_LIB ws2_32) + + IF(WINSOCK2_LIB) + LIST(APPEND LIBXML2_LIBRARIES ${WINSOCK2_LIB}) + ENDIF() + + FIND_LIBRARY(CRYPT32_LIB Crypt32) + + IF(CRYPT32_LIB) + LIST(APPEND LIBXML2_LIBRARIES ${CRYPT32_LIB}) + ENDIF() + ELSE() + # under Linux and OS X, recent libxml2 versions are linked against liblzma + FIND_PACKAGE(LibLZMA) + + IF(LIBLZMA_LIBRARIES) + LIST(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES}) + ENDIF() + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() + +MACRO(ADD_QT_LIBRARY _NAME) + IF(WIN32) + SET(_PREFIX "Qt5") + SET(_EXT "lib") + ELSE() + SET(_PREFIX "libQt5") + SET(_EXT "a") + ENDIF() + SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}.${_EXT}") + IF(EXISTS ${_LIB}) + LIST(APPEND QT_LIBRARIES optimized ${_LIB}) + ENDIF() + SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}") + IF(EXISTS ${_LIB}) + LIST(APPEND QT_LIBRARIES debug ${_LIB}) + ENDIF() +ENDMACRO() + +MACRO(ADD_QT_PLUGIN _TYPE _NAME) + IF(WIN32) + SET(_PREFIX "") + SET(_EXT "lib") + ELSE() + SET(_PREFIX "lib") + SET(_EXT "a") + ENDIF() + SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}.${_EXT}") + IF(EXISTS ${_LIB}) + LIST(APPEND QT_LIBRARIES optimized ${_LIB}) + ENDIF() + SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}") + IF(EXISTS ${_LIB}) + LIST(APPEND QT_LIBRARIES debug ${_LIB}) + ENDIF() +ENDMACRO() + +MACRO(ADD_QT_SYSTEM_LIBRARY _NAME) + # Save default suffixes + SET(_OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + + # Define specific suffixes + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) + + # Find the library with specified suffixes + FIND_LIBRARY(${_NAME}_LIBRARY NAMES ${_NAME}) + + # Restore default suffixes + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_OLD_SUFFIXES}) + + IF(${_NAME}_LIBRARY) + MESSAGE(STATUS "Found ${${_NAME}_LIBRARY} ${_NAME}") + + LIST(APPEND QT_LIBRARIES ${${_NAME}_LIBRARY}) + ELSE() + MESSAGE(STATUS "Didn't find ${_NAME}") + ENDIF() +ENDMACRO() + +MACRO(FIND_QT5) + CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR) + + SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR}) + + FIND_PACKAGE(Qt5Core QUIET) + + IF(Qt5Core_FOUND) + # Check if we are using Qt static or shared libraries + GET_TARGET_PROPERTY(_FILE Qt5::Core IMPORTED_LOCATION_RELEASE) + + SET(QT_VERSION "${Qt5Core_VERSION_STRING}") + SET(_VERSION "${QT_VERSION}") + + IF(_FILE MATCHES "\\.(lib|a)$") + SET(QT_STATIC ON) + SET(_VERSION "${_VERSION} static version") + ELSE() + SET(QT_STATIC OFF) + SET(_VERSION "${_VERSION} shared version") + ENDIF() + + MESSAGE(STATUS "Found Qt ${_VERSION}") + + # These variables are not defined with Qt5 CMake modules + SET(QT_BINARY_DIR "${_qt5Core_install_prefix}/bin") + SET(QT_LIBRARY_DIR "${_qt5Core_install_prefix}/lib") + SET(QT_PLUGINS_DIR "${_qt5Core_install_prefix}/plugins") + SET(QT_TRANSLATIONS_DIR "${_qt5Core_install_prefix}/translations") + + # Fix wrong include directories with Qt 5 under Mac OS X + INCLUDE_DIRECTORIES("${_qt5Core_install_prefix}/include") + + FIND_PACKAGE(Qt5Gui) + FIND_PACKAGE(Qt5Widgets) + FIND_PACKAGE(Qt5OpenGL) + FIND_PACKAGE(Qt5Xml) + FIND_PACKAGE(Qt5LinguistTools) + FIND_PACKAGE(Qt5Network) + + IF(QT_STATIC) + FIND_PACKAGE(PNG REQUIRED) + FIND_PACKAGE(Jpeg REQUIRED) + + ADD_DEFINITIONS(-DQT_STATICPLUGIN) + + SET(QT_LIBRARIES Qt5::Widgets) + + # Gui + LIST(APPEND QT_LIBRARIES Qt5::Gui Qt5::OpenGL) + + ADD_QT_LIBRARY(PrintSupport) + + IF(WIN32) + LIST(APPEND QT_LIBRARIES + ${WINSDK_LIBRARY_DIR}/Imm32.lib + ${WINSDK_LIBRARY_DIR}/OpenGL32.lib + ${WINSDK_LIBRARY_DIR}/WinMM.Lib) + ADD_QT_PLUGIN(platforms qwindows) + ADD_QT_LIBRARY(PlatformSupport) + ELSEIF(APPLE) + # Cups needs .dylib + SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib) + FIND_LIBRARY(CUPS_LIBRARY cups) + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES}) + + FIND_LIBRARY(IOKIT_FRAMEWORK IOKit) + FIND_LIBRARY(COCOA_FRAMEWORK Cocoa) + FIND_LIBRARY(SYSTEMCONFIGURATION_FRAMEWORK SystemConfiguration) + FIND_LIBRARY(OPENGL_FRAMEWORK NAMES OpenGL) + + LIST(APPEND QT_LIBRARIES + ${CUPS_LIBRARY} + ${COCOA_FRAMEWORK} + ${SYSTEMCONFIGURATION_FRAMEWORK} + ${IOKIT_FRAMEWORK} + ${OPENGL_FRAMEWORK}) + + ADD_QT_PLUGIN(printsupport cocoaprintersupport) + ADD_QT_PLUGIN(platforms qcocoa) + ADD_QT_LIBRARY(PlatformSupport) + ELSE() + # order is very important there + ADD_QT_PLUGIN(platforms qxcb) + ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration) + + ADD_QT_LIBRARY(XcbQpa) + ADD_QT_LIBRARY(GlxSupport) + ADD_QT_LIBRARY(ServiceSupport) + ADD_QT_LIBRARY(EdidSupport) + ADD_QT_LIBRARY(FontDatabaseSupport) + ADD_QT_LIBRARY(ThemeSupport) + ADD_QT_LIBRARY(EventDispatcherSupport) + ADD_QT_LIBRARY(PlatformSupport) + + ADD_QT_LIBRARY(DBus) + + IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a") + LIST(APPEND QT_LIBRARIES "${QT_LIBRARY_DIR}/libxcb-static.a") + ENDIF() + + # always link these in dynamic, API never changes + ADD_QT_SYSTEM_LIBRARY(X11) + ADD_QT_SYSTEM_LIBRARY(Xmu) + ADD_QT_SYSTEM_LIBRARY(X11-xcb) + ADD_QT_SYSTEM_LIBRARY(Xi) + ADD_QT_SYSTEM_LIBRARY(SM) + ADD_QT_SYSTEM_LIBRARY(ICE) + ADD_QT_SYSTEM_LIBRARY(xcb) + ADD_QT_SYSTEM_LIBRARY(GL) + ADD_QT_SYSTEM_LIBRARY(xcb-glx) + ADD_QT_SYSTEM_LIBRARY(fontconfig) + ADD_QT_SYSTEM_LIBRARY(Xrender) + ENDIF() + + ADD_QT_PLUGIN(imageformats qgif) + ADD_QT_PLUGIN(imageformats qicns) + ADD_QT_PLUGIN(imageformats qico) + ADD_QT_PLUGIN(imageformats qjpeg) + + # harfbuzz is needed since Qt 5.3 + IF(UNIX) + SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzzng.a") + IF(NOT EXISTS ${HB_LIB}) + SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzz.a") + ENDIF() + ELSEIF(WIN32) + SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib") + ENDIF() + IF(EXISTS ${HB_LIB}) + LIST(APPEND QT_LIBRARIES ${HB_LIB}) + ENDIF() + + # freetype is needed since Qt 5.5 + FIND_PACKAGE(Freetype) + + IF(FREETYPE_FOUND) + LIST(APPEND QT_LIBRARIES ${FREETYPE_LIBRARIES}) + ELSE() + IF(UNIX) + SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a") + ELSEIF(WIN32) + SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib") + ENDIF() + IF(EXISTS ${FREETYPE_LIB}) + LIST(APPEND QT_LIBRARIES ${FREETYPE_LIB}) + ENDIF() + ENDIF() + + ADD_QT_PLUGIN(accessible qtaccessiblewidgets) + + LIST(APPEND QT_LIBRARIES ${PNG_LIBRARIES} ${JPEG_LIBRARY}) + + # Network + LIST(APPEND QT_LIBRARIES Qt5::Network Qt5::Xml) + LIST(APPEND QT_LIBRARIES ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) + + IF(WIN32) + LIST(APPEND QT_LIBRARIES + ${WINSDK_LIBRARY_DIR}/Crypt32.lib + ${WINSDK_LIBRARY_DIR}/WS2_32.Lib + ${WINSDK_LIBRARY_DIR}/IPHlpApi.Lib) + ENDIF() + + # Core + LIST(APPEND QT_LIBRARIES Qt5::Core) + + # pcre is needed since Qt 5.5 + IF(UNIX) + SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a") + IF(NOT EXISTS ${PCRE_LIB}) + SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre2.a") + ENDIF() + ELSEIF(WIN32) + SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib") + ENDIF() + IF(EXISTS ${PCRE_LIB}) + LIST(APPEND QT_LIBRARIES ${PCRE_LIB}) + ENDIF() + + IF(APPLE) + FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre) + + FIND_LIBRARY(SECURITY_FRAMEWORK Security) + + LIST(APPEND QT_LIBRARIES + ${PCRE_LIBRARY} + ${FOUNDATION_FRAMEWORK} + ${CARBON_FRAMEWORK} + ${SECURITY_FRAMEWORK}) + ELSEIF(UNIX) + FIND_PACKAGE(Threads) + LIST(APPEND QT_LIBRARIES ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} -lrt) + ENDIF() + ELSE() + SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core) + ENDIF() + ELSE() + MESSAGE(WARNING "Unable to find Qt 5") + ENDIF() +ENDMACRO() diff --git a/code/CMakeModules/FindNeL.cmake b/code/CMakeModules/FindNeL.cmake new file mode 100644 index 000000000..e75163cce --- /dev/null +++ b/code/CMakeModules/FindNeL.cmake @@ -0,0 +1,398 @@ +# NEL_DIR can be specified as root directory + +# Returned variables +# NELDRIVER_XXX_BINARY_DEBUG +# NELDRIVER_XXX_BINARY_RELEASE +# NELDRIVER_XXX_LIBRARY_DEBUG +# NELDRIVER_XXX_LIBRARY_RELEASE +# NELDRIVER_XXX_FOUND +# NEL_DEFINITIONS +# NEL_INCLUDE_DIR +# NEL_INCLUDE_DIRS +# NEL_LIBRARIES +# NELXXX_FOUND +# NELXXX_LIBRARIES + + +INCLUDE(FindHelpers) + +# Init all variables we'll set +SET(NEL_LIBRARIES) +SET(NEL_INCLUDE_DIR) +SET(NEL_INCLUDE_DIRS) +SET(NEL_VERSION) +SET(NEL_STATIC) +SET(NEL_STATIC_DRIVERS) +SET(NEL_VERSION_MAJOR) +SET(NEL_VERSION_MINOR) +SET(NEL_VERSION_PATCH) +SET(NEL_REVISION) +SET(NEL_VERSION) + +SET(NEL_MODULES_FOUND) +SET(NEL_MODULES_AVAILABLE 3d georges gui ligo logic net pacs sound) # cegui pipeline + +SET(NEL_DRIVERS_FOUND) +SET(NEL_DRIVERS_AVAILABLE opengl opengles direct3d dsound fmod openal xaudio2) + +SET(NELMISC_FIND_REQUIRED ${NeL_FIND_REQUIRED}) + +# Force search of NELMISC +FIND_PACKAGE_HELPER(nelmisc nel/misc/types_nl.h RELEASE nelmisc_r nelmisc DEBUG nelmisc_d DIR ${NEL_DIR} VERBOSE QUIET) + +IF(NELMISC_FOUND) + # define NEL_DIR if not specified + IF(NOT NEL_DIR) + GET_FILENAME_COMPONENT(NEL_DIR ${NELMISC_INCLUDE_DIR}/.. ABSOLUTE) + ENDIF() + + # Aliases for include directory + SET(NEL_INCLUDE_DIR ${NELMISC_INCLUDE_DIR}) + SET(NEL_INCLUDE_DIRS ${NEL_INCLUDE_DIR}) + + MESSAGE(STATUS "Found NeL headers in ${NEL_INCLUDE_DIR}") + + GET_FILENAME_COMPONENT(NEL_LIBRARY_DIR ${NELMISC_LIBRARY} DIRECTORY) + + MESSAGE(STATUS "Found NeL library in ${NEL_LIBRARY_DIR}") + + # TODO: implement static version checks for Windows + + # static libraries + IF(UNIX) + GET_FILENAME_COMPONENT(_LIBEXT ${NELMISC_LIBRARY} EXT) + + IF(_LIBEXT STREQUAL ".a") + SET(NEL_STATIC ON) + MESSAGE(STATUS "NeL is using static libraries") + ENDIF() + ENDIF() + + IF(WIN32) + SET(NELDRIVER_DIRS_TO_CHECK + ${NEL_DIR}/bin${LIB_SUFFIX} + ${NEL_DIR} + ) + ELSE() + SET(NELDRIVER_DIRS_TO_CHECK + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}/nel + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/nel + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/lib/nel + /usr/lib + ) + ENDIF() + + # check for static drivers + FOREACH(_DRIVER ${NEL_DRIVERS_AVAILABLE}) + IF(WIN32) + SET(_DRIVER_RELASE_FILE "nel_drv_${_DRIVER}_win_r") + SET(_DRIVER_DEBUG_FILE "nel_drv_${_DRIVER}_win_d") + SET(_DRIVER_SHARED_EXT dll) + SET(_DRIVER_STATIC_EXT lib) + ELSE() + SET(_DRIVER_RELEASE_FILE "nel_drv_${_DRIVER}") + SET(_DRIVER_DEBUG_FILE) + SET(_DRIVER_SHARED_EXT so) + SET(_DRIVER_STATIC_EXT a) + ENDIF() + + STRING(TOUPPER ${_DRIVER} _UPDRIVER) + + FOREACH(_DIR ${NELDRIVER_DIRS_TO_CHECK}) + SET(_FOUND OFF) + + IF(_DRIVER_RELASE_FILE) + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_SHARED_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_BINARY_RELEASE ${_FILE}) + + MESSAGE(STATUS "Found NeL release shared driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS OFF) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_STATIC_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_LIBRARY_RELEASE ${_FILE}) + + MESSAGE(STATUS "Found NeL release static driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS ON) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + ENDIF() + + IF(_DRIVER_DEBUG_FILE) + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_SHARED_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_BINARY_DEBUG ${_FILE}) + + MESSAGE(STATUS "Found NeL debug shared driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS OFF) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + + SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_STATIC_EXT}") + IF(EXISTS ${_FILE}) + SET(NELDRIVER_${_UPDRIVER}_LIBRARY_DEBUG ${_FILE}) + + MESSAGE(STATUS "Found NeL debug static driver ${_DRIVER}: ${_FILE}") + + SET(NEL_STATIC_DRIVERS ON) + + IF(NOT NEL_DRIVER_DIR) + SET(NEL_DRIVER_DIR ${_DIR}) + ENDIF() + ENDIF() + + IF(_FOUND) + SET(NELDRIVER_${_UPDRIVER}_FOUND ON) + LIST(APPEND NEL_DRIVERS_FOUND ${_DRIVER}) + ENDIF() + ENDIF() + ENDFOREACH() + ENDFOREACH() + + MESSAGE(STATUS "Found NeL driver in ${NEL_DRIVER_DIR}") + + PARSE_VERSION_OTHER(${NEL_INCLUDE_DIR}/nel/misc/version_nl.h NL_VERSION_MAJOR NL_VERSION_MINOR NL_VERSION_PATCH NL_REVISION) + + SET(NEL_VERSION_MAJOR ${NL_VERSION_MAJOR}) + SET(NEL_VERSION_MINOR ${NL_VERSION_MINOR}) + SET(NEL_VERSION_PATCH ${NL_VERSION_PATCH}) + SET(NEL_REVISION ${NL_REVISION}) + + IF(NOT NEL_VERSION) + IF(NEL_VERSION_MAJOR OR NEL_VERSION_MINOR} OR NEL_VERSION_PATCH) + SET(NEL_VERSION "${NEL_VERSION_MAJOR}.${NEL_VERSION_MINOR}.${NEL_VERSION_PATCH}") + ELSE() + SET(NEL_VERSION "0.5.0") + ENDIF() + + IF(NEL_REVISION) + SET(NEL_VERSION "${NEL_VERSION}.${NEL_REVISION}") + ENDIF() + ENDIF() + + FIND_PACKAGE(PNG REQUIRED) + IF(PNG_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${PNG_LIBRARIES}) + ENDIF() + + FIND_PACKAGE(Jpeg REQUIRED) + IF(JPEG_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${JPEG_LIBRARY}) + ENDIF() + + FIND_PACKAGE(GIF) + + IF(GIF_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${GIF_LIBRARY}) + ENDIF() + + FIND_LIBXML2() + + IF(LIBXML2_FOUND) + LIST(APPEND NELMISC_LIBRARIES ${LIBXML2_LIBRARIES}) + ENDIF() + + LIST(REMOVE_ITEM NeL_FIND_COMPONENTS misc) + + LIST(APPEND NEL_MODULES_FOUND misc) + LIST(APPEND NEL_LIBRARIES ${NELMISC_LIBRARIES}) +ENDIF() + +IF(NOT NeL_FIND_COMPONENTS) + SET(NeL_FIND_COMPONENTS ${NEL_MODULES_AVAILABLE}) + + # We can skip not installed modules + SET(NeL_FIND_REQUIRED OFF) +ENDIF() + +FOREACH(COMPONENT ${NeL_FIND_COMPONENTS}) + SET(_NAME NeL${COMPONENT}) + STRING(TOUPPER ${_NAME} _UPNAME) + + # module is required + SET(${_NAME}_FIND_REQUIRED ${NeL_FIND_REQUIRED}) + + IF(COMPONENT STREQUAL "3d") + SET(HEADER_FILE shape.h) +# ELSEIF(COMPONENT STREQUAL "cegui") +# SET(HEADER_FILE shape.h) + ELSEIF(COMPONENT STREQUAL "georges") + SET(HEADER_FILE form.h) + ELSEIF(COMPONENT STREQUAL "gui") + SET(HEADER_FILE reflect.h) + ELSEIF(COMPONENT STREQUAL "ligo") + SET(HEADER_FILE primitive.h) + ELSEIF(COMPONENT STREQUAL "logic") + SET(HEADER_FILE logic_state.h) + ELSEIF(COMPONENT STREQUAL "net") + SET(HEADER_FILE sock.h) + ELSEIF(COMPONENT STREQUAL "pacs") + SET(HEADER_FILE primitive_block.h) +# ELSEIF(COMPONENT STREQUAL "pipeline") +# SET(HEADER_FILE shape.h) + ELSEIF(COMPONENT STREQUAL "sound") + SET(HEADER_FILE shape.h) + ELSE() + SET(HEADER_FILE) + ENDIF() + + # display if a component has a wrong name + IF(NOT HEADER_FILE) + MESSAGE(STATUS "NeL module ${COMPONENT} not supported, ignoring it...") + CONTINUE() + ENDIF() + + FIND_PACKAGE_HELPER(${_NAME} nel/${COMPONENT}/${HEADER_FILE} + RELEASE nel${COMPONENT}_r nel${COMPONENT} + DEBUG nel${COMPONENT}_d + QUIET) + + IF(${_UPNAME}_FOUND) + LIST(APPEND NEL_MODULES_FOUND ${COMPONENT}) + + IF(COMPONENT STREQUAL "3d") + IF(NEL_STATIC) + # 3rd party dependencies + FIND_PACKAGE(Freetype REQUIRED) + IF(FREETYPE_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${FREETYPE_LIBRARIES}) + ENDIF() + + # Append static 3D drivers + IF(NEL_STATIC_DRIVERS) + # Direct3D driver (only under Windows) + IF(WIN32) + IF(NELDRIVER_DIRECT3D_LIBRARY_DEBUG) + LIST(APPEND ${_UPNAME}_LIBRARIES debug ${NELDRIVER_DIRECT3D_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_DIRECT3D_LIBRARY_RELEASE) + LIST(APPEND ${_UPNAME}_LIBRARIES optimized ${NELDRIVER_DIRECT3D_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + + # OpenGL driver + IF(NELDRIVER_OPENGL_LIBRARY_DEBUG) + LIST(APPEND ${_UPNAME}_LIBRARIES debug ${NELDRIVER_OPENGL_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_OPENGL_LIBRARY_RELEASE) + LIST(APPEND ${_UPNAME}_LIBRARIES optimized ${NELDRIVER_OPENGL_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + ENDIF() + ELSEIF(COMPONENT STREQUAL "gui") + FIND_PACKAGE(Luabind REQUIRED) + + LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES}) + + FIND_LIBCURL() + + IF(CURL_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${CURL_LIBRARIES}) + LIST(APPEND ${_UPNAME}_DEFINITIONS ${CURL_DEFINITIONS}) + ENDIF() + + # TODO: remove complately OpenSSL requirement on Windows + + # Only used by libcurl under Linux + FIND_PACKAGE(OpenSSL REQUIRED) + + IF(WIN32) + LIST(APPEND OPENSSL_LIBRARIES Crypt32.lib) + ENDIF() + + # Only Linux version of libcurl depends on OpenSSL + LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) + LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES}) + + LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES} ${CURL_LIBRARIES}) + LIST(APPEND NEL_DEFINITIONS ${${_UPNAME}_DEFINITIONS}) + ELSEIF(COMPONENT STREQUAL "sound") + FIND_PACKAGE(Ogg REQUIRED) + + IF(OGG_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${OGG_LIBRARY}) + ENDIF() + + FIND_PACKAGE(Vorbis REQUIRED) + + IF(VORBIS_FOUND) + LIST(APPEND ${_UPNAME}_LIBRARIES ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY}) + ENDIF() + + IF(NEL_STATIC) + # Link to snd_lowlevel + FIND_LIBRARY_HELPER(nelsnd_lowlevel RELEASE nelsnd_lowlevel_r DEBUG nelsnd_lowlevel_d DIR ${NEL_DIR} REQUIRED) + + IF(NELSND_LOWLEVEL_LIBRARIES) + MESSAGE(STATUS "Found NeL sound lowlevel ${NELSND_LOWLEVEL_LIBRARIES}") + + LIST(APPEND NELSOUND_LIBRARIES ${NELSND_LOWLEVEL_LIBRARIES}) + + IF(NEL_STATIC_DRIVERS) + # DirectSound, XAudio2 and FMod drivers (only under Windows) + IF(WIN32) + # DirectSound + IF(NELDRIVER_DIRECTSOUND_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_DIRECTSOUND_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_DIRECTSOUND_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_DIRECTSOUND_LIBRARY_RELEASE}) + ENDIF() + + # FMod + IF(NELDRIVER_FMOD_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_FMOD_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_FMOD_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_FMOD_LIBRARY_RELEASE}) + ENDIF() + + # XAudio2 + IF(NELDRIVER_XAUDIO2_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_XAUDIO2_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_XAUDIO2_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_XAUDIO2_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + + # OpenAL driver + IF(NELDRIVER_OPENAL_LIBRARY_DEBUG) + LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_OPENAL_LIBRARY_DEBUG}) + ENDIF() + + IF(NELDRIVER_OPENAL_LIBRARY_RELEASE) + LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_OPENAL_LIBRARY_RELEASE}) + ENDIF() + ENDIF() + ENDIF() + ENDIF() + ENDIF() + + LIST(APPEND NEL_LIBRARIES ${${_UPNAME}_LIBRARIES}) + ENDIF() +ENDFOREACH() + +MESSAGE_VERSION_PACKAGE_HELPER(NeL ${NEL_VERSION} ${NEL_MODULES_FOUND}) diff --git a/code/CMakeModules/FindRyzomGameShare.cmake b/code/CMakeModules/FindRyzomGameShare.cmake new file mode 100644 index 000000000..f76e4dd93 --- /dev/null +++ b/code/CMakeModules/FindRyzomGameShare.cmake @@ -0,0 +1,14 @@ +INCLUDE(FindHelpers) + +FIND_PACKAGE_HELPER(RyzomGameShare game_share/continent.h RELEASE ryzom_gameshare_r ryzom_gameshare DEBUG ryzom_gameshare_d DIR ${NEL_DIR} ${RYZOM_DIR} SUFFIXES ryzom) + +IF(RYZOMGAMESHARE_FOUND) + FIND_PACKAGE(NeL REQUIRED) + LIST(APPEND RYZOMGAMESHARE_INCLUDE_DIRS ${NEL_INCLUDE_DIRS}) + LIST(APPEND RYZOMGAMESHARE_LIBRARIES ${NELMISC_LIBRARIES} ${NELLIGO_LIBRARIES} ${NELNET_LIBRARIES} ${NELGEORGES_LIBRARIES}) + + SET(RYZOM_GAMESHARE_LIBRARIES ${RYZOMGAMESHARE_LIBRARIES}) + SET(RYZOM_GAMESHARE_FOUND ${RYZOMGAMESHARE_FOUND}) + SET(RYZOM_GAMESHARE_INCLUDE_DIR ${RYZOMGAMESHARE_INCLUDE_DIR}) + SET(RYZOM_GAMESHARE_INCLUDE_DIRS ${RYZOMGAMESHARE_INCLUDE_DIRS}) +ENDIF() diff --git a/code/CMakeModules/FindSteam.cmake b/code/CMakeModules/FindSteam.cmake index 44013e6ed..8d9b12372 100644 --- a/code/CMakeModules/FindSteam.cmake +++ b/code/CMakeModules/FindSteam.cmake @@ -1,8 +1,8 @@ # - Locate Steam API # This module defines # STEAM_LIBRARY, the library to link against -# VORBIS_FOUND, if false, do not try to link to VORBIS -# VORBIS_INCLUDE_DIR, where to find headers. +# STEAM_FOUND, if false, do not try to link to STEAM +# STEAM_INCLUDE_DIR, where to find headers. IF(STEAM_LIBRARY AND STEAM_INCLUDE_DIR) # in cache already diff --git a/code/CMakeModules/GetRevision.cmake b/code/CMakeModules/GetRevision.cmake index b9bd6eb84..17a617ba3 100644 --- a/code/CMakeModules/GetRevision.cmake +++ b/code/CMakeModules/GetRevision.cmake @@ -98,4 +98,6 @@ ENDIF() IF(DEFINED REVISION) MESSAGE(STATUS "Found revision ${REVISION}") +ELSE() + SET(REVISION 0) ENDIF() diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index c396bd6cf..24b4d5a85 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -209,8 +209,8 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) ENDIF() ENDIF() - IF(USE_CPP0X AND gcc_compiler_version GREATER "6.2.0") - LIST(APPEND _FLAGS "-std=gnu++11") + IF(CMAKE_CXX11_EXTENSION_COMPILE_OPTION) + LIST(APPEND _FLAGS ${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}) ENDIF() # Format definitions diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 95b28bb8a..abe41ca1f 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -238,6 +238,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) OPTION(WITH_EXTERNAL "With provided external." OFF) ENDIF() OPTION(WITH_STATIC_EXTERNAL "With static external libraries" OFF) + OPTION(WITH_STATIC_RUNTIMES "Use only static C++ runtimes" OFF) IF(UNIX AND NOT APPLE) OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" ON ) ELSE() @@ -373,8 +374,14 @@ MACRO(ADD_PLATFORM_LINKFLAGS _FLAGS) SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${_FLAGS}") ENDMACRO() -MACRO(NL_SETUP_BUILD) +MACRO(CONVERT_VERSION_NUMBER _VERSION_NUMBER _BASE) + SET(${_VERSION_NUMBER} 0) + FOREACH(_ARG ${ARGN}) + MATH(EXPR ${_VERSION_NUMBER} "${${_VERSION_NUMBER}} * ${_BASE} + ${_ARG}") + ENDFOREACH() +ENDMACRO() +MACRO(NL_SETUP_BUILD) #----------------------------------------------------------------------------- # Setup the buildmode variables. # @@ -636,8 +643,14 @@ MACRO(NL_SETUP_BUILD) SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}") ENDIF() - SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}") - SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}") + IF(WITH_STATIC_RUNTIMES) + SET(RUNTIME_FLAG "/MT") + ELSE() + SET(RUNTIME_FLAG "/MD") + ENDIF() + + SET(NL_DEBUG_CFLAGS "/Zi ${RUNTIME_FLAG}d /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}") + SET(NL_RELEASE_CFLAGS "${RUNTIME_FLAG} /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}") SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt ${MSVC_INCREMENTAL_YES_FLAG} ${NL_DEBUG_LINKFLAGS}") SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}") @@ -665,7 +678,7 @@ MACRO(NL_SETUP_BUILD) IF(APPLE) SET(OBJC_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch -fobjc-weak) - + IF(NOT XCODE) IF(CMAKE_OSX_ARCHITECTURES) SET(TARGETS_COUNT 0) @@ -874,7 +887,9 @@ MACRO(NL_SETUP_BUILD) ENDIF() # use c++0x standard to use std::unique_ptr and std::shared_ptr - SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -std=c++0x") + IF(CMAKE_CXX11_EXTENSION_COMPILE_OPTION) + SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}") + ENDIF() ADD_PLATFORM_FLAGS("-D_REENTRANT") @@ -950,8 +965,6 @@ MACRO(NL_SETUP_BUILD) ADD_PLATFORM_FLAGS("-fPIC") ENDIF() - SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48") - # hardening ADD_PLATFORM_FLAGS("-fstack-protector --param=ssp-buffer-size=4") @@ -965,6 +978,10 @@ MACRO(NL_SETUP_BUILD) IF(NOT APPLE) ADD_PLATFORM_LINKFLAGS("-Wl,--no-undefined -Wl,--as-needed") + + IF(WITH_STATIC_RUNTIMES) + ADD_PLATFORM_LINKFLAGS("-static-libstdc++") + ENDIF() ENDIF() IF(NOT APPLE) @@ -1023,6 +1040,12 @@ MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE) ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX) MACRO(NL_SETUP_PREFIX_PATHS) + IF(TARGET_X64 AND WIN32) + SET(LIB_SUFFIX "64") + ELSE() + SET(LIB_SUFFIX "") + ENDIF() + ## Allow override of install_prefix/etc path. IF(NOT NL_ETC_PREFIX) IF(WITH_UNIX_STRUCTURE) @@ -1046,7 +1069,7 @@ MACRO(NL_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/sbin path. IF(NOT NL_SBIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(NL_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + SET(NL_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.") ELSE() SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") ENDIF() @@ -1056,7 +1079,7 @@ MACRO(NL_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/bin path. IF(NOT NL_BIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(NL_BIN_PREFIX "bin" CACHE PATH "Installation path for tools and applications.") + SET(NL_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools and applications.") ELSE() SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") ENDIF() @@ -1068,7 +1091,7 @@ MACRO(NL_SETUP_PREFIX_PATHS) IF(LIBRARY_ARCHITECTURE) SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") ELSE() - SET(NL_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + SET(NL_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.") ENDIF() ENDIF() NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX) @@ -1079,7 +1102,11 @@ MACRO(NL_SETUP_PREFIX_PATHS) IF(LIBRARY_ARCHITECTURE) SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.") ELSE() - SET(NL_DRIVER_PREFIX "lib/nel" CACHE PATH "Installation path for drivers.") + IF(WIN32) + SET(NL_DRIVER_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for drivers.") + ELSE() + SET(NL_DRIVER_PREFIX "lib${LIB_SUFFIX}/nel" CACHE PATH "Installation path for drivers.") + ENDIF() ENDIF() ELSE() SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.") @@ -1112,7 +1139,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/sbin path. IF(NOT RYZOM_SBIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(RYZOM_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.") + SET(RYZOM_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.") ELSE() SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") ENDIF() @@ -1122,7 +1149,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS) ## Allow override of install_prefix/bin path. IF(NOT RYZOM_BIN_PREFIX) IF(WITH_UNIX_STRUCTURE) - SET(RYZOM_BIN_PREFIX "bin" CACHE PATH "Installation path for tools.") + SET(RYZOM_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools.") ELSE() SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") ENDIF() @@ -1134,7 +1161,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS) IF(LIBRARY_ARCHITECTURE) SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.") ELSE() - SET(RYZOM_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.") + SET(RYZOM_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.") ENDIF() ENDIF() NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX) @@ -1210,4 +1237,4 @@ MACRO(SETUP_EXTERNAL) FIND_PACKAGE(MSVC REQUIRED) FIND_PACKAGE(WindowsSDK REQUIRED) ENDIF() -ENDMACRO(SETUP_EXTERNAL) +ENDMACRO() diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 52bda8576..85140b3da 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -224,7 +224,7 @@ public: // @{ // first param is the associated window. // Must be a HWND for Windows (WIN32). - virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show = true, bool resizeable = true) throw(EBadDisplay) = 0; + virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show = true, bool resizeable = true) = 0; // Must be called after a setDisplay that initialize the mode virtual bool setMode(const GfxMode &mode) = 0; virtual bool getModes(std::vector &modes) = 0; diff --git a/code/nel/include/nel/3d/dru.h b/code/nel/include/nel/3d/dru.h index fda543ecd..c23d41382 100644 --- a/code/nel/include/nel/3d/dru.h +++ b/code/nel/include/nel/3d/dru.h @@ -134,14 +134,14 @@ class CDRU public: /// Portable Function which create a GL Driver (using gl dll...). - static IDriver *createGlDriver() throw(EDru); + static IDriver *createGlDriver(); /// Portable Function which create a GL ES Driver (using gl dll...). - static IDriver *createGlEsDriver() throw(EDru); + static IDriver *createGlEsDriver(); #ifdef NL_OS_WINDOWS /// Windows Function which create a Direct3d Driver. - static IDriver *createD3DDriver() throw(EDru); + static IDriver *createD3DDriver(); #endif // NL_OS_WINDOWS /// \name 2D render. diff --git a/code/nel/include/nel/3d/landscape.h b/code/nel/include/nel/3d/landscape.h index aa432f88b..a7383963d 100644 --- a/code/nel/include/nel/3d/landscape.h +++ b/code/nel/include/nel/3d/landscape.h @@ -168,9 +168,9 @@ public: void clear(); /// Verify the binding of patchs of all zones. throw EBadBind if error. - void checkBinds() throw(EBadBind); + void checkBinds(); /// Verify the binding of patchs of one zone. throw EBadBind if error. nop if zone not loaded. - void checkBinds(uint16 zoneId) throw(EBadBind); + void checkBinds(uint16 zoneId); /** * Build tileBank. Call this after loading the near and far tile banks. diff --git a/code/nel/include/nel/3d/nelu.h b/code/nel/include/nel/3d/nelu.h index fb30a5012..b64e83672 100644 --- a/code/nel/include/nel/3d/nelu.h +++ b/code/nel/include/nel/3d/nelu.h @@ -64,7 +64,7 @@ public: * * You can access the driver with CNELU::Driver. */ - static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false, bool direct3d=false) throw(EDru); + static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false, bool direct3d=false); /** Init all that we need for a Scene. * - register scene basics models, @@ -108,7 +108,7 @@ public: * - initScene(); * - initEventServer(); */ - static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false, bool direct3d = false) throw(EDru); + static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false, bool direct3d = false); /** Delete all: * - releaseEventServer(); diff --git a/code/nel/include/nel/3d/text_context.h b/code/nel/include/nel/3d/text_context.h index 156ea9f79..a95916da4 100644 --- a/code/nel/include/nel/3d/text_context.h +++ b/code/nel/include/nel/3d/text_context.h @@ -88,7 +88,7 @@ public: void setShadeOutline (bool b) { _ShadeOutline = b; } - void setShadeExtent (float shext) { _ShadeExtent = shext; } + void setShadeExtent (float x, float y) { _ShadeExtentX = x; _ShadeExtentY = y; } /// The alpha of the shade is multiplied at each draw with the alpha of the color. Default: (0,0,0,255) void setShadeColor (NLMISC::CRGBA color) { _ShadeColor = color; } @@ -157,19 +157,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2D(*_Driver, x+rext, z-rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-rext, z-rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-rext, z+rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x+rext, z+rext, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x+_ShadeExtent, z, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x-_ShadeExtent, z, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); - rCS.render2D(*_Driver, x, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2D(*_Driver, x+rextX, z-rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-rextX, z-rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-rextX, z+rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+rextX, z+rextY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+_ShadeExtentX, z, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x-_ShadeExtentX, z, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } else { - rCS.render2D(*_Driver, x+_ShadeExtent, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ); + rCS.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } rCS.Color= bkup; } @@ -190,19 +191,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2DClip(*_Driver, rdrBuffer, x+rext, z-rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-rext, z-rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-rext, z+rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x+rext, z+rext, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtent, z, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x, z+_ShadeExtent, xmin, ymin, xmax, ymax); - rCS.render2DClip(*_Driver, rdrBuffer, x, z-_ShadeExtent, xmin, ymin, xmax, ymax); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2DClip(*_Driver, rdrBuffer, x+rextX, z-rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-rextX, z-rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-rextX, z+rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+rextX, z+rextY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtentX, z, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtentX, z, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x, z+_ShadeExtentY, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x, z-_ShadeExtentY, xmin, ymin, xmax, ymax); } else { - rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z-_ShadeExtent, xmin, ymin, xmax, ymax); + rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtentX, z-_ShadeExtentY, xmin, ymin, xmax, ymax); } rCS.Color= bkup; } @@ -223,19 +225,20 @@ public: rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rext, y-rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rext, y-rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rext, y+rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rext, y+rext, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtent, y, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y+_ShadeExtent, depth, xmin, ymin, xmax, ymax); - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rextX, y-rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rextX, y-rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rextX, y+rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rextX, y+rextY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtentX, y, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtentX, y, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y+_ShadeExtentY, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y-_ShadeExtentY, depth, xmin, ymin, xmax, ymax); } else { - rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax); + rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtentX, y-_ShadeExtentY, depth, xmin, ymin, xmax, ymax); } rCS.Color= bkup; } @@ -258,19 +261,20 @@ public: _TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - _TempString.render2D(*_Driver,x+rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + _TempString.render2D(*_Driver,x+rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z+_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z-_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); } else { - _TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } _TempString.Color = bkup; } @@ -297,19 +301,20 @@ public: _TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8); if (_ShadeOutline) { - float rext = _ShadeExtent * 0.7071f; - _TempString.render2D(*_Driver,x+rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z-rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+rext,z+rext,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x+_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x-_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); - _TempString.render2D(*_Driver,x,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + float rextX = _ShadeExtentX * 0.7071f; + float rextY = _ShadeExtentY * 0.7071f; + _TempString.render2D(*_Driver,x+rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x+_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x-_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z+_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver,x,z-_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ); } else { - _TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ); + _TempString.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ); } _TempString.Color = bkup; } @@ -412,7 +417,8 @@ private: bool _ShadeOutline; /// shade's extent (shadow size) - float _ShadeExtent; + float _ShadeExtentX; + float _ShadeExtentY; /// Shade color (default is black) NLMISC::CRGBA _ShadeColor; diff --git a/code/nel/include/nel/3d/text_context_user.h b/code/nel/include/nel/3d/text_context_user.h index b05238dbf..15e93c3f2 100644 --- a/code/nel/include/nel/3d/text_context_user.h +++ b/code/nel/include/nel/3d/text_context_user.h @@ -80,7 +80,7 @@ public: bool getShaded() const; void setShadeOutline(bool b); bool getShadeOutline() const; - void setShadeExtent(float shext) ; + void setShadeExtent(float x, float y); void setShadeColor (NLMISC::CRGBA sc); NLMISC::CRGBA getShadeColor () const; void setKeep800x600Ratio(bool keep); diff --git a/code/nel/include/nel/3d/u_text_context.h b/code/nel/include/nel/3d/u_text_context.h index 0aa9ea2f9..4c1dfea47 100644 --- a/code/nel/include/nel/3d/u_text_context.h +++ b/code/nel/include/nel/3d/u_text_context.h @@ -205,7 +205,7 @@ public: * set the shadow's size * \param the shade extent */ - virtual void setShadeExtent (float shext) = 0; + virtual void setShadeExtent (float x, float y) = 0; /** * set the shadow's color * The alpha of the shade is multiplied at each draw with the alpha of the color. Default: (0,0,0,255) diff --git a/code/nel/include/nel/gui/curl_certificates.h b/code/nel/include/nel/gui/curl_certificates.h index 021b13360..9d5ad4855 100644 --- a/code/nel/include/nel/gui/curl_certificates.h +++ b/code/nel/include/nel/gui/curl_certificates.h @@ -17,19 +17,22 @@ #ifndef CL_CURL_CERTIFICATES_HTML_H #define CL_CURL_CERTIFICATES_HTML_H -#include - #include "nel/misc/types_nl.h" +// forward declaration to avoid curl.h inclusion everywhere +typedef void CURL; + namespace NLGUI { -#if defined(NL_OS_WINDOWS) - class CCurlCertificates { + class CCurlCertificates + { public: - // cURL SSL certificate loading - static CURLcode sslCtxFunction(CURL *curl, void *sslctx, void *parm); + // allow to use custom PEM certificates + static void addCertificateFile(const std::string &cert); + + // set all CURL options to use custom SSL context function + static void useCertificates(CURL *curl); }; -#endif // NL_OS_WINDOWS } // namespace #endif diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index 8d3478579..9c48149bf 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -17,8 +17,6 @@ #ifndef CL_GROUP_HTML_H #define CL_GROUP_HTML_H -#include - #include "nel/misc/types_nl.h" #include "nel/gui/interface_group.h" #include "nel/gui/group_scrolltext.h" @@ -27,6 +25,9 @@ #include "nel/gui/group_table.h" #include "nel/gui/libwww_types.h" +// forward declaration +typedef void CURLM; + typedef std::map TStyle; namespace NLGUI @@ -73,11 +74,26 @@ namespace NLGUI }; static SWebOptions options; - + + // text-shadow + struct STextShadow + { + public: + STextShadow(bool enabled = false, bool outline = false, sint32 x=1, sint32 y=1, NLMISC::CRGBA color=NLMISC::CRGBA::Black) + : Enabled(enabled), Outline(outline), X(x), Y(y), Color(color) + { } + + bool Enabled; + bool Outline; + sint32 X; + sint32 Y; + NLMISC::CRGBA Color; + }; + class CStyleParams { public: - CStyleParams () : FontFamily(""), TextColor(255,255,255,255) + CStyleParams () : FontFamily(""), TextColor(255,255,255,255), TextShadow() { FontSize=10; FontWeight=400; @@ -95,6 +111,7 @@ namespace NLGUI bool FontOblique; std::string FontFamily; NLMISC::CRGBA TextColor; + STextShadow TextShadow; bool GlobalColor; bool Underlined; bool StrikeThrough; @@ -104,6 +121,10 @@ namespace NLGUI sint32 MaxHeight; }; + // ImageDownload system + enum TDataType {ImgType= 0, BnpType}; + enum TImageType {NormalImage=0, OverImage}; + // Constructor CGroupHTML(const TCtorParam ¶m); ~CGroupHTML(); @@ -149,6 +170,10 @@ namespace NLGUI // End of the paragraph void endParagraph(); + + // add image download (used by view_bitmap.cpp to load web images) + void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage); + std::string localImageName(const std::string &url); // Timeout void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);} @@ -495,78 +520,32 @@ namespace NLGUI // IL mode bool _LI; - // Current text color - std::vector _TextColor; - inline const NLMISC::CRGBA &getTextColor() const + // Current active style + CStyleParams _Style; + // Default style + CStyleParams _StyleDefault; + // Nested style stack + std::vector _StyleParams; + inline void pushStyle() { - if (_TextColor.empty()) - return TextColor; - return _TextColor.back(); + _StyleParams.push_back(_Style); + } + inline void popStyle() + { + if (_StyleParams.empty()) + _Style = _StyleDefault; + else + { + _Style = _StyleParams.back(); + _StyleParams.pop_back(); + } } - // Current global color flag - std::vector _GlobalColor; - inline bool getGlobalColor() const - { - if (_GlobalColor.empty()) - return false; - 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 - { - if (_FontSize.empty()) - return TextFontSize; - return _FontSize.back(); - } inline uint getFontSizeSmaller() const { - if (getFontSize() < 5) + if (_Style.FontSize < 5) return 3; - return getFontSize()-2; - } - - std::vector _FontWeight; - inline uint getFontWeight() const - { - if (_FontWeight.empty()) - return 400; - return _FontWeight.back(); - } - - std::vector _FontOblique; - inline bool getFontOblique() const - { - if (_FontOblique.empty()) - return false; - return _FontOblique.back(); - } - - std::vector _FontUnderlined; - inline bool getFontUnderlined() const - { - if (_FontUnderlined.empty()) - return false; - return _FontUnderlined.back(); - } - - std::vector _FontStrikeThrough; - inline bool getFontStrikeThrough() const - { - if (_FontStrikeThrough.empty()) - return false; - return _FontStrikeThrough.back(); + return _Style.FontSize-2; } // Current link @@ -631,6 +610,14 @@ namespace NLGUI return _TR.back(); } + std::vector _TextShadow; + inline STextShadow getTextShadow() const + { + if (_TextShadow.empty()) + return STextShadow(); + return _TextShadow.back(); + } + // Forms class CForm { @@ -720,6 +707,8 @@ namespace NLGUI return 0; return _Indent.back(); } + + // Current node is a title bool _Title; @@ -809,10 +798,6 @@ namespace NLGUI private: // decode all HTML entities static ucstring decodeHTMLEntities(const ucstring &str); - - // ImageDownload system - enum TDataType {ImgType= 0, BnpType}; - enum TImageType {NormalImage=0, OverImage}; struct CDataImageDownload { @@ -855,8 +840,6 @@ namespace NLGUI void initImageDownload(); void checkImageDownload(); - void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage); - std::string localImageName(const std::string &url); std::string getAbsoluteUrl(const std::string &url); bool isTrustedDomain(const std::string &domain); @@ -874,11 +857,6 @@ namespace NLGUI // HtmlType download finished void htmlDownloadFinished(const std::string &content, const std::string &type, long code); - - // cURL transfer callbacks - static size_t curlHeaderCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData); - static size_t curlDataCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData); - static size_t curlProgressCallback(void *pCCurlWWWData, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow); }; // adapter group that store y offset for inputs inside an html form diff --git a/code/nel/include/nel/gui/http_hsts.h b/code/nel/include/nel/gui/http_hsts.h index 2693461cd..28f1b5f5b 100644 --- a/code/nel/include/nel/gui/http_hsts.h +++ b/code/nel/include/nel/gui/http_hsts.h @@ -42,7 +42,7 @@ namespace NLGUI class CStrictTransportSecurity { public: - typedef std::map THSTSObject; + typedef std::map THSTSObjectMap; static CStrictTransportSecurity* getInstance(); static void release(); @@ -66,7 +66,7 @@ namespace NLGUI ~CStrictTransportSecurity(); std::string _Filename; - THSTSObject _Domains; + THSTSObjectMap _Domains; }; } diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index cd82417d6..1a360bbc6 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -182,6 +182,9 @@ namespace NLGUI void setMarginLeft(sint32 m) { _MarginLeft = m; } sint32 getMarginLeft() const { return _MarginLeft; } + // Return inner width for child elements + virtual sint32 getInnerWidth() const; + /** * Get the max width used by the window. * diff --git a/code/nel/include/nel/gui/interface_group.h b/code/nel/include/nel/gui/interface_group.h index b9efd3357..01f2b9701 100644 --- a/code/nel/include/nel/gui/interface_group.h +++ b/code/nel/include/nel/gui/interface_group.h @@ -164,6 +164,7 @@ namespace NLGUI sint32 getMaxH () const { return _MaxH; } sint32 getMaxWReal () const { return _Active ? _MaxWReal : 0; } sint32 getMaxHReal () const { return _Active ? _MaxHReal : 0; } + sint32 getInnerWidth () const; sint32 getOfsX () const { return _OffsetX; } sint32 getOfsY () const { return _OffsetY; } bool getResizeFromChildW() const { return _ResizeFromChildW; } diff --git a/code/nel/include/nel/gui/libwww.h b/code/nel/include/nel/gui/libwww.h index 0825779f2..64258608e 100644 --- a/code/nel/include/nel/gui/libwww.h +++ b/code/nel/include/nel/gui/libwww.h @@ -20,11 +20,12 @@ #ifndef CL_LIB_WWW_H #define CL_LIB_WWW_H -#include - #include "nel/misc/rgba.h" #include "nel/gui/libwww_types.h" +// forward declaration to avoid curl.h inclusion everywhere +typedef void CURL; + namespace NLGUI { class CCtrlBaseButton; @@ -102,6 +103,7 @@ namespace NLGUI HTML_ATTR(TR,L_MARGIN), HTML_ATTR(TR,NOWRAP), HTML_ATTR(TR,VALIGN), + HTML_ATTR(TR,STYLE), }; enum diff --git a/code/nel/include/nel/gui/lua_ihm.h b/code/nel/include/nel/gui/lua_ihm.h index 974ece6f7..e45e1125f 100644 --- a/code/nel/include/nel/gui/lua_ihm.h +++ b/code/nel/include/nel/gui/lua_ihm.h @@ -118,7 +118,7 @@ namespace NLGUI /** read/write between values on a lua stack & a property exported from a 'CReflectable' derived object * (throws on error) */ - static void luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException); + static void luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property); // push a reflected property on the stack // NB : no check is done that 'property' is part of the class info of 'reflectedObject' diff --git a/code/nel/include/nel/gui/lua_object.h b/code/nel/include/nel/gui/lua_object.h index 1d3b0d64c..88c011347 100644 --- a/code/nel/include/nel/gui/lua_object.h +++ b/code/nel/include/nel/gui/lua_object.h @@ -110,7 +110,7 @@ namespace NLGUI /** create a sub table for this object, with a string as a key * This object must be a table or an exception if thrown */ - CLuaObject newTable(const char *tableName) throw(ELuaNotATable); + CLuaObject newTable(const char *tableName); /** Set a value in a table. @@ -118,29 +118,29 @@ namespace NLGUI * NB : value should came from the same lua environment * \TODO other type of keys */ - void setValue(const char *key, const CLuaObject &value) throw(ELuaNotATable); - void setValue(const std::string &key, const CLuaObject &value) throw(ELuaNotATable) { setValue(key.c_str(), value); } - void setValue(const char *key, const std::string &value) throw(ELuaNotATable); - void setValue(const char *key, const char *value) throw(ELuaNotATable); - void setValue(const char *key, bool value) throw(ELuaNotATable); - void setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable); - void setValue(const char *key, double value) throw(ELuaNotATable); - void setValue(const char *key, uint32 value) throw(ELuaNotATable); - void setValue(const char *key, sint32 value) throw(ELuaNotATable); - void setValue(const char *key, sint64 value) throw(ELuaNotATable); - void setValue(const std::string &key, const std::string &value) throw(ELuaNotATable) { setValue(key.c_str(), value); } - void setNil(const char *key) throw(ELuaNotATable); - void setNil(const std::string &key) throw(ELuaNotATable) { setNil(key.c_str()); } + void setValue(const char *key, const CLuaObject &value); + void setValue(const std::string &key, const CLuaObject &value) { setValue(key.c_str(), value); } + void setValue(const char *key, const std::string &value); + void setValue(const char *key, const char *value); + void setValue(const char *key, bool value); + void setValue(const char *key, TLuaWrappedFunction value); + void setValue(const char *key, double value); + void setValue(const char *key, uint32 value); + void setValue(const char *key, sint32 value); + void setValue(const char *key, sint64 value); + void setValue(const std::string &key, const std::string &value) { setValue(key.c_str(), value); } + void setNil(const char *key); + void setNil(const std::string &key) { setNil(key.c_str()); } /** Erase a value in a table by its key. * If this object is not a table then an exception is thrown. * \TODO other type of keys */ - void eraseValue(const char *key) throw(ELuaNotATable); - void eraseValue(const std::string &key) throw(ELuaNotATable) { eraseValue(key.c_str()); } + void eraseValue(const char *key); + void eraseValue(const std::string &key) { eraseValue(key.c_str()); } // test is this object is enumerable bool isEnumerable() const; // Enumeration of a table. If the object is not a table, an exception is thrown. - CLuaEnumeration enumerate() throw(ELuaNotATable); + CLuaEnumeration enumerate(); // retrieve metatable of an object (or nil if object has no metatable) CLuaObject getMetaTable() const; // set metatable for this object @@ -155,7 +155,7 @@ namespace NLGUI CLuaObject operator[](const std::string &key) const { return operator[](key.c_str()); } /** Checked access to a sub element of a table. An exception is thrown is the element is not a table. */ - CLuaObject at(const char *key) const throw (ELuaNotATable); + CLuaObject at(const char *key) const; CLuaObject at(const std::string &key) const { return at(key.c_str()); } // Test is that table has the given key. The object must be a table or an exception is thrown diff --git a/code/nel/include/nel/gui/view_text.h b/code/nel/include/nel/gui/view_text.h index 8b8e1a7cf..cf53b5207 100644 --- a/code/nel/include/nel/gui/view_text.h +++ b/code/nel/include/nel/gui/view_text.h @@ -88,6 +88,7 @@ namespace NLGUI void setShadow (bool bShadow); void setShadowOutline (bool bShadowOutline); void setShadowColor (const NLMISC::CRGBA &color); + void setShadowOffset (sint x, sint y); void setLineMaxW (sint nMaxW, bool invalidate=true); void setMultiLine (bool bMultiLine); void setMultiLineSpace (sint nMultiLineSpace); @@ -112,6 +113,7 @@ namespace NLGUI bool getShadow() { return _Shadow; } bool getShadowOutline() { return _ShadowOutline; } NLMISC::CRGBA getShadowColor() { return _ShadowColor; } + void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; } sint getLineMaxW() const { return _LineMaxW; } bool getMultiLine() const { return _MultiLine; } sint getMultiLineSpace() const { return _MultiLineSpace; } @@ -247,6 +249,8 @@ namespace NLGUI /// the shadow mode bool _Shadow; bool _ShadowOutline; + sint32 _ShadowX; + sint32 _ShadowY; /// the case mode TCaseMode _CaseMode; /// the text shadow color diff --git a/code/nel/include/nel/misc/CMakeLists.txt b/code/nel/include/nel/misc/CMakeLists.txt index 4b77b813f..85d8914f5 100644 --- a/code/nel/include/nel/misc/CMakeLists.txt +++ b/code/nel/include/nel/misc/CMakeLists.txt @@ -1,3 +1,7 @@ +CONVERT_VERSION_NUMBER(NL_VERSION_NUM 100 ${NL_VERSION_MAJOR} ${NL_VERSION_MINOR} ${NL_VERSION_PATCH}) + +CONFIGURE_FILE(version_nl.cmake ${CMAKE_BINARY_DIR}/version_nl.h) + FILE(GLOB HEADERS *.h) -INSTALL(FILES ${HEADERS} DESTINATION include/nel/misc COMPONENT headers) +INSTALL(FILES ${HEADERS} ${CMAKE_BINARY_DIR}/version_nl.h DESTINATION include/nel/misc COMPONENT headers) diff --git a/code/nel/include/nel/misc/class_registry.h b/code/nel/include/nel/misc/class_registry.h index 5c1fe8cd6..98139f5dc 100644 --- a/code/nel/include/nel/misc/class_registry.h +++ b/code/nel/include/nel/misc/class_registry.h @@ -86,10 +86,10 @@ public: static void release(); /// Register your class for future Instanciation. - static void registerClass(const std::string &className, IClassable* (*creator)(), const std::string &typeidCheck) throw(ERegistry); + static void registerClass(const std::string &className, IClassable* (*creator)(), const std::string &typeidCheck); /// Create an object from his class name. - static IClassable *create(const std::string &className) throw(ERegistry); + static IClassable *create(const std::string &className); /// check if the object has been correctly registered. Must be used for debug only, and Must compile with RTTI. static bool checkObject(IClassable* obj); diff --git a/code/nel/include/nel/misc/file.h b/code/nel/include/nel/misc/file.h index 17154e6be..78dba95c6 100644 --- a/code/nel/include/nel/misc/file.h +++ b/code/nel/include/nel/misc/file.h @@ -108,9 +108,9 @@ public: // Advanced Usage. /// flush the file. void flush(); /// Seek the file - bool seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStream); + bool seek (sint32 offset, IStream::TSeekOrigin origin) const; /// Get the location of the file pointer - sint32 getPos () const throw(EStream); + sint32 getPos () const; // Imp the Name of the stream as the name of the file. virtual std::string getStreamName() const; @@ -125,7 +125,7 @@ public: // Advanced Usage. // return true if there's nothing more to read (same as ifstream) bool eof (); - virtual void serialBuffer(uint8 *buf, uint len)throw(EReadError); + virtual void serialBuffer(uint8 *buf, uint len); /// \name Statistics @@ -148,7 +148,7 @@ public: // Advanced Usage. static void clearDump (); protected: - virtual void serialBit(bool &bit) throw(EReadError); + virtual void serialBit(bool &bit); virtual uint getDbgStreamSize() const; @@ -223,20 +223,20 @@ public: // Advanced Usage. /// flush the file. void flush(); /// Seek the file - bool seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStream); + bool seek (sint32 offset, IStream::TSeekOrigin origin) const; /// Get the location of the file pointer - sint32 getPos () const throw(EStream); + sint32 getPos () const; // Imp the Name of the stream as the name of the file. virtual std::string getStreamName() const; // very useful to serialize string in text mode (without the size) - virtual void serialBuffer(uint8 *buf, uint len) throw(EWriteError); + virtual void serialBuffer(uint8 *buf, uint len); protected: /// Internal close. void internalClose(bool success); - virtual void serialBit(bool &bit) throw(EWriteError); + virtual void serialBit(bool &bit); private: FILE *_F; diff --git a/code/nel/include/nel/misc/mem_stream.h b/code/nel/include/nel/misc/mem_stream.h index f614cc040..4222e1672 100644 --- a/code/nel/include/nel/misc/mem_stream.h +++ b/code/nel/include/nel/misc/mem_stream.h @@ -197,7 +197,7 @@ public: * \return true if seek sucessfull. * \see ESeekNotSupported SeekOrigin getPos */ - virtual bool seek (sint32 offset, TSeekOrigin origin) const throw(EStream); + virtual bool seek (sint32 offset, TSeekOrigin origin) const; /** * Get the location of the stream pointer. @@ -210,7 +210,7 @@ public: * \return the new offset regarding from the origin. * \see ESeekNotSupported SeekOrigin seek */ - virtual sint32 getPos () const throw(EStream) + virtual sint32 getPos () const { return sint32(_Buffer.Pos); } diff --git a/code/nel/include/nel/misc/smart_ptr.h b/code/nel/include/nel/misc/smart_ptr.h index 2273cebeb..b0fc1c301 100644 --- a/code/nel/include/nel/misc/smart_ptr.h +++ b/code/nel/include/nel/misc/smart_ptr.h @@ -226,7 +226,7 @@ public: std::string toString() { if(Ptr) return toString(*Ptr); else return ""; } // serial using serialPtr - void serialPtr(NLMISC::IStream &f) throw(NLMISC::EStream ) + void serialPtr(NLMISC::IStream &f) { T* obj= NULL; if(f.isReading()) @@ -242,7 +242,7 @@ public: } } // serial using serialPloyPtr - void serialPolyPtr(NLMISC::IStream &f) throw(NLMISC::EStream ) + void serialPolyPtr(NLMISC::IStream &f) { T* obj= NULL; if(f.isReading()) @@ -337,7 +337,7 @@ public: void kill(); // serial using serialPloyPtr - void serialPolyPtr(NLMISC::IStream &f) throw(NLMISC::EStream ) + void serialPolyPtr(NLMISC::IStream &f) { T* obj= NULL; if(f.isReading()) diff --git a/code/nel/include/nel/misc/string_mapper.h b/code/nel/include/nel/misc/string_mapper.h index a20489f1c..aeaccf959 100644 --- a/code/nel/include/nel/misc/string_mapper.h +++ b/code/nel/include/nel/misc/string_mapper.h @@ -177,10 +177,10 @@ public: uint32 getCount() { return _IdCounter; } // helper serialize a string id as a string - void serial(NLMISC::IStream &f, TSStringId &strId) throw(EStream); + void serial(NLMISC::IStream &f, TSStringId &strId); // helper serialize a string id vector - void serial(NLMISC::IStream &f, std::vector &strIdVect) throw(EStream); + void serial(NLMISC::IStream &f, std::vector &strIdVect); }; diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 71702bce5..6431701fe 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -79,6 +79,9 @@ # elif _MSC_VER >= 1600 # define NL_COMP_VC10 # define NL_COMP_VC_VERSION 100 +# ifdef _HAS_CPP0X +# undef _HAS_CPP0X // VC++ 2010 doesn't implement C++11 stuff we need +# endif # elif _MSC_VER >= 1500 # define NL_COMP_VC9 # define NL_COMP_VC_VERSION 90 @@ -409,8 +412,16 @@ typedef unsigned int uint; // at least 32bits (depend of processor) #define NL_DEFAULT_MEMORY_ALIGNMENT 16 #define NL_ALIGN_SSE2 NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT) -#ifndef NL_CPU_X86_64 +#ifdef NL_CPU_X86_64 // on x86_64, new and delete are already aligned on 16 bytes +#elif (defined(NL_COMP_VC) && defined(NL_DEBUG)) +// don't use aligned memory if debugging with VC++ in 32 bits +#else +// use aligned memory in all other cases +#define NL_USE_ALIGNED_MEMORY_OPERATORS +#endif + +#ifdef NL_USE_ALIGNED_MEMORY_OPERATORS #ifdef NL_NO_EXCEPTION_SPECS extern void *operator new(size_t size); @@ -422,9 +433,9 @@ extern void *operator new(size_t size) throw(std::bad_alloc); extern void *operator new[](size_t size) throw(std::bad_alloc); extern void operator delete(void *p) throw(); extern void operator delete[](void *p) throw(); -#endif +#endif /* NL_NO_EXCEPTION_SPECS */ -#endif +#endif /* NL_USE_ALIGNED_MEMORY_OPERATORS */ #else /* NL_HAS_SSE2 */ diff --git a/code/nel/include/nel/misc/version_nl.cmake b/code/nel/include/nel/misc/version_nl.cmake new file mode 100644 index 000000000..2e650486e --- /dev/null +++ b/code/nel/include/nel/misc/version_nl.cmake @@ -0,0 +1,14 @@ +#ifndef NL_VERSION_H +#define NL_VERSION_H + +#define NL_VERSION "${NL_VERSION}" +#define NL_VERSION_MAJOR ${NL_VERSION_MAJOR} +#define NL_VERSION_MINOR ${NL_VERSION_MINOR} +#define NL_VERSION_PATCH ${NL_VERSION_PATCH} +#define NL_VERSION_NUM ${NL_VERSION_NUM} + +#define NL_REVISION ${REVISION} + +#define NL_BUILD_DATE "${BUILD_DATE}" + +#endif diff --git a/code/nel/include/nel/net/message.h b/code/nel/include/nel/net/message.h index e96cb50d3..f1c571d44 100644 --- a/code/nel/include/nel/net/message.h +++ b/code/nel/include/nel/net/message.h @@ -146,7 +146,7 @@ public: return _LengthR; } - virtual sint32 getPos () const throw(NLMISC::EStream) + virtual sint32 getPos() const { // return (_BufPos - _Buffer.getPtr()) - _SubMessagePosR; return _Buffer.Pos - _SubMessagePosR; diff --git a/code/nel/include/nel/net/module.h b/code/nel/include/nel/net/module.h index 4493dd966..790a49199 100644 --- a/code/nel/include/nel/net/module.h +++ b/code/nel/include/nel/net/module.h @@ -213,18 +213,14 @@ namespace NLNET * Note that a module can be plugged in several socket at the same * time, but not twice in the same socket. */ - virtual void plugModule(IModuleSocket *moduleSocket) - throw (EModuleAlreadyPluggedHere) - =0; + virtual void plugModule(IModuleSocket *moduleSocket) =0; /** Unplug this module from the specified socket. * Note that a module can be plugged in several socket at the same * time, but not twice in the same socket. * Throw an exception if the socket is not currently plug into * the specified socket. */ - virtual void unplugModule(IModuleSocket *moduleSocket) - throw (EModuleNotPluggedHere) - =0; + virtual void unplugModule(IModuleSocket *moduleSocket) =0; /** Fill resultList vector with the list of socket into * witch this module is currently plugged. * This method don't clear the result vector before filling it. @@ -265,9 +261,7 @@ namespace NLNET * The call is blocking until receptions of the operation * result message (or detection of the dest module module is down) */ - virtual void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) - throw (EInvokeFailed) - =0; + virtual void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) =0; //@} @@ -448,9 +442,7 @@ namespace NLNET * This method do the job of finding a valid socket to effectively send * the message. */ - virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotReachable) - =0; + virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message) =0; /** Return the first item of the security item list * If no security data are available, the method @@ -779,10 +771,10 @@ namespace NLNET // Init base module, init module name bool initModule(const TParsedCommandLine &initInfo); - void plugModule(IModuleSocket *moduleSocket) throw (EModuleAlreadyPluggedHere); - void unplugModule(IModuleSocket *moduleSocket) throw (EModuleNotPluggedHere); + void plugModule(IModuleSocket *moduleSocket); + void unplugModule(IModuleSocket *moduleSocket); void getPluggedSocketList(std::vector &resultList); - void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) throw (EInvokeFailed); + void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg); void _onModuleUp(IModuleProxy *removedProxy); void _onModuleDown(IModuleProxy *removedProxy); @@ -879,8 +871,7 @@ namespace NLNET /** Send a message to the module. */ - virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotReachable); + virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message); virtual const TSecurityData *getFirstSecurityData() const { diff --git a/code/nel/include/nel/net/module_gateway.h b/code/nel/include/nel/net/module_gateway.h index a097f8de0..40da736a3 100644 --- a/code/nel/include/nel/net/module_gateway.h +++ b/code/nel/include/nel/net/module_gateway.h @@ -171,8 +171,7 @@ namespace NLNET virtual void setTransportPeerInvisible(const std::string &transportInstanceName, bool peerInvisible) =0; /// Activate/stop firewalling mode on a transport - virtual void setTransportFirewallMode(const std::string &transportInstanceName, bool firewalled) - throw (EGatewayFirewallBreak) =0; + virtual void setTransportFirewallMode(const std::string &transportInstanceName, bool firewalled) =0; /// Send a command to a transport virtual void transportCommand(const TParsedCommandLine &commandLine) =0; @@ -233,9 +232,7 @@ namespace NLNET /** Disclose module information to a connected gateway. * This can also be this gateway itself. */ - virtual void discloseModule(IModuleProxy *moduleProxy) - throw (EGatewayNotConnected) - =0; + virtual void discloseModule(IModuleProxy *moduleProxy) =0; /** Retrieve the proxy for a locally plugged module. * Each local module plugged in a gateway has an associated @@ -346,9 +343,9 @@ namespace NLNET virtual const std::string &getClassName() const =0; /// The gateway send a command message to the transport - virtual void onCommand(const CMessage &command) throw (EInvalidCommand) = 0; + virtual void onCommand(const CMessage &command) = 0; /// The gateway send a textual command to the transport - virtual bool onCommand(const TParsedCommandLine &command) throw (EInvalidCommand) = 0; + virtual bool onCommand(const TParsedCommandLine &command) = 0; /// The gateway update the transport regularly virtual void update() =0; diff --git a/code/nel/include/nel/net/module_socket.h b/code/nel/include/nel/net/module_socket.h index f4bad56d4..a60836656 100644 --- a/code/nel/include/nel/net/module_socket.h +++ b/code/nel/include/nel/net/module_socket.h @@ -42,15 +42,11 @@ namespace NLNET * If the destination module is not accessible through this socket, * an exception is thrown. */ - virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotPluggedHere) - =0; + virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) =0; /** A plugged module send a message to all the module reachable * with this socket. */ - virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotPluggedHere) - =0; + virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) =0; /** Fill the resultList with the list of module that are * reachable with this socket. @@ -95,21 +91,15 @@ namespace NLNET virtual void _onModulePlugged(const TModulePtr &pluggedModule); virtual void _onModuleUnplugged(const TModulePtr &pluggedModule); - virtual void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotPluggedHere, NLNET::EModuleNotReachable) - =0; + virtual void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) =0; - virtual void _broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotPluggedHere) - =0; + virtual void _broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) =0; - virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotPluggedHere); + virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message); /** A plugged module send a message to all the module reachable * with this socket. */ - virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotPluggedHere); + virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message); }; diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index be7a74722..7a4618683 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -1328,7 +1328,7 @@ 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) { H_AUTO_D3D(CDriver3D_setDisplay); diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index a4d9dbaeb..51c21bbc9 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -849,7 +849,7 @@ public: // Mode initialisation, requests virtual bool init (uintptr_t windowIcon = 0, emptyProc exitFunc = 0); - virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); + virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable); virtual bool release(); virtual bool setMode(const GfxMode& mode); virtual bool getModes(std::vector &modes); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 68e6b0edf..a03077544 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -325,7 +325,7 @@ public: virtual void disableHardwareVertexArrayAGP(); virtual void disableHardwareTextureShader(); - virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); + virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable); virtual bool setMode(const GfxMode& mode); virtual bool getModes(std::vector &modes); virtual bool getCurrentScreenMode(GfxMode &mode); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index a7eb6e62a..3d1803a2a 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -611,7 +611,7 @@ void CDriverGL::setWindowIcon(const std::vector &bitmaps) } // -------------------------------------------------- -bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable) throw(EBadDisplay) +bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable) { H_AUTO_OGL(CDriverGL_setDisplay) diff --git a/code/nel/src/3d/dru.cpp b/code/nel/src/3d/dru.cpp index 15ccbfe01..54248c001 100644 --- a/code/nel/src/3d/dru.cpp +++ b/code/nel/src/3d/dru.cpp @@ -77,7 +77,7 @@ extern IDriver* createGlEsDriverInstance (); #endif // *************************************************************************** -IDriver *CDRU::createGlDriver() throw (EDru) +IDriver *CDRU::createGlDriver() { #ifdef NL_STATIC @@ -131,7 +131,7 @@ IDriver *CDRU::createGlDriver() throw (EDru) } // *************************************************************************** -IDriver *CDRU::createGlEsDriver() throw (EDru) +IDriver *CDRU::createGlEsDriver() { #ifdef NL_STATIC @@ -188,7 +188,7 @@ IDriver *CDRU::createGlEsDriver() throw (EDru) #ifdef NL_OS_WINDOWS -IDriver *CDRU::createD3DDriver() throw (EDru) +IDriver *CDRU::createD3DDriver() { #ifdef NL_STATIC diff --git a/code/nel/src/3d/landscape.cpp b/code/nel/src/3d/landscape.cpp index 4b597fc2d..75e71920a 100644 --- a/code/nel/src/3d/landscape.cpp +++ b/code/nel/src/3d/landscape.cpp @@ -2423,7 +2423,7 @@ void CLandscape::checkZoneBinds(CZone &curZone, EBadBind &bindError) // *************************************************************************** -void CLandscape::checkBinds() throw(EBadBind) +void CLandscape::checkBinds() { EBadBind bindError; @@ -2439,7 +2439,7 @@ void CLandscape::checkBinds() throw(EBadBind) // *************************************************************************** -void CLandscape::checkBinds(uint16 zoneId) throw(EBadBind) +void CLandscape::checkBinds(uint16 zoneId) { EBadBind bindError; diff --git a/code/nel/src/3d/nelu.cpp b/code/nel/src/3d/nelu.cpp index 8cb6e0968..7807a5ef7 100644 --- a/code/nel/src/3d/nelu.cpp +++ b/code/nel/src/3d/nelu.cpp @@ -51,7 +51,7 @@ CEventServer CNELU::EventServer; CEventListenerAsync CNELU::AsyncListener; -bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru) +bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) { // Init debug system // NLMISC::InitDebug(); @@ -183,7 +183,7 @@ void CNELU::releaseDriver() } } -bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru) +bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) { NL3D::registerSerial3d(); if (initDriver(w,h,bpp,windowed,systemWindow,offscreen,direct3d)) diff --git a/code/nel/src/3d/text_context.cpp b/code/nel/src/3d/text_context.cpp index 8cee144ca..5fcc43daa 100644 --- a/code/nel/src/3d/text_context.cpp +++ b/code/nel/src/3d/text_context.cpp @@ -47,7 +47,8 @@ CTextContext::CTextContext() _Shaded = false; _ShadeOutline = false; - _ShadeExtent = 0.001f; + _ShadeExtentX = 0.001f; + _ShadeExtentY = 0.001f; _ShadeColor = NLMISC::CRGBA(0,0,0); _Keep800x600Ratio= true; diff --git a/code/nel/src/3d/text_context_user.cpp b/code/nel/src/3d/text_context_user.cpp index 1834a93ce..ae2cc2417 100644 --- a/code/nel/src/3d/text_context_user.cpp +++ b/code/nel/src/3d/text_context_user.cpp @@ -187,11 +187,11 @@ bool CTextContextUser::getShadeOutline() const return _TextContext.getShadeOutline(); } -void CTextContextUser::setShadeExtent(float shext) +void CTextContextUser::setShadeExtent(float x, float y) { H_AUTO2; - _TextContext.setShadeExtent(shext); + _TextContext.setShadeExtent(x, y); } void CTextContextUser::setShadeColor (NLMISC::CRGBA sc) { diff --git a/code/nel/src/3d/water_height_map.cpp b/code/nel/src/3d/water_height_map.cpp index 5f67ffce3..6fe88a8bc 100644 --- a/code/nel/src/3d/water_height_map.cpp +++ b/code/nel/src/3d/water_height_map.cpp @@ -677,7 +677,7 @@ void CWaterHeightMap::setWaves(float intensity, float period, uint radius, bool void CWaterHeightMap::serial(NLMISC::IStream &f) { f.xmlPushBegin("WaterHeightMap"); - f.xmlSetAttrib ("NAME") ; + f.xmlSetAttrib ("NAME"); f.serial (_Name); f.xmlPushEnd(); (void)f.serialVersion(0); diff --git a/code/nel/src/gui/CMakeLists.txt b/code/nel/src/gui/CMakeLists.txt index 5233b8ceb..cb7bbe23a 100644 --- a/code/nel/src/gui/CMakeLists.txt +++ b/code/nel/src/gui/CMakeLists.txt @@ -6,9 +6,10 @@ SOURCE_GROUP("src" FILES ${SRC}) NL_TARGET_LIB(nelgui ${SRC} ${HEADERS}) -INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${CURL_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) + +TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) -TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES}) NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI") NL_ADD_RUNTIME_FLAGS(nelgui) diff --git a/code/nel/src/gui/ctrl_scroll.cpp b/code/nel/src/gui/ctrl_scroll.cpp index 9c9585fcc..acdaa15f5 100644 --- a/code/nel/src/gui/ctrl_scroll.cpp +++ b/code/nel/src/gui/ctrl_scroll.cpp @@ -885,7 +885,7 @@ namespace NLGUI } if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel && _Vertical) { - moveTrackY (eventDesc.getWheel() * 12); + moveTargetY (-(eventDesc.getWheel() * 12)); return true; } } @@ -1226,6 +1226,12 @@ namespace NLGUI if(hReal <= maxHReal) return; + if (_TargetStepY > 1) + { + sint sign = (0 < dy) - (dy < 0); + dy = sign * max(1, (dy / _TargetStepY)) * _TargetStepY; + } + // compute the new ofsY. sint32 ofsY= _Target->getOfsY(); ofsY+= dy; diff --git a/code/nel/src/gui/curl_certificates.cpp b/code/nel/src/gui/curl_certificates.cpp index 6cf34c8b8..6d1bc86ee 100644 --- a/code/nel/src/gui/curl_certificates.cpp +++ b/code/nel/src/gui/curl_certificates.cpp @@ -21,12 +21,18 @@ #include #include +#include -#if defined(NL_OS_WINDOWS) -#pragma comment(lib, "crypt32.lib") -#pragma comment(lib, "cryptui.lib") +#include + +// for compatibility with older versions +#ifndef CURL_AT_LEAST_VERSION +#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z) +#define CURL_AT_LEAST_VERSION(x,y,z) \ + (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z)) #endif + using namespace std; using namespace NLMISC; @@ -36,36 +42,143 @@ using namespace NLMISC; namespace NLGUI { -#if defined(NL_OS_WINDOWS) - static std::vector x509CertList; - // // x509CertList lifetime manager // - class SX509Certificates { + class SX509Certificates + { public: - SX509Certificates() + struct CertEntry { - curl_version_info_data *data; - data = curl_version_info(CURLVERSION_NOW); - if (!(data && data->features & CURL_VERSION_SSPI)) + X509 *cert; + std::string name; + std::string file; + + bool operator == (const std::string &str) { - addCertificatesFrom("CA"); - addCertificatesFrom("AuthRoot"); - addCertificatesFrom("ROOT"); + return file == str; } + }; + + std::vector CertList; + + bool isUsingOpenSSLBackend; + bool isInitialized; + + SX509Certificates():isUsingOpenSSLBackend(false), isInitialized(false) + { + init(); } ~SX509Certificates() { - for (uint i = 0; i < x509CertList.size(); ++i) + for (uint i = 0; i < CertList.size(); ++i) { - X509_free(x509CertList[i]); + X509_free(CertList[i].cert); } - x509CertList.clear(); + CertList.clear(); } + void init() + { + // init CURL + CURL *curl = curl_easy_init(); + if (!curl) return; + + // get information on CURL + curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); + + bool useOpenSSLBackend = false; + +#if CURL_AT_LEAST_VERSION(7, 34, 0) + // get more information on CURL session + curl_tlssessioninfo *sessionInfo; + + CURLINFO info; + +#if CURL_AT_LEAST_VERSION(7, 48, 0) + info = CURLINFO_TLS_SSL_PTR; +#else + info = CURLINFO_TLS_SESSION; +#endif + + CURLcode res = curl_easy_getinfo(curl, info, &sessionInfo); + + // CURL using OpenSSL backend + if ((res == CURLE_OK) && sessionInfo && sessionInfo->backend == CURLSSLBACKEND_OPENSSL) useOpenSSLBackend = true; +#elif CURL_AT_LEAST_VERSION(7, 12, 3) + // get a list of OpenSSL engines + struct curl_slist *engines; + + CURLcode res = curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines); + + // CURL using OpenSSL backend + // With OpenSSL compiled without any engine, engines will too return NULL + // Fortunately, if OpenSSL isn't compiled with engines means we compiled it ourself and CURL is a recent version + if ((res == CURLE_OK) && engines) + { + // free engines + curl_slist_free_all(engines); + + useOpenSSLBackend = true; + } +#else + // TODO: implement an equivalent, but CURL 7.12 was released in 2004 +#endif + + // only use OpenSSL callback if not using Windows SSPI and using OpenSSL backend + if (useOpenSSLBackend && !(data && data->features & CURL_VERSION_SSPI)) + { +#ifdef NL_OS_WINDOWS + // load native Windows CA Certs + addCertificatesFrom("CA"); + addCertificatesFrom("AuthRoot"); + addCertificatesFrom("ROOT"); +#endif + + isUsingOpenSSLBackend = true; + } + else + { + // if CURL is using SSPI or SChannel under Windows or DarwinSSL under OS X, we'll use native system CA Certs + isUsingOpenSSLBackend = false; + } + + // clean up CURL + curl_easy_cleanup(curl); + + isInitialized = true; + } + + static std::string getCertName(X509 *cert) + { + // NULL certificate + if (!cert) return ""; + + X509_NAME *subject = X509_get_subject_name(cert); + + std::string name; + unsigned char *tmp = NULL; + + // construct a multiline string with name + for (int j = 0, jlen = X509_NAME_entry_count(subject); j < jlen; ++j) + { + X509_NAME_ENTRY *e = X509_NAME_get_entry(subject, j); + ASN1_STRING *d = X509_NAME_ENTRY_get_data(e); + + if (ASN1_STRING_to_UTF8(&tmp, d) > 0) + { + name += NLMISC::toString("%s\n", tmp); + + OPENSSL_free(tmp); + } + } + + return name; + } + +#ifdef NL_OS_WINDOWS void addCertificatesFrom(LPCSTR root) { HCERTSTORE hStore; @@ -78,36 +191,154 @@ namespace NLGUI { x509 = NULL; x509 = d2i_X509(NULL, (const unsigned char **)&pContext->pbCertEncoded, pContext->cbCertEncoded); + if (x509) { - x509CertList.push_back(x509); + CertEntry entry; + entry.cert = x509; + entry.file = root; + entry.name = getCertName(x509); + + CertList.push_back(entry); } } + CertFreeCertificateContext(pContext); CertCloseStore(hStore, 0); } // this is called before debug context is set and log ends up in log.log - //nlinfo("Loaded %d certificates from '%s' certificate store", List.size(), root); + //nlinfo("Loaded %d certificates from '%s' certificate store", (int)CertList.size(), root); + } +#endif + + void addCertificatesFromFile(const std::string &cert) + { + if (!isInitialized) + { + nlwarning("CURL not initialized! Check if there are another errors"); + return; + } + + if (!isUsingOpenSSLBackend) + { + nlinfo("CURL not using OpenSSL backend! Unable to use custom certificates"); + return; + } + else + { + nlinfo("CURL using OpenSSL backend!"); + } + + // this file was already loaded + if (std::find(CertList.begin(), CertList.end(), cert) != CertList.end()) return; + + // look for certificate in search paths + string path = CPath::lookup(cert, false); + + if (path.empty()) + { + nlwarning("Unable to find %s", cert.c_str()); + return; + } + + nlinfo("CURL CA bundle '%s'", path.c_str()); + + CIFile file; + + // open certificate + if (!file.open(path)) + { + nlwarning("Unable to open %s", path.c_str()); + return; + } + + // load certificate content into memory + std::vector buffer(file.getFileSize()); + file.serialBuffer(&buffer[0], file.getFileSize()); + + // get a BIO + BIO *bio = BIO_new_mem_buf(&buffer[0], file.getFileSize()); + + if (bio) + { + // use it to read the PEM formatted certificate from memory into an X509 + // structure that SSL can use + STACK_OF(X509_INFO) *info = PEM_X509_INFO_read_bio(bio, NULL, NULL, NULL); + + if (info) + { + // iterate over all entries from the PEM file, add them to the x509_store one by one + for (sint i = 0; i < sk_X509_INFO_num(info); ++i) + { + X509_INFO *itmp = sk_X509_INFO_value(info, i); + + if (itmp && itmp->x509) + { + CertEntry entry; + entry.cert = X509_dup(itmp->x509); + entry.file = cert; + entry.name = getCertName(entry.cert); + + CertList.push_back(entry); + } + } + + // cleanup + sk_X509_INFO_pop_free(info, X509_INFO_free); + } + else + { + nlwarning("Unable to read PEM info"); + } + + // decrease reference counts + BIO_free(bio); + } + else + { + nlwarning("Unable to allocate BIO buffer for certificates"); + } } }; /// this will be initialized on startup and cleared on exit static SX509Certificates x509CertListManager; - // *************************************************************************** - // static - CURLcode CCurlCertificates::sslCtxFunction(CURL *curl, void *sslctx, void *parm) + // cURL SSL certificate loading + static CURLcode sslCtxFunction(CURL *curl, void *sslctx, void *parm) { - if (x509CertList.size() > 0) + CURLcode res = CURLE_OK; + + if (x509CertListManager.CertList.size() > 0) { SSL_CTX *ctx = (SSL_CTX*)sslctx; X509_STORE *x509store = SSL_CTX_get_cert_store(ctx); if (x509store) { - for (uint i = 0; i < x509CertList.size(); ++i) + char errorBuffer[1024]; + + for (uint i = 0, ilen = x509CertListManager.CertList.size(); i < ilen; ++i) { - X509_STORE_add_cert(x509store, x509CertList[i]); + SX509Certificates::CertEntry entry = x509CertListManager.CertList[i]; + + // add our certificate to this store + if (X509_STORE_add_cert(x509store, entry.cert) == 0) + { + uint errCode = ERR_get_error(); + + // ignore already in hash table errors + if (ERR_GET_LIB(errCode) != ERR_LIB_X509 || ERR_GET_REASON(errCode) != X509_R_CERT_ALREADY_IN_HASH_TABLE) + { + ERR_error_string_n(errCode, errorBuffer, 1024); + nlwarning("Error adding certificate %s: %s", entry.name.c_str(), errorBuffer); + res = CURLE_SSL_CACERT; + } + } + else + { + nldebug("Added certificate %s", entry.name.c_str()); + } } } else @@ -115,9 +346,40 @@ namespace NLGUI nlwarning("SSL_CTX_get_cert_store returned NULL"); } } - return CURLE_OK; + else + { + res = CURLE_SSL_CACERT; + } + + return res; + } + + // *************************************************************************** + // static + void CCurlCertificates::addCertificateFile(const std::string &cert) + { + x509CertListManager.addCertificatesFromFile(cert); + } + + // *************************************************************************** + // static + void CCurlCertificates::useCertificates(CURL *curl) + { + // CURL must be valid, using OpenSSL backend and certificates must be loaded, else return + if (!curl || !x509CertListManager.isInitialized || !x509CertListManager.isUsingOpenSSLBackend || x509CertListManager.CertList.empty()) return; + + curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM"); + + // would allow to provide the CA in memory instead of using CURLOPT_CAINFO, but needs to include and link OpenSSL + if (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, &sslCtxFunction) != CURLE_OK) + { + nlwarning("Unable to support CURLOPT_SSL_CTX_FUNCTION, curl not compiled with OpenSSL ?"); + } + + // set both CURLOPT_CAINFO and CURLOPT_CAPATH to NULL to be sure we won't use default values (these files can be missing and generate errors) + curl_easy_setopt(curl, CURLOPT_CAINFO, NULL); + curl_easy_setopt(curl, CURLOPT_CAPATH, NULL); } -#endif // NL_OS_WINDOWS }// namespace diff --git a/code/nel/src/gui/group_container.cpp b/code/nel/src/gui/group_container.cpp index 1922db221..26a23fd9f 100644 --- a/code/nel/src/gui/group_container.cpp +++ b/code/nel/src/gui/group_container.cpp @@ -2473,7 +2473,7 @@ namespace NLGUI if (_LayerSetup == 0) { - _List->forceSizeW(_W - pLayer->W_M_Open); + _List->forceSizeW(_W - (pLayer->W_M_Open + pLayer->W_R) ); } else { @@ -2748,6 +2748,9 @@ namespace NLGUI if (_Content != NULL) h += _Content->getHReal(); + if (_List != NULL) + h += _List->getHReal(); + h -= _ContentYOffset; } else diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp index e7ed22583..13979f4aa 100644 --- a/code/nel/src/gui/group_editbox.cpp +++ b/code/nel/src/gui/group_editbox.cpp @@ -1005,7 +1005,6 @@ namespace NLGUI { case KeyESCAPE: _CurrentHistoricIndex= -1; - CWidgetManager::getInstance()->setCaptureKeyboard(NULL); // stop selection _CurrSelection = NULL; _CursorAtPreviousLineEnd = false; @@ -1014,6 +1013,7 @@ namespace NLGUI setInputString(ucstring("")); triggerOnChangeAH(); } + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); break; case KeyTAB: makeTopWindow(); diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 7b2621b18..b606a093d 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -49,6 +49,8 @@ #include "nel/gui/http_hsts.h" #include "nel/gui/curl_certificates.h" +#include + using namespace std; using namespace NLMISC; @@ -205,6 +207,47 @@ namespace NLGUI std::map HeadersRecv; }; + // cURL transfer callbacks + // *************************************************************************** + static size_t curlHeaderCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData) + { + CCurlWWWData * me = static_cast(pCCurlWWWData); + if (me) + { + std::string header; + header.append(buffer, size * nmemb); + me->setRecvHeader(header.substr(0, header.find_first_of("\n\r"))); + } + + return size * nmemb; + } + + // *************************************************************************** + static size_t curlDataCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData) + { + CCurlWWWData * me = static_cast(pCCurlWWWData); + if (me) + me->Content.append(buffer, size * nmemb); + + return size * nmemb; + } + + // *************************************************************************** + static size_t curlProgressCallback(void *pCCurlWWWData, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) + { + CCurlWWWData * me = static_cast(pCCurlWWWData); + if (me) + { + if (dltotal > 0 || dlnow > 0 || ultotal > 0 || ulnow > 0) + { + nlwarning("> dltotal %d, dlnow %d, ultotal %d, ulnow %d, url '%s'", dltotal, dlnow, ultotal, ulnow, me->Url.c_str()); + } + } + + // return 1 to cancel download + return 0; + } + // Check if domain is on TrustedDomain bool CGroupHTML::isTrustedDomain(const string &domain) { @@ -395,13 +438,12 @@ namespace NLGUI return false; } -#if defined(NL_OS_WINDOWS) // https:// if (toLower(download.url.substr(0, 8)) == "https://") { - curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, &CCurlCertificates::sslCtxFunction); + // if supported, use custom SSL context function to load certificates + CCurlCertificates::useCertificates(curl); } -#endif download.data = new CCurlWWWData(curl, download.url); download.fp = fp; @@ -424,7 +466,7 @@ namespace NLGUI download.data->sendHeaders(headers); // catch headers - curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, curlHeaderCallback); + curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, NLGUI::curlHeaderCallback); curl_easy_setopt(curl, CURLOPT_WRITEHEADER, download.data); std::string userAgent = options.appName + "/" + options.appVersion; @@ -454,7 +496,7 @@ namespace NLGUI #endif // Display cached image while downloading new - if (type != TImageType::OverImage && CFile::fileExists(dest)) + if (type != OverImage && CFile::fileExists(dest)) { setImage(img, dest, type); setImageSize(img, style); @@ -1052,6 +1094,29 @@ namespace NLGUI _CellParams.push_back (cellParams); \ } + static bool scanCssLength(const std::string& str, uint32 &px) + { + if (fromString(str, px)) + return true; + + if (str == "thin") + { + px = 1; + return true; + } + if (str == "medium") + { + px = 3; + return true; + } + if (str == "thick") + { + px = 5; + return true; + } + + return false; + } static bool isHexa(char c) { @@ -1480,23 +1545,14 @@ namespace NLGUI { registerAnchorName(MY_HTML_A); - CStyleParams style; - style.FontFamily = getFontFamily(); - style.FontSize = getFontSize(); - style.TextColor = LinkColor; - style.Underlined = true; - style.StrikeThrough = getFontStrikeThrough(); - style.GlobalColor = LinkColorGlobalColor; + pushStyle(); + _Style.TextColor = LinkColor; + _Style.Underlined = true; + _Style.GlobalColor = LinkColorGlobalColor; if (present[HTML_A_STYLE] && value[HTML_A_STYLE]) - getStyleParams(value[HTML_A_STYLE], 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(style.GlobalColor); _A.push_back(true); _Link.push_back (""); _LinkTitle.push_back(""); @@ -1534,6 +1590,7 @@ namespace NLGUI { _BlockLevelElement.push_back(true); registerAnchorName(MY_HTML_DIV); + pushStyle(); if (present[MY_HTML_DIV_NAME] && value[MY_HTML_DIV_NAME]) _DivName = value[MY_HTML_DIV_NAME]; @@ -1542,6 +1599,13 @@ namespace NLGUI if (present[MY_HTML_DIV_CLASS] && value[MY_HTML_DIV_CLASS]) instClass = value[MY_HTML_DIV_CLASS]; + string style; + if (present[MY_HTML_DIV_STYLE] && value[MY_HTML_DIV_STYLE]) + style = value[MY_HTML_DIV_STYLE]; + + if (!style.empty()) + getStyleParams(style, _Style); + // use generic template system if (_TrustedDomain && !instClass.empty() && instClass == "ryzom-ui-grouptemplate") { @@ -1549,10 +1613,6 @@ namespace NLGUI if (present[MY_HTML_DIV_ID] && value[MY_HTML_DIV_ID]) id = value[MY_HTML_DIV_ID]; - string style; - if (present[MY_HTML_DIV_STYLE] && value[MY_HTML_DIV_STYLE]) - style = value[MY_HTML_DIV_STYLE]; - typedef pair TTmplParam; vector tmplParams; @@ -1565,6 +1625,8 @@ namespace NLGUI { if ((*it).first == "template") templateName = (*it).second; + else if ((*it).first == "display" && (*it).second == "inline-block") + _BlockLevelElement.back() = false; else tmplParams.push_back(TTmplParam((*it).first, (*it).second)); } @@ -1618,30 +1680,19 @@ namespace NLGUI break; case HTML_FONT: { - bool found = false; + pushStyle(); if (present[HTML_FONT_COLOR] && value[HTML_FONT_COLOR]) { CRGBA color; if (scanHTMLColor(value[HTML_FONT_COLOR], color)) - { - _TextColor.push_back(color); - found = true; - } - } - if (!found) - { - _TextColor.push_back(_TextColor.empty() ? CRGBA::White : _TextColor.back()); + _Style.TextColor = color; } if (present[HTML_FONT_SIZE] && value[HTML_FONT_SIZE]) { uint fontsize; fromString(value[HTML_FONT_SIZE], fontsize); - _FontSize.push_back(fontsize); - } - else - { - _FontSize.push_back(_FontSize.empty() ? TextFontSize : _FontSize.back()); + _Style.FontSize = fontsize; } } break; @@ -1692,6 +1743,10 @@ namespace NLGUI image = image.substr(4, image.size()-5); setBackground (image, scale, repeat); } + + // set default text style from + getStyleParams(style, _StyleDefault); + _Style = _StyleDefault; } } break; @@ -1713,46 +1768,76 @@ namespace NLGUI } break; case HTML_H1: - registerAnchorName(MY_HTML_H1); - newParagraph(PBeginSpace); - _FontSize.push_back(H1FontSize); - _TextColor.push_back(H1Color); - _GlobalColor.push_back(H1ColorGlobalColor); + { + registerAnchorName(MY_HTML_H1); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H1FontSize; + _Style.TextColor = H1Color; + _Style.GlobalColor = H1ColorGlobalColor; + if (present[MY_HTML_H1_STYLE] && value[MY_HTML_H1_STYLE]) + getStyleParams(value[MY_HTML_H1_STYLE], _Style); + } break; case HTML_H2: - registerAnchorName(MY_HTML_H2); - newParagraph(PBeginSpace); - _FontSize.push_back(H2FontSize); - _TextColor.push_back(H2Color); - _GlobalColor.push_back(H2ColorGlobalColor); + { + registerAnchorName(MY_HTML_H2); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H2FontSize; + _Style.TextColor = H2Color; + _Style.GlobalColor = H2ColorGlobalColor; + if (present[MY_HTML_H2_STYLE] && value[MY_HTML_H2_STYLE]) + getStyleParams(value[MY_HTML_H2_STYLE], _Style); + } break; case HTML_H3: - registerAnchorName(MY_HTML_H3); - newParagraph(PBeginSpace); - _FontSize.push_back(H3FontSize); - _TextColor.push_back(H3Color); - _GlobalColor.push_back(H3ColorGlobalColor); + { + registerAnchorName(MY_HTML_H3); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H3FontSize; + _Style.TextColor = H3Color; + _Style.GlobalColor = H3ColorGlobalColor; + if (present[MY_HTML_H3_STYLE] && value[MY_HTML_H3_STYLE]) + getStyleParams(value[MY_HTML_H3_STYLE], _Style); + } break; case HTML_H4: - registerAnchorName(MY_HTML_H4); - newParagraph(PBeginSpace); - _FontSize.push_back(H4FontSize); - _TextColor.push_back(H4Color); - _GlobalColor.push_back(H4ColorGlobalColor); + { + registerAnchorName(MY_HTML_H4); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H4FontSize; + _Style.TextColor = H4Color; + _Style.GlobalColor = H4ColorGlobalColor; + if (present[MY_HTML_H4_STYLE] && value[MY_HTML_H4_STYLE]) + getStyleParams(value[MY_HTML_H4_STYLE], _Style); + } break; case HTML_H5: - registerAnchorName(MY_HTML_H5); - newParagraph(PBeginSpace); - _FontSize.push_back(H5FontSize); - _TextColor.push_back(H5Color); - _GlobalColor.push_back(H5ColorGlobalColor); + { + registerAnchorName(MY_HTML_H5); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H5FontSize; + _Style.TextColor = H5Color; + _Style.GlobalColor = H5ColorGlobalColor; + if (present[MY_HTML_H5_STYLE] && value[MY_HTML_H5_STYLE]) + getStyleParams(value[MY_HTML_H5_STYLE], _Style); + } break; case HTML_H6: - registerAnchorName(MY_HTML_H6); - newParagraph(PBeginSpace); - _FontSize.push_back(H6FontSize); - _TextColor.push_back(H6Color); - _GlobalColor.push_back(H6ColorGlobalColor); + { + registerAnchorName(MY_HTML_H6); + newParagraph(PBeginSpace); + pushStyle(); + _Style.FontSize = H6FontSize; + _Style.TextColor = H6Color; + _Style.GlobalColor = H6ColorGlobalColor; + if (present[MY_HTML_H6_STYLE] && value[MY_HTML_H6_STYLE]) + getStyleParams(value[MY_HTML_H6_STYLE], _Style); + } break; case HTML_IMG: { @@ -1850,15 +1935,15 @@ namespace NLGUI if (present[MY_HTML_INPUT_TYPE] && value[MY_HTML_INPUT_TYPE]) { // 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; + pushStyle(); + _Style.TextColor = TextColor; + _Style.FontSize = TextFontSize; + _Style.FontWeight = FONT_WEIGHT_NORMAL; + _Style.FontOblique = false; // Global color flag if (present[MY_HTML_INPUT_GLOBAL_COLOR]) - style.GlobalColor = true; + _Style.GlobalColor = true; // Tooltip const char *tooltip = NULL; @@ -1866,13 +1951,7 @@ namespace NLGUI tooltip = value[MY_HTML_INPUT_ALT]; 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); + getStyleParams(value[MY_HTML_INPUT_STYLE], _Style); string type = toLower(value[MY_HTML_INPUT_TYPE]); if (type == "image") @@ -1892,7 +1971,7 @@ namespace NLGUI // Add the ctrl button addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over, - "html_submit_form", param.c_str(), tooltip, style); + "html_submit_form", param.c_str(), tooltip, _Style); } if (type == "button" || type == "submit") { @@ -1947,7 +2026,7 @@ namespace NLGUI if (!ctrlButton) ctrlButton = dynamic_cast(buttonGroup->getCtrl("b")); if (ctrlButton) { - ctrlButton->setModulateGlobalColorAll (style.GlobalColor); + ctrlButton->setModulateGlobalColorAll (_Style.GlobalColor); // Translate the tooltip if (tooltip) @@ -2030,7 +2109,7 @@ namespace NLGUI checked = (present[MY_HTML_INPUT_CHECKED] && value[MY_HTML_INPUT_CHECKED]); // Add the ctrl button - CCtrlButton *checkbox = addButton (btnType, name, normal, pushed, over, "", "", tooltip, style); + CCtrlButton *checkbox = addButton (btnType, name, normal, pushed, over, "", "", tooltip, _Style); if (checkbox) { if (btnType == CCtrlButton::RadioButton) @@ -2084,11 +2163,7 @@ namespace NLGUI } } - popIfNotEmpty(_FontFamily); - popIfNotEmpty(_FontSize); - popIfNotEmpty(_TextColor); - popIfNotEmpty(_FontWeight); - popIfNotEmpty(_FontOblique); + popStyle(); } } break; @@ -2182,6 +2257,10 @@ namespace NLGUI if (present[HTML_LI_VALUE] && value[HTML_LI_VALUE]) fromString(value[HTML_LI_VALUE], _UL.back().Value); + pushStyle(); + if (present[HTML_LI_STYLE] && value[HTML_LI_STYLE]) + getStyleParams(value[HTML_LI_STYLE], _Style); + ucstring str; str.fromUtf8(_UL.back().getListMarkerText()); addString (str); @@ -2199,35 +2278,28 @@ namespace NLGUI } break; case HTML_P: - newParagraph(PBeginSpace); + { + newParagraph(PBeginSpace); + pushStyle(); + if (present[HTML_BLOCK_STYLE] && value[HTML_BLOCK_STYLE]) + getStyleParams(value[HTML_BLOCK_STYLE], _Style); + } break; case HTML_PRE: { - CStyleParams style; - style.TextColor = getTextColor(); - style.FontFamily = "monospace"; - style.FontSize = getFontSize(); - style.FontWeight = getFontWeight(); - style.FontOblique = getFontOblique(); - style.Underlined = getFontUnderlined(); - style.StrikeThrough = getFontStrikeThrough(); + pushStyle(); + _Style.FontFamily = "monospace"; if (present[HTML_PRE_STYLE] && value[HTML_PRE_STYLE]) - getStyleParams(value[HTML_PRE_STYLE], 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: { + pushStyle(); registerAnchorName(MY_HTML_TABLE); // Get cells parameters @@ -2246,6 +2318,8 @@ namespace NLGUI fromString(value[MY_HTML_TABLE_CELLSPACING], table->CellSpacing); if (present[MY_HTML_TABLE_CELLPADDING] && value[MY_HTML_TABLE_CELLPADDING]) fromString(value[MY_HTML_TABLE_CELLPADDING], table->CellPadding); + if (present[MY_HTML_TABLE_STYLE] && value[MY_HTML_TABLE_STYLE]) + getStyleParams(value[MY_HTML_TABLE_STYLE], _Style); table->setMarginLeft(getIndent()); addHtmlGroup (table, 0); @@ -2265,14 +2339,18 @@ namespace NLGUI // Get cells parameters getCellsParameters (MY_HTML_TD, true); + pushStyle(); if (element_number == HTML_TH) { - _FontWeight.push_back(FONT_WEIGHT_BOLD); + _Style.FontWeight = FONT_WEIGHT_BOLD; // center if not specified otherwise. TD/TH present/value arrays have same indices if (!(present[MY_HTML_TD_ALIGN] && value[MY_HTML_TD_ALIGN])) _CellParams.back().Align = CGroupCell::Center; } + if (present[MY_HTML_TD_STYLE] && value[MY_HTML_TD_STYLE]) + getStyleParams(value[MY_HTML_TD_STYLE], _Style); + CGroupTable *table = getTable(); if (table) { @@ -2352,27 +2430,22 @@ namespace NLGUI } break; case HTML_TEXTAREA: + pushStyle(); _PRE.push_back(true); + // not inherited by default, font family defaults to system font + _Style.TextColor = TextColor; + _Style.FontWeight = FONT_WEIGHT_NORMAL; + _Style.FontOblique = false; + _Style.FontSize = TextFontSize; + _Style.TextShadow = STextShadow(true); + + if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE]) + getStyleParams(value[MY_HTML_TEXTAREA_STYLE], _Style); + // 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; @@ -2421,6 +2494,10 @@ namespace NLGUI // Set TR flag if (!_TR.empty()) _TR.back() = true; + + pushStyle(); + if (present[MY_HTML_TR_STYLE] && value[MY_HTML_TR_STYLE]) + getStyleParams(value[MY_HTML_TR_STYLE], _Style); } break; case HTML_UL: @@ -2434,6 +2511,10 @@ namespace NLGUI _LI = _UL.size() > 1 || _DL.size() > 1; _Indent.push_back(getIndent() + ULIndent); endParagraph(); + + pushStyle(); + if (present[HTML_UL_STYLE] && value[HTML_UL_STYLE]) + getStyleParams(value[HTML_UL_STYLE], _Style); break; case HTML_OBJECT: _ObjectType.clear(); @@ -2453,69 +2534,77 @@ namespace NLGUI break; case HTML_SPAN: { - CStyleParams style; - style.TextColor = getTextColor(); - style.FontFamily = getFontFamily(); - style.FontSize = getFontSize(); - style.FontWeight = getFontWeight(); - style.FontOblique = getFontOblique(); - style.Underlined = getFontUnderlined(); - style.StrikeThrough = getFontStrikeThrough(); - style.GlobalColor = getGlobalColor(); + pushStyle(); if (present[MY_HTML_SPAN_STYLE] && value[MY_HTML_SPAN_STYLE]) - 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); - _FontUnderlined.push_back(style.Underlined); - _FontStrikeThrough.push_back(style.StrikeThrough); - _GlobalColor.push_back(style.GlobalColor); + getStyleParams(value[MY_HTML_SPAN_STYLE], _Style); } break; case HTML_DEL: - _FontStrikeThrough.push_back(true); + { + pushStyle(); + _Style.StrikeThrough = true; + } break; case HTML_U: - _FontUnderlined.push_back(true); + { + pushStyle(); + _Style.Underlined = true; + } break; case HTML_EM: - _FontOblique.push_back(true); + { + pushStyle(); + _Style.FontOblique = true; + } break; case HTML_STRONG: - _FontWeight.push_back(FONT_WEIGHT_BOLD); + { + pushStyle(); + _Style.FontWeight = FONT_WEIGHT_BOLD; + } break; case HTML_SMALL: - _FontSize.push_back(getFontSizeSmaller()); + { + pushStyle(); + _Style.FontSize = getFontSizeSmaller(); + } break; case HTML_STYLE: case HTML_SCRIPT: _IgnoreText = true; break; case HTML_DL: - _DL.push_back(HTMLDListElement()); - _LI = _DL.size() > 1 || !_UL.empty(); - endParagraph(); + { + _DL.push_back(HTMLDListElement()); + _LI = _DL.size() > 1 || !_UL.empty(); + endParagraph(); + pushStyle(); + if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) + getStyleParams(value[HTML_GEN_STYLE], _Style); + } break; case HTML_DT: if (!_DL.empty()) { - // close DT if still open + // close if still open if (_DL.back().DD) { _DL.back().DD = false; popIfNotEmpty(_Indent); + popStyle(); } - // see if this is the first
, closing tag not required - if (!_DL.back().DT) - { - _DL.back().DT = true; - _FontWeight.push_back(FONT_WEIGHT_BOLD); - } + // close if still open + if (_DL.back().DT) + popStyle(); + + _DL.back().DT = true; + + pushStyle(); + _Style.FontWeight = FONT_WEIGHT_BOLD; + if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) + getStyleParams(value[HTML_GEN_STYLE], _Style); if (!_LI) { @@ -2535,15 +2624,23 @@ namespace NLGUI if (_DL.back().DT) { _DL.back().DT = false; - popIfNotEmpty (_FontWeight); + popStyle(); } - if (!_DL.back().DD) + if (_DL.back().DD) { - _DL.back().DD = true; - _Indent.push_back(getIndent() + ULIndent); + _DL.back().DD = false; + popStyle(); + popIfNotEmpty(_Indent); } + _DL.back().DD = true; + _Indent.push_back(getIndent() + ULIndent); + + pushStyle(); + if (present[HTML_GEN_STYLE] && value[HTML_GEN_STYLE]) + getStyleParams(value[HTML_GEN_STYLE], _Style); + if (!_LI) { _LI = true; @@ -2557,6 +2654,7 @@ namespace NLGUI break; case HTML_OL: { + pushStyle(); sint32 start = 1; std::string type("1"); @@ -2564,6 +2662,8 @@ namespace NLGUI fromString(value[HTML_OL_START], start); if (present[HTML_OL_TYPE] && value[HTML_OL_TYPE]) type = value[HTML_OL_TYPE]; + if (present[HTML_OL_STYLE] && value[HTML_OL_STYLE]) + getStyleParams(value[HTML_OL_STYLE], _Style); _UL.push_back(HTMLOListElement(start, type)); // if LI is already present @@ -2626,16 +2726,10 @@ namespace NLGUI _ReadingHeadTag = false; break; case HTML_FONT: - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontSize); + popStyle(); break; case HTML_A: - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontUnderlined); - popIfNotEmpty (_FontStrikeThrough); - popIfNotEmpty (_GlobalColor); + popStyle(); popIfNotEmpty (_A); popIfNotEmpty (_Link); popIfNotEmpty (_LinkTitle); @@ -2647,25 +2741,19 @@ namespace NLGUI case HTML_H4: case HTML_H5: case HTML_H6: - popIfNotEmpty (_FontSize); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_GlobalColor); + popStyle(); endParagraph(); break; case HTML_P: + popStyle(); endParagraph(); break; case HTML_PRE: - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_FontWeight); - popIfNotEmpty (_FontOblique); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontUnderlined); - popIfNotEmpty (_FontStrikeThrough); + popStyle(); popIfNotEmpty (_PRE); break; case HTML_DIV: + popStyle(); if (isBlockLevelElement()) { endParagraph(); @@ -2676,6 +2764,7 @@ namespace NLGUI break; case HTML_TABLE: + popStyle(); popIfNotEmpty (_CellParams); popIfNotEmpty (_TR); popIfNotEmpty (_Cells); @@ -2685,14 +2774,15 @@ namespace NLGUI // Add a cell break; case HTML_TH: - popIfNotEmpty (_FontWeight); // no break; case HTML_TD: + popStyle(); popIfNotEmpty (_CellParams); if (!_Cells.empty()) _Cells.back() = NULL; break; case HTML_TR: + popStyle(); popIfNotEmpty (_CellParams); break; case HTML_TEXTAREA: @@ -2709,14 +2799,9 @@ namespace NLGUI entry.TextArea = textArea; _Forms.back().Entries.push_back (entry); } - - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_FontWeight); - popIfNotEmpty (_FontOblique); - popIfNotEmpty (_TextColor); } + popStyle(); popIfNotEmpty (_PRE); } break; @@ -2824,10 +2909,16 @@ namespace NLGUI if (!_UL.empty()) { endParagraph(); + popStyle(); popIfNotEmpty(_UL); popIfNotEmpty(_Indent); } break; + case HTML_LI: + { + popStyle(); + } + break; case HTML_DL: if (!_DL.empty()) { @@ -2836,23 +2927,26 @@ namespace NLGUI // unclosed DT if (_DL.back().DT) { - popIfNotEmpty (_FontWeight); + popStyle(); } // unclosed DD if (_DL.back().DD) { popIfNotEmpty(_Indent); + popStyle(); } popIfNotEmpty (_DL); + popStyle(); } break; case HTML_DT: if (!_DL.empty()) { + if (_DL.back().DT) + popStyle(); _DL.back().DT = false; - popIfNotEmpty (_FontWeight); } break; case HTML_DD: @@ -2863,33 +2957,27 @@ namespace NLGUI { _DL.back().DD = false; popIfNotEmpty(_Indent); + popStyle(); } } break; case HTML_SPAN: - popIfNotEmpty (_FontFamily); - popIfNotEmpty (_FontSize); - popIfNotEmpty (_FontWeight); - popIfNotEmpty (_FontOblique); - popIfNotEmpty (_TextColor); - popIfNotEmpty (_FontUnderlined); - popIfNotEmpty (_FontStrikeThrough); - popIfNotEmpty (_GlobalColor); + popStyle(); break; case HTML_DEL: - popIfNotEmpty (_FontStrikeThrough); + popStyle(); break; case HTML_U: - popIfNotEmpty (_FontUnderlined); + popStyle(); break; case HTML_EM: - popIfNotEmpty (_FontOblique); + popStyle(); break; case HTML_STRONG: - popIfNotEmpty (_FontWeight); + popStyle(); break; case HTML_SMALL: - popIfNotEmpty (_FontSize); + popStyle(); break; case HTML_STYLE: case HTML_SCRIPT: @@ -4022,13 +4110,6 @@ namespace NLGUI void CGroupHTML::endParagraph() { - // Remove previous paragraph if empty - if (_Paragraph && (_Paragraph->getNumChildren() == 0)) - { - _Paragraph->getParent ()->delGroup(_Paragraph); - _Paragraph = NULL; - } - _Paragraph = NULL; paragraphChange (); @@ -4038,13 +4119,6 @@ namespace NLGUI void CGroupHTML::newParagraph(uint beginSpace) { - // Remove previous paragraph if empty - if (_Paragraph && (_Paragraph->getNumChildren() == 0)) - { - _Paragraph->getParent ()->delGroup(_Paragraph); - _Paragraph = NULL; - } - // Add a new paragraph CGroupParagraph *newParagraph = new CGroupParagraph(CViewBase::TCtorParam()); newParagraph->setResizeFromChildH(true); @@ -4332,23 +4406,32 @@ namespace NLGUI // Text added ? bool added = false; - bool embolden = getFontWeight() >= FONT_WEIGHT_BOLD; + bool embolden = _Style.FontWeight >= FONT_WEIGHT_BOLD; // Number of child in this paragraph if (_CurrentViewLink) { bool skipLine = !_CurrentViewLink->getText().empty() && *(_CurrentViewLink->getText().rbegin()) == (ucchar) '\n'; + bool sameShadow = _Style.TextShadow.Enabled && _CurrentViewLink->getShadow(); + if (sameShadow && _Style.TextShadow.Enabled) + { + sint sx, sy; + _CurrentViewLink->getShadowOffset(sx, sy); + sameShadow = (_Style.TextShadow.Color == _CurrentViewLink->getShadowColor()); + sameShadow = sameShadow && (_Style.TextShadow.Outline == _CurrentViewLink->getShadowOutline()); + sameShadow = sameShadow && (_Style.TextShadow.X == sx) && (_Style.TextShadow.Y == sy); + } // Compatible with current parameters ? - if (!skipLine && - (getTextColor() == _CurrentViewLink->getColor()) && - (getFontFamily() == _CurrentViewLink->getFontName()) && - (getFontSize() == (uint)_CurrentViewLink->getFontSize()) && - (getFontUnderlined() == _CurrentViewLink->getUnderlined()) && - (getFontStrikeThrough() == _CurrentViewLink->getStrikeThrough()) && + if (!skipLine && sameShadow && + (_Style.TextColor == _CurrentViewLink->getColor()) && + (_Style.FontFamily == _CurrentViewLink->getFontName()) && + (_Style.FontSize == (uint)_CurrentViewLink->getFontSize()) && + (_Style.Underlined == _CurrentViewLink->getUnderlined()) && + (_Style.StrikeThrough == _CurrentViewLink->getStrikeThrough()) && (embolden == _CurrentViewLink->getEmbolden()) && - (getFontOblique() == _CurrentViewLink->getOblique()) && + (_Style.FontOblique == _CurrentViewLink->getOblique()) && (getLink() == _CurrentViewLink->Link) && - (getGlobalColor() == _CurrentViewLink->getModulateGlobalColor())) + (_Style.GlobalColor == _CurrentViewLink->getModulateGlobalColor())) { // Concat the text _CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr); @@ -4408,16 +4491,23 @@ namespace NLGUI } } newLink->setText(tmpStr); - newLink->setColor(getTextColor()); - newLink->setFontName(getFontFamily()); - newLink->setFontSize(getFontSize()); + newLink->setColor(_Style.TextColor); + newLink->setFontName(_Style.FontFamily); + newLink->setFontSize(_Style.FontSize); newLink->setEmbolden(embolden); - newLink->setOblique(getFontOblique()); - newLink->setUnderlined(getFontUnderlined()); - newLink->setStrikeThrough(getFontStrikeThrough()); - newLink->setMultiLineSpace((uint)((float)getFontSize()*LineSpaceFontFactor)); + newLink->setOblique(_Style.FontOblique); + newLink->setUnderlined(_Style.Underlined); + newLink->setStrikeThrough(_Style.StrikeThrough); + newLink->setMultiLineSpace((uint)((float)(_Style.FontSize)*LineSpaceFontFactor)); newLink->setMultiLine(true); - newLink->setModulateGlobalColor(getGlobalColor()); + newLink->setModulateGlobalColor(_Style.GlobalColor); + if (_Style.TextShadow.Enabled) + { + newLink->setShadow(true); + newLink->setShadowColor(_Style.TextShadow.Color); + newLink->setShadowOutline(_Style.TextShadow.Outline); + newLink->setShadowOffset(_Style.TextShadow.X, _Style.TextShadow.Y); + } // newLink->setLineAtBottom (true); registerAnchor(newLink); @@ -4524,22 +4614,32 @@ namespace NLGUI { // Not added ? std::vector > templateParams; - templateParams.push_back (std::pair ("w", toString (cols*getFontSize()))); + templateParams.push_back (std::pair ("w", toString (cols*_Style.FontSize))); 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 ("fontsize", toString (_Style.FontSize))); + templateParams.push_back (std::pair ("color", _Style.TextColor.toString())); + if (_Style.FontWeight >= FONT_WEIGHT_BOLD) templateParams.push_back (std::pair ("fontweight", "bold")); - if (getFontOblique()) + if (_Style.FontOblique) 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 ("onenter", "")); templateParams.push_back (std::pair ("enter_recover_focus", "false")); if (maxlength > 0) templateParams.push_back (std::pair ("max_num_chars", toString(maxlength))); + templateParams.push_back (std::pair ("shadow", toString(_Style.TextShadow.Enabled))); + if (_Style.TextShadow.Enabled) + { + templateParams.push_back (std::pair ("shadow_x", toString(_Style.TextShadow.X))); + templateParams.push_back (std::pair ("shadow_y", toString(_Style.TextShadow.Y))); + templateParams.push_back (std::pair ("shadow_color", _Style.TextShadow.Color.toString())); + templateParams.push_back (std::pair ("shadow_outline", toString(_Style.TextShadow.Outline))); + } + CInterfaceGroup *textArea = CWidgetManager::getInstance()->getParser()->createGroupInstance (templateName.c_str(), getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); @@ -4718,7 +4818,7 @@ namespace NLGUI if (overBitmap != normalBitmap) { over = localImageName(overBitmap); - addImageDownload(overBitmap, ctrlButton, style, TImageType::OverImage); + addImageDownload(overBitmap, ctrlButton, style, OverImage); } } @@ -4774,13 +4874,6 @@ namespace NLGUI { _Paragraph = NULL; _PRE.clear(); - _TextColor.clear(); - _GlobalColor.clear(); - _FontSize.clear(); - _FontWeight.clear(); - _FontOblique.clear(); - _FontUnderlined.clear(); - _FontStrikeThrough.clear(); _Indent.clear(); _LI = false; _UL.clear(); @@ -4804,6 +4897,11 @@ namespace NLGUI _IgnoreHeadTag = false; _IgnoreBaseUrlTag = false; + // reset style + _StyleDefault = CStyleParams(); + _Style = _StyleDefault; + _StyleParams.clear(); + // TR paragraphChange (); @@ -4884,13 +4982,6 @@ namespace NLGUI if (!group) return; - // Remove previous paragraph if empty - if (_Paragraph && (_Paragraph->getNumChildren() == 0)) - { - _Paragraph->getParent ()->delGroup(_Paragraph); - _Paragraph = NULL; - } - registerAnchor(group); if (!_DivName.empty()) @@ -5354,13 +5445,12 @@ namespace NLGUI return; } -#if defined(NL_OS_WINDOWS) // https:// if (toLower(url.substr(0, 8)) == "https://") { - curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, &CCurlCertificates::sslCtxFunction); + // if supported, use custom SSL context function to load certificates + CCurlCertificates::useCertificates(curl); } -#endif // do not follow redirects, we have own handler curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 0); @@ -5430,17 +5520,17 @@ namespace NLGUI _CurlWWW->sendHeaders(headers); // catch headers for redirect - curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, curlHeaderCallback); + curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, NLGUI::curlHeaderCallback); curl_easy_setopt(curl, CURLOPT_WRITEHEADER, _CurlWWW); // catch body - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlDataCallback); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NLGUI::curlDataCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, _CurlWWW); #if LOG_DL // progress callback curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); - curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, curlProgressCallback); + curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, NLGUI::curlProgressCallback); curl_easy_setopt(curl, CURLOPT_XFERINFODATA, _CurlWWW); #else // progress off @@ -5841,6 +5931,8 @@ namespace NLGUI CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); std::string html = ls.toString(1); + // Always trust domain if rendered from lua + _TrustedDomain = true; renderHtmlString(html); return 0; @@ -6125,6 +6217,14 @@ namespace NLGUI // style.StrikeThrough; // text-decoration: line-through; text-decoration-line: line-through; void CGroupHTML::getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit) { + const CStyleParams current = _Style; + + if (inherit) + { + style.Underlined = current.Underlined; + style.StrikeThrough = current.StrikeThrough; + } + float tmpf; TStyle styles = parseStyle(styleString); TStyle::iterator it; @@ -6133,7 +6233,7 @@ namespace NLGUI if (it->first == "font-size") { if (it->second == "inherit") - style.FontSize = getFontSize(); + style.FontSize = current.FontSize; else { float tmp; @@ -6147,7 +6247,7 @@ namespace NLGUI if (it->first == "font-style") { if (it->second == "inherit") - style.FontOblique = getFontOblique(); + style.FontOblique = current.FontOblique; else if (it->second == "italic" || it->second == "oblique") style.FontOblique = true; @@ -6156,7 +6256,7 @@ namespace NLGUI if (it->first == "font-family") { if (it->second == "inherit") - style.FontFamily = getFontFamily(); + style.FontFamily = current.FontFamily; else if (it->second == "monospace") style.FontFamily = "monospace"; @@ -6169,7 +6269,7 @@ namespace NLGUI // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight uint weight = 400; if (it->second == "inherit") - weight = getFontWeight(); + weight = current.FontWeight; else if (it->second == "normal") weight = 400; @@ -6180,7 +6280,7 @@ namespace NLGUI if (it->second == "lighter") { const uint lighter[] = {100, 100, 100, 100, 100, 400, 400, 700, 700}; - uint index = getFontWeight() / 100 - 1; + uint index = current.FontWeight / 100 - 1; clamp(index, 1u, 9u); weight = lighter[index-1]; } @@ -6188,7 +6288,7 @@ namespace NLGUI if (it->second == "bolder") { const uint bolder[] = {400, 400, 400, 700, 700, 900, 900, 900, 900}; - uint index = getFontWeight() / 100 + 1; + uint index = current.FontWeight / 100 + 1; clamp(index, 1u, 9u); weight = bolder[index-1]; } @@ -6204,7 +6304,7 @@ namespace NLGUI else if (it->first == "color") if (it->second == "inherit") - style.TextColor = getTextColor(); + style.TextColor = current.TextColor; else scanHTMLColor(it->second.c_str(), style.TextColor); else @@ -6215,6 +6315,115 @@ namespace NLGUI style.StrikeThrough = (prop.find("line-through") != std::string::npos); } else + if (it->first == "text-stroke" || it->first == "-webkit-text-stroke") + { + // text-stroke: length || color + bool success = false; + uint px = 0; + CRGBA color; + std::vector parts; + NLMISC::splitString(it->second, " ", parts); + if (parts.size() == 1) + { + success = scanCssLength(parts[0], px); + if (!success) + success = scanHTMLColor(parts[0].c_str(), color); + } + else if (parts.size() == 2) + { + success = scanCssLength(parts[0], px); + if (success) + success = scanHTMLColor(parts[1].c_str(), color); + else + { + success = scanHTMLColor(parts[0].c_str(), color); + success = success && scanCssLength(parts[1], px); + } + } + + // do not disable shadow if one is already set + if (success) + { + style.TextShadow.Enabled = (px > 0); + style.TextShadow.Color = color; + style.TextShadow.X = px; + style.TextShadow.Y = px; + style.TextShadow.Outline = true; + } + } + else + if (it->first == "text-shadow") + { + if (it->second == "none") + style.TextShadow = STextShadow(false); + else + if (it->second == "inherit") + style.TextShadow = current.TextShadow; + else + { + // text-shadow: offset-x offset-y | blur | #color + // text-shadow: #color | offset-x offset-y + bool success = true; + std::string prop(it->second); + size_t pos; + pos = prop.find_first_of(",\n\r"); + if (pos != std::string::npos) + prop = prop.substr(0, pos); + + std::vector parts; + NLMISC::splitString(prop, " ", parts); + switch(parts.size()) + { + case 1: + { + success = scanHTMLColor(it->second.c_str(), style.TextShadow.Color); + break; + } + // no case 2: + case 3: + { + if (!fromString(parts[0], style.TextShadow.X)) + { + success = scanHTMLColor(parts[0].c_str(), style.TextShadow.Color); + success = success && fromString(parts[1], style.TextShadow.X); + success = success && fromString(parts[2], style.TextShadow.Y); + } + else + { + success = fromString(parts[1], style.TextShadow.Y); + success = success && scanHTMLColor(parts[2].c_str(), style.TextShadow.Color); + } + break; + } + case 4: + { + if (!fromString(parts[0], style.TextShadow.X)) + { + success = scanHTMLColor(parts[0].c_str(), style.TextShadow.Color); + success = success && fromString(parts[1], style.TextShadow.X); + success = success && fromString(parts[2], style.TextShadow.Y); + // ignore blur [3] + } + else + { + success = fromString(parts[0], style.TextShadow.X); + success = success && fromString(parts[1], style.TextShadow.Y); + // ignore blur [2] + success = success && scanHTMLColor(parts[3].c_str(), style.TextShadow.Color); + } + break; + } + default: + { + // unsupported rule + break; + } + } + + style.TextShadow.Enabled = success; + } + } + else if (it->first == "width") getPercentage(style.Width, tmpf, it->second.c_str()); else @@ -6231,17 +6440,12 @@ namespace NLGUI { bool b; if (it->second == "inherit") - style.GlobalColor = getGlobalColor(); + style.GlobalColor = current.GlobalColor; else if (fromString(it->second, b)) style.GlobalColor = b; } } - if (inherit) - { - style.Underlined = getFontUnderlined() || style.Underlined; - style.StrikeThrough = getFontStrikeThrough() || style.StrikeThrough; - } } // *************************************************************************** @@ -6312,46 +6516,6 @@ namespace NLGUI } } - // *************************************************************************** - size_t CGroupHTML::curlHeaderCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData) - { - CCurlWWWData * me = static_cast(pCCurlWWWData); - if (me) - { - std::string header; - header.append(buffer, size * nmemb); - me->setRecvHeader(header.substr(0, header.find_first_of("\n\r"))); - } - - return size * nmemb; - } - - // *************************************************************************** - size_t CGroupHTML::curlDataCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData) - { - CCurlWWWData * me = static_cast(pCCurlWWWData); - if (me) - me->Content.append(buffer, size * nmemb); - - return size * nmemb; - } - - // *************************************************************************** - size_t CGroupHTML::curlProgressCallback(void *pCCurlWWWData, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) - { - CCurlWWWData * me = static_cast(pCCurlWWWData); - if (me) - { - if (dltotal > 0 || dlnow > 0 || ultotal > 0 || ulnow > 0) - { - nlwarning("> dltotal %d, dlnow %d, ultotal %d, ulnow %d, url '%s'", dltotal, dlnow, ultotal, ulnow, me->Url.c_str()); - } - } - - // return 1 to cancel download - return 0; - } - // *************************************************************************** std::string CGroupHTML::HTMLOListElement::getListMarkerText() const { diff --git a/code/nel/src/gui/group_paragraph.cpp b/code/nel/src/gui/group_paragraph.cpp index b2635b52e..d7d50af2e 100644 --- a/code/nel/src/gui/group_paragraph.cpp +++ b/code/nel/src/gui/group_paragraph.cpp @@ -1410,7 +1410,7 @@ namespace NLGUI // Get the child width maxWidth += _Elements[k].Element->getMaxUsedW(); } - return maxWidth; + return maxWidth + _MarginLeft; } // ---------------------------------------------------------------------------- @@ -1425,7 +1425,7 @@ namespace NLGUI if (width > minWidth) minWidth = width; } - return minWidth; + return minWidth + _MarginLeft; } diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp index ef3eca57a..b10114a18 100644 --- a/code/nel/src/gui/group_table.cpp +++ b/code/nel/src/gui/group_table.cpp @@ -703,7 +703,7 @@ namespace NLGUI { if (ContinuousUpdate) { - sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); + sint parentWidth = _Parent->getInnerWidth(); if (_LastParentW != (sint) parentWidth) { _LastParentW = parentWidth; @@ -813,10 +813,6 @@ namespace NLGUI for(sint span = 0; span < cell->ColSpan -1; ++span) { ++column; - _Columns[column].Width = std::max(_Columns[column].Width, _Columns[column-1].Width); - _Columns[column].WidthMax = std::max(_Columns[column].WidthMax, _Columns[column-1].WidthMax); - _Columns[column].TableRatio = std::max(_Columns[column].TableRatio, _Columns[column-1].TableRatio); - _Columns[column].WidthWanted = std::max(_Columns[column].WidthWanted, _Columns[column-1].WidthWanted); _Columns[column].RowSpan = _Columns[column-1].RowSpan; } } @@ -1163,7 +1159,7 @@ namespace NLGUI { if (_Parent != NULL) { - sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); + sint parentWidth = _Parent->getInnerWidth(); if (_LastParentW != (sint) parentWidth) { if (ContinuousUpdate) @@ -1311,6 +1307,9 @@ namespace NLGUI // ---------------------------------------------------------------------------- void CGroupTable::draw () { + // move X for clip and borders + _XReal += _MarginLeft; + // search a parent container CInterfaceGroup *gr = getParent(); while (gr) @@ -1391,6 +1390,9 @@ namespace NLGUI } CInterfaceGroup::draw (); + + // restore + _XReal -= _MarginLeft; } std::string CGroupTable::getProperties( const std::string &name ) const diff --git a/code/nel/src/gui/http_hsts.cpp b/code/nel/src/gui/http_hsts.cpp index c69062538..c57bb738c 100644 --- a/code/nel/src/gui/http_hsts.cpp +++ b/code/nel/src/gui/http_hsts.cpp @@ -87,9 +87,12 @@ namespace NLGUI { if (domain.empty() || _Domains.empty()) return false; - if (_Domains.count(domain) > 0) + THSTSObjectMap::const_iterator itHsts; + + itHsts = _Domains.find(domain); + if (itHsts != _Domains.end()) { - hsts = _Domains.at(domain); + hsts = itHsts->second; return true; } @@ -99,11 +102,12 @@ namespace NLGUI { { std::string tmp; tmp = domain.substr(firstOf+1); - if (_Domains.count(tmp)) + itHsts = _Domains.find(tmp); + if (itHsts != _Domains.end()) { - if (_Domains.at(tmp).IncludeSubDomains) + if (itHsts->second.IncludeSubDomains) { - hsts = _Domains.at(tmp); + hsts = itHsts->second; return true; } @@ -182,7 +186,7 @@ namespace NLGUI { { uint32 nbItems = _Domains.size(); f.serial(nbItems); - for (THSTSObject::iterator it = _Domains.begin(); it != _Domains.end(); ++it) + for (THSTSObjectMap::iterator it = _Domains.begin(); it != _Domains.end(); ++it) { std::string domain(it->first); f.serial(domain); diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 2e13d80e6..d3ed2d01c 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -506,10 +506,16 @@ namespace NLGUI } } + // ------------------------------------------------------------------------------------------------ + sint32 CInterfaceElement::getInnerWidth() const + { + return _WReal - _MarginLeft; + } + // ------------------------------------------------------------------------------------------------ void CInterfaceElement::updateCoords() { - _XReal = _X + _MarginLeft; + _XReal = _X; _YReal = _Y; _WReal = getW(); _HReal = getH(); @@ -526,7 +532,7 @@ namespace NLGUI if (el == NULL) return; - _XReal += el->_XReal - el->_MarginLeft; + _XReal += el->_XReal; _YReal += el->_YReal; THotSpot hsParent = _ParentPosRef; diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index dce9fc266..789030a4a 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -1305,7 +1305,7 @@ namespace NLGUI CInterfaceGroup *currParent = _Parent; while (currParent) { - if (currParent->moveSBTrackY (this, eventDesc.getWheel()*12)) + if (currParent->moveSBTargetY (this, -(eventDesc.getWheel()*12))) return true; currParent = currParent->getParent(); } @@ -1397,9 +1397,19 @@ namespace NLGUI restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); } + // ------------------------------------------------------------------------------------------------ + sint32 CInterfaceGroup::getInnerWidth() const + { + sint width = CInterfaceElement::getInnerWidth(); + return std::min(width, _MaxWReal - _MarginLeft); + } + // ------------------------------------------------------------------------------------------------ void CInterfaceGroup::checkCoords() { + // Make XReal same as in updateCoords() as some elements (CViewText) depends on it + _XReal += _MarginLeft; + //update all children elements vector::const_iterator ite; for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) @@ -1408,7 +1418,9 @@ namespace NLGUI if(pIE->getActive()) pIE->checkCoords(); } - executeLuaScriptOnDraw(); + + _XReal -= _MarginLeft; + executeLuaScriptOnDraw(); } // ------------------------------------------------------------------------------------------------ @@ -1468,7 +1480,7 @@ namespace NLGUI pIE->updateCoords(); } - _XReal -= _OffsetX - _MarginLeft; + _XReal -= (_OffsetX + _MarginLeft); _YReal -= _OffsetY; } @@ -1958,9 +1970,11 @@ namespace NLGUI newSciH = newSciH - ((newSciY+newSciH)-(oldSciY+oldSciH)); } - newSciXDest = newSciX - _MarginLeft; + // Don't apply margins because HTML list marker is drawn outside group paragraph inner content. + // Should not be an issue because horizontal scolling not used. + newSciXDest = newSciX/* + _MarginLeft*/; newSciYDest = newSciY; - newSciWDest = newSciW + _MarginLeft; + newSciWDest = newSciW/* - _MarginLeft*/; newSciHDest = newSciH; } diff --git a/code/nel/src/gui/libwww.cpp b/code/nel/src/gui/libwww.cpp index c8b41a38f..2e9b4451a 100644 --- a/code/nel/src/gui/libwww.cpp +++ b/code/nel/src/gui/libwww.cpp @@ -19,6 +19,8 @@ #include "nel/gui/libwww.h" #include "nel/gui/group_html.h" +#include + using namespace NLMISC; #ifdef DEBUG_NEW @@ -101,6 +103,7 @@ namespace NLGUI HTML_ATTR(TR,L_MARGIN), HTML_ATTR(TR,NOWRAP), HTML_ATTR(TR,VALIGN), + HTML_ATTR(TR,STYLE), { 0 } }; diff --git a/code/nel/src/gui/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp index 0b4a1d0dc..4a51d221f 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -1434,7 +1434,7 @@ namespace NLGUI } // *************************************************************************** - void CLuaIHM::luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException) + void CLuaIHM::luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) { //H_AUTO(Lua_property_throw) if(ls.isNil(stackIndex)) diff --git a/code/nel/src/gui/lua_object.cpp b/code/nel/src/gui/lua_object.cpp index c957c3f2c..805e38ceb 100644 --- a/code/nel/src/gui/lua_object.cpp +++ b/code/nel/src/gui/lua_object.cpp @@ -222,7 +222,7 @@ namespace NLGUI } // ************************************************* - CLuaEnumeration CLuaObject::enumerate() throw(ELuaNotATable) + CLuaEnumeration CLuaObject::enumerate() { if (!isEnumerable()) { @@ -271,7 +271,7 @@ namespace NLGUI } // ************************************************* - CLuaObject CLuaObject::at(const char *key) const throw(ELuaNotATable) + CLuaObject CLuaObject::at(const char *key) const { if (!isEnumerable()) throw ELuaNotATable(NLMISC::toString("Can't get key '%s' in object '%s' because type is '%s', it is not a table.", key, getId().c_str(), getTypename()).c_str()); return operator[](key); @@ -286,7 +286,7 @@ namespace NLGUI } // ************************************************* - CLuaObject CLuaObject::newTable(const char *tableName) throw(ELuaNotATable) + CLuaObject CLuaObject::newTable(const char *tableName) { nlassert(tableName); nlassert(isValid()); @@ -301,7 +301,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, const CLuaObject &value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, const CLuaObject &value) { nlassert(key); nlassert(isValid()); @@ -317,7 +317,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setNil(const char *key) throw(ELuaNotATable) + void CLuaObject::setNil(const char *key) { nlassert(key); nlassert(isValid()); @@ -331,7 +331,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, const char *value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, const char *value) { nlassert(value); nlassert(key); @@ -346,13 +346,13 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, const std::string &value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, const std::string &value) { setValue(key, value.c_str()); } // ************************************************* - void CLuaObject::setValue(const char *key, bool value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, bool value) { nlassert(key); nlassert(isValid()); @@ -366,7 +366,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, TLuaWrappedFunction value) { nlassert(key); nlassert(isValid()); @@ -380,7 +380,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, double value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, double value) { nlassert(key); nlassert(isValid()); @@ -394,7 +394,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, uint32 value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, uint32 value) { nlassert(key); nlassert(isValid()); @@ -408,7 +408,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, sint32 value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, sint32 value) { nlassert(key); nlassert(isValid()); @@ -422,7 +422,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::setValue(const char *key, sint64 value) throw(ELuaNotATable) + void CLuaObject::setValue(const char *key, sint64 value) { nlassert(key); nlassert(isValid()); @@ -436,7 +436,7 @@ namespace NLGUI } // ************************************************* - void CLuaObject::eraseValue(const char *key) throw(ELuaNotATable) + void CLuaObject::eraseValue(const char *key) { nlassert(isValid()); nlassert(key); diff --git a/code/nel/src/gui/view_bitmap.cpp b/code/nel/src/gui/view_bitmap.cpp index b479cb889..79b8c32a4 100644 --- a/code/nel/src/gui/view_bitmap.cpp +++ b/code/nel/src/gui/view_bitmap.cpp @@ -21,6 +21,7 @@ #include "nel/gui/widget_manager.h" #include "nel/gui/interface_group.h" #include "nel/gui/group_container_base.h" +#include "nel/gui/group_html.h" using namespace std; using namespace NLMISC; @@ -452,7 +453,19 @@ namespace NLGUI // ---------------------------------------------------------------------------- void CViewBitmap::setTexture(const std::string & TxName) { - _TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false); + if (TxName.find("://") != string::npos || TxName.find("//") == 0) + { + CGroupHTML *groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:webig:content:html")); + if (groupHtml) { + string localname = groupHtml->localImageName(TxName); + if (!CFile::fileExists(localname)) + localname = "web_del.tga"; + _TextureId.setTexture (localname.c_str(), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false); + groupHtml->addImageDownload(TxName, dynamic_cast(this)); + } + } + else + _TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false); } // ---------------------------------------------------------------------------- diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp index 2faae3a0a..cfc2c3b92 100644 --- a/code/nel/src/gui/view_text.cpp +++ b/code/nel/src/gui/view_text.cpp @@ -72,6 +72,8 @@ namespace NLGUI _Shadow = false; _ShadowOutline = false; _ShadowColor = CRGBA(0,0,0,255); + _ShadowX = 1; + _ShadowY = 1; _MultiLine = false; _TextMode = DontClipWord; @@ -436,6 +438,22 @@ namespace NLGUI return true; } else + if( name == "shadow_x" ) + { + sint sx; + if( fromString( value, sx ) ) + _ShadowX = sx; + return true; + } + else + if( name == "shadow_y" ) + { + sint sy; + if( fromString( value, sy ) ) + _ShadowY = sy; + return true; + } + else if( name == "multi_line" ) { bool b; @@ -616,6 +634,8 @@ namespace NLGUI 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_color", BAD_CAST toString( _ShadowColor ).c_str() ); + xmlSetProp( node, BAD_CAST "shadow_x", BAD_CAST toString( _ShadowX ).c_str() ); + xmlSetProp( node, BAD_CAST "shadow_y", BAD_CAST toString( _ShadowY ).c_str() ); xmlSetProp( node, BAD_CAST "multi_line", BAD_CAST toString( _MultiLine ).c_str() ); std::string just; @@ -727,6 +747,16 @@ namespace NLGUI if (prop) _ShadowColor = convertColor(prop); + prop= (char*) xmlGetProp( cur, (xmlChar*)"shadow_x" ); + _ShadowX = 1; + if (prop) + fromString( (const char *)prop, _ShadowX); + + prop= (char*) xmlGetProp( cur, (xmlChar*)"shadow_y" ); + _ShadowY = 1; + if (prop) + fromString( (const char *)prop, _ShadowY); + prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_line" ); _MultiLine = false; if (prop) @@ -886,8 +916,8 @@ namespace NLGUI return _LineMaxW; else { - sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); - return std::min(parentWidth-(sint)(_XReal-_Parent->getXReal()), (sint)_LineMaxW); + sint offset = (sint)_XReal - (sint)_Parent->getXReal(); + return std::min(_Parent->getInnerWidth() - offset, (sint)_LineMaxW); } } @@ -955,6 +985,19 @@ namespace NLGUI ((_YReal) > (ClipY+ClipH)) || ((_YReal+_HReal) < ClipY)) return; + // hack: allow shadow to overflow outside parent box. + // In CGroupHTML context, clip is set for row + if (std::abs(_ShadowX) > 0) + { + ClipX -= 3; + ClipW += 3; + } + if (std::abs(_ShadowY) > 0) + { + ClipY -= 3; + ClipH += 3; + } + // *** Screen Minimized? uint32 w, h; float oow, ooh; @@ -992,6 +1035,7 @@ namespace NLGUI TextContext->setShaded (_Shadow); TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeColor (shcol); + TextContext->setShadeExtent (_ShadowX*oow, _ShadowY*ooh); TextContext->setFontSize (_FontSize); TextContext->setEmbolden (_Embolden); TextContext->setOblique (_Oblique); @@ -1119,6 +1163,7 @@ namespace NLGUI TextContext->setShaded (_Shadow); TextContext->setShadeOutline (_ShadowOutline); TextContext->setShadeColor (shcol); + TextContext->setShadeExtent (_ShadowX*oow, _ShadowY*ooh); TextContext->setFontSize (_FontSize); TextContext->setEmbolden (_Embolden); TextContext->setOblique (_Oblique); @@ -1339,6 +1384,13 @@ namespace NLGUI _ShadowColor = color; } + // *************************************************************************** + void CViewText::setShadowOffset(sint32 x, sint32 y) + { + _ShadowX = x; + _ShadowY = y; + } + // *************************************************************************** void CViewText::setLineMaxW (sint nMaxW, bool invalidate) { diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index 47bdf3886..7a3a38e70 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -1356,10 +1356,14 @@ bool CBitmap::decompressDXT1(bool alpha) { for(k=0; k<4; k++) { - dataTmp[m][pixelsCount + j*wtmp*4 + 4*k]= c[bits&3].R; - dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+1]= c[bits&3].G; - dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+2]= c[bits&3].B; - dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+3]= c[bits&3].A; + uint32 index = pixelsCount + (j*wtmp+k)*4; + // incase input image does not have proper width/height + if (index+3 > mipMapSz) break; + + dataTmp[m][index+0]= c[bits&3].R; + dataTmp[m][index+1]= c[bits&3].G; + dataTmp[m][index+2]= c[bits&3].B; + dataTmp[m][index+3]= c[bits&3].A; bits>>=2; } } @@ -1466,10 +1470,14 @@ bool CBitmap::decompressDXT3() { for(k=0; k<4; k++) { - dataTmp[m][pixelsCount + j*wtmp*4 + 4*k]= c[bits&3].R; - dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+1]= c[bits&3].G; - dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+2]= c[bits&3].B; - dataTmp[m][pixelsCount + j*wtmp*4 + 4*k+3]= alpha[4*j+k]; + uint32 index = pixelsCount + (j*wtmp+k)*4; + // incase input image does not have proper width/height + if (index+3 > mipMapSz) break; + + dataTmp[m][index+0]= c[bits&3].R; + dataTmp[m][index+1]= c[bits&3].G; + dataTmp[m][index+2]= c[bits&3].B; + dataTmp[m][index+3]= alpha[4*j+k]; bits>>=2; } } @@ -1602,10 +1610,14 @@ bool CBitmap::decompressDXT5() { for(k=0; k<4; k++) { - dataTmp[m][pixelsCount + (j*wtmp+k)*4 +0]= c[bits&3].R; - dataTmp[m][pixelsCount + (j*wtmp+k)*4 +1]= c[bits&3].G; - dataTmp[m][pixelsCount + (j*wtmp+k)*4 +2]= c[bits&3].B; - dataTmp[m][pixelsCount + (j*wtmp+k)*4 +3]= (uint8) alpha[codeAlpha[4*j+k]]; + uint32 index = pixelsCount + (j*wtmp+k)*4; + // incase input image does not have proper width/height + if (index+3 > mipMapSz) break; + + dataTmp[m][index+0]= c[bits&3].R; + dataTmp[m][index+1]= c[bits&3].G; + dataTmp[m][index+2]= c[bits&3].B; + dataTmp[m][index+3]= (uint8) alpha[codeAlpha[4*j+k]]; bits>>=2; } } diff --git a/code/nel/src/misc/class_registry.cpp b/code/nel/src/misc/class_registry.cpp index 91c603c90..c703e45d0 100644 --- a/code/nel/src/misc/class_registry.cpp +++ b/code/nel/src/misc/class_registry.cpp @@ -49,7 +49,7 @@ void CClassRegistry::release() } // ====================================================================================================== -IClassable *CClassRegistry::create(const string &className) throw(ERegistry) +IClassable *CClassRegistry::create(const string &className) { init(); @@ -72,7 +72,7 @@ IClassable *CClassRegistry::create(const string &className) throw(ERegistry) } // ====================================================================================================== -void CClassRegistry::registerClass(const string &className, IClassable* (*creator)(), const string &typeidCheck) throw(ERegistry) +void CClassRegistry::registerClass(const string &className, IClassable* (*creator)(), const string &typeidCheck) { init(); diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index db605f4f1..599f3cfb2 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -80,7 +80,7 @@ extern "C" long _ftol2( double dblSource ) { return _ftol( dblSource ); } #endif // !NL_COMP_MINGW -#if defined(NL_HAS_SSE2) && !defined(NL_CPU_X86_64) +#ifdef NL_USE_ALIGNED_MEMORY_OPERATORS #ifdef NL_NO_EXCEPTION_SPECS void *operator new(size_t size) diff --git a/code/nel/src/misc/file.cpp b/code/nel/src/misc/file.cpp index 727c02f83..414a10e5a 100644 --- a/code/nel/src/misc/file.cpp +++ b/code/nel/src/misc/file.cpp @@ -401,7 +401,7 @@ bool CIFile::eof () } // ====================================================================================================== -void CIFile::serialBuffer(uint8 *buf, uint len) throw(EReadError) +void CIFile::serialBuffer(uint8 *buf, uint len) { if (len == 0) return; @@ -444,7 +444,7 @@ void CIFile::serialBuffer(uint8 *buf, uint len) throw(EReadError) } // ====================================================================================================== -void CIFile::serialBit(bool &bit) throw(EReadError) +void CIFile::serialBit(bool &bit) { // Simple for now. uint8 v=bit; @@ -453,7 +453,7 @@ void CIFile::serialBit(bool &bit) throw(EReadError) } // ====================================================================================================== -bool CIFile::seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStream) +bool CIFile::seek (sint32 offset, IStream::TSeekOrigin origin) const { if ((_CacheFileOnOpen) && (_Cache == NULL)) return false; @@ -485,7 +485,7 @@ bool CIFile::seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStr } // ====================================================================================================== -sint32 CIFile::getPos () const throw(EStream) +sint32 CIFile::getPos () const { return _ReadPos; } @@ -652,7 +652,7 @@ void COFile::flush() // ====================================================================================================== -void COFile::serialBuffer(uint8 *buf, uint len) throw(EWriteError) +void COFile::serialBuffer(uint8 *buf, uint len) { if(!_F) throw EFileNotOpened(_FileName); @@ -667,14 +667,14 @@ void COFile::serialBuffer(uint8 *buf, uint len) throw(EWriteError) } } // ====================================================================================================== -void COFile::serialBit(bool &bit) throw(EWriteError) +void COFile::serialBit(bool &bit) { // Simple for now. uint8 v=bit; serialBuffer(&v, 1); } // ====================================================================================================== -bool COFile::seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStream) +bool COFile::seek (sint32 offset, IStream::TSeekOrigin origin) const { if (_F) { @@ -701,7 +701,7 @@ bool COFile::seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStr return false; } // ====================================================================================================== -sint32 COFile::getPos () const throw(EStream) +sint32 COFile::getPos () const { if (_F) { diff --git a/code/nel/src/misc/mem_stream.cpp b/code/nel/src/misc/mem_stream.cpp index 49e19f523..dd81334d1 100644 --- a/code/nel/src/misc/mem_stream.cpp +++ b/code/nel/src/misc/mem_stream.cpp @@ -107,7 +107,7 @@ void CMemStream::serialBit(bool &bit) * (to prevent from an "inside serial" to increment it). * Then a seek(end) would get back to the pointer. */ -bool CMemStream::seek (sint32 offset, TSeekOrigin origin) const throw(EStream) +bool CMemStream::seek (sint32 offset, TSeekOrigin origin) const { switch (origin) { diff --git a/code/nel/src/misc/string_mapper.cpp b/code/nel/src/misc/string_mapper.cpp index 6e59f7bab..39931efd2 100644 --- a/code/nel/src/misc/string_mapper.cpp +++ b/code/nel/src/misc/string_mapper.cpp @@ -211,7 +211,7 @@ void CStaticStringMapper::clear() } // **************************************************************************** -void CStaticStringMapper::serial(IStream &f, TSStringId &strId) throw(EStream) +void CStaticStringMapper::serial(IStream &f, TSStringId &strId) { std::string tmp; if (f.isReading()) @@ -227,7 +227,7 @@ void CStaticStringMapper::serial(IStream &f, TSStringId &strId) throw(EStream) } // **************************************************************************** -void CStaticStringMapper::serial(IStream &f, std::vector &strIdVect) throw(EStream) +void CStaticStringMapper::serial(IStream &f, std::vector &strIdVect) { std::vector vsTmp; std::string sTmp; diff --git a/code/nel/src/misc/system_info.cpp b/code/nel/src/misc/system_info.cpp index 2afa8da09..75d9707b3 100644 --- a/code/nel/src/misc/system_info.cpp +++ b/code/nel/src/misc/system_info.cpp @@ -1470,9 +1470,9 @@ uint64 CSystemInfo::availableHDSpace (const string &filename) uint64 CSystemInfo::availablePhysicalMemory () { #ifdef NL_OS_WINDOWS - MEMORYSTATUS ms; - GlobalMemoryStatus (&ms); - return uint64(ms.dwAvailPhys); + MEMORYSTATUSEX ms; + GlobalMemoryStatusEx(&ms); + return ms.ullAvailPhys; #elif defined NL_OS_MAC return uint64(getsysctlnum64("hw.usermem")); #elif defined NL_OS_UNIX @@ -1485,9 +1485,9 @@ uint64 CSystemInfo::availablePhysicalMemory () uint64 CSystemInfo::totalPhysicalMemory () { #ifdef NL_OS_WINDOWS - MEMORYSTATUS ms; - GlobalMemoryStatus (&ms); - return uint64(ms.dwTotalPhys); + MEMORYSTATUSEX ms; + GlobalMemoryStatusEx(&ms); + return ms.ullTotalPhys; #elif defined NL_OS_MAC return uint64(getsysctlnum64("hw.physmem")); #elif defined NL_OS_UNIX @@ -1867,9 +1867,9 @@ bool CSystemInfo::getVideoInfo (std::string &deviceName, uint64 &driverVersion) uint64 CSystemInfo::virtualMemory () { #ifdef NL_OS_WINDOWS - MEMORYSTATUS ms; - GlobalMemoryStatus (&ms); - return uint64(ms.dwTotalVirtual - ms.dwAvailVirtual); + MEMORYSTATUSEX ms; + GlobalMemoryStatusEx(&ms); + return ms.ullTotalVirtual - ms.ullAvailVirtual; #else return 0; #endif diff --git a/code/nel/src/net/module.cpp b/code/nel/src/net/module.cpp index 1b5e03bec..23f618973 100644 --- a/code/nel/src/net/module.cpp +++ b/code/nel/src/net/module.cpp @@ -397,7 +397,7 @@ namespace NLNET } - void CModuleBase::plugModule(IModuleSocket *moduleSocket) throw (EModuleAlreadyPluggedHere) + void CModuleBase::plugModule(IModuleSocket *moduleSocket) { CModuleSocket *sock = dynamic_cast(moduleSocket); nlassert(sock != NULL); @@ -415,7 +415,7 @@ namespace NLNET _ModuleSockets.insert(moduleSocket); } - void CModuleBase::unplugModule(IModuleSocket *moduleSocket) throw (EModuleNotPluggedHere) + void CModuleBase::unplugModule(IModuleSocket *moduleSocket) { CModuleSocket *sock = dynamic_cast(moduleSocket); nlassert(sock != NULL); @@ -443,7 +443,7 @@ namespace NLNET * The call is blocking until receptions of the operation * result message (or a module down) */ - void CModuleBase::invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) throw (EInvokeFailed) + void CModuleBase::invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) { H_AUTO(CModuleBase_invokeModuleOperation); @@ -867,7 +867,6 @@ namespace NLNET } void CModuleProxy::sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotReachable) { H_AUTO(CModuleProxy_sendModuleMessage); diff --git a/code/nel/src/net/module_gateway.cpp b/code/nel/src/net/module_gateway.cpp index 81ba76859..d4d07ea61 100644 --- a/code/nel/src/net/module_gateway.cpp +++ b/code/nel/src/net/module_gateway.cpp @@ -448,7 +448,6 @@ namespace NLNET /// Activate/stop firewalling mode on a transport virtual void setTransportFirewallMode(const std::string &transportInstanceName, bool firewalled) - throw (EGatewayFirewallBreak) { TTransportList::iterator it(_Transports.find(transportInstanceName)); if (it == _Transports.end()) @@ -1246,7 +1245,6 @@ namespace NLNET } virtual void discloseModule(IModuleProxy *moduleProxy) - throw (EGatewayNotConnected) { nlassert(moduleProxy->getModuleGateway() == this); @@ -1560,8 +1558,7 @@ namespace NLNET return getModuleName(); } - void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotReachable, EModuleNotPluggedHere) + void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) { // the socket implementation already checked that the module is plugged here // just check that the destination module effectively from here @@ -1585,7 +1582,6 @@ namespace NLNET } virtual void _broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotPluggedHere) { H_AUTO(CModuleGetaway__broadcastModuleMessage); // send the message to all proxies (except the sender module) diff --git a/code/nel/src/net/module_gateway_transport.cpp b/code/nel/src/net/module_gateway_transport.cpp index d9029285f..08ff51eeb 100644 --- a/code/nel/src/net/module_gateway_transport.cpp +++ b/code/nel/src/net/module_gateway_transport.cpp @@ -184,13 +184,13 @@ namespace NLNET } } - void onCommand(const CMessage &/* command */) throw (EInvalidCommand) + void onCommand(const CMessage &/* command */) { // nothing done for now throw EInvalidCommand(); } /// The gateway send a textual command to the transport - bool onCommand(const TParsedCommandLine &command) throw (EInvalidCommand) + bool onCommand(const TParsedCommandLine &command) { if (command.SubParams.size() < 1) throw EInvalidCommand(); @@ -218,7 +218,7 @@ namespace NLNET } /// Open the server by starting listing for incoming connection on the specified port - void openServer(uint16 port) throw (ETransportError) + void openServer(uint16 port) { if (_CallbackServer.get() != NULL) throw ETransportError("openServer : The server is already open"); @@ -607,13 +607,13 @@ namespace NLNET } } - void onCommand(const CMessage &/* command */) throw (EInvalidCommand) + void onCommand(const CMessage &/* command */) { // nothing done for now throw EInvalidCommand(); } /// The gateway send a textual command to the transport - bool onCommand(const TParsedCommandLine &command) throw (EInvalidCommand) + bool onCommand(const TParsedCommandLine &command) { if (command.SubParams.size() < 1) throw EInvalidCommand(); diff --git a/code/nel/src/net/module_l5_transport.cpp b/code/nel/src/net/module_l5_transport.cpp index 5eddabc9f..e902263c7 100644 --- a/code/nel/src/net/module_l5_transport.cpp +++ b/code/nel/src/net/module_l5_transport.cpp @@ -218,13 +218,13 @@ namespace NLNET } } - void onCommand(const CMessage &/* command */) throw (EInvalidCommand) + void onCommand(const CMessage &/* command */) { // nothing done for now throw EInvalidCommand(); } /// The gateway send a textual command to the transport - bool onCommand(const TParsedCommandLine &command) throw (EInvalidCommand) + bool onCommand(const TParsedCommandLine &command) { if (command.SubParams.size() < 1) throw EInvalidCommand(); @@ -255,7 +255,7 @@ namespace NLNET /// Open the server by establishing route with all known services - void open(const std::string &subNetName) throw (ETransportError) + void open(const std::string &subNetName) { H_AUTO(L5_open); diff --git a/code/nel/src/net/module_local_gateway.cpp b/code/nel/src/net/module_local_gateway.cpp index 3446c0663..0782c2d2c 100644 --- a/code/nel/src/net/module_local_gateway.cpp +++ b/code/nel/src/net/module_local_gateway.cpp @@ -102,7 +102,6 @@ namespace NLNET /// Activate/stop firewalling mode on a transport virtual void setTransportFirewallMode(const std::string &/* transportInstanceName */, bool /* firewalled */) - throw (EGatewayFirewallBreak) { // unsupported nlstop; @@ -174,12 +173,10 @@ namespace NLNET // return; // } // virtual void openGatewayServer(uint16 listeningPort) -// throw (EGatewayAlreadyOpen, EGatewayPortInUse) // { // nlstop; // } // virtual void closeGatewayServer() -// throw (EGatewayNotOpen) // { // nlstop; // } @@ -233,7 +230,6 @@ namespace NLNET { } virtual void discloseModule(IModuleProxy *moduleProxy) - throw (EGatewayNotConnected) { // check that the module is plugged here nlassert(_ModuleProxies.getB(moduleProxy) != NULL); @@ -364,8 +360,7 @@ namespace NLNET return getModuleName(); } - void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotReachable, EModuleNotPluggedHere) + void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) { TModuleProxies::TAToBMap::const_iterator first(_ModuleProxies.getAToBMap().begin()), last(_ModuleProxies.getAToBMap().end()); for (; first != last && first->first->getModuleProxyId() != destModuleProxyId; ++first) {} @@ -373,7 +368,6 @@ namespace NLNET throw EModuleNotReachable(); } virtual void _broadcastModuleMessage(IModule * /* senderModule */, const NLNET::CMessage &/* message */) - throw (EModuleNotPluggedHere) { nlstop; } diff --git a/code/nel/src/net/module_socket.cpp b/code/nel/src/net/module_socket.cpp index 068567761..6ea16e8d6 100644 --- a/code/nel/src/net/module_socket.cpp +++ b/code/nel/src/net/module_socket.cpp @@ -85,8 +85,7 @@ namespace NLNET _PluggedModules.removeWithB(pluggedModule); } - void CModuleSocket::sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message ) - throw (EModuleNotPluggedHere) + void CModuleSocket::sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) { TPluggedModules::TBToAMap::const_iterator it(_PluggedModules.getBToAMap().find(senderModule)); if (it == _PluggedModules.getBToAMap().end()) @@ -100,7 +99,6 @@ namespace NLNET } void CModuleSocket::broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) - throw (EModuleNotPluggedHere) { TPluggedModules::TBToAMap::const_iterator it(_PluggedModules.getBToAMap().find(senderModule)); if (it == _PluggedModules.getBToAMap().end()) diff --git a/code/nel/tools/3d/object_viewer/particle_workspace.cpp b/code/nel/tools/3d/object_viewer/particle_workspace.cpp index 43be30812..1a289d2b0 100644 --- a/code/nel/tools/3d/object_viewer/particle_workspace.cpp +++ b/code/nel/tools/3d/object_viewer/particle_workspace.cpp @@ -357,7 +357,7 @@ void CParticleWorkspace::setName(const std::string &name) //*********************************************************************************************** -CParticleWorkspace::CNode *CParticleWorkspace::addNode(const std::string &filenameWithFullPath) throw( NLMISC::EStream) +CParticleWorkspace::CNode *CParticleWorkspace::addNode(const std::string &filenameWithFullPath) { nlassert(_OV); // Check that file is not already inserted diff --git a/code/nel/tools/3d/object_viewer/particle_workspace.h b/code/nel/tools/3d/object_viewer/particle_workspace.h index 694aab986..3508746d5 100644 --- a/code/nel/tools/3d/object_viewer/particle_workspace.h +++ b/code/nel/tools/3d/object_viewer/particle_workspace.h @@ -186,7 +186,7 @@ public: * * \return pointer to new node, or NULL if already inserted */ - CNode *addNode(const std::string &filenameWithFullPath) throw( NLMISC::Exception); + CNode *addNode(const std::string &filenameWithFullPath); // remove a node by its index void removeNode(uint index); // remove a node by its pointer diff --git a/code/nel/tools/pacs/build_rbank/build_surf.cpp b/code/nel/tools/pacs/build_rbank/build_surf.cpp index 7e873f15f..465f5f94f 100644 --- a/code/nel/tools/pacs/build_rbank/build_surf.cpp +++ b/code/nel/tools/pacs/build_rbank/build_surf.cpp @@ -671,7 +671,7 @@ bool NLPACS::CComputableSurface::checkConsistency() CComputableSurfaceBorder& border = (*BorderKeeper)[BorderIds[i]]; for (j=0; j+1(border.Vertices[j], border.Vertices[j+1])); + edges.push_back(std::make_pair(border.Vertices[j], border.Vertices[j+1])); } for (i=0; i+1 + + - - - + w="380" + onenter="" + title="uiGuildDescWarning" + tooltip="uiGuildDescWarning" /> + + + + - + posref="BL BL" + x="150" + y="15" /> + + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/game_context_menu.xml b/code/ryzom/client/data/gamedev/interfaces_v3/game_context_menu.xml index 14ef15b80..25fd8b202 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/game_context_menu.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/game_context_menu.xml @@ -97,7 +97,6 @@ - @@ -107,6 +106,9 @@ + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml b/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml index bff52b123..6d7ac1fa7 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/login_widgets.xml @@ -63,7 +63,7 @@ - -