Merge with develop

--HG--
branch : feature-light_cycle
hg/feature/light_cycle
kaetemi 10 years ago
commit 8e5a515968

@ -14,6 +14,8 @@
**.font = native **.font = native
**.scheme = native **.scheme = native
**.tpl = native
**.xsd = native **.xsd = native
**.dox = native **.dox = native

@ -5,3 +5,6 @@
fedf2aa443d09707beed814b0f499c6a5519cc84 ryzomcore/v0.10.0 fedf2aa443d09707beed814b0f499c6a5519cc84 ryzomcore/v0.10.0
edaa3624a56420b02ccc64c26059801a389927ee ryzomcore/v0.11.0 edaa3624a56420b02ccc64c26059801a389927ee ryzomcore/v0.11.0
e3fe4855f22c3e75722e015dc33c091c340b3ad7 ryzomcore/v0.11.1 e3fe4855f22c3e75722e015dc33c091c340b3ad7 ryzomcore/v0.11.1
9e583b717fd63be0be9fd60b99087abf1691ea49 ryzomcore/v0.11.2
bfe5628e14a024ba7ea32e4b326ae433a07856b9 ryzomcore/v0.11.3
9a6120735daa97c96ac5d85ca35c7f21f607bd87 ryzomcore/v0.12.0

@ -1,8 +1,8 @@
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #
# NeL # Ryzom Core
# Authors: Nevrax and the NeL Community # Authors: Nevrax and the Ryzom Core Community
# Version: 0.11.1 # Version: 0.12.0
# #
# Notes: # Notes:
# * Changing install location: add -DCMAKE_INSTALL_PREFIX:PATH=/my/new/path # * Changing install location: add -DCMAKE_INSTALL_PREFIX:PATH=/my/new/path
@ -47,8 +47,8 @@ CHECK_OUT_OF_SOURCE()
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(RyzomCore CXX C) PROJECT(RyzomCore CXX C)
SET(NL_VERSION_MAJOR 0) SET(NL_VERSION_MAJOR 0)
SET(NL_VERSION_MINOR 11) SET(NL_VERSION_MINOR 12)
SET(NL_VERSION_PATCH 1) SET(NL_VERSION_PATCH 0)
SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}") SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}")
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@ -112,16 +112,20 @@ IF(WITH_STATIC_LIBXML2)
SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC) SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC)
ENDIF(WITH_STATIC_LIBXML2) ENDIF(WITH_STATIC_LIBXML2)
IF(WITH_LIBXML2_ICONV)
FIND_PACKAGE(Iconv REQUIRED)
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES})
ENDIF(WITH_LIBXML2_ICONV)
IF(WITH_STATIC) IF(WITH_STATIC)
# libxml2 could need winsock2 library # libxml2 could need winsock2 library
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB}) SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB})
# on Mac OS X libxml2 requires iconv and liblzma # on Mac OS X libxml2 requires iconv and liblzma
IF(APPLE) IF(APPLE)
FIND_PACKAGE(Iconv REQUIRED)
FIND_PACKAGE(LibLZMA REQUIRED) FIND_PACKAGE(LibLZMA REQUIRED)
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES} ${LIBLZMA_LIBRARIES}) SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${LIBLZMA_LIBRARIES})
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
ENDIF(APPLE) ENDIF(APPLE)
ENDIF(WITH_STATIC) ENDIF(WITH_STATIC)
@ -152,9 +156,11 @@ IF(WITH_NEL)
FIND_PACKAGE(Luabind REQUIRED) FIND_PACKAGE(Luabind REQUIRED)
FIND_PACKAGE(CURL REQUIRED) FIND_PACKAGE(CURL REQUIRED)
IF(WIN32 OR CURL_LIBRARIES MATCHES "\\.a") IF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
SET(CURL_STATIC ON) SET(CURL_STATIC ON)
ENDIF(WIN32 OR CURL_LIBRARIES MATCHES "\\.a") ELSE((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
SET(CURL_STATIC OFF)
ENDIF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
IF(CURL_STATIC) IF(CURL_STATIC)
SET(CURL_DEFINITIONS -DCURL_STATICLIB) SET(CURL_DEFINITIONS -DCURL_STATICLIB)
@ -228,30 +234,31 @@ IF(WITH_NEL_TESTS)
ENDIF(WITH_NEL_TESTS) ENDIF(WITH_NEL_TESTS)
# packaging information # packaging information
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NeL MMORPG Framework") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ryzom Core MMORPG Framework")
SET(CPACK_PACKAGE_VENDOR "NeL") SET(CPACK_PACKAGE_VENDOR "Ryzom Core")
SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README) SET(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README)
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING) SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING)
SET(CPACK_PACKAGE_VERSION_MAJOR "${NL_VERSION_MAJOR}") SET(CPACK_PACKAGE_VERSION_MAJOR "${NL_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${NL_VERSION_MINOR}") SET(CPACK_PACKAGE_VERSION_MINOR "${NL_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${NL_VERSION_PATCH}") SET(CPACK_PACKAGE_VERSION_PATCH "${NL_VERSION_PATCH}")
SET(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR};NeL;ALL;/") SET(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR};NeL;ALL;/")
SET(CPACK_PACKAGE_EXECUTABLES "nel${NL_VERSION}" "nel") SET(CPACK_PACKAGE_EXECUTABLES "ryzomcore${NL_VERSION}" "ryzomcore")
SET(CPACK_SET_DESTDIR TRUE)
# NSIS Specific Packing Setup # NSIS Specific Packing Setup
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "NeL") SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "RyzomCore")
SET(CPACK_NSIS_MODIFY_PATH "ON") SET(CPACK_NSIS_MODIFY_PATH "ON")
SET(CPACK_NSIS_MUI_ICON ${CMAKE_SOURCE_DIR}/resources/nevraxpill.ico) SET(CPACK_NSIS_MUI_ICON ${CMAKE_SOURCE_DIR}/resources/nevraxpill.ico)
SET(CPACK_NSIS_MUI_UNIICON ${CMAKE_SOURCE_DIR}/resources/nevraxpill.ico) SET(CPACK_NSIS_MUI_UNIICON ${CMAKE_SOURCE_DIR}/resources/nevraxpill.ico)
SET(CPACK_PACKAGE_ICON ${CMAKE_SOURCE_DIR}/resources\\\\nel.bmp) SET(CPACK_PACKAGE_ICON ${CMAKE_SOURCE_DIR}/resources\\\\nel.bmp)
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} NeL") SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} RyzomCore")
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\dev.ryzom.com") SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\dev.ryzom.com")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\dev.ryzom.com\\\\projects\\\\nel\\\\wiki") SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\dev.ryzom.com\\\\projects\\\\nel\\\\wiki")
SET(CPACK_NSIS_CONTACT "matt.raykowski@gmail.com") SET(CPACK_NSIS_CONTACT "matt.raykowski@gmail.com")
## Source Packages ## Source Packages
SET(CPACK_PACKAGE_FILE_NAME "nel-${NL_VERSION}") SET(CPACK_PACKAGE_FILE_NAME "ryzomcore-${NL_VERSION}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "nel-${NL_VERSION}") SET(CPACK_SOURCE_PACKAGE_FILE_NAME "ryzomcore-${NL_VERSION}")
IF(WIN32) IF(WIN32)
#SET(CPACK_GENERATOR "NSIS") #SET(CPACK_GENERATOR "NSIS")
SET(CPACK_GENERATOR "NSIS;ZIP") SET(CPACK_GENERATOR "NSIS;ZIP")

@ -26,63 +26,46 @@ IF(TARGET_CPU STREQUAL "armv7")
SET(LIBRARY_ARCHITECTURE "armeabi-v7a") SET(LIBRARY_ARCHITECTURE "armeabi-v7a")
SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(CMAKE_SYSTEM_PROCESSOR "armv7")
SET(TOOLCHAIN_ARCH "arm") SET(TOOLCHAIN_ARCH "arm")
SET(TOOLCHAIN_PREFIX "arm-linux-androideabi") SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi")
SET(TOOLCHAIN_BIN_PREFIX "arm") SET(TOOLCHAIN_BIN_PREFIX "arm")
SET(MINIMUM_NDK_TARGET 4) SET(MINIMUM_NDK_TARGET 4)
ELSEIF(TARGET_CPU STREQUAL "armv5") ELSEIF(TARGET_CPU STREQUAL "armv5")
SET(LIBRARY_ARCHITECTURE "armeabi") SET(LIBRARY_ARCHITECTURE "armeabi")
SET(CMAKE_SYSTEM_PROCESSOR "armv5") SET(CMAKE_SYSTEM_PROCESSOR "armv5")
SET(TOOLCHAIN_ARCH "arm") SET(TOOLCHAIN_ARCH "arm")
SET(TOOLCHAIN_PREFIX "arm-linux-androideabi") SET(GCC_TOOLCHAIN_PREFIX "arm-linux-androideabi")
SET(TOOLCHAIN_BIN_PREFIX "arm") SET(TOOLCHAIN_BIN_PREFIX "arm")
SET(MINIMUM_NDK_TARGET 4) SET(MINIMUM_NDK_TARGET 4)
ELSEIF(TARGET_CPU STREQUAL "x86") ELSEIF(TARGET_CPU STREQUAL "x86")
SET(LIBRARY_ARCHITECTURE "x86") SET(LIBRARY_ARCHITECTURE "x86")
SET(CMAKE_SYSTEM_PROCESSOR "x86") SET(CMAKE_SYSTEM_PROCESSOR "x86")
SET(TOOLCHAIN_ARCH "x86") SET(TOOLCHAIN_ARCH "x86")
SET(TOOLCHAIN_PREFIX "x86") SET(GCC_TOOLCHAIN_PREFIX "x86")
SET(TOOLCHAIN_BIN_PREFIX "i686") SET(TOOLCHAIN_BIN_PREFIX "i686")
SET(MINIMUM_NDK_TARGET 9) SET(MINIMUM_NDK_TARGET 9)
ELSEIF(TARGET_CPU STREQUAL "mips") ELSEIF(TARGET_CPU STREQUAL "mips")
SET(LIBRARY_ARCHITECTURE "mips") SET(LIBRARY_ARCHITECTURE "mips")
SET(CMAKE_SYSTEM_PROCESSOR "mips") SET(CMAKE_SYSTEM_PROCESSOR "mips")
SET(TOOLCHAIN_ARCH "mips") SET(TOOLCHAIN_ARCH "mips")
SET(TOOLCHAIN_PREFIX "mipsel-linux-android") SET(GCC_TOOLCHAIN_PREFIX "mipsel-linux-android")
SET(TOOLCHAIN_BIN_PREFIX "mipsel") SET(TOOLCHAIN_BIN_PREFIX "mipsel")
SET(MINIMUM_NDK_TARGET 9) SET(MINIMUM_NDK_TARGET 9)
ENDIF(TARGET_CPU STREQUAL "armv7") ENDIF(TARGET_CPU STREQUAL "armv7")
SET(ANDROID_COMPILER "GCC")
IF(NDK_TOOLCHAIN_VERSION STREQUAL "clang")
SET(ANDROID_COMPILER "clang")
SET(CLANG_TOOLCHAIN_PREFIX "llvm")
SET(CLANG ON)
ELSE()
SET(GCC_TOOLCHAIN_VERSION ${NDK_TOOLCHAIN_VERSION})
ENDIF()
IF(NOT NDK_TARGET) IF(NOT NDK_TARGET)
SET(NDK_TARGET ${MINIMUM_NDK_TARGET}) SET(NDK_TARGET ${MINIMUM_NDK_TARGET})
ENDIF(NOT NDK_TARGET) ENDIF(NOT NDK_TARGET)
FILE(GLOB _TOOLCHAIN_VERSIONS "${NDK_ROOT}/toolchains/${TOOLCHAIN_PREFIX}-*")
IF(_TOOLCHAIN_VERSIONS)
LIST(SORT _TOOLCHAIN_VERSIONS)
LIST(REVERSE _TOOLCHAIN_VERSIONS)
FOREACH(_TOOLCHAIN_VERSION ${_TOOLCHAIN_VERSIONS})
STRING(REGEX REPLACE ".+${TOOLCHAIN_PREFIX}-([0-9.]+)" "\\1" _TOOLCHAIN_VERSION "${_TOOLCHAIN_VERSION}")
IF(_TOOLCHAIN_VERSION MATCHES "^([0-9.]+)$")
LIST(APPEND NDK_TOOLCHAIN_VERSIONS ${_TOOLCHAIN_VERSION})
ENDIF(_TOOLCHAIN_VERSION MATCHES "^([0-9.]+)$")
ENDFOREACH(_TOOLCHAIN_VERSION)
ENDIF(_TOOLCHAIN_VERSIONS)
IF(NOT NDK_TOOLCHAIN_VERSIONS)
MESSAGE(FATAL_ERROR "No Android toolchain found in default search path ${NDK_ROOT}/toolchains")
ENDIF(NOT NDK_TOOLCHAIN_VERSIONS)
IF(NDK_TOOLCHAIN_VERSION)
LIST(FIND NDK_TOOLCHAIN_VERSIONS "${NDK_TOOLCHAIN_VERSION}" _INDEX)
IF(_INDEX EQUAL -1)
LIST(GET NDK_TOOLCHAIN_VERSIONS 0 NDK_TOOLCHAIN_VERSION)
ENDIF(_INDEX EQUAL -1)
ELSE(NDK_TOOLCHAIN_VERSION)
LIST(GET NDK_TOOLCHAIN_VERSIONS 0 NDK_TOOLCHAIN_VERSION)
ENDIF(NDK_TOOLCHAIN_VERSION)
MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use GCC ${NDK_TOOLCHAIN_VERSION}")
IF(CMAKE_HOST_WIN32) IF(CMAKE_HOST_WIN32)
SET(TOOLCHAIN_HOST "windows") SET(TOOLCHAIN_HOST "windows")
SET(TOOLCHAIN_BIN_SUFFIX ".exe") SET(TOOLCHAIN_BIN_SUFFIX ".exe")
@ -94,33 +77,73 @@ ELSEIF(CMAKE_HOST_UNIX)
SET(TOOLCHAIN_BIN_SUFFIX "") SET(TOOLCHAIN_BIN_SUFFIX "")
ENDIF(CMAKE_HOST_WIN32) ENDIF(CMAKE_HOST_WIN32)
SET(TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${TOOLCHAIN_PREFIX}-${NDK_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}") MACRO(SEARCH_TOOLCHAIN _COMPILER)
SET(PLATFORM_ROOT "${NDK_ROOT}/platforms/android-${NDK_TARGET}/arch-${TOOLCHAIN_ARCH}") SET(${_COMPILER}_TOOLCHAIN_VERSIONS)
FILE(GLOB _TOOLCHAIN_VERSIONS "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}-*")
IF(_TOOLCHAIN_VERSIONS)
LIST(SORT _TOOLCHAIN_VERSIONS)
LIST(REVERSE _TOOLCHAIN_VERSIONS)
FOREACH(_TOOLCHAIN_VERSION ${_TOOLCHAIN_VERSIONS})
STRING(REGEX REPLACE ".+${_PREFIX}-([0-9.]+)" "\\1" _TOOLCHAIN_VERSION "${_TOOLCHAIN_VERSION}")
IF(_TOOLCHAIN_VERSION MATCHES "^([0-9.]+)$")
LIST(APPEND ${_COMPILER}_TOOLCHAIN_VERSIONS ${_TOOLCHAIN_VERSION})
ENDIF()
ENDFOREACH()
ENDIF()
IF(NOT ${_COMPILER}_TOOLCHAIN_VERSIONS)
MESSAGE(FATAL_ERROR "No Android ${_COMPILER} toolchain found in default search path ${NDK_ROOT}/toolchains")
ENDIF()
IF(NOT EXISTS "${TOOLCHAIN_ROOT}") IF(${_COMPILER}_TOOLCHAIN_VERSIONS)
FILE(GLOB _TOOLCHAIN_PREFIXES "${TOOLCHAIN_ROOT}*") LIST(FIND ${_COMPILER}_TOOLCHAIN_VERSIONS "${${_COMPILER}_TOOLCHAIN_VERSION}" _INDEX)
IF(_INDEX EQUAL -1)
LIST(GET ${_COMPILER}_TOOLCHAIN_VERSIONS 0 ${_COMPILER}_TOOLCHAIN_VERSION)
ENDIF()
ELSE()
LIST(GET ${_COMPILER}_TOOLCHAIN_VERSIONS 0 ${_COMPILER}_TOOLCHAIN_VERSION)
ENDIF()
SET(${_COMPILER}_TOOLCHAIN_ROOT "${NDK_ROOT}/toolchains/${${_COMPILER}_TOOLCHAIN_PREFIX}-${${_COMPILER}_TOOLCHAIN_VERSION}/prebuilt/${TOOLCHAIN_HOST}")
IF(NOT EXISTS "${${_COMPILER}_TOOLCHAIN_ROOT}")
FILE(GLOB _TOOLCHAIN_PREFIXES "${${_COMPILER}_TOOLCHAIN_ROOT}*")
IF(_TOOLCHAIN_PREFIXES) IF(_TOOLCHAIN_PREFIXES)
LIST(GET _TOOLCHAIN_PREFIXES 0 TOOLCHAIN_ROOT) LIST(GET _TOOLCHAIN_PREFIXES 0 ${_COMPILER}_TOOLCHAIN_ROOT)
ENDIF(_TOOLCHAIN_PREFIXES) ENDIF(_TOOLCHAIN_PREFIXES)
ENDIF(NOT EXISTS "${TOOLCHAIN_ROOT}") ENDIF()
ENDMACRO()
IF(CLANG)
SEARCH_TOOLCHAIN(CLANG)
MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use clang ${CLANG_TOOLCHAIN_VERSION}")
ENDIF()
SEARCH_TOOLCHAIN(GCC)
MESSAGE(STATUS "Target Android NDK ${NDK_TARGET} and use GCC ${GCC_TOOLCHAIN_VERSION}")
MESSAGE(STATUS "Found Android LLVM toolchain in ${CLANG_TOOLCHAIN_ROOT}")
MESSAGE(STATUS "Found Android GCC toolchain in ${GCC_TOOLCHAIN_ROOT}")
SET(PLATFORM_ROOT "${NDK_ROOT}/platforms/android-${NDK_TARGET}/arch-${TOOLCHAIN_ARCH}")
MESSAGE(STATUS "Found Android toolchain in ${TOOLCHAIN_ROOT}")
MESSAGE(STATUS "Found Android platform in ${PLATFORM_ROOT}") MESSAGE(STATUS "Found Android platform in ${PLATFORM_ROOT}")
# include dirs # include dirs
SET(PLATFORM_INCLUDE_DIR "${PLATFORM_ROOT}/usr/include") SET(PLATFORM_INCLUDE_DIR "${PLATFORM_ROOT}/usr/include")
SET(STL_DIR "${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++") SET(STL_DIR "${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++")
IF(EXISTS "${STL_DIR}/${NDK_TOOLCHAIN_VERSION}") IF(EXISTS "${STL_DIR}/${GCC_TOOLCHAIN_VERSION}")
# NDK version >= 8b # NDK version >= 8b
SET(STL_DIR "${STL_DIR}/${NDK_TOOLCHAIN_VERSION}") SET(STL_DIR "${STL_DIR}/${GCC_TOOLCHAIN_VERSION}")
ENDIF(EXISTS "${STL_DIR}/${NDK_TOOLCHAIN_VERSION}") ENDIF(EXISTS "${STL_DIR}/${GCC_TOOLCHAIN_VERSION}")
# Determine bin prefix for toolchain # Determine bin prefix for toolchain
FILE(GLOB _TOOLCHAIN_BIN_PREFIXES "${TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-*-gcc${TOOLCHAIN_BIN_SUFFIX}") FILE(GLOB _TOOLCHAIN_BIN_PREFIXES "${GCC_TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-*-gcc${TOOLCHAIN_BIN_SUFFIX}")
IF(_TOOLCHAIN_BIN_PREFIXES) IF(_TOOLCHAIN_BIN_PREFIXES)
LIST(GET _TOOLCHAIN_BIN_PREFIXES 0 _TOOLCHAIN_BIN_PREFIX) LIST(GET _TOOLCHAIN_BIN_PREFIXES 0 _TOOLCHAIN_BIN_PREFIX)
STRING(REGEX REPLACE "${TOOLCHAIN_ROOT}/bin/([a-z0-9-]+)-gcc${TOOLCHAIN_BIN_SUFFIX}" "\\1" TOOLCHAIN_BIN_PREFIX "${_TOOLCHAIN_BIN_PREFIX}") STRING(REGEX REPLACE "${GCC_TOOLCHAIN_ROOT}/bin/([a-z0-9-]+)-gcc${TOOLCHAIN_BIN_SUFFIX}" "\\1" TOOLCHAIN_BIN_PREFIX "${_TOOLCHAIN_BIN_PREFIX}")
ENDIF(_TOOLCHAIN_BIN_PREFIXES) ENDIF(_TOOLCHAIN_BIN_PREFIXES)
SET(STL_INCLUDE_DIR "${STL_DIR}/include") SET(STL_INCLUDE_DIR "${STL_DIR}/include")
@ -128,22 +151,48 @@ SET(STL_LIBRARY_DIR "${STL_DIR}/libs/${LIBRARY_ARCHITECTURE}")
SET(STL_INCLUDE_CPU_DIR "${STL_LIBRARY_DIR}/include") SET(STL_INCLUDE_CPU_DIR "${STL_LIBRARY_DIR}/include")
SET(STL_LIBRARY "${STL_LIBRARY_DIR}/libgnustl_static.a") SET(STL_LIBRARY "${STL_LIBRARY_DIR}/libgnustl_static.a")
SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_ROOT} ${PLATFORM_ROOT}/usr ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} $ENV{EXTERNAL_ANDROID_PATH} CACHE string "Android find search path root") MESSAGE(STATUS "STL include dir: ${STL_INCLUDE_DIR}")
MESSAGE(STATUS "STL library dir: ${STL_LIBRARY_DIR}")
SET(CMAKE_FIND_ROOT_PATH ${CLANG_TOOLCHAIN_ROOT} ${GCC_TOOLCHAIN_ROOT} ${PLATFORM_ROOT}/usr ${CMAKE_PREFIX_PATH} ${CMAKE_INSTALL_PREFIX} $ENV{EXTERNAL_ANDROID_PATH} CACHE string "Android find search path root")
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
INCLUDE_DIRECTORIES(${STL_INCLUDE_DIR} ${STL_INCLUDE_CPU_DIR})
MACRO(SET_TOOLCHAIN_BINARY _NAME _BINARY) MACRO(SET_TOOLCHAIN_BINARY _NAME _BINARY)
SET(${_NAME} ${TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-${_BINARY}${TOOLCHAIN_BIN_SUFFIX}) IF("${_BINARY}" MATCHES "clang")
SET(${_NAME} ${CLANG_TOOLCHAIN_ROOT}/bin/${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE )
ELSE()
SET(${_NAME} ${GCC_TOOLCHAIN_ROOT}/bin/${TOOLCHAIN_BIN_PREFIX}-${_BINARY}${TOOLCHAIN_BIN_SUFFIX} CACHE PATH "" FORCE)
ENDIF()
ENDMACRO(SET_TOOLCHAIN_BINARY) ENDMACRO(SET_TOOLCHAIN_BINARY)
# Force the compilers to GCC for Android
include (CMakeForceCompiler)
IF(CLANG)
SET_TOOLCHAIN_BINARY(CMAKE_C_COMPILER clang)
SET_TOOLCHAIN_BINARY(CMAKE_CXX_COMPILER clang++)
CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} clang)
CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} clang)
MESSAGE(STATUS "Using clang compiler")
ELSE()
SET_TOOLCHAIN_BINARY(CMAKE_C_COMPILER gcc) SET_TOOLCHAIN_BINARY(CMAKE_C_COMPILER gcc)
SET_TOOLCHAIN_BINARY(CMAKE_CXX_COMPILER g++) SET_TOOLCHAIN_BINARY(CMAKE_CXX_COMPILER g++)
# Force the compilers to GCC for Android
include (CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} GNU) CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} GNU)
CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} GNU) CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} GNU)
MESSAGE(STATUS "Using GCC compiler")
ENDIF()
SET_TOOLCHAIN_BINARY(CMAKE_STRIP strip)
SET_TOOLCHAIN_BINARY(CMAKE_AR ar)
SET_TOOLCHAIN_BINARY(CMAKE_LINKER ld)
SET_TOOLCHAIN_BINARY(CMAKE_NM nm)
SET_TOOLCHAIN_BINARY(CMAKE_OBJCOPY objcopy)
SET_TOOLCHAIN_BINARY(CMAKE_OBJDUMP objdump)
SET_TOOLCHAIN_BINARY(CMAKE_RANLIB ranlib)

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

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

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

@ -57,13 +57,15 @@ ENDMACRO(DETECT_EXPRESS_VERSION)
IF(MSVC12) IF(MSVC12)
DETECT_VC_VERSION("12.0") DETECT_VC_VERSION("12.0")
SET(MSVC_TOOLSET "120")
IF(NOT MSVC12_REDIST_DIR) IF(NOT MSVC12_REDIST_DIR)
# If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist # If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC12_REDIST_DIR "${EXTERNAL_PATH}/redist") SET(MSVC12_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC11_REDIST_DIR) ENDIF(NOT MSVC12_REDIST_DIR)
ELSEIF(MSVC11) ELSEIF(MSVC11)
DETECT_VC_VERSION("11.0") DETECT_VC_VERSION("11.0")
SET(MSVC_TOOLSET "110")
IF(NOT MSVC11_REDIST_DIR) IF(NOT MSVC11_REDIST_DIR)
# If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist # If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist
@ -71,6 +73,7 @@ ELSEIF(MSVC11)
ENDIF(NOT MSVC11_REDIST_DIR) ENDIF(NOT MSVC11_REDIST_DIR)
ELSEIF(MSVC10) ELSEIF(MSVC10)
DETECT_VC_VERSION("10.0") DETECT_VC_VERSION("10.0")
SET(MSVC_TOOLSET "100")
IF(NOT MSVC10_REDIST_DIR) IF(NOT MSVC10_REDIST_DIR)
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist # If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
@ -78,8 +81,10 @@ ELSEIF(MSVC10)
ENDIF(NOT MSVC10_REDIST_DIR) ENDIF(NOT MSVC10_REDIST_DIR)
ELSEIF(MSVC90) ELSEIF(MSVC90)
DETECT_VC_VERSION("9.0") DETECT_VC_VERSION("9.0")
SET(MSVC_TOOLSET "90")
ELSEIF(MSVC80) ELSEIF(MSVC80)
DETECT_VC_VERSION("8.0") DETECT_VC_VERSION("8.0")
SET(MSVC_TOOLSET "80")
ENDIF(MSVC12) ENDIF(MSVC12)
# If you plan to use VC++ compilers with WINE, set VC_DIR environment variable # If you plan to use VC++ compilers with WINE, set VC_DIR environment variable

@ -13,7 +13,7 @@
IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
SET(MYSQL_FOUND TRUE) SET(MYSQL_FOUND TRUE)
ELSE(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) ELSE()
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
PATH_SUFFIXES mysql PATH_SUFFIXES mysql
@ -33,7 +33,7 @@ ELSE(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
PATHS PATHS
$ENV{ProgramFiles}/MySQL/*/lib/opt $ENV{ProgramFiles}/MySQL/*/lib/opt
$ENV{SystemDrive}/MySQL/*/lib/opt) $ENV{SystemDrive}/MySQL/*/lib/opt)
ELSE(WIN32 AND MSVC) ELSE()
FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient
PATHS PATHS
/usr/lib /usr/lib
@ -51,31 +51,30 @@ ELSE(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
/usr/local/lib/mysql /usr/local/lib/mysql
/opt/local/lib/mysql5/mysql /opt/local/lib/mysql5/mysql
) )
ENDIF(WIN32 AND MSVC) ENDIF()
IF(MYSQL_INCLUDE_DIR) IF(MYSQL_INCLUDE_DIR)
IF(MYSQL_LIBRARY_RELEASE) IF(MYSQL_LIBRARY_RELEASE)
SET(MYSQL_LIBRARIES optimized ${MYSQL_LIBRARY_RELEASE})
IF(MYSQL_LIBRARY_DEBUG) IF(MYSQL_LIBRARY_DEBUG)
SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} debug ${MYSQL_LIBRARY_DEBUG}) SET(MYSQL_LIBRARIES optimized ${MYSQL_LIBRARY_RELEASE} debug ${MYSQL_LIBRARY_DEBUG})
ELSE(MYSQL_LIBRARY_DEBUG) ELSE()
SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} debug ${MYSQL_LIBRARY_RELEASE}) SET(MYSQL_LIBRARIES ${MYSQL_LIBRARY_RELEASE})
ENDIF(MYSQL_LIBRARY_DEBUG) ENDIF()
FIND_PACKAGE(OpenSSL) FIND_PACKAGE(OpenSSL)
IF(OPENSSL_FOUND) IF(OPENSSL_FOUND)
SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} ${OPENSSL_LIBRARIES}) SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} ${OPENSSL_LIBRARIES})
ENDIF(OPENSSL_FOUND) ENDIF()
ENDIF(MYSQL_LIBRARY_RELEASE) ENDIF()
ENDIF(MYSQL_INCLUDE_DIR) ENDIF()
IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
SET(MYSQL_FOUND TRUE) SET(MYSQL_FOUND TRUE)
MESSAGE(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}") MESSAGE(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}")
ELSE(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) ELSE()
SET(MYSQL_FOUND FALSE) SET(MYSQL_FOUND FALSE)
MESSAGE(STATUS "MySQL not found.") MESSAGE(STATUS "MySQL not found.")
ENDIF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) ENDIF()
MARK_AS_ADVANCED(MYSQL_LIBRARY_RELEASE MYSQL_LIBRARY_DEBUG) MARK_AS_ADVANCED(MYSQL_LIBRARY_RELEASE MYSQL_LIBRARY_DEBUG)
ENDIF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) ENDIF()

@ -55,10 +55,12 @@ FIND_LIBRARY(SQUISH_LIBRARY_DEBUG
IF(SQUISH_INCLUDE_DIR) IF(SQUISH_INCLUDE_DIR)
IF(SQUISH_LIBRARY_RELEASE) IF(SQUISH_LIBRARY_RELEASE)
SET(SQUISH_FOUND "YES") SET(SQUISH_FOUND "YES")
SET(SQUISH_LIBRARIES "optimized;${SQUISH_LIBRARY_RELEASE}") SET(SQUISH_LIBRARIES "optimized;${SQUISH_LIBRARY_RELEASE}")
IF(SQUISH_LIBRARY_DEBUG) IF(SQUISH_LIBRARY_DEBUG)
SET(SQUISH_LIBRARIES "${SQUISH_LIBRARIES};debug;${SQUISH_LIBRARY_DEBUG}") SET(SQUISH_LIBRARIES "${SQUISH_LIBRARIES};debug;${SQUISH_LIBRARY_DEBUG}")
ELSE(SQUISH_LIBRARY_DEBUG)
SET(SQUISH_LIBRARIES "${SQUISH_LIBRARIES};debug;${SQUISH_LIBRARY_RELEASE}")
MESSAGE("Debug Squish NOT found, using the release version!")
ENDIF(SQUISH_LIBRARY_DEBUG) ENDIF(SQUISH_LIBRARY_DEBUG)
ENDIF(SQUISH_LIBRARY_RELEASE) ENDIF(SQUISH_LIBRARY_RELEASE)
ENDIF(SQUISH_INCLUDE_DIR) ENDIF(SQUISH_INCLUDE_DIR)

@ -68,6 +68,10 @@ ENDIF(WINSDKCURRENT_VERSION_INCLUDE)
SET(WINSDKENV_DIR $ENV{WINSDK_DIR}) SET(WINSDKENV_DIR $ENV{WINSDK_DIR})
IF(NOT WINSDKENV_DIR)
SET(WINSDKENV_DIR $ENV{WindowsSDKDir})
ENDIF(NOT WINSDKENV_DIR)
MACRO(FIND_WINSDK_VERSION_HEADERS) MACRO(FIND_WINSDK_VERSION_HEADERS)
IF(WINSDK_DIR AND NOT WINSDK_VERSION) IF(WINSDK_DIR AND NOT WINSDK_VERSION)
# Search version in headers # Search version in headers
@ -78,7 +82,6 @@ MACRO(FIND_WINSDK_VERSION_HEADERS)
) )
IF(_MSI_FILE) IF(_MSI_FILE)
# Look for Windows SDK 8.0 # Look for Windows SDK 8.0
FILE(STRINGS ${_MSI_FILE} _CONTENT REGEX "^#ifndef NTDDI_WIN8") FILE(STRINGS ${_MSI_FILE} _CONTENT REGEX "^#ifndef NTDDI_WIN8")
@ -181,7 +184,7 @@ MACRO(USE_CURRENT_WINSDK)
# Look for Windows.h because there are several paths # Look for Windows.h because there are several paths
IF(EXISTS ${_INCLUDE}/Windows.h) IF(EXISTS ${_INCLUDE}/Windows.h)
STRING(REGEX REPLACE "/(include|INCLUDE|Include)(.*)" "" WINSDK_DIR ${_INCLUDE}) STRING(REGEX REPLACE "/(include|INCLUDE|Include)(.*)" "" WINSDK_DIR ${_INCLUDE})
MESSAGE(STATUS "Found Windows SDK from include environment variable in ${WINSDK_DIR}") MESSAGE(STATUS "Found Windows SDK in INCLUDE environment variable: ${WINSDK_DIR}")
BREAK() BREAK()
ENDIF(EXISTS ${_INCLUDE}/Windows.h) ENDIF(EXISTS ${_INCLUDE}/Windows.h)
ENDFOREACH(_INCLUDE) ENDFOREACH(_INCLUDE)
@ -280,6 +283,13 @@ FIND_PATH(WINSDK_SHARED_INCLUDE_DIR d3d9.h
${WINSDK_DIR}/Include ${WINSDK_DIR}/Include
) )
# directory where OpenGL headers are found
FIND_PATH(WINSDK_OPENGL_INCLUDE_DIR GL.h
HINTS
${WINSDK_DIR}/Include/gl
${WINSDK_DIR}/Include
)
# directory where all libraries are found # directory where all libraries are found
FIND_PATH(WINSDK_LIBRARY_DIR ComCtl32.lib FIND_PATH(WINSDK_LIBRARY_DIR ComCtl32.lib
HINTS HINTS
@ -303,7 +313,7 @@ FIND_PROGRAM(WINSDK_MIDL midl
IF(WINSDK_INCLUDE_DIR) IF(WINSDK_INCLUDE_DIR)
SET(WINSDK_FOUND ON) SET(WINSDK_FOUND ON)
SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIR} ${WINSDK_SHARED_INCLUDE_DIR}) SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIR} ${WINSDK_SHARED_INCLUDE_DIR} ${WINSDK_OPENGL_INCLUDE_DIR})
SET(CMAKE_LIBRARY_PATH ${WINSDK_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH}) SET(CMAKE_LIBRARY_PATH ${WINSDK_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH})
INCLUDE_DIRECTORIES(${WINSDK_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${WINSDK_INCLUDE_DIRS})

@ -13,38 +13,44 @@ IF(SOURCE_DIR)
IF(NOT ROOT_DIR AND SOURCE_DIR) IF(NOT ROOT_DIR AND SOURCE_DIR)
SET(ROOT_DIR ${SOURCE_DIR}) SET(ROOT_DIR ${SOURCE_DIR})
ENDIF(NOT ROOT_DIR AND SOURCE_DIR) ENDIF()
IF(NOT SOURCE_DIR AND ROOT_DIR) IF(NOT SOURCE_DIR AND ROOT_DIR)
SET(SOURCE_DIR ${ROOT_DIR}) SET(SOURCE_DIR ${ROOT_DIR})
ENDIF(NOT SOURCE_DIR AND ROOT_DIR) ENDIF()
ELSE(SOURCE_DIR) ELSE()
SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}) SET(SOURCE_DIR ${CMAKE_SOURCE_DIR})
SET(ROOT_DIR ${CMAKE_SOURCE_DIR}) SET(ROOT_DIR ${CMAKE_SOURCE_DIR})
ENDIF(SOURCE_DIR) ENDIF()
MACRO(NOW RESULT) MACRO(NOW RESULT)
IF (WIN32) IF (WIN32)
EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME) EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME)
IF(NOT DATETIME MATCHES "ERROR") IF(NOT DATETIME MATCHES "ERROR")
STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} "${DATETIME}") STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} "${DATETIME}")
ENDIF(NOT DATETIME MATCHES "ERROR") ENDIF()
ELSEIF(UNIX) ELSEIF(UNIX)
EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE DATETIME) EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE DATETIME)
STRING(REGEX REPLACE "([0-9: -]+).*" "\\1" ${RESULT} "${DATETIME}") STRING(REGEX REPLACE "([0-9: -]+).*" "\\1" ${RESULT} "${DATETIME}")
ELSE (WIN32) ELSE()
MESSAGE(SEND_ERROR "date not implemented") MESSAGE(SEND_ERROR "date not implemented")
SET(${RESULT} "0000-00-00 00:00:00") SET(${RESULT} "0000-00-00 00:00:00")
ENDIF (WIN32) ENDIF()
ENDMACRO(NOW) ENDMACRO(NOW)
IF(EXISTS "${ROOT_DIR}/.svn/") IF(EXISTS "${ROOT_DIR}/.svn/")
FIND_PACKAGE(Subversion) FIND_PACKAGE(Subversion QUIET)
IF(SUBVERSION_FOUND) IF(SUBVERSION_FOUND)
Subversion_WC_INFO(${ROOT_DIR} ER) Subversion_WC_INFO(${ROOT_DIR} ER)
SET(REVISION ${ER_WC_REVISION}) SET(REVISION ${ER_WC_REVISION})
ENDIF(SUBVERSION_FOUND) ENDIF(SUBVERSION_FOUND)
FIND_PACKAGE(TortoiseSVN QUIET)
IF(TORTOISESVN_FOUND)
TORTOISESVN_GET_REVISION(${ROOT_DIR} REVISION)
ENDIF(TORTOISESVN_FOUND)
ENDIF(EXISTS "${ROOT_DIR}/.svn/") ENDIF(EXISTS "${ROOT_DIR}/.svn/")
IF(EXISTS "${ROOT_DIR}/.hg/") IF(EXISTS "${ROOT_DIR}/.hg/")
@ -55,8 +61,8 @@ IF(EXISTS "${ROOT_DIR}/.hg/")
SET(REVISION ${ER_WC_REVISION}) SET(REVISION ${ER_WC_REVISION})
SET(CHANGESET ${ER_WC_CHANGESET}) SET(CHANGESET ${ER_WC_CHANGESET})
SET(BRANCH ${ER_WC_BRANCH}) SET(BRANCH ${ER_WC_BRANCH})
ENDIF(MERCURIAL_FOUND) ENDIF()
ENDIF(EXISTS "${ROOT_DIR}/.hg/") ENDIF()
# if processing exported sources, use "revision" file if exists # if processing exported sources, use "revision" file if exists
IF(SOURCE_DIR AND NOT DEFINED REVISION) IF(SOURCE_DIR AND NOT DEFINED REVISION)
@ -64,8 +70,8 @@ IF(SOURCE_DIR AND NOT DEFINED REVISION)
IF(EXISTS ${REVISION_FILE}) IF(EXISTS ${REVISION_FILE})
FILE(STRINGS ${REVISION_FILE} REVISION LIMIT_COUNT 1) FILE(STRINGS ${REVISION_FILE} REVISION LIMIT_COUNT 1)
MESSAGE(STATUS "Read revision ${REVISION} from file") MESSAGE(STATUS "Read revision ${REVISION} from file")
ENDIF(EXISTS ${REVISION_FILE}) ENDIF()
ENDIF(SOURCE_DIR AND NOT DEFINED REVISION) ENDIF()
IF(SOURCE_DIR AND DEFINED REVISION) IF(SOURCE_DIR AND DEFINED REVISION)
IF(EXISTS ${SOURCE_DIR}/revision.h.in) IF(EXISTS ${SOURCE_DIR}/revision.h.in)
@ -73,5 +79,5 @@ IF(SOURCE_DIR AND DEFINED REVISION)
NOW(BUILD_DATE) NOW(BUILD_DATE)
CONFIGURE_FILE(${SOURCE_DIR}/revision.h.in revision.h.txt) CONFIGURE_FILE(${SOURCE_DIR}/revision.h.in revision.h.txt)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy revision.h.txt revision.h) # copy_if_different EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy revision.h.txt revision.h) # copy_if_different
ENDIF(EXISTS ${SOURCE_DIR}/revision.h.in) ENDIF()
ENDIF(SOURCE_DIR AND DEFINED REVISION) ENDIF()

@ -6,6 +6,9 @@ IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE) ENDIF(NOT CMAKE_BUILD_TYPE)
# Declare CMAKE_CONFIGURATION_TYPES before PROJECT
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
### ###
# Helper macro that generates .pc and installs it. # Helper macro that generates .pc and installs it.
# Argument: name - the name of the .pc package, e.g. "nel-pacs.pc" # Argument: name - the name of the .pc package, e.g. "nel-pacs.pc"
@ -252,6 +255,16 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
ELSE(WITH_STATIC) ELSE(WITH_STATIC)
OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF) OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF)
ENDIF(WITH_STATIC) ENDIF(WITH_STATIC)
IF (WITH_STATIC)
OPTION(WITH_STATIC_CURL "With static curl" ON )
ELSE(WITH_STATIC)
OPTION(WITH_STATIC_CURL "With static curl" OFF)
ENDIF(WITH_STATIC)
IF(APPLE)
OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" ON )
ELSE(APPLE)
OPTION(WITH_LIBXML2_ICONV "With libxml2 using iconv" OFF)
ENDIF(APPLE)
OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF) OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF)
IF(WIN32) IF(WIN32)
OPTION(WITH_EXTERNAL "With provided external." ON ) OPTION(WITH_EXTERNAL "With provided external." ON )
@ -360,6 +373,7 @@ MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
### ###
OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON ) OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON )
OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF) OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF)
OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF)
ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS) ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS) MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
@ -384,8 +398,6 @@ MACRO(NL_SETUP_BUILD)
# Debug = NL_DEBUG # Debug = NL_DEBUG
# Release = NL_RELEASE # Release = NL_RELEASE
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
IF(CMAKE_BUILD_TYPE MATCHES "Debug") IF(CMAKE_BUILD_TYPE MATCHES "Debug")
SET(NL_BUILD_MODE "NL_DEBUG") SET(NL_BUILD_MODE "NL_DEBUG")
ELSE(CMAKE_BUILD_TYPE MATCHES "Debug") ELSE(CMAKE_BUILD_TYPE MATCHES "Debug")
@ -556,9 +568,15 @@ MACRO(NL_SETUP_BUILD)
# Ignore default include paths # Ignore default include paths
ADD_PLATFORM_FLAGS("/X") ADD_PLATFORM_FLAGS("/X")
IF(MSVC11) IF(MSVC12)
ADD_PLATFORM_FLAGS("/Gy- /MP") ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2010, but custom optimizations don't exist # /Ox is working with VC++ 2013, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC11)
ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2012, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again # without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
@ -580,9 +598,9 @@ MACRO(NL_SETUP_BUILD)
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again # without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}") SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}")
ELSE(MSVC11) ELSE(MSVC12)
MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
ENDIF(MSVC11) ENDIF(MSVC12)
ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250") ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250")

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

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

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

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

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

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

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

@ -218,7 +218,7 @@ protected:
date*= previous->OODeltaTime; date*= previous->OODeltaTime;
NLMISC::clamp(date, 0,1); NLMISC::clamp(date, 0,1);
date = this->ease(previous, date); date = this->ease(previous, (float)date);
float hb[4]; float hb[4];
this->computeHermiteBasis(date, hb); this->computeHermiteBasis(date, hb);

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

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

@ -51,6 +51,7 @@ namespace NLGUI
// Init part // Init part
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual void checkCoords();
virtual void updateCoords(); virtual void updateCoords();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }

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

@ -55,9 +55,7 @@ namespace NLGUI
static void forceLink(); static void forceLink();
protected: protected:
sint64 getVal();
sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor);
else return (_Number.getSInt64() / _Divisor)%_Modulo; }
protected: protected:

@ -283,6 +283,10 @@ namespace NLGUI
sint32 _ViewTextDeltaX; sint32 _ViewTextDeltaX;
CViewText* getVT() const{ return _ViewText; }
void createViewText();
private: private:
void setupDisplayText(); void setupDisplayText();
void makeTopWindow(); void makeTopWindow();

@ -0,0 +1,53 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2014 Laszlo Kis-Adam
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef GROUP_EDITBOX_DECOR
#define GROUP_EDITBOX_DECOR
#include "nel/gui/group_editbox.h"
namespace NLGUI
{
/// Decorated CGroupEditBox
class CGroupEditBoxDecor : public CGroupEditBox
{
public:
DECLARE_UI_CLASS( CGroupEditBoxDecor )
CGroupEditBoxDecor( const TCtorParam &param );
~CGroupEditBoxDecor();
void moveBy( sint32 x, sint32 y );
void setIdRecurse( const std::string &newID );
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
bool parse( xmlNodePtr cur, CInterfaceGroup *parent );
void draw();
void updateCoords();
static void forceLink();
private:
class EBDPrivate *_Pvt;
};
}
#endif

@ -17,7 +17,6 @@
#ifndef CL_GROUP_HTML_H #ifndef CL_GROUP_HTML_H
#define CL_GROUP_HTML_H #define CL_GROUP_HTML_H
#define CURL_STATICLIB 1
#include <curl/curl.h> #include <curl/curl.h>
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
@ -103,11 +102,14 @@ namespace NLGUI
// Browse // Browse
virtual void browse (const char *url); virtual void browse (const char *url);
// parse html string using libxml2 parser
virtual bool parseHtml(std::string htmlString);
// Refresh // Refresh
void refresh(); void refresh();
// submit form // submit form
void submitForm (uint formId, const char *submitButtonName); void submitForm (uint formId, const char *submitButtonType, const char *submitButtonName, const char *submitButtonValue, sint32 x, sint32 y);
// Browse error // Browse error
void browseError (const char *msg); void browseError (const char *msg);
@ -200,6 +202,7 @@ namespace NLGUI
int luaBeginElement(CLuaState &ls); int luaBeginElement(CLuaState &ls);
int luaEndElement(CLuaState &ls); int luaEndElement(CLuaState &ls);
int luaShowDiv(CLuaState &ls); int luaShowDiv(CLuaState &ls);
int luaParseHtml(CLuaState &ls);
REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText) REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText)
REFLECT_LUA_METHOD("browse", luaBrowse) REFLECT_LUA_METHOD("browse", luaBrowse)
@ -211,6 +214,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("beginElement", luaBeginElement) REFLECT_LUA_METHOD("beginElement", luaBeginElement)
REFLECT_LUA_METHOD("endElement", luaEndElement) REFLECT_LUA_METHOD("endElement", luaEndElement)
REFLECT_LUA_METHOD("showDiv", luaShowDiv) REFLECT_LUA_METHOD("showDiv", luaShowDiv)
REFLECT_LUA_METHOD("parseHtml", luaParseHtml)
REFLECT_STRING("url", getURL, setURL) REFLECT_STRING("url", getURL, setURL)
REFLECT_FLOAT("timeout", getTimeout, setTimeout) REFLECT_FLOAT("timeout", getTimeout, setTimeout)
REFLECT_EXPORT_END REFLECT_EXPORT_END
@ -229,7 +233,7 @@ namespace NLGUI
virtual void addText (const char * buf, int len); virtual void addText (const char * buf, int len);
// A link has been parsed // A link has been parsed
virtual void addLink (uint element_number, uint attribute_number, HTChildAnchor *anchor, const BOOL *present, const char **value); virtual void addLink (uint element_number, const BOOL *present, const char **value);
// A new begin HTML element has been parsed (<IMG> for exemple) // A new begin HTML element has been parsed (<IMG> for exemple)
virtual void beginElement (uint element_number, const BOOL *present, const char **value); virtual void beginElement (uint element_number, const BOOL *present, const char **value);
@ -252,6 +256,10 @@ namespace NLGUI
// the current request is terminated // the current request is terminated
virtual void requestTerminated(HTRequest *request); virtual void requestTerminated(HTRequest *request);
// libxml2 html parser functions
void htmlElement(xmlNode *node, int element_number);
void htmlWalkDOM(xmlNode *a_node);
// Get Home URL // Get Home URL
virtual std::string home(); virtual std::string home();
@ -328,7 +336,11 @@ namespace NLGUI
bool _BrowseNextTime; bool _BrowseNextTime;
bool _PostNextTime; bool _PostNextTime;
uint _PostFormId; uint _PostFormId;
std::string _PostFormSubmitType;
std::string _PostFormSubmitButton; std::string _PostFormSubmitButton;
std::string _PostFormSubmitValue;
sint32 _PostFormSubmitX;
sint32 _PostFormSubmitY;
// Browsing.. // Browsing..
bool _Browsing; bool _Browsing;
@ -422,6 +434,38 @@ namespace NLGUI
return _FontSize.back(); return _FontSize.back();
} }
std::vector<uint> _FontWeight;
inline uint getFontWeight() const
{
if (_FontWeight.empty())
return 400;
return _FontWeight.back();
}
std::vector<bool> _FontOblique;
inline uint getFontOblique() const
{
if (_FontOblique.empty())
return false;
return _FontOblique.back();
}
std::vector<bool> _FontUnderlined;
inline uint getFontUnderlined() const
{
if (_FontUnderlined.empty())
return false;
return _FontUnderlined.back();
}
std::vector<bool> _FontStrikeThrough;
inline uint getFontStrikeThrough() const
{
if (_FontStrikeThrough.empty())
return false;
return _FontStrikeThrough.back();
}
// Current link // Current link
std::vector<std::string> _Link; std::vector<std::string> _Link;
inline const char *getLink() const inline const char *getLink() const
@ -541,6 +585,26 @@ namespace NLGUI
}; };
std::vector<CCellParams> _CellParams; std::vector<CCellParams> _CellParams;
class CStyleParams
{
public:
CStyleParams () : TextColor(255,255,255,255)
{
FontSize=10;
FontWeight=400;
FontOblique=false;
Underlined=false;
StrikeThrough=false;
}
uint FontSize;
uint FontWeight;
bool FontOblique;
NLMISC::CRGBA TextColor;
bool Underlined;
bool StrikeThrough;
};
// Indentation // Indentation
uint _Indent; uint _Indent;
@ -610,8 +674,16 @@ namespace NLGUI
typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap; typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap;
static TGroupHtmlByUIDMap _GroupHtmlByUID; static TGroupHtmlByUIDMap _GroupHtmlByUID;
private: // read style attribute
void getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit = true);
// load and render local html file (from bnp for example)
void doBrowseLocalFile(const std::string &filename);
// render html string as new browser page
bool renderHtmlString(const std::string &html);
private:
// decode all HTML entities // decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str); static ucstring decodeHTMLEntities(const ucstring &str);
@ -642,6 +714,7 @@ namespace NLGUI
void checkImageDownload(); void checkImageDownload();
void addImageDownload(const std::string &url, CViewBase *img); void addImageDownload(const std::string &url, CViewBase *img);
std::string localImageName(const std::string &url); std::string localImageName(const std::string &url);
std::string getAbsoluteUrl(const std::string &url);
bool isTrustedDomain(const std::string &domain); bool isTrustedDomain(const std::string &domain);
void setImage(CViewBase *view, const std::string &file); void setImage(CViewBase *view, const std::string &file);

@ -117,6 +117,7 @@ namespace NLGUI
editorSelected = false; editorSelected = false;
serializable = true; serializable = true;
_EditorSelectable = true;
} }
// dtor // dtor
@ -531,9 +532,16 @@ namespace NLGUI
/// Aligns the element to the other element specified /// Aligns the element to the other element specified
void alignTo( CInterfaceElement *other ); void alignTo( CInterfaceElement *other );
/// Specifies if the widget can be selected in the editor
void setEditorSelectable( bool b ){ _EditorSelectable = b; }
/// Tells if the widget can be selected in the editor
bool isEditorSelectable() const{ return _EditorSelectable; }
protected: protected:
bool editorSelected; bool editorSelected;
bool _EditorSelectable;
static bool editorMode; static bool editorMode;

@ -47,6 +47,15 @@ namespace NLGUI
_VolatileValue = NULL; _VolatileValue = NULL;
} }
/// Tells if this property has a value
bool hasValue() const
{
if( _VolatileValue != NULL )
return true;
else
return false;
}
NLMISC::CCDBNodeLeaf* getNodePtr() const NLMISC::CCDBNodeLeaf* getNodePtr() const
{ {
return _VolatileValue; return _VolatileValue;

@ -25,6 +25,8 @@ extern "C"
#include "WWWInit.h" #include "WWWInit.h"
} }
#include "nel/misc/rgba.h"
namespace NLGUI namespace NLGUI
{ {
class CCtrlBaseButton; class CCtrlBaseButton;
@ -216,6 +218,13 @@ namespace NLGUI
HTML_ATTR(DIV,STYLE), HTML_ATTR(DIV,STYLE),
}; };
enum
{
HTML_ATTR(SPAN,CLASS) = 0,
HTML_ATTR(SPAN,ID),
HTML_ATTR(SPAN,STYLE),
};
#undef HTML_ATTR #undef HTML_ATTR

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

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

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

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

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

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

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

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

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

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

@ -28,7 +28,11 @@
# endif # endif
#elif defined(NL_OS_UNIX) #elif defined(NL_OS_UNIX)
# include <pthread.h> // PThread # include <pthread.h> // PThread
# ifdef NL_OS_MAC
# include <dispatch/dispatch.h>
# else
# include <semaphore.h> // PThread POSIX semaphores # include <semaphore.h> // PThread POSIX semaphores
# endif
# include <unistd.h> # include <unistd.h>
# define __forceinline # define __forceinline
# ifdef NL_OS_MAC # ifdef NL_OS_MAC
@ -532,7 +536,9 @@ private:
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
TNelRtlCriticalSection _Cs; TNelRtlCriticalSection _Cs;
#elif defined NL_OS_UNIX #elif defined(NL_OS_MAC)
dispatch_semaphore_t _Sem;
#elif defined(NL_OS_UNIX)
sem_t _Sem; sem_t _Sem;
#else #else
# error "No fair mutex implementation for this OS" # error "No fair mutex implementation for this OS"

@ -343,7 +343,7 @@ public:
/** Adds a search path. /** Adds a search path.
* The path is a directory "c:/temp" all files in the directory will be included (and recursively if asked) * The path is a directory "c:/temp" all files in the directory will be included (and recursively if asked)
* *
* Alternative directories are not pre-cached (instead of non Alternative files) and will used when a file is not found in the standard directories. * Alternative directories are not pre-cached (instead of non Alternative files) and will be used when a file is not found in the standard directories.
* For example, local data will be in the cached directories and server repository files will be in the Alternative files. If a new file is not * For example, local data will be in the cached directories and server repository files will be in the Alternative files. If a new file is not
* found in the local data, we'll try to find it on the repository. * found in the local data, we'll try to find it on the repository.
* *
@ -507,6 +507,13 @@ public:
*/ */
static bool makePathRelative (const char *basePath, std::string &relativePath); static bool makePathRelative (const char *basePath, std::string &relativePath);
/** Make path absolute
* \param relativePath - The relative path
* \param directory - the directory to which the path is relative to
* returns the absolute path, or empty if something went wrong.
*/
static std::string makePathAbsolute (const std::string &relativePath, const std::string &directory );
/** If File in this list is added more than one in an addSearchPath, it doesn't launch a warning. /** If File in this list is added more than one in an addSearchPath, it doesn't launch a warning.
*/ */
static void addIgnoredDoubleFile(const std::string &ignoredFile); static void addIgnoredDoubleFile(const std::string &ignoredFile);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -603,6 +603,9 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
{ {
H_AUTO_OGL(CDriverGL_setDisplay) H_AUTO_OGL(CDriverGL_setDisplay)
if (!mode.OffScreen)
NLMISC::INelContext::getInstance().setWindowedApplication(true);
_win = EmptyWindow; _win = EmptyWindow;
_CurrentMode = mode; _CurrentMode = mode;
@ -627,12 +630,15 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
// Offscreen mode ? // Offscreen mode ?
if (_CurrentMode.OffScreen) if (_CurrentMode.OffScreen)
{ {
if (!createWindow(mode)) if (!createWindow(mode)) return false;
return false;
HWND tmpHWND = _win; HWND tmpHWND = _win;
int width = mode.Width; int width = mode.Width;
int height = mode.Height; int height = mode.Height;
#ifdef USE_OPENGLES
// TODO: implement for OpenGL ES 1.x
#else
// resize the window // resize the window
RECT rc; RECT rc;
SetRect (&rc, 0, 0, width, height); SetRect (&rc, 0, 0, width, height);
@ -910,6 +916,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
_hDC = NULL; _hDC = NULL;
return false; return false;
} }
#endif
} }
else else
{ {
@ -1479,7 +1486,7 @@ bool CDriverGL::createWindow(const GfxMode &mode)
[[CocoaApplicationDelegate alloc] initWithDriver:this]; [[CocoaApplicationDelegate alloc] initWithDriver:this];
// set the application delegate, this will handle window/app close events // set the application delegate, this will handle window/app close events
[NSApp setDelegate:appDelegate]; [NSApp setDelegate:(id<NSFileManagerDelegate>)appDelegate];
// bind the close button of the window to applicationShouldTerminate // bind the close button of the window to applicationShouldTerminate
id closeButton = [cocoa_window standardWindowButton:NSWindowCloseButton]; id closeButton = [cocoa_window standardWindowButton:NSWindowCloseButton];

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

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

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

@ -109,10 +109,6 @@ void UDriver::purgeMemory()
// *************************************************************************** // ***************************************************************************
// ***************************************************************************
bool CDriverUser::_StaticInit= false;
// *************************************************************************** // ***************************************************************************
CDriverUser::CDriverUser (uintptr_t windowIcon, TDriver driver, emptyProc exitFunc) CDriverUser::CDriverUser (uintptr_t windowIcon, TDriver driver, emptyProc exitFunc)
{ {
@ -122,16 +118,7 @@ CDriverUser::CDriverUser (uintptr_t windowIcon, TDriver driver, emptyProc exitFu
nlassert((uint)IDriver::iconCount == (uint)UDriver::iconCount); nlassert((uint)IDriver::iconCount == (uint)UDriver::iconCount);
// Static Initialisation. NL3D::init3d();
if(!_StaticInit)
{
_StaticInit= true;
// Register basic serial.
NL3D::registerSerial3d();
// Register basic csene.
CScene::registerBasics();
}
_Driver = NULL; _Driver = NULL;

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

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

@ -19,19 +19,35 @@
#include "nel/3d/init_3d.h" #include "nel/3d/init_3d.h"
#include <cfloat> #include <cfloat>
#include "nel/3d/scene.h"
#include "nel/3d/register_3d.h"
namespace
{
static bool _Initialized = false;
}
namespace NL3D namespace NL3D
{ {
void init3d () void init3d ()
{ {
if( _Initialized )
return;
// Init for windows // Init for windows
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
// Enable FPU exceptions // Enable FPU exceptions
// Enable divid by zero and overflow exception // Enable divid by zero and overflow exception
_control87 (_EM_INVALID|_EM_DENORMAL/*|_EM_ZERODIVIDE|_EM_OVERFLOW*/|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM); //_control87 (_EM_INVALID|_EM_DENORMAL/*|_EM_ZERODIVIDE|_EM_OVERFLOW*/|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM);
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
NL3D::registerSerial3d();
CScene::registerBasics();
_Initialized = true;
} }
} // NL3D } // NL3D

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

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

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

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

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

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

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

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

@ -17,7 +17,86 @@
#include "std3d.h" #include "std3d.h"
#include "nel/3d/vertex_program_parse.h" #include "nel/3d/vertex_program_parse.h"
enum TArguments
{
#ifdef NL_LITTLE_ENDIAN
ADD = 1094992928,
ARL = 1095912480,
BFC0 = 1111900976,
BFC1 = 1111900977,
COL0 = 1129270320,
COL1 = 1129270321,
DP3 = 1146106656,
DP4 = 1146106912,
DST = 1146311712,
END = 1162757152,
EXP = 1163415584,
EXPP = 1163415632,
FOGC = 1179600707,
HPOS = 1213222739,
LIT = 1279874080,
LOG = 1280263968,
MAD = 1296122912,
MAX = 1296128032,
MIN = 1296649760,
MOV = 1297045024,
MUL = 1297435680,
NRML = 1314016588,
OPOS = 1330663251,
PSIZ = 1347635546,
RCP = 1380143136,
RSQ = 1381191968,
SGE = 1397179680,
SLT = 1397511200,
TEX0 = 1413830704,
TEX1 = 1413830705,
TEX2 = 1413830706,
TEX3 = 1413830707,
TEX4 = 1413830708,
TEX5 = 1413830709,
TEX6 = 1413830710,
TEX7 = 1413830711,
WGHT = 1464289364,
#else
ADD = 541344833,
ARL = 541872705,
BFC0 = 809715266,
BFC1 = 826492482,
COL0 = 810307395,
COL1 = 827084611,
DP3 = 540233796,
DP4 = 540299332,
DST = 542397252,
END = 541347397,
EXP = 542136389,
EXPP = 1347442757,
FOGC = 1128746822,
HPOS = 1397706824,
LIT = 542394700,
LOG = 541544268,
MAD = 541344077,
MAX = 542654797,
MIN = 542001485,
MOV = 542527309,
MUL = 541873485,
NRML = 1280135758,
OPOS = 1397706831,
PSIZ = 1514754896,
RCP = 542131026,
RSQ = 542200658,
SGE = 541411155,
SLT = 542395475,
TEX0 = 811091284,
TEX1 = 827868500,
TEX2 = 844645716,
TEX3 = 861422932,
TEX4 = 878200148,
TEX5 = 894977364,
TEX6 = 911754580,
TEX7 = 928531796,
WGHT = 1414022999,
#endif
};
//===================================== //=====================================
bool CVPParser::parseWriteMask(uint &mask, std::string &errorOutput) bool CVPParser::parseWriteMask(uint &mask, std::string &errorOutput)
@ -256,23 +335,23 @@ bool CVPParser::parseInputRegister(CVPOperand &operand, std::string &errorOutput
strValue |= ((uint32) *_CurrChar) << (8 * (3 - k)); strValue |= ((uint32) *_CurrChar) << (8 * (3 - k));
++_CurrChar; ++_CurrChar;
} }
switch (strValue) switch ((TArguments)strValue)
{ {
case 'OPOS': operand.Value.InputRegisterValue = CVPOperand::IPosition; break; case OPOS: operand.Value.InputRegisterValue = CVPOperand::IPosition; break;
case 'WGHT': operand.Value.InputRegisterValue = CVPOperand::IWeight; break; case WGHT: operand.Value.InputRegisterValue = CVPOperand::IWeight; break;
case 'NRML': operand.Value.InputRegisterValue = CVPOperand::INormal; break; case NRML: operand.Value.InputRegisterValue = CVPOperand::INormal; break;
case 'COL0': operand.Value.InputRegisterValue = CVPOperand::IPrimaryColor; break; case COL0: operand.Value.InputRegisterValue = CVPOperand::IPrimaryColor; break;
case 'COL1': operand.Value.InputRegisterValue = CVPOperand::ISecondaryColor; break; case COL1: operand.Value.InputRegisterValue = CVPOperand::ISecondaryColor; break;
case 'FOGC': operand.Value.InputRegisterValue = CVPOperand::IFogCoord; break; case FOGC: operand.Value.InputRegisterValue = CVPOperand::IFogCoord; break;
// texture argument // texture argument
case 'TEX0': case TEX0:
case 'TEX1': case TEX1:
case 'TEX2': case TEX2:
case 'TEX3': case TEX3:
case 'TEX4': case TEX4:
case 'TEX5': case TEX5:
case 'TEX6': case TEX6:
case 'TEX7': case TEX7:
operand.Value.InputRegisterValue = (CVPOperand::EInputRegister) (((CVPOperand::ITex0 + strValue) & 0xff) - '0'); operand.Value.InputRegisterValue = (CVPOperand::EInputRegister) (((CVPOperand::ITex0 + strValue) & 0xff) - '0');
break; break;
default: default:
@ -384,23 +463,23 @@ bool CVPParser::parseOutputRegister(CVPOperand &operand, std::string &errorOutpu
++_CurrChar; ++_CurrChar;
} }
// convert to enum // convert to enum
switch(strValue) switch((TArguments)strValue)
{ {
case 'HPOS': operand.Value.OutputRegisterValue = CVPOperand::OHPosition; break; case HPOS: operand.Value.OutputRegisterValue = CVPOperand::OHPosition; break;
case 'COL0': operand.Value.OutputRegisterValue = CVPOperand::OPrimaryColor; break; case COL0: operand.Value.OutputRegisterValue = CVPOperand::OPrimaryColor; break;
case 'COL1': operand.Value.OutputRegisterValue = CVPOperand::OSecondaryColor; break; case COL1: operand.Value.OutputRegisterValue = CVPOperand::OSecondaryColor; break;
case 'BFC0': operand.Value.OutputRegisterValue = CVPOperand::OBackFacePrimaryColor; break; case BFC0: operand.Value.OutputRegisterValue = CVPOperand::OBackFacePrimaryColor; break;
case 'BFC1': operand.Value.OutputRegisterValue = CVPOperand::OBackFaceSecondaryColor; break; case BFC1: operand.Value.OutputRegisterValue = CVPOperand::OBackFaceSecondaryColor; break;
case 'FOGC': operand.Value.OutputRegisterValue = CVPOperand::OFogCoord; break; case FOGC: operand.Value.OutputRegisterValue = CVPOperand::OFogCoord; break;
case 'PSIZ': operand.Value.OutputRegisterValue = CVPOperand::OPointSize; break; case PSIZ: operand.Value.OutputRegisterValue = CVPOperand::OPointSize; break;
case 'TEX0': operand.Value.OutputRegisterValue = CVPOperand::OTex0; break; case TEX0: operand.Value.OutputRegisterValue = CVPOperand::OTex0; break;
case 'TEX1': operand.Value.OutputRegisterValue = CVPOperand::OTex1; break; case TEX1: operand.Value.OutputRegisterValue = CVPOperand::OTex1; break;
case 'TEX2': operand.Value.OutputRegisterValue = CVPOperand::OTex2; break; case TEX2: operand.Value.OutputRegisterValue = CVPOperand::OTex2; break;
case 'TEX3': operand.Value.OutputRegisterValue = CVPOperand::OTex3; break; case TEX3: operand.Value.OutputRegisterValue = CVPOperand::OTex3; break;
case 'TEX4': operand.Value.OutputRegisterValue = CVPOperand::OTex4; break; case TEX4: operand.Value.OutputRegisterValue = CVPOperand::OTex4; break;
case 'TEX5': operand.Value.OutputRegisterValue = CVPOperand::OTex5; break; case TEX5: operand.Value.OutputRegisterValue = CVPOperand::OTex5; break;
case 'TEX6': operand.Value.OutputRegisterValue = CVPOperand::OTex6; break; case TEX6: operand.Value.OutputRegisterValue = CVPOperand::OTex6; break;
case 'TEX7': operand.Value.OutputRegisterValue = CVPOperand::OTex7; break; case TEX7: operand.Value.OutputRegisterValue = CVPOperand::OTex7; break;
default: default:
errorOutput = "Can't read index for output register."; errorOutput = "Can't read index for output register.";
return false; return false;
@ -753,9 +832,9 @@ bool CVPParser::parseInstruction(CVPInstruction &instr, std::string &errorOutput
{ {
instrStr |= (uint32) ' '; instrStr |= (uint32) ' ';
} }
switch (instrStr) switch ((TArguments)instrStr)
{ {
case 'ARL ': case ARL:
instr.Opcode = CVPInstruction::ARL; instr.Opcode = CVPInstruction::ARL;
if (!parseOp2(instr, errorOutput)) return false; if (!parseOp2(instr, errorOutput)) return false;
if (!instr.Src1.Swizzle.isScalar()) if (!instr.Src1.Swizzle.isScalar())
@ -764,7 +843,7 @@ bool CVPParser::parseInstruction(CVPInstruction &instr, std::string &errorOutput
return false; return false;
} }
break; break;
case 'RSQ ': case RSQ:
instr.Opcode = CVPInstruction::RSQ; instr.Opcode = CVPInstruction::RSQ;
if (!parseOp2(instr, errorOutput)) return false; if (!parseOp2(instr, errorOutput)) return false;
if (!instr.Src1.Swizzle.isScalar()) if (!instr.Src1.Swizzle.isScalar())
@ -773,8 +852,8 @@ bool CVPParser::parseInstruction(CVPInstruction &instr, std::string &errorOutput
return false; return false;
} }
break; break;
case 'EXP ': case EXP:
case 'EXPP': case EXPP:
instr.Opcode = CVPInstruction::EXPP; instr.Opcode = CVPInstruction::EXPP;
if (!parseOp2(instr, errorOutput)) return false; if (!parseOp2(instr, errorOutput)) return false;
if (!instr.Src1.Swizzle.isScalar()) if (!instr.Src1.Swizzle.isScalar())
@ -789,7 +868,7 @@ bool CVPParser::parseInstruction(CVPInstruction &instr, std::string &errorOutput
return false; return false;
}*/ }*/
break; break;
case 'LOG ': case LOG:
instr.Opcode = CVPInstruction::LOG; instr.Opcode = CVPInstruction::LOG;
if (!parseOp2(instr, errorOutput)) return false; if (!parseOp2(instr, errorOutput)) return false;
if (!instr.Src1.Swizzle.isScalar()) if (!instr.Src1.Swizzle.isScalar())
@ -805,7 +884,7 @@ bool CVPParser::parseInstruction(CVPInstruction &instr, std::string &errorOutput
} }
*/ */
break; break;
case 'RCP ': case RCP:
instr.Opcode = CVPInstruction::RCP; instr.Opcode = CVPInstruction::RCP;
if (!parseOp2(instr, errorOutput)) return false; if (!parseOp2(instr, errorOutput)) return false;
if (!instr.Src1.Swizzle.isScalar()) if (!instr.Src1.Swizzle.isScalar())
@ -815,60 +894,60 @@ bool CVPParser::parseInstruction(CVPInstruction &instr, std::string &errorOutput
} }
break; break;
///////////////// /////////////////
case 'MOV ': case MOV:
instr.Opcode = CVPInstruction::MOV; instr.Opcode = CVPInstruction::MOV;
if (!parseOp2(instr, errorOutput)) return false; if (!parseOp2(instr, errorOutput)) return false;
break; break;
case 'LIT ': case LIT:
instr.Opcode = CVPInstruction::LIT; instr.Opcode = CVPInstruction::LIT;
if (!parseOp2(instr, errorOutput)) return false; if (!parseOp2(instr, errorOutput)) return false;
break; break;
///////////////// /////////////////
case 'MAD ': case MAD:
instr.Opcode = CVPInstruction::MAD; instr.Opcode = CVPInstruction::MAD;
if (!parseOp4(instr, errorOutput)) return false; if (!parseOp4(instr, errorOutput)) return false;
break; break;
///////////////// /////////////////
case 'ADD ': case ADD:
instr.Opcode = CVPInstruction::ADD; instr.Opcode = CVPInstruction::ADD;
if (!parseOp3(instr, errorOutput)) return false; if (!parseOp3(instr, errorOutput)) return false;
break; break;
///////////////// /////////////////
case 'MUL ': case MUL:
instr.Opcode = CVPInstruction::MUL; instr.Opcode = CVPInstruction::MUL;
if (!parseOp3(instr, errorOutput)) return false; if (!parseOp3(instr, errorOutput)) return false;
break; break;
case 'DP3 ': case DP3:
instr.Opcode = CVPInstruction::DP3; instr.Opcode = CVPInstruction::DP3;
if (!parseOp3(instr, errorOutput)) return false; if (!parseOp3(instr, errorOutput)) return false;
break; break;
case 'DP4 ': case DP4:
instr.Opcode = CVPInstruction::DP4; instr.Opcode = CVPInstruction::DP4;
if (!parseOp3(instr, errorOutput)) return false; if (!parseOp3(instr, errorOutput)) return false;
break; break;
case 'DST ': case DST:
instr.Opcode = CVPInstruction::DST; instr.Opcode = CVPInstruction::DST;
if (!parseOp3(instr, errorOutput)) return false; if (!parseOp3(instr, errorOutput)) return false;
break; break;
case 'MIN ': case MIN:
instr.Opcode = CVPInstruction::MIN; instr.Opcode = CVPInstruction::MIN;
if (!parseOp3(instr, errorOutput)) return false; if (!parseOp3(instr, errorOutput)) return false;
break; break;
case 'MAX ': case MAX:
instr.Opcode = CVPInstruction::MAX; instr.Opcode = CVPInstruction::MAX;
if (!parseOp3(instr, errorOutput)) return false; if (!parseOp3(instr, errorOutput)) return false;
break; break;
case 'SLT ': case SLT:
instr.Opcode = CVPInstruction::SLT; instr.Opcode = CVPInstruction::SLT;
if (!parseOp3(instr, errorOutput)) return false; if (!parseOp3(instr, errorOutput)) return false;
break; break;
case 'SGE ': case SGE:
instr.Opcode = CVPInstruction::SGE; instr.Opcode = CVPInstruction::SGE;
if (!parseOp3(instr, errorOutput)) return false; if (!parseOp3(instr, errorOutput)) return false;
break; break;
///////////////// /////////////////
case 'END ': case END:
endEncountered = true; endEncountered = true;
return true; return true;
break; break;

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

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

@ -231,7 +231,7 @@ bool CFormElm::isAtom () const
const CType* CFormElm::getType () const CType* CFormElm::getType ()
{ {
warning (false, "getType", "This node is not an atom."); warning (false, "getType", "This node is not an atom.");
return 0; return NULL;
} }
// *************************************************************************** // ***************************************************************************

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

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

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

@ -868,6 +868,15 @@ namespace NLGUI
} }
} }
// ***************************************************************************
void CCtrlTextButton::checkCoords()
{
if( _ViewText != NULL )
_ViewText->checkCoords();
CCtrlBaseButton::checkCoords();
}
// *************************************************************************** // ***************************************************************************
void CCtrlTextButton::updateCoords() void CCtrlTextButton::updateCoords()

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

@ -121,7 +121,7 @@ namespace NLGUI
{ {
sint64 i; sint64 i;
if( fromString( value, i ) ) if( fromString( value, i ) )
_Divisor = i; _Modulo = i;
return; return;
} }
else else
@ -249,5 +249,16 @@ namespace NLGUI
{ {
} }
sint64 CDBViewNumber::getVal()
{
if( !_Number.hasValue() )
return 0;
if( _Modulo == 0 )
return _Number.getSInt64() / _Divisor;
else
return ( _Number.getSInt64() / _Divisor ) % _Modulo;
}
} }

@ -156,6 +156,8 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CDBViewQuantity::draw () void CDBViewQuantity::draw ()
{
if( _Number.hasValue() && _NumberMax.hasValue() )
{ {
// change text // change text
sint32 val= _Number.getSInt32(); sint32 val= _Number.getSInt32();
@ -166,6 +168,7 @@ namespace NLGUI
_CacheMax=valMax; _CacheMax=valMax;
buildTextFromCache(); buildTextFromCache();
} }
}
// parent call // parent call
CViewText::draw(); CViewText::draw();

@ -999,7 +999,8 @@ namespace NLGUI
break; break;
// OTHER // OTHER
default: default:
if ((rEDK.getChar() == KeyRETURN) && !_WantReturn) bool isKeyRETURN = !rEDK.getKeyCtrl() && rEDK.getChar() == KeyRETURN;
if (isKeyRETURN && !_WantReturn)
{ {
// update historic. // update historic.
if(_MaxHistoric) if(_MaxHistoric)
@ -1030,9 +1031,9 @@ namespace NLGUI
// If the char is not alphanumeric -> return. // If the char is not alphanumeric -> return.
// if(!isalnum(ec.Char)) // if(!isalnum(ec.Char))
// return // return
if( (rEDK.getChar()>=32) || (rEDK.getChar() == KeyRETURN) ) if( (rEDK.getChar()>=32) || isKeyRETURN )
{ {
if (rEDK.getChar() == KeyRETURN) if (isKeyRETURN)
{ {
ucstring copyStr= _InputString; ucstring copyStr= _InputString;
if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn) if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn)
@ -1049,7 +1050,7 @@ namespace NLGUI
cutSelection(); cutSelection();
} }
ucchar c = (rEDK.getChar() == KeyRETURN)?'\n':rEDK.getChar(); ucchar c = isKeyRETURN ? '\n' : rEDK.getChar();
if (isFiltered(c)) return; if (isFiltered(c)) return;
switch(_EntryType) switch(_EntryType)
{ {
@ -1128,7 +1129,7 @@ namespace NLGUI
++ _CursorPos; ++ _CursorPos;
triggerOnChangeAH(); triggerOnChangeAH();
} }
if (rEDK.getChar() == KeyRETURN) if (isKeyRETURN)
{ {
CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams);
} }
@ -1336,6 +1337,11 @@ namespace NLGUI
// if click, and not frozen, then get the focus // if click, and not frozen, then get the focus
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && !_Frozen) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && !_Frozen)
{ {
if( getEditorMode() )
{
return CViewBase::handleEvent( event );
}
_SelectingText = true; _SelectingText = true;
stopParentBlink(); stopParentBlink();
CWidgetManager::getInstance()->setCaptureKeyboard (this); CWidgetManager::getInstance()->setCaptureKeyboard (this);
@ -1532,35 +1538,44 @@ namespace NLGUI
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupEditBox::setup()
{
// bind to the controls
_ViewText = dynamic_cast<CViewText *>(CInterfaceGroup::getView("edit_text"));
if(_ViewText == NULL) void CGroupEditBox::createViewText()
{ {
nlwarning("Interface: CGroupEditBox: text 'edit_text' missing or bad type"); nlwarning("Interface: CGroupEditBox: text 'edit_text' missing or bad type");
if( editorMode )
{
nlwarning( "Trying to create a new 'edit_text' for %s", getId().c_str() ); nlwarning( "Trying to create a new 'edit_text' for %s", getId().c_str() );
_ViewText = dynamic_cast< CViewText* >( CInterfaceFactory::createClass( "text" ) ); _ViewText = dynamic_cast< CViewText* >( CInterfaceFactory::createClass( "text" ) );
if( _ViewText != NULL ) if( _ViewText == NULL )
{ {
nlwarning( "Failed to create new 'edit_text' for %s", getId().c_str() );
return;
}
_ViewText->setParent( this ); _ViewText->setParent( this );
_ViewText->setIdRecurse( "edit_text" ); _ViewText->setIdRecurse( "edit_text" );
_ViewText->setHardText( "sometext" ); _ViewText->setHardText( "" );
_ViewText->setPosRef( Hotspot_TL ); _ViewText->setPosRef( Hotspot_ML );
_ViewText->setParentPosRef( Hotspot_TL ); _ViewText->setParentPosRef( Hotspot_ML );
addView( _ViewText ); addView( _ViewText );
setH( _ViewText->getFontHeight() ); sint32 w,h;
setW( _ViewText->getFontWidth() * _ViewText->getText().size() ); w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() );
h = std::max( sint32( _ViewText->getFontHeight() ), getH() );
setH( h );
setW( w );
} }
else
nlwarning( "Failed to create new 'edit_text' for %s", getId().c_str() ); // ----------------------------------------------------------------------------
} void CGroupEditBox::setup()
} {
// bind to the controls
if( _ViewText == NULL )
_ViewText = dynamic_cast<CViewText *>(CInterfaceGroup::getView("edit_text"));
if(_ViewText == NULL)
createViewText();
_ViewText->setEditorSelectable( false );
// For MultiLine editbox, clip the end space, else weird when edit space at end of line (nothing happens) // For MultiLine editbox, clip the end space, else weird when edit space at end of line (nothing happens)
if(_ViewText) if(_ViewText)

@ -0,0 +1,380 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2014 Laszlo Kis-Adam
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "nel/gui/group_editbox_decor.h"
#include "nel/gui/view_bitmap.h"
#include "nel/gui/view_text.h"
namespace NLGUI
{
class EBDPrivate
{
public:
enum Textures
{
BG,
L,
R,
TM,
BM,
TL,
TR,
BL,
BR,
TCOUNT
};
EBDPrivate()
{
for( int i = 0; i < TCOUNT; i++ )
{
_Textures.push_back( new CViewBitmap( CViewBase::TCtorParam() ) );
}
}
~EBDPrivate()
{
for( int i = 0; i < _Textures.size(); i++ )
delete _Textures[ i ];
_Textures.clear();
}
void draw()
{
for( int i = 0; i < _Textures.size(); i++ )
{
CViewBitmap *bm = _Textures[ i ];
bm->draw();
}
}
void updateCoords()
{
for( int i = 0; i < _Textures.size(); i++ )
{
CViewBitmap *bm = _Textures[ i ];
bm->fitTexture();
}
// W and H parameters depend on the sizes of the other textures
// Negative sizes mean that the sizes are that much smaller than the parent
sint32 w,h;
h = _Textures[ TL ]->getHReal() + _Textures[ BL ]->getHReal();
h *= -1;
_Textures[ L ]->setH( h );
h = _Textures[ TR ]->getHReal() + _Textures[ BR ]->getHReal();
h *= -1;
_Textures[ R ]->setH( h );
w = _Textures[ TL ]->getWReal() + _Textures[ TR ]->getWReal();
w *= -1;
_Textures[ TM ]->setW( w );
w = _Textures[ BL ]->getWReal() + _Textures[ BR ]->getWReal();
w *= -1;
_Textures[ BM ]->setW( w );
h = _Textures[ TM ]->getHReal() + _Textures[ BM ]->getHReal();
h *= -1;
w = _Textures[ L ]->getWReal() + _Textures[ R ]->getWReal();
w *= -1;
_Textures[ BG ]->setW( w );
_Textures[ BG ]->setH( h );
for( int i = 0; i < _Textures.size(); i++ )
{
CViewBitmap *bm = _Textures[ i ];
bm->updateCoords();
}
}
void setup( CInterfaceGroup *parent )
{
for( int i = 0; i < _Textures.size(); i++ )
{
CViewBitmap *bm = _Textures[ i ];
bm->setParent( parent );
bm->setParentPos( parent );
bm->setParentSize( parent );
bm->setEditorSelectable( false );
}
_Textures[ TL ]->setPosRef( Hotspot_TL );
_Textures[ TL ]->setParentPosRef( Hotspot_TL );
_Textures[ TM ]->setPosRef( Hotspot_TM );
_Textures[ TM ]->setParentPosRef( Hotspot_TM );
_Textures[ TM ]->setScale( true );
_Textures[ TM ]->setSizeRef( "w" );
_Textures[ TR ]->setPosRef( Hotspot_TR );
_Textures[ TR ]->setParentPosRef( Hotspot_TR );
_Textures[ BL ]->setPosRef( Hotspot_BL );
_Textures[ BL ]->setParentPosRef( Hotspot_BL );
_Textures[ BM ]->setPosRef( Hotspot_BM );
_Textures[ BM ]->setParentPosRef( Hotspot_BM );
_Textures[ BM ]->setScale( true );
_Textures[ BM ]->setSizeRef( "w" );
_Textures[ BR ]->setPosRef( Hotspot_BR );
_Textures[ BR ]->setParentPosRef( Hotspot_BR );
_Textures[ L ]->setPosRef( Hotspot_ML );
_Textures[ L ]->setParentPosRef( Hotspot_ML );
_Textures[ L ]->setScale( true );
_Textures[ L ]->setSizeRef( "h" );
_Textures[ R ]->setPosRef( Hotspot_MR );
_Textures[ R ]->setParentPosRef( Hotspot_MR );
_Textures[ R ]->setScale( true );
_Textures[ R ]->setSizeRef( "h" );
_Textures[ BG ]->setPosRef( Hotspot_MM );
_Textures[ BG ]->setParentPosRef( Hotspot_MM );
_Textures[ BG ]->setScale( true );
_Textures[ BG ]->setSizeRef( "wh" );
}
std::vector< CViewBitmap* > _Textures;
};
NLMISC_REGISTER_OBJECT( CViewBase, CGroupEditBoxDecor, std::string, "edit_box_decor" );
CGroupEditBoxDecor::CGroupEditBoxDecor( const TCtorParam &param ) :
CGroupEditBox( param )
{
_Pvt = new EBDPrivate();
_Pvt->setup( this );
createViewText();
getVT()->setSerializable( false );
getVT()->setEditorSelectable( false );
}
CGroupEditBoxDecor::~CGroupEditBoxDecor()
{
delete _Pvt;
_Pvt = NULL;
}
void CGroupEditBoxDecor::moveBy( sint32 x, sint32 y )
{
CInterfaceElement::moveBy( x, y );
_Pvt->updateCoords();
}
void CGroupEditBoxDecor::setIdRecurse( const std::string &newID )
{
CInterfaceElement::setIdRecurse( newID );
_ViewText->setIdRecurse( _ViewText->getShortId() );
}
std::string CGroupEditBoxDecor::getProperty( const std::string &name ) const
{
if( name == "tx_tl" )
{
return _Pvt->_Textures[ EBDPrivate::TL ]->getTexture();
}
else
if( name == "tx_tm" )
{
return _Pvt->_Textures[ EBDPrivate::TM ]->getTexture();
}
else
if( name == "tx_tr" )
{
return _Pvt->_Textures[ EBDPrivate::TR ]->getTexture();
}
else
if( name == "tx_bl" )
{
return _Pvt->_Textures[ EBDPrivate::BL ]->getTexture();
}
else
if( name == "tx_bm" )
{
return _Pvt->_Textures[ EBDPrivate::BM ]->getTexture();
}
else
if( name == "tx_br" )
{
return _Pvt->_Textures[ EBDPrivate::BR ]->getTexture();
}
else
if( name == "tx_l" )
{
return _Pvt->_Textures[ EBDPrivate::L ]->getTexture();
}
else
if( name == "tx_r" )
{
return _Pvt->_Textures[ EBDPrivate::R ]->getTexture();
}
else
if( name == "tx_bg" )
{
return _Pvt->_Textures[ EBDPrivate::BG ]->getTexture();
}
else
return CGroupEditBox::getProperty( name );
}
void CGroupEditBoxDecor::setProperty( const std::string &name, const std::string &value )
{
if( name == "tx_tl" )
{
_Pvt->_Textures[ EBDPrivate::TL ]->setTexture( value );
}
else
if( name == "tx_tm" )
{
_Pvt->_Textures[ EBDPrivate::TM ]->setTexture( value );
}
else
if( name == "tx_tr" )
{
_Pvt->_Textures[ EBDPrivate::TR ]->setTexture( value );
}
else
if( name == "tx_bl" )
{
_Pvt->_Textures[ EBDPrivate::BL ]->setTexture( value );
}
else
if( name == "tx_bm" )
{
_Pvt->_Textures[ EBDPrivate::BM ]->setTexture( value );
}
else
if( name == "tx_br" )
{
_Pvt->_Textures[ EBDPrivate::BR ]->setTexture( value );
}
else
if( name == "tx_l" )
{
_Pvt->_Textures[ EBDPrivate::L ]->setTexture( value );
}
else
if( name == "tx_r" )
{
_Pvt->_Textures[ EBDPrivate::R ]->setTexture( value );
}
else
if( name == "tx_bg" )
{
_Pvt->_Textures[ EBDPrivate::BG ]->setTexture( value );
}
else
CGroupEditBox::setProperty( name, value );
}
xmlNodePtr CGroupEditBoxDecor::serialize( xmlNodePtr parentNode, const char *type ) const
{
xmlNodePtr node = CGroupEditBox::serialize( parentNode, type );
if( node == NULL )
return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "edit_box_decor" );
xmlSetProp( node, BAD_CAST "tx_tl", BAD_CAST _Pvt->_Textures[ EBDPrivate::TL ]->getTexture().c_str() );
xmlSetProp( node, BAD_CAST "tx_tr", BAD_CAST _Pvt->_Textures[ EBDPrivate::TR ]->getTexture().c_str() );
xmlSetProp( node, BAD_CAST "tx_tm", BAD_CAST _Pvt->_Textures[ EBDPrivate::TM ]->getTexture().c_str() );
xmlSetProp( node, BAD_CAST "tx_bl", BAD_CAST _Pvt->_Textures[ EBDPrivate::BL ]->getTexture().c_str() );
xmlSetProp( node, BAD_CAST "tx_bm", BAD_CAST _Pvt->_Textures[ EBDPrivate::BM ]->getTexture().c_str() );
xmlSetProp( node, BAD_CAST "tx_br", BAD_CAST _Pvt->_Textures[ EBDPrivate::BR ]->getTexture().c_str() );
xmlSetProp( node, BAD_CAST "tx_l", BAD_CAST _Pvt->_Textures[ EBDPrivate::L ]->getTexture().c_str() );
xmlSetProp( node, BAD_CAST "tx_r", BAD_CAST _Pvt->_Textures[ EBDPrivate::R ]->getTexture().c_str() );
xmlSetProp( node, BAD_CAST "tx_bg", BAD_CAST _Pvt->_Textures[ EBDPrivate::BG ]->getTexture().c_str() );
return node;
}
bool CGroupEditBoxDecor::parse( xmlNodePtr cur, CInterfaceGroup *parent )
{
if( !CGroupEditBox::parse( cur, parent ) )
return false;
CXMLAutoPtr prop;
prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_tl" );
if( prop )
_Pvt->_Textures[ EBDPrivate::TL ]->setTexture( ( const char* )prop );
prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_tm" );
if( prop )
_Pvt->_Textures[ EBDPrivate::TM ]->setTexture( ( const char* )prop );
prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_tr" );
if( prop )
_Pvt->_Textures[ EBDPrivate::TR ]->setTexture( ( const char* )prop );
prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_bl" );
if( prop )
_Pvt->_Textures[ EBDPrivate::BL ]->setTexture( ( const char* )prop );
prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_bm" );
if( prop )
_Pvt->_Textures[ EBDPrivate::BM ]->setTexture( ( const char* )prop );
prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_br" );
if( prop )
_Pvt->_Textures[ EBDPrivate::BR ]->setTexture( ( const char* )prop );
prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_l" );
if( prop )
_Pvt->_Textures[ EBDPrivate::L ]->setTexture( ( const char* )prop );
prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_r" );
if( prop )
_Pvt->_Textures[ EBDPrivate::R ]->setTexture( ( const char* )prop );
prop = ( char* ) xmlGetProp( cur, BAD_CAST "tx_bg" );
if( prop )
_Pvt->_Textures[ EBDPrivate::BG ]->setTexture( ( const char* )prop );
getVT()->setIdRecurse( "edit_text" );
return true;
}
void CGroupEditBoxDecor::draw()
{
CGroupEditBox::draw();
_Pvt->draw();
}
void CGroupEditBoxDecor::updateCoords()
{
sint32 tw = _Pvt->_Textures[ EBDPrivate::L ]->getWReal();
getVT()->setX( tw + 1 );
CGroupEditBox::updateCoords();
_Pvt->updateCoords();
}
void CGroupEditBoxDecor::forceLink()
{
}
}

@ -485,7 +485,7 @@ namespace NLGUI
string fullstyle = style[1]; string fullstyle = style[1];
for (uint j=2; j < style.size(); j++) for (uint j=2; j < style.size(); j++)
fullstyle += ":"+style[j]; fullstyle += ":"+style[j];
styles[trim(style[0])] = fullstyle; styles[trim(style[0])] = trim(fullstyle);
} }
} }
@ -570,7 +570,7 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupHTML::addLink (uint element_number, uint /* attribute_number */, HTChildAnchor *anchor, const BOOL *present, const char **value) void CGroupHTML::addLink (uint element_number, const BOOL *present, const char **value)
{ {
if (_Browsing) if (_Browsing)
{ {
@ -591,16 +591,8 @@ namespace NLGUI
} }
else else
{ {
HTAnchor * dest = HTAnchor_followMainLink((HTAnchor *) anchor); // convert href from "?key=val" into "http://domain.com/?key=val"
if (dest) _Link.push_back(getAbsoluteUrl(suri));
{
C3WSmartPtr uri = HTAnchor_address(dest);
_Link.push_back ((const char*)uri);
}
else
{
_Link.push_back("");
}
} }
for(uint8 i = MY_HTML_A_ACCESSKEY; i < MY_HTML_A_Z_ACTION_SHORTCUT; i++) for(uint8 i = MY_HTML_A_ACCESSKEY; i < MY_HTML_A_Z_ACTION_SHORTCUT; i++)
@ -894,7 +886,20 @@ namespace NLGUI
switch(element_number) switch(element_number)
{ {
case HTML_A: case HTML_A:
_TextColor.push_back(LinkColor); {
CStyleParams style;
style.FontSize = getFontSize();
style.TextColor = LinkColor;
style.Underlined = true;
style.StrikeThrough = getFontStrikeThrough();
if (present[HTML_A_STYLE] && value[HTML_A_STYLE])
getStyleParams(value[HTML_A_STYLE], style);
_FontSize.push_back(style.FontSize);
_TextColor.push_back(style.TextColor);
_FontUnderlined.push_back(style.Underlined);
_FontStrikeThrough.push_back(style.StrikeThrough);
_GlobalColor.push_back(LinkColorGlobalColor); _GlobalColor.push_back(LinkColorGlobalColor);
_A.push_back(true); _A.push_back(true);
@ -903,6 +908,7 @@ namespace NLGUI
if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS]) if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS])
_LinkClass.push_back(value[MY_HTML_A_CLASS]); _LinkClass.push_back(value[MY_HTML_A_CLASS]);
}
break; break;
case HTML_DIV: case HTML_DIV:
@ -1217,7 +1223,7 @@ namespace NLGUI
normal = value[MY_HTML_INPUT_SRC]; normal = value[MY_HTML_INPUT_SRC];
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name; string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=image";
// Add the ctrl button // Add the ctrl button
addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over, addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over,
@ -1241,7 +1247,15 @@ namespace NLGUI
text = value[MY_HTML_INPUT_VALUE]; text = value[MY_HTML_INPUT_VALUE];
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name; string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=submit";
if (text.size() > 0)
{
// escape AH param separator
string tmp = text;
while(NLMISC::strFindReplace(tmp, "|", "&#124;"))
;
param = param + "|submit_button_value=" + tmp;
}
// Add the ctrl button // Add the ctrl button
if (!_Paragraph) if (!_Paragraph)
@ -1626,6 +1640,28 @@ namespace NLGUI
_Object = true; _Object = true;
break; break;
case HTML_SPAN:
{
CStyleParams style;
style.TextColor = getTextColor();
style.FontSize = getFontSize();
style.FontWeight = getFontWeight();
style.FontOblique = getFontOblique();
style.Underlined = getFontUnderlined();
style.StrikeThrough = getFontStrikeThrough();
if (present[MY_HTML_SPAN_STYLE] && value[MY_HTML_SPAN_STYLE])
getStyleParams(value[MY_HTML_SPAN_STYLE], style);
_TextColor.push_back(style.TextColor);
_FontSize.push_back(style.FontSize);
_FontWeight.push_back(style.FontWeight);
_FontOblique.push_back(style.FontOblique);
_FontUnderlined.push_back(style.Underlined);
_FontStrikeThrough.push_back(style.StrikeThrough);
}
break;
case HTML_STYLE: case HTML_STYLE:
_IgnoreText = true; _IgnoreText = true;
break; break;
@ -1647,7 +1683,10 @@ namespace NLGUI
popIfNotEmpty (_FontSize); popIfNotEmpty (_FontSize);
break; break;
case HTML_A: case HTML_A:
popIfNotEmpty (_FontSize);
popIfNotEmpty (_TextColor); popIfNotEmpty (_TextColor);
popIfNotEmpty (_FontUnderlined);
popIfNotEmpty (_FontStrikeThrough);
popIfNotEmpty (_GlobalColor); popIfNotEmpty (_GlobalColor);
popIfNotEmpty (_A); popIfNotEmpty (_A);
popIfNotEmpty (_Link); popIfNotEmpty (_Link);
@ -1755,6 +1794,14 @@ namespace NLGUI
popIfNotEmpty (_UL); popIfNotEmpty (_UL);
} }
break; break;
case HTML_SPAN:
popIfNotEmpty (_FontSize);
popIfNotEmpty (_FontWeight);
popIfNotEmpty (_FontOblique);
popIfNotEmpty (_TextColor);
popIfNotEmpty (_FontUnderlined);
popIfNotEmpty (_FontStrikeThrough);
break;
case HTML_STYLE: case HTML_STYLE:
_IgnoreText = false; _IgnoreText = false;
break; break;
@ -3069,6 +3116,7 @@ namespace NLGUI
// Text added ? // Text added ?
bool added = false; bool added = false;
bool embolden = getFontWeight() >= 700;
// Number of child in this paragraph // Number of child in this paragraph
if (_CurrentViewLink) if (_CurrentViewLink)
@ -3078,6 +3126,10 @@ namespace NLGUI
if (!skipLine && if (!skipLine &&
(getTextColor() == _CurrentViewLink->getColor()) && (getTextColor() == _CurrentViewLink->getColor()) &&
(getFontSize() == (uint)_CurrentViewLink->getFontSize()) && (getFontSize() == (uint)_CurrentViewLink->getFontSize()) &&
(getFontUnderlined() == _CurrentViewLink->getUnderlined()) &&
(getFontStrikeThrough() == _CurrentViewLink->getStrikeThrough()) &&
(embolden == _CurrentViewLink->getEmbolden()) &&
(getFontOblique() == _CurrentViewLink->getOblique()) &&
(getLink() == _CurrentViewLink->Link) && (getLink() == _CurrentViewLink->Link) &&
(getGlobalColor() == _CurrentViewLink->getModulateGlobalColor())) (getGlobalColor() == _CurrentViewLink->getModulateGlobalColor()))
{ {
@ -3133,12 +3185,15 @@ namespace NLGUI
if (!newLink->Link.empty()) if (!newLink->Link.empty())
{ {
newLink->setHTMLView (this); newLink->setHTMLView (this);
newLink->setUnderlined (true);
} }
} }
newLink->setText(tmpStr); newLink->setText(tmpStr);
newLink->setColor(getTextColor()); newLink->setColor(getTextColor());
newLink->setFontSize(getFontSize()); newLink->setFontSize(getFontSize());
newLink->setEmbolden(embolden);
newLink->setOblique(getFontOblique());
newLink->setUnderlined(getFontUnderlined());
newLink->setStrikeThrough(getFontStrikeThrough());
newLink->setMultiLineSpace((uint)((float)getFontSize()*LineSpaceFontFactor)); newLink->setMultiLineSpace((uint)((float)getFontSize()*LineSpaceFontFactor));
newLink->setMultiLine(true); newLink->setMultiLine(true);
newLink->setModulateGlobalColor(getGlobalColor()); newLink->setModulateGlobalColor(getGlobalColor());
@ -3414,6 +3469,10 @@ namespace NLGUI
_TextColor.clear(); _TextColor.clear();
_GlobalColor.clear(); _GlobalColor.clear();
_FontSize.clear(); _FontSize.clear();
_FontWeight.clear();
_FontOblique.clear();
_FontUnderlined.clear();
_FontStrikeThrough.clear();
_Indent = 0; _Indent = 0;
_LI = false; _LI = false;
_UL.clear(); _UL.clear();
@ -3638,14 +3697,18 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupHTML::submitForm (uint formId, const char *submitButtonName) void CGroupHTML::submitForm (uint formId, const char *submitButtonType, const char *submitButtonName, const char *submitButtonValue, sint32 x, sint32 y)
{ {
// Form id valid ? // Form id valid ?
if (formId < _Forms.size()) if (formId < _Forms.size())
{ {
_PostNextTime = true; _PostNextTime = true;
_PostFormId = formId; _PostFormId = formId;
_PostFormSubmitType = submitButtonType;
_PostFormSubmitButton = submitButtonName; _PostFormSubmitButton = submitButtonName;
_PostFormSubmitValue = submitButtonValue;
_PostFormSubmitX = x;
_PostFormSubmitY = y;
} }
} }
@ -3761,6 +3824,10 @@ namespace NLGUI
stopBrowse (); stopBrowse ();
updateRefreshButton(); updateRefreshButton();
// Browsing
_Browsing = true;
updateRefreshButton();
// Home ? // Home ?
if (_URL == "home") if (_URL == "home")
_URL = home(); _URL = home();
@ -3780,17 +3847,24 @@ namespace NLGUI
_Connecting = true; _Connecting = true;
_ConnectingTimeout = ( times.thisFrameMs / 1000.0f ) + _TimeoutValue; _ConnectingTimeout = ( times.thisFrameMs / 1000.0f ) + _TimeoutValue;
// Save new url
_URL = finalUrl;
// file is probably from bnp (ingame help)
if (isLocal)
{
if (strlwr(finalUrl).find("file:/") == 0)
{
finalUrl = finalUrl.substr(6, finalUrl.size() - 6);
}
doBrowseLocalFile(finalUrl);
}
else
{
CButtonFreezer freezer; CButtonFreezer freezer;
this->visit(&freezer); this->visit(&freezer);
// Browsing
_Browsing = true;
updateRefreshButton();
// Save new url
_URL = finalUrl;
// display HTTP query // display HTTP query
//nlinfo("WEB: GET '%s'", finalUrl.c_str()); //nlinfo("WEB: GET '%s'", finalUrl.c_str());
@ -3806,12 +3880,7 @@ namespace NLGUI
C3WSmartPtr uri = HTParse(finalUrl.c_str(), NULL, PARSE_ALL); C3WSmartPtr uri = HTParse(finalUrl.c_str(), NULL, PARSE_ALL);
// Create an anchor // Create an anchor
#ifdef NL_OS_WINDOWS
if ((_LibWWW->Anchor = HTAnchor_findAddress(uri)) == NULL) if ((_LibWWW->Anchor = HTAnchor_findAddress(uri)) == NULL)
#else
// temporarily disable local URL's until LibWWW can be replaced.
if (isLocal || ((_LibWWW->Anchor = HTAnchor_findAddress(uri)) == NULL))
#endif
{ {
browseError((string("The page address is malformed : ")+(const char*)uri).c_str()); browseError((string("The page address is malformed : ")+(const char*)uri).c_str());
} }
@ -3848,6 +3917,8 @@ namespace NLGUI
} }
} }
} // !isLocal
_BrowseNextTime = false; _BrowseNextTime = false;
} }
@ -3918,9 +3989,22 @@ namespace NLGUI
} }
} }
if (_PostFormSubmitType == "image")
{
// Add the button coordinates // Add the button coordinates
HTParseFormInput(formfields, (_PostFormSubmitButton + "_x=0").c_str()); if (_PostFormSubmitButton.find_first_of("[") == string::npos)
HTParseFormInput(formfields, (_PostFormSubmitButton + "_y=0").c_str()); {
HTParseFormInput(formfields, (_PostFormSubmitButton + "_x=" + NLMISC::toString(_PostFormSubmitX)).c_str());
HTParseFormInput(formfields, (_PostFormSubmitButton + "_y=" + NLMISC::toString(_PostFormSubmitY)).c_str());
}
else
{
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + NLMISC::toString(_PostFormSubmitX)).c_str());
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + NLMISC::toString(_PostFormSubmitY)).c_str());
}
}
else
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + _PostFormSubmitValue).c_str());
// Add custom params // Add custom params
addHTTPPostParams(formfields, _TrustedDomain); addHTTPPostParams(formfields, _TrustedDomain);
@ -4023,6 +4107,57 @@ namespace NLGUI
#endif #endif
} }
// ***************************************************************************
void CGroupHTML::doBrowseLocalFile(const std::string &filename)
{
CIFile in;
if (in.open(filename))
{
std::string html;
while(!in.eof())
{
char buf[1024];
in.getline(buf, 1024);
html += std::string(buf) + "\n";
}
in.close();
if (!renderHtmlString(html))
{
browseError((string("Failed to parse html from file : ")+filename).c_str());
}
}
else
{
browseError((string("The page address is malformed : ")+filename).c_str());
}
}
// ***************************************************************************
bool CGroupHTML::renderHtmlString(const std::string &html)
{
bool success;
// clear content
beginBuild();
success = parseHtml(html);
// invalidate coords
endBuild();
// libwww would call requestTerminated() here
_Browsing = false;
if (_TitleString.empty())
{
setTitle(_TitlePrefix);
}
updateRefreshButton();
return success;
}
// *************************************************************************** // ***************************************************************************
void CGroupHTML::draw () void CGroupHTML::draw ()
@ -4432,7 +4567,7 @@ namespace NLGUI
beginElement(element_number, &present[0], &value[0]); beginElement(element_number, &present[0], &value[0]);
if (element_number == HTML_A) if (element_number == HTML_A)
addLink(element_number, 0, NULL, &present[0], &value[0]); addLink(element_number, &present[0], &value[0]);
return 0; return 0;
} }
@ -4565,5 +4700,93 @@ namespace NLGUI
return result; return result;
} }
// ***************************************************************************
std::string CGroupHTML::getAbsoluteUrl(const std::string &url)
{
if (HTURL_isAbsolute(url.c_str()))
return url;
return std::string(HTParse(url.c_str(), _URL.c_str(), PARSE_ALL));
}
// ***************************************************************************
// CGroupHTML::CStyleParams style;
// style.FontSize; // font-size: 10px;
// style.TextColor; // color: #ABCDEF;
// style.Underlined; // text-decoration: underline; text-decoration-line: underline;
// style.StrikeThrough; // text-decoration: line-through; text-decoration-line: line-through;
void CGroupHTML::getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit)
{
TStyle styles = parseStyle(styleString);
TStyle::iterator it;
for (it=styles.begin(); it != styles.end(); ++it)
{
if (it->first == "font-size")
{
float tmp;
sint size = 0;
getPercentage (size, tmp, it->second.c_str());
if (size > 0)
style.FontSize = size;
}
else
if (it->first == "font-style")
{
if (it->second == "italic" || it->second == "oblique")
style.FontOblique = true;
}
else
if (it->first == "font-weight")
{
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
uint weight = 400;
if (it->second == "normal")
weight = 400;
else
if (it->second == "bold")
weight = 700;
else
if (it->second == "lighter")
{
const uint lighter[] = {100, 100, 100, 100, 100, 400, 400, 700, 700};
int index = getFontWeight() / 100 - 1;
clamp(index, 1, 9);
weight = lighter[index-1];
}
else
if (it->second == "bolder")
{
const uint bolder[] = {400, 400, 400, 700, 700, 900, 900, 900, 900};
uint index = getFontWeight() / 100 + 1;
clamp(index, 1, 9);
weight = bolder[index-1];
}
else
if (fromString(it->second, weight))
{
weight = (weight / 100);
clamp(weight, 1, 9);
weight *= 100;
}
style.FontWeight = weight;
}
else
if (it->first == "color")
scanHTMLColor(it->second.c_str(), style.TextColor);
else
if (it->first == "text-decoration" || it->first == "text-decoration-line")
{
std::string prop(strlwr(it->second));
style.Underlined = (prop.find("underline") != std::string::npos);
style.StrikeThrough = (prop.find("line-through") != std::string::npos);
}
}
if (inherit)
{
style.Underlined = getFontUnderlined() || style.Underlined;
style.StrikeThrough = getFontStrikeThrough() || style.StrikeThrough;
}
}
} }

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

Loading…
Cancel
Save