This commit is contained in:
sfb 2011-05-26 11:00:22 -05:00
parent 13b276b8fc
commit f57dc817e8
156 changed files with 8424 additions and 736 deletions

View file

@ -41,10 +41,6 @@ INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
# Force out of source builds. # Force out of source builds.
CHECK_OUT_OF_SOURCE() CHECK_OUT_OF_SOURCE()
# Variables which must be set before PROJECT
NL_SETUP_BUILD()
NL_SETUP_BUILD_FLAGS()
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(RyzomCore CXX C) PROJECT(RyzomCore CXX C)
SET(NL_VERSION_MAJOR 0) SET(NL_VERSION_MAJOR 0)
@ -52,6 +48,9 @@ SET(NL_VERSION_MINOR 8)
SET(NL_VERSION_PATCH 0) SET(NL_VERSION_PATCH 0)
SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}") SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}")
NL_SETUP_BUILD()
NL_SETUP_BUILD_FLAGS()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Redirect output files # Redirect output files
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@ -101,8 +100,15 @@ IF(WIN32)
# convert IDE fullpath to VC++ path # convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/IDE/.+" "VC" VC_DIR ${CMAKE_MAKE_PROGRAM}) STRING(REGEX REPLACE "Common7/IDE/.+" "VC" VC_DIR ${CMAKE_MAKE_PROGRAM})
ELSE(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") ELSE(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
# convert compiler fullpath to VC++ path IF(${CMAKE_CXX_COMPILER} MATCHES "VC")
STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER}) # convert compiler fullpath to VC++ path
STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER})
ELSE(${CMAKE_CXX_COMPILER} MATCHES "VC")
# Hack for Visual C++ 2010
GET_FILENAME_COMPONENT(VC_ROOT_PATH "[HKEY_CURRENT_USER\\Software\\Microsoft\\VCExpress\\10.0_Config;InstallDir]" ABSOLUTE)
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_PATH})
ENDIF(${CMAKE_CXX_COMPILER} MATCHES "VC")
ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
IF(WITH_MFC) IF(WITH_MFC)

View file

@ -47,6 +47,10 @@ MACRO(NL_CONFIGURE_CHECKS)
IF(WITH_DRIVER_OPENGL) IF(WITH_DRIVER_OPENGL)
SET(NL_OPENGL_AVAILABLE 1) SET(NL_OPENGL_AVAILABLE 1)
ENDIF(WITH_DRIVER_OPENGL) ENDIF(WITH_DRIVER_OPENGL)
IF(WITH_DRIVER_OPENGLES)
SET(NL_OPENGLES_AVAILABLE 1)
ENDIF(WITH_DRIVER_OPENGLES)
IF(WITH_DRIVER_DIRECT3D) IF(WITH_DRIVER_DIRECT3D)
SET(NL_DIRECT3D_AVAILABLE 1) SET(NL_DIRECT3D_AVAILABLE 1)

View file

@ -40,17 +40,12 @@ ENDIF(WITH_STLPORT OR NOT MFC_FOUND)
# Only if using a custom path # Only if using a custom path
IF(CUSTOM_MFC_DIR) IF(CUSTOM_MFC_DIR)
IF(NOT CMAKE_SIZEOF_VOID_P)
INCLUDE (CheckTypeSize)
CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)
ENDIF(NOT CMAKE_SIZEOF_VOID_P)
# Using 32 or 64 bits libraries # Using 32 or 64 bits libraries
IF(CMAKE_SIZEOF_VOID_P EQUAL 8) IF(TARGET_X64)
SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib/amd64") SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib/amd64")
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) ELSE(TARGET_X64)
SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib") SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib")
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8) ENDIF(TARGET_X64)
# Add MFC libraries directory to default library path # Add MFC libraries directory to default library path
LINK_DIRECTORIES(${MFC_LIBRARY_DIR}) LINK_DIRECTORIES(${MFC_LIBRARY_DIR})

View file

@ -30,16 +30,11 @@ ENDMACRO(FIND_DXSDK_LIBRARY MYLIBRARY MYLIBRARYNAME)
IF(DXSDK_DIR) IF(DXSDK_DIR)
SET(DXSDK_INCLUDE_DIR "${DXSDK_DIR}/Include") SET(DXSDK_INCLUDE_DIR "${DXSDK_DIR}/Include")
IF(NOT CMAKE_SIZEOF_VOID_P) IF(TARGET_X64)
INCLUDE (CheckTypeSize)
CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)
ENDIF(NOT CMAKE_SIZEOF_VOID_P)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(DXSDK_LIBRARY_DIR "${DXSDK_DIR}/Lib/x64") SET(DXSDK_LIBRARY_DIR "${DXSDK_DIR}/Lib/x64")
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) ELSE(TARGET_X64)
SET(DXSDK_LIBRARY_DIR "${DXSDK_DIR}/Lib/x86") SET(DXSDK_LIBRARY_DIR "${DXSDK_DIR}/Lib/x86")
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8) ENDIF(TARGET_X64)
FIND_DXSDK_LIBRARY(DXSDK_GUID_LIBRARY dxguid) FIND_DXSDK_LIBRARY(DXSDK_GUID_LIBRARY dxguid)
FIND_DXSDK_LIBRARY(DXSDK_DINPUT_LIBRARY dinput8) FIND_DXSDK_LIBRARY(DXSDK_DINPUT_LIBRARY dinput8)
@ -59,7 +54,7 @@ ENDIF(DXSDK_DIR)
# all listed variables are TRUE. # all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs) INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DIRECTXSDK DEFAULT_MSG DXSDK_DIR DXSDK_GUID_LIBRARY DXSDK_DINPUT_LIBRARY) FIND_PACKAGE_HANDLE_STANDARD_ARGS(DirectXSDK DEFAULT_MSG DXSDK_DIR DXSDK_GUID_LIBRARY DXSDK_DINPUT_LIBRARY)
MARK_AS_ADVANCED(DXSDK_INCLUDE_DIR MARK_AS_ADVANCED(DXSDK_INCLUDE_DIR
DXSDK_GUID_LIBRARY DXSDK_GUID_LIBRARY

View file

@ -7,7 +7,7 @@
# EXTERNAL_FOUND - True if the external libraries are available # 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_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/png.h") SET(EXTERNAL_TEMP_FILE "include/zlib.h")
SET(EXTERNAL_NAME "external") SET(EXTERNAL_NAME "external")
# If using STLport preprend external_stlport # If using STLport preprend external_stlport
@ -17,36 +17,35 @@ IF(WITH_STLPORT)
SET(EXTERNAL_NAME "external with STLport") SET(EXTERNAL_NAME "external with STLport")
ENDIF(WITH_STLPORT) ENDIF(WITH_STLPORT)
SET(EXTERNAL_FOUND FALSE) FIND_PATH(EXTERNAL_PATH
FOREACH(ITEM ${EXTERNAL_TEMP_PATH}) ${EXTERNAL_TEMP_FILE}
IF(EXISTS "${ITEM}/${EXTERNAL_TEMP_FILE}" AND NOT EXTERNAL_FOUND) PATHS
SET(EXTERNAL_FOUND TRUE) $ENV{EXTERNAL_PATH}
# Get absolute path to avoid .. ${EXTERNAL_TEMP_PATH}
GET_FILENAME_COMPONENT(ITEM ${ITEM} ABSOLUTE) /usr/local
SET(EXTERNAL_PATH ${ITEM} CACHE PATH "" FORCE) /usr
ENDIF(EXISTS "${ITEM}/${EXTERNAL_TEMP_FILE}" AND NOT EXTERNAL_FOUND) /sw
ENDFOREACH(ITEM ${EXTERNAL_TEMP_PATH}) /opt/local
/opt/csw
/opt
)
IF(EXTERNAL_FOUND) IF(EXTERNAL_PATH)
SET(EXTERNAL_FOUND TRUE)
SET(EXTERNAL_INCLUDE_PATH "${EXTERNAL_PATH}/include") SET(EXTERNAL_INCLUDE_PATH "${EXTERNAL_PATH}/include")
IF(NOT CMAKE_SIZEOF_VOID_P)
INCLUDE (CheckTypeSize)
CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)
ENDIF(NOT CMAKE_SIZEOF_VOID_P)
# Using 32 or 64 bits libraries # Using 32 or 64 bits libraries
IF(CMAKE_SIZEOF_VOID_P EQUAL 8) IF(TARGET_X64)
SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib64") SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib64")
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) ELSE(TARGET_X64)
SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib") SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib")
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8) ENDIF(TARGET_X64)
SET(CMAKE_INCLUDE_PATH "${EXTERNAL_INCLUDE_PATH};${CMAKE_INCLUDE_PATH}") SET(CMAKE_INCLUDE_PATH "${EXTERNAL_INCLUDE_PATH};${CMAKE_INCLUDE_PATH}")
# Stupid hack for FindOpenAL.cmake # Stupid hack for FindOpenAL.cmake
SET(CMAKE_INCLUDE_PATH "${EXTERNAL_PATH};${CMAKE_INCLUDE_PATH}") SET(CMAKE_INCLUDE_PATH "${EXTERNAL_PATH};${CMAKE_INCLUDE_PATH}")
SET(CMAKE_LIBRARY_PATH "${EXTERNAL_LIBRARY_PATH};${CMAKE_LIBRARY_PATH}") SET(CMAKE_LIBRARY_PATH "${EXTERNAL_LIBRARY_PATH};${CMAKE_LIBRARY_PATH}")
ENDIF(EXTERNAL_FOUND) ENDIF(EXTERNAL_PATH)
IF(EXTERNAL_FOUND) IF(EXTERNAL_FOUND)
IF(NOT External_FIND_QUIETLY) IF(NOT External_FIND_QUIETLY)

View file

@ -6,7 +6,7 @@
IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR) IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
# in cache already # in cache already
SET(LUABIND_FIND_QUIETLY TRUE) SET(Luabind_FIND_QUIETLY TRUE)
ENDIF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR) ENDIF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
FIND_PATH(LUABIND_INCLUDE_DIR FIND_PATH(LUABIND_INCLUDE_DIR
@ -22,7 +22,7 @@ FIND_PATH(LUABIND_INCLUDE_DIR
) )
SET(LIBRARY_NAME_RELEASE luabind libluabind) SET(LIBRARY_NAME_RELEASE luabind libluabind)
SET(LIBRARY_NAME_DEBUG luabind_d libluabind_d libluabindd) SET(LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd)
IF(WITH_STLPORT) IF(WITH_STLPORT)
SET(LIBRARY_NAME_RELEASE luabind_stlport ${LIBRARY_NAME_RELEASE}) SET(LIBRARY_NAME_RELEASE luabind_stlport ${LIBRARY_NAME_RELEASE})
@ -62,30 +62,35 @@ FIND_LIBRARY(LUABIND_LIBRARY_DEBUG
FIND_PACKAGE(Boost REQUIRED) FIND_PACKAGE(Boost REQUIRED)
IF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR) IF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR)
IF(LUABIND_LIBRARY_RELEASE) IF(LUABIND_LIBRARY_RELEASE AND LUABIND_LIBRARY_DEBUG)
# Case where both Release and Debug versions are provided
SET(LUABIND_FOUND TRUE) SET(LUABIND_FOUND TRUE)
SET(LUABIND_INCLUDE_DIR ${LUABIND_INCLUDE_DIR} ${Boost_INCLUDE_DIR}) SET(LUABIND_LIBRARIES optimized ${LUABIND_LIBRARY_RELEASE} debug ${LUABIND_LIBRARY_DEBUG})
IF(LUABIND_LIBRARY_DEBUG) ELSEIF(LUABIND_LIBRARY_RELEASE)
SET(LUABIND_LIBRARIES "optimized;${LUABIND_LIBRARY_RELEASE};debug;${LUABIND_LIBRARY_DEBUG}") # Normal case
ELSE(LUABIND_LIBRARY_DEBUG) SET(LUABIND_FOUND TRUE)
SET(LUABIND_LIBRARIES "${LUABIND_LIBRARY_RELEASE}") SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_RELEASE})
ENDIF(LUABIND_LIBRARY_DEBUG) ELSEIF(LUABIND_LIBRARY_DEBUG)
ENDIF(LUABIND_LIBRARY_RELEASE) # Case where Luabind is compiled from sources (debug version is compiled by default)
SET(LUABIND_FOUND TRUE)
SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_DEBUG})
ENDIF(LUABIND_LIBRARY_RELEASE AND LUABIND_LIBRARY_DEBUG)
ENDIF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR) ENDIF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR)
IF(LUABIND_FOUND) IF(LUABIND_FOUND)
SET(LUABIND_INCLUDE_DIR ${LUABIND_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
# Check if luabind/version.hpp exists # Check if luabind/version.hpp exists
FIND_FILE(LUABIND_VERSION_FILE luabind/version.hpp PATHS ${LUABIND_INCLUDE_DIR}) FIND_FILE(LUABIND_VERSION_FILE luabind/version.hpp PATHS ${LUABIND_INCLUDE_DIR})
IF(LUABIND_VERSION_FILE) IF(LUABIND_VERSION_FILE)
SET(LUABIND_DEFINITIONS "-DHAVE_LUABIND_VERSION") SET(LUABIND_DEFINITIONS "-DHAVE_LUABIND_VERSION")
ENDIF(LUABIND_VERSION_FILE) ENDIF(LUABIND_VERSION_FILE)
IF(NOT LUABIND_FIND_QUIETLY) IF(NOT Luabind_FIND_QUIETLY)
MESSAGE(STATUS "Found Luabind: ${LUABIND_LIBRARIES}") MESSAGE(STATUS "Found Luabind: ${LUABIND_LIBRARIES}")
ENDIF(NOT LUABIND_FIND_QUIETLY) ENDIF(NOT Luabind_FIND_QUIETLY)
ELSE(LUABIND_FOUND) ELSE(LUABIND_FOUND)
IF(NOT LUABIND_FIND_QUIETLY) IF(NOT Luabind_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Luabind!") MESSAGE(STATUS "Warning: Unable to find Luabind!")
ENDIF(NOT LUABIND_FIND_QUIETLY) ENDIF(NOT Luabind_FIND_QUIETLY)
ENDIF(LUABIND_FOUND) ENDIF(LUABIND_FOUND)
MARK_AS_ADVANCED(LUABIND_LIBRARY_RELEASE LUABIND_LIBRARY_DEBUG Boost_LIB_DIAGNOSTIC_DEFINITIONS) MARK_AS_ADVANCED(LUABIND_LIBRARY_RELEASE LUABIND_LIBRARY_DEBUG Boost_LIB_DIAGNOSTIC_DEFINITIONS)

View file

@ -71,9 +71,9 @@ IF(STLPORT_INCLUDE_DIR)
IF(STLPORT_LIBRARY_RELEASE) IF(STLPORT_LIBRARY_RELEASE)
SET(STLPORT_FOUND TRUE) SET(STLPORT_FOUND TRUE)
SET(STLPORT_LIBRARIES "optimized;${STLPORT_LIBRARY_RELEASE}") SET(STLPORT_LIBRARIES ${STLPORT_LIBRARY_RELEASE})
IF(STLPORT_LIBRARY_DEBUG) IF(STLPORT_LIBRARY_DEBUG)
SET(STLPORT_LIBRARIES "${STLPORT_LIBRARIES};debug;${STLPORT_LIBRARY_DEBUG}") SET(STLPORT_LIBRARIES optimized ${STLPORT_LIBRARIES} debug ${STLPORT_LIBRARY_DEBUG})
ENDIF(STLPORT_LIBRARY_DEBUG) ENDIF(STLPORT_LIBRARY_DEBUG)
ENDIF(STLPORT_LIBRARY_RELEASE) ENDIF(STLPORT_LIBRARY_RELEASE)
ENDIF(STLPORT_INCLUDE_DIR) ENDIF(STLPORT_INCLUDE_DIR)

View file

@ -9,17 +9,32 @@ IF(WINSDK_INCLUDE_DIR)
SET(WINSDK_FIND_QUIETLY TRUE) SET(WINSDK_FIND_QUIETLY TRUE)
ENDIF(WINSDK_INCLUDE_DIR) ENDIF(WINSDK_INCLUDE_DIR)
GET_FILENAME_COMPONENT(WINSDK71_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;InstallationFolder]" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(WINSDK71_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;ProductVersion]" NAME)
IF(WINSDK71_DIR)
IF(NOT WINSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDK71_VERSION} in ${WINSDK71_DIR}")
ENDIF(NOT WINSDK_FIND_QUIETLY)
ENDIF(WINSDK71_DIR)
GET_FILENAME_COMPONENT(WINSDKCURRENT_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(WINSDKCURRENT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentVersion]" NAME)
IF(WINSDKCURRENT_DIR)
IF(NOT WINSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDKCURRENT_VERSION} in ${WINSDKCURRENT_DIR}")
ENDIF(NOT WINSDK_FIND_QUIETLY)
ENDIF(WINSDKCURRENT_DIR)
FIND_PATH(WINSDK_INCLUDE_DIR Windows.h FIND_PATH(WINSDK_INCLUDE_DIR Windows.h
PATHS PATHS
"[HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]/Include" ${WINSDK71_DIR}/Include
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]/Include" ${WINSDKCURRENT_DIR}/Include
) )
IF(WINSDK_INCLUDE_DIR) IF(WINSDK_INCLUDE_DIR)
SET(WINSDK_FOUND TRUE) SET(WINSDK_FOUND TRUE)
IF(NOT WINSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK.")
ENDIF(NOT WINSDK_FIND_QUIETLY)
ELSE(WINSDK_INCLUDE_DIR) ELSE(WINSDK_INCLUDE_DIR)
IF(NOT WINSDK_FIND_QUIETLY) IF(NOT WINSDK_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Windows SDK!") MESSAGE(STATUS "Warning: Unable to find Windows SDK!")

View file

@ -1,39 +0,0 @@
# - Find zlib
# Find the native ZLIB includes and library
#
# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
# ZLIB_LIBRARIES - List of libraries when using zlib.
# ZLIB_FOUND - True if zlib found.
#=============================================================================
# Copyright 2001-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 distributed this file outside of CMake, substitute the full
# License text for the above reference.)
IF (ZLIB_INCLUDE_DIR)
# Already in cache, be silent
SET(ZLIB_FIND_QUIETLY TRUE)
ENDIF (ZLIB_INCLUDE_DIR)
FIND_PATH(ZLIB_INCLUDE_DIR zlib.h)
SET(ZLIB_NAMES z zlib zdll)
FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} )
MARK_AS_ADVANCED( ZLIB_LIBRARY ZLIB_INCLUDE_DIR )
# Per-recommendation
SET(ZLIB_INCLUDE_DIRS "${ZLIB_INCLUDE_DIR}")
SET(ZLIB_LIBRARIES "${ZLIB_LIBRARY}")
# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB DEFAULT_MSG ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS)

View file

@ -45,8 +45,6 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
LIST(APPEND ${_out_compile_flags} "-fPIC") LIST(APPEND ${_out_compile_flags} "-fPIC")
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
ELSE(CMAKE_COMPILER_IS_GNUCXX)
## TODO ... ? or does it work out of the box
ENDIF(CMAKE_COMPILER_IS_GNUCXX) ENDIF(CMAKE_COMPILER_IS_GNUCXX)
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES ) GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES )
@ -115,6 +113,11 @@ MACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input _output)
ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input) ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input)
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use ) MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND)
IF(CMAKE_COMPILER_IS_GNUCXX) IF(CMAKE_COMPILER_IS_GNUCXX)
# to do: test whether compiler flags match between target _targetName # to do: test whether compiler flags match between target _targetName
# and _pch_output_to_use # and _pch_output_to_use
@ -123,19 +126,15 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
# for use with distcc and gcc >4.0.1 if preprocessed files are accessible # for use with distcc and gcc >4.0.1 if preprocessed files are accessible
# on all remote machines set # on all remote machines set
# PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess # PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess
SET(_target_cflags "${PCH_ADDITIONAL_COMPILER_FLAGS}-include ${_input} -Winvalid-pch") SET(_target_cflags "${oldProps} ${PCH_ADDITIONAL_COMPILER_FLAGS}-include ${_input} -Winvalid-pch")
ELSE(CMAKE_COMPILER_IS_GNUCXX) ELSE(CMAKE_COMPILER_IS_GNUCXX)
IF(MSVC) IF(MSVC)
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND)
SET(_target_cflags "${oldProps} /Yu\"${_input}\" /FI\"${_input}\" /Fp\"${_pch_output_to_use}\"") SET(_target_cflags "${oldProps} /Yu\"${_input}\" /FI\"${_input}\" /Fp\"${_pch_output_to_use}\"")
ENDIF(MSVC) ENDIF(MSVC)
ENDIF(CMAKE_COMPILER_IS_GNUCXX) ENDIF(CMAKE_COMPILER_IS_GNUCXX)
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_target_cflags}) SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_target_cflags})
SET_TARGET_PROPERTIES(${_targetName}_pch_dephelp PROPERTIES COMPILE_FLAGS ${_target_cflags})
ADD_CUSTOM_TARGET(pch_Generate_${_targetName} DEPENDS ${_pch_output_to_use}) ADD_CUSTOM_TARGET(pch_Generate_${_targetName} DEPENDS ${_pch_output_to_use})
ADD_DEPENDENCIES(${_targetName} pch_Generate_${_targetName}) ADD_DEPENDENCIES(${_targetName} pch_Generate_${_targetName})
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET) ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET)

View file

@ -37,16 +37,17 @@ ENDMACRO(NL_TARGET_DRIVER)
# Argument: # Argument:
### ###
MACRO(NL_DEFAULT_PROPS name label) MACRO(NL_DEFAULT_PROPS name label)
IF(NOT MSVC10)
SET_TARGET_PROPERTIES(${name} PROPERTIES PROJECT_LABEL ${label})
ENDIF(NOT MSVC10)
GET_TARGET_PROPERTY(type ${name} TYPE) GET_TARGET_PROPERTY(type ${name} TYPE)
IF(${type} STREQUAL SHARED_LIBRARY) IF(${type} STREQUAL SHARED_LIBRARY)
# Set versions only if target is a shared library # Set versions only if target is a shared library
SET_TARGET_PROPERTIES(${name} PROPERTIES SET_TARGET_PROPERTIES(${name} PROPERTIES
VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR} VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR})
INSTALL_NAME_DIR ${NL_LIB_PREFIX} IF(NL_LIB_PREFIX)
PROJECT_LABEL ${label}) SET_TARGET_PROPERTIES(${name} PROPERTIES INSTALL_NAME_DIR ${NL_LIB_PREFIX})
ELSE(${type} STREQUAL SHARED_LIBRARY) ENDIF(NL_LIB_PREFIX)
SET_TARGET_PROPERTIES(${name} PROPERTIES
PROJECT_LABEL ${label})
ENDIF(${type} STREQUAL SHARED_LIBRARY) ENDIF(${type} STREQUAL SHARED_LIBRARY)
IF(WITH_STLPORT AND WIN32) IF(WITH_STLPORT AND WIN32)
SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "/X") SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "/X")
@ -93,6 +94,14 @@ MACRO(NL_ADD_STATIC_VID_DRIVERS name)
TARGET_LINK_LIBRARIES(${name} nel_drv_opengl) TARGET_LINK_LIBRARIES(${name} nel_drv_opengl)
ENDIF(WIN32) ENDIF(WIN32)
ENDIF(WITH_DRIVER_OPENGL) ENDIF(WITH_DRIVER_OPENGL)
IF(WITH_DRIVER_OPENGLES)
IF(WIN32)
TARGET_LINK_LIBRARIES(${name} nel_drv_opengles_win)
ELSE(WIN32)
TARGET_LINK_LIBRARIES(${name} nel_drv_opengles)
ENDIF(WIN32)
ENDIF(WITH_DRIVER_OPENGLES)
ENDIF(WITH_STATIC_DRIVERS) ENDIF(WITH_STATIC_DRIVERS)
ENDMACRO(NL_ADD_STATIC_VID_DRIVERS) ENDMACRO(NL_ADD_STATIC_VID_DRIVERS)
@ -208,6 +217,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
# Drivers Support # Drivers Support
### ###
OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON ) OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON )
OPTION(WITH_DRIVER_OPENGLES "Build OpenGL ES Driver (3D)" OFF)
OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF) OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF)
OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON ) OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON )
OPTION(WITH_DRIVER_FMOD "Build FMOD Driver (Sound)" OFF) OPTION(WITH_DRIVER_FMOD "Build FMOD Driver (Sound)" OFF)
@ -279,12 +289,19 @@ MACRO(NL_SETUP_BUILD)
ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug") ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug")
IF(WIN32) IF(WIN32)
# don't use a /O[012x] flag if you want custom optimizations IF(MSVC10)
SET(SPEED_OPTIMIZATIONS "/Ob2 /Oi /Ot /Oy /GT /GF /GS-") # /Ox is working with VC++ 2010, but custom optimizations don't exist
# without inlining it's unusable, use custom optimizations again SET(SPEED_OPTIMIZATIONS "/Ox /GF /GS-")
SET(MIN_OPTIMIZATIONS "/Ob1") # without inlining it's unusable, use custom optimizations again
SET(MIN_OPTIMIZATIONS "/Od /Ob1")
ELSE(MSVC10)
# don't use a /O[012x] flag if you want custom optimizations
SET(SPEED_OPTIMIZATIONS "/Ob2 /Oi /Ot /Oy /GT /GF /GS-")
# without inlining it's unusable, use custom optimizations again
SET(MIN_OPTIMIZATIONS "/Ob1")
ENDIF(MSVC10)
SET(PLATFORM_CFLAGS "/D_CRT_SECURE_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zi /Zm1000") SET(PLATFORM_CFLAGS "/D_CRT_SECURE_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zi /Zm1000 /MP")
# Exceptions are only set for C++ # Exceptions are only set for C++
SET(PLATFORM_CXXFLAGS "${PLATFORM_CFLAGS} /EHa") SET(PLATFORM_CXXFLAGS "${PLATFORM_CFLAGS} /EHa")
@ -317,30 +334,29 @@ MACRO(NL_SETUP_BUILD)
ENDIF(WIN32) ENDIF(WIN32)
# Determine host CPU # Determine target CPU
IF(UNIX AND NOT WIN32) # IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin ) IF(NOT CMAKE_SIZEOF_VOID_P)
IF(CMAKE_UNAME) INCLUDE (CheckTypeSize)
EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR) CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)
SET(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL "processor type (i386 and x86_64)") ENDIF(NOT CMAKE_SIZEOF_VOID_P)
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
ADD_DEFINITIONS(-DHAVE_X86_64) # Using 32 or 64 bits libraries
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64") SET(TARGET_X86 1)
ADD_DEFINITIONS(-DHAVE_IA64) IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
ELSE(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") SET(ARCH "x86_64")
ADD_DEFINITIONS(-DHAVE_X86) SET(TARGET_X64 1)
ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") ADD_DEFINITIONS(-DHAVE_X86_64)
ELSE(CMAKE_UNAME) # Assume that if uname is not found that we're x86. ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(ARCH "x86")
ADD_DEFINITIONS(-DHAVE_X86) ADD_DEFINITIONS(-DHAVE_X86)
ENDIF(CMAKE_UNAME) ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
ENDIF(UNIX AND NOT WIN32) # ADD_DEFINITIONS(-DHAVE_IA64)
# ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
ENDMACRO(NL_SETUP_BUILD) ENDMACRO(NL_SETUP_BUILD)
MACRO(NL_SETUP_BUILD_FLAGS) MACRO(NL_SETUP_BUILD_FLAGS)
#SET(CMAKE_DEBUG_POSTFIX "_d")
#SET(CMAKE_RELEASE_POSTFIX "_r")
SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE) SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE) SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE)

View file

@ -29,4 +29,4 @@ file for for more details on license terms and other legal issues.
Installation Installation
------------ ------------
Please check the dev.ryzom.com for more information Please visit http://dev.ryzom.com for more information.

View file

@ -35,6 +35,7 @@
#cmakedefine HAVE_STAT64 1 #cmakedefine HAVE_STAT64 1
#cmakedefine NL_OPENGL_AVAILABLE ${NL_OPENGL_AVAILABLE} #cmakedefine NL_OPENGL_AVAILABLE ${NL_OPENGL_AVAILABLE}
#cmakedefine NL_OPENGLES_AVAILABLE ${NL_OPENGLES_AVAILABLE}
#cmakedefine NL_DIRECT3D_AVAILABLE ${NL_DIRECT3D_AVAILABLE} #cmakedefine NL_DIRECT3D_AVAILABLE ${NL_DIRECT3D_AVAILABLE}
#cmakedefine NL_FMOD_AVAILABLE ${NL_FMOD_AVAILABLE} #cmakedefine NL_FMOD_AVAILABLE ${NL_FMOD_AVAILABLE}

View file

@ -169,7 +169,7 @@ void setCrashAlreadyReported(bool state);
*\endcode *\endcode
*/ */
#ifdef NL_NO_DEBUG #ifdef NL_NO_DEBUG
# if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# define nldebug __noop # define nldebug __noop
# else # else
# define nldebug 0&& # define nldebug 0&&
@ -184,7 +184,7 @@ void setCrashAlreadyReported(bool state);
* Same as nldebug but it will be display in debug and in release mode. * Same as nldebug but it will be display in debug and in release mode.
*/ */
#ifdef NL_NO_DEBUG #ifdef NL_NO_DEBUG
# if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# define nlinfo __noop # define nlinfo __noop
# else # else
# define nlinfo 0&& # define nlinfo 0&&
@ -212,7 +212,7 @@ void setCrashAlreadyReported(bool state);
*/ */
#ifdef NL_NO_DEBUG #ifdef NL_NO_DEBUG
# if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# define nlwarning __noop # define nlwarning __noop
# else # else
# define nlwarning 0&& # define nlwarning 0&&
@ -583,7 +583,11 @@ template<class T, class U> inline T type_cast(U o)
/** Compile time assertion /** Compile time assertion
*/ */
#define nlctassert(cond) sizeof(uint[(cond) ? 1 : 0]) #ifdef NL_ISO_CPP0X_AVAILABLE
# define nlctassert(cond) static_assert(cond, "Compile time assert in "#cond)
#else
# define nlctassert(cond) sizeof(uint[(cond) ? 1 : 0])
#endif
/** /**
* Allow to verify an object was accessed before its destructor call. * Allow to verify an object was accessed before its destructor call.

View file

@ -105,4 +105,7 @@ CHashKey getSHA1(const std::string &filename, bool forcePath = false);
// This function get a buffer with size and returns his SHA hash key // This function get a buffer with size and returns his SHA hash key
CHashKey getSHA1(const uint8 *buffer, uint32 size); CHashKey getSHA1(const uint8 *buffer, uint32 size);
// This function get a buffer and key with size and returns his HMAC-SHA1 hash key
CHashKey getHMacSHA1(const uint8 *text, uint32 text_len, const uint8 *key, uint32 key_len);
#endif // NL_SHA1_H #endif // NL_SHA1_H

View file

@ -352,7 +352,7 @@ public:
} }
}; };
#if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) #if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
// This operator only purpose is to compare with NULL value // This operator only purpose is to compare with NULL value
template <class T> template <class T>

View file

@ -51,14 +51,10 @@
# ifndef _WIN32_WINNT # ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0500 // Minimal OS = Windows 2000 (NeL is not supported on Windows 95/98) # define _WIN32_WINNT 0x0500 // Minimal OS = Windows 2000 (NeL is not supported on Windows 95/98)
# endif # endif
# if _MSC_VER >= 1500 # if _MSC_VER >= 1600
# define NL_COMP_VC10
# elif _MSC_VER >= 1500
# define NL_COMP_VC9 # define NL_COMP_VC9
# ifndef _STLPORT_VERSION // STLport doesn't depend on MS STL features
# if defined(_HAS_TR1) && (_HAS_TR1 + 0) // VC9 TR1 feature pack
# define NL_ISO_STDTR1_AVAILABLE
# define NL_ISO_STDTR1_HEADER(header) <header>
# endif
# endif
# elif _MSC_VER >= 1400 # elif _MSC_VER >= 1400
# define NL_COMP_VC8 # define NL_COMP_VC8
# undef nl_time # undef nl_time
@ -79,6 +75,10 @@
# define NL_COMP_VC6 # define NL_COMP_VC6
# define NL_COMP_NEED_PARAM_ON_METHOD # define NL_COMP_NEED_PARAM_ON_METHOD
# endif # endif
# if defined(_HAS_TR1) && (_HAS_TR1 + 0) // VC9 TR1 feature pack or later
# define NL_ISO_STDTR1_AVAILABLE
# define NL_ISO_STDTR1_HEADER(header) <header>
# endif
# ifdef _DEBUG # ifdef _DEBUG
# define NL_DEBUG # define NL_DEBUG
# elif defined (NDEBUG) # elif defined (NDEBUG)
@ -117,6 +117,10 @@
# define NL_COMP_GCC # define NL_COMP_GCC
#endif #endif
#if defined(_HAS_CPP0X) || defined(__GXX_EXPERIMENTAL_CXX0X__)
# define NL_ISO_CPP0X_AVAILABLE
#endif
// gcc 3.4 introduced ISO C++ with tough template rules // gcc 3.4 introduced ISO C++ with tough template rules
// //
// NL_ISO_SYNTAX can be used using #if NL_ISO_SYNTAX or #if !NL_ISO_SYNTAX // NL_ISO_SYNTAX can be used using #if NL_ISO_SYNTAX or #if !NL_ISO_SYNTAX
@ -149,7 +153,7 @@
# pragma warning (disable : 4390) // don't warn in empty block "if(exp) ;" # pragma warning (disable : 4390) // don't warn in empty block "if(exp) ;"
# pragma warning (disable : 4996) // 'vsnprintf': This function or variable may be unsafe. Consider using vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. # pragma warning (disable : 4996) // 'vsnprintf': This function or variable may be unsafe. Consider using vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
// Debug : Sept 01 2006 // Debug : Sept 01 2006
# if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# pragma warning (disable : 4005) // don't warn on redefinitions caused by xp platform sdk # pragma warning (disable : 4005) // don't warn on redefinitions caused by xp platform sdk
# endif // NL_COMP_VC8 || NL_COMP_VC9 # endif // NL_COMP_VC8 || NL_COMP_VC9
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
@ -287,20 +291,18 @@ typedef unsigned int uint; // at least 32bits (depend of processor)
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#include <inttypes.h> #include <inttypes.h>
#ifdef NL_OS_MAC #if defined(__PRI_64_LENGTH_MODIFIER__)
#define NL_I64 __PRI_64_LENGTH_MODIFIER__ # define NL_I64 __PRI_64_LENGTH_MODIFIER__
#elif defined(__PRI64_PREFIX)
# define NL_I64 __PRI64_PREFIX
#else #else
#define NL_I64 __PRI64_PREFIX # ifdef _LP64
# define NL_I64 "l"
# else
# define NL_I64 "ll"
# endif // _LP64
#endif #endif
/*
#ifdef _LP64
# define NL_I64 "l"
#else
# define NL_I64 "ll"
#endif // _LP64
*/
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
// CHashMap, CHashSet and CHashMultiMap definitions // CHashMap, CHashSet and CHashMultiMap definitions
@ -364,7 +366,7 @@ typedef uint16 ucchar;
// To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234) // To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# define INT64_CONSTANT(c) (c##LL) # define INT64_CONSTANT(c) (c##LL)
# define SINT64_CONSTANT(c) (c##LL) # define SINT64_CONSTANT(c) (c##LL)
# define UINT64_CONSTANT(c) (c##LL) # define UINT64_CONSTANT(c) (c##LL)

View file

@ -42,7 +42,6 @@ using namespace std;
using namespace NL3D; using namespace NL3D;
using namespace NLMISC; using namespace NLMISC;
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
int WINAPI WinMain( HINSTANCE hInstance, int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,
@ -139,7 +138,7 @@ int main(int argc, char **argv)
tc.setScaleX (scale); tc.setScaleX (scale);
tc.setScaleZ (scale); tc.setScaleZ (scale);
tc.printAt (0.1f, 0.3f, string("printAt Scale String")); tc.printAt (0.1f, 0.3f, string("printAt Scale String"));
// display the same string with no scale // display the same string with no scale
tc.setHotSpot (CComputedString::TopLeft); tc.setHotSpot (CComputedString::TopLeft);
tc.setScaleX (1.0f); tc.setScaleX (1.0f);

View file

@ -2508,8 +2508,13 @@ void CDriverGL::checkTextureOn() const
GLboolean flagCM; GLboolean flagCM;
GLboolean flagTR; GLboolean flagTR;
glGetBooleanv(GL_TEXTURE_2D, &flag2D); glGetBooleanv(GL_TEXTURE_2D, &flag2D);
#ifdef USE_OPENGLES
glGetBooleanv(GL_TEXTURE_CUBE_MAP_OES, &flagCM);
flagTR = true; // always true in OpenGL ES
#else
glGetBooleanv(GL_TEXTURE_CUBE_MAP_ARB, &flagCM); glGetBooleanv(GL_TEXTURE_CUBE_MAP_ARB, &flagCM);
glGetBooleanv(GL_TEXTURE_RECTANGLE_NV, &flagTR); glGetBooleanv(GL_TEXTURE_RECTANGLE_NV, &flagTR);
#endif
switch(dgs.getTextureMode()) switch(dgs.getTextureMode())
{ {
case CDriverGLStates::TextureDisabled: case CDriverGLStates::TextureDisabled:
@ -2545,7 +2550,8 @@ bool CDriverGL::supportOcclusionQuery() const
// *************************************************************************** // ***************************************************************************
bool CDriverGL::supportTextureRectangle() const bool CDriverGL::supportTextureRectangle() const
{ {
H_AUTO_OGL(CDriverGL_supportTextureRectangle) H_AUTO_OGL(CDriverGL_supportTextureRectangle);
return (_Extensions.NVTextureRectangle || _Extensions.EXTTextureRectangle || _Extensions.ARBTextureRectangle); return (_Extensions.NVTextureRectangle || _Extensions.EXTTextureRectangle || _Extensions.ARBTextureRectangle);
} }

View file

@ -139,8 +139,13 @@ void CDriverGL::setLightInternal(uint8 num, const CLight& light)
else else
{ {
// Deactivate spot properties // Deactivate spot properties
#ifdef USE_OPENGLES
glLightf (lightNum, GL_SPOT_CUTOFF, 180.f);
glLightf (lightNum, GL_SPOT_EXPONENT, 0.f);
#else
glLighti (lightNum, GL_SPOT_CUTOFF, 180); glLighti (lightNum, GL_SPOT_CUTOFF, 180);
glLighti (lightNum, GL_SPOT_EXPONENT, 0); glLighti (lightNum, GL_SPOT_EXPONENT, 0);
#endif
} }
// Flag this light as dirt. // Flag this light as dirt.

View file

@ -35,10 +35,18 @@ static void convBlend(CMaterial::TBlend blend, GLenum& glenum)
case CMaterial::srccolor: glenum=GL_SRC_COLOR; break; case CMaterial::srccolor: glenum=GL_SRC_COLOR; break;
case CMaterial::invsrccolor:glenum=GL_ONE_MINUS_SRC_COLOR; break; case CMaterial::invsrccolor:glenum=GL_ONE_MINUS_SRC_COLOR; break;
// Extended Blend modes. // Extended Blend modes.
#ifdef USE_OPENGLES
case CMaterial::blendConstantColor: glenum=GL_CONSTANT_COLOR; break;
case CMaterial::blendConstantInvColor: glenum=GL_ONE_MINUS_CONSTANT_COLOR; break;
case CMaterial::blendConstantAlpha: glenum=GL_CONSTANT_ALPHA; break;
case CMaterial::blendConstantInvAlpha: glenum=GL_ONE_MINUS_CONSTANT_ALPHA; break;
#else
case CMaterial::blendConstantColor: glenum=GL_CONSTANT_COLOR_EXT; break; case CMaterial::blendConstantColor: glenum=GL_CONSTANT_COLOR_EXT; break;
case CMaterial::blendConstantInvColor: glenum=GL_ONE_MINUS_CONSTANT_COLOR_EXT; break; case CMaterial::blendConstantInvColor: glenum=GL_ONE_MINUS_CONSTANT_COLOR_EXT; break;
case CMaterial::blendConstantAlpha: glenum=GL_CONSTANT_ALPHA_EXT; break; case CMaterial::blendConstantAlpha: glenum=GL_CONSTANT_ALPHA_EXT; break;
case CMaterial::blendConstantInvAlpha: glenum=GL_ONE_MINUS_CONSTANT_ALPHA_EXT; break; case CMaterial::blendConstantInvAlpha: glenum=GL_ONE_MINUS_CONSTANT_ALPHA_EXT; break;
#endif
default: nlstop; default: nlstop;
} }
} }
@ -137,7 +145,9 @@ void CDriverGL::setTextureEnvFunction(uint stage, CMaterial& mat)
_DriverGLStates.setTexGenMode (stage, GL_OBJECT_LINEAR); _DriverGLStates.setTexGenMode (stage, GL_OBJECT_LINEAR);
} }
else if(mode==CMaterial::TexCoordGenEyeSpace) else if(mode==CMaterial::TexCoordGenEyeSpace)
{
_DriverGLStates.setTexGenMode (stage, GL_EYE_LINEAR); _DriverGLStates.setTexGenMode (stage, GL_EYE_LINEAR);
}
} }
else else
{ {
@ -240,7 +250,9 @@ void CDriverGL::setTextureShaders(const uint8 *addressingModes, const CSmartPtr<
if (glAddrMode != _CurrentTexAddrMode[stage]) // addressing mode different from the one in the device? if (glAddrMode != _CurrentTexAddrMode[stage]) // addressing mode different from the one in the device?
{ {
_DriverGLStates.activeTextureARB(stage); _DriverGLStates.activeTextureARB(stage);
#ifndef USE_OPENGLES
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, glAddrMode); glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, glAddrMode);
#endif
_CurrentTexAddrMode[stage] = glAddrMode; _CurrentTexAddrMode[stage] = glAddrMode;
} }
} }
@ -918,7 +930,11 @@ void CDriverGL::setupLightMapPass(uint pass)
if (mat._LightMapsMulx2) if (mat._LightMapsMulx2)
{ {
// Multiply x 2 // Multiply x 2
#ifdef USE_OPENGLES
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, 2);
#else
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2); glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2);
#endif
} }
} }
} }
@ -1027,7 +1043,11 @@ void CDriverGL::endLightMapMultiPass()
for (uint32 i = 0; i < (_NLightMapPerPass+1); ++i) for (uint32 i = 0; i < (_NLightMapPerPass+1); ++i)
{ {
_DriverGLStates.activeTextureARB(i); _DriverGLStates.activeTextureARB(i);
#ifdef USE_OPENGLES
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, 1);
#else
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1); glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1);
#endif
} }
} }
} }
@ -1102,13 +1122,16 @@ void CDriverGL::setupSpecularBegin()
// todo hulud remove // todo hulud remove
// _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap); // _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap);
#ifdef USE_OPENGLES
_DriverGLStates.setTexGenMode (1, GL_REFLECTION_MAP_OES);
#else
_DriverGLStates.setTexGenMode (1, GL_REFLECTION_MAP_ARB); _DriverGLStates.setTexGenMode (1, GL_REFLECTION_MAP_ARB);
#endif
// setup the good matrix for stage 1. // setup the good matrix for stage 1.
glMatrixMode(GL_TEXTURE); glMatrixMode(GL_TEXTURE);
glLoadMatrixf( _SpecularTexMtx.get() ); glLoadMatrixf( _SpecularTexMtx.get() );
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
} }
// *************************************************************************** // ***************************************************************************
@ -1292,7 +1315,8 @@ void CDriverGL::setupSpecularPass(uint pass)
_DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled); _DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled);
} }
else else
{ // Multiply texture1 by alpha_texture0 and display with add {
// Multiply texture1 by alpha_texture0 and display with add
_DriverGLStates.enableBlend(true); _DriverGLStates.enableBlend(true);
_DriverGLStates.blendFunc(GL_ONE, GL_ONE); _DriverGLStates.blendFunc(GL_ONE, GL_ONE);
@ -1957,7 +1981,9 @@ void CDriverGL::endCloudMultiPass()
nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud); nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud);
if (ATICloudShaderHandle) if (ATICloudShaderHandle)
{ {
#ifndef USE_OPENGLES
glDisable(GL_FRAGMENT_SHADER_ATI); glDisable(GL_FRAGMENT_SHADER_ATI);
#endif
} }
} }
@ -1975,7 +2001,9 @@ sint CDriverGL::beginWaterMultiPass()
*/ */
void CDriverGL::setupWaterPassR200(const CMaterial &mat) void CDriverGL::setupWaterPassR200(const CMaterial &mat)
{ {
H_AUTO_OGL(CDriverGL_setupWaterPassR200) H_AUTO_OGL(CDriverGL_setupWaterPassR200);
#ifndef USE_OPENGLES
uint k; uint k;
ITexture *tex = mat.getTexture(0); ITexture *tex = mat.getTexture(0);
if (tex) if (tex)
@ -2047,6 +2075,7 @@ void CDriverGL::setupWaterPassR200(const CMaterial &mat)
float cst[4] = { 1.f, 1.f, 1.f, 0.f }; float cst[4] = { 1.f, 1.f, 1.f, 0.f };
nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst); nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst);
} }
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -2054,7 +2083,9 @@ void CDriverGL::setupWaterPassR200(const CMaterial &mat)
*/ */
void CDriverGL::setupWaterPassARB(const CMaterial &mat) void CDriverGL::setupWaterPassARB(const CMaterial &mat)
{ {
H_AUTO_OGL(CDriverGL_setupWaterPassARB) H_AUTO_OGL(CDriverGL_setupWaterPassARB);
#ifndef USE_OPENGLES
uint k; uint k;
ITexture *tex = mat.getTexture(0); ITexture *tex = mat.getTexture(0);
if (tex) if (tex)
@ -2133,6 +2164,7 @@ void CDriverGL::setupWaterPassARB(const CMaterial &mat)
} }
} }
} }
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -2161,6 +2193,7 @@ void CDriverGL::setupWaterPassNV20(const CMaterial &mat)
{ {
H_AUTO_OGL(CDriverGL_setupWaterPassNV20) H_AUTO_OGL(CDriverGL_setupWaterPassNV20)
#ifndef USE_OPENGLES
static bool setupDone = false; static bool setupDone = false;
static CMaterial::CTexEnv texEnvReplace; static CMaterial::CTexEnv texEnvReplace;
static CMaterial::CTexEnv texEnvModulate; static CMaterial::CTexEnv texEnvModulate;
@ -2245,6 +2278,7 @@ void CDriverGL::setupWaterPassNV20(const CMaterial &mat)
activateTexEnvMode(2, texEnvReplace); activateTexEnvMode(2, texEnvReplace);
activateTexEnvMode(3, texEnvModulate); activateTexEnvMode(3, texEnvModulate);
} }
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -2272,7 +2306,9 @@ void CDriverGL::setupWaterPass(uint /* pass */)
// *************************************************************************** // ***************************************************************************
void CDriverGL::endWaterMultiPass() void CDriverGL::endWaterMultiPass()
{ {
H_AUTO_OGL(CDriverGL_endWaterMultiPass) H_AUTO_OGL(CDriverGL_endWaterMultiPass);
#ifndef USE_OPENGLES
nlassert(_CurrentMaterial->getShader() == CMaterial::Water); nlassert(_CurrentMaterial->getShader() == CMaterial::Water);
// NB : as fragment shaders / programs bypass the texture envs, no special env enum is added (c.f CTexEnvSpecial) // NB : as fragment shaders / programs bypass the texture envs, no special env enum is added (c.f CTexEnvSpecial)
if (_Extensions.NVTextureShader) return; if (_Extensions.NVTextureShader) return;
@ -2284,6 +2320,7 @@ void CDriverGL::endWaterMultiPass()
{ {
glDisable(GL_FRAGMENT_SHADER_ATI); glDisable(GL_FRAGMENT_SHADER_ATI);
} }
#endif
} }
} // NL3D } // NL3D

View file

@ -15,24 +15,35 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h" #include "stdopengl.h"
#include "driver_opengl.h" #include "driver_opengl.h"
namespace NL3D { namespace NL3D {
// *************************************************************************** // ***************************************************************************
void CDriverGL::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective) void CDriverGL::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective)
{ {
H_AUTO_OGL(CDriverGL_setFrustum) H_AUTO_OGL(CDriverGL_setFrustum);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
if (perspective) if (perspective)
{ {
#ifdef USE_OPENGLES
glFrustumf(left,right,bottom,top,znear,zfar);
#else
glFrustum(left,right,bottom,top,znear,zfar); glFrustum(left,right,bottom,top,znear,zfar);
#endif
} }
else else
{ {
#ifdef USE_OPENGLES
glOrthof(left,right,bottom,top,znear,zfar);
#else
glOrtho(left,right,bottom,top,znear,zfar); glOrtho(left,right,bottom,top,znear,zfar);
#endif
} }
_ProjMatDirty = true; _ProjMatDirty = true;
// Backup znear and zfar for zbias setup // Backup znear and zfar for zbias setup

View file

@ -77,7 +77,8 @@ void CDriverGLStates::init(bool supportTextureCubeMap, bool supportTextureRect
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::forceDefaults(uint nbStages) void CDriverGLStates::forceDefaults(uint nbStages)
{ {
H_AUTO_OGL(CDriverGLStates_forceDefaults) H_AUTO_OGL(CDriverGLStates_forceDefaults);
// Enable / disable. // Enable / disable.
_CurFog= false; _CurFog= false;
_CurBlend= false; _CurBlend= false;
@ -86,6 +87,7 @@ void CDriverGLStates::forceDefaults(uint nbStages)
_CurLighting= false; _CurLighting= false;
_CurZWrite= true; _CurZWrite= true;
_CurStencilTest=false; _CurStencilTest=false;
// setup GLStates. // setup GLStates.
glDisable(GL_FOG); glDisable(GL_FOG);
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -144,33 +146,62 @@ void CDriverGLStates::forceDefaults(uint nbStages)
for(stage=0;stage<nbStages; stage++) for(stage=0;stage<nbStages; stage++)
{ {
// disable texturing. // disable texturing.
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
if(_TextureCubeMapSupported) if(_TextureCubeMapSupported)
{
#ifdef USE_OPENGLES
glDisable(GL_TEXTURE_CUBE_MAP_OES);
glDisable(GL_TEXTURE_GEN_STR_OES);
#else
glDisable(GL_TEXTURE_CUBE_MAP_ARB); glDisable(GL_TEXTURE_CUBE_MAP_ARB);
if(_TextureRectangleSupported) #endif
glDisable(GL_TEXTURE_RECTANGLE_NV); }
_TextureMode[stage]= TextureDisabled; _TextureMode[stage]= TextureDisabled;
// Tex gen init // Tex gen init
_TexGenMode[stage] = 0; _TexGenMode[stage] = 0;
glDisable( GL_TEXTURE_GEN_S );
glDisable( GL_TEXTURE_GEN_T ); #ifndef USE_OPENGLES
glDisable( GL_TEXTURE_GEN_R ); if(_TextureRectangleSupported)
glDisable( GL_TEXTURE_GEN_Q ); glDisable(GL_TEXTURE_RECTANGLE_NV);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_GEN_Q);
#endif
} }
// ActiveTexture current texture to 0. // ActiveTexture current texture to 0.
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB); nglActiveTextureARB(GL_TEXTURE0_ARB);
_CurrentActiveTextureARB= 0;
nglClientActiveTextureARB(GL_TEXTURE0_ARB); nglClientActiveTextureARB(GL_TEXTURE0_ARB);
#endif
_CurrentActiveTextureARB= 0;
_CurrentClientActiveTextureARB= 0; _CurrentClientActiveTextureARB= 0;
// Depth range // Depth range
_DepthRangeNear = 0.f; _DepthRangeNear = 0.f;
_DepthRangeFar = 1.f; _DepthRangeFar = 1.f;
_ZBias = 0.f; _ZBias = 0.f;
#ifdef USE_OPENGLES
glDepthRangef (0.f, 1.f);
#else
glDepthRange (0, 1); glDepthRange (0, 1);
#endif
// Cull order // Cull order
_CullMode = CCW; _CullMode = CCW;
@ -536,7 +567,9 @@ void CDriverGLStates::setVertexColorLighted(bool enable)
if (_VertexColorLighted) if (_VertexColorLighted)
{ {
glEnable (GL_COLOR_MATERIAL); glEnable (GL_COLOR_MATERIAL);
#ifndef USE_OPENGLES
glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE); glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE);
#endif
} }
else else
{ {
@ -558,9 +591,15 @@ void CDriverGLStates::setVertexColorLighted(bool enable)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::updateDepthRange() void CDriverGLStates::updateDepthRange()
{ {
H_AUTO_OGL(CDriverGLStates_updateDepthRange) H_AUTO_OGL(CDriverGLStates_updateDepthRange);
float delta = _ZBias * (_DepthRangeFar - _DepthRangeNear); float delta = _ZBias * (_DepthRangeFar - _DepthRangeNear);
#ifdef USE_OPENGLES
glDepthRangef(delta + _DepthRangeNear, delta + _DepthRangeFar);
#else
glDepthRange(delta + _DepthRangeNear, delta + _DepthRangeFar); glDepthRange(delta + _DepthRangeNear, delta + _DepthRangeFar);
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -605,10 +644,14 @@ void CDriverGLStates::setTexGenMode (uint stage, GLint mode)
if(mode==0) if(mode==0)
{ {
#ifdef USE_OPENGLES
glDisable(GL_TEXTURE_GEN_STR_OES);
#else
glDisable( GL_TEXTURE_GEN_S ); glDisable( GL_TEXTURE_GEN_S );
glDisable( GL_TEXTURE_GEN_T ); glDisable( GL_TEXTURE_GEN_T );
glDisable( GL_TEXTURE_GEN_R ); glDisable( GL_TEXTURE_GEN_R );
glDisable( GL_TEXTURE_GEN_Q ); glDisable( GL_TEXTURE_GEN_Q );
#endif
} }
else else
{ {
@ -630,10 +673,15 @@ void CDriverGLStates::setTexGenMode (uint stage, GLint mode)
{ {
glDisable( GL_TEXTURE_GEN_Q ); glDisable( GL_TEXTURE_GEN_Q );
} }
// Enable All. // Enable All.
#ifdef USE_OPENGLES
glEnable(GL_TEXTURE_GEN_STR_OES);
#else
glEnable( GL_TEXTURE_GEN_S ); glEnable( GL_TEXTURE_GEN_S );
glEnable( GL_TEXTURE_GEN_T ); glEnable( GL_TEXTURE_GEN_T );
glEnable( GL_TEXTURE_GEN_R ); glEnable( GL_TEXTURE_GEN_R );
#endif
} }
} }
} }
@ -649,12 +697,19 @@ void CDriverGLStates::resetTextureMode()
if (_TextureCubeMapSupported) if (_TextureCubeMapSupported)
{ {
#ifdef USE_OPENGLES
glDisable(GL_TEXTURE_CUBE_MAP_OES);
#else
glDisable(GL_TEXTURE_CUBE_MAP_ARB); glDisable(GL_TEXTURE_CUBE_MAP_ARB);
#endif
} }
#ifndef USE_OPENGLES
if (_TextureRectangleSupported) if (_TextureRectangleSupported)
{ {
glDisable(GL_TEXTURE_RECTANGLE_NV); glDisable(GL_TEXTURE_RECTANGLE_NV);
} }
#endif
_TextureMode[_CurrentActiveTextureARB]= TextureDisabled; _TextureMode[_CurrentActiveTextureARB]= TextureDisabled;
} }
@ -674,11 +729,13 @@ void CDriverGLStates::setTextureMode(TTextureMode texMode)
} }
else if(oldTexMode == TextureRect) else if(oldTexMode == TextureRect)
{ {
#ifndef USE_OPENGLES
if(_TextureRectangleSupported) if(_TextureRectangleSupported)
{ {
glDisable(GL_TEXTURE_RECTANGLE_NV); glDisable(GL_TEXTURE_RECTANGLE_NV);
} }
else else
#endif
{ {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
} }
@ -687,7 +744,11 @@ void CDriverGLStates::setTextureMode(TTextureMode texMode)
{ {
if(_TextureCubeMapSupported) if(_TextureCubeMapSupported)
{ {
#ifdef USE_OPENGLES
glDisable(GL_TEXTURE_CUBE_MAP_OES);
#else
glDisable(GL_TEXTURE_CUBE_MAP_ARB); glDisable(GL_TEXTURE_CUBE_MAP_ARB);
#endif
} }
else else
{ {
@ -702,24 +763,30 @@ void CDriverGLStates::setTextureMode(TTextureMode texMode)
} }
else if(texMode == TextureRect) else if(texMode == TextureRect)
{ {
#ifndef USE_OPENGLES
if(_TextureRectangleSupported) if(_TextureRectangleSupported)
{ {
glEnable(GL_TEXTURE_RECTANGLE_NV); glEnable(GL_TEXTURE_RECTANGLE_NV);
} }
else else
#endif
{ {
glDisable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
} }
} }
else if(texMode == TextureCubeMap) else if(texMode == TextureCubeMap)
{ {
if(_TextureCubeMapSupported) if(_TextureCubeMapSupported)
{ {
#ifdef USE_OPENGLES
glEnable(GL_TEXTURE_CUBE_MAP_OES);
#else
glEnable(GL_TEXTURE_CUBE_MAP_ARB); glEnable(GL_TEXTURE_CUBE_MAP_ARB);
#endif
} }
else else
{ {
glDisable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
} }
} }
@ -736,8 +803,11 @@ void CDriverGLStates::activeTextureARB(uint stage)
if( _CurrentActiveTextureARB != stage ) if( _CurrentActiveTextureARB != stage )
{ {
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentActiveTextureARB= stage; _CurrentActiveTextureARB= stage;
} }
@ -748,7 +818,11 @@ void CDriverGLStates::forceActiveTextureARB(uint stage)
{ {
H_AUTO_OGL(CDriverGLStates_forceActiveTextureARB); H_AUTO_OGL(CDriverGLStates_forceActiveTextureARB);
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentActiveTextureARB= stage; _CurrentActiveTextureARB= stage;
} }
@ -786,22 +860,25 @@ void CDriverGLStates::enableNormalArray(bool enable)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableWeightArray(bool enable) void CDriverGLStates::enableWeightArray(bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableWeightArray) H_AUTO_OGL(CDriverGLStates_enableWeightArray);
if(_WeightArrayEnabled != enable) if(_WeightArrayEnabled != enable)
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
glEnableClientState(GL_VERTEX_WEIGHTING_EXT); glEnableClientState(GL_VERTEX_WEIGHTING_EXT);
else else
glDisableClientState(GL_VERTEX_WEIGHTING_EXT); glDisableClientState(GL_VERTEX_WEIGHTING_EXT);
#endif
_WeightArrayEnabled= enable; _WeightArrayEnabled= enable;
} }
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableColorArray(bool enable) void CDriverGLStates::enableColorArray(bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableColorArray) H_AUTO_OGL(CDriverGLStates_enableColorArray);
if(_ColorArrayEnabled != enable) if(_ColorArrayEnabled != enable)
{ {
if(enable) if(enable)
@ -818,32 +895,42 @@ void CDriverGLStates::enableColorArray(bool enable)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableSecondaryColorArray(bool enable) void CDriverGLStates::enableSecondaryColorArray(bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableSecondaryColorArray) H_AUTO_OGL(CDriverGLStates_enableSecondaryColorArray);
if(_SecondaryColorArrayEnabled != enable) if(_SecondaryColorArrayEnabled != enable)
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
else else
glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
#endif
_SecondaryColorArrayEnabled= enable; _SecondaryColorArrayEnabled= enable;
#ifndef USE_OPENGLES
// If disable // If disable
if(!enable) if(!enable)
{ {
// GeForceFx Bug: Must reset Secondary color to 0 (if comes from a VP), else bugs // GeForceFx Bug: Must reset Secondary color to 0 (if comes from a VP), else bugs
nglSecondaryColor3ubEXT(0,0,0); nglSecondaryColor3ubEXT(0,0,0);
} }
#endif
} }
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::clientActiveTextureARB(uint stage) void CDriverGLStates::clientActiveTextureARB(uint stage)
{ {
H_AUTO_OGL(CDriverGLStates_clientActiveTextureARB) H_AUTO_OGL(CDriverGLStates_clientActiveTextureARB);
if( _CurrentClientActiveTextureARB != stage ) if( _CurrentClientActiveTextureARB != stage )
{ {
#ifdef USE_OPENGLES
glClientActiveTexture(GL_TEXTURE0+stage);
#else
nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage); nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentClientActiveTextureARB= stage; _CurrentClientActiveTextureARB= stage;
} }
} }
@ -851,7 +938,8 @@ void CDriverGLStates::clientActiveTextureARB(uint stage)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableTexCoordArray(bool enable) void CDriverGLStates::enableTexCoordArray(bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableTexCoordArray) H_AUTO_OGL(CDriverGLStates_enableTexCoordArray);
if(_TexCoordArrayEnabled[_CurrentClientActiveTextureARB] != enable) if(_TexCoordArrayEnabled[_CurrentClientActiveTextureARB] != enable)
{ {
if(enable) if(enable)
@ -867,14 +955,16 @@ void CDriverGLStates::enableTexCoordArray(bool enable)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableVertexAttribArray(uint glIndex, bool enable) void CDriverGLStates::enableVertexAttribArray(uint glIndex, bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableVertexAttribArray) H_AUTO_OGL(CDriverGLStates_enableVertexAttribArray);
if(_VertexAttribArrayEnabled[glIndex] != enable) if(_VertexAttribArrayEnabled[glIndex] != enable)
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
glEnableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV); glEnableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV);
else else
glDisableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV); glDisableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV);
#endif
_VertexAttribArrayEnabled[glIndex]= enable; _VertexAttribArrayEnabled[glIndex]= enable;
} }
@ -883,15 +973,18 @@ void CDriverGLStates::enableVertexAttribArray(uint glIndex, bool enable)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableVertexAttribArrayARB(uint glIndex,bool enable) void CDriverGLStates::enableVertexAttribArrayARB(uint glIndex,bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableVertexAttribArrayARB) H_AUTO_OGL(CDriverGLStates_enableVertexAttribArrayARB);
#ifndef NL3D_GLSTATE_DISABLE_CACHE #ifndef NL3D_GLSTATE_DISABLE_CACHE
if(_VertexAttribArrayEnabled[glIndex] != enable) if(_VertexAttribArrayEnabled[glIndex] != enable)
#endif #endif
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
nglEnableVertexAttribArrayARB(glIndex); nglEnableVertexAttribArrayARB(glIndex);
else else
nglDisableVertexAttribArrayARB(glIndex); nglDisableVertexAttribArrayARB(glIndex);
#endif
_VertexAttribArrayEnabled[glIndex]= enable; _VertexAttribArrayEnabled[glIndex]= enable;
} }
@ -988,7 +1081,13 @@ void CDriverGLStates::enableFog(uint enable)
void CDriverGLStates::forceBindARBVertexBuffer(uint objectID) void CDriverGLStates::forceBindARBVertexBuffer(uint objectID)
{ {
H_AUTO_OGL(CDriverGLStates_forceBindARBVertexBuffer) H_AUTO_OGL(CDriverGLStates_forceBindARBVertexBuffer)
#ifdef USE_OPENGLES
glBindBuffer(GL_ARRAY_BUFFER, objectID);
#else
nglBindBufferARB(GL_ARRAY_BUFFER_ARB, objectID); nglBindBufferARB(GL_ARRAY_BUFFER_ARB, objectID);
#endif
_CurrARBVertexBuffer = objectID; _CurrARBVertexBuffer = objectID;
} }

View file

@ -20,11 +20,15 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/3d/vertex_buffer.h" #include "nel/3d/vertex_buffer.h"
#ifdef NL_OS_MAC #ifdef USE_OPENGLES
# define GL_GLEXT_LEGACY # include <GLES/gl.h>
# include <OpenGL/gl.h>
#else #else
# include <GL/gl.h> # ifdef NL_OS_MAC
# define GL_GLEXT_LEGACY
# include <OpenGL/gl.h>
# else
# include <GL/gl.h>
# endif
#endif #endif
@ -41,7 +45,7 @@ namespace NL3D
- GL_ALPHA_TEST - GL_ALPHA_TEST
- GL_LIGHTING - GL_LIGHTING
- GL_LIGHT0 + i ..... - GL_LIGHT0 + i .....
- GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP_ARB. - GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP_ARB/OES.
- GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R - GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R
- GL_COLOR_MATERIAL - GL_COLOR_MATERIAL
- GL_FOG - GL_FOG

View file

@ -155,7 +155,11 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
// check status // check status
GLenum status; GLenum status;
#ifdef USE_OPENGLES
status = (GLenum) nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
#else
status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
#endif
switch(status) { switch(status) {
case GL_FRAMEBUFFER_COMPLETE_EXT: case GL_FRAMEBUFFER_COMPLETE_EXT:
InitFBO = true; InitFBO = true;
@ -204,12 +208,24 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
// clean up resources if allocation failed // clean up resources if allocation failed
if (!InitFBO) if (!InitFBO)
{ {
#ifdef USE_OPENGLES
nglDeleteFramebuffersOES(1, &FBOId);
#else
nglDeleteFramebuffersEXT(1, &FBOId); nglDeleteFramebuffersEXT(1, &FBOId);
#endif
if (AttachDepthStencil) if (AttachDepthStencil)
{ {
#ifdef USE_OPENGLES
nglDeleteRenderbuffersOES(1, &DepthFBOId);
#else
nglDeleteRenderbuffersEXT(1, &DepthFBOId); nglDeleteRenderbuffersEXT(1, &DepthFBOId);
#endif
if(!UsePackedDepthStencil) if(!UsePackedDepthStencil)
#ifdef USE_OPENGLES
nglDeleteRenderbuffersOES(1, &StencilFBOId);
#else
nglDeleteRenderbuffersEXT(1, &StencilFBOId); nglDeleteRenderbuffersEXT(1, &StencilFBOId);
#endif
} }
} }
@ -226,14 +242,22 @@ bool CTextureDrvInfosGL::activeFrameBufferObject(ITexture * tex)
if(initFrameBufferObject(tex)) if(initFrameBufferObject(tex))
{ {
glBindTexture(TextureMode, 0); glBindTexture(TextureMode, 0);
#ifdef USE_OPENGLES
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, FBOId);
#else
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId); nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId);
#endif
} }
else else
return false; return false;
} }
else else
{ {
#ifdef USE_OPENGLES
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
#else
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
#endif
} }
return true; return true;
@ -840,8 +864,13 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
sint size= tex.getPixels(i).size(); sint size= tex.getPixels(i).size();
if (bUpload) if (bUpload)
{ {
#ifdef USE_OPENGLES
glCompressedTexImage2D (GL_TEXTURE_2D, i-decalMipMapResize, glfmt,
tex.getWidth(i),tex.getHeight(i), 0, size, ptr);
#else
nglCompressedTexImage2DARB (GL_TEXTURE_2D, i-decalMipMapResize, glfmt, nglCompressedTexImage2DARB (GL_TEXTURE_2D, i-decalMipMapResize, glfmt,
tex.getWidth(i),tex.getHeight(i), 0, size, ptr); tex.getWidth(i),tex.getHeight(i), 0, size, ptr);
#endif
bAllUploaded = true; bAllUploaded = true;
} }
else else

View file

@ -280,8 +280,12 @@ bool CDriverGL::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines)
} }
else else
{ {
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
nlassert(_LastIB._Format == CIndexBuffer::Indices32); nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_LINES,2*nlines,GL_UNSIGNED_INT,((uint32 *) _LastIB._Values)+firstIndex); glDrawElements(GL_LINES,2*nlines,GL_UNSIGNED_INT,((uint32 *) _LastIB._Values)+firstIndex);
#endif
} }
} }
} }
@ -336,8 +340,12 @@ bool CDriverGL::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris)
} }
else else
{ {
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
nlassert(_LastIB._Format == CIndexBuffer::Indices32); nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstIndex); glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstIndex);
#endif
} }
} }
} }
@ -380,8 +388,12 @@ bool CDriverGL::renderSimpleTriangles(uint32 firstTri, uint32 ntris)
} }
else else
{ {
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
nlassert(_LastIB._Format == CIndexBuffer::Indices32); nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstTri); glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstTri);
#endif
} }
// Profiling. // Profiling.
@ -608,6 +620,9 @@ bool CDriverGL::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQuad
} }
else else
{ {
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
// indices fits on 32 bits // indices fits on 32 bits
GLint indices[QUAD_BATCH_SIZE]; GLint indices[QUAD_BATCH_SIZE];
GLint *curr = indices; GLint *curr = indices;
@ -625,6 +640,7 @@ bool CDriverGL::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQuad
} }
while(curr != end); while(curr != end);
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices); glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices);
#endif
} }
numLeftQuads -= numQuadsToDraw; numLeftQuads -= numQuadsToDraw;
currIndex += 4 * numQuadsToDraw; currIndex += 4 * numQuadsToDraw;
@ -665,10 +681,12 @@ void CDriverGL::setupUVPtr(uint stage, CVertexBufferInfo &VB, uint uvId)
// Setup ATI VBHard or std ptr. // Setup ATI VBHard or std ptr.
switch(VB.VBMode) switch(VB.VBMode)
{ {
#ifndef USE_OPENGLES
case CVertexBufferInfo::HwATI: case CVertexBufferInfo::HwATI:
nglArrayObjectATI(GL_TEXTURE_COORD_ARRAY, numTexCoord, GL_FLOAT, VB.VertexSize, VB.VertexObjectId, nglArrayObjectATI(GL_TEXTURE_COORD_ARRAY, numTexCoord, GL_FLOAT, VB.VertexSize, VB.VertexObjectId,
(ptrdiff_t) VB.ValuePtr[CVertexBuffer::TexCoord0+uvId]); (ptrdiff_t) VB.ValuePtr[CVertexBuffer::TexCoord0+uvId]);
break; break;
#endif
case CVertexBufferInfo::HwARB: case CVertexBufferInfo::HwARB:
_DriverGLStates.bindARBVertexBuffer(VB.VertexObjectId); _DriverGLStates.bindARBVertexBuffer(VB.VertexObjectId);
// with arb buffers, position is relative to the start of the stream // with arb buffers, position is relative to the start of the stream
@ -811,6 +829,21 @@ const uint CDriverGL::NumCoordinatesType[CVertexBuffer::NumType]=
// *************************************************************************** // ***************************************************************************
const uint CDriverGL::GLType[CVertexBuffer::NumType]= const uint CDriverGL::GLType[CVertexBuffer::NumType]=
{ {
#ifdef USE_OPENGLES
GL_FLOAT, // Double1
GL_FLOAT, // Float1
GL_SHORT, // Short1
GL_FLOAT, // Double2
GL_FLOAT, // Float2
GL_SHORT, // Short2
GL_FLOAT, // Double3
GL_FLOAT, // Float3
GL_SHORT, // Short3
GL_FLOAT, // Double4
GL_FLOAT, // Float4
GL_SHORT, // Short4
GL_UNSIGNED_BYTE // UChar4
#else
GL_DOUBLE, // Double1 GL_DOUBLE, // Double1
GL_FLOAT, // Float1 GL_FLOAT, // Float1
GL_SHORT, // Short1 GL_SHORT, // Short1
@ -824,6 +857,7 @@ const uint CDriverGL::GLType[CVertexBuffer::NumType]=
GL_FLOAT, // Float4 GL_FLOAT, // Float4
GL_SHORT, // Short4 GL_SHORT, // Short4
GL_UNSIGNED_BYTE // UChar4 GL_UNSIGNED_BYTE // UChar4
#endif
}; };
// *************************************************************************** // ***************************************************************************
@ -926,6 +960,7 @@ void CDriverGL::setupGlArraysStd(CVertexBufferInfo &vb)
} }
} }
break; break;
#ifndef USE_OPENGLES
case CVertexBufferInfo::HwATI: case CVertexBufferInfo::HwATI:
{ {
// setup vertex ptr. // setup vertex ptr.
@ -963,9 +998,12 @@ void CDriverGL::setupGlArraysStd(CVertexBufferInfo &vb)
nglArrayObjectATI(GL_COLOR_ARRAY, 4, GL_UNSIGNED_BYTE, vb.VertexSize, vb.VertexObjectId, (ptrdiff_t) vb.ValuePtr[CVertexBuffer::PrimaryColor]); nglArrayObjectATI(GL_COLOR_ARRAY, 4, GL_UNSIGNED_BYTE, vb.VertexSize, vb.VertexObjectId, (ptrdiff_t) vb.ValuePtr[CVertexBuffer::PrimaryColor]);
} }
else else
{
_DriverGLStates.enableColorArray(false); _DriverGLStates.enableColorArray(false);
}
} }
break; break;
#endif
default: default:
nlassert(0); nlassert(0);
break; break;
@ -1035,7 +1073,9 @@ void CDriverGL::toggleGlArraysForARBVertexProgram()
// If last was a VertexProgram setup, and now it is a standard GL array setup. // If last was a VertexProgram setup, and now it is a standard GL array setup.
if( _LastSetupGLArrayVertexProgram && !isVertexProgramEnabled () ) if( _LastSetupGLArrayVertexProgram && !isVertexProgramEnabled () )
{ {
#ifndef USE_OPENGLES
if (_Extensions.ATITextureEnvCombine3) if (_Extensions.ATITextureEnvCombine3)
#endif
{ {
// fix for ATI : when switching from Vertex Program to fixed Pipe, must clean texture, otherwise texture may be disabled in next render // fix for ATI : when switching from Vertex Program to fixed Pipe, must clean texture, otherwise texture may be disabled in next render
// (seems to be a driver bug) // (seems to be a driver bug)
@ -1046,12 +1086,16 @@ void CDriverGL::toggleGlArraysForARBVertexProgram()
// activate the texture, or disable texturing if NULL. // activate the texture, or disable texturing if NULL.
activateTexture(stage, NULL); activateTexture(stage, NULL);
} }
#ifndef USE_OPENGLES
glBegin(GL_QUADS); glBegin(GL_QUADS);
glVertex4f(0.f, 0.f, 0.f, 1.f); glVertex4f(0.f, 0.f, 0.f, 1.f);
glVertex4f(0.f, 0.f, 0.f, 1.f); glVertex4f(0.f, 0.f, 0.f, 1.f);
glVertex4f(0.f, 0.f, 0.f, 1.f); glVertex4f(0.f, 0.f, 0.f, 1.f);
glVertex4f(0.f, 0.f, 0.f, 1.f); glVertex4f(0.f, 0.f, 0.f, 1.f);
glEnd(); glEnd();
#endif
for(uint stage=0 ; stage<inlGetNumTextStages() ; stage++) for(uint stage=0 ; stage<inlGetNumTextStages() ; stage++)
{ {
// activate the texture, or disable texturing if NULL. // activate the texture, or disable texturing if NULL.
@ -1185,7 +1229,9 @@ void CDriverGL::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
{ {
// Secondary color // Secondary color
_DriverGLStates.enableSecondaryColorArray(true); _DriverGLStates.enableSecondaryColorArray(true);
nglSecondaryColorPointerEXT(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[value]); #ifndef USE_OPENGLES
nglSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[value]);
#endif
} }
} }
else else
@ -1199,7 +1245,9 @@ void CDriverGL::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
// Active this value // Active this value
_DriverGLStates.enableVertexAttribArray(glIndex, true); _DriverGLStates.enableVertexAttribArray(glIndex, true);
#ifndef USE_OPENGLES
nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]); nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
#endif
} }
} }
// Else normal case, can't do anything for other values with UChar4.... // Else normal case, can't do anything for other values with UChar4....
@ -1207,7 +1255,9 @@ void CDriverGL::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
{ {
// Active this value // Active this value
_DriverGLStates.enableVertexAttribArray(glIndex, true); _DriverGLStates.enableVertexAttribArray(glIndex, true);
#ifndef USE_OPENGLES
nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]); nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
#endif
} }
} }
else else

View file

@ -69,7 +69,7 @@ IVertexBufferHardGL::~IVertexBufferHardGL()
H_AUTO_OGL(IVertexBufferHardGL_IVertexBufferHardGLDtor) H_AUTO_OGL(IVertexBufferHardGL_IVertexBufferHardGLDtor)
} }
#ifndef USE_OPENGLES
// *************************************************************************** // ***************************************************************************
// *************************************************************************** // ***************************************************************************
@ -1133,7 +1133,7 @@ void CVertexArrayRangeMapObjectATI::updateLostBuffers()
} }
#endif #endif
#endif // USE_OPENGLES
// *************************************************************************** // ***************************************************************************
@ -1210,19 +1210,37 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
// create a ARB VBHard // create a ARB VBHard
GLuint vertexBufferID; GLuint vertexBufferID;
glGetError(); glGetError();
#ifdef USE_OPENGLES
glGenBuffers(1, &vertexBufferID);
#else
nglGenBuffersARB(1, &vertexBufferID); nglGenBuffersARB(1, &vertexBufferID);
#endif
if (glGetError() != GL_NO_ERROR) return false; if (glGetError() != GL_NO_ERROR) return false;
_Driver->_DriverGLStates.forceBindARBVertexBuffer(vertexBufferID); _Driver->_DriverGLStates.forceBindARBVertexBuffer(vertexBufferID);
switch(_VBType) switch(_VBType)
{ {
case CVertexBuffer::AGPPreferred: case CVertexBuffer::AGPPreferred:
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
#endif
break; break;
case CVertexBuffer::StaticPreferred: case CVertexBuffer::StaticPreferred:
if (_Driver->getStaticMemoryToVRAM()) if (_Driver->getStaticMemoryToVRAM())
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB);
#endif
else else
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
#endif
break; break;
default: default:
nlassert(0); nlassert(0);
@ -1230,7 +1248,12 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
} }
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
#ifdef USE_OPENGLES
glDeleteBuffers(1, &vertexBufferID);
#else
nglDeleteBuffersARB(1, &vertexBufferID); nglDeleteBuffersARB(1, &vertexBufferID);
#endif
return false; return false;
} }
CVertexBufferHardARB *newVbHard= new CVertexBufferHardARB(_Driver, vb); CVertexBufferHardARB *newVbHard= new CVertexBufferHardARB(_Driver, vb);
@ -1272,8 +1295,13 @@ void CVertexArrayRangeARB::updateLostBuffers()
{ {
nlassert((*it)->_VertexObjectId); nlassert((*it)->_VertexObjectId);
GLuint id = (GLuint) (*it)->_VertexObjectId; GLuint id = (GLuint) (*it)->_VertexObjectId;
#ifdef USE_OPENGLES
nlassert(glIsBuffer(id));
glDeleteBuffers(1, &id);
#else
nlassert(nglIsBufferARB(id)); nlassert(nglIsBufferARB(id));
nglDeleteBuffersARB(1, &id); nglDeleteBuffersARB(1, &id);
#endif
(*it)->_VertexObjectId = 0; (*it)->_VertexObjectId = 0;
(*it)->VB->setLocation(CVertexBuffer::NotResident); (*it)->VB->setLocation(CVertexBuffer::NotResident);
} }
@ -1300,6 +1328,12 @@ CVertexBufferHardARB::CVertexBufferHardARB(CDriverGL *drv, CVertexBuffer *vb) :
#ifdef NL_DEBUG #ifdef NL_DEBUG
_Unmapping = false; _Unmapping = false;
#endif #endif
#ifdef USE_OPENGLES
_Buffer = NULL;
_BufferSize = 0;
_LastBufferSize = 0;
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -1316,8 +1350,13 @@ CVertexBufferHardARB::~CVertexBufferHardARB()
if (_VertexObjectId) if (_VertexObjectId)
{ {
GLuint id = (GLuint) _VertexObjectId; GLuint id = (GLuint) _VertexObjectId;
#ifdef USE_OPENGLES
nlassert(glIsBuffer(id));
glDeleteBuffers(1, &id);
#else
nlassert(nglIsBufferARB(id)); nlassert(nglIsBufferARB(id));
nglDeleteBuffersARB(1, &id); nglDeleteBuffersARB(1, &id);
#endif
} }
if (_VertexArrayRange) if (_VertexArrayRange)
{ {
@ -1336,12 +1375,21 @@ CVertexBufferHardARB::~CVertexBufferHardARB()
_VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList); _VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList);
} }
#endif #endif
#ifdef USE_OPENGLES
if (_Buffer)
{
delete [] _Buffer;
_Buffer = NULL;
}
#endif
} }
// *************************************************************************** // ***************************************************************************
void *CVertexBufferHardARB::lock() void *CVertexBufferHardARB::lock()
{ {
H_AUTO_OGL(CVertexBufferHardARB_lock) H_AUTO_OGL(CVertexBufferHardARB_lock);
if (_VertexPtr) return _VertexPtr; // already locked if (_VertexPtr) return _VertexPtr; // already locked
if (_Invalid) if (_Invalid)
{ {
@ -1352,7 +1400,13 @@ void *CVertexBufferHardARB::lock()
} }
// recreate a vb // recreate a vb
GLuint vertexBufferID; GLuint vertexBufferID;
#ifdef USE_OPENGLES
glGenBuffers(1, &vertexBufferID);
#else
nglGenBuffersARB(1, &vertexBufferID); nglGenBuffersARB(1, &vertexBufferID);
#endif
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
_Driver->incrementResetCounter(); _Driver->incrementResetCounter();
@ -1363,13 +1417,25 @@ void *CVertexBufferHardARB::lock()
switch(_MemType) switch(_MemType)
{ {
case CVertexBuffer::AGPPreferred: case CVertexBuffer::AGPPreferred:
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
#endif
break; break;
case CVertexBuffer::StaticPreferred: case CVertexBuffer::StaticPreferred:
if (_Driver->getStaticMemoryToVRAM()) if (_Driver->getStaticMemoryToVRAM())
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB);
#endif
else else
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
#endif
break; break;
default: default:
nlassert(0); nlassert(0);
@ -1378,7 +1444,11 @@ void *CVertexBufferHardARB::lock()
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
_Driver->incrementResetCounter(); _Driver->incrementResetCounter();
#ifdef USE_OPENGLES
glDeleteBuffers(1, &vertexBufferID);
#else
nglDeleteBuffersARB(1, &vertexBufferID); nglDeleteBuffersARB(1, &vertexBufferID);
#endif
return &_DummyVB[0];; return &_DummyVB[0];;
} }
_VertexObjectId = vertexBufferID; _VertexObjectId = vertexBufferID;
@ -1394,6 +1464,39 @@ void *CVertexBufferHardARB::lock()
beforeLock= CTime::getPerformanceTime(); beforeLock= CTime::getPerformanceTime();
} }
_Driver->_DriverGLStates.bindARBVertexBuffer(_VertexObjectId); _Driver->_DriverGLStates.bindARBVertexBuffer(_VertexObjectId);
#ifdef USE_OPENGLES
if (_Driver->_Extensions.OESMapBuffer)
{
_VertexPtr = nglMapBufferOES(GL_ARRAY_BUFFER, GL_WRITE_ONLY_OES);
if (!_VertexPtr)
{
nglUnmapBufferOES(GL_ARRAY_BUFFER);
nlassert(glIsBuffer(_VertexObjectId));
invalidate();
return &_DummyVB[0];
}
}
else
{
const uint size = VB->getNumVertices() * VB->getVertexSize();
if (size > _BufferSize)
{
if (_Buffer) delete [] _Buffer;
_Buffer = new uint8[size+3];
_BufferSize = size;
}
uint8 offset = (size_t)_Buffer % 4;
if (offset > 0) offset = 4 - offset;
_VertexPtr = _Buffer + offset;
_LastBufferSize = size;
}
#else
_VertexPtr = nglMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); _VertexPtr = nglMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
if (!_VertexPtr) if (!_VertexPtr)
{ {
@ -1402,6 +1505,8 @@ void *CVertexBufferHardARB::lock()
invalidate(); invalidate();
return &_DummyVB[0]; return &_DummyVB[0];
} }
#endif
#ifdef NL_DEBUG #ifdef NL_DEBUG
_VertexArrayRange->_MappedVBList.push_front(this); _VertexArrayRange->_MappedVBList.push_front(this);
_IteratorInMappedVBList = _VertexArrayRange->_MappedVBList.begin(); _IteratorInMappedVBList = _VertexArrayRange->_MappedVBList.begin();
@ -1420,7 +1525,8 @@ void *CVertexBufferHardARB::lock()
// *************************************************************************** // ***************************************************************************
void CVertexBufferHardARB::unlock() void CVertexBufferHardARB::unlock()
{ {
H_AUTO_OGL(CVertexBufferHardARB_unlock) H_AUTO_OGL(CVertexBufferHardARB_unlock);
_VertexPtr = NULL; _VertexPtr = NULL;
if (_Invalid) return; if (_Invalid) return;
if (!_VertexObjectId) return; if (!_VertexObjectId) return;
@ -1434,7 +1540,17 @@ void CVertexBufferHardARB::unlock()
#ifdef NL_DEBUG #ifdef NL_DEBUG
_Unmapping = true; _Unmapping = true;
#endif #endif
GLboolean unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB); GLboolean unmapOk = false;
#ifdef USE_OPENGLES
if (_Driver->_Extensions.OESMapBuffer)
{
unmapOk = nglUnmapBufferOES(GL_ARRAY_BUFFER);
}
#else
unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
#endif
#ifdef NL_DEBUG #ifdef NL_DEBUG
_Unmapping = false; _Unmapping = false;
#endif #endif

View file

@ -2376,11 +2376,15 @@ void CDriverGL::getWindowSize(uint32 &width, uint32 &height)
if (_CurrentMode.OffScreen) if (_CurrentMode.OffScreen)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
#ifndef USE_OPENGLES
if (_PBuffer) if (_PBuffer)
{ {
nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width ); nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width );
nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height ); nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height );
} }
#endif
#endif #endif
} }
else else

View file

@ -109,7 +109,7 @@ CRGBA CFastHLSModifier::convert(uint H, uint L, uint S)
return col; return col;
} }
#if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) #if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# pragma warning( push ) # pragma warning( push )
# pragma warning( disable : 4799 ) # pragma warning( disable : 4799 )
#endif #endif
@ -262,7 +262,7 @@ uint16 CFastHLSModifier::applyHLSMod(uint16 colorIn, uint8 dHue, uint dLum, uin
#pragma managed(pop) #pragma managed(pop)
#endif #endif
#if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) #if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# pragma warning( pop ) # pragma warning( pop )
#endif #endif

View file

@ -233,6 +233,7 @@ const CType* CFormElm::getType ()
warning (false, "getType", "This node is not an atom."); warning (false, "getType", "This node is not an atom.");
return 0; return 0;
} }
// *************************************************************************** // ***************************************************************************
bool CFormElm::getValue (string &/* result */, TEval /* evaluate */) const bool CFormElm::getValue (string &/* result */, TEval /* evaluate */) const

View file

@ -187,6 +187,77 @@ CHashKey getSHA1(const string &filename, bool forcePath)
return hk; return hk;
} }
/*
*
* HMAC = hash( (Key ^ 0x5c) .. hash( (Key ^0x36) .. Message ) )
*
*/
CHashKey getHMacSHA1(const uint8 *text, uint32 text_len, const uint8 *key, uint32 key_len)
{
SHA1Context sha;
uint8_t SHA1_Key[64];
uint8_t SHA1_Key1[20];
uint8_t SHA1_Key2[20];
string buffer1;
string buffer2;
// Init some vars
for (uint i = 0; i < 64; i++)
SHA1_Key[i] = 0;
// If lenght of key > 64 use sha1 hash
if (key_len > 64) {
uint8_t SHA1_Key0[20];
SHA1Reset(&sha);
SHA1Input(&sha, (const uint8_t*)key, key_len);
SHA1Result(&sha, SHA1_Key0);
CHashKey hk0 (SHA1_Key0);
for (uint i = 0; i < 20; i++)
SHA1_Key[i] = hk0.HashKeyString[i];
} else {
for (uint i = 0; i < key_len; i++)
SHA1_Key[i] = key[i];
}
// Do 0x36 XOR Key
for (uint i = 0; i < 64; i++)
buffer1 += 0x36 ^ SHA1_Key[i];
// Append text
for (uint i = 0; i < text_len; i++)
buffer1 += text[i];
// Get hash
SHA1Reset(&sha);
SHA1Input(&sha, (const uint8_t*)buffer1.c_str(), (uint)buffer1.size());
SHA1Result(&sha, SHA1_Key1);
CHashKey hk1 (SHA1_Key1);
// Do 0x5c XOR Key
for (uint i = 0; i < 64; i++)
buffer2 += 0x5c ^ SHA1_Key[i];
// Append previous hash
for (uint i = 0; i < 20; i++)
buffer2 += hk1.HashKeyString[i];
// Get new hash
SHA1Reset(&sha);
SHA1Input(&sha, (const uint8_t*)buffer2.c_str(), (uint)buffer2.size());
SHA1Result(&sha, SHA1_Key2);
CHashKey hk (SHA1_Key2);
return hk;
}
#ifdef _MFC_VER
#pragma runtime_checks( "", off )
#endif
/* /*
* Define the SHA1 circular left shift macro * Define the SHA1 circular left shift macro
*/ */

View file

@ -36,8 +36,8 @@ namespace NLMISC {
// Storage for file handles, necessary to close the handles // Storage for file handles, necessary to close the handles
map<void*,HANDLE> AccessAddressesToHandles; map<void*,HANDLE> AccessAddressesToHandles;
#else #else
// Storage for shmid, necessary to destroy the segments // Storage for shmid, necessary to destroy the segments
map<TSharedMemId, int> SharedMemIdsToShmids; map<TSharedMemId, sint> SharedMemIdsToShmids;
#endif #endif
@ -71,7 +71,7 @@ void *CSharedMemory::createSharedMemory( TSharedMemId sharedMemId, uint32 size
#else #else
// Create a shared memory segment // Create a shared memory segment
int shmid = shmget( sharedMemId, size, IPC_CREAT | IPC_EXCL | 0666 ); sint shmid = shmget( sharedMemId, size, IPC_CREAT | IPC_EXCL | 0666 );
if ( shmid == -1 ) if ( shmid == -1 )
return NULL; return NULL;
SharedMemIdsToShmids.insert( make_pair( sharedMemId, shmid ) ); SharedMemIdsToShmids.insert( make_pair( sharedMemId, shmid ) );
@ -82,6 +82,7 @@ void *CSharedMemory::createSharedMemory( TSharedMemId sharedMemId, uint32 size
return NULL; return NULL;
else else
return accessAddress; return accessAddress;
#endif #endif
} }

View file

@ -22,10 +22,8 @@
#include "nel/misc/hierarchical_timer.h" #include "nel/misc/hierarchical_timer.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# if defined(NL_COMP_VC7) || defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9)
# include <winsock2.h>
# endif
# define NOMINMAX # define NOMINMAX
# include <winsock2.h>
# include <windows.h> # include <windows.h>
# define socklen_t int # define socklen_t int
# define ERROR_NUM WSAGetLastError() # define ERROR_NUM WSAGetLastError()

View file

@ -20,9 +20,7 @@
#include "nel/net/net_log.h" #include "nel/net/net_log.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# if defined(NL_COMP_VC7) || defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # include <winsock2.h>
# include <winsock2.h>
# endif
# define NOMINMAX # define NOMINMAX
# include <windows.h> # include <windows.h>
# define socklen_t int # define socklen_t int

View file

@ -8,6 +8,10 @@
# This tells the application(s) where to fidn the installed data. # This tells the application(s) where to fidn the installed data.
ADD_DEFINITIONS(-DDATA_DIR="\\"${NL_SHARE_PREFIX}/object_viewer_qt/\\"") ADD_DEFINITIONS(-DDATA_DIR="\\"${NL_SHARE_PREFIX}/object_viewer_qt/\\"")
IF(UNIX AND WITH_STATIC)
MESSAGE(FATAL_ERROR "OVQT does not work with static NeL builds on Unix atm.")
ENDIF()
ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(src)
INSTALL(DIRECTORY data/ INSTALL(DIRECTORY data/

View file

@ -31,7 +31,7 @@ PROJECT_NAME = "Object Viewer Qt"
# This could be handy for archiving the generated documentation or # This could be handy for archiving the generated documentation or
# if some version control system is used. # if some version control system is used.
PROJECT_NUMBER = r90 PROJECT_NUMBER =
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put. # base path where the generated documentation will be put.
@ -643,7 +643,7 @@ FILE_PATTERNS = *.c \
# should be searched for input files as well. Possible values are YES and NO. # should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used. # If left blank NO is used.
RECURSIVE = NO RECURSIVE = YES
# The EXCLUDE tag can be used to specify files and/or directories that should # The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a # excluded from the INPUT source files. This way you can easily exclude a

View file

@ -1,6 +1,6 @@
/** /**
@mainpage Object Viewer Qt @mainpage Object Viewer Qt
@author Dzmitry Kamiahin <dnk-88@tut.by>, (C) 2010 @author Dzmitry Kamiahin <dnk-88@tut.by>, (C) 2011
@section introduce Introduce @section introduce Introduce
@details @details
@ -15,130 +15,22 @@ The tool can be used in different tasks:
- Create and modify micro-vegetation material (.vegetset files) - Create and modify micro-vegetation material (.vegetset files)
- Viewing landscape (.zonel files) - Viewing landscape (.zonel files)
- Dialog allows to specify graphical, sound, search path and landscape settings. - Dialog allows to specify graphical, sound, search path and landscape settings.
- OVQT supports loading third-party plug-ins.
@section project_structure Overview of the Object Viewer Qt Project Structure
@details
OVQT - consists of several major subsystems. Each subsystem performs its defined part of the task.
Through Modules:: provides access to all other program subsystems.
Program has the following subsystems:
- @ref Modules - Main modules aggregated all parts of the program.
- @ref NLQT::CConfiguration - is responsible for loading and saving settings from the configuration file. As well as search path of data.
- @ref NLQT::CObjectViewer - main subsystem of the program, which initializes the driver, creates a scene and other supporting elements.
It is a container for loaded models, which can further be viewed and animated.
- @ref NLQT::CMainWindow - is responsible for the GUI.
- @ref NLQT::CParticleEditor - is responsible for the particle systems and provides access to a container that keeps all the loaded particle systems.
And also allows you to view an animation of particle systems, with the ability to control its parameters.
- @ref NLQT::CVegetableEditor - is responsible for the landscape zones and the editor of vegetation.
Allows you to load and view the landscape. Also has the ability to create and edit the parameters of the micro-vegetation.
- @ref NLQT::CSoundSystem - is responsible for the sound in the program.
<b>
The structure of the GUI in the editor of the particles.
</b><br>
This can be useful for new developers who want to add more new dialogs or to improve the functionality of existing dialogues.
<img src="gui_struct.png" alt="Particle Workspace">
ParticleWorkspace dialogue uses the technique of model-view.
Using the signal/slot link QTreeView with QStackWidget, Editor properties dialog.
When you select an item in QTreeView, QStackWidget displays the necessary page(PageWidget) where you can edit the element of the particles system.
Each page is made in the designer and has a separate forms(.ui).
In accordance with the recommendations of dialogues design, with a large number of items,every page uses QTabWidget.
In case when there is a great number of controls, and not everything you want to display,
it's used the dynamic creation of tabs. Moreover, each tab uses a separate forms(.ui).
@section for_new_developer Guide for new developers of the Object Viewer Qt.
@details
First of all, to begin developing dialogues that add new features ovqt,
it is needed to read the documentation Qt libs (http://doc.qt.nokia.com/) and NeL documentation.
In order to have convenient using of the tool and its further development,
it is expected to make a unified interface that is why all dialogs should adhere to a standard design,
which will be written further. For this goals program provides some additional widgets,
which are recommended to use. As in the development Qt Designer is actively used.
To get access to founded here widgets from the designer,the technique promotion is used,
which can be found <a href="http://doc.qt.nokia.com/4.5/designer-using-custom-widgets.html"> here </a>.
<ol>
<li><b>
CEditRangeUIntWidget / CEditRangeIntWidget / CEditRangeFloatWidget
</b><br>
Widgets provides a slider that allows you to specify an integer (or float, depending on which widget used) number within a set range.
The range is also can be set by the user, or for a more accurate selection of numbers, either for receiving large values.
As there may be situations when the range that a user requests,has to be restricted, and widget provides methods that allow you to do so.
<br><br>
<img src="cedit_range_int_widget.png" alt="CEditRangeIntWidget">
<br>
<img src="cedit_range_float_widget.png" alt="CEditRangeFloatWidget">
@see
@ref NLQT::CEditRangeUIntWidget, @ref NLQT::CEditRangeIntWidget, @ref NLQT::CEditRangeFloatWidget
<li><b>
CColorEditWidget
</b><br>
Using this widget you can set the color(RGBA) using the four sliders or through the color selection dialog.
<br><br>
<img src="cedit_color_widget.png" alt="CColorEditWidget">
@see
@ref NLQT::CColorEditWidget
<li><b>
CDirectionWidget
</b><br>
This widget helps to choose from several preset directions, or to choose a custom one.
<br><br>
<img src="cdirection_widget.png" alt="CDirectionWidget">
@see
@ref NLQT::CDirectionWidget
</ol><br><br>
To further convinience of instrument using dialogues interface is recommended to make as follows.
The most sophisticated tools of the program, should take the form of three dock windows (example shown in the screenshot).
<img src="object_viewer_qt_window.png" alt="Object Viewer Qt">
<ol>
<li>
The first dock window - is a control dock window, it should focus all of the control functions of general purpose
(for example: start/stop/pause animations or particles system).
It is recommended to perform of the horizontal type window and placed in the bottom of the main window.
<li>
The second dock window - is a list or a tree of items. In which selecting of the current element,
which assumes to modify or viewis possible.Operations "add/remove/insert or other" items are recommended to make as a popur menu.
It is recommended to perform of the vertical type window and placed in the left of the main window.
<li>
The third dock - is an editor for properties of the element that was selected in the list or in the tree of elements.
As all the controls occupy much space or do not fit at all, you have to use tabs QTabWidget,
which in total can contains quite a lot of elements.
For a small number of tabs it is allowed to use both horizontal and vertical location.
But with a large number of tabs, it is necessary to apply the vertical arrangement.
It is recommended to perform of the vertical type of window and placed in the right of the main window.
</ol>
In the simple dialogues do not necessary to use all three windows, but user has to adhere to the recommendations given above as well.
Also, <b>all dialogs must use the qt layout manager</b>. And if you do not use the designer,
make sure you use the qt tools internationalization applications.
<br><br>
In ovqt for most dialogs their owner is NLQT::CMainWindow and in its methods creating and initializing all dependent dialogs occur.
For the convenience of the program using, most dialogues are created in the form of docking windows.
Creating all the dialogues are carried out in a private method NLQT::CMainWindow::createDialogs().
Hence, it is necessary to add operations in this method to create new dialogues.
But we must take into account that at this moment is fully available only one component of the program CConfiguration,
to read the settings from the configuration file. The remaining components of the program are available only after the main window stays visible.
Calling the dialogues going through the menu or the toolbar, usually it is a checkable item.
Adding of the new menu items or items toolbars is need in methods NLQT::CMainWindow::createMenus(), NLQT::CMainWindow::createToolBars().
@section license_ovqt License Object Viewer Qt @section license_ovqt License Object Viewer Qt
@details @details
Object Viewer Qt Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom>
<br> <br>
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by> 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.
<br><br> <br><br>
This program is free software: you can redistribute it and/or modify This program is distributed in the hope that it will be useful,
it under the terms of the GNU General Public License as published by but WITHOUT ANY WARRANTY; without even the implied warranty of
the Free Software Foundation, either version 3 of the License, or MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(at your option) any later version. GNU Affero General Public License for more details.
<br><br> <br><br>
This program is distributed in the hope that it will be useful, You should have received a copy of the GNU Affero General Public License
but WITHOUT ANY WARRANTY; without even the implied warranty of along with this program. If not, see <http://www.gnu.org/licenses/>.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
<br><br>
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */

View file

@ -40,7 +40,6 @@ class IPluginSpec;
class IPluginManager: public QObject class IPluginManager: public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
IPluginManager(QObject *parent = 0): QObject(parent) {} IPluginManager(QObject *parent = 0): QObject(parent) {}
virtual ~IPluginManager() {} virtual ~IPluginManager() {}

View file

@ -292,4 +292,4 @@ void CPluginManager::deleteAll()
} }
} }
}; // namespace NLQT }; // namespace ExtensionSystem

View file

@ -74,6 +74,6 @@ private:
}; // class CPluginManager }; // class CPluginManager
} // namespace NLQT } // namespace ExtensionSystem
#endif // PLUGINMANAGER_H #endif // PLUGINMANAGER_H

View file

@ -266,4 +266,4 @@ bool CPluginSpec::reportError(const QString &err)
return false; return false;
} }
} // namespace NLQT } // namespace ExtensionSystem

View file

@ -79,7 +79,7 @@ private:
friend class CPluginManager; friend class CPluginManager;
}; };
} // namespace NLQT } // namespace ExtensionSystem
#endif // PLUGINSPEC_H #endif // PLUGINSPEC_H

View file

@ -38,6 +38,8 @@
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtGui/QSplashScreen> #include <QtGui/QSplashScreen>
#include <QtGui/QFileDialog>
#include <QtGui/QInputDialog>
static const char *appNameC = "ObjectViewerQt"; static const char *appNameC = "ObjectViewerQt";
@ -135,7 +137,7 @@ sint main(int argc, char **argv)
QTranslator qtTranslator; QTranslator qtTranslator;
QString locale = settings->value("Language", QLocale::system().name()).toString(); QString locale = settings->value("Language", QLocale::system().name()).toString();
QString qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); QString qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
translator.load("object_viewer_qt_" + locale, ":/"); // translator.load("object_viewer_qt_" + locale, ":/");
qtTranslator.load("qt_" + locale, qtTrPath); qtTranslator.load("qt_" + locale, qtTrPath);
app.installTranslator(&translator); app.installTranslator(&translator);
app.installTranslator(&qtTranslator); app.installTranslator(&qtTranslator);
@ -149,9 +151,9 @@ sint main(int argc, char **argv)
pluginManager.setSettings(settings); pluginManager.setSettings(settings);
QStringList pluginPaths; QStringList pluginPaths;
#if !defined(NL_OS_MAC) #if !defined(NL_OS_MAC)
pluginPaths << QString("./plugins"); pluginPaths << settings->value("PluginPath", "./plugins").toString();
#else #else
pluginPaths << qApp->applicationDirPath() + QString("/../PlugIns/ovqt"); pluginPaths << settings->value("PluginPath", qApp->applicationDirPath() + QString("/../PlugIns/ovqt")).toString();
#endif #endif
pluginManager.setPluginPaths(pluginPaths); pluginManager.setPluginPaths(pluginPaths);
@ -176,6 +178,15 @@ sint main(int argc, char **argv)
QString absolutePaths = absolutePluginPaths.absolutePath(); QString absolutePaths = absolutePluginPaths.absolutePath();
const QString reason = QCoreApplication::translate("Application", "Could not find ovqt_plugin_core in %1").arg(absolutePaths); const QString reason = QCoreApplication::translate("Application", "Could not find ovqt_plugin_core in %1").arg(absolutePaths);
displayError(msgCoreLoadFailure(reason)); displayError(msgCoreLoadFailure(reason));
QString newPath = QFileDialog::getExistingDirectory(0, QCoreApplication::translate("Application", "Change the plugins path"), QDir::homePath());
bool ok;
QString text = QInputDialog::getText(0, QCoreApplication::translate("Application", "Enter the plugins path"),
QCoreApplication::translate("Application", "Plugin path:"), QLineEdit::Normal,
newPath, &ok);
if (ok && !text.isEmpty())
settings->setValue("PluginPath", text);
settings->sync();
return 1; return 1;
} }
if (corePlugin->hasError()) if (corePlugin->hasError())

View file

@ -20,10 +20,12 @@ SET(OVQT_CORE_PLUGIN_HDR
menu_manager.h menu_manager.h
settings_dialog.h settings_dialog.h
search_paths_settings_page.h search_paths_settings_page.h
general_settings_page.h
plugin_view_dialog.h) plugin_view_dialog.h)
SET(OVQT_CORE_PLUGIN_UIS settings_dialog.ui SET(OVQT_CORE_PLUGIN_UIS settings_dialog.ui
plugin_view_dialog.ui plugin_view_dialog.ui
general_settings_page.ui
search_paths_settings_page.ui) search_paths_settings_page.ui)
SET(OVQT_CORE_PLUGIN_RCS core.qrc) SET(OVQT_CORE_PLUGIN_RCS core.qrc)

View file

@ -24,7 +24,7 @@ namespace Constants
{ {
const char * const OVQT_VERSION_LONG = "0.0.1"; const char * const OVQT_VERSION_LONG = "0.0.1";
const char * const OVQT_VENDOR = "Dzmitry Kamiahin"; const char * const OVQT_VENDOR = "Ryzom Core";
const char * const OVQT_YEAR = "2010, 2011"; const char * const OVQT_YEAR = "2010, 2011";
const char * const OVQT_CORE_PLUGIN = "Core"; const char * const OVQT_CORE_PLUGIN = "Core";
@ -32,7 +32,7 @@ const char * const OVQT_CORE_PLUGIN = "Core";
const char * const MAIN_WINDOW = "ObjectViewerQt.MainWindow"; const char * const MAIN_WINDOW = "ObjectViewerQt.MainWindow";
//menubar //menubar
const char * const MENU_BAR = "ObjectViewerQt.MenuBar"; const char * const MENU_BAR = "ObjectViewerQt.MenuBar";
//menus //menus
const char * const M_FILE = "ObjectViewerQt.Menu.File"; const char * const M_FILE = "ObjectViewerQt.Menu.File";
@ -54,21 +54,34 @@ const char * const SETTINGS = "ObjectViewerQt.Settings";
const char * const TOGGLE_FULLSCREEN = "ObjectViewerQt.ToggleFullScreen"; const char * const TOGGLE_FULLSCREEN = "ObjectViewerQt.ToggleFullScreen";
const char * const CLOSE = "ObjectViewerQt.Close"; const char * const CLOSE = "ObjectViewerQt.Close";
const char * const CLOSEALL = "ObjectViewerQt.CloseAll"; const char * const CLOSEALL = "ObjectViewerQt.CloseAll";
const char * const CLOSEOTHERS = "ObjectViewerQt.CloseOthers"; const char * const CLOSEOTHERS = "ObjectViewerQt.CloseOthers";
const char * const ABOUT = "ObjectViewerQt.About"; const char * const ABOUT = "ObjectViewerQt.About";
const char * const ABOUT_PLUGINS = "ObjectViewerQt.AboutPlugins"; const char * const ABOUT_PLUGINS = "ObjectViewerQt.AboutPlugins";
const char * const ABOUT_QT = "ObjectViewerQt.AboutQt"; const char * const ABOUT_QT = "ObjectViewerQt.AboutQt";
//settings //settings
const char * const SETTINGS_CATEGORY_GENERAL = "general";
const char * const SETTINGS_CATEGORY_GENERAL_ICON = ":/icons/ic_nel_generic_settings.png";
const char * const SETTINGS_TR_CATEGORY_GENERAL = QT_TR_NOOP("General");
const char * const MAIN_WINDOW_SECTION = "MainWindow";
const char * const MAIN_WINDOW_STATE = "WindowState";
const char * const MAIN_WINDOW_GEOMETRY = "WindowGeometry";
const char * const QT_STYLE = "QtStyle";
const char * const QT_PALETTE = "QtPalette";
const char * const LANGUAGE = "Language";
const char * const PLUGINS_PATH = "PluginPath";
const char * const DATA_PATH_SECTION = "DataPath"; const char * const DATA_PATH_SECTION = "DataPath";
const char * const SEARCH_PATHS = "SearchPaths"; const char * const SEARCH_PATHS = "SearchPaths";
const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes"; const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes";
const char * const LEVELDESIGN_PATH = "LevelDesignPath"; const char * const LEVELDESIGN_PATH = "LevelDesignPath";
const char * const ASSETS_PATH = "LevelDesignPath"; const char * const ASSETS_PATH = "AssetsPath";
const char * const REMAP_EXTENSIONS = "RemapExtensions";
//resources //resources
const char * const ICON_NEL = ":/core/images/nel.png"; const char * const ICON_NEL = ":/core/images/nel.png";
const char * const ICON_SETTINGS = ":/core/images/preferences.png"; const char * const ICON_SETTINGS = ":/core/images/preferences.png";
const char * const ICON_PILL = ":/core/icons/ic_nel_pill.png"; const char * const ICON_PILL = ":/core/icons/ic_nel_pill.png";
const char * const ICON_OPEN = ":/core/icons/ic_nel_open.png"; const char * const ICON_OPEN = ":/core/icons/ic_nel_open.png";

View file

@ -20,8 +20,8 @@
#include "settings_dialog.h" #include "settings_dialog.h"
#include "core_constants.h" #include "core_constants.h"
#include "search_paths_settings_page.h" #include "search_paths_settings_page.h"
#include "general_settings_page.h"
#include "../../extension_system/iplugin_spec.h" #include "../../extension_system/iplugin_spec.h"
#include "qtwin.h"
// NeL includes // NeL includes
#include "nel/misc/debug.h" #include "nel/misc/debug.h"
@ -42,37 +42,40 @@ CorePlugin::CorePlugin()
CorePlugin::~CorePlugin() CorePlugin::~CorePlugin()
{ {
Q_FOREACH(QObject *obj, _autoReleaseObjects) Q_FOREACH(QObject *obj, m_autoReleaseObjects)
{ {
_plugMan->removeObject(obj); m_plugMan->removeObject(obj);
} }
qDeleteAll(_autoReleaseObjects); qDeleteAll(m_autoReleaseObjects);
_autoReleaseObjects.clear(); m_autoReleaseObjects.clear();
delete _mainWindow; delete m_mainWindow;
} }
bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
{ {
Q_UNUSED(errorString); Q_UNUSED(errorString);
_plugMan = pluginManager; m_plugMan = pluginManager;
_mainWindow = new MainWindow(pluginManager); m_mainWindow = new MainWindow(pluginManager);
/*if (QtWin::isCompositionEnabled()) bool success = m_mainWindow->initialize(errorString);
{
QtWin::extendFrameIntoClientArea(_mainWindow); GeneralSettingsPage *generalSettings = new GeneralSettingsPage(this);
_mainWindow->setContentsMargins(0, 0, 0, 0); CSearchPathsSettingsPage *searchPathPage = new CSearchPathsSettingsPage(false, this);
}*/ CSearchPathsSettingsPage *recureseSearchPathPage = new CSearchPathsSettingsPage(true, this);
bool success = _mainWindow->initialize(errorString);
CSearchPathsSettingsPage *serchPathPage = new CSearchPathsSettingsPage(this); generalSettings->applyGeneralSettings();
serchPathPage->applySearchPaths(); searchPathPage->applySearchPaths();
addAutoReleasedObject(serchPathPage); recureseSearchPathPage->applySearchPaths();
addAutoReleasedObject(generalSettings);
addAutoReleasedObject(searchPathPage);
addAutoReleasedObject(recureseSearchPathPage);
return success; return success;
} }
void CorePlugin::extensionsInitialized() void CorePlugin::extensionsInitialized()
{ {
_mainWindow->extensionsInitialized(); m_mainWindow->extensionsInitialized();
} }
void CorePlugin::shutdown() void CorePlugin::shutdown()
@ -86,7 +89,7 @@ void CorePlugin::setNelContext(NLMISC::INelContext *nelContext)
// This only applies to platforms without PIC, e.g. Windows. // This only applies to platforms without PIC, e.g. Windows.
nlassert(!NLMISC::INelContext::isContextInitialised()); nlassert(!NLMISC::INelContext::isContextInitialised());
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
_LibContext = new NLMISC::CLibraryContext(*nelContext); m_libContext = new NLMISC::CLibraryContext(*nelContext);
} }
QString CorePlugin::name() const QString CorePlugin::name() const
@ -116,8 +119,8 @@ QStringList CorePlugin::dependencies() const
void CorePlugin::addAutoReleasedObject(QObject *obj) void CorePlugin::addAutoReleasedObject(QObject *obj)
{ {
_plugMan->addObject(obj); m_plugMan->addObject(obj);
_autoReleaseObjects.prepend(obj); m_autoReleaseObjects.prepend(obj);
} }
Q_EXPORT_PLUGIN(CorePlugin) Q_EXPORT_PLUGIN(CorePlugin)

View file

@ -63,16 +63,16 @@ public:
ExtensionSystem::IPluginManager *pluginManager() const ExtensionSystem::IPluginManager *pluginManager() const
{ {
return _plugMan; return m_plugMan;
} }
protected: protected:
NLMISC::CLibraryContext *_LibContext; NLMISC::CLibraryContext *m_libContext;
private: private:
ExtensionSystem::IPluginManager *_plugMan; ExtensionSystem::IPluginManager *m_plugMan;
MainWindow *_mainWindow; MainWindow *m_mainWindow;
QList<QObject *> _autoReleaseObjects; QList<QObject *> m_autoReleaseObjects;
}; };
} // namespace Core } // namespace Core

View file

@ -0,0 +1,187 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// 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/>.
// Project includes
#include "general_settings_page.h"
#include "core_constants.h"
#include "icore.h"
// NeL includes
#include <nel/misc/path.h>
// Qt includes
#include <QtCore/QSettings>
#include <QtGui/QWidget>
#include <QtGui/QMessageBox>
#include <QtGui/QFileDialog>
#include <QtGui/QStyleFactory>
#include <QtGui/QStyle>
namespace Core
{
GeneralSettingsPage::GeneralSettingsPage(QObject *parent)
: IOptionsPage(parent),
m_page(0)
{
m_originalPalette = QApplication::palette();
}
GeneralSettingsPage::~GeneralSettingsPage()
{
}
QString GeneralSettingsPage::id() const
{
return QLatin1String("general_settings");
}
QString GeneralSettingsPage::trName() const
{
return tr("General");
}
QString GeneralSettingsPage::category() const
{
return QLatin1String(Constants::SETTINGS_CATEGORY_GENERAL);
}
QString GeneralSettingsPage::trCategory() const
{
return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL);
}
void GeneralSettingsPage::applyGeneralSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::MAIN_WINDOW_SECTION);
QApplication::setStyle(QStyleFactory::create(settings->value(Constants::QT_STYLE, "").toString()));
if (settings->value(Constants::QT_PALETTE, true).toBool())
QApplication::setPalette(QApplication::style()->standardPalette());
else
QApplication::setPalette(m_originalPalette);
settings->endGroup();
}
QWidget *GeneralSettingsPage::createPage(QWidget *parent)
{
m_page = new QWidget(parent);
m_ui.setupUi(m_page);
readSettings();
connect(m_ui.languageComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeLanguage(QString)));
connect(m_ui.pluginsPathButton, SIGNAL(clicked()), this, SLOT(setPluginsPath()));
connect(m_ui.leveldesignPathButton, SIGNAL(clicked()), this, SLOT(setLevelDesignPath()));
connect(m_ui.assetsPathButton, SIGNAL(clicked()), this, SLOT(setAssetsPath()));
return m_page;
}
void GeneralSettingsPage::apply()
{
writeSettings();
applyGeneralSettings();
}
void GeneralSettingsPage::finish()
{
delete m_page;
m_page = 0;
}
void GeneralSettingsPage::changeLanguage(const QString &lang)
{
QMessageBox::information(0, tr("Restart required"),
tr("The language change will take effect after a restart of Object Viewer Qt."));
}
void GeneralSettingsPage::setPluginsPath()
{
QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the plugins path"),
m_ui.pluginsPathLineEdit->text());
if (!newPath.isEmpty())
{
m_ui.pluginsPathLineEdit->setText(newPath);
}
}
void GeneralSettingsPage::setLevelDesignPath()
{
QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the level design path"),
m_ui.leveldesignPathLineEdit->text());
if (!newPath.isEmpty())
{
m_ui.leveldesignPathLineEdit->setText(newPath);
}
}
void GeneralSettingsPage::setAssetsPath()
{
QString newPath = QFileDialog::getExistingDirectory(0, tr("Set the assets path"),
m_ui.assetsPathLineEdit->text());
if (!newPath.isEmpty())
{
m_ui.assetsPathLineEdit->setText(newPath);
}
}
void GeneralSettingsPage::readSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
m_ui.pluginsPathLineEdit->setText(settings->value(Core::Constants::PLUGINS_PATH, "./plugins").toString());
settings->beginGroup(Constants::MAIN_WINDOW_SECTION);
m_ui.styleComboBox->addItems(QStyleFactory::keys());
QString style = settings->value(Constants::QT_STYLE, "").toString();
if (style == "")
m_ui.styleComboBox->setCurrentIndex(0);
else
m_ui.styleComboBox->setCurrentIndex(m_ui.styleComboBox->findText(style));
m_ui.paletteCheckBox->setChecked(settings->value(Constants::QT_PALETTE, true).toBool());
settings->endGroup();
QStringList paths;
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
m_ui.leveldesignPathLineEdit->setText(settings->value(Core::Constants::LEVELDESIGN_PATH, "l:/leveldesign").toString());
m_ui.assetsPathLineEdit->setText(settings->value(Core::Constants::ASSETS_PATH, "w:/database").toString());
settings->endGroup();
}
void GeneralSettingsPage::writeSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->setValue(Core::Constants::PLUGINS_PATH, m_ui.pluginsPathLineEdit->text());
settings->beginGroup(Constants::MAIN_WINDOW_SECTION);
if (m_ui.styleComboBox->currentIndex() == 0)
settings->setValue(Constants::QT_STYLE, "");
else
settings->setValue(Constants::QT_STYLE, m_ui.styleComboBox->currentText());
settings->setValue(Constants::QT_PALETTE, m_ui.paletteCheckBox->isChecked());
settings->endGroup();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
settings->setValue(Core::Constants::LEVELDESIGN_PATH, m_ui.leveldesignPathLineEdit->text());
settings->setValue(Core::Constants::ASSETS_PATH, m_ui.assetsPathLineEdit->text());
settings->endGroup();
settings->sync();
}
} /* namespace Core */

View file

@ -0,0 +1,71 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef GENERAL_SETTINGS_PAGE_H
#define GENERAL_SETTINGS_PAGE_H
#include <QtCore/QObject>
#include "ioptions_page.h"
#include "ui_general_settings_page.h"
class QWidget;
namespace Core
{
/**
@class GeneralSettingsPage
*/
class GeneralSettingsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
GeneralSettingsPage(QObject *parent = 0);
~GeneralSettingsPage();
QString id() const;
QString trName() const;
QString category() const;
QString trCategory() const;
QWidget *createPage(QWidget *parent);
void apply();
void finish();
void applyGeneralSettings();
private Q_SLOTS:
void changeLanguage(const QString &lang);
void setPluginsPath();
void setLevelDesignPath();
void setAssetsPath();
private:
void readSettings();
void writeSettings();
QPalette m_originalPalette;
QWidget *m_page;
Ui::GeneralSettingsPage m_ui;
};
} // namespace Core
#endif // GENERAL_SETTINGS_H

View file

@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GeneralSettingsPage</class>
<widget class="QWidget" name="GeneralSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>267</width>
<height>282</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>6</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="qtStyleGroupBox">
<property name="title">
<string>Qt Style</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QComboBox" name="styleComboBox">
<item>
<property name="text">
<string>default</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="paletteCheckBox">
<property name="text">
<string>Use style's standard palette</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="languageGroupBox">
<property name="title">
<string>Language</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QComboBox" name="languageComboBox">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>English</string>
</property>
</item>
<item>
<property name="text">
<string>German</string>
</property>
</item>
<item>
<property name="text">
<string>French</string>
</property>
</item>
<item>
<property name="text">
<string>Russian</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="pathsGroupBox">
<property name="title">
<string>Paths</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>6</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="pluginsPathLabel">
<property name="text">
<string>Plugins path:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="pluginsPathLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="pluginsPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="leveldesignPathLabel">
<property name="text">
<string>Level design path:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leveldesignPathLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="leveldesignPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="assetsPathLabel">
<property name="text">
<string>Assets path:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="assetsPathLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="assetsPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="core.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -59,6 +59,7 @@ public:
virtual ExtensionSystem::IPluginManager *pluginManager() const = 0; virtual ExtensionSystem::IPluginManager *pluginManager() const = 0;
Q_SIGNALS: Q_SIGNALS:
void changeSettings();
void closeMainWindow(); void closeMainWindow();
}; };

View file

@ -60,6 +60,7 @@ MainWindow::MainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget *
m_tabWidget = new QTabWidget(this); m_tabWidget = new QTabWidget(this);
m_tabWidget->setTabPosition(QTabWidget::South); m_tabWidget->setTabPosition(QTabWidget::South);
m_tabWidget->setMovable(true); m_tabWidget->setMovable(true);
m_tabWidget->setDocumentMode(true);
setCentralWidget(m_tabWidget); setCentralWidget(m_tabWidget);
setDockNestingEnabled(true); setDockNestingEnabled(true);
@ -118,6 +119,10 @@ ExtensionSystem::IPluginManager *MainWindow::pluginManager() const
return m_pluginManager; return m_pluginManager;
} }
void MainWindow::open()
{
}
void MainWindow::checkObject(QObject *obj) void MainWindow::checkObject(QObject *obj)
{ {
IContext *context = qobject_cast<IContext *>(obj); IContext *context = qobject_cast<IContext *>(obj);
@ -133,7 +138,10 @@ bool MainWindow::showOptionsDialog(const QString &group,
parent = this; parent = this;
CSettingsDialog settingsDialog(m_pluginManager, group, page, parent); CSettingsDialog settingsDialog(m_pluginManager, group, page, parent);
settingsDialog.show(); settingsDialog.show();
return settingsDialog.execDialog(); bool ok = settingsDialog.execDialog();
if (ok)
Q_EMIT m_coreImpl->changeSettings();
return ok;
} }
void MainWindow::about() void MainWindow::about()
@ -177,7 +185,7 @@ void MainWindow::createActions()
m_openAction->setShortcut(QKeySequence::Open); m_openAction->setShortcut(QKeySequence::Open);
m_openAction->setStatusTip(tr("Open an existing file")); m_openAction->setStatusTip(tr("Open an existing file"));
menuManager()->registerAction(m_openAction, Constants::OPEN); menuManager()->registerAction(m_openAction, Constants::OPEN);
// connect(m_openAction, SIGNAL(triggered()), this, SLOT(open())); connect(m_openAction, SIGNAL(triggered()), this, SLOT(open()));
m_exitAction = new QAction(tr("E&xit"), this); m_exitAction = new QAction(tr("E&xit"), this);
m_exitAction->setShortcut(QKeySequence(tr("Ctrl+Q"))); m_exitAction->setShortcut(QKeySequence(tr("Ctrl+Q")));
@ -220,6 +228,7 @@ void MainWindow::createMenus()
{ {
m_fileMenu = menuBar()->addMenu(tr("&File")); m_fileMenu = menuBar()->addMenu(tr("&File"));
menuManager()->registerMenu(m_fileMenu, Constants::M_FILE); menuManager()->registerMenu(m_fileMenu, Constants::M_FILE);
// m_fileMenu->addAction(m_openAction);
m_fileMenu->addSeparator(); m_fileMenu->addSeparator();
m_fileMenu->addAction(m_exitAction); m_fileMenu->addAction(m_exitAction);
@ -260,17 +269,17 @@ void MainWindow::createDialogs()
void MainWindow::readSettings() void MainWindow::readSettings()
{ {
m_settings->beginGroup("MainWindow"); m_settings->beginGroup(Constants::MAIN_WINDOW_SECTION);
restoreState(m_settings->value("WindowState").toByteArray()); restoreState(m_settings->value(Constants::MAIN_WINDOW_STATE).toByteArray());
restoreGeometry(m_settings->value("WindowGeometry").toByteArray()); restoreGeometry(m_settings->value(Constants::MAIN_WINDOW_GEOMETRY).toByteArray());
m_settings->endGroup(); m_settings->endGroup();
} }
void MainWindow::writeSettings() void MainWindow::writeSettings()
{ {
m_settings->beginGroup("MainWindow"); m_settings->beginGroup(Constants::MAIN_WINDOW_SECTION);
m_settings->setValue("WindowState", saveState()); m_settings->setValue(Constants::MAIN_WINDOW_STATE, saveState());
m_settings->setValue("WindowGeometry", saveGeometry()); m_settings->setValue(Constants::MAIN_WINDOW_GEOMETRY, saveGeometry());
m_settings->endGroup(); m_settings->endGroup();
} }

View file

@ -59,6 +59,7 @@ public Q_SLOTS:
QWidget *parent = 0); QWidget *parent = 0);
private Q_SLOTS: private Q_SLOTS:
void open();
void checkObject(QObject *obj); void checkObject(QObject *obj);
void about(); void about();

View file

@ -33,8 +33,9 @@ namespace Core
QString lastDir = "."; QString lastDir = ".";
CSearchPathsSettingsPage::CSearchPathsSettingsPage(QObject *parent) CSearchPathsSettingsPage::CSearchPathsSettingsPage(bool recurse, QObject *parent)
: IOptionsPage(parent), : IOptionsPage(parent),
m_recurse(recurse),
m_page(0) m_page(0)
{ {
} }
@ -45,22 +46,28 @@ CSearchPathsSettingsPage::~CSearchPathsSettingsPage()
QString CSearchPathsSettingsPage::id() const QString CSearchPathsSettingsPage::id() const
{ {
return QLatin1String("SearchPaths"); if (m_recurse)
return QLatin1String("search_recurse_paths");
else
return QLatin1String("search_paths");
} }
QString CSearchPathsSettingsPage::trName() const QString CSearchPathsSettingsPage::trName() const
{ {
return tr("Search Paths"); if (m_recurse)
return tr("Search Recurse Paths");
else
return tr("Search Paths");
} }
QString CSearchPathsSettingsPage::category() const QString CSearchPathsSettingsPage::category() const
{ {
return QLatin1String("General"); return QLatin1String(Constants::SETTINGS_CATEGORY_GENERAL);
} }
QString CSearchPathsSettingsPage::trCategory() const QString CSearchPathsSettingsPage::trCategory() const
{ {
return tr("General"); return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL);
} }
QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent) QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent)
@ -92,17 +99,24 @@ void CSearchPathsSettingsPage::finish()
void CSearchPathsSettingsPage::applySearchPaths() void CSearchPathsSettingsPage::applySearchPaths()
{ {
QStringList paths; QStringList paths, remapExt;
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION); settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList(); if (m_recurse)
paths = settings->value(Core::Constants::RECURSIVE_SEARCH_PATHS).toStringList();
else
paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList();
remapExt = settings->value(Core::Constants::REMAP_EXTENSIONS).toStringList();
settings->endGroup(); settings->endGroup();
for (int i = 1; i < remapExt.size(); i += 2)
NLMISC::CPath::remapExtension(remapExt.at(i - 1).toStdString(), remapExt.at(i).toStdString(), true);
Q_FOREACH(QString path, paths) Q_FOREACH(QString path, paths)
{ {
NLMISC::CPath::addSearchPath(path.toStdString(), false, false); NLMISC::CPath::addSearchPath(path.toStdString(), m_recurse, false);
} }
NLMISC::CPath::remapExtension("png", "tga", true);
NLMISC::CPath::remapExtension("png", "dds", true);
} }
void CSearchPathsSettingsPage::addPath() void CSearchPathsSettingsPage::addPath()
@ -156,7 +170,10 @@ void CSearchPathsSettingsPage::readSettings()
QStringList paths; QStringList paths;
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION); settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList(); if (m_recurse)
paths = settings->value(Core::Constants::RECURSIVE_SEARCH_PATHS).toStringList();
else
paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList();
settings->endGroup(); settings->endGroup();
Q_FOREACH(QString path, paths) Q_FOREACH(QString path, paths)
{ {
@ -175,8 +192,12 @@ void CSearchPathsSettingsPage::writeSettings()
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION); settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
settings->setValue(Core::Constants::SEARCH_PATHS, paths); if (m_recurse)
settings->setValue(Core::Constants::RECURSIVE_SEARCH_PATHS, paths);
else
settings->setValue(Core::Constants::SEARCH_PATHS, paths);
settings->endGroup(); settings->endGroup();
settings->sync();
} }
void CSearchPathsSettingsPage::checkEnabledButton() void CSearchPathsSettingsPage::checkEnabledButton()

View file

@ -37,7 +37,7 @@ class CSearchPathsSettingsPage : public Core::IOptionsPage
Q_OBJECT Q_OBJECT
public: public:
CSearchPathsSettingsPage(QObject *parent = 0); explicit CSearchPathsSettingsPage(bool recurse, QObject *parent = 0);
~CSearchPathsSettingsPage(); ~CSearchPathsSettingsPage();
QString id() const; QString id() const;
@ -49,6 +49,7 @@ public:
void apply(); void apply();
void finish(); void finish();
// Set of the search paths(not recursive) and the remap extensions (loading from settings file)
void applySearchPaths(); void applySearchPaths();
private Q_SLOTS: private Q_SLOTS:
@ -62,6 +63,7 @@ private:
void writeSettings(); void writeSettings();
void checkEnabledButton(); void checkEnabledButton();
bool m_recurse;
QWidget *m_page; QWidget *m_page;
Ui::CSearchPathsSettingsPage m_ui; Ui::CSearchPathsSettingsPage m_ui;
}; };

View file

@ -38,6 +38,9 @@ QNLWidget::QNLWidget(QWidget *parent)
m_initialized(false), m_initialized(false),
m_interval(25) m_interval(25)
{ {
setAttribute(Qt::WA_OpaquePaintEvent);
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_PaintOnScreen);
setMouseTracking(true); setMouseTracking(true);
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);

View file

@ -45,7 +45,7 @@ using namespace Plugin;
namespace ExtensionSystem namespace ExtensionSystem
{ {
class IPluginSpec; class IPluginSpec;
} }
CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent) CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent)
@ -53,9 +53,9 @@ CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent)
_ui.setupUi(this); _ui.setupUi(this);
} }
CLogPlugin::~CLogPlugin() CLogPlugin::~CLogPlugin()
{ {
_plugMan->removeObject(_logSettingsPage); //_plugMan->removeObject(_logSettingsPage);
delete _logSettingsPage; delete _logSettingsPage;
NLMISC::ErrorLog->removeDisplayer(_displayer); NLMISC::ErrorLog->removeDisplayer(_displayer);
@ -71,7 +71,7 @@ bool CLogPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr
Q_UNUSED(errorString); Q_UNUSED(errorString);
_plugMan = pluginManager; _plugMan = pluginManager;
_logSettingsPage = new CLogSettingsPage(this); _logSettingsPage = new CLogSettingsPage(this);
_plugMan->addObject(_logSettingsPage); //_plugMan->addObject(_logSettingsPage);
return true; return true;
} }
@ -96,12 +96,12 @@ void CLogPlugin::extensionsInitialized()
void CLogPlugin::setNelContext(NLMISC::INelContext *nelContext) void CLogPlugin::setNelContext(NLMISC::INelContext *nelContext)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
// Ensure that a context doesn't exist yet. // Ensure that a context doesn't exist yet.
// This only applies to platforms without PIC, e.g. Windows. // This only applies to platforms without PIC, e.g. Windows.
nlassert(!NLMISC::INelContext::isContextInitialised()); nlassert(!NLMISC::INelContext::isContextInitialised());
#endif // fdef NL_OS_WINDOWS^M #endif // fdef NL_OS_WINDOWS^M
_LibContext = new NLMISC::CLibraryContext(*nelContext); _LibContext = new NLMISC::CLibraryContext(*nelContext);
_displayer = new NLQT::CQtDisplayer(_ui.plainTextEdit); _displayer = new NLQT::CQtDisplayer(_ui.plainTextEdit);

View file

@ -193,7 +193,7 @@
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="object_viewer.qrc"> <iconset resource="object_viewer.qrc">
<normaloff>:/images/animset.png</normaloff>:/images/animset.png</iconset> <normaloff>:/icons/ic_nel_animset.png</normaloff>:/icons/ic_nel_animset.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>

View file

@ -91,7 +91,7 @@
<item> <item>
<widget class="QPushButton" name="bankButton"> <widget class="QPushButton" name="bankButton">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>195</width> <width>192</width>
<height>64</height> <height>52</height>
</rect> </rect>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
@ -21,6 +21,12 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents"> <widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>3</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="1" column="1" colspan="2"> <item row="1" column="1" colspan="2">
<widget class="QSlider" name="horizontalSlider"> <widget class="QSlider" name="horizontalSlider">
<property name="maximum"> <property name="maximum">

View file

@ -25,8 +25,6 @@
// Qt includes // Qt includes
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QStyleFactory>
#include <QtGui/QStyle>
// NeL includes // NeL includes
#include <nel/3d/bloom_effect.h> #include <nel/3d/bloom_effect.h>
@ -75,11 +73,6 @@ QWidget *GraphicsSettingsPage::createPage(QWidget *parent)
m_ui.squareBloomCheckBox->setChecked(NL3D::CBloomEffect::instance().getSquareBloom()); m_ui.squareBloomCheckBox->setChecked(NL3D::CBloomEffect::instance().getSquareBloom());
m_ui.bloomDensityHorizontalSlider->setValue(NL3D::CBloomEffect::instance().getDensityBloom()); m_ui.bloomDensityHorizontalSlider->setValue(NL3D::CBloomEffect::instance().getDensityBloom());
m_ui.styleComboBox->addItems(QStyleFactory::keys());
QString style = settings->value(Constants::QT_STYLE, "").toString();
m_ui.styleComboBox->setCurrentIndex(m_ui.styleComboBox->findText(style));
m_ui.paletteCheckBox->setChecked(settings->value(Constants::QT_PALETTE, true).toBool());
settings->endGroup(); settings->endGroup();
connect(m_ui.enableBloomCheckBox, SIGNAL(toggled(bool)), this, SLOT(setEnableBloom(bool))); connect(m_ui.enableBloomCheckBox, SIGNAL(toggled(bool)), this, SLOT(setEnableBloom(bool)));
@ -103,16 +96,6 @@ void GraphicsSettingsPage::apply()
settings->setValue(Constants::ENABLE_BLOOM, m_ui.enableBloomCheckBox->isChecked()); settings->setValue(Constants::ENABLE_BLOOM, m_ui.enableBloomCheckBox->isChecked());
settings->setValue(Constants::ENABLE_SQUARE_BLOOM, m_ui.squareBloomCheckBox->isChecked()); settings->setValue(Constants::ENABLE_SQUARE_BLOOM, m_ui.squareBloomCheckBox->isChecked());
settings->setValue(Constants::BLOOM_DENSITY, m_ui.bloomDensityHorizontalSlider->value()); settings->setValue(Constants::BLOOM_DENSITY, m_ui.bloomDensityHorizontalSlider->value());
settings->setValue(Constants::QT_STYLE, m_ui.styleComboBox->currentText());
settings->setValue(Constants::QT_PALETTE, m_ui.paletteCheckBox->isChecked());
// apply qt style and palette
QApplication::setStyle(QStyleFactory::create(m_ui.styleComboBox->currentText()));
if (m_ui.paletteCheckBox->isChecked())
QApplication::setPalette(QApplication::style()->standardPalette());
else
QApplication::setPalette(Modules::mainWin().getOriginalPalette());
settings->endGroup(); settings->endGroup();
settings->sync(); settings->sync();

View file

@ -117,50 +117,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="3"> <item row="2" column="0">
<widget class="QGroupBox" name="qtStyleGroupBox">
<property name="title">
<string>Qt Style</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="styleComboBox"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="paletteCheckBox">
<property name="text">
<string>Use style's standard palette</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -170,14 +127,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="fontLineEdit"> <widget class="QLineEdit" name="fontLineEdit">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2"> <item row="2" column="2">
<widget class="QToolButton" name="fontSelectButton"> <widget class="QToolButton" name="fontSelectButton">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -187,7 +144,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="3" column="1">
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>

View file

@ -49,6 +49,9 @@ namespace NLQT
CGraphicsViewport::CGraphicsViewport(QWidget *parent) CGraphicsViewport::CGraphicsViewport(QWidget *parent)
: QNLWidget(parent) : QNLWidget(parent)
{ {
setAttribute(Qt::WA_OpaquePaintEvent);
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_PaintOnScreen);
} }
CGraphicsViewport::~CGraphicsViewport() CGraphicsViewport::~CGraphicsViewport()
@ -77,7 +80,7 @@ void CGraphicsViewport::release()
{ {
//H_AUTO2 //H_AUTO2
nldebug("CGraphicsViewport::release"); nldebug("CGraphicsViewport::release");
Modules::veget().release(); Modules::veget().release();
Modules::psEdit().release(); Modules::psEdit().release();
Modules::objView().release(); Modules::objView().release();
@ -119,39 +122,6 @@ void CGraphicsViewport::resizeEvent(QResizeEvent *resizeEvent)
Modules::objView().setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height()); Modules::objView().setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height());
} }
#if defined(NL_OS_MAC)
// Qt does not provide wheel events through winEvent() and macEvent() (but it
// does through x11Event(), which is inconsistent...)
// Workaround is to handle wheel events like implemented below.
//
// TODO: this is not a clean solution, because all but wheel events are
// handled using winEvent(), x11Event(), macEvent(). But this seems to be a
// limitation of current (4.7.1) Qt versions. (see e.g. qapplication_mac.mm)
void CGraphicsViewport::wheelEvent(QWheelEvent *event)
{
// Get relative positions.
float fX = 1.0f - (float)event->pos().x() / this->width();
float fY = 1.0f - (float)event->pos().y() / this->height();
// Get the buttons currently pressed.
uint32 buttons = NLMISC::noButton;
if(event->buttons() & Qt::LeftButton) buttons |= NLMISC::leftButton;
if(event->buttons() & Qt::RightButton) buttons |= NLMISC::rightButton;
if(event->buttons() & Qt::MidButton) buttons |= NLMISC::middleButton;
if(event->modifiers() & Qt::ControlModifier) buttons |= NLMISC::ctrlButton;
if(event->modifiers() & Qt::ShiftModifier) buttons |= NLMISC::shiftButton;
if(event->modifiers() & Qt::AltModifier) buttons |= NLMISC::altButton;
if(event->delta() > 0)
Modules::objView().getDriver()->EventServer.postEvent(
new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, true, NULL));
else
Modules::objView().getDriver()->EventServer.postEvent(
new NLMISC::CEventMouseWheel(-fX, fY, (NLMISC::TMouseButton)buttons, false, NULL));
}
#endif // defined(NL_OS_MAC)
#if defined(NL_OS_WINDOWS) #if defined(NL_OS_WINDOWS)
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

View file

@ -80,10 +80,6 @@ private Q_SLOTS:
protected: protected:
virtual void resizeEvent(QResizeEvent *resizeEvent); virtual void resizeEvent(QResizeEvent *resizeEvent);
#if defined(NL_OS_MAC)
virtual void wheelEvent(QWheelEvent *event);
#endif
#if defined(NL_OS_WINDOWS) #if defined(NL_OS_WINDOWS)
virtual bool winEvent(MSG *message, long *result); virtual bool winEvent(MSG *message, long *result);
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)

View file

@ -66,7 +66,7 @@ CMainWindow::CMainWindow(QWidget *parent)
_isGraphicsInitialized(false), _isGraphicsInitialized(false),
_isGraphicsEnabled(false), _isGraphicsEnabled(false),
_isSoundInitialized(false), _isSoundInitialized(false),
_isSoundEnabled(false), _isSoundEnabled(true),
_GraphicsViewport(NULL), _GraphicsViewport(NULL),
_lastDir("."), _lastDir("."),
_mouseMode(NL3D::U3dMouseListener::edit3d) _mouseMode(NL3D::U3dMouseListener::edit3d)
@ -80,19 +80,6 @@ CMainWindow::CMainWindow(QWidget *parent)
setDockNestingEnabled(true); setDockNestingEnabled(true);
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
// setup Qt style and palette from config file
_originalPalette = QApplication::palette();
QApplication::setStyle(QStyleFactory::create(settings->value(Constants::QT_STYLE, "").toString()));
if (settings->value(Constants::QT_PALETTE, true).toBool())
QApplication::setPalette(QApplication::style()->standardPalette());
else
QApplication::setPalette(_originalPalette);
_GraphicsViewport->init(); _GraphicsViewport->init();
_isGraphicsInitialized = true; _isGraphicsInitialized = true;
@ -111,6 +98,9 @@ CMainWindow::CMainWindow(QWidget *parent)
setWindowIcon(QIcon(":/images/nel.png")); setWindowIcon(QIcon(":/images/nel.png"));
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
restoreState(settings->value("QtWindowState").toByteArray()); restoreState(settings->value("QtWindowState").toByteArray());
restoreGeometry(settings->value("QtWindowGeometry").toByteArray()); restoreGeometry(settings->value("QtWindowGeometry").toByteArray());
@ -484,22 +474,6 @@ bool CMainWindow::loadFile(const QString &fileName, const QString &skelName)
return true; return true;
} }
void CMainWindow::cfcbQtStyle(NLMISC::CConfigFile::CVar &var)
{
QApplication::setStyle(QStyleFactory::create(var.asString().c_str()));
}
void CMainWindow::cfcbQtPalette(NLMISC::CConfigFile::CVar &var)
{
if (var.asBool()) QApplication::setPalette(QApplication::style()->standardPalette());
else QApplication::setPalette(_originalPalette);
}
void CMainWindow::cfcbSoundEnabled(NLMISC::CConfigFile::CVar &var)
{
_isSoundEnabled = var.asBool(); // update loop inits
}
void CMainWindow::updateRender() void CMainWindow::updateRender()
{ {
if (isVisible()) if (isVisible())

View file

@ -71,10 +71,6 @@ public:
{ {
return _SkeletonTreeModel; return _SkeletonTreeModel;
} }
QPalette getOriginalPalette() const
{
return _originalPalette;
}
private Q_SLOTS: private Q_SLOTS:
void open(); void open();
@ -96,10 +92,6 @@ private:
bool loadFile(const QString &fileName, const QString &skelName); bool loadFile(const QString &fileName, const QString &skelName);
void cfcbQtStyle(NLMISC::CConfigFile::CVar &var);
void cfcbQtPalette(NLMISC::CConfigFile::CVar &var);
void cfcbSoundEnabled(NLMISC::CConfigFile::CVar &var);
bool _isGraphicsInitialized, _isGraphicsEnabled; bool _isGraphicsInitialized, _isGraphicsEnabled;
bool _isSoundInitialized, _isSoundEnabled; bool _isSoundInitialized, _isSoundEnabled;
@ -122,7 +114,6 @@ private:
CCameraControl *_cameraControl; CCameraControl *_cameraControl;
QPalette _originalPalette;
QString _lastDir; QString _lastDir;
QTimer *_mainTimer; QTimer *_mainTimer;

View file

@ -214,7 +214,7 @@ public:
{ {
return _FontGen; return _FontGen;
} }
CSchemeManager *getSchemeManager () const CSchemeManager *getSchemeManager () const
{ {
return _SchemeManager; return _SchemeManager;

View file

@ -605,25 +605,21 @@ void CParticleSystemPage::setMaxSteps(uint32 value)
void CParticleSystemPage::setUserParam1(float value) void CParticleSystemPage::setUserParam1(float value)
{ {
_Node->getPSPointer()->setUserParam(0, value); _Node->getPSPointer()->setUserParam(0, value);
updateModifiedFlag();
} }
void CParticleSystemPage::setUserParam2(float value) void CParticleSystemPage::setUserParam2(float value)
{ {
_Node->getPSPointer()->setUserParam(1, value); _Node->getPSPointer()->setUserParam(1, value);
updateModifiedFlag();
} }
void CParticleSystemPage::setUserParam3(float value) void CParticleSystemPage::setUserParam3(float value)
{ {
_Node->getPSPointer()->setUserParam(2, value); _Node->getPSPointer()->setUserParam(2, value);
updateModifiedFlag();
} }
void CParticleSystemPage::setUserParam4(float value) void CParticleSystemPage::setUserParam4(float value)
{ {
_Node->getPSPointer()->setUserParam(3, value); _Node->getPSPointer()->setUserParam(3, value);
updateModifiedFlag();
} }
void CParticleSystemPage::setMaxViewDist(float value) void CParticleSystemPage::setMaxViewDist(float value)

View file

@ -177,7 +177,7 @@ CParticleTreeModel::~CParticleTreeModel()
int CParticleTreeModel::columnCount(const QModelIndex &parent) const int CParticleTreeModel::columnCount(const QModelIndex &parent) const
{ {
if (parent.isValid()) if (parent.isValid())
return static_cast<CParticleTreeItem*>(parent.internalPointer())->columnCount(); return static_cast<CParticleTreeItem *>(parent.internalPointer())->columnCount();
else else
return _rootItem->columnCount(); return _rootItem->columnCount();
} }

View file

@ -222,24 +222,27 @@ void CParticleWorkspaceDialog::touchPSState(CParticleTreeItem *item)
void CParticleWorkspaceDialog::clickedItem(const QModelIndex & index) void CParticleWorkspaceDialog::clickedItem(const QModelIndex & index)
{ {
if (_currentItem != NULL) if (_currentItem != 0)
_treeModel->getOwnerNode(_currentItem)->getPSPointer()->setCurrentEditedElement(NULL); _treeModel->getOwnerNode(_currentItem)->getPSPointer()->setCurrentEditedElement(NULL);
_currentItem = static_cast<CParticleTreeItem *>(index.internalPointer()); _currentItem = static_cast<CParticleTreeItem *>(index.internalPointer());
if (_currentItem == 0)
return;
if (index.flags() != Qt::NoItemFlags) if (index.flags() != Qt::NoItemFlags)
_PropertyDialog->setCurrentEditedElement(_currentItem); _PropertyDialog->setCurrentEditedElement(_currentItem);
if ((_currentItem->itemType() == ItemType::Workspace) || if ((_currentItem->itemType() == ItemType::Workspace) ||
(_currentItem->itemType() == ItemType::ParticleSystemNotLoaded)) (_currentItem->itemType() == ItemType::ParticleSystemNotLoaded))
_currentItem = NULL; _currentItem = 0;
} }
void CParticleWorkspaceDialog::customContextMenu() void CParticleWorkspaceDialog::customContextMenu()
{ {
if (!Modules::psEdit().getParticleWorkspace()) return; if (!Modules::psEdit().getParticleWorkspace()) return;
clickedItem(_ui.treeView->currentIndex()); clickedItem(_ui.treeView->currentIndex());
if (_currentItem == NULL) return; if (_currentItem == 0) return;
QMenu *popurMenu = new QMenu(this); QMenu *popurMenu = new QMenu(this);
switch (_currentItem->itemType()) switch (_currentItem->itemType())
{ {

View file

@ -25,10 +25,10 @@
namespace NL3D namespace NL3D
{ {
class CPSAttribMakerBase; class CPSAttribMakerBase;
} }
namespace NLQT namespace NLQT
{ {
class CSchemeManager class CSchemeManager
@ -50,10 +50,9 @@ public:
void remove(NL3D::CPSAttribMakerBase *am); void remove(NL3D::CPSAttribMakerBase *am);
// rename a scheme, given a pointer on it // rename a scheme, given a pointer on it
void rename(NL3D::CPSAttribMakerBase *am, const std::string &newName); void rename(NL3D::CPSAttribMakerBase *am, const std::string &newName);
protected: protected:
typedef std::pair<std::string, NL3D::CPSAttribMakerBase *> TSchemeInfo;
typedef std::multimap<std::string, TSchemeInfo> TSchemeMap; typedef std::multimap<std::string, TSchemeInfo> TSchemeMap;
TSchemeMap _SchemeMap; TSchemeMap _SchemeMap;
}; };
} /* namespace NLQT */ } /* namespace NLQT */

View file

@ -6,14 +6,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>460</width> <width>452</width>
<height>64</height> <height>52</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>86</width> <width>0</width>
<height>64</height> <height>0</height>
</size> </size>
</property> </property>
<property name="features"> <property name="features">
@ -24,6 +24,12 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents"> <widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>3</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QSlider" name="horizontalSlider"> <widget class="QSlider" name="horizontalSlider">
<property name="maximum"> <property name="maximum">

View file

@ -1,18 +1,18 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by> // Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// Projects include // Projects include
@ -154,6 +154,9 @@ void CGradientDialog::valueDown()
m_ui.listWidget->setCurrentRow(currentRow); m_ui.listWidget->setCurrentRow(currentRow);
} }
m_ui.listWidget->setCurrentRow(currentRow); m_ui.listWidget->setCurrentRow(currentRow);
--currentRow;
QListWidgetItem *item = m_ui.listWidget->item(currentRow);
m_clientInterface->displayValue(currentRow, item);
} }
void CGradientDialog::valueUp() void CGradientDialog::valueUp()

View file

@ -1,18 +1,18 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by> // Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef VALUE_GRADIENT_DIALOG_H #ifndef VALUE_GRADIENT_DIALOG_H

View file

@ -0,0 +1,3 @@
OVQT Translation Manager plugin
--------------------------------
http://dev.ryzom.com/wiki/ryzom/OVQTTranslationPluginGSoc2011

View file

@ -62,7 +62,8 @@ namespace NLQT
_CameraFocal(75), _CurrentInstance(""), _BloomEffect(false), _CameraFocal(75), _CurrentInstance(""), _BloomEffect(false),
_Scene(0), QWidget(parent) _Scene(0), QWidget(parent)
{ {
setMouseTracking(true);
setFocusPolicy(Qt::StrongFocus);
_objectViewerWidget = this; _objectViewerWidget = this;
_isGraphicsEnabled = true; _isGraphicsEnabled = true;
@ -78,7 +79,7 @@ namespace NLQT
CObjectViewerWidget::~CObjectViewerWidget() CObjectViewerWidget::~CObjectViewerWidget()
{ {
release();
} }
void CObjectViewerWidget::showEvent ( QShowEvent * event ) void CObjectViewerWidget::showEvent ( QShowEvent * event )
@ -261,7 +262,7 @@ namespace NLQT
//updateAnimation(_AnimationDialog->getTime()); //updateAnimation(_AnimationDialog->getTime());
updateAnimatePS();
// 10. Update Camera (depends on entities) // 10. Update Camera (depends on entities)
// ... // ...
@ -718,6 +719,19 @@ namespace NLQT
//CFile::deleteFile(filename); //CFile::deleteFile(filename);
return icon; return icon;
} }
void CObjectViewerWidget::updateAnimatePS(uint64 deltaTime)
{
static sint64 firstTime = NLMISC::CTime::getLocalTime();
static sint64 lastTime = NLMISC::CTime::getLocalTime();
if (deltaTime == 0)
{
deltaTime = NLMISC::CTime::getLocalTime() - lastTime;
}
lastTime += deltaTime;
float fdelta = 0.001f * (float) (lastTime - firstTime);
_Scene->animate ( fdelta);
}
#if defined(NL_OS_WINDOWS) #if defined(NL_OS_WINDOWS)

View file

@ -178,6 +178,10 @@ namespace NLQT
void updateRender(); void updateRender();
private: private:
/// Update the animation time for Particle System animation.
/// @param deltaTime - set the manual animation time.
void updateAnimatePS(uint64 deltaTime = 0);
static CObjectViewerWidget *_objectViewerWidget; static CObjectViewerWidget *_objectViewerWidget;

View file

@ -23,7 +23,7 @@ using namespace NLMISC;
#ifdef NL_DEBUG #ifdef NL_DEBUG
#define INFO nlinfo #define INFO nlinfo
#else // NL_DEBUG #else // NL_DEBUG
# if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# define INFO __noop # define INFO __noop
# else # else
# define INFO 0&& # define INFO 0&&

View file

@ -71,6 +71,8 @@ public:
const NLMISC::CMatrix *StaticMatrix; // Useful if stick mode is "StaticMatrix" const NLMISC::CMatrix *StaticMatrix; // Useful if stick mode is "StaticMatrix"
uint MaxNumAnimCount; // Number of frame on which the fx can overlap when it is being shutdown uint MaxNumAnimCount; // Number of frame on which the fx can overlap when it is being shutdown
float TimeOut; float TimeOut;
double StartTime;
float DelayBeforeStart;
public: public:
CBuildInfo() CBuildInfo()
{ {
@ -80,6 +82,8 @@ public:
StaticMatrix = NULL; StaticMatrix = NULL;
MaxNumAnimCount = 0; MaxNumAnimCount = 0;
TimeOut = FX_MANAGER_DEFAULT_TIMEOUT; TimeOut = FX_MANAGER_DEFAULT_TIMEOUT;
StartTime = 0.0;
DelayBeforeStart = 0.f;
} }
}; };
CAttachedFX(); CAttachedFX();

View file

@ -5874,6 +5874,27 @@ void CCharacterCL::updateAttachedFX()
CMatrix alignMatrix; CMatrix alignMatrix;
buildAlignMatrix(alignMatrix); buildAlignMatrix(alignMatrix);
std::list<CAttachedFX::CBuildInfo>::iterator itAttachedFxToStart = _AttachedFXListToStart.begin();
while(itAttachedFxToStart != _AttachedFXListToStart.end())
{
if ((*itAttachedFxToStart).DelayBeforeStart < (float)(TimeInSec - (*itAttachedFxToStart).StartTime))
{
uint index = (*itAttachedFxToStart).MaxNumAnimCount;
(*itAttachedFxToStart).MaxNumAnimCount = 0;
CAttachedFX::TSmartPtr fx = new CAttachedFX;
fx->create(*this, (*itAttachedFxToStart), CAttachedFX::CTargeterInfo());
if (!fx->FX.empty())
{
_AuraFX[index] = fx;
}
itAttachedFxToStart = _AttachedFXListToStart.erase(itAttachedFxToStart);
}
else
{
++itAttachedFxToStart;
}
}
// update tracks & pos for anim attachedfxs // update tracks & pos for anim attachedfxs
std::list<CAttachedFX::TSmartPtr>::iterator itAttachedFx = _AttachedFXListForCurrentAnim.begin(); std::list<CAttachedFX::TSmartPtr>::iterator itAttachedFx = _AttachedFXListForCurrentAnim.begin();
while(itAttachedFx != _AttachedFXListForCurrentAnim.end()) while(itAttachedFx != _AttachedFXListForCurrentAnim.end())
@ -8993,16 +9014,40 @@ void CCharacterCL::setAuraFX(uint index, const CAnimationFX *sheet)
} }
else else
{ {
std::list<CAttachedFX::CBuildInfo>::iterator itAttachedFxToStart = _AttachedFXListToStart.begin();
while(itAttachedFxToStart != _AttachedFXListToStart.end())
{
if ((*itAttachedFxToStart).MaxNumAnimCount == index)
return;
}
// remove previous aura // remove previous aura
_AuraFX[index] = NULL; _AuraFX[index] = NULL;
CAttachedFX::TSmartPtr fx = new CAttachedFX;
CAttachedFX::CBuildInfo bi; CAttachedFX::CBuildInfo bi;
bi.Sheet = sheet; bi.Sheet = sheet;
bi.TimeOut = 0.f; bi.TimeOut = 0.f;
fx->create(*this, bi, CAttachedFX::CTargeterInfo());
if (!fx->FX.empty()) if (sheet->Sheet->PSName == "misc_caravan_teleportout.ps")
{ {
_AuraFX[index] = fx; bi.MaxNumAnimCount = index;
bi.StartTime = TimeInSec;
bi.DelayBeforeStart = 12.5f;
_AttachedFXListToStart.push_front(bi);
}
else if (sheet->Sheet->PSName == "misc_kami_teleportout.ps")
{
bi.MaxNumAnimCount = index;
bi.StartTime = TimeInSec;
bi.DelayBeforeStart = 11.5f;
_AttachedFXListToStart.push_front(bi);
}
else
{
CAttachedFX::TSmartPtr fx = new CAttachedFX;
fx->create(*this, bi, CAttachedFX::CTargeterInfo());
if (!fx->FX.empty())
{
_AuraFX[index] = fx;
}
} }
} }
} }

View file

@ -675,6 +675,7 @@ protected:
/// List of attached to remove as soon as possible (when there are no particles left) /// List of attached to remove as soon as possible (when there are no particles left)
std::list<CAttachedFX::TSmartPtr> _AttachedFXListToRemove; std::list<CAttachedFX::TSmartPtr> _AttachedFXListToRemove;
std::list<CAttachedFX::CBuildInfo> _AttachedFXListToStart;
CAttachedFX::TSmartPtr _AuraFX[MaxNumAura]; // special case for aura CAttachedFX::TSmartPtr _AuraFX[MaxNumAura]; // special case for aura
CAttachedFX::TSmartPtr _LinkFX; // special case for link CAttachedFX::TSmartPtr _LinkFX; // special case for link

View file

@ -1942,7 +1942,7 @@ void CClientConfig::init(const string &configFileName)
// save the updated config file // save the updated config file
NLMISC::COFile configFile(configFileName, false, true, false); NLMISC::COFile configFile(configFileName, false, true, false);
configFile.serialBuffer((uint8*)contentUtf8.c_str(), contentUtf8.size()); configFile.serialBuffer((uint8*)contentUtf8.c_str(), (uint)contentUtf8.size());
configFile.close(); configFile.close();
// now we can continue loading and parsing the config file // now we can continue loading and parsing the config file

View file

@ -1199,6 +1199,11 @@ class CHandlerTell : public IActionHandler
// display msg with good color // display msg with good color
// TDataSetIndex dsi; // not used .... // TDataSetIndex dsi; // not used ....
PeopleInterraction.ChatInput.Tell.displayTellMessage(/*dsi, */finalMsg, receiver, prop.getRGBA()); PeopleInterraction.ChatInput.Tell.displayTellMessage(/*dsi, */finalMsg, receiver, prop.getRGBA());
ucstring s = CI18N::get("youTellPlayer");
strFindReplace(s, "%name", receiver);
strFindReplace(finalMsg, CI18N::get("youTell"), s);
CInterfaceManager::getInstance()->log(finalMsg);
} }
}; };
REGISTER_ACTION_HANDLER( CHandlerTell, "tell"); REGISTER_ACTION_HANDLER( CHandlerTell, "tell");

View file

@ -1271,6 +1271,30 @@ NLMISC_COMMAND(7,"talk in 7th dynamic chat channel","<channel_nb> <sentence>")
{ {
return talkInChan(7,args); return talkInChan(7,args);
} }
NLMISC_COMMAND(setItemName, "set name of items, sbrick, etc..","<sheet_id> <name> <desc> <desc2>")
{
if (args.size() < 2) return false;
CSheetId id(args[0]);
ucstring name;
name.fromUtf8(args[1]);
ucstring desc;
ucstring desc2;
if (args.size() > 2)
desc.fromUtf8(args[2]);
if (args.size() > 2)
desc2.fromUtf8(args[3]);
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
if (pSMC)
pSMC->replaceSBrickName(id, name, desc, desc2);
else
return false;
return true;
}
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View file

@ -550,7 +550,9 @@ void checkUnderCursor()
if (!instref.ContextText.empty()) if (!instref.ContextText.empty())
{ {
selectedInstanceURL = instref.ContextURL; selectedInstanceURL = instref.ContextURL;
if(ContextCur.context("WEBIG", 0.f, ucstring(instref.ContextText))) ucstring contextText;
contextText.fromUtf8(instref.ContextText);
if(ContextCur.context("WEBIG", 0.f, contextText))
return; return;
} }
} }

View file

@ -1326,7 +1326,7 @@ void postlogInit()
ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) );
CSBrickManager::getInstance()->init(); // Must be done after sheet loading CSBrickManager::getInstance()->init(); // Must be done after sheet loading
STRING_MANAGER::CStringManagerClient::specialWordsMemoryCompress(); // Must be done after brick manager init //STRING_MANAGER::CStringManagerClient::specialWordsMemoryCompress(); // Must be done after brick manager init
initLast = initCurrent; initLast = initCurrent;
initCurrent = ryzomGetLocalTime(); initCurrent = ryzomGetLocalTime();

View file

@ -1761,7 +1761,7 @@ class CHandlerItemMenuCheck : public IActionHandler
if (pCS->getInventoryIndex()==INVENTORIES::bag) if (pCS->getInventoryIndex()==INVENTORIES::bag)
{ {
bool isTextEditionActive = false; bool isTextEditionActive = false;
static const string itemTextEditionPriv = ":DEV:SGM:EM:"; static const string itemTextEditionPriv = ":DEV:SGM:GM:EM:";
if (!UserPrivileges.empty() && itemTextEditionPriv.find(UserPrivileges)!=std::string::npos) if (!UserPrivileges.empty() && itemTextEditionPriv.find(UserPrivileges)!=std::string::npos)
{ {
isTextEditionActive = true; isTextEditionActive = true;

View file

@ -60,6 +60,7 @@ void launchPhraseComposition(bool creation);
const std::string PhraseComposition="ui:interface:phrase_composition"; const std::string PhraseComposition="ui:interface:phrase_composition";
const std::string PhraseCompositionGroup="ui:interface:phrase_composition:header_opened"; const std::string PhraseCompositionGroup="ui:interface:phrase_composition:header_opened";
const std::string PhraseMemoryCtrlBase= "ui:interface:gestionsets:shortcuts:s"; const std::string PhraseMemoryCtrlBase= "ui:interface:gestionsets:shortcuts:s";
const std::string PhraseMemoryAltCtrlBase= "ui:interface:gestionsets2:header_closed:shortcuts:s";
// ********************************************************************************************************** // **********************************************************************************************************
@ -129,7 +130,11 @@ public:
if(pCSDst && pCSDst->isSPhraseId() && pCSDst->isSPhraseIdMemory()) if(pCSDst && pCSDst->isSPhraseId() && pCSDst->isSPhraseIdMemory())
{ {
// then will auto-memorize it in this slot // then will auto-memorize it in this slot
pPM->CompositionPhraseMemoryLineDest= pPM->getSelectedMemoryLineDB(); if (pCSDst->isShortCut())
pPM->CompositionPhraseMemoryLineDest= pPM->getSelectedMemoryLineDB();
else
pPM->CompositionPhraseMemoryLineDest= 0;
pPM->CompositionPhraseMemorySlotDest= pCSDst->getIndexInDB(); pPM->CompositionPhraseMemorySlotDest= pCSDst->getIndexInDB();
} }
// else no auto memorize // else no auto memorize
@ -1110,7 +1115,11 @@ public:
return; return;
// Ok, the user try to cast a phrase slot. // Ok, the user try to cast a phrase slot.
sint32 memoryLine= pPM->getSelectedMemoryLineDB(); sint32 memoryLine;
if (pCSDst->isShortCut())
memoryLine = pPM->getSelectedMemoryLineDB();
else
memoryLine = 0;
if(memoryLine<0) if(memoryLine<0)
return; return;
@ -1249,12 +1258,16 @@ public:
{ {
sint shortcut; sint shortcut;
fromString(Params, shortcut); fromString(Params, shortcut);
if (shortcut>=0 && shortcut <= RYZOM_MAX_SHORTCUT) if (shortcut>=0 && shortcut <= 2*RYZOM_MAX_SHORTCUT)
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance(); CInterfaceManager *pIM= CInterfaceManager::getInstance();
// get the control // get the control
CInterfaceElement *elm= pIM->getElementFromId(PhraseMemoryCtrlBase + toString(shortcut) ); CInterfaceElement *elm;
if (shortcut < RYZOM_MAX_SHORTCUT)
elm = pIM->getElementFromId(PhraseMemoryCtrlBase + toString(shortcut) );
else
elm = pIM->getElementFromId(PhraseMemoryAltCtrlBase + toString(shortcut-RYZOM_MAX_SHORTCUT) );
CDBCtrlSheet *ctrl= dynamic_cast<CDBCtrlSheet*>(elm); CDBCtrlSheet *ctrl= dynamic_cast<CDBCtrlSheet*>(elm);
if(ctrl) if(ctrl)
{ {
@ -1491,7 +1504,11 @@ public:
return; return;
// Ok, the user try to cast a phrase slot. // Ok, the user try to cast a phrase slot.
sint32 memoryLine= pPM->getSelectedMemoryLineDB(); sint32 memoryLine;
if (pCSDst->isShortCut())
memoryLine = pPM->getSelectedMemoryLineDB();
else
memoryLine = 0;
if(memoryLine<0) if(memoryLine<0)
return; return;

View file

@ -313,7 +313,7 @@ void CChatTargetFilter::msgEntered(const ucstring &msg, CChatWindow *chatWindow)
// the target must be a player, make a tell on him // the target must be a player, make a tell on him
ChatMngr.tell(_TargetPlayer.toString(), msg); ChatMngr.tell(_TargetPlayer.toString(), msg);
// direct output in the chat // direct output in the chat
chatWindow->displayLocalPlayerTell(msg); chatWindow->displayLocalPlayerTell(_TargetPlayer.toString(), msg);
} }
else else
{ {

View file

@ -199,7 +199,7 @@ bool CChatWindow::isVisible() const
} }
//================================================================================= //=================================================================================
void CChatWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGroup::TGroupType /* gt */, uint32 /* dynamicChatDbIndex */, uint numBlinks /* = 0*/, bool *windowVisible /*= NULL*/) void CChatWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, uint numBlinks /* = 0*/, bool *windowVisible /*= NULL*/)
{ {
if (!_Chat) if (!_Chat)
{ {
@ -466,7 +466,7 @@ void CChatWindow::setHeaderColor(const std::string &n)
} }
//================================================================================= //=================================================================================
void CChatWindow::displayLocalPlayerTell(const ucstring &msg, uint numBlinks /*= 0*/) void CChatWindow::displayLocalPlayerTell(const ucstring &receiver, const ucstring &msg, uint numBlinks /*= 0*/)
{ {
ucstring finalMsg; ucstring finalMsg;
CInterfaceProperty prop; CInterfaceProperty prop;
@ -484,7 +484,12 @@ void CChatWindow::displayLocalPlayerTell(const ucstring &msg, uint numBlinks /*=
prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," "); prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," ");
encodeColorTag(prop.getRGBA(), finalMsg, true); encodeColorTag(prop.getRGBA(), finalMsg, true);
finalMsg += msg; finalMsg += msg;
ucstring s = CI18N::get("youTellPlayer");
strFindReplace(s, "%name", receiver);
strFindReplace(finalMsg, CI18N::get("youTell"), s);
displayMessage(finalMsg, prop.getRGBA(), CChatGroup::tell, 0, numBlinks); displayMessage(finalMsg, prop.getRGBA(), CChatGroup::tell, 0, numBlinks);
CInterfaceManager::getInstance()->log(finalMsg);
} }
void CChatWindow::encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, bool append) void CChatWindow::encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, bool append)
@ -797,14 +802,6 @@ CGroupContainer *CChatGroupWindow::createFreeTeller(const ucstring &winNameIn, c
} }
} }
// Create the free teller in all the desktops
uint8 nMode = pIM->getMode();
pGC->setActive(false);
for (uint8 m = 0; m < MAX_NUM_MODES; ++m)
{
if (m != nMode)
pIM->updateGroupContainerImage(*pGC, m);
}
// the group is only active on the current desktop // the group is only active on the current desktop
pGC->setActive(true); pGC->setActive(true);
} }
@ -812,7 +809,7 @@ CGroupContainer *CChatGroupWindow::createFreeTeller(const ucstring &winNameIn, c
if (!winColor.empty()) if (!winColor.empty())
_FreeTellers[i]->setHeaderColor(winColor); _FreeTellers[i]->setHeaderColor(winColor);
updateFreeTellerHeader(*_FreeTellers[i]); // updateFreeTellerHeader(*_FreeTellers[i]);
return _FreeTellers[i]; return _FreeTellers[i];
} }

View file

@ -143,7 +143,7 @@ public:
void setAHOnCloseButtonParams(const std::string &n); void setAHOnCloseButtonParams(const std::string &n);
void setHeaderColor(const std::string &n); void setHeaderColor(const std::string &n);
// //
void displayLocalPlayerTell(const ucstring &msg, uint numBlinks = 0); void displayLocalPlayerTell(const ucstring &receiver, const ucstring &msg, uint numBlinks = 0);
/// Encode a color tag '@{RGBA}' in the text. If append is true, append at end of text, otherwise, replace the text /// Encode a color tag '@{RGBA}' in the text. If append is true, append at end of text, otherwise, replace the text
static void encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, bool append=true); static void encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, bool append=true);

View file

@ -114,7 +114,7 @@ public:
/// \name Handlers /// \name Handlers
// @{ // @{
// Event part // Event part
void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClick = getAH(actionHandlerName, _AHLeftClickParams); } void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = getAH(actionHandlerName, _AHLeftClickParams); }
void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = getAH(actionHandlerName, _AHRightClickParams); } void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = getAH(actionHandlerName, _AHRightClickParams); }
void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = getAH(ahName, _AHClockTickParams); } void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = getAH(ahName, _AHClockTickParams); }
void setParamsOnLeftClick (const std::string &paramsHandlerName) { _AHLeftClickParams = paramsHandlerName; } void setParamsOnLeftClick (const std::string &paramsHandlerName) { _AHLeftClickParams = paramsHandlerName; }
@ -203,6 +203,7 @@ protected:
//@{ //@{
IActionHandler *_AHOnOver; IActionHandler *_AHOnOver;
CStringShared _AHOverParams; CStringShared _AHOverParams;
std::string _AHOnLeftClickString;
IActionHandler *_AHOnLeftClick; IActionHandler *_AHOnLeftClick;
CStringShared _AHLeftClickParams; CStringShared _AHLeftClickParams;
IActionHandler *_AHOnLeftDblClick; IActionHandler *_AHOnLeftDblClick;

View file

@ -333,4 +333,16 @@ void CCtrlButton::fitTexture()
setH(h); setH(h);
} }
// ***************************************************************************
bool CCtrlButton::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col)
{
if (_AHOnLeftClickString == "browse")
{
texName = "curs_pick.tga";
rot= 0;
col = CRGBA::White;
return true;
}
return false;
}

View file

@ -50,6 +50,8 @@ public:
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */);
// Display part // Display part
virtual void draw(); virtual void draw();

View file

@ -21,6 +21,7 @@
#include "group_editbox.h" #include "group_editbox.h"
#include "interface_manager.h" #include "interface_manager.h"
#include "input_handler_manager.h" #include "input_handler_manager.h"
#include "nel/misc/command.h"
#include "view_text.h" #include "view_text.h"
#include "game_share/xml_auto_ptr.h" #include "game_share/xml_auto_ptr.h"
#include "interface_options.h" #include "interface_options.h"
@ -56,6 +57,7 @@ CGroupEditBox::CGroupEditBox(const TCtorParam &param) :
_MaxCharsSize(32768), _MaxCharsSize(32768),
_FirstVisibleChar(0), _FirstVisibleChar(0),
_LastVisibleChar(0), _LastVisibleChar(0),
_SelectingText(false),
_ViewText(NULL), _ViewText(NULL),
_MaxHistoric(0), _MaxHistoric(0),
_CurrentHistoricIndex(-1), _CurrentHistoricIndex(-1),
@ -354,16 +356,27 @@ void CGroupEditBox::paste()
if (Driver->pasteTextFromClipboard(sString)) if (Driver->pasteTextFromClipboard(sString))
{ {
// append string now // append string now
appendString(sString); appendStringFromClipboard(sString);
} }
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupEditBox::appendString(const ucstring &str) void CGroupEditBox::appendStringFromClipboard(const ucstring &str)
{ {
stopParentBlink(); stopParentBlink();
makeTopWindow(); makeTopWindow();
writeString(str, true, false);
nlinfo ("Chat input was pasted from the clipboard");
triggerOnChangeAH();
_CursorAtPreviousLineEnd = false;
}
// ----------------------------------------------------------------------------
void CGroupEditBox::writeString(const ucstring &str, bool replace, bool atEnd)
{
sint length = (sint)str.length(); sint length = (sint)str.length();
ucstring toAppend; ucstring toAppend;
@ -500,13 +513,41 @@ void CGroupEditBox::appendString(const ucstring &str)
length = _MaxNumChar - (sint)_InputString.length(); length = _MaxNumChar - (sint)_InputString.length();
} }
ucstring toAdd = toAppend.substr(0, length); ucstring toAdd = toAppend.substr(0, length);
_InputString = _InputString.substr(0, _CursorPos) + toAdd + _InputString.substr(_CursorPos); sint32 minPos;
_CursorPos += (sint32)toAdd.length(); sint32 maxPos;
nlinfo ("Chat input was pasted from the clipboard"); if (_CurrSelection == this)
{
minPos = min(_CursorPos, _SelectCursorPos);
maxPos = max(_CursorPos, _SelectCursorPos);
}
else
{
minPos = _CursorPos;
maxPos = _CursorPos;
}
triggerOnChangeAH(); nlinfo("%d, %d", minPos, maxPos);
if (replace)
{
_InputString = _InputString.substr(0, minPos) + toAdd + _InputString.substr(maxPos);
_CursorPos = minPos+(sint32)toAdd.length();
}
else
{
if (atEnd)
{
_InputString = _InputString.substr(0, maxPos) + toAdd + _InputString.substr(maxPos);
_CursorPos = maxPos;
_SelectCursorPos = _CursorPos;
_CursorAtPreviousLineEnd = false; }
else
{
_InputString = _InputString.substr(0, minPos) + toAdd + _InputString.substr(minPos);
_CursorPos = minPos+(sint32)toAdd.length();
_SelectCursorPos = maxPos+(sint32)toAdd.length();
}
}
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -672,7 +713,7 @@ void CGroupEditBox::handleEventChar(const CEventDescriptorKey &rEDK)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupEditBox::handleEventString(const CEventDescriptorKey &rEDK) void CGroupEditBox::handleEventString(const CEventDescriptorKey &rEDK)
{ {
appendString(rEDK.getString()); appendStringFromClipboard(rEDK.getString());
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -862,6 +903,7 @@ bool CGroupEditBox::handleEvent (const CEventDescriptor& event)
// if click, and not frozen, then get the focus // if click, and not frozen, then get the focus
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown && !_Frozen) if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown && !_Frozen)
{ {
_SelectingText = true;
stopParentBlink(); stopParentBlink();
pIM->setCaptureKeyboard (this); pIM->setCaptureKeyboard (this);
// set the right cursor position // set the right cursor position
@ -872,9 +914,34 @@ bool CGroupEditBox::handleEvent (const CEventDescriptor& event)
_CursorPos = newCurPos; _CursorPos = newCurPos;
_CursorPos -= (sint32)_Prompt.length(); _CursorPos -= (sint32)_Prompt.length();
_CursorPos = std::max(_CursorPos, sint32(0)); _CursorPos = std::max(_CursorPos, sint32(0));
_SelectCursorPos = _CursorPos;
_CurrSelection = NULL;
return true; return true;
} }
// if click, and not frozen, then get the focus
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousemove && !_Frozen && _SelectingText)
{
// set the right cursor position
uint newCurPos;
bool cursorAtPreviousLineEnd;
_CurrSelection = this;
_ViewText->getCharacterIndexFromPosition(eventDesc.getX() - _ViewText->getXReal(), eventDesc.getY() - _ViewText->getYReal(), newCurPos, cursorAtPreviousLineEnd);
_SelectCursorPos = newCurPos;
_SelectCursorPos -= (sint32)_Prompt.length();
_SelectCursorPos = std::max(_SelectCursorPos, sint32(0));
return true;
}
// if click, and not frozen, then get the focus
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup && !_Frozen)
{
_SelectingText = false;
if (_SelectCursorPos == _CursorPos)
_CurrSelection = NULL;
return true;
}
if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown) if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown)
{ {

View file

@ -125,6 +125,8 @@ public:
void copy(); void copy();
// Paste the selection into buffer // Paste the selection into buffer
void paste(); void paste();
// Write the string into buffer
void writeString(const ucstring &str, bool replace = true, bool atEnd = true);
// Expand the expression (true if there was a '/' at the start of the line) // Expand the expression (true if there was a '/' at the start of the line)
bool expand(); bool expand();
@ -217,6 +219,7 @@ protected:
// Text selection // Text selection
static sint32 _SelectCursorPos; static sint32 _SelectCursorPos;
static CGroupEditBox *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none static CGroupEditBox *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none
bool _SelectingText;
NLMISC::CRGBA _TextSelectColor; NLMISC::CRGBA _TextSelectColor;
NLMISC::CRGBA _BackSelectColor; NLMISC::CRGBA _BackSelectColor;
@ -291,7 +294,7 @@ private:
void handleEventString(const CEventDescriptorKey &event); void handleEventString(const CEventDescriptorKey &event);
void setup(); void setup();
void triggerOnChangeAH(); void triggerOnChangeAH();
void appendString(const ucstring &str); void appendStringFromClipboard(const ucstring &str);
ucstring getSelection(); ucstring getSelection();

View file

@ -442,6 +442,9 @@ void CGroupHTML::addText (const char * buf, int len)
{ {
if (_Browsing) if (_Browsing)
{ {
if (_IgnoreText)
return;
// Build a UTF8 string // Build a UTF8 string
string inputString(buf, buf+len); string inputString(buf, buf+len);
// inputString.resize (len); // inputString.resize (len);
@ -525,6 +528,11 @@ void CGroupHTML::addLink (uint element_number, uint /* attribute_number */, HTCh
// in ah: command we don't respect the uri standard so the HTAnchor_address doesn't work correctly // in ah: command we don't respect the uri standard so the HTAnchor_address doesn't work correctly
_Link.push_back (suri); _Link.push_back (suri);
} }
else if (suri[0] == '#')
{
// Direct url (hack for lua beginElement)
_Link.push_back (suri.substr(1));
}
else else
{ {
HTAnchor * dest = HTAnchor_followMainLink((HTAnchor *) anchor); HTAnchor * dest = HTAnchor_followMainLink((HTAnchor *) anchor);
@ -839,6 +847,14 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
} }
} }
break; break;
case HTML_DIV:
{
if (present[MY_HTML_DIV_NAME] && value[MY_HTML_DIV_NAME])
{
_DivName = value[MY_HTML_DIV_NAME];
}
}
break;
case HTML_FONT: case HTML_FONT:
{ {
bool found = false; bool found = false;
@ -856,7 +872,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
_TextColor.push_back(_TextColor.empty() ? CRGBA::White : _TextColor.back()); _TextColor.push_back(_TextColor.empty() ? CRGBA::White : _TextColor.back());
} }
} }
break; break;
case HTML_BR: case HTML_BR:
addString(ucstring ("\n")); addString(ucstring ("\n"));
break; break;
@ -1372,6 +1388,9 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
_ObjectAction = value[HTML_OBJECT_STANDBY]; _ObjectAction = value[HTML_OBJECT_STANDBY];
_Object = true; _Object = true;
break;
case HTML_STYLE:
_IgnoreText = true;
break; break;
} }
} }
@ -1409,6 +1428,10 @@ void CGroupHTML::endElement (uint element_number)
case HTML_PRE: case HTML_PRE:
popIfNotEmpty (_PRE); popIfNotEmpty (_PRE);
break; break;
case HTML_DIV:
_DivName = "";
break;
case HTML_TABLE: case HTML_TABLE:
popIfNotEmpty (_CellParams); popIfNotEmpty (_CellParams);
popIfNotEmpty (_TR); popIfNotEmpty (_TR);
@ -1493,6 +1516,9 @@ void CGroupHTML::endElement (uint element_number)
popIfNotEmpty (_UL); popIfNotEmpty (_UL);
} }
break; break;
case HTML_STYLE:
_IgnoreText = false;
break;
case HTML_OBJECT: case HTML_OBJECT:
if (_ObjectType=="application/ryzom-data") if (_ObjectType=="application/ryzom-data")
{ {
@ -1560,6 +1586,7 @@ CGroupHTML::CGroupHTML(const TCtorParam &param)
// init // init
_ParsingLua = false; _ParsingLua = false;
_IgnoreText = false;
_BrowseNextTime = false; _BrowseNextTime = false;
_PostNextTime = false; _PostNextTime = false;
_Browsing = false; _Browsing = false;
@ -2506,6 +2533,7 @@ void CGroupHTML::clearContext()
_Cells.clear(); _Cells.clear();
_TR.clear(); _TR.clear();
_Forms.clear(); _Forms.clear();
_Groups.clear();
_CellParams.clear(); _CellParams.clear();
_Title = false; _Title = false;
_TextArea = false; _TextArea = false;
@ -2584,6 +2612,12 @@ void CGroupHTML::addGroup (CInterfaceGroup *group, uint beginSpace)
_Paragraph = NULL; _Paragraph = NULL;
} }
if (!_DivName.empty())
{
group->setName(_DivName);
_Groups.push_back(group);
}
group->setSizeRef(CInterfaceElement::width); group->setSizeRef(CInterfaceElement::width);
// Compute begin space between paragraph and tables // Compute begin space between paragraph and tables
@ -3337,6 +3371,171 @@ int CGroupHTML::luaRefresh(CLuaState &ls)
return 0; return 0;
} }
// ***************************************************************************
int CGroupHTML::luaRemoveContent(CLuaState &ls)
{
const char *funcName = "refresh";
CLuaIHM::checkArgCount(ls, funcName, 0);
removeContent();
return 0;
}
// ***************************************************************************
int CGroupHTML::luaInsertText(CLuaState &ls)
{
const char *funcName = "insertText";
CLuaIHM::checkArgCount(ls, funcName, 3);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 3, LUA_TBOOLEAN);
string name = ls.toString(1);
ucstring text;
text.fromUtf8(ls.toString(2));
if (!_Forms.empty()) {
for (uint i=0; i<_Forms.back().Entries.size(); i++)
{
if (_Forms.back().Entries[i].TextArea && _Forms.back().Entries[i].Name == name)
{
// Get the edit box view
CInterfaceGroup *group = _Forms.back().Entries[i].TextArea->getGroup ("eb");
if (group)
{
// Should be a CGroupEditBox
CGroupEditBox *editBox = dynamic_cast<CGroupEditBox*>(group);
if (editBox)
editBox->writeString(text, false, ls.toBoolean(3));
}
}
}
}
return 0;
}
// ***************************************************************************
int CGroupHTML::luaAddString(CLuaState &ls)
{
const char *funcName = "addString";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
addString(ucstring(ls.toString(1)));
return 0;
}
// ***************************************************************************
int CGroupHTML::luaAddImage(CLuaState &ls)
{
const char *funcName = "addImage";
CLuaIHM::checkArgCount(ls, funcName, 2);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TBOOLEAN);
if (!_Paragraph)
{
newParagraph(0);
paragraphChange();
}
string url = getLink();
if (!url.empty()) {
string params = "name=" + getId() + "|url=" + getLink ();
addButton(CCtrlButton::PushButton, ls.toString(1), ls.toString(1), ls.toString(1),
"", ls.toBoolean(2), "browse", params.c_str(), "");
} else {
addImage(ls.toString(1), ls.toBoolean(2));
}
return 0;
}
// ***************************************************************************
int CGroupHTML::luaBeginElement(CLuaState &ls)
{
const char *funcName = "beginElement";
CLuaIHM::checkArgCount(ls, funcName, 2);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TTABLE);
uint element_number = (uint)ls.toNumber(1);
std::vector<BOOL> present;
std::vector<const char *> value;
present.resize(30, false);
value.resize(30);
CLuaObject params;
params.pop(ls);
uint max_idx = 0;
ENUM_LUA_TABLE(params, it)
{
if (!it.nextKey().isNumber())
{
nlwarning("%s : bad key encountered with type %s, number expected.", funcName, it.nextKey().getTypename());
continue;
}
if (!it.nextValue().isString())
{
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();
present.insert(present.begin() + (uint)it.nextKey().toNumber(), 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);
}
beginElement(element_number, &present[0], &value[0]);
if (element_number == HTML_A)
addLink(element_number, 0, NULL, &present[0], &value[0]);
return 0;
}
// ***************************************************************************
int CGroupHTML::luaEndElement(CLuaState &ls)
{
const char *funcName = "endElement";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
uint element_number = (uint)ls.toNumber(1);
endElement(element_number);
return 0;
}
// ***************************************************************************
int CGroupHTML::luaShowDiv(CLuaState &ls)
{
const char *funcName = "showDiv";
CLuaIHM::checkArgCount(ls, funcName, 2);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TBOOLEAN);
if (!_Groups.empty()) {
for (uint i=0; i<_Groups.size(); i++)
{
CInterfaceGroup *group = _Groups[i];
if (group->getName() == ls.toString(1))
{
group->setActive(ls.toBoolean(2));
}
}
}
return 0;
}
// *************************************************************************** // ***************************************************************************
void CGroupHTML::setURL(const std::string &url) void CGroupHTML::setURL(const std::string &url)
{ {

View file

@ -165,10 +165,24 @@ public:
int luaBrowse(CLuaState &ls); int luaBrowse(CLuaState &ls);
int luaRefresh(CLuaState &ls); int luaRefresh(CLuaState &ls);
int luaRemoveContent(CLuaState &ls);
int luaInsertText(CLuaState &ls);
int luaAddString(CLuaState &ls);
int luaAddImage(CLuaState &ls);
int luaBeginElement(CLuaState &ls);
int luaEndElement(CLuaState &ls);
int luaShowDiv(CLuaState &ls);
REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText) REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText)
REFLECT_LUA_METHOD("browse", luaBrowse) REFLECT_LUA_METHOD("browse", luaBrowse)
REFLECT_LUA_METHOD("refresh", luaRefresh) REFLECT_LUA_METHOD("refresh", luaRefresh)
REFLECT_LUA_METHOD("removeContent", luaRemoveContent)
REFLECT_LUA_METHOD("insertText", luaInsertText)
REFLECT_LUA_METHOD("addString", luaAddString)
REFLECT_LUA_METHOD("addImage", luaAddImage)
REFLECT_LUA_METHOD("beginElement", luaBeginElement)
REFLECT_LUA_METHOD("endElement", luaEndElement)
REFLECT_LUA_METHOD("showDiv", luaShowDiv)
REFLECT_STRING("url", getURL, setURL) REFLECT_STRING("url", getURL, setURL)
REFLECT_FLOAT("timeout", getTimeout, setTimeout) REFLECT_FLOAT("timeout", getTimeout, setTimeout)
REFLECT_EXPORT_END REFLECT_EXPORT_END
@ -290,6 +304,7 @@ protected :
// element has been found // element has been found
// True when the <lua> element has been encountered // True when the <lua> element has been encountered
bool _ParsingLua; bool _ParsingLua;
bool _IgnoreText;
// the script to execute // the script to execute
std::string _LuaScript; std::string _LuaScript;
@ -303,6 +318,7 @@ protected :
class CLibWWWData *_LibWWW; class CLibWWWData *_LibWWW;
// Current paragraph // Current paragraph
std::string _DivName;
CGroupParagraph* _Paragraph; CGroupParagraph* _Paragraph;
inline CGroupParagraph *getParagraph() inline CGroupParagraph *getParagraph()
{ {
@ -442,6 +458,7 @@ protected :
std::vector<CEntry> Entries; std::vector<CEntry> Entries;
}; };
std::vector<CForm> _Forms; std::vector<CForm> _Forms;
std::vector<CInterfaceGroup *> _Groups;
// Cells parameters // Cells parameters
class CCellParams class CCellParams

View file

@ -278,8 +278,11 @@ void CGroupQuickHelp::browse (const char *url)
_IsQuickHelp = false; _IsQuickHelp = false;
string completeURL = url; string completeURL = url;
completeURL = completeURL.substr(0, completeURL.size()-5); // Substract the ".html" if (completeURL.substr(completeURL.size()-5, 5) == ".html")
completeURL += "_" + ClientCfg.getHtmlLanguageCode() + ".html"; {
completeURL = completeURL.substr(0, completeURL.size()-5); // Substract the ".html"
completeURL += "_" + ClientCfg.getHtmlLanguageCode() + ".html";
}
CGroupHTML::browse (completeURL.c_str()); CGroupHTML::browse (completeURL.c_str());
} }

View file

@ -250,6 +250,9 @@ public:
/// Accessors : SET /// Accessors : SET
void setId (const std::string &newID) { _Id = newID; } void setId (const std::string &newID) { _Id = newID; }
inline void setName(const std::string &name) { _Name = name; }
inline const std::string& getName() { return _Name; }
virtual void setIdRecurse(const std::string &newID); virtual void setIdRecurse(const std::string &newID);
void setParent (CInterfaceGroup *pIG) { _Parent = pIG; } void setParent (CInterfaceGroup *pIG) { _Parent = pIG; }
@ -510,6 +513,8 @@ protected:
///the id of the element ///the id of the element
std::string _Id; std::string _Id;
std::string _Name;
///is the element active? ///is the element active?
bool _Active; bool _Active;

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