Merge with feature-export-assimp

This commit is contained in:
kaetemi 2015-11-16 00:46:27 +01:00
commit df382464d8
172 changed files with 3720 additions and 1232 deletions

View file

@ -106,6 +106,7 @@ ENDIF(WIN32)
FIND_PACKAGE(LibXml2 REQUIRED)
FIND_PACKAGE(PNG REQUIRED)
FIND_PACKAGE(GIF)
FIND_PACKAGE(Jpeg)
IF(WITH_STATIC_LIBXML2)
@ -161,9 +162,9 @@ IF(WITH_NEL)
IF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
SET(CURL_STATIC ON)
ELSE((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
ELSE()
SET(CURL_STATIC OFF)
ENDIF((WIN32 OR CURL_LIBRARIES MATCHES "\\.a") AND WITH_STATIC_CURL)
ENDIF()
IF(CURL_STATIC)
SET(CURL_DEFINITIONS -DCURL_STATICLIB)
@ -175,15 +176,23 @@ IF(WITH_NEL)
SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES})
ENDIF(OPENSSL_FOUND)
# CURL Macports version depends on libidn, libintl and libiconv too
IF(APPLE)
IF(UNIX)
# CURL depends on libidn
FIND_LIBRARY(IDN_LIBRARY idn)
FIND_LIBRARY(INTL_LIBRARY intl)
SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${IDN_LIBRARY} ${INTL_LIBRARY})
ENDIF(APPLE)
ENDIF(CURL_STATIC)
ENDIF(WITH_GUI)
IF(IDN_LIBRARY)
SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${IDN_LIBRARY})
ENDIF()
# CURL Macports version depends on libidn, libintl and libiconv too
IF(APPLE)
FIND_LIBRARY(INTL_LIBRARY intl)
IF(INTL_LIBRARY)
SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${INTL_LIBRARY})
ENDIF()
ENDIF()
ENDIF()
ENDIF()
ENDIF()
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include ${LIBXML2_INCLUDE_DIR})
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})

View file

@ -8,7 +8,7 @@
# EXTERNAL_FOUND - True if the external libraries are available
SET(EXTERNAL_TEMP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/../external ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty ${EXTERNAL_PATH})
SET(EXTERNAL_TEMP_FILE "include/wwwconf.h")
SET(EXTERNAL_TEMP_FILE "include/zlib.h")
SET(EXTERNAL_NAME "external")
# If using STLport preprend external_stlport
@ -38,35 +38,35 @@ IF(EXTERNAL_PATH)
# Using 32 or 64 bits binaries
IF(TARGET_X64 AND WIN32)
SET(EXTERNAL_BINARY_PATH "${EXTERNAL_PATH}/bin64")
ELSE(TARGET_X64 AND WIN32)
ELSE()
SET(EXTERNAL_BINARY_PATH "${EXTERNAL_PATH}/bin")
ENDIF(TARGET_X64 AND WIN32)
ENDIF()
# Using 32 or 64 bits libraries
IF(TARGET_X64 AND WIN32)
SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib64")
ELSE(TARGET_X64 AND WIN32)
ELSE()
SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib")
ENDIF(TARGET_X64 AND WIN32)
ENDIF()
SET(CMAKE_INCLUDE_PATH "${EXTERNAL_INCLUDE_PATH};${CMAKE_INCLUDE_PATH}")
# Stupid hack for FindOpenAL.cmake
SET(CMAKE_INCLUDE_PATH "${EXTERNAL_PATH};${CMAKE_INCLUDE_PATH}")
SET(CMAKE_LIBRARY_PATH "${EXTERNAL_LIBRARY_PATH};${CMAKE_LIBRARY_PATH}")
ENDIF(EXTERNAL_PATH)
ENDIF()
IF(EXTERNAL_FOUND)
IF(NOT External_FIND_QUIETLY)
MESSAGE(STATUS "Found ${EXTERNAL_NAME}: ${EXTERNAL_PATH}")
ENDIF(NOT External_FIND_QUIETLY)
ENDIF()
ELSE(EXTERNAL_FOUND)
IF(External_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Unable to find ${EXTERNAL_NAME}!")
ELSE(External_FIND_REQUIRED)
ELSE()
IF(NOT External_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find ${EXTERNAL_NAME}!")
ENDIF(NOT External_FIND_QUIETLY)
ENDIF(External_FIND_REQUIRED)
ENDIF(EXTERNAL_FOUND)
ENDIF()
ENDIF()
ENDIF()
MARK_AS_ADVANCED(EXTERNAL_INCLUDE_PATH EXTERNAL_BINARY_PATH EXTERNAL_LIBRARY_PATH)

View file

@ -0,0 +1,81 @@
# Locate Lua library
# This module defines
# LUA53_FOUND, if false, do not try to link to Lua
# LUA_LIBRARIES
# LUA_INCLUDE_DIR, where to find lua.h
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
#
# Note that the expected include convention is
# #include "lua.h"
# and not
# #include <lua/lua.h>
# This is because, the lua location is not standardized and may exist
# in locations other than lua/
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
find_path(LUA_INCLUDE_DIR lua.h
HINTS
ENV LUA_DIR
PATH_SUFFIXES include/lua53 include/lua5.3 include/lua-5.3 include/lua include
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
find_library(LUA_LIBRARY
NAMES lua53 lua5.3 lua-5.3 lua
HINTS
ENV LUA_DIR
PATH_SUFFIXES lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
)
if(LUA_LIBRARY)
# include the math library for Unix
if(UNIX AND NOT APPLE AND NOT BEOS)
find_library(LUA_MATH_LIBRARY m)
set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
# For Windows and Mac, don't need to explicitly include the math library
else()
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
endif()
endif()
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
unset(lua_version_str)
endif()
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua52
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUA_VERSION_STRING)
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)

View file

@ -42,20 +42,22 @@ MACRO(FIND_CORRECT_LUA_VERSION)
ENDIF(LUALIB_FOUND)
ELSE(LUABIND_LIBRARY_RELEASE MATCHES "\\.so")
# TODO: find a way to detect Lua version
IF(WITH_LUA52)
IF(WITH_LUA53)
FIND_PACKAGE(Lua53 REQUIRED)
ELSEIF(WITH_LUA52)
FIND_PACKAGE(Lua52 REQUIRED)
ELSEIF(WITH_LUA51)
FIND_PACKAGE(Lua51 REQUIRED)
ELSE(WITH_LUA52)
ELSE()
FIND_PACKAGE(Lua50 REQUIRED)
ENDIF(WITH_LUA52)
ENDIF(LUABIND_LIBRARY_RELEASE MATCHES "\\.so")
ENDMACRO(FIND_CORRECT_LUA_VERSION)
ENDIF()
ENDIF()
ENDMACRO()
IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
# in cache already
SET(Luabind_FIND_QUIETLY TRUE)
ENDIF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
ENDIF()
FIND_PATH(LUABIND_INCLUDE_DIR
luabind/luabind.hpp
@ -72,11 +74,21 @@ FIND_PATH(LUABIND_INCLUDE_DIR
SET(LIBRARY_NAME_RELEASE)
SET(LIBRARY_NAME_DEBUG)
IF(WITH_LUA53)
IF(WITH_STLPORT)
LIST(APPEND LIBRARY_NAME_RELEASE luabind_stlport_lua53)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_stlport_lua53d)
ENDIF()
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua53)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua53d)
ENDIF()
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)
ENDIF()
LIST(APPEND LIBRARY_NAME_RELEASE luabind_lua52)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_lua52d)

View file

@ -251,10 +251,10 @@ MACRO(USE_CURRENT_WINSDK)
SET(WINSDK_VERSION "6.1")
ELSEIF(WINSDK6.0_FOUND)
SET(WINSDK_VERSION "6.0")
ELSE(WINSDK7.1_FOUND)
ELSE()
MESSAGE(FATAL_ERROR "You have no compatible Windows SDK installed.")
ENDIF(WINSDK7.1_FOUND)
ENDIF(NOT WINSDK_VERSION)
ENDIF()
ENDIF()
# Look for correct registered Windows SDK version
FOREACH(_VERSION ${WINSDK_DETECTED_VERSIONS})

View file

@ -10,22 +10,22 @@
IF(MSVC)
SET(PCHSupport_FOUND TRUE)
ELSE(MSVC)
ELSE()
IF(CMAKE_COMPILER_IS_GNUCXX)
EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE gcc_compiler_version)
IF(gcc_compiler_version MATCHES "^4\\.1(\\.[0-9]+)?")
IF(gcc_compiler_version VERSION_LESS "4.2")
SET(PCHSupport_FOUND FALSE)
ELSEIF(gcc_compiler_version MATCHES "^4\\.[0-9]+(\\.[0-9]+)?")
ELSE()
SET(PCHSupport_FOUND TRUE)
ENDIF(gcc_compiler_version MATCHES "^4\\.1(\\.[0-9]+)?")
ELSE(CMAKE_COMPILER_IS_GNUCXX)
ENDIF()
ELSE()
# TODO: make tests for other compilers than GCC
SET(PCHSupport_FOUND TRUE)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ENDIF(MSVC)
ENDIF()
ENDIF()
# Set PCH_FLAGS for common flags, PCH_ARCH_XXX_FLAGS for specific archs flags and PCH_ARCHS for archs
MACRO(PCH_SET_COMPILE_FLAGS _target)
@ -40,19 +40,19 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
GET_TARGET_PROPERTY(_targetType ${_target} TYPE)
IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
IF(${_targetType} STREQUAL "SHARED_LIBRARY" OR ${_targetType} STREQUAL "MODULE_LIBRARY")
LIST(APPEND _FLAGS " ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")
ELSE(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
ELSE()
GET_TARGET_PROPERTY(_pic ${_target} POSITION_INDEPENDENT_CODE)
IF(_pic)
LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIE}")
ENDIF(_pic)
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
ENDIF()
ENDIF()
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES)
FOREACH(item ${DIRINC})
LIST(APPEND _FLAGS " -I\"${item}\"")
ENDFOREACH(item)
ENDFOREACH()
# Required for CMake 2.6
SET(GLOBAL_DEFINITIONS)
@ -60,61 +60,64 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item)
ENDIF(DEFINITIONS)
ENDFOREACH()
ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item)
ENDIF(DEFINITIONS)
ENDFOREACH()
ENDIF()
GET_TARGET_PROPERTY(oldProps ${_target} COMPILE_FLAGS)
IF(oldProps)
LIST(APPEND _FLAGS " ${oldProps}")
ENDIF(oldProps)
ENDIF()
GET_TARGET_PROPERTY(oldPropsBuild ${_target} COMPILE_FLAGS_${_UPPER_BUILD})
IF(oldPropsBuild)
LIST(APPEND _FLAGS " ${oldPropsBuild}")
ENDIF(oldPropsBuild)
ENDIF()
GET_TARGET_PROPERTY(DIRINC ${_target} INCLUDE_DIRECTORIES)
IF(DIRINC)
FOREACH(item ${DIRINC})
LIST(APPEND _FLAGS " -I\"${item}\"")
ENDFOREACH(item)
ENDIF(DIRINC)
ENDFOREACH()
ENDIF()
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS)
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item)
ENDIF(DEFINITIONS)
ENDFOREACH()
ENDIF()
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item)
ENDIF(DEFINITIONS)
ENDFOREACH()
ENDIF()
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
LIST(APPEND _FLAGS " ${GLOBAL_DEFINITIONS}")
LIST(APPEND _FLAGS " ${_directory_flags}")
LIST(APPEND _FLAGS " ${_directory_definitions}")
IF(CMAKE_VERSION VERSION_LESS "3.3.0")
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
LIST(APPEND _FLAGS " ${_directory_flags}")
LIST(APPEND _FLAGS " ${_directory_definitions}")
ENDIF()
# Format definitions
IF(MSVC)
# Fix path with space
SEPARATE_ARGUMENTS(_FLAGS UNIX_COMMAND "${_FLAGS}")
ELSE(MSVC)
ELSE()
STRING(REGEX REPLACE " +" " " _FLAGS ${_FLAGS})
SEPARATE_ARGUMENTS(_FLAGS)
ENDIF(MSVC)
ENDIF()
IF(CLANG)
# Determining all architectures and get common flags
@ -127,11 +130,11 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
LIST(APPEND PCH_ARCHS ${item})
STRING(TOUPPER "${item}" _UPPER_ARCH)
SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item})
ENDIF(ITEM_FOUND EQUAL -1)
ENDIF()
SET(_ARCH_NEXT OFF)
ELSEIF(_XARCH_NEXT)
SET(_XARCH_NEXT OFF)
ELSE(_ARCH_NEXT)
ELSE()
IF(item MATCHES "^-arch")
SET(_ARCH_NEXT ON)
ELSEIF(item MATCHES "^-Xarch_")
@ -141,13 +144,13 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
LIST(APPEND PCH_ARCHS ${item})
STRING(TOUPPER "${item}" _UPPER_ARCH)
SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item})
ENDIF(ITEM_FOUND EQUAL -1)
ENDIF()
SET(_XARCH_NEXT ON)
ELSE(item MATCHES "^-arch")
ELSE()
LIST(APPEND PCH_FLAGS ${item})
ENDIF(item MATCHES "^-arch")
ENDIF(_ARCH_NEXT)
ENDFOREACH(item)
ENDIF()
ENDIF()
ENDFOREACH()
# Get architcture specific flags
SET(_XARCH_NEXT)
@ -156,25 +159,25 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
STRING(TOUPPER "${_XARCH_NEXT}" _UPPER_XARCH)
LIST(APPEND PCH_ARCH_${_UPPER_XARCH}_FLAGS ${item})
SET(_XARCH_NEXT OFF)
ELSE(_XARCH_NEXT)
ELSE()
IF(item MATCHES "^-Xarch_")
STRING(SUBSTRING "${item}" 7 -1 _XARCH_NEXT)
ENDIF(item MATCHES "^-Xarch_")
ENDIF(_XARCH_NEXT)
ENDFOREACH(item)
ENDIF()
ENDIF()
ENDFOREACH()
# Remove duplicated architectures
IF(_ARCHS AND PCH_ARCHS)
LIST(REMOVE_DUPLICATES PCH_ARCHS)
ENDIF(_ARCHS AND PCH_ARCHS)
ELSE(CLANG)
ENDIF()
ELSE()
SET(PCH_FLAGS ${_FLAGS})
ENDIF(CLANG)
ENDIF()
IF(PCH_FLAGS)
LIST(REMOVE_DUPLICATES PCH_FLAGS)
ENDIF(PCH_FLAGS)
ENDMACRO(PCH_SET_COMPILE_FLAGS)
ENDIF()
ENDMACRO()
MACRO(GET_PDB_FILENAME _out_filename _target)
# determine output directory based on target type
@ -201,9 +204,9 @@ MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS)
IF(CMAKE_CXX_COMPILER_ARG1)
# remove leading space in compiler argument
STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
ELSE(CMAKE_CXX_COMPILER_ARG1)
ELSE()
SET(pchsupport_compiler_cxx_arg1 "")
ENDIF(CMAKE_CXX_COMPILER_ARG1)
ENDIF()
IF(MSVC)
GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target})
@ -211,16 +214,16 @@ MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS)
# Ninja PCH Support
# http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html
SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES OBJECT_OUTPUTS "${PCH_OUTPUT}.obj")
ELSE(MSVC)
ELSE()
SET(HEADER_FORMAT "c++-header")
SET(_FLAGS "")
IF(APPLE)
SET(HEADER_FORMAT "objective-${HEADER_FORMAT}")
SET(_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch)
ENDIF(APPLE)
ENDIF()
SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} ${_FLAGS} -x ${HEADER_FORMAT} -o ${PCH_OUTPUT} -c ${PCH_INPUT})
ENDIF(MSVC)
ENDMACRO(PCH_SET_COMPILE_COMMAND)
ENDIF()
ENDMACRO()
MACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT _targetName _input _arch _language)
SET(_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch")
@ -230,14 +233,14 @@ MACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT _targetName _input _arch _language)
GET_FILENAME_COMPONENT(_name ${_input} NAME_WE)
SET(PCH_INPUT ${_input})
SET(PCH_OUTPUT "${_OUTPUT_DIR}/${_name}.pch")
ELSE(MSVC)
ELSE()
IF(NOT "${_arch}" STREQUAL "")
SET(_OUTPUT_DIR "${_OUTPUT_DIR}_${_arch}")
ENDIF(NOT "${_arch}" STREQUAL "")
ENDIF()
IF(NOT "${_language}" STREQUAL "")
SET(_OUTPUT_DIR "${_OUTPUT_DIR}_${_language}")
ENDIF(NOT "${_language}" STREQUAL "")
ENDIF()
GET_FILENAME_COMPONENT(_name ${_input} NAME)
@ -251,14 +254,14 @@ MACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT _targetName _input _arch _language)
IF(CLANG)
SET(PCH_EXT "pth")
ELSE(CLANG)
ELSE()
SET(PCH_EXT "gch")
ENDIF(CLANG)
ENDIF()
# For GCC and Clang, PCH needs to be in the same directory as .h
SET(PCH_OUTPUT "${_OUTPUT_DIR}/${_name}.${PCH_EXT}")
ENDIF(MSVC)
ENDMACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT)
ENDIF()
ENDMACRO()
# Add common flags
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName)
@ -266,7 +269,7 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName)
IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND)
ENDIF()
IF(MSVC)
SET(_target_cflags "${oldProps} /Yu\"${PCH_INPUT}\" /FI\"${PCH_INPUT}\" /Fp\"${PCH_OUTPUT}\"")
@ -279,17 +282,17 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName)
GET_TARGET_PROPERTY(_STATIC_LIBRARY_FLAGS ${_targetName} STATIC_LIBRARY_FLAGS)
IF(NOT _STATIC_LIBRARY_FLAGS)
SET(_STATIC_LIBRARY_FLAGS)
ENDIF(NOT _STATIC_LIBRARY_FLAGS)
ENDIF()
SET(_STATIC_LIBRARY_FLAGS "${PCH_OUTPUT}.obj ${_STATIC_LIBRARY_FLAGS}")
GET_TARGET_PROPERTY(_LINK_FLAGS ${_targetName} LINK_FLAGS)
IF(NOT _LINK_FLAGS)
SET(_LINK_FLAGS)
ENDIF(NOT _LINK_FLAGS)
ENDIF()
SET(_LINK_FLAGS "${PCH_OUTPUT}.obj ${_LINK_FLAGS}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES STATIC_LIBRARY_FLAGS ${_STATIC_LIBRARY_FLAGS} LINK_FLAGS ${_LINK_FLAGS})
ELSE(MSVC)
ELSE()
# for use with distcc and gcc >4.0.1 if preprocessed files are accessible
# on all remote machines set
# PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess
@ -299,21 +302,21 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName)
# If no arch is specified, create common flags
IF(PCH_ARCHS_COUNT LESS 2)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-include ${PCH_INPUT} ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(PCH_ARCHS_COUNT LESS 2)
ENDIF()
IF(APPLE)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-fobjc-abi-version=2 -fobjc-legacy-dispatch -x objective-c++ ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(APPLE)
ENDIF()
IF(WITH_PCH_DEBUG)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-H ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(WITH_PCH_DEBUG)
ENDIF()
SET(_target_cflags "${oldProps} ${PCH_ADDITIONAL_COMPILER_FLAGS} -Winvalid-pch")
ENDIF(MSVC)
ENDIF()
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_target_cflags})
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET)
ENDMACRO()
# Add specific flags for an arch
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH _targetName _arch)
@ -324,19 +327,19 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH _targetName _arch)
IF(${_FLAGS} MATCHES NOTFOUND)
SET(_FLAGS "")
ENDIF(${_FLAGS} MATCHES NOTFOUND)
ENDIF()
SET(_FLAGS "${_FLAGS} -Xarch_${_arch} -include${PCH_INPUT}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_FLAGS})
ENDIF(PCH_ARCHS_COUNT GREATER 1)
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH)
ENDIF()
ENDMACRO()
MACRO(PCH_CREATE_TARGET _targetName _targetNamePCH)
ADD_CUSTOM_COMMAND(OUTPUT ${PCH_OUTPUT} COMMAND ${PCH_COMMAND} COMMENT "Generating ${_targetNamePCH}" DEPENDS ${PCH_INPUT})
ADD_CUSTOM_TARGET(${_targetNamePCH} DEPENDS ${PCH_INPUT} ${PCH_OUTPUT})
ADD_DEPENDENCIES(${_targetName} ${_targetNamePCH})
ENDMACRO(PCH_CREATE_TARGET _targetName _inputh _inputcpp)
ENDMACRO()
MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
SET(_PCH_current_target ${_targetName})
@ -346,7 +349,7 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
"This is the ADD_PRECOMPILED_HEADER macro. "
"You must set CMAKE_BUILD_TYPE!"
)
ENDIF(NOT CMAKE_BUILD_TYPE)
ENDIF()
PCH_SET_COMPILE_FLAGS(${_targetName})
@ -362,25 +365,25 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch_${_ARCH})
ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH(${_targetName} ${_ARCH})
ENDFOREACH(_ARCH)
ELSE(PCH_ARCHS)
ENDFOREACH()
ELSE()
PCH_SET_PRECOMPILED_HEADER_OUTPUT(${_targetName} ${_inputh} "" "")
LIST(APPEND PCH_OUTPUTS ${PCH_OUTPUT})
PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_FLAGS}")
PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch)
ENDIF(PCH_ARCHS)
ENDIF()
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName})
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PCH_OUTPUTS}")
ENDMACRO(ADD_PRECOMPILED_HEADER)
ENDMACRO()
MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
IF(NOT PCHSupport_FOUND)
MESSAGE(STATUS "PCH disabled because compiler doesn't support them")
RETURN()
ENDIF(NOT PCHSupport_FOUND)
ENDIF()
# 0 => creating a new target for PCH, works for all makefiles
# 1 => setting PCH for VC++ project, works for VC++ projects
@ -389,9 +392,9 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
SET(PCH_METHOD 1)
ELSEIF(CMAKE_GENERATOR MATCHES "Xcode")
SET(PCH_METHOD 2)
ELSE(CMAKE_GENERATOR MATCHES "Visual Studio")
ELSE()
SET(PCH_METHOD 0)
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio")
ENDIF()
IF(PCH_METHOD EQUAL 1)
# Auto include the precompile (useful for moc processing, since the use of
@ -401,7 +404,7 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND)
ENDIF()
SET(newProperties "${oldProps} /Yu\"${_inputh}\" /FI\"${_inputh}\"")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
@ -418,12 +421,12 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
ELSE(PCH_METHOD EQUAL 1)
ELSE()
#Fallback to the "old" precompiled suppport
ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp})
ENDIF(PCH_METHOD EQUAL 1)
ENDIF()
IF(TARGET ${_targetName}_static)
ADD_NATIVE_PRECOMPILED_HEADER(${_targetName}_static ${_inputh} ${_inputcpp})
ENDIF(TARGET ${_targetName}_static)
ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)
ENDIF()
ENDMACRO()

View file

@ -102,10 +102,10 @@ ENDMACRO(NL_TARGET_DRIVER)
# Argument:
###
MACRO(NL_DEFAULT_PROPS name label)
IF(HAVE_REVISION_H)
IF(TARGET revision)
# explicitly say that the target depends on revision.h
ADD_DEPENDENCIES(${name} revision)
ENDIF(HAVE_REVISION_H)
ENDIF()
# Note: This is just a workaround for a CMake bug generating VS10 files with a colon in the project name.
# CMake Bug ID: http://www.cmake.org/Bug/view.php?id=11819
@ -375,6 +375,7 @@ MACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)
###
OPTION(WITH_LUA51 "Build Ryzom Core using Lua 5.1" ON )
OPTION(WITH_LUA52 "Build Ryzom Core using Lua 5.2" OFF)
OPTION(WITH_LUA53 "Build Ryzom Core using Lua 5.3" OFF)
OPTION(WITH_RYZOM_CLIENT_UAC "Ask to run as Administrator" OFF)
ENDMACRO(NL_SETUP_RYZOM_DEFAULT_OPTIONS)

View file

@ -429,7 +429,7 @@ private:
void resetTouchFlags() {_InternalFlags &= (uint16)(~TouchedAll);}
// Force non resident memory
void restaureNonResidentMemory();
void restoreNonResidentMemory();
// Convert current index to a serializable vector
void buildSerialVector(std::vector<uint32> &dest) const;

View file

@ -653,7 +653,7 @@ private:
void resetTouchFlags() {_InternalFlags &= (uint16)(~TouchedAll);}
// Force non resident memory
void restaureNonResidentMemory();
void restoreNonResidentMemory();
private:

View file

@ -151,8 +151,12 @@ namespace NLGUI
// called when keyboard capture has been lost
virtual void onKeyboardCaptureLost() {}
// 'tooltip' property expects string to be ucstring or latin1 which is not possible from html page
int luaSetTooltipUtf8(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlBase, CViewBase)
REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp);
REFLECT_LUA_METHOD("setTooltipUtf8", luaSetTooltipUtf8);
REFLECT_EXPORT_END
// special for mouse over : return true and fill the name of the cursor to display

View file

@ -64,8 +64,10 @@ namespace NLGUI
std::string languageCode;
/// List of domains the widget can consider secure.
std::vector< std::string > trustedDomains;
/// Maximum concurrent MultiCurl connections per CGroupHTML instance
sint32 curlMaxConnections;
SWebOptions()
SWebOptions(): curlMaxConnections(2)
{
}
};
@ -366,7 +368,7 @@ namespace NLGUI
bool _Connecting;
double _TimeoutValue; // the timeout in seconds
double _ConnectingTimeout;
uint32 _RedirectsRemaining;
sint _RedirectsRemaining;
// minimal embeded lua script support
// Note : any embeded script is executed immediately after the closing

View file

@ -239,6 +239,7 @@ namespace NLGUI
bool isNil(int index = -1);
bool isBoolean(int index = -1);
bool isNumber(int index = -1);
bool isInteger(int index = -1);
bool isString(int index = -1);
bool isTable(int index = -1);
bool isFunction(int index = -1);
@ -248,6 +249,7 @@ namespace NLGUI
// converting then getting a value from the stack
bool toBoolean(int index = -1);
lua_Number toNumber(int index = -1);
lua_Integer toInteger(int index = -1);
const char *toString(int index = -1);
void toString(int index, std::string &str); // convert to a std::string, with a NULL check.
size_t strlen(int index = -1);
@ -259,11 +261,21 @@ namespace NLGUI
* If conversion fails then an exception is thrown (with optional msg)
*/
bool getTableBooleanValue(const char *name, bool defaultValue= false);
double getTableNumberValue(const char *name, double defaultValue= 0);
double getTableNumberValue(const char *name, double defaultValue= 0.0);
sint64 getTableIntegerValue(const char *name, sint64 defaultValue= 0);
const char *getTableStringValue(const char *name, const char *defaultValue= NULL);
// pushing value onto the stack
void push(bool value);
void push(lua_Number value);
void push(float value);
void push(double value);
void push(uint8 value);
void push(uint16 value);
void push(uint32 value);
void push(uint64 value);
void push(sint8 value);
void push(sint16 value);
void push(sint32 value);
void push(sint64 value);
void push(const char *str);
void push(const char *str, int length);
void push(const std::string &str);

View file

@ -172,6 +172,18 @@ inline bool CLuaState::isNumber(int index)
return lua_isnumber(_State, index) != 0;
}
//================================================================================
inline bool CLuaState::isInteger(int index)
{
//H_AUTO(Lua_CLuaState_isInteger)
checkIndex(index);
#if LUA_VERSION_NUM >= 503
return lua_isinteger(_State, index) != 0;
#else
return lua_isnumber(_State, index) != 0;
#endif
}
//================================================================================
inline bool CLuaState::isString(int index)
{
@ -236,6 +248,14 @@ inline lua_Number CLuaState::toNumber(int index)
return lua_tonumber(_State, index);
}
//================================================================================
inline lua_Integer CLuaState::toInteger(int index)
{
//H_AUTO(Lua_CLuaState_toInteger)
checkIndex(index);
return lua_tointeger(_State, index);
}
//================================================================================
inline const char *CLuaState::toString(int index)
{
@ -302,11 +322,83 @@ inline void CLuaState::push(bool value)
}
//================================================================================
inline void CLuaState::push(lua_Number value)
inline void CLuaState::push(float value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushnumber(_State, value);
lua_pushnumber(_State, (lua_Number)value);
}
//================================================================================
inline void CLuaState::push(double value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushnumber(_State, (lua_Number)value);
}
//================================================================================
inline void CLuaState::push(uint8 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(uint16 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(uint32 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(uint64 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(sint8 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(sint16 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(sint32 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================
inline void CLuaState::push(sint64 value)
{
//H_AUTO(Lua_CLuaState_push)
nlverify( lua_checkstack(_State, 1) );
lua_pushinteger(_State, (lua_Integer)value);
}
//================================================================================

View file

@ -31,8 +31,8 @@ namespace NLGUI
class CLuaManager
{
public:
~CLuaManager();
/// Get or create singleton
static CLuaManager& getInstance()
{
if( instance == NULL )
@ -42,6 +42,9 @@ namespace NLGUI
return *instance;
}
/// Release singleton
static void releaseInstance();
/// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup.
static void enableLuaDebugging(){ debugLua = true; }
@ -65,6 +68,7 @@ namespace NLGUI
private:
CLuaManager();
~CLuaManager();
static CLuaManager *instance;
static bool debugLua;

View file

@ -80,6 +80,7 @@ namespace NLGUI
const char *getTypename() const;
bool isNil() const;
bool isNumber() const;
bool isInteger() const;
bool isBoolean() const;
bool isString() const;
bool isFunction() const;
@ -94,6 +95,7 @@ namespace NLGUI
NLMISC::CRGBA toRGBA() const; // default to black if not a crgba
bool toBoolean() const;
lua_Number toNumber() const;
lua_Integer toInteger() const;
std::string toString() const;
lua_CFunction toCFunction() const;
void *toUserData() const;
@ -102,6 +104,8 @@ namespace NLGUI
operator bool() const;
operator float() const;
operator double() const;
operator sint32() const;
operator sint64() const;
operator std::string() const;
/** create a sub table for this object, with a string as a key
* This object must be a table or an exception if thrown
@ -121,6 +125,9 @@ namespace NLGUI
void setValue(const char *key, bool value) throw(ELuaNotATable);
void setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable);
void setValue(const char *key, double value) throw(ELuaNotATable);
void setValue(const char *key, uint32 value) throw(ELuaNotATable);
void setValue(const char *key, sint32 value) throw(ELuaNotATable);
void setValue(const char *key, sint64 value) throw(ELuaNotATable);
void setValue(const std::string &key, const std::string &value) throw(ELuaNotATable) { setValue(key.c_str(), value); }
void setNil(const char *key) throw(ELuaNotATable);
void setNil(const std::string &key) throw(ELuaNotATable) { setNil(key.c_str()); }

View file

@ -569,7 +569,7 @@ namespace NLGUI
std::vector< CInterfaceGroup* > _GroupsUnderPointer;
// view that should be notified from clock msg
std::vector<CCtrlBase*> _ClockMsgTargets;
std::list<CCtrlBase*> _ClockMsgTargets;
NLMISC::CRGBA _GlobalColor;
NLMISC::CRGBA _GlobalColorForContent;

View file

@ -44,6 +44,7 @@ const uint32 DDS_HEADER = NL_MAKEFOURCC('D', 'D', 'S', ' ');
const uint32 DXT_HEADER = NL_MAKEFOURCC('D', 'X', 'T', '\0');
const uint32 PNG_HEADER = NL_MAKEFOURCC(0x89, 'P', 'N', 'G');
const uint32 JPG_HEADER = NL_MAKEFOURCC(0xff, 0xd8, 0xff, 0xe0);
const uint32 GIF_HEADER = NL_MAKEFOURCC('G', 'I', 'F', '8');
// dwLinearSize is valid
@ -132,6 +133,15 @@ private :
uint8 readJPG( NLMISC::IStream &f );
/**
* Read a GIF from an IStream.
* GIF pictures are all converted to 32bit
* \param f IStream (must be a reading stream)
* \return image depth if succeed, 0 else
*/
uint8 readGIF( NLMISC::IStream &f );
/**
* Change bitmap format
*

View file

@ -104,6 +104,11 @@ public:
*/
static const std::vector<std::string> &getLanguageCodes();
/** Check if a language code is supported.
* Code are ISO 639-2 compliant.
*/
static bool isLanguageCodeSupported(const std::string &lang);
/// Load a language file depending of the language code("en", "fr", ...). Code are ISO 639-2 compliant.
static void load (const std::string &languageCode, const std::string &fallbackLanguageCode="");
@ -119,6 +124,9 @@ public:
/// Returns the code of the language ("fr", "en", ...)
static std::string getCurrentLanguageCode ();
/// Returns the code of the language ("fr", "en", ...) defined on system
static std::string getSystemLanguageCode ();
/// Find a string in the selected language and return his association.
static const ucstring &get (const std::string &label);

View file

@ -178,7 +178,7 @@ void CCloud::generate (CNoise3d &noise)
_Driver->activeVertexBuffer (rVB);
_Driver->renderRawQuads (_CloudTexClamp->ToClamp, 0, 1);
// Restaure render target
// Restore render target
_Driver->setRenderTarget (NULL);
_CloudTexTmp->Tex->setFilterMode (ITexture::Nearest, ITexture::NearestMipMapOff);
@ -685,7 +685,7 @@ void CCloud::genBill (CCamera *pCam, uint32 nBillSize)
dispXYZ (&_CloudTexTmp->ToBill);
// Restaure render target
// Restore render target
_Driver->setRenderTarget (NULL);
// This is the end of render to texture like so reset all stuff

View file

@ -1912,7 +1912,7 @@ bool CDriverD3D::clear2D(CRGBA rgba)
bool result = _DeviceInterface->Clear( 0, NULL, D3DCLEAR_TARGET, NL_D3DCOLOR_RGBA(rgba), 1.0f, 0 ) == D3D_OK;
// Restaure the old viewport
// Restore the old viewport
setupViewport (oldViewport);
return result;
}
@ -1931,7 +1931,7 @@ bool CDriverD3D::clearZBuffer(float zval)
bool result = _DeviceInterface->Clear( 0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0,0,0,0), zval, 0 ) == D3D_OK;
// Restaure the old viewport
// Restore the old viewport
setupViewport (oldViewport);
// NVidia driver 56.72 needs to reset the vertex buffer after a clear Z
@ -1954,7 +1954,7 @@ bool CDriverD3D::clearStencilBuffer(float stencilval)
bool result = _DeviceInterface->Clear( 0, NULL, D3DCLEAR_STENCIL, D3DCOLOR_ARGB(0,0,0,0), 1.0f, (unsigned long)stencilval ) == D3D_OK;
// Restaure the old viewport
// Restore the old viewport
setupViewport (oldViewport);
return result;
@ -2526,7 +2526,7 @@ bool CDriverD3D::reset (const GfxMode& mode)
_CurrentMaterial = NULL;
_CurrentMaterialInfo = NULL;
// Restaure non managed vertex buffer in system memory
// Restore non managed vertex buffer in system memory
ItVBDrvInfoPtrList iteVb = _VBDrvInfos.begin();
while (iteVb != _VBDrvInfos.end())
{

View file

@ -1,4 +1,3 @@
LIBRARY nel_drv_direct3d_win_r
EXPORTS
NL3D_createIDriverInstance
NL3D_interfaceVersion

View file

@ -49,7 +49,7 @@ uint indexCount=0;
CIBDrvInfosD3D::~CIBDrvInfosD3D()
{
H_AUTO_D3D(CIBDrvInfosD3D_CIBDrvInfosD3DDtor);
// Restaure non resident memory
// Restore non resident memory
if (IndexBufferPtr)
{
IndexBufferPtr->setLocation(CIndexBuffer::NotResident);

View file

@ -818,7 +818,7 @@ bool CDriverD3D::setupMaterial(CMaterial &mat)
if (_CurrentMaterial != &mat)
{
// Material has changed ?
// Restaure fog state to its current value
// Restore fog state to its current value
{
H_AUTO_D3D(CDriverD3D_setupMaterial_updateFog)
setRenderState (D3DRS_FOGENABLE, _FogEnabled?TRUE:FALSE);

View file

@ -63,7 +63,7 @@ CVBDrvInfosD3D::~CVBDrvInfosD3D()
{
H_AUTO_D3D(CVBDrvInfosD3D_CVBDrvInfosD3D)
CDriverD3D *driver = static_cast<CDriverD3D*>(_Driver);
// Restaure non resident memory
// Restore non resident memory
if (VertexBufferPtr)
{
VertexBufferPtr->setLocation(CVertexBuffer::NotResident);

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@ extern "C" {
#endif
/*
** Copyright (c) 2013-2014 The Khronos Group Inc.
** Copyright (c) 2013-2015 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
@ -33,10 +33,10 @@ extern "C" {
** used to make the header, and the header can be found at
** http://www.opengl.org/registry/
**
** Khronos $Revision: 26290 $ on $Date: 2014-04-16 05:35:38 -0700 (Wed, 16 Apr 2014) $
** Khronos $Revision: 31597 $ on $Date: 2015-06-25 16:32:35 -0400 (Thu, 25 Jun 2015) $
*/
#define GLX_GLXEXT_VERSION 20140416
#define GLX_GLXEXT_VERSION 20150623
/* Generated C header for:
* API: glx
@ -158,6 +158,13 @@ __GLXextFuncPtr glXGetProcAddress (const GLubyte *procName);
#endif
#endif /* GLX_VERSION_1_4 */
#ifndef GLX_ARB_context_flush_control
#define GLX_ARB_context_flush_control 1
#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
#endif /* GLX_ARB_context_flush_control */
#ifndef GLX_ARB_create_context
#define GLX_ARB_create_context 1
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
@ -243,6 +250,26 @@ __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName);
#define GLX_GPU_NUM_SIMD_AMD 0x21A6
#define GLX_GPU_NUM_RB_AMD 0x21A7
#define GLX_GPU_NUM_SPI_AMD 0x21A8
typedef unsigned int ( *PFNGLXGETGPUIDSAMDPROC) (unsigned int maxCount, unsigned int *ids);
typedef int ( *PFNGLXGETGPUINFOAMDPROC) (unsigned int id, int property, GLenum dataType, unsigned int size, void *data);
typedef unsigned int ( *PFNGLXGETCONTEXTGPUIDAMDPROC) (GLXContext ctx);
typedef GLXContext ( *PFNGLXCREATEASSOCIATEDCONTEXTAMDPROC) (unsigned int id, GLXContext share_list);
typedef GLXContext ( *PFNGLXCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (unsigned int id, GLXContext share_context, const int *attribList);
typedef Bool ( *PFNGLXDELETEASSOCIATEDCONTEXTAMDPROC) (GLXContext ctx);
typedef Bool ( *PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (GLXContext ctx);
typedef GLXContext ( *PFNGLXGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
typedef void ( *PFNGLXBLITCONTEXTFRAMEBUFFERAMDPROC) (GLXContext dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#ifdef GLX_GLXEXT_PROTOTYPES
unsigned int glXGetGPUIDsAMD (unsigned int maxCount, unsigned int *ids);
int glXGetGPUInfoAMD (unsigned int id, int property, GLenum dataType, unsigned int size, void *data);
unsigned int glXGetContextGPUIDAMD (GLXContext ctx);
GLXContext glXCreateAssociatedContextAMD (unsigned int id, GLXContext share_list);
GLXContext glXCreateAssociatedContextAttribsAMD (unsigned int id, GLXContext share_context, const int *attribList);
Bool glXDeleteAssociatedContextAMD (GLXContext ctx);
Bool glXMakeAssociatedContextCurrentAMD (GLXContext ctx);
GLXContext glXGetCurrentAssociatedContextAMD (void);
void glXBlitContextFramebufferAMD (GLXContext dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
#endif /* GLX_AMD_gpu_association */
#ifndef GLX_EXT_buffer_age
@ -468,6 +495,16 @@ Bool glXSet3DfxModeMESA (int mode);
#endif
#endif /* GLX_MESA_set_3dfx_mode */
#ifndef GLX_NV_copy_buffer
#define GLX_NV_copy_buffer 1
typedef void ( *PFNGLXCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
typedef void ( *PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
#ifdef GLX_GLXEXT_PROTOTYPES
void glXCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
void glXNamedCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
#endif
#endif /* GLX_NV_copy_buffer */
#ifndef GLX_NV_copy_image
#define GLX_NV_copy_image 1
typedef void ( *PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
@ -544,8 +581,8 @@ void glXReleaseVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV devic
#endif
#endif /* GLX_NV_video_capture */
#ifndef GLX_NV_video_output
#define GLX_NV_video_output 1
#ifndef GLX_NV_video_out
#define GLX_NV_video_out 1
typedef unsigned int GLXVideoDeviceNV;
#define GLX_VIDEO_OUT_COLOR_NV 0x20C3
#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4
@ -571,7 +608,7 @@ int glXReleaseVideoImageNV (Display *dpy, GLXPbuffer pbuf);
int glXSendPbufferToVideoNV (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
int glXGetVideoInfoNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#endif
#endif /* GLX_NV_video_output */
#endif /* GLX_NV_video_out */
#ifndef GLX_OML_swap_method
#define GLX_OML_swap_method 1

View file

@ -6,7 +6,7 @@ extern "C" {
#endif
/*
** Copyright (c) 2013-2014 The Khronos Group Inc.
** Copyright (c) 2013-2015 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
@ -33,7 +33,7 @@ extern "C" {
** used to make the header, and the header can be found at
** http://www.opengl.org/registry/
**
** Khronos $Revision: 26290 $ on $Date: 2014-04-16 05:35:38 -0700 (Wed, 16 Apr 2014) $
** Khronos $Revision: 31597 $ on $Date: 2015-06-25 16:32:35 -0400 (Thu, 25 Jun 2015) $
*/
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
@ -41,7 +41,7 @@ extern "C" {
#include <windows.h>
#endif
#define WGL_WGLEXT_VERSION 20140416
#define WGL_WGLEXT_VERSION 20150623
/* Generated C header for:
* API: wgl
@ -70,6 +70,13 @@ BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width,
#endif
#endif /* WGL_ARB_buffer_region */
#ifndef WGL_ARB_context_flush_control
#define WGL_ARB_context_flush_control 1
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
#endif /* WGL_ARB_context_flush_control */
#ifndef WGL_ARB_create_context
#define WGL_ARB_create_context 1
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001

View file

@ -234,7 +234,7 @@ CDriverGL::CDriverGL()
_CursorScale = 1.f;
_MouseCaptured = false;
_NeedToRestaureGammaRamp = false;
_NeedToRestoreGammaRamp = false;
_win = EmptyWindow;
_WindowX = 0;

View file

@ -1,4 +1,3 @@
LIBRARY nel_drv_opengl_win_r
EXPORTS
NL3D_createIDriverInstance
NL3D_interfaceVersion

View file

@ -1558,7 +1558,7 @@ private:
// Monitor color parameters backup
bool _NeedToRestaureGammaRamp;
bool _NeedToRestoreGammaRamp;
uint16 _GammaRampBackuped[3*256];

View file

@ -519,6 +519,14 @@ PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC nwglMakeAssociatedContextCurrentAMD;
PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC nwglGetCurrentAssociatedContextAMD;
PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC nwglBlitContextFramebufferAMD;
// WGL_NV_gpu_affinity
//====================
PFNWGLENUMGPUSNVPROC nwglEnumGpusNV;
PFNWGLENUMGPUDEVICESNVPROC nwglEnumGpuDevicesNV;
PFNWGLCREATEAFFINITYDCNVPROC nwglCreateAffinityDCNV;
PFNWGLENUMGPUSFROMAFFINITYDCNVPROC nwglEnumGpusFromAffinityDCNV;
PFNWGLDELETEDCNVPROC nwglDeleteDCNV;
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)
@ -1553,12 +1561,20 @@ static bool setupATIMeminfo(const char *glext)
void registerGlExtensions(CGlExtensions &ext)
{
H_AUTO_OGL(registerGlExtensions);
// OpenGL 1.2 ??
const char *nglVersion= (const char *)glGetString (GL_VERSION);
sint a=0, b=0;
// 1.2*** ???
sscanf(nglVersion, "%d.%d", &a, &b);
ext.Version1_2= (a==1 && b>=2) || (a>=2);
ext.Version1_2 = (a==1 && b>=2) || (a>=2);
const char *vendor = (const char *) glGetString (GL_VENDOR);
const char *renderer = (const char *) glGetString (GL_RENDERER);
// Log GPU details
nlinfo("3D: OpenGL %s / %s / %s", nglVersion, vendor, renderer);
// Extensions.
const char *glext= (const char*)glGetString(GL_EXTENSIONS);
@ -1777,17 +1793,30 @@ void registerGlExtensions(CGlExtensions &ext)
if (ext.NVXGPUMemoryInfo)
{
// GPU_MEMORY_INFO_EVICTION_COUNT_NVX;
// GPU_MEMORY_INFO_EVICTED_MEMORY_NVX;
GLint nEvictionCount = 0;
#ifdef GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
glGetIntegerv(GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX, &nEvictionCount);
#endif
GLint nEvictionMemory = 0;
#ifdef GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
glGetIntegerv(GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX, &nEvictionMemory);
#endif
GLint nDedicatedMemoryInKB = 0;
#ifdef GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &nDedicatedMemoryInKB);
#endif
GLint nTotalMemoryInKB = 0;
#ifdef GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &nTotalMemoryInKB);
#endif
GLint nCurAvailMemoryInKB = 0;
#ifdef GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &nCurAvailMemoryInKB);
#endif
nlinfo("Memory: total: %d available: %d dedicated: %d", nTotalMemoryInKB, nCurAvailMemoryInKB, nDedicatedMemoryInKB);
}
@ -1840,7 +1869,23 @@ static bool setupWGLAMDGPUAssociation(const char *glext)
return true;
}
// *********************************
// ***************************************************************************
static bool setupWGLNVGPUAssociation(const char *glext)
{
H_AUTO_OGL(setupWGLNVGPUAssociation);
CHECK_EXT("WGL_NV_gpu_affinity");
#if !defined(USE_OPENGLES) && defined(NL_OS_WINDOWS)
CHECK_ADDRESS(PFNWGLENUMGPUSNVPROC, wglEnumGpusNV);
CHECK_ADDRESS(PFNWGLENUMGPUDEVICESNVPROC, wglEnumGpuDevicesNV);
CHECK_ADDRESS(PFNWGLCREATEAFFINITYDCNVPROC, wglCreateAffinityDCNV);
CHECK_ADDRESS(PFNWGLENUMGPUSFROMAFFINITYDCNVPROC, wglEnumGpusFromAffinityDCNV);
CHECK_ADDRESS(PFNWGLDELETEDCNVPROC, wglDeleteDCNV);
#endif
return true;
}
static bool setupGLXEXTSwapControl(const char *glext)
{
H_AUTO_OGL(setupGLXEXTSwapControl);
@ -1966,6 +2011,31 @@ bool registerWGlExtensions(CGlExtensions &ext, HDC hDC)
delete [] uGPUIDs;
}
ext.WGLNVGPUAffinity = setupWGLNVGPUAssociation(glext);
if (ext.WGLNVGPUAffinity)
{
uint i = 0;
HGPUNV hGPU;
while(nwglEnumGpusNV(i, &hGPU))
{
uint j = 0;
PGPU_DEVICE lpGpuDevice = NULL;
while(nwglEnumGpuDevicesNV(hGPU, j, lpGpuDevice))
{
nlinfo("Device: %s - %s - flags: %u", lpGpuDevice->DeviceName, lpGpuDevice->DeviceString, lpGpuDevice->Flags);
++j;
}
++i;
}
}
return true;
}
#elif defined(NL_OS_MAC)

View file

@ -123,6 +123,9 @@ struct CGlExtensions
// WGL_AMD_gpu_association
bool WGLAMDGPUAssociation;
// WGL_NV_gpu_affinity
bool WGLNVGPUAffinity;
public:
/// \name Disable Hardware feature. False by default. setuped by IDriver
@ -793,6 +796,13 @@ extern PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC nwglMakeAssociatedContextCurren
extern PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC nwglGetCurrentAssociatedContextAMD;
extern PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC nwglBlitContextFramebufferAMD;
// WGL_NV_gpu_affinity
//====================
extern PFNWGLENUMGPUSNVPROC nwglEnumGpusNV;
extern PFNWGLENUMGPUDEVICESNVPROC nwglEnumGpuDevicesNV;
extern PFNWGLCREATEAFFINITYDCNVPROC nwglCreateAffinityDCNV;
extern PFNWGLENUMGPUSFROMAFFINITYDCNVPROC nwglEnumGpusFromAffinityDCNV;
extern PFNWGLDELETEDCNVPROC nwglDeleteDCNV;
#elif defined(NL_OS_MAC)
#elif defined(NL_OS_UNIX)

View file

@ -532,7 +532,7 @@ bool CDriverGL::setupMaterial(CMaterial& mat)
}
else
{
// Restaure fog state to its current value
// Restore fog state to its current value
_DriverGLStates.enableFog(_FogEnabled);
}

View file

@ -71,7 +71,7 @@ CVBDrvInfosGL::CVBDrvInfosGL(CDriverGL *drv, ItVBDrvInfoPtrList it, CVertexBuffe
CVBDrvInfosGL::~CVBDrvInfosGL()
{
H_AUTO_OGL(CVBDrvInfosGL_CVBDrvInfosGLDtor)
// Restaure non resident memory
// Restore non resident memory
if (VertexBufferPtr)
{
VertexBufferPtr->setLocation(CVertexBuffer::NotResident);

View file

@ -329,7 +329,7 @@ bool CDriverGL::init (uintptr_t windowIcon, emptyProc exitFunc)
HDC dc = CreateDC ("DISPLAY", NULL, NULL, NULL);
if (dc)
{
_NeedToRestaureGammaRamp = GetDeviceGammaRamp (dc, _GammaRampBackuped) != FALSE;
_NeedToRestoreGammaRamp = GetDeviceGammaRamp (dc, _GammaRampBackuped) != FALSE;
// Release the DC
ReleaseDC (NULL, dc);
@ -465,8 +465,8 @@ bool CDriverGL::unInit()
}
_Registered = 0;
// Restaure monitor color parameters
if (_NeedToRestaureGammaRamp)
// Restore monitor color parameters
if (_NeedToRestoreGammaRamp)
{
HDC dc = CreateDC ("DISPLAY", NULL, NULL, NULL);
if (dc)
@ -1738,7 +1738,9 @@ bool CDriverGL::setWindowStyle(EWindowStyle windowStyle)
}
else if (windowStyle == EWSFullscreen)
{
#ifndef _DEBUG
dwNewStyle |= WS_POPUP;
#endif
isVisible = true;
}
@ -1756,14 +1758,14 @@ bool CDriverGL::setWindowStyle(EWindowStyle windowStyle)
#elif defined(NL_OS_MAC)
// leave fullscreen mode, enter windowed mode
if(windowStyle == EWSWindowed && [containerView() isInFullScreenMode])
if (windowStyle == EWSWindowed && [containerView() isInFullScreenMode])
{
// disable manual setting of back buffer size, cocoa handles this
// automatically as soon as the view gets resized
CGLError error = CGLDisable((CGLContextObj)[_ctx CGLContextObj],
kCGLCESurfaceBackingSize);
if(error != kCGLNoError)
if (error != kCGLNoError)
nlerror("cannot disable kCGLCESurfaceBackingSize (%s)",
CGLErrorString(error));
@ -1778,20 +1780,20 @@ bool CDriverGL::setWindowStyle(EWindowStyle windowStyle)
}
// enter fullscreen, leave windowed mode
else if(windowStyle == EWSFullscreen && ![containerView() isInFullScreenMode])
else if (windowStyle == EWSFullscreen && ![containerView() isInFullScreenMode])
{
// enable manual back buffer size for mode setting in fullscreen
CGLError error = CGLEnable((CGLContextObj)[_ctx CGLContextObj],
kCGLCESurfaceBackingSize);
if(error != kCGLNoError)
if (error != kCGLNoError)
nlerror("cannot enable kCGLCESurfaceBackingSize (%s)",
CGLErrorString(error));
// put the view in fullscreen mode, hiding the dock but enabling the menubar
// to pop up if the mouse hits the top screen border.
// NOTE: withOptions:nil disables <CMD>+<Tab> application switching!
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
#ifdef NL_MAC_VERSION_10_6_UP
[containerView() enterFullScreenMode:[NSScreen mainScreen] withOptions:
[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:
@ -1915,8 +1917,9 @@ bool CDriverGL::setMode(const GfxMode& mode)
return true;
}
#if defined(NL_OS_MAC) && defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
#ifdef NL_OS_MAC
#ifdef NL_MAC_VERSION_10_6_UP
/// helper to extract bits per pixel value from screen mode, only 16 or 32 bits
static int bppFromDisplayMode(CGDisplayModeRef mode)
@ -1934,7 +1937,7 @@ static int bppFromDisplayMode(CGDisplayModeRef mode)
return 0;
}
#elif defined(NL_OS_MAC)
#else
long GetDictionaryLong(CFDictionaryRef theDict, const void* key)
{
@ -1951,7 +1954,9 @@ long GetDictionaryLong(CFDictionaryRef theDict, const void* key)
#define GetModeHeight(mode) GetDictionaryLong((mode), kCGDisplayHeight)
#define GetModeBitsPerPixel(mode) GetDictionaryLong((mode), kCGDisplayBitsPerPixel)
#endif // defined(NL_OS_MAC)
#endif
#endif // NL_OS_MAC
// --------------------------------------------------
bool CDriverGL::getModes(std::vector<GfxMode> &modes)
@ -1998,7 +2003,7 @@ bool CDriverGL::getModes(std::vector<GfxMode> &modes)
{
CGDirectDisplayID dspy = display[i];
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
#ifdef NL_MAC_VERSION_10_6_UP
CFArrayRef modeList = CGDisplayCopyAllDisplayModes(dspy, NULL);
#else
CFArrayRef modeList = CGDisplayAvailableModes(dspy);
@ -2012,7 +2017,7 @@ bool CDriverGL::getModes(std::vector<GfxMode> &modes)
for (CFIndex j = 0; j < CFArrayGetCount(modeList); ++j)
{
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
#ifdef NL_MAC_VERSION_10_6_UP
CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modeList, j);
uint8 bpp = bppFromDisplayMode(mode);
#else
@ -2022,7 +2027,7 @@ bool CDriverGL::getModes(std::vector<GfxMode> &modes)
if (bpp >= 16)
{
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
#ifdef NL_MAC_VERSION_10_6_UP
uint16 w = CGDisplayModeGetWidth(mode);
uint16 h = CGDisplayModeGetHeight(mode);
#else
@ -2045,6 +2050,10 @@ bool CDriverGL::getModes(std::vector<GfxMode> &modes)
// nldebug(" Display 0x%x: Mode %dx%d, %d BPP", dspy, w, h, bpp);
}
}
#ifdef NL_MAC_VERSION_10_6_UP
CFRelease(modeList);
#endif
}
#elif defined (NL_OS_UNIX)

View file

@ -27,7 +27,7 @@ using NL3D::CDriverGL;
#endif
@interface CocoaApplicationDelegate : NSObject
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
#ifdef NL_MAC_VERSION_10_6_UP
<NSApplicationDelegate>
#endif
{

View file

@ -14,6 +14,7 @@
// 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 "../stdopengl.h"
#include "cocoa_event_emitter.h"
namespace NLMISC
@ -380,7 +381,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
case NSOtherMouseDown:break;
case NSOtherMouseUp:break;
case NSOtherMouseDragged:break;
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
#ifdef NL_MAC_VERSION_10_6_UP
case NSEventTypeGesture:break;
case NSEventTypeMagnify:break;
case NSEventTypeSwipe:break;

View file

@ -47,7 +47,7 @@ static void viewDidResize(NSView* view, CDriverGL* driver)
-(void)keyDown:(NSEvent*)event
{
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
#ifdef NL_MAC_VERSION_10_6_UP
[[self inputContext] handleEvent:event];
#endif
}

View file

@ -28,7 +28,7 @@ using NL3D::CDriverGL;
#endif
@interface CocoaWindowDelegate : NSObject
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
#ifdef NL_MAC_VERSION_10_6_UP
<NSWindowDelegate>
#endif
{

View file

@ -31,8 +31,7 @@ static void windowDidMove(NSWindow* window, CDriverGL* driver)
driver->_WindowX = windowRect.origin.x;
// map y from cocoa to NeL coordinates before setting in driver
driver->_WindowY =
screenRect.size.height - windowRect.size.height - windowRect.origin.y;
driver->_WindowY = screenRect.size.height - windowRect.size.height - windowRect.origin.y;
}
@implementation CocoaWindowDelegate

View file

@ -100,4 +100,11 @@
#include "nel/3d/light.h"
#include "nel/3d/index_buffer.h"
#ifdef NL_OS_MAC
#include <AvailabilityMacros.h>
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
#define NL_MAC_VERSION_10_6_UP
#endif
#endif
#endif

View file

@ -106,7 +106,7 @@ CIndexBuffer::~CIndexBuffer()
// Single value
if (DrvInfos)
DrvInfos->IndexBufferPtr = NULL; // Tell the driver info to not restaure memory when it will die
DrvInfos->IndexBufferPtr = NULL; // Tell the driver info to not restore memory when it will die
// Must kill the drv mirror of this VB.
DrvInfos.kill();
@ -144,7 +144,7 @@ void CIndexBuffer::setPreferredMemory (TPreferredMemory preferredMemory, bool ke
_KeepLocalMemory = keepLocalMemory;
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
}
}
@ -159,7 +159,7 @@ void CIndexBuffer::reserve(uint32 n)
_NbIndexes=std::min (_NbIndexes,_Capacity);
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
}
}
@ -206,7 +206,7 @@ void CIndexBuffer::deleteAllIndexes()
}
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
// Delete driver info
nlassert (DrvInfos == NULL);
@ -276,12 +276,12 @@ void CIndexBuffer::setLocation (TLocation newLocation)
// ***************************************************************************
void CIndexBuffer::restaureNonResidentMemory()
void CIndexBuffer::restoreNonResidentMemory()
{
setLocation (NotResident);
if (DrvInfos)
DrvInfos->IndexBufferPtr = NULL; // Tell the driver info to not restaure memory when it will die
DrvInfos->IndexBufferPtr = NULL; // Tell the driver info to not restore memory when it will die
// Must kill the drv mirror of this VB.
DrvInfos.kill();
@ -407,7 +407,7 @@ void CIndexBuffer::serial(NLMISC::IStream &f)
if (f.isReading())
{
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
}
}

View file

@ -166,7 +166,7 @@ CVertexBuffer::~CVertexBuffer()
* ***********************************************/
if (DrvInfos)
DrvInfos->VertexBufferPtr = NULL; // Tell the driver info to not restaure memory when it will die
DrvInfos->VertexBufferPtr = NULL; // Tell the driver info to not restore memory when it will die
// Must kill the drv mirror of this VB.
DrvInfos.kill();
@ -302,7 +302,7 @@ bool CVertexBuffer::setVertexFormat(uint32 flags)
initEx ();
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
return (true);
}
@ -468,7 +468,7 @@ void CVertexBuffer::initEx ()
_Capacity = 0;
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
}
// --------------------------------------------------
@ -482,7 +482,7 @@ void CVertexBuffer::reserve(uint32 n)
_NbVerts=std::min (_NbVerts,_Capacity);
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
}
}
@ -518,7 +518,7 @@ void CVertexBuffer::deleteAllVertices()
}
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
// Delete driver info
nlassert (DrvInfos == NULL);
@ -725,7 +725,7 @@ void CVertexBuffer::serialOldV1Minus(NLMISC::IStream &f, sint ver)
if(f.isReading())
{
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
}
}
@ -979,7 +979,7 @@ void CVertexBuffer::serialSubset(NLMISC::IStream &f, uint vertexStart, uint ver
if(f.isReading())
{
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
}
}
@ -1029,7 +1029,7 @@ bool CVertexBuffer::setVertexColorFormat (TVertexColorType format)
_VertexColorFormat = (uint8)format;
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
}
return true;
}
@ -1044,7 +1044,7 @@ void CVertexBuffer::setPreferredMemory (TPreferredMemory preferredMemory, bool k
_KeepLocalMemory = keepLocalMemory;
// Force non resident
restaureNonResidentMemory();
restoreNonResidentMemory();
}
}
@ -1110,12 +1110,12 @@ void CVertexBuffer::setLocation (TLocation newLocation)
}
// --------------------------------------------------
void CVertexBuffer::restaureNonResidentMemory()
void CVertexBuffer::restoreNonResidentMemory()
{
setLocation (NotResident);
if (DrvInfos)
DrvInfos->VertexBufferPtr = NULL; // Tell the driver info to not restaure memory when it will die
DrvInfos->VertexBufferPtr = NULL; // Tell the driver info to not restore memory when it will die
// Must kill the drv mirror of this VB.
DrvInfos.kill();

View file

@ -19,6 +19,7 @@
#include "libxml/globals.h"
#include "nel/misc/debug.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/lua_ihm.h"
#include "nel/gui/ctrl_base.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h"
@ -556,5 +557,17 @@ namespace NLGUI
return itr2->second;
}
// ***************************************************************************
int CCtrlBase::luaSetTooltipUtf8(CLuaState &ls)
{
const char *funcName = "setTooltipUtf8";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
std::string tooltip = ls.toString(1);
setDefaultContextHelp(ucstring::makeFromUtf8(tooltip));
return 0;
}
}

View file

@ -169,25 +169,25 @@ namespace NLGUI
if( _ColSelR.getNodePtr() != NULL )
s = _ColSelR.getNodePtr()->getFullName();
else
s = "";
s.clear();
xmlSetProp( node, BAD_CAST "dbcolr", BAD_CAST s.c_str() );
if( _ColSelG.getNodePtr() != NULL )
s = _ColSelG.getNodePtr()->getFullName();
else
s = "";
s.clear();
xmlSetProp( node, BAD_CAST "dbcolg", BAD_CAST s.c_str() );
if( _ColSelB.getNodePtr() != NULL )
s = _ColSelB.getNodePtr()->getFullName();
else
s = "";
s.clear();
xmlSetProp( node, BAD_CAST "dbcolb", BAD_CAST s.c_str() );
if( _ColSelA.getNodePtr() != NULL )
s = _ColSelA.getNodePtr()->getFullName();
else
s = "";
s.clear();
xmlSetProp( node, BAD_CAST "dbcola", BAD_CAST s.c_str() );
return node;

View file

@ -519,17 +519,17 @@ namespace NLGUI
// Read Action handlers
prop = (char*) xmlGetProp( node, (xmlChar*)"onscroll" );
if (prop) _AHOnScroll = NLMISC::strlwr(prop.str());
if (prop) _AHOnScroll = NLMISC::toLower(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"params" );
if (prop) _AHOnScrollParams = string((const char*)prop);
//
prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollend" );
if (prop) _AHOnScrollEnd = NLMISC::strlwr(prop.str());
if (prop) _AHOnScrollEnd = NLMISC::toLower(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"end_params" );
if (prop) _AHOnScrollEndParams = string((const char*)prop);
//
prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollcancel" );
if (prop) _AHOnScrollCancel = NLMISC::strlwr(prop.str());
if (prop) _AHOnScrollCancel = NLMISC::toLower(prop.str());
prop = (char*) xmlGetProp( node, (xmlChar*)"cancel_params" );
if (prop) _AHOnScrollCancelParams = string((const char*)prop);

View file

@ -543,7 +543,7 @@ namespace NLGUI
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring text;
nlverify(CLuaIHM::pop(ls, text));
setText((uint) ls.toNumber(1), text);
setText((uint) ls.toInteger(1), text);
return 0;
}
@ -556,7 +556,7 @@ namespace NLGUI
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring text;
nlverify(CLuaIHM::pop(ls, text));
insertText((uint) ls.toNumber(1), text);
insertText((uint) ls.toInteger(1), text);
return 0;
}
@ -569,7 +569,7 @@ namespace NLGUI
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
ucstring texture;
nlverify(CLuaIHM::pop(ls, texture));
setTexture((uint) ls.toNumber(1), texture);
setTexture((uint) ls.toInteger(1), texture);
return 0;
}
@ -579,7 +579,7 @@ namespace NLGUI
const char *funcName = "setText";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CLuaIHM::push(ls, getText((uint) ls.toNumber(1)));
CLuaIHM::push(ls, getText((uint) ls.toInteger(1)));
return 1;
}
@ -589,7 +589,7 @@ namespace NLGUI
const char *funcName = "removeText";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
removeText((uint) ls.toNumber(1));
removeText((uint) ls.toInteger(1));
return 0;
}
@ -598,7 +598,7 @@ namespace NLGUI
{
const char *funcName = "getNumTexts";
CLuaIHM::checkArgCount(ls, funcName, 0);
ls.push((double) getNumTexts());
ls.push(getNumTexts());
return 1;
}

View file

@ -4820,7 +4820,7 @@ namespace NLGUI
const char *funcName = "blink";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
enableBlink((uint) ls.toNumber(1));
enableBlink((uint) ls.toInteger(1));
return 0;
}

View file

@ -606,11 +606,7 @@ namespace NLGUI
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" );
if (prop)
{
string tmp = (const char *) prop;
_ListMenuRight = strlwr(tmp);
}
if (prop) _ListMenuRight = toLower((const char *) prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"max_historic" );
if (prop) fromString((const char*)prop, _MaxHistoric);

View file

@ -202,7 +202,7 @@ namespace NLGUI
const char *funcName = "enlargeColumns";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
enlargeColumns((sint32) ls.toNumber(1));
enlargeColumns((sint32) ls.toInteger(1));
return 0;
}
@ -212,7 +212,7 @@ namespace NLGUI
const char *funcName = "resizeColumnsAndContainer";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
resizeColumnsAndContainer((sint32) ls.toNumber(1));
resizeColumnsAndContainer((sint32) ls.toInteger(1));
return 0;
}

View file

@ -772,8 +772,7 @@ namespace NLGUI
cellParams.NoWrap = true; \
if (present[prefix##_ALIGN] && value[prefix##_ALIGN]) \
{ \
string align = value[prefix##_ALIGN]; \
align = strlwr(align); \
string align = toLower(value[prefix##_ALIGN]); \
if (align == "left") \
cellParams.Align = CGroupCell::Left; \
if (align == "center") \
@ -783,8 +782,7 @@ namespace NLGUI
} \
if (present[prefix##_VALIGN] && value[prefix##_VALIGN]) \
{ \
string align = value[prefix##_VALIGN]; \
align = strlwr(align); \
string align = toLower(value[prefix##_VALIGN]); \
if (align == "top") \
cellParams.VAlign = CGroupCell::Top; \
if (align == "middle") \
@ -1182,7 +1180,7 @@ namespace NLGUI
if (it != styles.end())
{
string image = it->second;
string::size_type texExt = strlwr(image).find("url(");
string::size_type texExt = toLower(image).find("url(");
// Url image
if (texExt != string::npos)
// Remove url()
@ -1321,8 +1319,7 @@ namespace NLGUI
if (present[MY_HTML_INPUT_ALT] && value[MY_HTML_INPUT_ALT])
tooltip = value[MY_HTML_INPUT_ALT];
string type = value[MY_HTML_INPUT_TYPE];
type = strlwr (type);
string type = toLower(value[MY_HTML_INPUT_TYPE]);
if (type == "image")
{
// The submit button
@ -1668,7 +1665,7 @@ namespace NLGUI
{
nlinfo("found background-image %s", it->second.c_str());
string image = (*it).second;
string::size_type texExt = strlwr(image).find("url(");
string::size_type texExt = toLower(image).find("url(");
// Url image
if (texExt != string::npos)
{
@ -2090,6 +2087,14 @@ namespace NLGUI
clearContext();
MultiCurl = curl_multi_init();
if (MultiCurl)
{
#ifdef CURLMOPT_MAX_HOST_CONNECTIONS
// added in libcurl 7.30.0
curl_multi_setopt(MultiCurl, CURLMOPT_MAX_HOST_CONNECTIONS, options.curlMaxConnections);
#endif
curl_multi_setopt(MultiCurl, CURLMOPT_PIPELINING, 1);
}
RunningCurls = 0;
_CurlWWW = NULL;
@ -3613,7 +3618,7 @@ namespace NLGUI
}
else
{
ctrlButton->setDefaultContextHelp(ucstring(tooltip));
ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(tooltip));
//ctrlButton->setOnContextHelp(string(tooltip));
}
@ -3818,7 +3823,7 @@ namespace NLGUI
// folder used for images cache
static const string cacheDir = "cache";
string::size_type protocolPos = strlwr(result).find("://");
string::size_type protocolPos = toLower(result).find("://");
if (protocolPos != string::npos)
{
@ -3832,7 +3837,7 @@ namespace NLGUI
else
{
// Url is a file ?
if (strlwr(result).find("file:") == 0)
if (toLower(result).find("file:") == 0)
{
result = result.substr(5, result.size()-5);
}
@ -3849,7 +3854,7 @@ namespace NLGUI
{
// Normalize the path
if (isUrl)
//result = "file:"+strlwr(CPath::standardizePath (CPath::getFullPath (CFile::getPath(result)))+CFile::getFilename(result));*/
//result = "file:"+toLower(CPath::standardizePath (CPath::getFullPath (CFile::getPath(result)))+CFile::getFilename(result));*/
result = "file:/"+tmp;
else
result = tmp;
@ -4106,7 +4111,7 @@ namespace NLGUI
void CGroupHTML::doBrowseLocalFile(const std::string &uri)
{
std::string filename;
if (strlwr(uri).find("file:/") == 0)
if (toLower(uri).find("file:/") == 0)
{
filename = uri.substr(6, uri.size() - 6);
}
@ -4720,7 +4725,7 @@ namespace NLGUI
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TTABLE);
uint element_number = (uint)ls.toNumber(1);
uint element_number = (uint)ls.toInteger(1);
std::vector<bool> present;
std::vector<const char *> value;
present.resize(30, false);
@ -4733,7 +4738,7 @@ namespace NLGUI
ENUM_LUA_TABLE(params, it)
{
if (!it.nextKey().isNumber())
if (!it.nextKey().isInteger())
{
nlwarning("%s : bad key encountered with type %s, number expected.", funcName, it.nextKey().getTypename());
continue;
@ -4743,16 +4748,16 @@ namespace NLGUI
nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str());
continue;
}
uint idx = (uint)it.nextKey().toNumber();
uint idx = (uint)it.nextKey().toInteger();
present.insert(present.begin() + (uint)it.nextKey().toNumber(), true);
present.insert(present.begin() + (uint)it.nextKey().toInteger(), true);
string str = it.nextValue().toString();
size_t size = str.size() + 1;
char * buffer = new char[ size ];
strncpy(buffer, str.c_str(), size );
value.insert(value.begin() + (uint)it.nextKey().toNumber(), buffer);
value.insert(value.begin() + (uint)it.nextKey().toInteger(), buffer);
}
beginElement(element_number, present, value);
@ -4770,7 +4775,7 @@ namespace NLGUI
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
uint element_number = (uint)ls.toNumber(1);
uint element_number = (uint)ls.toInteger(1);
endElement(element_number);
return 0;
@ -4970,7 +4975,7 @@ namespace NLGUI
else
if (it->first == "text-decoration" || it->first == "text-decoration-line")
{
std::string prop(strlwr(it->second));
std::string prop(toLower(it->second));
style.Underlined = (prop.find("underline") != std::string::npos);
style.StrikeThrough = (prop.find("line-through") != std::string::npos);
}

View file

@ -1145,7 +1145,7 @@ namespace NLGUI
{
CLuaIHM::checkArgCount(ls, "getElementIndex", 1);
CViewBase * viewBase = dynamic_cast<CViewBase *>(CLuaIHM::getUIOnStack(ls, 1));
ls.push((double) getElementIndex(viewBase));
ls.push(getElementIndex(viewBase));
return 1;
}
@ -1224,7 +1224,7 @@ namespace NLGUI
const char *funcName = "getChild";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
sint index = (sint) ls.toNumber(1);
sint index = (sint) ls.toInteger(1);
if(index < 0 || index >= (sint) _Elements.size())
{
CLuaIHM::fails(ls, "getChild : trying to access element %d in list '%s', which has %d elements",
@ -1304,10 +1304,10 @@ namespace NLGUI
ucstring ucText;
ucText.fromUtf8(text);
uint r = (uint) ls.toNumber(2);
uint g = (uint) ls.toNumber(3);
uint b = (uint) ls.toNumber(4);
uint a = (uint) ls.toNumber(5);
uint r = (uint) ls.toInteger(2);
uint g = (uint) ls.toInteger(3);
uint b = (uint) ls.toInteger(4);
uint a = (uint) ls.toInteger(5);
addTextChild(ucText, CRGBA(r, g, b, a));
@ -1344,7 +1344,7 @@ namespace NLGUI
}
else
{
addChildAtIndex(vb, (uint) ls.toNumber(2));
addChildAtIndex(vb, (uint) ls.toInteger(2));
}
return 0;
}

View file

@ -1702,7 +1702,7 @@ namespace NLGUI
int CGroupSubMenu::luaGetNumLine(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "getNumLine", 0);
ls.push((double) getNumLine());
ls.push(getNumLine());
return 1;
}
@ -1712,7 +1712,7 @@ namespace NLGUI
const char *funcName = "getSubMenu";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1)));
CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toInteger(1)));
return 1;
}
@ -1722,8 +1722,8 @@ namespace NLGUI
const char *funcName = "addSubMenu";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
setSubMenu((uint) ls.toNumber(1), new CGroupSubMenu(CViewText::TCtorParam()));
CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1)));
setSubMenu((uint) ls.toInteger(1), new CGroupSubMenu(CViewText::TCtorParam()));
CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toInteger(1)));
return 1;
}
@ -1733,7 +1733,7 @@ namespace NLGUI
const char *funcName = "getLineId";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
std::string id = getLineId((uint) ls.toNumber(1));
std::string id = getLineId((uint) ls.toInteger(1));
CLuaIHM::push(ls, id);
return 1;
}
@ -1744,7 +1744,7 @@ namespace NLGUI
const char *funcName = "getLineFromId";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
ls.push((double) getLineFromId(ls.toString(1)));
ls.push(getLineFromId(ls.toString(1)));
return 1;
}
@ -1754,7 +1754,7 @@ namespace NLGUI
const char *funcName = "isSeparator";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
ls.push(isSeparator((uint) ls.toNumber(1)));
ls.push(isSeparator((uint) ls.toInteger(1)));
return 1;
}
@ -1785,7 +1785,7 @@ namespace NLGUI
CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING);
ucstring arg2;
nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2));
addLineAtIndex((uint) ls.toNumber(1), arg2, ls.toString(3), ls.toString(4), ls.toString(5));
addLineAtIndex((uint) ls.toInteger(1), arg2, ls.toString(3), ls.toString(4), ls.toString(5));
return 0;
}
@ -1803,7 +1803,7 @@ namespace NLGUI
const char *funcName = "addSeparatorAtIndex";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
addSeparatorAtIndex((uint) ls.toNumber(1));
addSeparatorAtIndex((uint) ls.toInteger(1));
return 0;
}
@ -1813,7 +1813,7 @@ namespace NLGUI
const char *funcName = "removeLine";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
removeLine((uint) ls.toNumber(1));
removeLine((uint) ls.toInteger(1));
return 0;
}
@ -1833,7 +1833,7 @@ namespace NLGUI
{
CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName);
}
setUserGroupRight((uint) ls.toNumber(1), group, true);
setUserGroupRight((uint) ls.toInteger(1), group, true);
return 0;
}
@ -1853,7 +1853,7 @@ namespace NLGUI
{
CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName);
}
setUserGroupLeft((uint) ls.toNumber(1), group, true);
setUserGroupLeft((uint) ls.toInteger(1), group, true);
return 0;
}
@ -1864,7 +1864,7 @@ namespace NLGUI
const char *funcName = "getUserGroupRight";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CLuaIHM::pushUIOnStack(ls, getUserGroupRight((uint) ls.toNumber(1)));
CLuaIHM::pushUIOnStack(ls, getUserGroupRight((uint) ls.toInteger(1)));
return 1;
}
@ -1875,7 +1875,7 @@ namespace NLGUI
const char *funcName = "getUserGroupLeft";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CInterfaceElement *pIE = getUserGroupLeft((uint) ls.toNumber(1));
CInterfaceElement *pIE = getUserGroupLeft((uint) ls.toInteger(1));
if (pIE)
{
CLuaIHM::pushUIOnStack(ls, pIE);
@ -1890,7 +1890,7 @@ namespace NLGUI
const char *funcName = "setMaxVisibleLine";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
setMaxVisibleLine((uint) ls.toNumber(1));
setMaxVisibleLine((uint) ls.toInteger(1));
return 0;
}
@ -2566,7 +2566,7 @@ namespace NLGUI
const char *funcName = "setMinW";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
setMinW((sint32) ls.toNumber(1));
setMinW((sint32) ls.toInteger(1));
return 0;
}
}

View file

@ -316,7 +316,7 @@ namespace NLGUI
if (tabB)
{
// don't use addTab to avoid selection of new tab
addTab(tabB, (sint) ls.toNumber(2));
addTab(tabB, (sint) ls.toInteger(2));
}
return 0;
}
@ -395,7 +395,7 @@ namespace NLGUI
const char *funcName = "removeTab";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
removeTab((uint) ls.toNumber(1));
removeTab((uint) ls.toInteger(1));
return 0;
}
@ -441,7 +441,7 @@ namespace NLGUI
const char *funcName = "getTabButton";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CCtrlTabButton* tab = getTabButton((uint) ls.toNumber(1));
CCtrlTabButton* tab = getTabButton((uint) ls.toInteger(1));
if(tab != NULL)
{
CLuaIHM::pushUIOnStack(ls, tab);
@ -562,7 +562,7 @@ namespace NLGUI
const char *funcName = "showTabButton";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
sint showTab = (sint)ls.toNumber(1);
sint showTab = (sint)ls.toInteger(1);
if(showTab>=0 && showTab<(sint)_Buttons.size())
{
@ -770,7 +770,7 @@ namespace NLGUI
const char *funcName = "getGroup";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CInterfaceGroup* group = getGroup((uint) ls.toNumber(1));
CInterfaceGroup* group = getGroup((uint) ls.toInteger(1));
if(group != NULL)
{
CLuaIHM::pushUIOnStack(ls, group);

View file

@ -1815,7 +1815,7 @@ namespace NLGUI
const char *funcName = "CGroupTree::SNode::luaAddChildAtIndex";
CLuaIHM::checkArgCount(ls, funcName, 2);
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER);
addChildAtIndex(luaGetNodeOnStack(ls, funcName), (sint) ls.toNumber(2));
addChildAtIndex(luaGetNodeOnStack(ls, funcName), (sint) ls.toInteger(2));
return 0;
}
@ -1836,7 +1836,7 @@ namespace NLGUI
{
const char *funcName = "CGroupTree::SNode::luaGetNumChildren";
CLuaIHM::checkArgCount(ls, funcName, 0);
ls.push((double) Children.size());
ls.push((uint)Children.size());
return 1;
}
@ -1847,7 +1847,7 @@ namespace NLGUI
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
//
sint index = (sint) ls.toNumber(1);
sint index = (sint) ls.toInteger(1);
if (index < 0 || index >= (sint) Children.size())
{
std::string range = Children.empty() ? "<empty>" : toString("[0, %d]", Children.size() - 1);
@ -1890,7 +1890,7 @@ namespace NLGUI
{
CLuaIHM::checkArgType(ls, "CGroupTree::selectLine", 1, LUA_TNUMBER);
CLuaIHM::checkArgType(ls, "CGroupTree::selectLine", 2, LUA_TBOOLEAN);
selectLine((uint) ls.toNumber(1), ls.toBoolean(2));
selectLine((uint) ls.toInteger(1), ls.toBoolean(2));
return 0;
}

View file

@ -55,8 +55,7 @@ namespace NLGUI
if (ptr) _Dynamic = CInterfaceElement::convertBool (ptr);
ptr = xmlGetProp (cur, (xmlChar*)"type");
string sTmp = ptr.str();
sTmp = strlwr(sTmp);
string sTmp = toLower(ptr.str());
if (sTmp == "linear")
_Type = Track_Linear;
else if (sTmp == "bezier")

View file

@ -312,8 +312,7 @@ namespace NLGUI
ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_sizeparent" );
if (ptr)
{
string idparent = ptr.str();
idparent = NLMISC::strlwr(idparent);
string idparent = NLMISC::toLower(ptr.str());
if (idparent != "parent")
{
if (parentGroup)
@ -1174,7 +1173,7 @@ namespace NLGUI
int CInterfaceGroup::luaGetNumGroups(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getNumGroups", 0);
ls.push((double) _ChildrenGroups.size());
ls.push((uint)_ChildrenGroups.size());
return 1;
}
@ -1184,7 +1183,7 @@ namespace NLGUI
const char *funcName = "CInterfaceGroup::getGroup";
CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getGroup", 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
uint index = (uint) ls.toNumber(1);
uint index = (uint) ls.toInteger(1);
if (index >= _ChildrenGroups.size())
{
CLuaIHM::fails(ls, "getGroup : try to index group %s, but there are only %d son groups", ls.toString(1), (int) _ChildrenGroups.size());
@ -2140,7 +2139,8 @@ namespace NLGUI
std::string typeName = "???";
if (_ChildrenGroups[k])
{
const type_info &ti = typeid(*_ChildrenGroups[k]);
NLGUI::CInterfaceGroup *group = _ChildrenGroups[k];
const type_info &ti = typeid(*group);
typeName = ti.name();
}
nlinfo("Group %d, name = %s, type=%s", k, _ChildrenGroups[k] ? _ChildrenGroups[k]->getId().c_str() : "???", typeName.c_str());
@ -2156,7 +2156,8 @@ namespace NLGUI
std::string typeName = "???";
if (_ChildrenGroups[k])
{
const type_info &ti = typeid(*_EltOrder[k]);
NLGUI::CViewBase *view = _EltOrder[k];
const type_info &ti = typeid(*view);
typeName = ti.name();
}
CInterfaceElement *el = _EltOrder[k];

View file

@ -127,8 +127,7 @@ namespace NLGUI
// ***************************************************************************
const CInterfaceOptionValue &CInterfaceOptions::getValue(const string &sParamName) const
{
string sLwrParamName = strlwr (sParamName);
std::map<std::string, CInterfaceOptionValue>::const_iterator it = _ParamValue.find (sLwrParamName);
std::map<std::string, CInterfaceOptionValue>::const_iterator it = _ParamValue.find (toLower(sParamName));
if (it != _ParamValue.end())
return it->second;
else

View file

@ -1359,6 +1359,9 @@ namespace NLGUI
{
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
string stmp2 = toLower(string((const char*)ptr));
CInterfaceElement *pEltFound = NULL;
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
@ -1367,8 +1370,8 @@ namespace NLGUI
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
string stmp = strlwr(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
string stmp2 = strlwr(string((const char*)ptr));
string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
if (stmp == stmp2)
{
pEltFound = pIG;
@ -1408,6 +1411,9 @@ namespace NLGUI
{
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
string stmp2 = toLower(string((const char*)ptr));
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
CInterfaceElement *pEltFound = NULL;
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
@ -1416,8 +1422,7 @@ namespace NLGUI
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
string stmp = strlwr(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
string stmp2 = strlwr(string((const char*)ptr));
string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
if (stmp == stmp2)
{
pEltFound = pIG;
@ -1600,6 +1605,9 @@ namespace NLGUI
{
CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" ));
if (!ptr) return false;
string stmp2 = toLower(string((const char*)ptr));
std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup();
CInterfaceElement *pEltFound = NULL;
for (uint32 i = 0; i < _MasterGroups.size(); ++i)
@ -1608,8 +1616,8 @@ namespace NLGUI
for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j)
{
CInterfaceGroup *pIG = rMG.Group->getGroups()[j];
string stmp = strlwr(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
string stmp2 = strlwr(string((const char*)ptr));
string stmp = toLower(pIG->getId().substr(pIG->getId().rfind(':')+1,pIG->getId().size()));
if (stmp == stmp2)
{
pEltFound = pIG;

View file

@ -623,6 +623,23 @@ namespace NLGUI
return result;
}
// ***************************************************************************
sint64 CLuaState::getTableIntegerValue(const char *name, sint64 defaultValue)
{
//H_AUTO(Lua_CLuaState_getTableIntegerValue)
nlassert(name);
push(name);
getTable(-2);
if (isNil())
{
pop();
return defaultValue;
}
sint64 result = toInteger(-1);
pop();
return result;
}
// ***************************************************************************
const char *CLuaState::getTableStringValue(const char *name, const char *defaultValue)
{

View file

@ -231,20 +231,24 @@ namespace NLGUI
}
#if LUA_VERSION_NUM < 503
#define lua_isinteger(a, b) lua_isnumber(a, b)
#endif
// ***************************************************************************
#define LUA_REGISTER_BASIC(_type_) \
luabind::detail::yes_t is_user_defined(luabind::detail::by_value<_type_>); \
_type_ convert_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \
luabind::detail::yes_t is_user_defined(luabind::detail::by_value<_type_>); \
_type_ convert_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \
{ \
return (_type_)lua_tonumber(L, index); \
return (_type_)lua_tointeger(L, index); \
} \
int match_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \
int match_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \
{ \
if (lua_isnumber(L, index)) return 0; else return -1; \
if (lua_isinteger(L, index)) return 0; else return -1; \
} \
void convert_cpp_to_lua(lua_State* L, const _type_& v) \
void convert_cpp_to_lua(lua_State* L, const _type_& v) \
{ \
lua_pushnumber(L, (double)v); \
lua_pushinteger(L, (double)v); \
}
// Basic LUA types
@ -258,8 +262,6 @@ namespace NLGUI
LUA_REGISTER_BASIC(uint16)
LUA_REGISTER_BASIC(sint32)
LUA_REGISTER_BASIC(uint32)
// LUA_REGISTER_BASIC(sint)
// LUA_REGISTER_BASIC(uint)
}
}
@ -942,8 +944,8 @@ namespace NLGUI
CLuaIHM::checkArgCount(ls, "getWindowSize", 0);
uint32 w, h;
CViewRenderer::getInstance()->getScreenSize(w, h);
ls.push((double) w);
ls.push((double) h);
ls.push(w);
ls.push(h);
return 2;
}
@ -974,8 +976,8 @@ namespace NLGUI
CIFile fs(CPath::lookup(textureName).c_str());
bitmap.load(fs);
ls.push((double) bitmap.getWidth());
ls.push((double) bitmap.getHeight());
ls.push(bitmap.getWidth());
ls.push(bitmap.getHeight());
return 2;
}
@ -1098,7 +1100,7 @@ namespace NLGUI
ls.push(value.getBool());
break;
case CInterfaceExprValue::Integer:
ls.push((double)value.getInteger());
ls.push(value.getInteger());
break;
case CInterfaceExprValue::Double:
ls.push(value.getDouble());
@ -1361,7 +1363,7 @@ namespace NLGUI
ls.newTable();
for(uint k = 0; k < files.size(); ++k)
{
ls.push((double) k);
ls.push(k);
ls.push(files[k]);
ls.setTable(-3);
}
@ -1381,10 +1383,10 @@ namespace NLGUI
ls.push( (reflectedObject.*(property.GetMethod.GetBool))() );
break;
case CReflectedProperty::SInt32:
ls.push( (lua_Number)(reflectedObject.*(property.GetMethod.GetSInt32))() );
ls.push( (reflectedObject.*(property.GetMethod.GetSInt32))() );
break;
case CReflectedProperty::Float:
ls.push( (lua_Number)(reflectedObject.*(property.GetMethod.GetFloat))() );
ls.push( (reflectedObject.*(property.GetMethod.GetFloat))() );
break;
case CReflectedProperty::String:
ls.push( (reflectedObject.*(property.GetMethod.GetString))() );
@ -1447,13 +1449,13 @@ namespace NLGUI
}
case CReflectedProperty::SInt32:
{
sint32 val= (sint32)ls.toNumber(stackIndex);
sint32 val= (sint32)ls.toInteger(stackIndex);
(target.*(property.SetMethod.SetSInt32))(val);
return;
}
case CReflectedProperty::UInt32:
{
uint32 val= (uint32)ls.toNumber(stackIndex);
uint32 val= (uint32)ls.toInteger(stackIndex);
(target.*(property.SetMethod.SetUInt32))(val);
return;
}
@ -1474,7 +1476,7 @@ namespace NLGUI
{
ucstring val;
// Additionaly return of CInterfaceExpr may be std::string... test std string too
if(ls.isString() || ls.isNumber())
if(ls.isString() || ls.isNumber() || ls.isInteger())
{
std::string str;
ls.toString(stackIndex, str);

View file

@ -33,8 +33,20 @@ namespace NLGUI
CLuaManager::~CLuaManager()
{
delete luaState;
luaState = NULL;
if (luaState)
{
delete luaState;
luaState = NULL;
}
}
void CLuaManager::releaseInstance()
{
if (instance)
{
delete instance;
instance = NULL;
}
}
bool CLuaManager::executeLuaScript( const std::string &luaScript, bool smallScript )
@ -60,7 +72,8 @@ namespace NLGUI
void CLuaManager::ResetLuaState()
{
delete luaState;
if (luaState) delete luaState;
luaState = new CLuaState( debugLua );
}

View file

@ -150,7 +150,8 @@ namespace NLGUI
// *************************************************
bool CLuaObject::isNil() const { push(); bool result = _LuaState->isNil(); _LuaState->pop(); return result; }
bool CLuaObject::isNumber() const { push(); bool result = _LuaState->isNumber(); _LuaState->pop(); return result; }
bool CLuaObject::isBoolean() const { push(); bool result = _LuaState->isBoolean(); _LuaState->pop(); return result; }
bool CLuaObject::isInteger() const { push(); bool result = _LuaState->isInteger(); _LuaState->pop(); return result; }
bool CLuaObject::isBoolean() const { push(); bool result = _LuaState->isBoolean(); _LuaState->pop(); return result; }
bool CLuaObject::isString() const { push(); bool result = _LuaState->isString(); _LuaState->pop(); return result; }
bool CLuaObject::isFunction() const { push(); bool result = _LuaState->isFunction(); _LuaState->pop(); return result; }
bool CLuaObject::isCFunction() const { push(); bool result = _LuaState->isCFunction(); _LuaState->pop(); return result; }
@ -168,6 +169,7 @@ namespace NLGUI
// *************************************************
bool CLuaObject::toBoolean() const { push(); bool result = _LuaState->toBoolean(); _LuaState->pop(); return result; }
lua_Number CLuaObject::toNumber() const { push(); lua_Number result = _LuaState->toNumber(); _LuaState->pop(); return result; }
lua_Integer CLuaObject::toInteger() const { push(); lua_Integer result = _LuaState->toInteger(); _LuaState->pop(); return result; }
std::string CLuaObject::toString() const
{
push();
@ -194,6 +196,8 @@ namespace NLGUI
CLuaObject::operator bool() const { return toBoolean(); }
CLuaObject::operator float() const { return (float) toNumber(); }
CLuaObject::operator double() const { return (double) toNumber(); }
CLuaObject::operator sint32() const { return (sint32) toInteger(); }
CLuaObject::operator sint64() const { return (sint64) toInteger(); }
CLuaObject::operator std::string() const { return toString(); }
@ -385,6 +389,48 @@ namespace NLGUI
_LuaState->pop();
}
// *************************************************
void CLuaObject::setValue(const char *key, uint32 value) throw(ELuaNotATable)
{
nlassert(key);
nlassert(isValid());
if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%u' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename()));
CLuaStackChecker lsc(_LuaState);
push();
_LuaState->push(key);
_LuaState->push(value);
_LuaState->setTable(-3);
_LuaState->pop();
}
// *************************************************
void CLuaObject::setValue(const char *key, sint32 value) throw(ELuaNotATable)
{
nlassert(key);
nlassert(isValid());
if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%d' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename()));
CLuaStackChecker lsc(_LuaState);
push();
_LuaState->push(key);
_LuaState->push(value);
_LuaState->setTable(-3);
_LuaState->pop();
}
// *************************************************
void CLuaObject::setValue(const char *key, sint64 value) throw(ELuaNotATable)
{
nlassert(key);
nlassert(isValid());
if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%d"NL_I64"' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename()));
CLuaStackChecker lsc(_LuaState);
push();
_LuaState->push(key);
_LuaState->push(value);
_LuaState->setTable(-3);
_LuaState->pop();
}
// *************************************************
void CLuaObject::eraseValue(const char *key) throw(ELuaNotATable)
{

View file

@ -52,6 +52,9 @@ namespace NLGUI
_TxIdPanR2 = -2;
_TxIdCanPanR2 = -2;
_OffsetX = 0;
_OffsetY = 0;
// The pointer must be draw over ALL layers
_RenderLayer= VR_LAYER_MAX;
_Color = CRGBA(255,255,255,255);
@ -59,6 +62,7 @@ namespace NLGUI
_StringMode = false;
_ForceStringMode = false;
_StringCursor = NULL;
_StringCursorHardware = NULL;
}
void CViewPointer::forceLink()
@ -80,56 +84,43 @@ namespace NLGUI
_OffsetY = getY();
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_default");
if (prop) _TxDefault = (const char *) prop;
_TxDefault = NLMISC::strlwr (_TxDefault);
if (prop) _TxDefault = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_move_window");
if (prop) _TxMoveWindow = (const char *) prop;
_TxMoveWindow = NLMISC::strlwr (_TxMoveWindow);
if (prop) _TxMoveWindow = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BR_TL");
if (prop) _TxResizeBRTL = (const char *) prop;
_TxResizeBRTL = NLMISC::strlwr (_TxResizeBRTL);
if (prop) _TxResizeBRTL = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BL_TR");
if (prop) _TxResizeBLTR = (const char *) prop;
_TxResizeBLTR = NLMISC::strlwr (_TxResizeBLTR);
if (prop) _TxResizeBLTR = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_TB");
if (prop) _TxResizeTB = (const char *) prop;
_TxResizeTB = NLMISC::strlwr (_TxResizeTB);
if (prop) _TxResizeTB = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_LR");
if (prop) _TxResizeLR = (const char *) prop;
_TxResizeLR = NLMISC::strlwr (_TxResizeLR);
if (prop) _TxResizeLR = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_rotate");
if (prop) _TxRotate = (const char *) prop;
_TxRotate = NLMISC::strlwr (_TxRotate);
if (prop) _TxRotate = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_scale");
if (prop) _TxScale = (const char *) prop;
_TxScale = NLMISC::strlwr (_TxScale);
if (prop) _TxScale = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_colpick");
if (prop) _TxColPick = (const char *) prop;
_TxColPick = NLMISC::strlwr (_TxColPick);
if (prop) _TxColPick = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan");
if (prop) _TxPan = (const char *) prop;
_TxPan = NLMISC::strlwr (_TxPan);
if (prop) _TxPan = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan");
if (prop) _TxCanPan = (const char *) prop;
_TxCanPan = NLMISC::strlwr (_TxCanPan);
if (prop) _TxCanPan = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan_r2");
if (prop) _TxPanR2 = (const char *) prop;
_TxPanR2 = NLMISC::strlwr (_TxPanR2);
if (prop) _TxPanR2 = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan_r2");
if (prop) _TxCanPanR2 = (const char *) prop;
_TxCanPanR2 = NLMISC::strlwr (_TxCanPanR2);
if (prop) _TxCanPanR2 = NLMISC::toLower ((const char *) prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"color");
if (prop) _Color = convertColor(prop);

View file

@ -854,12 +854,11 @@ namespace NLGUI
return;
}
// Look if already existing
string sLwrGTName = strlwr(sGlobalTextureName);
string sLwrGTName = toLower(sGlobalTextureName);
TGlobalTextureList::iterator ite = _GlobalTextures.begin();
while (ite != _GlobalTextures.end())
{
std::string sText = strlwr(ite->Name);
if (sText == sLwrGTName)
if (toLower(ite->Name) == sLwrGTName)
break;
ite++;
}
@ -984,11 +983,11 @@ namespace NLGUI
*/
NL3D::UTexture *CViewRenderer::getGlobalTexture(const std::string &name)
{
string sLwrGTName = strlwr(name);
string sLwrGTName = NLMISC::toLower(name);
TGlobalTextureList::iterator ite = _GlobalTextures.begin();
while (ite != _GlobalTextures.end())
{
std::string sText = strlwr(ite->Name);
std::string sText = NLMISC::toLower(ite->Name);
if (sText == sLwrGTName)
break;
ite++;

View file

@ -42,6 +42,8 @@ namespace NLGUI
// ***************************************************************************
void CViewText::setupDefault ()
{
_ParentElm = NULL;
_CaseMode = CaseNormal;
_Underlined = false;
_StrikeThrough = false;
@ -2650,6 +2652,10 @@ namespace NLGUI
void CViewText::onInvalidateContent()
{
_InvalidTextContext= true;
if (_ParentElm)
_ParentElm->invalidateCoords();
invalidateCoords();
}

View file

@ -1026,7 +1026,7 @@ namespace NLGUI
void CWidgetManager::reset()
{
setCurContextHelp( NULL );
_ViewsUnderPointer.clear();
_CtrlsUnderPointer.clear();
_GroupsUnderPointer.clear();
@ -1254,7 +1254,7 @@ namespace NLGUI
sint32 wParent, sint32 hParent )
{
CCtrlBase::TToolTipParentType parentType= newCtrl->getToolTipParent();
CInterfaceGroup *groupContextHelp =
CInterfaceGroup *groupContextHelp =
getWindowForActiveMasterGroup(newCtrl->getContextHelpWindowName());
uint32 _ScreenH, _ScreenW;
@ -1383,7 +1383,7 @@ namespace NLGUI
{
if (!newCtrl) return;
if (!newCtrl->getInvalidCoords()) return;
CInterfaceGroup *groupContextHelp =
getWindowForActiveMasterGroup(newCtrl->getContextHelpWindowName());
@ -1450,7 +1450,7 @@ namespace NLGUI
// **** resolve auto posref
uint clampCount =
uint clampCount =
adjustTooltipPosition( newCtrl, win, newCtrl->getToolTipParentPosRef(),
newCtrl->getToolTipPosRef(), xParent, yParent,
wParent, hParent);
@ -1458,7 +1458,7 @@ namespace NLGUI
if (clampCount != 0)
{
// try to fallback on alternate tooltip posref
uint altClampCount =
uint altClampCount =
adjustTooltipPosition( newCtrl, win, newCtrl->getToolTipParentPosRefAlt(),
newCtrl->getToolTipPosRefAlt(), xParent, yParent,
wParent, hParent);
@ -1961,6 +1961,7 @@ namespace NLGUI
}
while (cb);
}
// Check if screen size changed
uint32 w, h;
CViewRenderer::getInstance()->checkNewScreenSize ();
@ -1974,7 +1975,7 @@ namespace NLGUI
setScreenWH( w, h );
}
}
// Update global color from database
if (!_RProp)
{
@ -1983,6 +1984,7 @@ namespace NLGUI
_BProp = CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B");
_AProp = CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A");
}
setGlobalColor(NLMISC::CRGBA(
(uint8)_RProp->getValue32(),
(uint8)_GProp->getValue32(),
@ -1996,7 +1998,7 @@ namespace NLGUI
c.B = gc.B;
c.A = (uint8) (( (uint16) c.A * (uint16) getContentAlpha() ) >> 8);
setGlobalColorForContent( c );
// Update global alphaS from database
updateGlobalAlphas();
@ -2005,7 +2007,7 @@ namespace NLGUI
Computed String are rendered in on big drawQuads at last part of each layer
*/
CDBManager::getInstance()->flushObserverCalls();
for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{
CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup];
@ -2158,7 +2160,7 @@ namespace NLGUI
bool CWidgetManager::handleKeyboardEvent( const CEventDescriptor &evnt )
{
bool handled = false;
CEventDescriptorKey &eventDesc = (CEventDescriptorKey&)evnt;
//_LastEventKeyDesc = eventDesc;
@ -2541,7 +2543,7 @@ namespace NLGUI
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup)
{
{
if (!handled)
if (pNewCurrentWnd != NULL)
pNewCurrentWnd->handleEvent(evnt);
@ -2589,7 +2591,7 @@ namespace NLGUI
}
_CapturedView = NULL;
if( CInterfaceElement::getEditorMode() )
stopDragging();
}
@ -2634,7 +2636,7 @@ namespace NLGUI
if( eventDesc.getType() != CEventDescriptor::mouse )
return false;
const CEventDescriptorMouse &e = static_cast< const CEventDescriptorMouse& >( eventDesc );
const CEventDescriptorMouse &e = static_cast< const CEventDescriptorMouse& >( eventDesc );
if( e.getEventTypeExtended() != CEventDescriptorMouse::mousemove )
return false;
@ -2699,7 +2701,7 @@ namespace NLGUI
e->setParent( NULL );
draggedElement = e;
return true;
}
@ -2715,7 +2717,7 @@ namespace NLGUI
g = tw;
std::string oldid = e->getId();
e->setParent( g );
e->setIdRecurse( e->getShortId() );
e->setParentPos( g );
@ -2730,7 +2732,7 @@ namespace NLGUI
onWidgetMoved( oldid, e->getId() );
}
}
// ------------------------------------------------------------------------------------------------
void CWidgetManager::movePointer (sint32 dx, sint32 dy)
{
@ -2866,17 +2868,19 @@ namespace NLGUI
void CWidgetManager::unregisterClockMsgTarget(CCtrlBase *vb)
{
if (!vb) return;
std::vector<CCtrlBase*>::iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb);
std::list<CCtrlBase*>::iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb);
if (it != _ClockMsgTargets.end())
{
_ClockMsgTargets.erase(it);
// instead of deleting, just mark as deleted incase we are inside iterating loop,
// it will be removed in sendClockTickEvent
(*it) = NULL;
}
}
// ***************************************************************************
bool CWidgetManager::isClockMsgTarget(CCtrlBase *vb) const
{
std::vector<CCtrlBase*>::const_iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb);
std::list<CCtrlBase*>::const_iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb);
return it != _ClockMsgTargets.end();
}
@ -2895,10 +2899,16 @@ namespace NLGUI
}
// and send clock tick msg to ctrl that are registered
std::vector<CCtrlBase*> clockMsgTarget = _ClockMsgTargets;
for(std::vector<CCtrlBase*>::iterator it = clockMsgTarget.begin(); it != clockMsgTarget.end(); ++it)
for(std::list<CCtrlBase*>::iterator it = _ClockMsgTargets.begin(); it != _ClockMsgTargets.end();)
{
(*it)->handleEvent(clockTick);
CCtrlBase* ctrl = *it;
if (ctrl)
{
ctrl->handleEvent(clockTick);
++it;
}
else
it = _ClockMsgTargets.erase(it);
}
}
@ -3083,7 +3093,7 @@ namespace NLGUI
{
const SMasterGroup &mg = _MasterGroups[ i ];
std::vector< CInterfaceGroup* >::size_type j;
std::vector< CInterfaceGroup* >::size_type j;
for( j = 0; j < mg.Group->getNumGroup(); j++ )
{
CInterfaceGroup *g = mg.Group->getGroup( j );
@ -3098,8 +3108,8 @@ namespace NLGUI
return true;
}
// ***************************************************************************
void CWidgetManager::enableMouseHandling( bool handle )
{
@ -3108,7 +3118,7 @@ namespace NLGUI
{
if(!getPointer())
return;
// If Left captured, reset
if( getCapturePointerLeft() )
setCapturePointerLeft( NULL );
@ -3116,12 +3126,12 @@ namespace NLGUI
// Same for Right
if( getCapturePointerRight() )
setCapturePointerRight( NULL );
// Avoid any problem with modals
disableModalWindow();
}
}
// ***************************************************************************
uint CWidgetManager::getUserDblClickDelay()
{
@ -3129,11 +3139,11 @@ namespace NLGUI
NLMISC::CCDBNodeLeaf *pNL = CDBManager::getInstance()->getDbProp("UI:SAVE:DOUBLE_CLICK_SPEED");
if( pNL != NULL )
nVal = pNL->getValue32();
uint dbclickDelay = (uint)(DOUBLE_CLICK_MIN + (DOUBLE_CLICK_MAX-DOUBLE_CLICK_MIN) * (float)nVal / 100.0f);
return dbclickDelay;
}
// ------------------------------------------------------------------------------------------------
void CWidgetManager::setupOptions()
{
@ -3157,9 +3167,9 @@ namespace NLGUI
_SystemOptions[OptionTimeoutContext]= opt->getValue("context_timeout");
_SystemOptions[OptionTimeoutContextHtml]= opt->getValue("context_html_timeout");
}
}
// Get the alpha roll over speed
float CWidgetManager::getAlphaRolloverSpeed()
{
@ -3173,7 +3183,7 @@ namespace NLGUI
{
_AlphaRolloverSpeedDB = NULL;
}
void CWidgetManager::setContainerAlpha(uint8 alpha)
{
_ContainerAlpha = alpha;
@ -3368,11 +3378,11 @@ namespace NLGUI
void CWidgetManager::selectWidget( const std::string &name )
{
std::vector< std::string >::iterator itr
std::vector< std::string >::iterator itr
= std::find( editorSelection.begin(), editorSelection.end(), name );
CInterfaceElement *e = getElementFromId( name );
if( itr != editorSelection.end() )
{
// If multiselection is on unselect if already selected
@ -3397,7 +3407,7 @@ namespace NLGUI
e->setEditorSelected( true );
editorSelection.push_back( name );
}
}
notifySelectionWatchers();
@ -3414,7 +3424,7 @@ namespace NLGUI
std::vector< IEditorSelectionWatcher* >::iterator itr = selectionWatchers.begin();
while( itr != selectionWatchers.end() )
{
(*itr)->selectionChanged();
(*itr)->selectionChanged();
++itr;
}
}
@ -3423,7 +3433,7 @@ namespace NLGUI
{
std::vector< IEditorSelectionWatcher* >::iterator itr =
std::find( selectionWatchers.begin(), selectionWatchers.end(), watcher );
// We already have this watcher
if( itr != selectionWatchers.end() )
return;
@ -3435,7 +3445,7 @@ namespace NLGUI
{
std::vector< IEditorSelectionWatcher* >::iterator itr =
std::find( selectionWatchers.begin(), selectionWatchers.end(), watcher );
// We don't have this watcher
if( itr == selectionWatchers.end() )
return;
@ -3465,7 +3475,7 @@ namespace NLGUI
void CWidgetManager::registerWidgetWatcher( IWidgetWatcher *watcher )
{
std::vector< IWidgetWatcher* >::const_iterator itr
std::vector< IWidgetWatcher* >::const_iterator itr
= std::find( widgetWatchers.begin(), widgetWatchers.end(), watcher );
// already exists
if( itr != widgetWatchers.end() )
@ -3516,7 +3526,7 @@ namespace NLGUI
g->addView( v );
onWidgetAdded( v->getId() );
return v;
}
@ -3560,7 +3570,7 @@ namespace NLGUI
e->setParent( g );
e->setParentPos( g );
e->setParentSize( g );
e->setIdRecurse( e->getShortId() );
e->setIdRecurse( e->getShortId() );
onWidgetMoved( oldId, e->getId() );
}
@ -3572,9 +3582,9 @@ namespace NLGUI
g->alignElements();
// Align the new group to the top window
g->alignTo( getTopWindow() );
g->setActive( true );
return true;
}
@ -3626,7 +3636,7 @@ namespace NLGUI
SMasterGroup mg;
mg.Group = root;
root->setIdRecurse( project );
root->setW( 1024 );
root->setH( 768 );
@ -3658,7 +3668,7 @@ namespace NLGUI
VariableData v;
v.type = "sint32";
v.value = "255";
v.entry = "UI:SAVE:COLOR:R";
parser->setVariable( v );
@ -3670,7 +3680,7 @@ namespace NLGUI
v.entry = "UI:SAVE:COLOR:A";
parser->setVariable( v );
return true;
}

View file

@ -49,7 +49,7 @@ void xmlCheckNodeName (xmlNodePtr &node, const char *nodeName)
// Make an error message
char tmp[512];
smprintf (tmp, 512, "LogicStateMachine STATE_MACHINE XML Syntax error in block line %d, node %s should be %s",
(int)node->line, node->name, nodeName);
node ? (int)node->line:-1, node->name, nodeName);
nlinfo (tmp);
nlstop;

View file

@ -187,6 +187,12 @@ IF(JPEG_FOUND)
TARGET_LINK_LIBRARIES(nelmisc ${JPEG_LIBRARY})
ENDIF(JPEG_FOUND)
IF(GIF_FOUND)
INCLUDE_DIRECTORIES(${GIF_INCLUDE_DIR})
ADD_DEFINITIONS(-DUSE_GIF)
TARGET_LINK_LIBRARIES(nelmisc ${GIF_LIBRARY})
ENDIF(GIF_FOUND)
IF(WITH_STATIC OR WIN32)
TARGET_LINK_LIBRARIES(nelmisc ${PNG_LIBRARIES})
ELSE(WITH_STATIC OR WIN32)

View file

@ -134,6 +134,19 @@ uint8 CBitmap::load(NLMISC::IStream &f, uint mipMapSkip)
}
#endif // USE_JPEG
#ifdef USE_GIF
if (fileType == GIF_HEADER)
{
#ifdef NEL_ALL_BITMAP_WHITE
uint8 result = readGIF(f);
MakeWhite (*this);
return result;
#else // NEL_ALL_BITMAP_WHITE
return readGIF(f);
#endif // NEL_ALL_BITMAP_WHITE
}
#endif // USE_GIF
// assuming it's TGA
NLMISC::IStream::TSeekOrigin origin= f.begin;
if(!f.seek (0, origin))
@ -3149,6 +3162,25 @@ void CBitmap::loadSize(NLMISC::IStream &f, uint32 &retWidth, uint32 &retHeight)
}
while(!eof);
}
else if(fileType == GIF_HEADER)
{
// check second part of header ("7a" or "9a" in 'GIF89a')
uint16 s;
f.serial(s);
if (s != 0x6137 && s != 0x6139)
{
nlwarning("Invalid GIF header, expected GIF87a or GIF89a");
return;
}
uint16 lsWidth;
uint16 lsHeight;
f.serial(lsWidth);
f.serial(lsHeight);
retWidth = lsWidth;
retHeight = lsHeight;
}
// assuming it's TGA
else
{

View file

@ -0,0 +1,315 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdmisc.h"
#include "nel/misc/bitmap.h"
#ifdef USE_GIF
#include <gif_lib.h>
#endif
using namespace std;
namespace NLMISC
{
#ifdef USE_GIF
// GIFLIB_MAJOR is defined from version 5
#ifndef GIFLIB_MAJOR
#define GIFLIB_MAJOR 4
#endif
static uint8 GIF_TRANSPARENT_MASK = 0x01;
static uint8 GIF_DISPOSE_MASK = 0x07;
static sint8 GIF_NOT_TRANSPARENT = -1;
static uint8 GIF_DISPOSE_NONE = 0;
static uint8 GIF_DISPOSE_LEAVE = 1;
static uint8 GIF_DISPOSE_BACKGROUND = 2;
static uint8 GIF_DISPOSE_RESTORE = 3;
static NLMISC::IStream *GIFStream = NULL;
#if GIFLIB_MAJOR < 5
static uint8 INTERLACED_OFFSET[] = { 0, 4, 2, 1 };
static uint8 INTERLACED_JUMP[] = { 8, 8, 4, 2 };
#endif
static int readGIFData(GifFileType *gif, GifByteType *data, int length){
NLMISC::IStream *f = static_cast<NLMISC::IStream *>(gif->UserData);
if(!f->isReading()) return 0;
try
{
f->serialBuffer((uint8*) data, length);
}
catch(...)
{
nlwarning("error while reading JPEG image");
return 0;
}
return length;
}
/*-------------------------------------------------------------------*\
readGIF
\*-------------------------------------------------------------------*/
uint8 CBitmap::readGIF( NLMISC::IStream &f )
{
if(!f.isReading()) return false;
{
// check gif canvas dimension
uint16 ver;
uint16 width;
uint16 height;
f.serial(ver);
f.serial(width);
f.serial(height);
// limit image size as we are using 32bit pixels
// 4000x4000x4 ~ 61MiB
if (width*height > 4000*4000)
{
nlwarning("GIF image size is too big (width=%d, height=%d)", width, height);
return 0;
}
// rewind for gif decoder
f.seek(-10, IStream::current);
}
#if GIFLIB_MAJOR >= 5
sint32 errorCode;
GifFileType *gif = DGifOpen(&f, readGIFData, &errorCode);
if (gif == NULL)
{
nlwarning("failed to open gif, error=%d", errorCode);
return 0;
}
#else
GifFileType *gif = DGifOpen(&f, readGIFData);
if (gif == NULL)
{
nlwarning("failed to open gif, error=%d", GifLastError());
return 0;
}
#endif
// this will read and decode all frames
sint32 ret = DGifSlurp(gif);
if (ret != GIF_OK)
{
nlwarning("failed to read gif, error=%d", ret);
#if GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
DGifCloseFile(gif, &errorCode);
#else
DGifCloseFile(gif);
#endif
return 0;
}
// resize target buffer
uint32 dstChannels = 4; // RGBA
resize (gif->SWidth, gif->SHeight, RGBA);
// make transparent
_Data[0].fill(0);
// make sure background color index exists in global colormap
if (gif->SColorMap && gif->SColorMap->ColorCount < gif->SBackGroundColor)
{
gif->SBackGroundColor = 0;
}
// merge all frames one by one into single target
ColorMapObject *ColorMap;
sint32 transparency = GIF_NOT_TRANSPARENT;
uint8 r, g, b, a;
uint32 offset_x, offset_y, width, height;
// disable loop as we only interested in first frame
// for (uint32 frame = 0; frame < gif->ImageCount; frame++)
{
uint32 frame = 0;
SavedImage *curFrame = &gif->SavedImages[frame];
if (curFrame->ExtensionBlockCount > 0)
{
for(uint e=0; e<curFrame->ExtensionBlockCount; e++){
ExtensionBlock *ext = &curFrame->ExtensionBlocks[e];
if (ext->Function == GRAPHICS_EXT_FUNC_CODE) {
uint8 flag = ext->Bytes[0];
//delay = (ext.Bytes[1] << 8) | ext.Bytes[2];
transparency = (flag & GIF_TRANSPARENT_MASK) ? ext->Bytes[3] : GIF_NOT_TRANSPARENT;
//dispose = ((flag >> 2) & GIF_DISPOSE_MASK);
}
}
}
// select color map for frame
if (curFrame->ImageDesc.ColorMap)
{
ColorMap = curFrame->ImageDesc.ColorMap;
}
else
if (gif->SColorMap)
{
ColorMap = gif->SColorMap;
}
else
{
nlwarning("GIF has no global or local color map");
ColorMap = NULL;
}
// copy frame to canvas
offset_x = curFrame->ImageDesc.Left;
offset_y = curFrame->ImageDesc.Top;
width = curFrame->ImageDesc.Width;
height = curFrame->ImageDesc.Height;
#if GIFLIB_MAJOR < 5
// giflib 4 does not handle interlaced images, so we must do it
if (curFrame->ImageDesc.Interlace)
{
uint32 srcOffset = 0;
for (uint8 pass = 0; pass < 4; pass++)
{
uint32 nextLine = INTERLACED_OFFSET[pass];
// y is destination row
for (uint32 y = 0; y < height; y++)
{
if (y != nextLine)
continue;
uint32 dstOffset = (y + offset_y)*gif->SWidth*dstChannels + offset_x*dstChannels;
nextLine += INTERLACED_JUMP[pass];
for (uint32 x = 0; x < width; x++)
{
srcOffset++;
dstOffset+= dstChannels;
uint32 index = curFrame->RasterBits[srcOffset];
if (index != transparency)
{
// make sure color index is not outside colormap
if (ColorMap)
{
if (index > ColorMap->ColorCount)
{
index = 0;
}
r = ColorMap->Colors[index].Red;
g = ColorMap->Colors[index].Green;
b = ColorMap->Colors[index].Blue;
}
else
{
// broken gif, no colormap
r = g = b = 0;
}
a = 255;
}
else
{
// transparent
r = g = b = a = 0;
}
_Data[0][dstOffset] = r;
_Data[0][dstOffset+1] = g;
_Data[0][dstOffset+2] = b;
_Data[0][dstOffset+3] = a;
} // x loop
} // y loop
} // pass loop
}
else
#endif
for (uint32 y = 0; y < height; y++)
{
uint32 srcOffset = y*width;
uint32 dstOffset = (y + offset_y)*gif->SWidth*dstChannels + offset_x*dstChannels;
for (uint32 x = 0; x < width; x++)
{
srcOffset++;
dstOffset+= dstChannels;
uint32 index = curFrame->RasterBits[srcOffset];
if (index != transparency)
{
// make sure color index is not outside colormap
if (ColorMap)
{
if (index > ColorMap->ColorCount)
{
index = 0;
}
r = ColorMap->Colors[index].Red;
g = ColorMap->Colors[index].Green;
b = ColorMap->Colors[index].Blue;
}
else
{
// broken gif, no colormap
r = g = b = 0;
}
a = 255;
}
else
{
// transparent
r = g = b = a = 0;
}
_Data[0][dstOffset] = r;
_Data[0][dstOffset+1] = g;
_Data[0][dstOffset+2] = b;
_Data[0][dstOffset+3] = a;
} // x loop
} // y loop
}
// clean up after the read, and free any memory allocated
#if GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
DGifCloseFile(gif, &errorCode);
#else
DGifCloseFile(gif);
#endif
//return the size of a pixel as 32bits
return 32;
}
#else
uint8 CBitmap::readGIF( NLMISC::IStream &/* f */)
{
nlwarning ("You must compile NLMISC with USE_GIF if you want gif support");
return 0;
}
#endif
}//namespace

View file

@ -440,7 +440,7 @@ NLMISC_CATEGORISED_COMMAND(nel,hrtob, "Convert a human readable number into a by
string secondsToHumanReadable (uint32 time)
{
static const char *divTable[] = { "s", "mn", "h", "d" };
static uint divCoef[] = { 60, 60, 24 };
static uint divCoef[] = { 60, 60, 24 };
uint div = 0;
uint32 res = time;
uint32 newres = res;
@ -671,13 +671,13 @@ bool launchProgram(const std::string &programName, const std::string &arguments,
{
#ifdef NL_OS_WINDOWS
STARTUPINFOA si;
PROCESS_INFORMATION pi;
STARTUPINFOA si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));
memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));
si.cb = sizeof(si);
si.cb = sizeof(si);
/* SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof (sa);
@ -781,7 +781,7 @@ bool launchProgram(const std::string &programName, const std::string &arguments,
nlwarning("LAUNCH: Failed launched '%s' with arg '%s' err %d: '%s'", programName.c_str(), arguments.c_str(), errno, err);
}
else if (status == 0)
{
{
// Exec (the only allowed instruction after vfork)
status = execvp(programName.c_str(), &argv.front());
@ -1009,50 +1009,87 @@ NLMISC_CATEGORISED_COMMAND(nel, killProgram, "kill a program given the pid", "<p
#ifdef NL_OS_WINDOWS
LONG GetRegKey(HKEY key, LPCSTR subkey, LPSTR retdata)
{
HKEY hkey;
LONG retval = RegOpenKeyExA(key, subkey, 0, KEY_QUERY_VALUE, &hkey);
HKEY hkey;
LONG retval = RegOpenKeyExA(key, subkey, 0, KEY_QUERY_VALUE, &hkey);
if (retval == ERROR_SUCCESS)
if (retval == ERROR_SUCCESS)
{
long datasize = MAX_PATH;
char data[MAX_PATH];
RegQueryValueA(hkey, NULL, data, &datasize);
lstrcpyA(retdata,data);
RegCloseKey(hkey);
}
long datasize = MAX_PATH;
char data[MAX_PATH];
RegQueryValueA(hkey, NULL, data, &datasize);
lstrcpyA(retdata,data);
RegCloseKey(hkey);
}
return retval;
return retval;
}
#endif // NL_OS_WINDOWS
static bool openDocWithExtension (const char *document, const char *ext)
{
#ifdef NL_OS_WINDOWS
// First try ShellExecute()
HINSTANCE result = ShellExecuteA(NULL, "open", document, NULL, NULL, SW_SHOWDEFAULT);
// If it failed, get the .htm regkey and lookup the program
if ((uintptr_t)result <= HINSTANCE_ERROR)
{
char key[MAX_PATH + MAX_PATH];
if (GetRegKey(HKEY_CLASSES_ROOT, ext, key) == ERROR_SUCCESS)
{
lstrcatA(key, "\\shell\\open\\command");
if (GetRegKey(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS)
{
char *pos = strstr(key, "\"%1\"");
if (pos == NULL)
{
// No quotes found
// Check for %1, without quotes
pos = strstr(key, "%1");
if (pos == NULL)
{
// No parameter at all...
pos = key+lstrlenA(key)-1;
}
else
{
// Remove the parameter
*pos = '\0';
}
}
else
{
// Remove the parameter
*pos = '\0';
}
lstrcatA(pos, " ");
lstrcatA(pos, document);
int res = WinExec(key, SW_SHOWDEFAULT);
return (res>31);
}
}
}
else
{
return true;
}
#else
// TODO: implement for Linux and Mac OS X
nlunreferenced(document);
#endif // NL_OS_WINDOWS
return false;
}
bool openURL (const char *url)
{
#ifdef NL_OS_WINDOWS
char key[1024];
if (GetRegKey(HKEY_CLASSES_ROOT, ".html", key) == ERROR_SUCCESS)
{
lstrcatA(key, "\\shell\\open\\command");
if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS)
{
char *pos;
pos = strstr(key, "\"%1\"");
if (pos == NULL) { // No quotes found
pos = strstr(key, "%1"); // Check for %1, without quotes
if (pos == NULL) // No parameter at all...
pos = key+lstrlenA(key)-1;
else
*pos = '\0'; // Remove the parameter
}
else
*pos = '\0'; // Remove the parameter
lstrcatA(pos, " ");
lstrcatA(pos, url);
int res = WinExec(key,SW_SHOWDEFAULT);
return (res>31);
}
}
return openDocWithExtension(url, "htm");
#elif defined(NL_OS_MAC)
return launchProgram("open", url);
#elif defined(NL_OS_UNIX)
@ -1060,53 +1097,17 @@ bool openURL (const char *url)
#else
nlwarning("openURL() is not implemented for this OS");
#endif // NL_OS_WINDOWS
return false;
}
bool openDoc (const char *document)
{
#ifdef NL_OS_WINDOWS
string ext = CFile::getExtension (document);
char key[MAX_PATH + MAX_PATH];
// get extension from document fullpath
string ext = CFile::getExtension(document);
// First try ShellExecute()
HINSTANCE result = ShellExecuteA(NULL, "open", document, NULL,NULL, SW_SHOWDEFAULT);
// If it failed, get the .htm regkey and lookup the program
if ((uintptr_t)result <= HINSTANCE_ERROR)
{
if (GetRegKey(HKEY_CLASSES_ROOT, ext.c_str(), key) == ERROR_SUCCESS)
{
lstrcatA(key, "\\shell\\open\\command");
if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS)
{
char *pos;
pos = strstr(key, "\"%1\"");
if (pos == NULL) { // No quotes found
pos = strstr(key, "%1"); // Check for %1, without quotes
if (pos == NULL) // No parameter at all...
pos = key+lstrlenA(key)-1;
else
*pos = '\0'; // Remove the parameter
}
else
*pos = '\0'; // Remove the parameter
lstrcatA(pos, " ");
lstrcatA(pos, document);
int res = WinExec(key,SW_SHOWDEFAULT);
return (res>31);
}
}
}
else
return true;
#else
// TODO: implement for Linux and Mac OS X
nlunreferenced(document);
#endif // NL_OS_WINDOWS
return false;
// try to open document
return openDocWithExtension(document, ext.c_str());
}
} // NLMISC

View file

@ -79,8 +79,7 @@ using namespace std;
#define LOG_IN_FILE NEL_LOG_IN_FILE
// If true, debug system will trap crash even if the application is in debugger
//static const bool TrapCrashInDebugger = false;
static const bool TrapCrashInDebugger = true;
static const bool TrapCrashInDebugger = false;
#ifdef DEBUG_NEW
#define new DEBUG_NEW

View file

@ -700,6 +700,9 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m
# endif
abort();
break;
default:
break;
}
// no more sent mail for crash

View file

@ -20,6 +20,12 @@
#include "nel/misc/path.h"
#include "nel/misc/i18n.h"
#include <locale.h>
#ifdef NL_OS_MAC
#include <CoreFoundation/CoreFoundation.h>
#endif
using namespace std;
#ifdef DEBUG_NEW
@ -52,11 +58,13 @@ void CI18N::initLanguages()
_LanguageCodes.push_back("fr");
_LanguageCodes.push_back("de");
_LanguageCodes.push_back("ru");
_LanguageCodes.push_back("es");
_LanguageNames.push_back(ucstring("English"));
_LanguageNames.push_back(ucstring("French"));
_LanguageNames.push_back(ucstring("German"));
_LanguageNames.push_back(ucstring("Russian"));
_LanguageNames.push_back(ucstring("Spanish"));
_LanguagesNamesLoaded = true;
}
@ -226,6 +234,108 @@ string CI18N::getCurrentLanguageCode ()
return _SelectedLanguageCode;
}
bool CI18N::isLanguageCodeSupported(const std::string &lang)
{
initLanguages();
for (sint i = 0, ilen = _LanguageCodes.size(); i < ilen; ++i)
{
if (lang == _LanguageCodes[i]) return true;
}
return false;
}
std::string CI18N::getSystemLanguageCode ()
{
static std::string s_cachedSystemLanguage;
if (!s_cachedSystemLanguage.empty())
return s_cachedSystemLanguage;
#ifdef NL_OS_MAC
// under OS X, locale is only defined in console, not in UI
// so we need to use CoreFoundation API to retrieve it
// get an array with all preferred languages
CFArrayRef langs = CFLocaleCopyPreferredLanguages();
if (langs)
{
// get languages count
sint languagesCount = CFArrayGetCount(langs);
// process each language
for (sint i = 0; i < languagesCount; ++i)
{
std::string lang;
// get language CFString
CFStringRef langCF = (CFStringRef)CFArrayGetValueAtIndex(langs, i);
if (langCF)
{
// get a C string from CFString
const char *langStr = CFStringGetCStringPtr(langCF, kCFStringEncodingASCII);
if (!langStr)
{
// get length of the CFString
CFIndex length = CFStringGetLength(langCF);
// allocate a temporary buffer to hold converted string
char *tmp = new char[length+1];
// use alternative function to get a C string from CFString
if (CFStringGetCString(langCF, tmp, length+1, kCFStringEncodingASCII))
{
lang = std::string(tmp, length);
}
else
{
nlerror("Unable to convert CFStringRef to string");
}
delete [] tmp;
}
else
{
lang = std::string(langStr);
}
CFRelease(langCF);
}
// only keep language code if supported by NeL
if (!lang.empty() && isLanguageCodeSupported(lang))
{
s_cachedSystemLanguage = lang;
break;
}
}
// don't need languages array anymore
CFRelease(langs);
}
#endif
// use system locale (works under Linux and Windows)
if (s_cachedSystemLanguage.empty())
{
std::string lang = NLMISC::toLower(std::string(setlocale(LC_CTYPE, "")));
// only keep 2 first characters
if (lang.size() > 1)
s_cachedSystemLanguage = lang.substr(0, 2);
}
// english is default language
if (s_cachedSystemLanguage.empty())
s_cachedSystemLanguage = "en";
return s_cachedSystemLanguage;
}
void CI18N::removeCComment(ucstring &commentedString)
{
ucstring temp;

View file

@ -677,7 +677,7 @@ void CFairMutex::debugEndEnter()
if (_Mutex == (void*)0x88)
{
OutputDebugString (str);
if (entered) __asm int 3;
if (entered) __debugbreak();
entered = true;
}
*/
@ -704,7 +704,7 @@ void CFairMutex::debugLeave()
if (_Mutex == (void*)0x88)
{
OutputDebugString (str);
if (!entered) __asm int 3;
if (!entered) __debugbreak();
entered = false;
}
*/

View file

@ -298,7 +298,8 @@ void CRGBA::modulateColors(CRGBA *dest, const CRGBA *src1, const CRGBA *src2, ui
uint64 blank = 0;
/// well, this could be further optimized when stride is 4
if (dup == 1)
{ __asm
{
__asm
{
push ebp
movq mm2, blank
@ -733,17 +734,23 @@ void CRGBA::buildFromHLS(float h, float l, float s)
CRGBA CRGBA::stringToRGBA( const char *ptr )
{
if (!ptr)
return NLMISC::CRGBA::White;
if (ptr)
{
int r = 255, g = 255, b = 255, a = 255;
// we need at least 3 integer values to consider string is valid
if (sscanf( ptr, "%d %d %d %d", &r, &g, &b, &a ) >= 3)
{
clamp( r, 0, 255 );
clamp( g, 0, 255 );
clamp( b, 0, 255 );
clamp( a, 0, 255 );
int r = 255, g = 255, b = 255, a = 255;
sscanf( ptr, "%d %d %d %d", &r, &g, &b, &a );
clamp( r, 0, 255 );
clamp( g, 0, 255 );
clamp( b, 0, 255 );
clamp( a, 0, 255 );
return CRGBA( r,g,b,a );
return CRGBA( r,g,b,a );
}
}
return NLMISC::CRGBA::White;
}
std::string CRGBA::toString() const

View file

@ -185,11 +185,12 @@ string CSystemInfo::getOS()
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
typedef LONG (WINAPI* pRtlGetVersion)(OSVERSIONINFOEXA*);
SYSTEM_INFO si;
PGNSI pGNSI;
PGPI pGPI;
OSVERSIONINFOEX osvi;
OSVERSIONINFOEXA osvi;
BOOL bOsVersionInfoEx;
const int BUFSIZE = 80;
@ -197,15 +198,26 @@ string CSystemInfo::getOS()
// If that fails, try using the OSVERSIONINFO structure.
ZeroMemory(&si, sizeof(SYSTEM_INFO));
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
ZeroMemory(&osvi, sizeof(osvi));
osvi.dwOSVersionInfoSize = sizeof(osvi);
bOsVersionInfoEx = GetVersionExA ((OSVERSIONINFO *) &osvi);
HMODULE hNtDll = GetModuleHandleA("ntdll.dll");
pRtlGetVersion RtlGetVersion = (pRtlGetVersion)GetProcAddress(hNtDll, "RtlGetVersion");
if (RtlGetVersion)
{
bOsVersionInfoEx = RtlGetVersion(&osvi) == 0;
}
if(!bOsVersionInfoEx)
{
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionExA ( (OSVERSIONINFO *) &osvi) )
bOsVersionInfoEx = GetVersionExA ((OSVERSIONINFOA *) &osvi);
}
if(!bOsVersionInfoEx)
{
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOA);
if (! GetVersionExA ( (OSVERSIONINFOA *) &osvi) )
return OSString+" Can't GetVersionEx()";
}
@ -223,13 +235,24 @@ string CSystemInfo::getOS()
{
OSString = "Microsoft";
if ( osvi.dwMajorVersion > 6 )
if ( osvi.dwMajorVersion > 10 )
{
OSString += " Windows (not released)";
}
else if ( osvi.dwMajorVersion == 10 )
{
OSString += " Windows 10";
}
else if ( osvi.dwMajorVersion == 6 )
{
if ( osvi.dwMinorVersion == 2 )
if ( osvi.dwMinorVersion == 3 )
{
if( osvi.wProductType == VER_NT_WORKSTATION )
OSString += " Windows 8.1";
else
OSString += " Windows Server 2012 R2";
}
else if ( osvi.dwMinorVersion == 2 )
{
if( osvi.wProductType == VER_NT_WORKSTATION )
OSString += " Windows 8";

View file

@ -114,7 +114,7 @@ void *CCallbackNetBase::getUserData()
*/
void CCallbackNetBase::addCallbackArray (const TCallbackItem *callbackarray, sint arraysize)
{
if (arraysize == 1 && callbackarray[0].Callback == NULL && string("") == callbackarray[0].Key)
if (arraysize == 1 && callbackarray[0].Callback == NULL && strlen(callbackarray[0].Key) == 0)
{
// it's an empty array, ignore it
return;

View file

@ -752,7 +752,7 @@ sint32 NLPACS::CGlobalRetriever::getIdentifier(const string &id) const
const string &NLPACS::CGlobalRetriever::getIdentifier(const NLPACS::UGlobalPosition &position) const
{
static const string nullString = string("");
static const string nullString;
if (position.InstanceId == -1)
return nullString;
@ -784,7 +784,7 @@ bool NLPACS::CGlobalRetriever::buildInstance(const string &id, const NLMISC::C
const CRetrieverInstance &instance = makeInstance(retrieverId, 0, CVector(position));
// check make instance success
if (&instance == NULL || instance.getInstanceId() == -1 || instance.getRetrieverId() != retrieverId)
if (instance.getInstanceId() == -1 || instance.getRetrieverId() != retrieverId)
return false;
// links new instance to its neighbors

View file

@ -124,7 +124,12 @@ bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, st
/// Get audio/container extensions that are currently supported by the nel sound library.
void IAudioDecoder::getMusicExtensions(std::vector<std::string> &extensions)
{
extensions.push_back("ogg");
// only add ogg format if not already in extensions list
if (std::find(extensions.begin(), extensions.end(), "ogg") == extensions.end())
{
extensions.push_back("ogg");
}
// extensions.push_back("wav"); // TODO: Easy.
}

View file

@ -54,6 +54,7 @@
#include "nel/sound/sound_bank.h"
#include "nel/sound/group_controller.h"
#include "nel/sound/containers.h"
#include "nel/sound/audio_decoder.h"
using namespace std;
using namespace NLMISC;
@ -2689,21 +2690,30 @@ bool CAudioMixerUser::getSongTitle(const std::string &filename, std::string &res
{
std::string artist;
std::string title;
if (_SoundDriver->getMusicInfo(filename, artist, title))
if (!_SoundDriver->getMusicInfo(filename, artist, title))
{
if (!title.empty())
{
if (!artist.empty()) result = artist + " - " + title;
else result = title;
}
else if (!artist.empty())
{
result = artist + " - " + CFile::getFilename(filename);
}
else result = CFile::getFilename(filename);
return true;
// use 3rd party libraries supported formats
IAudioDecoder::getInfo(filename, artist, title);
}
if (!title.empty())
{
if (!artist.empty()) result = artist + " - " + title;
else result = title;
}
else if (!artist.empty())
{
result = artist + " - " + CFile::getFilename(filename);
}
else
{
result = CFile::getFilename(filename);
}
return true;
}
result = "???";
return false;
}
@ -2751,7 +2761,14 @@ bool CAudioMixerUser::isEventMusicEnded()
/// Get audio/container extensions that are currently supported by nel or the used driver implementation.
void CAudioMixerUser::getMusicExtensions(std::vector<std::string> &extensions)
{
_SoundDriver->getMusicExtensions(extensions);
if (_SoundDriver)
{
// add file formats supported by driver
_SoundDriver->getMusicExtensions(extensions);
}
// add 3rd party libraries support file formats
IAudioDecoder::getMusicExtensions(extensions);
}
/// Add a reverb environment

View file

@ -1,4 +1,3 @@
LIBRARY nel_drv_openal_win_r
EXPORTS
NLSOUND_createISoundDriverInstance
NLSOUND_interfaceVersion

View file

@ -630,7 +630,11 @@ void CSoundDriverAL::commit3DChanges()
/// Write information about the driver to the output stream.
void CSoundDriverAL::writeProfile(std::string& out)
{
// TODO
out = toString("OpenAL\n");
out += toString("Source size: %u\n", (uint32)_Sources.size());
out += toString("Effects size: %u\n", (uint32)_Effects.size());
// TODO: write other useful information like OpenAL version and supported extensions
}
// Does not create a sound loader .. what does it do then?

View file

@ -1,4 +1,3 @@
LIBRARY nel_drv_xaudio2_win_r
EXPORTS
NLSOUND_createISoundDriverInstance
NLSOUND_interfaceVersion

View file

@ -179,7 +179,7 @@ CSoundDriverXAudio2::CSoundDriverXAudio2(ISoundDriver::IStringMapperProvider * /
uint32 flags = 0;
#ifdef NL_DEBUG
flags |= XAUDIO2_DEBUG_ENGINE; // comment when done using this :)
// flags |= XAUDIO2_DEBUG_ENGINE; // comment when done using this :)
#endif
// XAudio2

View file

@ -32,7 +32,7 @@ using namespace NLMISC;
namespace NLSOUND {
CSourceXAudio2::CSourceXAudio2(CSoundDriverXAudio2 *soundDriver)
: _SoundDriver(soundDriver), _SourceVoice(NULL), _StaticBuffer(NULL), _OperationSet(soundDriver->getUniqueOperationSet()),
: _SoundDriver(soundDriver), _SourceVoice(NULL), _StaticBuffer(NULL), _LastPreparedBuffer(NULL), _OperationSet(soundDriver->getUniqueOperationSet()),
_Format(IBuffer::FormatUnknown), _Frequency(0), _PlayStart(0),
_Doppler(1.0f), _Pos(0.0f, 0.0f, 0.0f), _Relative(false), _Alpha(1.0),
_DirectDryVoice(NULL), _DirectFilterVoice(NULL), _EffectDryVoice(NULL), _EffectFilterVoice(NULL),
@ -407,6 +407,7 @@ void CSourceXAudio2::submitStreamingBuffer(IBuffer *buffer)
uint32 frequency;
buffer->getFormat(bufferFormat, channels, bitsPerSample, frequency);
preparePlay(bufferFormat, channels, bitsPerSample, frequency);
_LastPreparedBuffer = NULL;
}
submitBuffer(static_cast<CBufferXAudio2 *>(buffer));
@ -455,7 +456,8 @@ void CSourceXAudio2::setLooping(bool l)
if (FAILED(_SourceVoice->FlushSourceBuffers()))
nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers");
// resubmit with updated looping settings
submitBuffer(_StaticBuffer);
if (_LastPreparedBuffer == _StaticBuffer)
submitBuffer(_StaticBuffer);
}
else
{
@ -478,7 +480,8 @@ void CSourceXAudio2::setLooping(bool l)
if (FAILED(_SourceVoice->FlushSourceBuffers()))
nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers");
// queue buffer with correct looping parameters
submitBuffer(_StaticBuffer);
if (_LastPreparedBuffer == _StaticBuffer)
submitBuffer(_StaticBuffer);
}
}
}
@ -635,6 +638,7 @@ bool CSourceXAudio2::play()
_StaticBuffer->getChannels(),
_StaticBuffer->getBitsPerSample(),
_StaticBuffer->getFrequency());
_LastPreparedBuffer = _StaticBuffer;
submitBuffer(_StaticBuffer);
_PlayStart = CTime::getLocalTime();
if (SUCCEEDED(_SourceVoice->Start(0))) _IsPlaying = true;
@ -663,6 +667,8 @@ void CSourceXAudio2::stop()
// stop source voice and remove pending buffers
_SoundDriver->getXAudio2()->CommitChanges(_OperationSet);
if (FAILED(_SourceVoice->ExitLoop()))
nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED ExitLoop");
if (FAILED(_SourceVoice->Stop(0)))
nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED Stop");
if (FAILED(_SourceVoice->FlushSourceBuffers()))

View file

@ -41,6 +41,8 @@ private:
CSoundDriverXAudio2 *_SoundDriver;
/// Buffer that should be playing.
CBufferXAudio2 *_StaticBuffer;
/// Last buffer that was prepared for playing.
CBufferXAudio2 *_LastPreparedBuffer;
// -- Pointers --
/// Source voice, can be NULL!

View file

@ -53,7 +53,7 @@ using namespace NL3D;
// ---------------------------------------------------------------------------
// Out a string to the stdout and log.log
void outString (string &sText)
void outString (const string &sText)
{
createDebug ();
InfoLog->displayRaw(sText.c_str());

View file

@ -483,7 +483,7 @@ XMLR2EDInterfaceFiles =
{
"r2ed.xml",
"r2_triggers.xml",
"r2_logic_entities.xml",
"r2_logic_entities.xml",
"r2ed_acts.xml",
"r2ed_scenario.xml",
"r2ed_connect.xml"

View file

@ -19,7 +19,7 @@ end
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
-- WIDGET TO CHOOSE A COLOR
-- WIDGET TO CHOOSE A COLOR
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
@ -29,14 +29,14 @@ function game:mcwChooseColor(title, pal)
local ui = getUICaller();
-- get the color of the button and store it in temporary db location
-- get the color of the button and store it in temporary db location
local rgba = ui.col_normal_rgba;
game.ColorPicker.r = rgba.R;
game.ColorPicker.g = rgba.G;
game.ColorPicker.b = rgba.B;
game.ColorPicker.button = ui;
game.ColorPicker.pal = pal;
-- setup the color picker window
local uiModalWin = getUI('ui:interface:define_mcw_color');
if (game.ColorPicker.pal == 0) then
@ -64,8 +64,8 @@ end
-- called when we have finished choosing the color in the modal window and the chosen color is valid
function game:mcwValidateColor()
if (game.ColorPicker.button == nil) then
return;
if (game.ColorPicker.button == nil) then
return;
end
game.ColorPicker.button.col_normal = game.ColorPicker.r .. ' ' .. game.ColorPicker.g .. ' ' .. game.ColorPicker.b;
--debugInfo(game.ColorPicker.button.col_normal)
@ -108,10 +108,10 @@ end
-- hide all the pages of the config window
function game:configHideAll()
local uiList = {
local uiList = {
'explanation', 'general', 'landscape', 'fx', 'char', 'hud', 'language', 'alpha_colors',
'chat_colors', 'entity_colors', 'in_scene_user', 'in_scene_friend', 'in_scene_enemy',
'in_scene_chat_messages', 'win_colors', 'win_colors_r2', 'mouse', 'keyb', 'vr', 'sound', 'landmark_colors', 'help'
'chat_colors', 'entity_colors', 'in_scene_user', 'in_scene_friend', 'in_scene_enemy',
'in_scene_chat_messages', 'win_colors', 'win_colors_r2', 'mouse', 'keyb', 'vr', 'sound', 'landmark_colors', 'help'
};
for k,v in pairs(uiList) do
@ -127,19 +127,19 @@ function game:configShowOne(strUIToShow)
game:configHideAll();
-- special case : if the display tab was shown, update the aspect ratio if needed
local generalGrp = getUI('ui:interface:game_config:content:general');
local uiGrp = getUI('ui:interface:game_config:content:' .. strUIToShow);
local uiGrp = getUI('ui:interface:game_config:content:' .. strUIToShow);
-- Removed the following code to solve RT n°14720
-- The 'game_config_change_screen_ratio_custom' action handler
-- should only be called if the user changed the apect ratio himself
-- The 'game_config_change_screen_ratio_custom' action handler
-- should only be called if the user changed the apect ratio himself
-- (else the edit box containing the aspect ratio may not have been initiliazed here)
--if uiGrp ~= generalGrp then
--if uiGrp ~= generalGrp then
-- runAH(nil, 'game_config_change_screen_ratio_custom', '')
--end
uiGrp.active = true;
end
------------------------------------------------------------------------------------------------------------
--
--
function game:configInit()
-- init language
@ -187,9 +187,9 @@ function game:configInit()
winActive("wc_r2_dialogs", r2WinOn)
winActive("wc_r2_events", r2WinOn)
winActive("wc_r2_activities", r2WinOn)
winActive("wc_r2_feature_help", r2WinOn)
winActive("wc_r2_connect", not r2WinOn)
winActive("wc_r2_session_browser", not r2WinOn)
winActive("wc_r2_scenario_control", true)
winActive("wc_r2_feature_help", r2WinOn)
winActive("wc_r2_connect", not r2WinOn)
winActive("wc_r2_session_browser", not r2WinOn)
winActive("wc_r2_scenario_control", true)
winActive("wc_r2_player_tracking", r2WinOn)
end

View file

@ -61,8 +61,7 @@ void CAnimationFX::buildTrack(NL3D::UAnimationSet *as)
nlassert(Sheet != NULL);
if (!as) return;
if (Sheet->TrajectoryAnim.empty()) return;
std::string animName = Sheet->TrajectoryAnim;
NLMISC::strlwr(animName);
std::string animName = NLMISC::toLower(Sheet->TrajectoryAnim);
uint id = as->getAnimationIdByName(animName);
NL3D::UAnimation *anim = NULL;
if (id != NL3D::UAnimationSet::NotFound)

View file

@ -17,53 +17,57 @@
#include "stdpch.h"
#include "app_bundle_utils.h"
#if defined(NL_OS_MAC)
#ifdef NL_OS_MAC
#include <CoreFoundation/CoreFoundation.h>
#endif
std::string getAppBundlePath()
{
static std::string cachedPathToBundle;
static std::string s_cachedPathToBundle;
if(cachedPathToBundle.size())
return cachedPathToBundle;
if (!s_cachedPathToBundle.empty())
return s_cachedPathToBundle;
#if defined(NL_OS_MAC)
// get the bundle
CFBundleRef bundle = CFBundleGetMainBundle();
if(bundle)
if (bundle)
{
// get the url to the bundles root
CFURLRef url = CFBundleCopyBundleURL(bundle);
if(url)
if (url)
{
// get the file system path
CFStringRef str;
str = CFURLCopyFileSystemPath(
CFURLCopyAbsoluteURL(url), kCFURLPOSIXPathStyle);
str = CFURLCopyFileSystemPath(CFURLCopyAbsoluteURL(url), kCFURLPOSIXPathStyle);
CFRelease(url);
if(str)
if (str)
{
cachedPathToBundle = CFStringGetCStringPtr(
str, CFStringGetSmallestEncoding(str));
s_cachedPathToBundle = CFStringGetCStringPtr(str, CFStringGetSmallestEncoding(str));
CFRelease(str);
}
else
{
nlerror("CFStringGetCStringPtr");
}
}
else
{
nlerror("CFBundleCopyBundleURL");
}
}
else
{
nlerror("CFBundleGetMainBundle");
}
#elif defined(NL_OS_WINDOWS)
char buffer[MAX_PATH+1];
if (GetModuleFileNameA(NULL, buffer, MAX_PATH))
cachedPathToBundle = NLMISC::CPath::standardizePath(NLMISC::CFile::getPath(buffer), false);
s_cachedPathToBundle = NLMISC::CPath::standardizePath(NLMISC::CFile::getPath(buffer), false);
#endif // defined(NL_OS_MAC)
return cachedPathToBundle;
return s_cachedPathToBundle;
}

View file

@ -81,7 +81,7 @@ void initAutoAnimation()
file.getline(line, 512);
// Read the animation file
string animName = strlwr (CFile::getFilenameWithoutExtension(line));
string animName = toLower(CFile::getFilenameWithoutExtension(line));
uint id = AutoAnimSet->addAnimation (line, animName.c_str ());
if (id == UAnimationSet::NotFound)
{

View file

@ -24,21 +24,26 @@ void browseFAQ(NLMISC::CConfigFile &cf)
std::string url;
std::string languageCode = "wk";
CConfigFile::CVar *languageCodeVarPtr = cf.getVarPtr("LanguageCode");
if (languageCodeVarPtr)
{
languageCode = languageCodeVarPtr->asString();
}
CConfigFile::CVar *helpPages = cf.getVarPtr("HelpPages");
if (helpPages)
{
for (uint i = 0; i < helpPages->size(); ++i)
{
std::string entry = helpPages->asString(i);
if (entry.size() >= languageCode.size())
{
if (nlstricmp(entry.substr(0, languageCode.size()), languageCode) == 0)
{
std::string::size_type pos = entry.find("=");
if (pos != std::string::npos)
{
url = entry.substr(pos + 1);

View file

@ -610,7 +610,7 @@ uint32 CCharacterCL::buildEquipment(const CCharacterSheet::CEquipment &slot, SLO
{
// IS the item a valid one ?
CSheetId itemId;
if(itemId.buildSheetId(NLMISC::strlwr(slot.getItem())))
if(itemId.buildSheetId(NLMISC::toLower(slot.getItem())))
{
// Is it stored in the database ?
CEntitySheet *entitySheet = SheetMngr.get(itemId);
@ -1098,7 +1098,7 @@ string CCharacterCL::automatonType() const // virtual
//-----------------------------------------------
void CCharacterCL::computeAutomaton()
{
_CurrentAutomaton = automatonType() + "_" + NLMISC::strlwr(MBEHAV::modeToString(_Mode)) + ".automaton";
_CurrentAutomaton = automatonType() + "_" + NLMISC::toLower(MBEHAV::modeToString(_Mode)) + ".automaton";
}// computeAutomaton //

View file

@ -49,9 +49,6 @@
#define FINAL_VERSION 1
#endif // TEST_CRASH_COUNTER
// game share
#include "game_share/ryzom_version.h"
// Client
#include "resource.h"
#include "init.h"
@ -124,6 +121,12 @@ static void sigHandler(int Sig)
//---------------------------------------------------
#ifdef NL_OS_WINDOWS
// enable optimus for NVIDIA cards
extern "C"
{
_declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}
void pump ()
{
// Display the window
@ -363,6 +366,11 @@ int main(int argc, char **argv)
// init the Nel context
CApplicationContext *appContext = new CApplicationContext;
// disable nldebug messages in logs in Release
#ifdef NL_RELEASE
DisableNLDebug = true;
#endif
createDebug();
INelContext::getInstance().setWindowedApplication(true);
@ -443,10 +451,9 @@ int main(int argc, char **argv)
if (string(cmdline) == "/crash")
volatile int toto = *(int*)0;
if (string(cmdline) == "/break")
__asm
{
int 3
};
{
__debugbreak();
}
#endif // TEST_CRASH_COUNTER
HInstance = hInstance;
@ -513,7 +520,7 @@ int main(int argc, char **argv)
uint i;
for (i=0; i<files.size(); i++)
{
if (strlwr (CFile::getExtension (files[i])) == "ttf")
if (toLower(CFile::getExtension (files[i])) == "ttf")
CFile::deleteFile (files[i]);
}
}

View file

@ -54,7 +54,7 @@ END
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_MAIN_ICON ICON DISCARDABLE "ryzom_small.ico"
IDI_MAIN_ICON ICON DISCARDABLE "ryzom.ico"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////

View file

@ -49,8 +49,6 @@
#include "app_bundle_utils.h"
#endif // NL_OS_MAC
#include <locale.h>
///////////
// MACRO //
///////////
@ -295,8 +293,8 @@ CClientConfig::CClientConfig()
SelectedSlot = 0; // Default is slot 0
Windowed = false; // Default is windowed mode.
Width = 800; // Default Width for the window.
Height = 600; // Default Height for the window.
Width = 0; // Default Width for the window (0 = current screen resolution).
Height = 0; // Default Height for the window (0 = current screen resolution).
Depth = 32; // Default Bit per Pixel.
Driver3D = DrvAuto; // Select best driver depending on hardware.
Contrast = 0.f; // Default Monitor Contrast.
@ -431,6 +429,8 @@ CClientConfig::CClientConfig()
WebIgMainDomain = "shard.ryzomcore.org";
WebIgTrustedDomains.push_back(WebIgMainDomain);
CurlMaxConnections = 2;
RingReleaseNotePath = "http://" + WebIgMainDomain + "/releasenotes_ring/index.php";
ReleaseNotePath = "http://" + WebIgMainDomain + "/releasenotes/index.php";
@ -680,7 +680,6 @@ CClientConfig::CClientConfig()
DamageShieldEnabled = false;
AllowDebugLua = false;
LoadLuaDebugger = false;
DisplayLuaDebugInfo = false;
BeepWhenLaunched = false;
@ -1076,6 +1075,9 @@ void CClientConfig::setValues()
// WEBIG //
READ_STRING_FV(WebIgMainDomain);
READ_STRINGVECTOR_FV(WebIgTrustedDomains);
READ_INT_FV(CurlMaxConnections);
if (ClientCfg.CurlMaxConnections < 0)
ClientCfg.CurlMaxConnections = 2;
///////////////
// ANIMATION //
@ -1747,7 +1749,7 @@ void CClientConfig::setValues()
// Allow warning display only first time.
DisplayCFGWarning= false;
// If it is the load time, bkup the ClientCfg into LastClientCfg
// If it is the load time, backup the ClientCfg into LastClientCfg
if(firstTimeSetValues)
LastClientCfg = ClientCfg;
@ -1761,7 +1763,6 @@ void CClientConfig::setValues()
READ_BOOL_DEV(DamageShieldEnabled)
READ_BOOL_DEV(AllowDebugLua)
READ_BOOL_DEV(LoadLuaDebugger)
READ_BOOL_DEV(DisplayLuaDebugInfo)
READ_BOOL_DEV(LuaDebugInfoGotoButtonEnabled)
@ -1934,8 +1935,7 @@ void CClientConfig::init(const string &configFileName)
nlwarning("CFG::init: creating '%s' with default values", configFileName.c_str ());
// get current locale
std::string lang = toLower(std::string(setlocale(LC_CTYPE, "")));
lang = lang.substr(0, 2);
std::string lang = CI18N::getSystemLanguageCode();
const std::vector<std::string> &languages = CI18N::getLanguageCodes();

View file

@ -304,6 +304,7 @@ struct CClientConfig
std::string WebIgMainDomain;
std::vector<string> WebIgTrustedDomains;
sint32 CurlMaxConnections;
///////////////
// ANIMATION //
@ -765,7 +766,6 @@ struct CClientConfig
/// Allow Lua commands (commands beginning with Lua)
bool AllowDebugLua;
bool LoadLuaDebugger;
bool LuaDebugInfoGotoButtonEnabled;
std::string LuaDebugInfoGotoButtonTemplate;

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