Merge branch 'ryzomcore' into 'develop'

Ryzomcore merge upstream

See merge request khaganat/mmorpg_khanat/khanat-opennel-code!42
This commit is contained in:
aleajactaest 2019-08-01 10:14:47 +02:00
commit 6ab72bc441
658 changed files with 79956 additions and 12526 deletions

7
.gitignore vendored
View file

@ -160,7 +160,7 @@ code/build/*
code/build-2010/*
build/*
install/*
build_vc*
build_*
code/nel/tools/build_gamedata/configuration/buildsite.py
code/build*
build*
@ -218,6 +218,7 @@ code/ryzom/server/src/ryzom_admin_service/ryzom_admin_service
code/ryzom/server/src/ryzom_naming_service/ryzom_naming_service
code/ryzom/server/src/ryzom_welcome_service/ryzom_welcome_service
code/ryzom/server/src/tick_service/tick_service
# WebTT temp dir
code/ryzom/tools/server/www/webtt/app/tmp
@ -238,14 +239,14 @@ code/ryzom/tools/server/ryzom_ams/old
#tools and external dir's
# Tools and external directories
external
external_vc14
external_stlport
nel_tools*
ryzom_tools*
#Dumps
# Dumps
*.dmp
code/nel/tools/build_gamedata/processes/ai_wmap/ai_build_wmap.cfg

View file

@ -52,14 +52,14 @@ Linux client build:
- echo "disableproc:$disableproc, nb core compile:$(nproc --ignore=$disableproc) optionproc:$optionproc"
# Installation des dépendances
#- echo "deb http://ftp.debian.org/debian/ jessie-backports non-free contrib main" >> /etc/apt/sources.list
- apt-get update
- apt-get -y upgrade
- apt-get install libxml2 -y g++ gcc cmake libcurl4-openssl-dev libgl1-mesa-dev libjpeg-dev libpng-dev libopenal-dev libfreetype6-dev libxxf86vm-dev libxrandr-dev libxrender-dev libvorbis-dev libluabind-dev libboost-dev libmysqlclient-dev libssl-dev liblzma-dev libxml2-dev makeself libgif-dev patch
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install libxml2 -y g++ gcc cmake libcurl4-openssl-dev libgl1-mesa-dev libjpeg-dev libpng-dev libopenal-dev libfreetype6-dev libxxf86vm-dev libxrandr-dev libxrender-dev libvorbis-dev libluabind-dev libboost-dev libmysqlclient-dev libssl-dev liblzma-dev libxml2-dev makeself libgif-dev patch
# Installation des dépendances des dépendances statiques (à commenter si construction de Khanat en mode dynamique)
# libxml2 : python-pyicu (support d'unicode), python-dev (support de... python)
- apt-get install -y wget python-pyicu python-dev
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
# Création de l'environnement de compilation
- mkdir -p BUILD/x86_64
- cd BUILD/x86_64
@ -72,6 +72,49 @@ Linux client build:
- ./configure --disable-ldap --disable-ldaps --disable-rtsp --disable-dict --disable-ipv6 --disable-crypto-auth --disable-sspi --disable-tls-srp --without-gnutls --without-librtmp --without-libidn --disable-versioned-symbols --disable-pop3 --without-libssh2 --with-ssl
- make install $optionproc
- cd ..
# Build luabind
- mkdir -p luabind
- wget -q http://http.debian.net/debian/pool/main/l/luabind/luabind_0.9.1+dfsg.orig.tar.gz -O luabind.tar.gz
- wget -q http://http.debian.net/debian/pool/main/l/luabind/luabind_0.9.1+dfsg-11.debian.tar.xz -O luabind-debian.tar.xz
- tar xvf luabind.tar.gz -C luabind --strip 1 || exit 2
- tar xvf luabind-debian.tar.xz -C luabind || exit 2
- cd luabind
- for file in $(cat debian/patches/series); do patch -p1 < debian/patches/$file; done
- export -p DEB_HOST_MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH); bjam -d2 release debug install cflags="-fPIC $(dpkg-buildflags --get CFLAGS)" cxxflags="-fPIC $(dpkg-buildflags --get CXXFLAGS) -Wno-deprecated-declarations" linkflags=" $(dpkg-buildflags --get LDFLAGS)"
- export -p DEB_HOST_MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH); bjam -d2 release debug install link=static cflags="-fPIC $(dpkg-buildflags --get CFLAGS)" cxxflags="-fPIC $(dpkg-buildflags --get CXXFLAGS) -Wno-deprecated-declarations" linkflags=" $(dpkg-buildflags --get LDFLAGS)"
- cd ..
# Build libogg
- mkdir -p libogg/build
- wget -q http://http.debian.net/debian/pool/main/libo/libogg/libogg_1.3.2.orig.tar.gz -O libogg.tar.gz
- wget -q http://http.debian.net/debian/pool/main/libo/libogg/libogg_1.3.2-1.diff.gz -O libogg.diff.gz
- tar xvf libogg.tar.gz -C libogg --strip 1 || exit 2
- gunzip libogg.diff.gz
- cd libogg
- patch -p1 < ../libogg.diff
- cd build
- ../configure --disable-maintainer-mode --host=$(dpkg-architecture -qDEB_HOST_GNU_TYPE) --build=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE) --libdir=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH) --enable-static --prefix=/usr CPPFLAGS="-D_FORTIFY_SOURCE=2" CFLAGS="-Wformat=2 -g -fPIC" CXXFLAGS="-Wformat=2 -g -fPIC" LDFLAGS="-Wl,-z,now"
- make
- make install
- cd ../..
# Build libvorbis
- mkdir -p libvorbis
- wget -q http://security.debian.org/debian-security/pool/updates/main/libv/libvorbis/libvorbis_1.3.5.orig.tar.gz -O libvorbis.tar.gz
- tar xvf libvorbis.tar.gz -C libvorbis --strip 1 || exit 2
# Get list package
- wget -q http://security.debian.org/debian-security/pool/updates/main/libv/libvorbis -O list_libvorbis
# get last patch for our release
- line=$(egrep '(libvorbis_1.3.5)(.*)(tar[.]xz)' list_libvorbis | tail -n 1)
# get only name of the patch
- tmp=${line#*href} ; tmp2=${tmp%%>*} ; tmp3=${tmp2#*\"} ; namepatch=${tmp3%\"*}
# download this patch
- wget -q http://security.debian.org/debian-security/pool/updates/main/libv/libvorbis/$namepatch -O libvorbis.debian.tar.xz
- tar xvf libvorbis.debian.tar.xz -C libvorbis || exit 2
- cd libvorbis
- for file in $(cat debian/patches/series); do patch -p1 < debian/patches/$file; done
- ./configure --enable-static --with-pic
- make
- make install
- cd ..
## Compilation de Khanat
# Configuration
- cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/ -DCMAKE_BUILD_TYPE=Release -DWITH_RYZOM_SERVER=OFF -DWITH_RYZOM_TOOLS=OFF -DWITH_RYZOM_CLIENT=ON -DWITH_NEL_TESTS=OFF -DWITH_NEL_TOOLS=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_STATIC=ON -DWITH_STATIC_DRIVERS=ON -DWITH_STATIC_EXTERNAL=ON -DWITH_UNIX_STRUCTURE=OFF -DWITH_INSTALL_LIBRARIES=OFF -DWITH_LUA52=ON ../../code
@ -100,10 +143,9 @@ Linux server debian_amd64_strech build:
image: amd64/debian:9
script:
# Prepare environment
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server
- apt-get install -y
git
libcurl4-openssl-dev
libfreetype6-dev
@ -144,7 +186,7 @@ Linux server debian_amd64_strech build:
patch
- apt-get install -y liblua5.2-0 liblua5.2-dev libluabind-dev libluabind0.9.1v5
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
# install squish
- mkdir -p squish
- (cd squish; wget -c https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/libsquish/squish-1.11.zip)
@ -188,8 +230,8 @@ Linux client debian_amd64_strech build:
image: amd64/debian:9
script:
# Prepare environment
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
- apt-get install -y autoconf
autogen
automake
@ -224,7 +266,7 @@ Linux client debian_amd64_strech build:
patch
- apt-get install -y liblua5.2-0 liblua5.2-dev libluabind-dev libluabind0.9.1v5 libogg-dev libvorbis-dev
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
# Build Curl
- wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz
- mkdir -p curl/build
@ -254,8 +296,8 @@ Linux client_static debian_amd64_strech build:
image: amd64/debian:9
script:
# Prepare environment
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
- apt-get install -y
autoconf
autogen
@ -291,7 +333,7 @@ Linux client_static debian_amd64_strech build:
patch
- apt-get install -y liblua5.2-0 liblua5.2-dev
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
# Build Curl
- wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz
- mkdir -p curl/build
@ -303,6 +345,7 @@ Linux client_static debian_amd64_strech build:
- mkdir -p luabind
- wget -q http://http.debian.net/debian/pool/main/l/luabind/luabind_0.9.1+dfsg.orig.tar.gz -O luabind.tar.gz
- wget -q http://http.debian.net/debian/pool/main/l/luabind/luabind_0.9.1+dfsg-11.debian.tar.xz -O luabind-debian.tar.xz
- ls
- tar xvf luabind.tar.gz -C luabind --strip 1 || exit 2
- tar xvf luabind-debian.tar.xz -C luabind || exit 2
- cd luabind
@ -363,8 +406,8 @@ Linux client_static_debug debian_amd64_strech build:
image: amd64/debian:9
script:
# Prepare environment
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
- apt-get install -y
autoconf
autogen
@ -400,7 +443,7 @@ Linux client_static_debug debian_amd64_strech build:
patch
- apt-get install -y liblua5.2-0 liblua5.2-dev
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
# Build Curl
- wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz
- mkdir -p curl/build
@ -472,11 +515,11 @@ Linux server_static debian_amd64_strech build:
image: amd64/debian:9
script:
# Prepare environment
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 apache2-utils autoconf autogen automake bison build-essential cmake cpputest default-libmysqlclient-dev fakeroot git libapache2-mod-php libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblua5.2-0 liblua5.2-dev liblzma-dev libogg-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libvorbis-dev libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial mysql-server php php-gd php-imagick php-mysql python3 python3-pip python3-bcrypt python3-venv rrdtool unzip wget zlib1g-dev
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
# Build Curl
- wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz
- mkdir -p curl/build
@ -563,11 +606,11 @@ Linux server_static_debug debian_amd64_strech build:
image: amd64/debian:9
script:
# Prepare environment
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 apache2-utils autoconf autogen automake bison build-essential cmake cpputest default-libmysqlclient-dev fakeroot git libapache2-mod-php libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblua5.2-0 liblua5.2-dev liblzma-dev libogg-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libvorbis-dev libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial mysql-server php php-gd php-imagick php-mysql python3 python3-pip python3-bcrypt python3-venv rrdtool unzip wget zlib1g-dev
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
# Build Curl
- wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz
- mkdir -p curl/build
@ -654,12 +697,12 @@ Linux client_static debian_i386_strech build:
image: i386/debian:9
script:
# Prepare environment
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
- apt-get install -y autoconf autogen automake bison build-essential cmake cpputest fakeroot libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblzma-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial rrdtool unzip wget zlib1g-dev patch
- apt-get install -y liblua5.2-0 liblua5.2-dev
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
# Build Curl
- wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz
- mkdir -p curl/build
@ -732,12 +775,12 @@ Linux client_static_debug debian_i386_strech build:
image: i386/debian:9
script:
# Prepare environment
- apt-get update
- apt-get dist-upgrade -y
- apt-get install -y autoconf autogen automake bison build-essential cmake cpputest fakeroot libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblzma-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial rrdtool unzip wget zlib1g-dev patch
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y autoconf autogen automake bison build-essential cmake cpputest fakeroot libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblzma-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial rrdtool unzip wget zlib1g-dev patch
- apt-get install -y liblua5.2-0 liblua5.2-dev
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
# Build Curl
- wget -q https://curl.haxx.se/download/curl-7.58.0.tar.gz -O curl.tar.gz
- mkdir -p curl/build
@ -852,7 +895,7 @@ Linux client fedora_amd64_27 build:
zlib-devel
patch
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
# Action
- mkdir -p code/build
- (cd code/build ; export -p CPPFLAGS="-Wno-deprecated -Wno-deprecated-declarations"; cmake -G "Unix Makefiles" -DWITH_NEL=ON -DWITH_LUA52=ON -DWITH_RYZOM_PATCH=OFF -DWITH_RYZOM_CUSTOM_PATCH_SERVER=OFF -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=ON -DWITH_DRIVER_OPENGL=ON -DWITH_DRIVER_OPENAL=ON -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=ON -DWITH_STATIC_CURL=OFF ..)
@ -876,9 +919,9 @@ Linux client ubuntu_amd64_17_10 build:
image: amd64/ubuntu:17.10
script:
# Prepare environment
- apt-get update
- apt-get dist-upgrade -y
- apt-get install -y autoconf
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y autoconf
autogen
automake
bison
@ -912,7 +955,7 @@ Linux client ubuntu_amd64_17_10 build:
zlib1g-dev
- apt-get install -y liblua5.2-0 liblua5.2-dev libluabind-dev libluabind0.9.1v5 libogg-dev libvorbis-dev
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
# Action
- mkdir -p code/build
- (cd code/build ; export -p CPPFLAGS="-Wno-deprecated -Wno-deprecated-declarations"; cmake -G "Unix Makefiles" -DWITH_NEL=ON -DWITH_LUA52=ON -DWITH_RYZOM_PATCH=OFF -DWITH_RYZOM_CUSTOM_PATCH_SERVER=OFF -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=ON -DWITH_DRIVER_OPENGL=ON -DWITH_DRIVER_OPENAL=ON -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=ON -DWITH_STATIC_CURL=OFF ..)
@ -996,7 +1039,7 @@ Linux client archlinux build:
- cd ../..
- yaourt -Syyu --noconfirm --aur boost-build
# Apply patch
- (for patchfile in $(cat patch/series); do if ! patch -Z -t -R -s -f --dry-run -p 1 -i patch/$patchfile; then patch -f -Z -t -p 1 -i patch/$patchfile || exit 2 ; fi;done)
- (for patchfile in $(cat patch/series); do echo "patch patch/$patchfile"; patch -f -Z -t -p 1 -i patch/$patchfile || exit 2; done)
- patch -f -Z -t -p 1 -i patch/02_archlinux_allocator_static_assert_error.patch
# Build
- mkdir -p luabind
@ -1033,9 +1076,9 @@ Windows client build:
script:
# Prepare environment
- dpkg --add-architecture i386
- apt-get update
- apt-get dist-upgrade -y
- apt-get install -y
- DEBIAN_FRONTEND=noninteractive apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y
p7zip-full
binfmt-support
libc6-i386
@ -1098,7 +1141,7 @@ Linux client test:
- mac-ci-build
tags:
- Docker
image: ubuntu:14.04
image: ubuntu:18.04
script:
# Test de l'installation initiale
- ./khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-Linux-x86_64.run
@ -1128,7 +1171,7 @@ Linux client test:
- ryzomcore
tags:
- Docker
image: ubuntu:14.04
image: ubuntu:18.04
script:
- echo "pas encore de deployment"
dependencies:
@ -1148,7 +1191,7 @@ Linux client test:
- tags
tags:
- Docker
image: ubuntu:14.04
image: ubuntu:18.04
script:
- echo "pas encore de tag"
dependencies:

268
.hgignore Normal file
View file

@ -0,0 +1,268 @@
syntax: glob
# Various build directories
bin
obj
Debug
Release
ReleaseDebug
DebugFast
ReleaseDebugStatic
DebugFastStatic
# Test and application directories
screenshots
release
test
Temp
# NeL cache
*.packed_sheets
# Ryzom save
save_shard
last_loaded_char.bin
*.binprim
*.string_cache
graphs_output
default_c
# Windows compile
*.exe
*.dll
*.lib
*.obj
# Linux compile
*.a
*.la
*.lo
*.Po
*.Plo
*.o
*.so
*.so.*
*_debug
*.pc
*.gch
# Mac OS X compile
*.dylib
# Log dump files
report_refused
report_failed
exception_catched
*.stat
*.log
log.txt
# Max plugin extensions
*.dlx
*.dlm
*.dlu
# makeall build
.mode_static
# cmake build files & directories
CMakeFiles
CMakeCache.txt
cmake_install.cmake
CTestTestfile.cmake
CPackConfig.cmake
CPackSourceConfig.cmake
.libs
# Linux garbage
Makefile*
aclocal.m4
config.guess
config.sub
configure
depcomp
config.h.in
nelconfig.h.in
install-sh
ltmain.sh
missing
ylwrap
*.mk
# Visual Studio garbage
*.opensdf
UpgradeLog*.XML
_UpgradeReport_Files
BuildLog.htm
mt.dep
ipch
*.suo
*.ncb
*.user
*.ilk
*.pdb
*.aps
*.exp
*.idb
*.sdf
# Mac OS X garbage
.DS_Store
# Ryzom server garbage
aes_alias_name.cfg
aes_nagios_report.txt
aes_state.txt
*.launch_ctrl
*.state
*.start_count
# Vim and kwrite cache
*~
# Kdevelop4 garbage
*.kdev4
.kdev4
# intellij project folder
.idea/
# Python cache
*.pyd
*.pyc
# Qt compiler
moc_*.cpp
*.moc
# Misc garbage
*.rej
*.orig
*.cachefile
*.cache
*.patch
*.7z
3rdParty
.svn
thumbs.db
Thumbs.db
*.tpl.php
.SyncID
.SyncIgnore
.SyncArchive
# build
code/nel/build/*
code/nelns/build/*
code/snowballs/build/*
code/ryzom/build/*
code/build/*
code/build-2010/*
build/*
install/*
build_vc*
code/nel/tools/build_gamedata/configuration/buildsite.py
# Linux nel compile
code/nel/build/nel-config
code/nel/config.status
code/nel/include/nelconfig.h
code/nel/include/stamp-h1
code/nel/libtool
code/nel/nel-config
code/nel/samples/3d/cluster_viewer/cluster_viewer
code/nel/samples/3d/font/font
code/nel/samples/georges/georges
code/nel/samples/misc/command/command
code/nel/samples/misc/configfile/configfile
code/nel/samples/misc/debug/debug
code/nel/samples/misc/i18n/i18n
code/nel/samples/misc/log/log
code/nel/samples/misc/strings/strings
code/nel/samples/net/chat/chatclient
code/nel/samples/net/chat/chatserver
code/nel/samples/net/login_system/nls_frontend_service
code/nel/samples/net/login_system/nls_login_client
code/nel/samples/net/udp/udp_bench_client
code/nel/samples/net/udp/udp_bench_service
code/nel/samples/pacs/pacs_sample
code/nel/tools/3d/build_coarse_mesh/build_coarse_mesh
code/nel/tools/3d/build_far_bank/build_far_bank
code/nel/tools/3d/build_smallbank/build_smallbank
code/nel/tools/3d/ig_lighter/ig_lighter
code/nel/tools/3d/zone_dependencies/zone_dependencies
code/nel/tools/3d/zone_ig_lighter/zone_ig_lighter
code/nel/tools/3d/zone_lighter/zone_lighter
code/nel/tools/3d/zone_welder/zone_welder
code/nel/tools/misc/bnp_make/bnp_make
code/nel/tools/misc/disp_sheet_id/disp_sheet_id
code/nel/tools/misc/make_sheet_id/make_sheet_id
code/nel/tools/misc/xml_packer/xml_packer
code/nel/tools/pacs/build_ig_boxes/build_ig_boxes
code/nel/tools/pacs/build_indoor_rbank/build_indoor_rbank
code/nel/tools/pacs/build_rbank/build_rbank
code/ryzom/common/data_leveldesign/leveldesign/game_element/xp_table/skills.skill_tree
code/ryzom/common/data_leveldesign/leveldesign/game_element/xp_table/xptable.xp_table
code/ryzom/tools/server/sql/ryzom_admin_default_data.sql
# Linux server compile
code/ryzom/server/src/entities_game_service/entities_game_service
code/ryzom/server/src/frontend_service/frontend_service
code/ryzom/server/src/gpm_service/gpm_service
code/ryzom/server/src/input_output_service/input_output_service
code/ryzom/server/src/mirror_service/mirror_service
code/ryzom/server/src/ryzom_admin_service/ryzom_admin_service
code/ryzom/server/src/ryzom_naming_service/ryzom_naming_service
code/ryzom/server/src/ryzom_welcome_service/ryzom_welcome_service
code/ryzom/server/src/tick_service/tick_service
# WebTT temp dir
code/ryzom/tools/server/www/webtt/app/tmp
# AMS ignore
code/web/public_php/ams/is_installed
code/web/docs/ams/html
code/web/public_php/ams/templates_c
code/ryzom/tools/server/ryzom_ams/drupal
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/autoload
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/configs
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/cron
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/img
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/plugins
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/smarty
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/translations
code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/ams_lib/libinclude.php
code/ryzom/tools/server/ryzom_ams/old
#tools and external dir's
external
external_stlport
nel_tools*
ryzom_tools*
#personal projects
personal/
#Dumps
*.dmp
code/nel/tools/build_gamedata/processes/ai_wmap/ai_build_wmap.cfg
code/nel/tools/build_gamedata/processes/sheets/sheets_packer.cfg
code/nel/tools/build_gamedata/processes/rbank/build_rbank.cfg
code/nel/tools/build_gamedata/processes/zone/debug_zone_dependencies.cfg
code/web/public_php/config.php
code/web/public_php/is_installed
code/web/public_php/ams/files
code/web/public_php/db_version_lib
code/web/public_php/db_version_shard
code/web/public_php/db_version_tool
code/web/public_php/db_version_web
code/web/public_php/role_service
code/web/public_php/role_support
code/web/public_php/role_domain
code/web/public_php/db_version_ring
code/web/public_php/config_user.php
code/nel/tools/build_gamedata/processes/pz/build_world_packed_col.cfg
code/nel/tools/build_gamedata/processes/cartographer/island_screenshots.cfg

40
azure-pipelines.yml Normal file
View file

@ -0,0 +1,40 @@
jobs:
- job: ubuntu16
pool:
vmImage: 'Ubuntu-16.04'
steps:
- script: |
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install cmake build-essential -y
sudo apt-get install gcc-8 g++-8 -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 60
sudo apt-get install bison autoconf automake -y
sudo apt-get install libpng12-dev -y
sudo apt-get install libjpeg-dev -y
sudo apt-get install libgif-dev libfreetype6-dev -y
sudo apt-get install freeglut3-dev -y
sudo apt-get install liblua5.1-dev libluabind-dev libcpptest-dev -y
sudo apt-get install libogg-dev libvorbis-dev libopenal-dev -y
sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev libswscale-dev libpostproc-dev -y
sudo apt-get install libmysqlclient-dev -y
sudo apt-get install libxml2-dev -y
sudo apt-get install libcurl4-openssl-dev libssl-dev -y
sudo apt-get install libsquish-dev -y
sudo apt-get install liblzma-dev -y
sudo apt-get install libgsf-1-dev -y
displayName: 'Dependencies'
- script: |
mkdir build
cmake --version
cd build
cmake -DWITH_STATIC=ON -DWITH_NEL_TESTS=OFF -DWITH_NEL_SAMPLES=ON -DWITH_LUA51=ON -DWITH_RYZOM_SERVER=ON -DWITH_RYZOM_TOOLS=OFF -DWITH_NEL_TOOLS=ON -DWITH_LIBGSF=ON ../code
cat CMakeCache.txt
displayName: 'CMake'
- script: |
cd build
make -j`nproc`
displayName: 'Make'

24
code/.clang-format Normal file
View file

@ -0,0 +1,24 @@
---
BasedOnStyle: WebKit
AllowShortFunctionsOnASingleLine: All
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
BreakBeforeBraces: Custom
BreakConstructorInitializersBeforeComma: 'false'
NamespaceIndentation: None
PointerAlignment: Right
SortIncludes: 'false'
TabWidth: '4'
UseTab: ForIndentation
...

23
code/.editorconfig Normal file
View file

@ -0,0 +1,23 @@
; Top-most EditorConfig file
root = true
; 4-column tab indentation
[*.cpp]
indent_style = tab
indent_size = 4
[*.c]
indent_style = tab
indent_size = 4
[*.h]
indent_style = tab
indent_size = 4
[*.py]
indent_style = tab
indent_size = 4
[*.config]
indent_style = space
indent_size = 2

View file

@ -53,8 +53,8 @@ ENDIF()
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(RyzomCore CXX C)
SET(NL_VERSION_MAJOR 0)
SET(NL_VERSION_MINOR 12)
SET(NL_VERSION_MAJOR 1)
SET(NL_VERSION_MINOR 0)
SET(NL_VERSION_PATCH 0)
SET(YEAR "2004-${CURRENT_YEAR}")
SET(AUTHOR "Winch Gate and The Ryzom Core Community")
@ -91,12 +91,12 @@ NL_SETUP_NELNS_DEFAULT_OPTIONS()
NL_SETUP_RYZOM_DEFAULT_OPTIONS()
NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS()
NL_SETUP_PREFIX_PATHS()
RYZOM_SETUP_PREFIX_PATHS()
NL_SETUP_BUILD()
NL_SETUP_BUILD_FLAGS()
NL_SETUP_PREFIX_PATHS()
RYZOM_SETUP_PREFIX_PATHS()
#-----------------------------------------------------------------------------
#Platform specifics
@ -172,6 +172,7 @@ ENDIF()
IF(APPLE)
FIND_LIBRARY(CARBON_FRAMEWORK Carbon)
FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation)
FIND_LIBRARY(SECURITY_FRAMEWORK Security)
IF(APPLE_CERTIFICATE)
# Find codesign_allocate
@ -196,214 +197,10 @@ IF(APPLE)
ENDIF()
ENDIF()
MACRO(ADD_QT_LIBRARY _NAME)
IF(WIN32)
SET(_PREFIX "Qt5")
SET(_EXT "lib")
ELSE()
SET(_PREFIX "libQt5")
SET(_EXT "a")
ENDIF()
SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}.${_EXT}")
IF(EXISTS ${_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB})
ENDIF()
SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}")
IF(EXISTS ${_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB})
ENDIF()
ENDMACRO()
MACRO(ADD_QT_PLUGIN _TYPE _NAME)
IF(WIN32)
SET(_PREFIX "")
SET(_EXT "lib")
ELSE()
SET(_PREFIX "lib")
SET(_EXT "a")
ENDIF()
SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}.${_EXT}")
IF(EXISTS ${_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} optimized ${_LIB})
ENDIF()
SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}")
IF(EXISTS ${_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} debug ${_LIB})
ENDIF()
ENDMACRO()
INCLUDE(FindHelpers)
IF(WITH_QT5)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR)
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR})
FIND_PACKAGE(Qt5Core QUIET)
IF(Qt5Core_FOUND)
# Check if we are using Qt static or shared libraries
GET_TARGET_PROPERTY(_FILE Qt5::Core IMPORTED_LOCATION_RELEASE)
SET(QT_VERSION "${Qt5Core_VERSION_STRING}")
SET(_VERSION "${QT_VERSION}")
IF(_FILE MATCHES "\\.(lib|a)$")
SET(QT_STATIC ON)
SET(_VERSION "${_VERSION} static version")
ELSE()
SET(QT_STATIC OFF)
SET(_VERSION "${_VERSION} shared version")
ENDIF()
MESSAGE(STATUS "Found Qt ${_VERSION}")
# These variables are not defined with Qt5 CMake modules
SET(QT_BINARY_DIR "${_qt5Core_install_prefix}/bin")
SET(QT_LIBRARY_DIR "${_qt5Core_install_prefix}/lib")
SET(QT_PLUGINS_DIR "${_qt5Core_install_prefix}/plugins")
SET(QT_TRANSLATIONS_DIR "${_qt5Core_install_prefix}/translations")
# Fix wrong include directories with Qt 5 under Mac OS X
INCLUDE_DIRECTORIES("${_qt5Core_install_prefix}/include")
FIND_PACKAGE(Qt5Gui)
FIND_PACKAGE(Qt5Widgets)
FIND_PACKAGE(Qt5OpenGL)
FIND_PACKAGE(Qt5Xml)
FIND_PACKAGE(Qt5LinguistTools)
FIND_PACKAGE(Qt5Network)
IF(QT_STATIC)
ADD_DEFINITIONS(-DQT_STATICPLUGIN)
SET(QT_LIBRARIES Qt5::Widgets)
# Gui
SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Gui Qt5::OpenGL)
ADD_QT_LIBRARY(PrintSupport)
IF(WIN32)
SET(QT_LIBRARIES ${QT_LIBRARIES}
${WINSDK_LIBRARY_DIR}/Imm32.lib
${WINSDK_LIBRARY_DIR}/OpenGL32.lib
${WINSDK_LIBRARY_DIR}/WinMM.Lib)
ADD_QT_PLUGIN(platforms qwindows)
ADD_QT_LIBRARY(PlatformSupport)
ELSEIF(APPLE)
# Cups needs .dylib
SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib)
FIND_LIBRARY(CUPS_LIBRARY cups)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES})
FIND_LIBRARY(IOKIT_FRAMEWORK IOKit)
FIND_LIBRARY(COCOA_FRAMEWORK Cocoa)
FIND_LIBRARY(SYSTEMCONFIGURATION_FRAMEWORK SystemConfiguration)
FIND_LIBRARY(OPENGL_FRAMEWORK NAMES OpenGL)
SET(QT_LIBRARIES ${QT_LIBRARIES}
${CUPS_LIBRARY}
${COCOA_FRAMEWORK}
${SYSTEMCONFIGURATION_FRAMEWORK}
${IOKIT_FRAMEWORK}
${OPENGL_FRAMEWORK})
ADD_QT_PLUGIN(printsupport cocoaprintersupport)
ADD_QT_PLUGIN(platforms qcocoa)
ADD_QT_LIBRARY(PlatformSupport)
ELSE()
# order is very important there
ADD_QT_PLUGIN(platforms qxcb)
ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration)
ADD_QT_LIBRARY(XcbQpa)
ADD_QT_LIBRARY(PlatformSupport)
SET(QT_LIBRARIES ${QT_LIBRARIES} -lX11-xcb -lXi -lSM -lICE -lxcb -lGL -lxcb-glx)
IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a")
SET(QT_LIBRARIES ${QT_LIBRARIES} "${QT_LIBRARY_DIR}/libxcb-static.a")
ENDIF()
SET(QT_LIBRARIES ${QT_LIBRARIES} -lfontconfig)
ADD_QT_LIBRARY(DBus)
ENDIF()
ADD_QT_PLUGIN(imageformats qgif)
ADD_QT_PLUGIN(imageformats qicns)
ADD_QT_PLUGIN(imageformats qico)
ADD_QT_PLUGIN(imageformats qjpeg)
# harfbuzz is needed since Qt 5.3
IF(UNIX)
SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzzng.a")
ELSEIF(WIN32)
SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib")
ENDIF()
IF(EXISTS ${HB_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} ${HB_LIB})
ENDIF()
# freetype is needed since Qt 5.5
FIND_PACKAGE(Freetype)
IF(FREETYPE_FOUND)
SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIBRARIES})
ELSE()
IF(UNIX)
SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a")
ELSEIF(WIN32)
SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib")
ENDIF()
IF(EXISTS ${FREETYPE_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIB})
ENDIF()
ENDIF()
ADD_QT_PLUGIN(accessible qtaccessiblewidgets)
SET(QT_LIBRARIES ${QT_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARY})
# Network
SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Network Qt5::Xml)
SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES})
IF(WIN32)
SET(QT_LIBRARIES ${QT_LIBRARIES}
${WINSDK_LIBRARY_DIR}/Crypt32.lib
${WINSDK_LIBRARY_DIR}/WS2_32.Lib
${WINSDK_LIBRARY_DIR}/IPHlpApi.Lib)
ENDIF()
# Core
SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Core)
# pcre is needed since Qt 5.5
IF(UNIX)
SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a")
ELSEIF(WIN32)
SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib")
ENDIF()
IF(EXISTS ${PCRE_LIB})
SET(QT_LIBRARIES ${QT_LIBRARIES} ${PCRE_LIB})
ENDIF()
IF(APPLE)
FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre)
FIND_LIBRARY(SECURITY_FRAMEWORK Security)
SET(QT_LIBRARIES ${QT_LIBRARIES}
${PCRE_LIBRARY}
${FOUNDATION_FRAMEWORK}
${CARBON_FRAMEWORK}
${SECURITY_FRAMEWORK})
ELSEIF(UNIX)
SET(QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -ldl -lrt)
ENDIF()
ELSE()
SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core)
ENDIF()
ELSE()
MESSAGE(WARNING "Unable to find Qt 5")
ENDIF()
FIND_QT5()
ENDIF()
IF(WITH_QT)
@ -435,22 +232,41 @@ IF(WITH_NEL)
IF(CURL_STATIC)
SET(CURL_DEFINITIONS -DCURL_STATICLIB)
SET(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES})
LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES})
IF(UNIX)
IF(WIN32)
LIST(APPEND CURL_LIBRARIES Crypt32 Cryptui)
ELSE()
# CURL depends on libidn
FIND_LIBRARY(IDN_LIBRARY idn)
IF(IDN_LIBRARY)
SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${IDN_LIBRARY})
LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY})
ENDIF()
# CURL Macports version depends on libidn, libintl and libiconv too
# CURL Macports version can depend on libidn, libidn2, libintl, libpsl and libiconv too
IF(APPLE)
FIND_LIBRARY(INTL_LIBRARY intl)
IF(INTL_LIBRARY)
SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${INTL_LIBRARY})
LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY})
ENDIF()
FIND_LIBRARY(IDN2_LIBRARY idn2)
IF(IDN2_LIBRARY)
LIST(APPEND CURL_LIBRARIES ${IDN2_LIBRARY})
ENDIF()
FIND_LIBRARY(PSL_LIBRARY psl)
IF(PSL_LIBRARY)
LIST(APPEND CURL_LIBRARIES ${PSL_LIBRARY})
ENDIF()
FIND_LIBRARY(UNISTRING_LIBRARY unistring)
IF(UNISTRING_LIBRARY)
LIST(APPEND CURL_LIBRARIES ${UNISTRING_LIBRARY})
ENDIF()
LIST(APPEND CURL_LIBRARIES ${SECURITY_FRAMEWORK})
ENDIF()
ENDIF()
ENDIF()
@ -458,6 +274,19 @@ IF(WITH_NEL)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include)
ADD_SUBDIRECTORY(nel)
# Aliases for targets
SET(NELMISC_LIBRARIES nelmisc)
SET(NELNET_LIBRARIES nelnet)
SET(NELLIGO_LIBRARIES nelligo)
SET(NELGEORGES_LIBRARIES nelgeorges)
SET(NEL3D_LIBRARIES nel3d)
SET(NELGUI_LIBRARIES nelgui)
SET(NELSOUND_LIBRARIES nelsound)
ELSE()
# FIND_PACKAGE(NeL COMPONENTS 3d misc pacs sound nimp REQUIRED)
FIND_PACKAGE(NeL REQUIRED)
INCLUDE_DIRECTORIES(${NEL_INCLUDE_DIRS})
ENDIF()
IF(WITH_RYZOM)
@ -480,6 +309,10 @@ IF(WITH_STUDIO)
ADD_SUBDIRECTORY(studio)
ENDIF()
IF(WITH_PERSONAL)
ADD_SUBDIRECTORY(personal)
ENDIF()
# To build the documention, you will have to enable it
# and then do the equivalent of "make DoxygenDoc".
IF(BUILD_DOCUMENTATION)

View file

@ -11,18 +11,56 @@ if(MAXSDK_INCLUDE_DIR)
SET(MAXSDK_FIND_QUIETLY TRUE)
endif()
set(_pf_x86 "PROGRAMFILES(x86)")
FIND_PATH(MAXSDK_DIR
"include/maxversion.h"
HINTS
"$ENV{MAXSDK_DIR}"
PATHS
"$ENV{ADSK_3DSMAX_SDK_2021}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2020}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2019}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2018}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2017}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2016}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2015}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2014}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2013}/maxsdk"
"$ENV{ADSK_3DSMAX_SDK_2012}/maxsdk"
"$ENV{3DSMAX_2011_SDK_PATH}/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2021 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2020 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2019 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2018 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2017 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2016 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2015 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2014 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2013 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2012 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2011 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2010 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2009 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 2008 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3ds Max 9 SDK/maxsdk"
"$ENV{${_pf_x86}}/Autodesk/3dsMax8/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2021 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2020 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2019 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2018 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2017 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2016 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2015 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2014 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2013 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2012 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2011 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3dsMax8/maxsdk"
)
FIND_PATH(MAXSDK_INCLUDE_DIR

View file

@ -0,0 +1,173 @@
# vim: ts=2 sw=2
# - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC)
#
# Once done this will define
# FFMPEG_FOUND - System has the all required components.
# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers.
# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components.
# FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components.
#
# For each of the components it will additionaly set.
# - AVCODEC
# - AVDEVICE
# - AVFORMAT
# - AVUTIL
# - POSTPROC
# - SWSCALE
# - SWRESAMPLE
# the following variables will be defined
# <component>_FOUND - System has <component>
# <component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers
# <component>_LIBRARIES - Link these to use <component>
# <component>_DEFINITIONS - Compiler switches required for using <component>
# <component>_VERSION - The components version
#
# Copyright (c) 2006, Matthias Kretz, <kretz@kde.org>
# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz>
#
# Redistribution and use is allowed according to the terms of the BSD license.
include(FindPackageHandleStandardArgs)
if(NOT FFmpeg_FIND_COMPONENTS)
set(FFmpeg_FIND_COMPONENTS AVFORMAT AVCODEC AVUTIL)
endif()
#
### Macro: set_component_found
#
# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present.
#
macro(set_component_found _component)
if(${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS)
# message(STATUS " - ${_component} found.")
set(${_component}_FOUND TRUE)
else()
# message(STATUS " - ${_component} not found.")
endif()
endmacro()
#
### Macro: find_component
#
# Checks for the given component by invoking pkgconfig and then looking up the libraries and
# include directories.
#
macro(find_component _component _pkgconfig _library _header)
if(NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_${_component} ${_pkgconfig})
endif()
endif()
find_path(${_component}_INCLUDE_DIRS ${_header}
HINTS
${FFMPEGSDK_INC}
${PC_LIB${_component}_INCLUDEDIR}
${PC_LIB${_component}_INCLUDE_DIRS}
PATH_SUFFIXES
ffmpeg
)
find_library(${_component}_LIBRARIES NAMES ${_library}
HINTS
${FFMPEGSDK_LIB}
${PC_LIB${_component}_LIBDIR}
${PC_LIB${_component}_LIBRARY_DIRS}
)
STRING(REGEX REPLACE "/.*" "/version.h" _ver_header ${_header})
if(EXISTS "${${_component}_INCLUDE_DIRS}/${_ver_header}")
file(STRINGS "${${_component}_INCLUDE_DIRS}/${_ver_header}" version_str REGEX "^#define[\t ]+LIB${_component}_VERSION_M.*")
foreach(_str "${version_str}")
if(NOT version_maj)
string(REGEX REPLACE "^.*LIB${_component}_VERSION_MAJOR[\t ]+([0-9]*).*$" "\\1" version_maj "${_str}")
endif()
if(NOT version_min)
string(REGEX REPLACE "^.*LIB${_component}_VERSION_MINOR[\t ]+([0-9]*).*$" "\\1" version_min "${_str}")
endif()
if(NOT version_mic)
string(REGEX REPLACE "^.*LIB${_component}_VERSION_MICRO[\t ]+([0-9]*).*$" "\\1" version_mic "${_str}")
endif()
endforeach()
unset(version_str)
set(${_component}_VERSION "${version_maj}.${version_min}.${version_mic}" CACHE STRING "The ${_component} version number.")
unset(version_maj)
unset(version_min)
unset(version_mic)
endif(EXISTS "${${_component}_INCLUDE_DIRS}/${_ver_header}")
set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.")
set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.")
set_component_found(${_component})
mark_as_advanced(
${_component}_INCLUDE_DIRS
${_component}_LIBRARIES
${_component}_DEFINITIONS
${_component}_VERSION)
endmacro()
set(FFMPEGSDK $ENV{FFMPEG_HOME})
if(FFMPEGSDK)
set(FFMPEGSDK_INC "${FFMPEGSDK}/include")
set(FFMPEGSDK_LIB "${FFMPEGSDK}/lib")
endif()
# Check for all possible components.
find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h)
find_component(AVFORMAT libavformat avformat libavformat/avformat.h)
find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
find_component(AVUTIL libavutil avutil libavutil/avutil.h)
find_component(SWSCALE libswscale swscale libswscale/swscale.h)
find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h)
find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h)
# Check if the required components were found and add their stuff to the FFMPEG_* vars.
foreach(_component ${FFmpeg_FIND_COMPONENTS})
if(${_component}_FOUND)
# message(STATUS "Required component ${_component} present.")
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES})
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS})
list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS})
else()
# message(STATUS "Required component ${_component} missing.")
endif()
endforeach()
# Build the include path and library list with duplicates removed.
if(FFMPEG_INCLUDE_DIRS)
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
endif()
if(FFMPEG_LIBRARIES)
list(REMOVE_DUPLICATES FFMPEG_LIBRARIES)
endif()
# cache the vars.
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE)
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE)
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE)
mark_as_advanced(FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES FFMPEG_DEFINITIONS)
# Now set the noncached _FOUND vars for the components.
foreach(_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWRESAMPLE SWSCALE)
set_component_found(${_component})
endforeach ()
# Compile the list of required vars
set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS)
foreach(_component ${FFmpeg_FIND_COMPONENTS})
list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS)
endforeach()
# Give a nice error message if some of the required vars are missing.
find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS})

View file

@ -0,0 +1,217 @@
# - Try to find GLib2
# Once done this will define
#
# GLIB2_FOUND - system has GLib2
# GLIB2_INCLUDE_DIRS - the GLib2 include directory
# GLIB2_LIBRARIES - Link these to use GLib2
#
# HAVE_GLIB_GREGEX_H glib has gregex.h header and
# supports g_regex_match_simple
#
# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
# Copyright (c) 2006 Philippe Bernery <philippe.bernery@gmail.com>
# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
# Copyright (c) 2007 Alban Browaeys <prahal@yahoo.com>
# Copyright (c) 2008 Michael Bell <michael.bell@web.de>
# Copyright (c) 2008 Bjoern Ricks <bjoern.ricks@googlemail.com>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS )
# in cache already
SET(GLIB2_FOUND TRUE)
ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS )
INCLUDE(FindPkgConfig)
## Glib
IF ( GLIB2_FIND_REQUIRED )
SET( _pkgconfig_REQUIRED "REQUIRED" )
ELSE ( GLIB2_FIND_REQUIRED )
SET( _pkgconfig_REQUIRED "" )
ENDIF ( GLIB2_FIND_REQUIRED )
IF ( GLIB2_MIN_VERSION )
PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} )
ELSE ( GLIB2_MIN_VERSION )
PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 )
ENDIF ( GLIB2_MIN_VERSION )
IF ( PKG_CONFIG_FOUND )
IF ( GLIB2_FOUND )
SET ( GLIB2_CORE_FOUND TRUE )
ELSE ( GLIB2_FOUND )
SET ( GLIB2_CORE_FOUND FALSE )
ENDIF ( GLIB2_FOUND )
ENDIF ( PKG_CONFIG_FOUND )
# Look for glib2 include dir and libraries w/o pkgconfig
IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND )
FIND_PATH(
_glibconfig_include_DIR
NAMES
glibconfig.h
PATHS
/opt/gnome/lib64
/opt/gnome/lib
/opt/lib/
/opt/local/lib
/sw/lib/
/usr/lib64
/usr/lib
/usr/local/include
${CMAKE_LIBRARY_PATH}
PATH_SUFFIXES
glib-2.0/include
)
FIND_PATH(
_glib2_include_DIR
NAMES
glib.h
PATHS
/opt/gnome/include
/opt/local/include
/sw/include
/usr/include
/usr/local/include
PATH_SUFFIXES
glib-2.0
)
#MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}")
FIND_LIBRARY(
_glib2_link_DIR
NAMES
glib-2.0
glib
PATHS
/opt/gnome/lib
/opt/local/lib
/sw/lib
/usr/lib
/usr/local/lib
)
IF ( _glib2_include_DIR AND _glib2_link_DIR )
SET ( _glib2_FOUND TRUE )
ENDIF ( _glib2_include_DIR AND _glib2_link_DIR )
IF ( _glib2_FOUND )
SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} )
SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} )
SET ( GLIB2_CORE_FOUND TRUE )
ELSE ( _glib2_FOUND )
SET ( GLIB2_CORE_FOUND FALSE )
ENDIF ( _glib2_FOUND )
# Handle dependencies
# libintl
IF ( NOT LIBINTL_FOUND )
FIND_PATH(LIBINTL_INCLUDE_DIR
NAMES
libintl.h
PATHS
/opt/gnome/include
/opt/local/include
/sw/include
/usr/include
/usr/local/include
)
FIND_LIBRARY(LIBINTL_LIBRARY
NAMES
intl
PATHS
/opt/gnome/lib
/opt/local/lib
/sw/lib
/usr/local/lib
/usr/lib
)
IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR)
SET (LIBINTL_FOUND TRUE)
ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR)
ENDIF ( NOT LIBINTL_FOUND )
# libiconv
IF ( NOT LIBICONV_FOUND )
FIND_PATH(LIBICONV_INCLUDE_DIR
NAMES
iconv.h
PATHS
/opt/gnome/include
/opt/local/include
/opt/local/include
/sw/include
/sw/include
/usr/local/include
/usr/include
PATH_SUFFIXES
glib-2.0
)
FIND_LIBRARY(LIBICONV_LIBRARY
NAMES
iconv
PATHS
/opt/gnome/lib
/opt/local/lib
/sw/lib
/usr/lib
/usr/local/lib
)
IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR)
SET (LIBICONV_FOUND TRUE)
ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR)
ENDIF ( NOT LIBICONV_FOUND )
IF (LIBINTL_FOUND)
SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY})
SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR})
ENDIF (LIBINTL_FOUND)
IF (LIBICONV_FOUND)
SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY})
SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR})
ENDIF (LIBICONV_FOUND)
ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND )
##
IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
SET (GLIB2_FOUND TRUE)
ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
IF (GLIB2_FOUND)
IF (NOT GLIB2_FIND_QUIETLY)
MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}")
ENDIF (NOT GLIB2_FIND_QUIETLY)
ELSE (GLIB2_FOUND)
IF (GLIB2_FIND_REQUIRED)
MESSAGE (SEND_ERROR "Could not find GLib2")
ENDIF (GLIB2_FIND_REQUIRED)
ENDIF (GLIB2_FOUND)
# show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view
MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES)
MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY)
MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY)
ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS)
IF ( GLIB2_FOUND )
# Check if system has a newer version of glib
# which supports g_regex_match_simple
INCLUDE( CheckIncludeFiles )
SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} )
CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H )
# Reset CMAKE_REQUIRED_INCLUDES
SET( CMAKE_REQUIRED_INCLUDES "" )
ENDIF( GLIB2_FOUND )

View file

@ -0,0 +1,51 @@
# - Try to find GObject2
# Find GObject2 headers, libraries and the answer to all questions.
#
# GOBJECT2_FOUND True if GOBJECT2 got found
# GOBJECT2_INCLUDE_DIRS Location of GOBJECT2 headers
# GOBJECT2_LIBRARIES List of libraries to use GOBJECT2
#
# Copyright (c) 2008 Bjoern Ricks <bjoern.ricks@googlemail.com>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
INCLUDE( FindPkgConfig )
IF ( GOBJECT2_FIND_REQUIRED )
SET( _pkgconfig_REQUIRED "REQUIRED" )
ELSE( GOBJECT2_FIND_REQUIRED )
SET( _pkgconfig_REQUIRED "" )
ENDIF ( GOBJECT2_FIND_REQUIRED )
IF ( GOBJECT2_MIN_VERSION )
PKG_SEARCH_MODULE( GOBJECT2 ${_pkgconfig_REQUIRED} gobject-2.0>=${GOBJECT2_MIN_VERSION} )
ELSE ( GOBJECT2_MIN_VERSION )
PKG_SEARCH_MODULE( GOBJECT2 ${_pkgconfig_REQUIRED} gobject-2.0 )
ENDIF ( GOBJECT2_MIN_VERSION )
IF( NOT GOBJECT2_FOUND AND NOT PKG_CONFIG_FOUND )
FIND_PATH( GOBJECT2_INCLUDE_DIRS gobject/gobject.h PATH_SUFFIXES glib-2.0)
FIND_LIBRARY( GOBJECT2_LIBRARIES gobject-2.0 )
# Report results
IF ( GOBJECT2_LIBRARIES AND GOBJECT2_INCLUDE_DIRS )
SET( GOBJECT2_FOUND 1 )
IF ( NOT GOBJECT2_FIND_QUIETLY )
MESSAGE( STATUS "Found GOBJECT2: ${GOBJECT2_LIBRARIES}" )
ENDIF ( NOT GOBJECT2_FIND_QUIETLY )
ELSE ( GOBJECT2_LIBRARIES AND GOBJECT2_INCLUDE_DIRS )
IF ( GOBJECT2_FIND_REQUIRED )
MESSAGE( SEND_ERROR "Could NOT find GOBJECT2" )
ELSE ( GOBJECT2_FIND_REQUIRED )
IF ( NOT GOBJECT2_FIND_QUIETLY )
MESSAGE( STATUS "Could NOT find GOBJECT2" )
ENDIF ( NOT GOBJECT2_FIND_QUIETLY )
ENDIF ( GOBJECT2_FIND_REQUIRED )
ENDIF ( GOBJECT2_LIBRARIES AND GOBJECT2_INCLUDE_DIRS )
ENDIF( NOT GOBJECT2_FOUND AND NOT PKG_CONFIG_FOUND )
MARK_AS_ADVANCED( GOBJECT2_LIBRARIES GOBJECT2_INCLUDE_DIRS )

View file

@ -0,0 +1,959 @@
MACRO(CONVERT_NUMBER_VERSION _VERSION_NUMBER _BASE _OUT)
SET(${_OUT})
SET(_NUMBER ${_VERSION_NUMBER})
WHILE(_NUMBER GREATER 0)
MATH(EXPR _TEMP "${_NUMBER} % ${_BASE}")
LIST(APPEND ${_OUT} ${_TEMP})
MATH(EXPR _NUMBER "${_NUMBER} / ${_BASE}")
ENDWHILE()
ENDMACRO(CONVERT_NUMBER_VERSION)
FUNCTION(JOIN VALUES GLUE OUTPUT)
STRING(REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")
STRING(REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping
SET(${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
ENDFUNCTION()
MACRO(PARSE_VERSION_OTHER FILENAME)
IF(EXISTS ${FILENAME})
SET(_FILTER_ARRAY ${ARGN})
JOIN("${_FILTER_ARRAY}" "|" _FILTER_REGEX)
FILE(STRINGS ${FILENAME} _FILE REGEX "(${_FILTER_REGEX})[: \t=\(\)\"]+([0-9.]+)")
IF(_FILE)
FOREACH(_LINE ${_FILE})
FOREACH(_VAR ${_FILTER_ARRAY})
IF("${${_VAR}}" STREQUAL "")
STRING(REGEX REPLACE "^.*${_VAR}[: \t=\(\)\"]+([0-9.]+).*$" "\\1" ${_VAR} "${_LINE}")
IF(${_VAR} STREQUAL "${_LINE}")
SET(${_VAR})
ENDIF()
IF(NOT ${_VAR} AND NOT STREQUAL "0")
SET(${_VAR} 0)
ENDIF()
ENDIF()
ENDFOREACH()
ENDFOREACH()
ENDIF()
ENDIF()
ENDMACRO()
# macro to define FIND_PACKAGE options with a different package name
MACRO(FIX_PACKAGE_OPTIONS OLDNAME NEWNAME)
# append other options if needed
SET(_OPTIONS COMPONENTS REQUIRED QUIETLY)
# process each options
FOREACH(_OPTION ${_OPTIONS})
SET(OLD_OPTION ${OLDNAME}_FIND_${_OPTION})
IF(DEFINED )
SET(NEW_OPTION ${NEWNAME}_FIND_${_OPTION})
SET(${NEW_OPTION} ${OLD_OPTION})
ENDIF()
ENDFOREACH()
ENDMACRO()
MACRO(FIND_PACKAGE_HELPER NAME INCLUDE)
# Looks for a directory containing NAME.
#
# NAME is the name of the library, lowercase and uppercase can be mixed
# It should be EXACTLY (same case) the same part as XXXX in FindXXXX.cmake
#
# INCLUDE is the file to check for includes
#
# Following parameters are optional variables and must be prefixed by:
#
# RELEASE is the list of libraries to check in release mode
# DEBUG is the list of libraries to check in debug mode
# SUFFIXES is the PATH_SUFFIXES to check for include file
# QUIET don't display anything
# VERBOSE display more details if not found
# REQUIRED throw an error if not found
# DIR is the base directory where to look for
#
# The first match will be used in the specified order and next matches will be ignored
#
# The following values are defined
# NAME_INCLUDE_DIR - where to find NAME
# NAME_LIBRARIES - link against these to use NAME
# NAME_FOUND - True if NAME is available.
SET(_PARAMS ${ARGN})
SET(_RELEASE_LIBRARIES)
SET(_DEBUG_LIBRARIES)
SET(_SUFFIXES)
SET(_BASE_DIRECTORIES)
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG OFF)
SET(_IS_SUFFIXES OFF)
SET(_IS_VERBOSE OFF)
SET(_IS_DIR OFF)
IF(_PARAMS)
FOREACH(_PARAM ${_PARAMS})
IF(_PARAM STREQUAL "RELEASE")
SET(_IS_RELEASE ON)
SET(_IS_DEBUG OFF)
SET(_IS_SUFFIXES OFF)
SET(_IS_DIR OFF)
ELSEIF(_PARAM STREQUAL "DEBUG")
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG ON)
SET(_IS_SUFFIXES OFF)
SET(_IS_DIR OFF)
ELSEIF(_PARAM STREQUAL "SUFFIXES")
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG OFF)
SET(_IS_DIR OFF)
SET(_IS_SUFFIXES ON)
ELSEIF(_PARAM STREQUAL "QUIET")
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG OFF)
SET(_IS_SUFFIXES OFF)
SET(_IS_DIR OFF)
SET(${NAME}_FIND_QUIETLY ON)
ELSEIF(_PARAM STREQUAL "VERBOSE")
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG OFF)
SET(_IS_SUFFIXES OFF)
SET(_IS_DIR OFF)
SET(_IS_VERBOSE ON)
ELSEIF(_PARAM STREQUAL "REQUIRED")
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG OFF)
SET(_IS_SUFFIXES OFF)
SET(_IS_DIR OFF)
SET(${NAME}_FIND_REQUIRED ON)
ELSEIF(_PARAM STREQUAL "DIR")
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG OFF)
SET(_IS_SUFFIXES OFF)
SET(_IS_DIR ON)
ELSE()
IF(_IS_RELEASE)
LIST(APPEND _RELEASE_LIBRARIES ${_PARAM})
ELSEIF(_IS_DEBUG)
LIST(APPEND _DEBUG_LIBRARIES ${_PARAM})
ELSEIF(_IS_SUFFIXES)
LIST(APPEND _SUFFIXES ${_PARAM})
ELSEIF(_IS_DIR)
LIST(APPEND _BASE_DIRECTORIES ${_PARAM})
ELSE()
MESSAGE(STATUS "parameter ${_PARAM} with no prefix")
ENDIF()
ENDIF()
ENDFOREACH()
ENDIF()
# Fixes names if invalid characters are found
IF("${NAME}" MATCHES "^[a-zA-Z0-9]+$")
SET(_NAME_FIXED ${NAME})
ELSE()
# if invalid characters are detected, replace them by valid ones
STRING(REPLACE "+" "p" _NAME_FIXED ${NAME})
ENDIF()
# Create uppercase and lowercase versions of NAME
STRING(TOUPPER ${NAME} _UPNAME)
STRING(TOLOWER ${NAME} _LOWNAME)
STRING(TOUPPER ${_NAME_FIXED} _UPNAME_FIXED)
STRING(TOLOWER ${_NAME_FIXED} _LOWNAME_FIXED)
SET(_SUFFIXES ${_SUFFIXES} ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME})
# Don't use pkg-config
# IF(NOT WIN32 AND NOT IOS)
# FIND_PACKAGE(PkgConfig QUIET)
# SET(_MODULES ${_LOWNAME} ${_RELEASE_LIBRARIES})
# LIST(REMOVE_DUPLICATES _MODULES)
# IF(PKG_CONFIG_EXECUTABLE)
# PKG_SEARCH_MODULE(PKG_${_NAME_FIXED} QUIET ${_MODULES})
# ENDIF()
# ENDIF()
SET(_INCLUDE_PATHS)
SET(_LIBRARY_PATHS)
# Check for root directories passed to CMake with -DXXX_DIR=...
IF(DEFINED ${_UPNAME_FIXED}_DIR)
SET(_TMP ${${_UPNAME_FIXED}_DIR})
GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE)
LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP})
LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})
IF(_IS_VERBOSE)
MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")
ENDIF()
ENDIF()
IF(DEFINED ${_UPNAME}_DIR)
SET(_TMP ${${_UPNAME}_DIR})
LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP})
LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})
IF(_IS_VERBOSE)
MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")
ENDIF()
ENDIF()
IF(_BASE_DIRECTORIES)
FOREACH(_DIR ${_BASE_DIRECTORIES})
IF(_DIR)
LIST(APPEND _INCLUDE_PATHS ${_DIR}/include ${_DIR})
LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX})
IF(_IS_VERBOSE)
MESSAGE(STATUS "Using ${_DIR} as root directory")
ENDIF()
ENDIF()
ENDFOREACH()
ENDIF()
IF(UNIX)
# Append UNIX standard include paths
SET(_UNIX_INCLUDE_PATHS)
# Append multiarch include paths
IF(CMAKE_LIBRARY_ARCHITECTURE)
LIST(APPEND _UNIX_INCLUDE_PATHS
/usr/local/include/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/include/${CMAKE_LIBRARY_ARCHITECTURE})
ENDIF()
LIST(APPEND _UNIX_INCLUDE_PATHS
/usr/local/include
/usr/include
/sw/include
/opt/local/include
/opt/csw/include
/opt/include)
ENDIF()
IF(_IS_VERBOSE)
MESSAGE(STATUS "Searching header ${INCLUDE} in: ${_INCLUDE_PATHS} with suffixes ${_SUFFIXES}")
ENDIF()
# Search for include directory
FIND_PATH(${_UPNAME_FIXED}_INCLUDE_DIR
NAMES ${INCLUDE}
HINTS
${PKG_${_NAME_FIXED}_INCLUDE_DIRS}
${_INCLUDE_PATHS}
$ENV{${_UPNAME}_DIR}/include
$ENV{${_UPNAME_FIXED}_DIR}/include
$ENV{${_UPNAME}_DIR}
$ENV{${_UPNAME_FIXED}_DIR}
PATHS
${_UNIX_INCLUDE_PATHS}
PATH_SUFFIXES
${_SUFFIXES}
DOC "Include path for ${NAME}"
)
IF(_IS_VERBOSE)
IF(${_UPNAME_FIXED}_INCLUDE_DIR)
MESSAGE(STATUS "${INCLUDE} found in ${${_UPNAME_FIXED}_INCLUDE_DIR}")
ELSE()
MESSAGE(STATUS "${INCLUDE} not found")
ENDIF()
ENDIF()
# Append environment variables XXX_DIR
LIST(APPEND _LIBRARY_PATHS
$ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX}
$ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX})
IF(UNIX)
SET(_UNIX_LIBRARY_PATHS)
# Append multiarch libraries paths
IF(CMAKE_LIBRARY_ARCHITECTURE)
LIST(APPEND _UNIX_LIBRARY_PATHS
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})
ENDIF()
# Append UNIX standard libraries paths
LIST(APPEND _UNIX_LIBRARY_PATHS
/usr/local/lib
/usr/lib
/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib${LIB_SUFFIX})
ENDIF()
LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED})
LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d)
# Under Windows, some libs may need the lib prefix
IF(WIN32)
SET(_LIBS ${_RELEASE_LIBRARIES})
FOREACH(_LIB ${_LIBS})
LIST(APPEND _RELEASE_LIBRARIES lib${_LIB})
ENDFOREACH()
SET(_LIBS ${_DEBUG_LIBRARIES})
FOREACH(_LIB ${_LIBS})
LIST(APPEND _DEBUG_LIBRARIES lib${_LIB})
ENDFOREACH()
ENDIF()
LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES)
LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES)
# Search for release library
FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE
NAMES
${_RELEASE_LIBRARIES}
HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}
PATHS
${_LIBRARY_PATHS}
${_UNIX_LIBRARY_PATHS}
NO_CMAKE_SYSTEM_PATH
)
IF(_IS_VERBOSE)
IF(${_UPNAME_FIXED}_LIBRARY_RELEASE)
MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}")
ELSE()
MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}")
ENDIF()
ENDIF()
# Search for debug library
FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG
NAMES
${_DEBUG_LIBRARIES}
HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}
PATHS
${_LIBRARY_PATHS}
${_UNIX_LIBRARY_PATHS}
NO_CMAKE_SYSTEM_PATH
)
IF(_IS_VERBOSE)
IF(${_UPNAME_FIXED}_LIBRARY_DEBUG)
MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}")
ELSE()
MESSAGE(STATUS "${NAME} debug library not found")
ENDIF()
ENDIF()
SET(${_UPNAME_FIXED}_FOUND OFF)
IF(${_UPNAME_FIXED}_INCLUDE_DIR)
# Set also _INCLUDE_DIRS
SET(${_UPNAME_FIXED}_INCLUDE_DIRS ${${_UPNAME_FIXED}_INCLUDE_DIR})
ENDIF()
# Library has been found if at least only one library and include are found
IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG)
# Release and debug libraries found
SET(${_UPNAME_FIXED}_FOUND ON)
SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG})
SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})
ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE)
# Release library found
SET(${_UPNAME_FIXED}_FOUND ON)
SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE})
SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})
ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG)
# Debug library found
SET(${_UPNAME_FIXED}_FOUND ON)
SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG})
SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG})
ENDIF()
IF(${_UPNAME_FIXED}_FOUND)
IF(NOT ${NAME}_FIND_QUIETLY)
MESSAGE(STATUS "Found ${NAME}: ${${_UPNAME_FIXED}_LIBRARIES}")
ENDIF()
ELSE()
IF(${NAME}_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Error: Unable to find ${NAME}!")
ENDIF()
IF(NOT ${NAME}_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find ${NAME}!")
ENDIF()
ENDIF()
MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG)
ENDMACRO()
MACRO(MESSAGE_VERSION_PACKAGE_HELPER NAME VERSION)
MESSAGE(STATUS "Found ${NAME} ${VERSION}: ${ARGN}")
ENDMACRO()
MACRO(FIND_LIBRARY_HELPER NAME)
# Looks for libraries.
#
# NAME is the name of the library, lowercase and uppercase can be mixed
#
# Following parameters are optional variables and must be prefixed by:
#
# RELEASE is the list of libraries to check in release mode
# DEBUG is the list of libraries to check in debug mode
# VERBOSE display more details if not found
# REQUIRED throw an error if not found
# DIR is the base directory where to look for
#
# The first match will be used in the specified order and next matches will be ignored
#
# The following values are defined
# NAME_LIBRARIES - link against these to use NAME
SET(_PARAMS ${ARGN})
SET(_RELEASE_LIBRARIES)
SET(_DEBUG_LIBRARIES)
SET(_BASE_DIRECTORIES)
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG OFF)
SET(_IS_VERBOSE OFF)
SET(_IS_DIR OFF)
IF(_PARAMS)
FOREACH(_PARAM ${_PARAMS})
IF(_PARAM STREQUAL "RELEASE")
SET(_IS_RELEASE ON)
SET(_IS_DEBUG OFF)
SET(_IS_DIR OFF)
ELSEIF(_PARAM STREQUAL "DEBUG")
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG ON)
SET(_IS_DIR OFF)
ELSEIF(_PARAM STREQUAL "VERBOSE")
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG OFF)
SET(_IS_DIR OFF)
SET(_IS_VERBOSE ON)
ELSEIF(_PARAM STREQUAL "REQUIRED")
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG OFF)
SET(_IS_DIR OFF)
SET(${NAME}_FIND_REQUIRED ON)
ELSEIF(_PARAM STREQUAL "DIR")
SET(_IS_RELEASE OFF)
SET(_IS_DEBUG OFF)
SET(_IS_DIR ON)
ELSE()
IF(_IS_RELEASE)
LIST(APPEND _RELEASE_LIBRARIES ${_PARAM})
ELSEIF(_IS_DEBUG)
LIST(APPEND _DEBUG_LIBRARIES ${_PARAM})
ELSEIF(_IS_DIR)
LIST(APPEND _BASE_DIRECTORIES ${_PARAM})
ELSE()
MESSAGE(STATUS "parameter ${_PARAM} with no prefix")
ENDIF()
ENDIF()
ENDFOREACH()
ENDIF()
# Fixes names if invalid characters are found
IF("${NAME}" MATCHES "^[a-zA-Z0-9]+$")
SET(_NAME_FIXED ${NAME})
ELSE()
# if invalid characters are detected, replace them by valid ones
STRING(REPLACE "+" "p" _NAME_FIXED ${NAME})
ENDIF()
# Create uppercase and lowercase versions of NAME
STRING(TOUPPER ${NAME} _UPNAME)
STRING(TOLOWER ${NAME} _LOWNAME)
STRING(TOUPPER ${_NAME_FIXED} _UPNAME_FIXED)
STRING(TOLOWER ${_NAME_FIXED} _LOWNAME_FIXED)
SET(_LIBRARY_PATHS)
# Check for root directories passed to CMake with -DXXX_DIR=...
IF(DEFINED ${_UPNAME_FIXED}_DIR)
SET(_TMP ${${_UPNAME_FIXED}_DIR})
GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE)
LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})
IF(_IS_VERBOSE)
MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")
ENDIF()
ENDIF()
IF(DEFINED ${_UPNAME}_DIR)
SET(_TMP ${${_UPNAME}_DIR})
LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})
IF(_IS_VERBOSE)
MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")
ENDIF()
ENDIF()
IF(_BASE_DIRECTORIES)
FOREACH(_DIR ${_BASE_DIRECTORIES})
IF(_DIR)
LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX})
IF(_IS_VERBOSE)
MESSAGE(STATUS "Using ${_DIR} as root directory")
ENDIF()
ENDIF()
ENDFOREACH()
ENDIF()
# Append environment variables XXX_DIR
LIST(APPEND _LIBRARY_PATHS
$ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX}
$ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX})
IF(UNIX)
SET(_UNIX_LIBRARY_PATHS)
# Append multiarch libraries paths
IF(CMAKE_LIBRARY_ARCHITECTURE)
LIST(APPEND _UNIX_LIBRARY_PATHS
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})
ENDIF()
# Append UNIX standard libraries paths
LIST(APPEND _UNIX_LIBRARY_PATHS
/usr/local/lib
/usr/lib
/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib${LIB_SUFFIX})
ENDIF()
LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED})
LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d)
# Under Windows, some libs may need the lib prefix
IF(WIN32)
SET(_LIBS ${_RELEASE_LIBRARIES})
FOREACH(_LIB ${_LIBS})
LIST(APPEND _RELEASE_LIBRARIES lib${_LIB})
ENDFOREACH()
SET(_LIBS ${_DEBUG_LIBRARIES})
FOREACH(_LIB ${_LIBS})
LIST(APPEND _DEBUG_LIBRARIES lib${_LIB})
ENDFOREACH()
ENDIF()
LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES)
LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES)
# Search for release library
FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE
NAMES
${_RELEASE_LIBRARIES}
HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}
PATHS
${_LIBRARY_PATHS}
${_UNIX_LIBRARY_PATHS}
NO_CMAKE_SYSTEM_PATH
)
IF(_IS_VERBOSE)
IF(${_UPNAME_FIXED}_LIBRARY_RELEASE)
MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}")
ELSE()
MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}")
ENDIF()
ENDIF()
# Search for debug library
FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG
NAMES
${_DEBUG_LIBRARIES}
HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}
PATHS
${_LIBRARY_PATHS}
${_UNIX_LIBRARY_PATHS}
NO_CMAKE_SYSTEM_PATH
)
IF(_IS_VERBOSE)
IF(${_UPNAME_FIXED}_LIBRARY_DEBUG)
MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}")
ELSE()
MESSAGE(STATUS "${NAME} debug library not found")
ENDIF()
ENDIF()
# Library has been found if at least only one library and include are found
IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG)
# Release and debug libraries found
SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG})
SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})
ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE)
# Release library found
SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE})
SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})
ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG)
# Debug library found
SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG})
SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG})
ENDIF()
MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG)
ENDMACRO()
MACRO(FIND_LIBCURL)
IF(NOT CURL_FOUND)
FIND_PACKAGE(CURL REQUIRED)
IF(WIN32 OR CURL_LIBRARY MATCHES "\\.a" OR WITH_STATIC_CURL)
SET(CURL_STATIC ON)
ELSE()
SET(CURL_STATIC OFF)
ENDIF()
IF(CURL_STATIC)
SET(CURL_DEFINITIONS -DCURL_STATICLIB)
IF(UNIX)
# CURL can depend on libidn
FIND_LIBRARY(IDN_LIBRARY idn)
IF(IDN_LIBRARY)
LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY})
ENDIF()
# CURL Macports version can depend on libidn, libintl and libiconv too
IF(APPLE)
FIND_LIBRARY(INTL_LIBRARY intl)
IF(INTL_LIBRARY)
LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY})
ENDIF()
ELSE()
# Only used by libcurl under Linux
FIND_PACKAGE(OpenSSL REQUIRED)
#IF(WIN32)
# SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib)
#ENDIF()
# Only Linux version of libcurl depends on OpenSSL
LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES})
ENDIF()
ENDIF()
ENDIF()
ENDIF()
ENDMACRO()
MACRO(FIND_LIBXML2)
IF(NOT LIBXML2_FOUND)
FIND_PACKAGE(LibXml2 REQUIRED)
IF(WIN32 OR WITH_STATIC_LIBXML2)
LIST(APPEND LIBXML2_DEFINITIONS -DLIBXML_STATIC)
ENDIF()
IF(WITH_LIBXML2_ICONV)
FIND_PACKAGE(Iconv REQUIRED)
# LIST(APPEND CURL_INCLUDE_DIRS ${ICONV_INCLUDE_DIR})
LIST(APPEND LIBXML2_LIBRARIES ${ICONV_LIBRARIES})
ENDIF()
IF(WITH_STATIC)
# libxml2 could need winsock2 library
IF(WIN32)
FIND_LIBRARY(WINSOCK2_LIB ws2_32)
IF(WINSOCK2_LIB)
LIST(APPEND LIBXML2_LIBRARIES ${WINSOCK2_LIB})
ENDIF()
FIND_LIBRARY(CRYPT32_LIB Crypt32)
IF(CRYPT32_LIB)
LIST(APPEND LIBXML2_LIBRARIES ${CRYPT32_LIB})
ENDIF()
ELSE()
# under Linux and OS X, recent libxml2 versions are linked against liblzma
FIND_PACKAGE(LibLZMA)
IF(LIBLZMA_LIBRARIES)
LIST(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES})
ENDIF()
ENDIF()
ENDIF()
ENDIF()
ENDMACRO()
MACRO(ADD_QT_LIBRARY _NAME)
IF(WIN32)
SET(_PREFIX "Qt5")
SET(_EXT "lib")
ELSE()
SET(_PREFIX "libQt5")
SET(_EXT "a")
ENDIF()
SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}.${_EXT}")
IF(EXISTS ${_LIB})
LIST(APPEND QT_LIBRARIES optimized ${_LIB})
ENDIF()
SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}")
IF(EXISTS ${_LIB})
LIST(APPEND QT_LIBRARIES debug ${_LIB})
ENDIF()
ENDMACRO()
MACRO(ADD_QT_PLUGIN _TYPE _NAME)
IF(WIN32)
SET(_PREFIX "")
SET(_EXT "lib")
ELSE()
SET(_PREFIX "lib")
SET(_EXT "a")
ENDIF()
SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}.${_EXT}")
IF(EXISTS ${_LIB})
LIST(APPEND QT_LIBRARIES optimized ${_LIB})
ENDIF()
SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}")
IF(EXISTS ${_LIB})
LIST(APPEND QT_LIBRARIES debug ${_LIB})
ENDIF()
ENDMACRO()
MACRO(ADD_QT_SYSTEM_LIBRARY _NAME)
# Save default suffixes
SET(_OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
# Define specific suffixes
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})
# Find the library with specified suffixes
FIND_LIBRARY(${_NAME}_LIBRARY NAMES ${_NAME})
# Restore default suffixes
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_OLD_SUFFIXES})
IF(${_NAME}_LIBRARY)
MESSAGE(STATUS "Found ${${_NAME}_LIBRARY} ${_NAME}")
LIST(APPEND QT_LIBRARIES ${${_NAME}_LIBRARY})
ELSE()
MESSAGE(STATUS "Didn't find ${_NAME}")
ENDIF()
ENDMACRO()
MACRO(FIND_QT5)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR)
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR})
FIND_PACKAGE(Qt5Core QUIET)
IF(Qt5Core_FOUND)
# Check if we are using Qt static or shared libraries
GET_TARGET_PROPERTY(_FILE Qt5::Core IMPORTED_LOCATION_RELEASE)
SET(QT_VERSION "${Qt5Core_VERSION_STRING}")
SET(_VERSION "${QT_VERSION}")
IF(_FILE MATCHES "\\.(lib|a)$")
SET(QT_STATIC ON)
SET(_VERSION "${_VERSION} static version")
ELSE()
SET(QT_STATIC OFF)
SET(_VERSION "${_VERSION} shared version")
ENDIF()
MESSAGE(STATUS "Found Qt ${_VERSION}")
# These variables are not defined with Qt5 CMake modules
SET(QT_BINARY_DIR "${_qt5Core_install_prefix}/bin")
SET(QT_LIBRARY_DIR "${_qt5Core_install_prefix}/lib")
SET(QT_PLUGINS_DIR "${_qt5Core_install_prefix}/plugins")
SET(QT_TRANSLATIONS_DIR "${_qt5Core_install_prefix}/translations")
# Fix wrong include directories with Qt 5 under Mac OS X
INCLUDE_DIRECTORIES("${_qt5Core_install_prefix}/include")
FIND_PACKAGE(Qt5Gui)
FIND_PACKAGE(Qt5Widgets)
FIND_PACKAGE(Qt5OpenGL)
FIND_PACKAGE(Qt5Xml)
FIND_PACKAGE(Qt5LinguistTools)
FIND_PACKAGE(Qt5Network)
IF(QT_STATIC)
FIND_PACKAGE(PNG REQUIRED)
FIND_PACKAGE(Jpeg REQUIRED)
ADD_DEFINITIONS(-DQT_STATICPLUGIN)
SET(QT_LIBRARIES Qt5::Widgets)
# Gui
LIST(APPEND QT_LIBRARIES Qt5::Gui Qt5::OpenGL)
ADD_QT_LIBRARY(PrintSupport)
IF(WIN32)
LIST(APPEND QT_LIBRARIES
${WINSDK_LIBRARY_DIR}/Imm32.lib
${WINSDK_LIBRARY_DIR}/OpenGL32.lib
${WINSDK_LIBRARY_DIR}/WinMM.Lib)
ADD_QT_PLUGIN(platforms qwindows)
ADD_QT_LIBRARY(PlatformSupport)
ELSEIF(APPLE)
# Cups needs .dylib
SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib)
FIND_LIBRARY(CUPS_LIBRARY cups)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES})
FIND_LIBRARY(IOKIT_FRAMEWORK IOKit)
FIND_LIBRARY(COCOA_FRAMEWORK Cocoa)
FIND_LIBRARY(SYSTEMCONFIGURATION_FRAMEWORK SystemConfiguration)
FIND_LIBRARY(OPENGL_FRAMEWORK NAMES OpenGL)
LIST(APPEND QT_LIBRARIES
${CUPS_LIBRARY}
${COCOA_FRAMEWORK}
${SYSTEMCONFIGURATION_FRAMEWORK}
${IOKIT_FRAMEWORK}
${OPENGL_FRAMEWORK})
ADD_QT_PLUGIN(printsupport cocoaprintersupport)
ADD_QT_PLUGIN(platforms qcocoa)
ADD_QT_LIBRARY(PlatformSupport)
ELSE()
# order is very important there
ADD_QT_PLUGIN(platforms qxcb)
ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration)
ADD_QT_LIBRARY(XcbQpa)
ADD_QT_LIBRARY(GlxSupport)
ADD_QT_LIBRARY(ServiceSupport)
ADD_QT_LIBRARY(EdidSupport)
ADD_QT_LIBRARY(FontDatabaseSupport)
ADD_QT_LIBRARY(ThemeSupport)
ADD_QT_LIBRARY(EventDispatcherSupport)
ADD_QT_LIBRARY(PlatformSupport)
ADD_QT_LIBRARY(DBus)
IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a")
LIST(APPEND QT_LIBRARIES "${QT_LIBRARY_DIR}/libxcb-static.a")
ENDIF()
# always link these in dynamic, API never changes
ADD_QT_SYSTEM_LIBRARY(X11)
ADD_QT_SYSTEM_LIBRARY(Xmu)
ADD_QT_SYSTEM_LIBRARY(X11-xcb)
ADD_QT_SYSTEM_LIBRARY(Xi)
ADD_QT_SYSTEM_LIBRARY(SM)
ADD_QT_SYSTEM_LIBRARY(ICE)
ADD_QT_SYSTEM_LIBRARY(xcb)
ADD_QT_SYSTEM_LIBRARY(GL)
ADD_QT_SYSTEM_LIBRARY(xcb-glx)
ADD_QT_SYSTEM_LIBRARY(fontconfig)
ADD_QT_SYSTEM_LIBRARY(Xrender)
ENDIF()
ADD_QT_PLUGIN(imageformats qgif)
ADD_QT_PLUGIN(imageformats qicns)
ADD_QT_PLUGIN(imageformats qico)
ADD_QT_PLUGIN(imageformats qjpeg)
# harfbuzz is needed since Qt 5.3
IF(UNIX)
SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzzng.a")
IF(NOT EXISTS ${HB_LIB})
SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzz.a")
ENDIF()
ELSEIF(WIN32)
SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib")
ENDIF()
IF(EXISTS ${HB_LIB})
LIST(APPEND QT_LIBRARIES ${HB_LIB})
ENDIF()
# freetype is needed since Qt 5.5
FIND_PACKAGE(Freetype)
IF(FREETYPE_FOUND)
LIST(APPEND QT_LIBRARIES ${FREETYPE_LIBRARIES})
ELSE()
IF(UNIX)
SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a")
ELSEIF(WIN32)
SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib")
ENDIF()
IF(EXISTS ${FREETYPE_LIB})
LIST(APPEND QT_LIBRARIES ${FREETYPE_LIB})
ENDIF()
ENDIF()
ADD_QT_PLUGIN(accessible qtaccessiblewidgets)
LIST(APPEND QT_LIBRARIES ${PNG_LIBRARIES} ${JPEG_LIBRARY})
# Network
LIST(APPEND QT_LIBRARIES Qt5::Network Qt5::Xml)
LIST(APPEND QT_LIBRARIES ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES})
IF(WIN32)
LIST(APPEND QT_LIBRARIES
${WINSDK_LIBRARY_DIR}/Crypt32.lib
${WINSDK_LIBRARY_DIR}/WS2_32.Lib
${WINSDK_LIBRARY_DIR}/IPHlpApi.Lib)
ENDIF()
# Core
LIST(APPEND QT_LIBRARIES Qt5::Core)
# pcre is needed since Qt 5.5
IF(UNIX)
SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a")
IF(NOT EXISTS ${PCRE_LIB})
SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre2.a")
ENDIF()
ELSEIF(WIN32)
SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib")
ENDIF()
IF(EXISTS ${PCRE_LIB})
LIST(APPEND QT_LIBRARIES ${PCRE_LIB})
ENDIF()
IF(APPLE)
FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre)
FIND_LIBRARY(SECURITY_FRAMEWORK Security)
LIST(APPEND QT_LIBRARIES
${PCRE_LIBRARY}
${FOUNDATION_FRAMEWORK}
${CARBON_FRAMEWORK}
${SECURITY_FRAMEWORK})
ELSEIF(UNIX)
FIND_PACKAGE(Threads)
LIST(APPEND QT_LIBRARIES ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} -lrt)
ENDIF()
ELSE()
SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core)
ENDIF()
ELSE()
MESSAGE(WARNING "Unable to find Qt 5")
ENDIF()
ENDMACRO()

View file

@ -0,0 +1,57 @@
# - Try to find libGSF
#
# Once done this will define
#
# LIBGSF_FOUND - System has LibGSF
# LIBGSF_INCLUDE_DIR - The LibGSF include directory
# LIBGSF_LIBRARIES - The libraries needed to use LibGSF
# LIBGSF_DEFINITIONS - Compiler switches required for using LibGSF
# LIBGSF_GSF_EXECUTABLE - The archive utility
# LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE - The office files thumbnailer for the GNOME desktop
# LIBGSF_GSFVBADUMP_EXECUTABLE - The utility to extract Visual Basic for Applications macros
# Copyright (c) 2009, Pau Garcia i Quiles <pgquiles@elpauer.org>
# Based off FindLibXml2.cmake from CMake 2.6.4 by Alexander Neundorf <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF (LIBGSF_INCLUDE_DIR AND LIBGSF_LIBRARIES)
# in cache already
SET(LIBGSF_FIND_QUIETLY TRUE)
ENDIF (LIBGSF_INCLUDE_DIR AND LIBGSF_LIBRARIES)
IF (NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_LIBGSF libgsf-1)
SET(LIBGSF_DEFINITIONS ${PC_LIBGSF_CFLAGS_OTHER})
ENDIF (NOT WIN32)
FIND_PATH(LIBGSF_INCLUDE_DIR gsf/gsf.h
HINTS
${PC_LIBGSF_INCLUDEDIR}
${PC_LIBGSF_INCLUDE_DIRS}
PATH_SUFFIXES libgsf-1
)
FIND_LIBRARY(LIBGSF_LIBRARIES NAMES gsf-1 libgsf-1
HINTS
${PC_LIBGSF_LIBDIR}
${PC_LIBGSF_LIBRARY_DIRS}
)
FIND_PROGRAM(LIBGSF_GSF_EXECUTABLE gsf)
FIND_PROGRAM(LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE gsf-office-thumbnailer)
FIND_PROGRAM(LIBGSF_GSFVBADUMP_EXECUTABLE gsf-vba-dump)
INCLUDE(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBGSF_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBGSF DEFAULT_MSG LIBGSF_LIBRARIES LIBGSF_INCLUDE_DIR)
MARK_AS_ADVANCED(LIBGSF_INCLUDE_DIR LIBGSF_LIBRARIES LIBGSF_GSF_EXECUTABLE LIBGSF_GSFOFFICETHUMBNAILER_EXECUTABLE LIBGSF_GSFVBADUMP_EXECUTABLE )

View file

@ -16,10 +16,12 @@ IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
ELSE()
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
PATH_SUFFIXES mysql
PATH_SUFFIXES mysql mariadb
PATHS
/usr/include/mysql
/usr/include/mariadb
/usr/local/include/mysql
/usr/local/include/mariadb
/opt/local/include/mysql5/mysql
/opt/local/include/mysql55/mysql
/opt/local/include/mysql51/mysql
@ -27,28 +29,29 @@ ELSE()
$ENV{SystemDrive}/MySQL/*/include)
IF(WIN32 AND MSVC)
FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES libmysql mysqlclient
FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES libmysql mysqlclient libmariadb mariadbclient
PATHS
$ENV{ProgramFiles}/MySQL/*/lib/opt
$ENV{SystemDrive}/MySQL/*/lib/opt)
FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES libmysqld mysqlclientd
FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES libmysqld mysqlclientd libmariadb mariadbclient
PATHS
$ENV{ProgramFiles}/MySQL/*/lib/opt
$ENV{SystemDrive}/MySQL/*/lib/opt)
ELSE()
FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient
FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient mariadbclient
PATHS
/usr/lib
/usr/local/lib
/usr/lib/mariadb
/usr/lib/mysql
/usr/local/lib/mysql
/usr/local/lib/mariadb
/opt/local/lib/mysql5/mysql
/opt/local/lib/mysql55/mysql
/opt/local/lib/mysql51/mysql
)
FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES mysqlclientd
FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES mysqlclientd mariadbclientd
PATHS
/usr/lib
/usr/local/lib
@ -80,6 +83,10 @@ ELSE()
IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
SET(MYSQL_FOUND TRUE)
MESSAGE(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}")
IF (MYSQL_LIBRARIES MATCHES "libmariadb" OR MYSQL_LIBRARIES MATCHES "mariadbclient")
SET(MARIADB_FOUND TRUE)
MESSAGE(STATUS "Found MariaDB.")
ENDIF()
ELSE()
SET(MYSQL_FOUND FALSE)
MESSAGE(STATUS "MySQL not found.")

View file

@ -0,0 +1,398 @@
# NEL_DIR can be specified as root directory
# Returned variables
# NELDRIVER_XXX_BINARY_DEBUG
# NELDRIVER_XXX_BINARY_RELEASE
# NELDRIVER_XXX_LIBRARY_DEBUG
# NELDRIVER_XXX_LIBRARY_RELEASE
# NELDRIVER_XXX_FOUND
# NEL_DEFINITIONS
# NEL_INCLUDE_DIR
# NEL_INCLUDE_DIRS
# NEL_LIBRARIES
# NELXXX_FOUND
# NELXXX_LIBRARIES
INCLUDE(FindHelpers)
# Init all variables we'll set
SET(NEL_LIBRARIES)
SET(NEL_INCLUDE_DIR)
SET(NEL_INCLUDE_DIRS)
SET(NEL_VERSION)
SET(NEL_STATIC)
SET(NEL_STATIC_DRIVERS)
SET(NEL_VERSION_MAJOR)
SET(NEL_VERSION_MINOR)
SET(NEL_VERSION_PATCH)
SET(NEL_REVISION)
SET(NEL_VERSION)
SET(NEL_MODULES_FOUND)
SET(NEL_MODULES_AVAILABLE 3d georges gui ligo logic net pacs sound) # cegui pipeline
SET(NEL_DRIVERS_FOUND)
SET(NEL_DRIVERS_AVAILABLE opengl opengles direct3d dsound fmod openal xaudio2)
SET(NELMISC_FIND_REQUIRED ${NeL_FIND_REQUIRED})
# Force search of NELMISC
FIND_PACKAGE_HELPER(nelmisc nel/misc/types_nl.h RELEASE nelmisc_r nelmisc DEBUG nelmisc_d DIR ${NEL_DIR} VERBOSE QUIET)
IF(NELMISC_FOUND)
# define NEL_DIR if not specified
IF(NOT NEL_DIR)
GET_FILENAME_COMPONENT(NEL_DIR ${NELMISC_INCLUDE_DIR}/.. ABSOLUTE)
ENDIF()
# Aliases for include directory
SET(NEL_INCLUDE_DIR ${NELMISC_INCLUDE_DIR})
SET(NEL_INCLUDE_DIRS ${NEL_INCLUDE_DIR})
MESSAGE(STATUS "Found NeL headers in ${NEL_INCLUDE_DIR}")
GET_FILENAME_COMPONENT(NEL_LIBRARY_DIR ${NELMISC_LIBRARY} DIRECTORY)
MESSAGE(STATUS "Found NeL library in ${NEL_LIBRARY_DIR}")
# TODO: implement static version checks for Windows
# static libraries
IF(UNIX)
GET_FILENAME_COMPONENT(_LIBEXT ${NELMISC_LIBRARY} EXT)
IF(_LIBEXT STREQUAL ".a")
SET(NEL_STATIC ON)
MESSAGE(STATUS "NeL is using static libraries")
ENDIF()
ENDIF()
IF(WIN32)
SET(NELDRIVER_DIRS_TO_CHECK
${NEL_DIR}/bin${LIB_SUFFIX}
${NEL_DIR}
)
ELSE()
SET(NELDRIVER_DIRS_TO_CHECK
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}/nel
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/nel
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/lib/nel
/usr/lib
)
ENDIF()
# check for static drivers
FOREACH(_DRIVER ${NEL_DRIVERS_AVAILABLE})
IF(WIN32)
SET(_DRIVER_RELASE_FILE "nel_drv_${_DRIVER}_win_r")
SET(_DRIVER_DEBUG_FILE "nel_drv_${_DRIVER}_win_d")
SET(_DRIVER_SHARED_EXT dll)
SET(_DRIVER_STATIC_EXT lib)
ELSE()
SET(_DRIVER_RELEASE_FILE "nel_drv_${_DRIVER}")
SET(_DRIVER_DEBUG_FILE)
SET(_DRIVER_SHARED_EXT so)
SET(_DRIVER_STATIC_EXT a)
ENDIF()
STRING(TOUPPER ${_DRIVER} _UPDRIVER)
FOREACH(_DIR ${NELDRIVER_DIRS_TO_CHECK})
SET(_FOUND OFF)
IF(_DRIVER_RELASE_FILE)
SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_SHARED_EXT}")
IF(EXISTS ${_FILE})
SET(NELDRIVER_${_UPDRIVER}_BINARY_RELEASE ${_FILE})
MESSAGE(STATUS "Found NeL release shared driver ${_DRIVER}: ${_FILE}")
SET(NEL_STATIC_DRIVERS OFF)
IF(NOT NEL_DRIVER_DIR)
SET(NEL_DRIVER_DIR ${_DIR})
ENDIF()
ENDIF()
SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_STATIC_EXT}")
IF(EXISTS ${_FILE})
SET(NELDRIVER_${_UPDRIVER}_LIBRARY_RELEASE ${_FILE})
MESSAGE(STATUS "Found NeL release static driver ${_DRIVER}: ${_FILE}")
SET(NEL_STATIC_DRIVERS ON)
IF(NOT NEL_DRIVER_DIR)
SET(NEL_DRIVER_DIR ${_DIR})
ENDIF()
ENDIF()
ENDIF()
IF(_DRIVER_DEBUG_FILE)
SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_SHARED_EXT}")
IF(EXISTS ${_FILE})
SET(NELDRIVER_${_UPDRIVER}_BINARY_DEBUG ${_FILE})
MESSAGE(STATUS "Found NeL debug shared driver ${_DRIVER}: ${_FILE}")
SET(NEL_STATIC_DRIVERS OFF)
IF(NOT NEL_DRIVER_DIR)
SET(NEL_DRIVER_DIR ${_DIR})
ENDIF()
ENDIF()
SET(_FILE "${_DIR}/${_DRIVER_RELASE_FILE}.${_DRIVER_STATIC_EXT}")
IF(EXISTS ${_FILE})
SET(NELDRIVER_${_UPDRIVER}_LIBRARY_DEBUG ${_FILE})
MESSAGE(STATUS "Found NeL debug static driver ${_DRIVER}: ${_FILE}")
SET(NEL_STATIC_DRIVERS ON)
IF(NOT NEL_DRIVER_DIR)
SET(NEL_DRIVER_DIR ${_DIR})
ENDIF()
ENDIF()
IF(_FOUND)
SET(NELDRIVER_${_UPDRIVER}_FOUND ON)
LIST(APPEND NEL_DRIVERS_FOUND ${_DRIVER})
ENDIF()
ENDIF()
ENDFOREACH()
ENDFOREACH()
MESSAGE(STATUS "Found NeL driver in ${NEL_DRIVER_DIR}")
PARSE_VERSION_OTHER(${NEL_INCLUDE_DIR}/nel/misc/version_nl.h NL_VERSION_MAJOR NL_VERSION_MINOR NL_VERSION_PATCH NL_REVISION)
SET(NEL_VERSION_MAJOR ${NL_VERSION_MAJOR})
SET(NEL_VERSION_MINOR ${NL_VERSION_MINOR})
SET(NEL_VERSION_PATCH ${NL_VERSION_PATCH})
SET(NEL_REVISION ${NL_REVISION})
IF(NOT NEL_VERSION)
IF(NEL_VERSION_MAJOR OR NEL_VERSION_MINOR} OR NEL_VERSION_PATCH)
SET(NEL_VERSION "${NEL_VERSION_MAJOR}.${NEL_VERSION_MINOR}.${NEL_VERSION_PATCH}")
ELSE()
SET(NEL_VERSION "0.5.0")
ENDIF()
IF(NEL_REVISION)
SET(NEL_VERSION "${NEL_VERSION}.${NEL_REVISION}")
ENDIF()
ENDIF()
FIND_PACKAGE(PNG REQUIRED)
IF(PNG_FOUND)
LIST(APPEND NELMISC_LIBRARIES ${PNG_LIBRARIES})
ENDIF()
FIND_PACKAGE(Jpeg REQUIRED)
IF(JPEG_FOUND)
LIST(APPEND NELMISC_LIBRARIES ${JPEG_LIBRARY})
ENDIF()
FIND_PACKAGE(GIF)
IF(GIF_FOUND)
LIST(APPEND NELMISC_LIBRARIES ${GIF_LIBRARY})
ENDIF()
FIND_LIBXML2()
IF(LIBXML2_FOUND)
LIST(APPEND NELMISC_LIBRARIES ${LIBXML2_LIBRARIES})
ENDIF()
LIST(REMOVE_ITEM NeL_FIND_COMPONENTS misc)
LIST(APPEND NEL_MODULES_FOUND misc)
LIST(APPEND NEL_LIBRARIES ${NELMISC_LIBRARIES})
ENDIF()
IF(NOT NeL_FIND_COMPONENTS)
SET(NeL_FIND_COMPONENTS ${NEL_MODULES_AVAILABLE})
# We can skip not installed modules
SET(NeL_FIND_REQUIRED OFF)
ENDIF()
FOREACH(COMPONENT ${NeL_FIND_COMPONENTS})
SET(_NAME NeL${COMPONENT})
STRING(TOUPPER ${_NAME} _UPNAME)
# module is required
SET(${_NAME}_FIND_REQUIRED ${NeL_FIND_REQUIRED})
IF(COMPONENT STREQUAL "3d")
SET(HEADER_FILE shape.h)
# ELSEIF(COMPONENT STREQUAL "cegui")
# SET(HEADER_FILE shape.h)
ELSEIF(COMPONENT STREQUAL "georges")
SET(HEADER_FILE form.h)
ELSEIF(COMPONENT STREQUAL "gui")
SET(HEADER_FILE reflect.h)
ELSEIF(COMPONENT STREQUAL "ligo")
SET(HEADER_FILE primitive.h)
ELSEIF(COMPONENT STREQUAL "logic")
SET(HEADER_FILE logic_state.h)
ELSEIF(COMPONENT STREQUAL "net")
SET(HEADER_FILE sock.h)
ELSEIF(COMPONENT STREQUAL "pacs")
SET(HEADER_FILE primitive_block.h)
# ELSEIF(COMPONENT STREQUAL "pipeline")
# SET(HEADER_FILE shape.h)
ELSEIF(COMPONENT STREQUAL "sound")
SET(HEADER_FILE shape.h)
ELSE()
SET(HEADER_FILE)
ENDIF()
# display if a component has a wrong name
IF(NOT HEADER_FILE)
MESSAGE(STATUS "NeL module ${COMPONENT} not supported, ignoring it...")
CONTINUE()
ENDIF()
FIND_PACKAGE_HELPER(${_NAME} nel/${COMPONENT}/${HEADER_FILE}
RELEASE nel${COMPONENT}_r nel${COMPONENT}
DEBUG nel${COMPONENT}_d
QUIET)
IF(${_UPNAME}_FOUND)
LIST(APPEND NEL_MODULES_FOUND ${COMPONENT})
IF(COMPONENT STREQUAL "3d")
IF(NEL_STATIC)
# 3rd party dependencies
FIND_PACKAGE(Freetype REQUIRED)
IF(FREETYPE_FOUND)
LIST(APPEND ${_UPNAME}_LIBRARIES ${FREETYPE_LIBRARIES})
ENDIF()
# Append static 3D drivers
IF(NEL_STATIC_DRIVERS)
# Direct3D driver (only under Windows)
IF(WIN32)
IF(NELDRIVER_DIRECT3D_LIBRARY_DEBUG)
LIST(APPEND ${_UPNAME}_LIBRARIES debug ${NELDRIVER_DIRECT3D_LIBRARY_DEBUG})
ENDIF()
IF(NELDRIVER_DIRECT3D_LIBRARY_RELEASE)
LIST(APPEND ${_UPNAME}_LIBRARIES optimized ${NELDRIVER_DIRECT3D_LIBRARY_RELEASE})
ENDIF()
ENDIF()
# OpenGL driver
IF(NELDRIVER_OPENGL_LIBRARY_DEBUG)
LIST(APPEND ${_UPNAME}_LIBRARIES debug ${NELDRIVER_OPENGL_LIBRARY_DEBUG})
ENDIF()
IF(NELDRIVER_OPENGL_LIBRARY_RELEASE)
LIST(APPEND ${_UPNAME}_LIBRARIES optimized ${NELDRIVER_OPENGL_LIBRARY_RELEASE})
ENDIF()
ENDIF()
ENDIF()
ELSEIF(COMPONENT STREQUAL "gui")
FIND_PACKAGE(Luabind REQUIRED)
LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES})
FIND_LIBCURL()
IF(CURL_FOUND)
LIST(APPEND ${_UPNAME}_LIBRARIES ${CURL_LIBRARIES})
LIST(APPEND ${_UPNAME}_DEFINITIONS ${CURL_DEFINITIONS})
ENDIF()
# TODO: remove complately OpenSSL requirement on Windows
# Only used by libcurl under Linux
FIND_PACKAGE(OpenSSL REQUIRED)
IF(WIN32)
LIST(APPEND OPENSSL_LIBRARIES Crypt32.lib)
ENDIF()
# Only Linux version of libcurl depends on OpenSSL
LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES})
LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES} ${CURL_LIBRARIES})
LIST(APPEND NEL_DEFINITIONS ${${_UPNAME}_DEFINITIONS})
ELSEIF(COMPONENT STREQUAL "sound")
FIND_PACKAGE(Ogg REQUIRED)
IF(OGG_FOUND)
LIST(APPEND ${_UPNAME}_LIBRARIES ${OGG_LIBRARY})
ENDIF()
FIND_PACKAGE(Vorbis REQUIRED)
IF(VORBIS_FOUND)
LIST(APPEND ${_UPNAME}_LIBRARIES ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY})
ENDIF()
IF(NEL_STATIC)
# Link to snd_lowlevel
FIND_LIBRARY_HELPER(nelsnd_lowlevel RELEASE nelsnd_lowlevel_r DEBUG nelsnd_lowlevel_d DIR ${NEL_DIR} REQUIRED)
IF(NELSND_LOWLEVEL_LIBRARIES)
MESSAGE(STATUS "Found NeL sound lowlevel ${NELSND_LOWLEVEL_LIBRARIES}")
LIST(APPEND NELSOUND_LIBRARIES ${NELSND_LOWLEVEL_LIBRARIES})
IF(NEL_STATIC_DRIVERS)
# DirectSound, XAudio2 and FMod drivers (only under Windows)
IF(WIN32)
# DirectSound
IF(NELDRIVER_DIRECTSOUND_LIBRARY_DEBUG)
LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_DIRECTSOUND_LIBRARY_DEBUG})
ENDIF()
IF(NELDRIVER_DIRECTSOUND_LIBRARY_RELEASE)
LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_DIRECTSOUND_LIBRARY_RELEASE})
ENDIF()
# FMod
IF(NELDRIVER_FMOD_LIBRARY_DEBUG)
LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_FMOD_LIBRARY_DEBUG})
ENDIF()
IF(NELDRIVER_FMOD_LIBRARY_RELEASE)
LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_FMOD_LIBRARY_RELEASE})
ENDIF()
# XAudio2
IF(NELDRIVER_XAUDIO2_LIBRARY_DEBUG)
LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_XAUDIO2_LIBRARY_DEBUG})
ENDIF()
IF(NELDRIVER_XAUDIO2_LIBRARY_RELEASE)
LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_XAUDIO2_LIBRARY_RELEASE})
ENDIF()
ENDIF()
# OpenAL driver
IF(NELDRIVER_OPENAL_LIBRARY_DEBUG)
LIST(APPEND NELSOUND_LIBRARIES debug ${NELDRIVER_OPENAL_LIBRARY_DEBUG})
ENDIF()
IF(NELDRIVER_OPENAL_LIBRARY_RELEASE)
LIST(APPEND NELSOUND_LIBRARIES optimized ${NELDRIVER_OPENAL_LIBRARY_RELEASE})
ENDIF()
ENDIF()
ENDIF()
ENDIF()
ENDIF()
LIST(APPEND NEL_LIBRARIES ${${_UPNAME}_LIBRARIES})
ENDIF()
ENDFOREACH()
MESSAGE_VERSION_PACKAGE_HELPER(NeL ${NEL_VERSION} ${NEL_MODULES_FOUND})

View file

@ -0,0 +1,14 @@
INCLUDE(FindHelpers)
FIND_PACKAGE_HELPER(RyzomGameShare game_share/continent.h RELEASE ryzom_gameshare_r ryzom_gameshare DEBUG ryzom_gameshare_d DIR ${NEL_DIR} ${RYZOM_DIR} SUFFIXES ryzom)
IF(RYZOMGAMESHARE_FOUND)
FIND_PACKAGE(NeL REQUIRED)
LIST(APPEND RYZOMGAMESHARE_INCLUDE_DIRS ${NEL_INCLUDE_DIRS})
LIST(APPEND RYZOMGAMESHARE_LIBRARIES ${NELMISC_LIBRARIES} ${NELLIGO_LIBRARIES} ${NELNET_LIBRARIES} ${NELGEORGES_LIBRARIES})
SET(RYZOM_GAMESHARE_LIBRARIES ${RYZOMGAMESHARE_LIBRARIES})
SET(RYZOM_GAMESHARE_FOUND ${RYZOMGAMESHARE_FOUND})
SET(RYZOM_GAMESHARE_INCLUDE_DIR ${RYZOMGAMESHARE_INCLUDE_DIR})
SET(RYZOM_GAMESHARE_INCLUDE_DIRS ${RYZOMGAMESHARE_INCLUDE_DIRS})
ENDIF()

View file

@ -1,8 +1,8 @@
# - Locate Steam API
# This module defines
# STEAM_LIBRARY, the library to link against
# VORBIS_FOUND, if false, do not try to link to VORBIS
# VORBIS_INCLUDE_DIR, where to find headers.
# STEAM_FOUND, if false, do not try to link to STEAM
# STEAM_INCLUDE_DIR, where to find headers.
IF(STEAM_LIBRARY AND STEAM_INCLUDE_DIR)
# in cache already

View file

@ -98,4 +98,6 @@ ENDIF()
IF(DEFINED REVISION)
MESSAGE(STATUS "Found revision ${REVISION}")
ELSE()
SET(REVISION 0)
ENDIF()

View file

@ -41,31 +41,49 @@ ENDMACRO()
MACRO(PCH_SET_COMPILE_FLAGS _target)
SET(PCH_FLAGS)
SET(PCH_ARCHS)
SET(PCH_INCLUDES)
SET(_FLAGS)
# Append target for clang if defined
IF(CMAKE_CXX_COMPILER_TARGET)
LIST(APPEND PCH_FLAGS "--target=${CMAKE_CXX_COMPILER_TARGET}")
ENDIF()
IF(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
LIST(APPEND PCH_FLAGS "--gcc-toolchain=${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}")
ENDIF()
IF(CMAKE_SYSROOT)
LIST(APPEND PCH_FLAGS "--sysroot=${CMAKE_SYSROOT}")
ENDIF()
IF(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES)
FOREACH(item ${CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES})
LIST(APPEND PCH_FLAGS "-isystem ${item}")
ENDFOREACH()
ENDIF()
# C++ flags
SET(_FLAG ${CMAKE_CXX_FLAGS})
SEPARATE_ARGUMENTS(_FLAG)
SET(_FLAGS ${CMAKE_CXX_FLAGS})
SEPARATE_ARGUMENTS(_FLAGS)
LIST(APPEND _FLAGS ${_FLAG})
LIST(APPEND PCH_FLAGS ${_FLAGS})
# C++ config flags
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" _UPPER_BUILD)
SET(_FLAG ${CMAKE_CXX_FLAGS_${_UPPER_BUILD}})
SEPARATE_ARGUMENTS(_FLAG)
SET(_FLAGS ${CMAKE_CXX_FLAGS_${_UPPER_BUILD}})
SEPARATE_ARGUMENTS(_FLAGS)
LIST(APPEND _FLAGS ${_FLAG})
LIST(APPEND PCH_FLAGS ${_FLAGS})
GET_TARGET_PROPERTY(_targetType ${_target} TYPE)
SET(_USE_PIC OFF)
IF(${_targetType} STREQUAL "SHARED_LIBRARY" OR ${_targetType} STREQUAL "MODULE_LIBRARY")
SET(_FLAG ${CMAKE_SHARED_LIBRARY_CXX_FLAGS})
SEPARATE_ARGUMENTS(_FLAG)
LIST(APPEND _FLAGS ${_FLAG})
SET(_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS})
SEPARATE_ARGUMENTS(_FLAGS)
LIST(APPEND PCH_FLAGS ${_FLAGS})
ELSE()
GET_TARGET_PROPERTY(_pic ${_target} POSITION_INDEPENDENT_CODE)
IF(_pic)
@ -75,7 +93,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES)
FOREACH(item ${DIRINC})
LIST(APPEND _FLAGS -I"${item}")
LIST(APPEND PCH_INCLUDES "${item}")
ENDFOREACH()
# NOTE: As cmake files (eg FindQT4) may now use generator expressions around their defines that evaluate
@ -98,14 +116,14 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
ENDFOREACH()
ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS)
GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS)
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item})
ENDFOREACH()
ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS_${_UPPER_BUILD})
GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS})
APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item})
@ -114,22 +132,22 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
GET_TARGET_PROPERTY(oldProps ${_target} COMPILE_FLAGS)
IF(oldProps)
SET(_FLAG ${oldProps})
SEPARATE_ARGUMENTS(_FLAG)
LIST(APPEND _FLAGS ${_FLAG})
SET(_FLAGS ${oldProps})
SEPARATE_ARGUMENTS(_FLAGS)
LIST(APPEND PCH_FLAGS ${_FLAGS})
ENDIF()
GET_TARGET_PROPERTY(oldPropsBuild ${_target} COMPILE_FLAGS_${_UPPER_BUILD})
IF(oldPropsBuild)
SET(_FLAG ${oldPropsBuild})
SEPARATE_ARGUMENTS(_FLAG)
LIST(APPEND _FLAGS ${_FLAG})
SET(_FLAGS ${oldPropsBuild})
SEPARATE_ARGUMENTS(_FLAGS)
LIST(APPEND PCH_FLAGS ${_FLAGS})
ENDIF()
GET_TARGET_PROPERTY(DIRINC ${_target} INCLUDE_DIRECTORIES)
IF(DIRINC)
FOREACH(item ${DIRINC})
LIST(APPEND _FLAGS -I"${item}")
LIST(APPEND PCH_INCLUDES "${item}")
ENDFOREACH()
ENDIF()
@ -147,6 +165,18 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
ENDFOREACH()
ENDIF()
GET_TARGET_PROPERTY(OPTIONS ${_target} COMPILE_OPTIONS)
IF(OPTIONS)
SEPARATE_ARGUMENTS(OPTIONS)
LIST(APPEND PCH_FLAGS ${OPTIONS})
ENDIF()
GET_TARGET_PROPERTY(OPTIONS ${_target} COMPILE_OPTIONS_${_UPPER_BUILD})
IF(OPTIONS)
SEPARATE_ARGUMENTS(OPTIONS)
LIST(APPEND PCH_FLAGS ${OPTIONS})
ENDIF()
GET_TARGET_PROPERTY(_LIBS ${_target} INTERFACE_LINK_LIBRARIES)
IF(_LIBS)
FOREACH(_LIB ${_LIBS})
@ -156,7 +186,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
IF(_DIRS)
FOREACH(item ${_DIRS})
LIST(APPEND GLOBAL_DEFINITIONS -I"${item}")
LIST(APPEND PCH_INCLUDES "${item}")
ENDFOREACH()
ENDIF()
@ -185,7 +215,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
ENDIF()
IF(_USE_PIC)
LIST(APPEND _FLAGS ${CMAKE_CXX_COMPILE_OPTIONS_PIC})
LIST(APPEND PCH_FLAGS ${CMAKE_CXX_COMPILE_OPTIONS_PIC})
ENDIF()
ENDIF()
@ -195,92 +225,78 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
IF(_DIRECTORY_FLAGS)
SEPARATE_ARGUMENTS(_DIRECTORY_FLAGS)
FOREACH(item ${_DIRECTORY_FLAGS})
LIST(APPEND _FLAGS "${item}")
LIST(APPEND PCH_FLAGS "${item}")
ENDFOREACH()
ENDIF()
GET_DIRECTORY_PROPERTY(_DIRECTORY_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
GET_DIRECTORY_PROPERTY(_DIRECTORY_DEFINITIONS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEFINITIONS)
IF(_DIRECTORY_DEFINITIONS)
SEPARATE_ARGUMENTS(_DIRECTORY_DEFINITIONS)
FOREACH(item ${_DIRECTORY_DEFINITIONS})
LIST(APPEND _FLAGS "${item}")
LIST(APPEND PCH_FLAGS "${item}")
ENDFOREACH()
ENDIF()
ENDIF()
IF(USE_CPP0X AND gcc_compiler_version GREATER "6.2.0")
LIST(APPEND _FLAGS "-std=gnu++11")
ENDIF()
# Format definitions
IF(MSVC)
# Fix path with space
SEPARATE_ARGUMENTS(_FLAGS UNIX_COMMAND "${_FLAGS}")
IF(CMAKE_CXX11_EXTENSION_COMPILE_OPTION)
LIST(APPEND PCH_FLAGS "${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}")
ENDIF()
# Already in list form and items may contain non-leading spaces that should not be split on
LIST(INSERT _FLAGS 0 "${GLOBAL_DEFINITIONS}")
LIST(APPEND PCH_FLAGS "${GLOBAL_DEFINITIONS}")
IF(CLANG)
# Determining all architectures and get common flags
SET(_ARCH_NEXT)
SET(_XARCH_NEXT)
FOREACH(item ${_FLAGS})
IF(_ARCH_NEXT)
LIST(FIND PCH_ARCHS ${item} ITEM_FOUND)
IF(ITEM_FOUND EQUAL -1)
LIST(APPEND PCH_ARCHS ${item})
STRING(TOUPPER "${item}" _UPPER_ARCH)
SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item})
ENDIF()
SET(_ARCH_NEXT OFF)
ELSEIF(_XARCH_NEXT)
SET(_XARCH_NEXT OFF)
ELSE()
IF(item MATCHES "^-arch")
SET(_ARCH_NEXT ON)
ELSEIF(item MATCHES "^-Xarch_")
STRING(REGEX REPLACE "-Xarch_([a-z0-9_]+)" "\\1" item ${item})
LIST(FIND PCH_ARCHS ${item} ITEM_FOUND)
IF(ITEM_FOUND EQUAL -1)
LIST(APPEND PCH_ARCHS ${item})
STRING(TOUPPER "${item}" _UPPER_ARCH)
SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item})
ENDIF()
SET(_XARCH_NEXT ON)
ELSE()
LIST(APPEND PCH_FLAGS ${item})
ENDIF()
ENDIF()
ENDFOREACH()
# Get architcture specific flags
SET(_XARCH_NEXT)
FOREACH(item ${_FLAGS})
IF(_XARCH_NEXT)
STRING(TOUPPER "${_XARCH_NEXT}" _UPPER_XARCH)
LIST(APPEND PCH_ARCH_${_UPPER_XARCH}_FLAGS ${item})
SET(_XARCH_NEXT OFF)
ELSE()
IF(item MATCHES "^-Xarch_")
STRING(SUBSTRING "${item}" 7 -1 _XARCH_NEXT)
ENDIF()
ENDIF()
ENDFOREACH()
# Remove duplicated architectures
IF(_ARCHS AND PCH_ARCHS)
LIST(REMOVE_DUPLICATES PCH_ARCHS)
ENDIF()
IF(WIN32)
SET(SYSTEM_FLAG "[-/$]")
ELSE()
SET(PCH_FLAGS ${_FLAGS})
SET(SYSTEM_FLAG "[-$]")
ENDIF()
IF(PCH_FLAGS)
LIST(REMOVE_ITEM PCH_FLAGS "")
LIST(REMOVE_DUPLICATES PCH_FLAGS)
SET(_FINAL_FLAGS)
SET(_PREVIOUS_FLAG)
FOREACH(_FLAG ${PCH_FLAGS})
# If parameter is really a flag (starts with -)
IF(_FLAG MATCHES "^${SYSTEM_FLAG}")
IF(_PREVIOUS_FLAG)
# Append previous flag
LIST(APPEND _FINAL_FLAGS ${_PREVIOUS_FLAG})
ENDIF()
SET(_PREVIOUS_FLAG ${_FLAG})
ELSE()
IF(_PREVIOUS_FLAG)
# Append previous flag and its parameter
# TODO: escape them only if there is an space
LIST(APPEND _FINAL_FLAGS "${_PREVIOUS_FLAG} \"${_FLAG}\"")
SET(_PREVIOUS_FLAG)
ELSE()
# Shouldn't happen
MESSAGE(FATAL_ERROR "No previous flag before ${_FLAG}")
ENDIF()
ENDIF()
ENDFOREACH()
IF(_PREVIOUS_FLAG)
LIST(APPEND _FINAL_FLAGS ${_PREVIOUS_FLAG})
ENDIF()
SET(PCH_FLAGS ${_FINAL_FLAGS})
# Remove flags that don't work with PCH
LIST(REMOVE_ITEM PCH_FLAGS "-Wa,--noexecstack")
# Remove all empty parameters
LIST(REMOVE_ITEM PCH_FLAGS "")
# Remove duplicate parameters
LIST(REMOVE_DUPLICATES PCH_FLAGS)
# create a command-line string
STRING(REGEX REPLACE ";" " " PCH_FLAGS "${PCH_FLAGS}")
# and separate arguments
SEPARATE_ARGUMENTS(PCH_FLAGS)
ENDMACRO()
MACRO(GET_PDB_FILENAME _out_filename _target)
@ -304,7 +320,7 @@ MACRO(GET_PDB_FILENAME _out_filename _target)
SET(${_out_filename} "${_targetOutput}/${_target}${_targetPostfix}.pdb")
ENDMACRO(GET_PDB_FILENAME)
MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS)
MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS _includes)
IF(CMAKE_CXX_COMPILER_ARG1)
# remove leading space in compiler argument
STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
@ -314,18 +330,33 @@ MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS)
IF(MSVC)
GET_PDB_FILENAME(_PDB_FILE ${_PCH_current_target})
SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${_PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj")
SET(PCH_TEMP_CONTENT)
FOREACH(_include ${_includes})
SET(PCH_TEMP_CONTENT "${PCH_TEMP_CONTENT} -I \"${_include}\"")
ENDFOREACH()
SET(PCH_TEMP_FILE ${CMAKE_CURRENT_BINARY_DIR}/pch_command.txt)
FILE(WRITE ${PCH_TEMP_FILE} "${PCH_TEMP_CONTENT}")
SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} /nologo @${PCH_TEMP_FILE} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${_PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj")
# Ninja PCH Support
# http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html
SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES OBJECT_OUTPUTS "${PCH_OUTPUT}.obj")
ELSE()
SET(HEADER_FORMAT "c++-header")
SET(_FLAGS "")
SET(_FLAGS)
IF(APPLE)
SET(HEADER_FORMAT "objective-${HEADER_FORMAT}")
SET(_FLAGS ${OBJC_FLAGS})
LIST(APPEND _FLAGS ${OBJC_FLAGS})
ENDIF()
FOREACH(_include ${_includes})
LIST(APPEND _FLAGS -I "${_include}")
ENDFOREACH()
SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} ${_FLAGS} -x ${HEADER_FORMAT} -o ${PCH_OUTPUT} -c ${PCH_INPUT})
ENDIF()
ENDMACRO()
@ -467,7 +498,7 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
PCH_SET_PRECOMPILED_HEADER_OUTPUT(${_targetName} ${_inputh} ${_ARCH} "")
LIST(APPEND PCH_OUTPUTS ${PCH_OUTPUT})
PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_ARCH_${_UPPER_ARCH}_FLAGS};${PCH_FLAGS}")
PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_ARCH_${_UPPER_ARCH}_FLAGS};${PCH_FLAGS}" "${PCH_INCLUDES}")
PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch_${_ARCH})
ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH(${_targetName} ${_ARCH})
@ -476,7 +507,7 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
PCH_SET_PRECOMPILED_HEADER_OUTPUT(${_targetName} ${_inputh} "" "")
LIST(APPEND PCH_OUTPUTS ${PCH_OUTPUT})
PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_FLAGS}")
PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_FLAGS}" "${PCH_INCLUDES}")
PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch)
ENDIF()
@ -525,7 +556,13 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
ELSE()
#Fallback to the "old" precompiled suppport
ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp})
IF(CMAKE_OSX_ARCHITECTURES AND TARGETS_COUNT GREATER 1)
FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES})
ADD_PRECOMPILED_HEADER(${_targetName}_${_ARCH} ${_inputh} ${_inputcpp})
ENDFOREACH()
ELSE()
ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp})
ENDIF()
ENDIF()
IF(TARGET ${_targetName}_static)

View file

@ -238,6 +238,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
OPTION(WITH_EXTERNAL "With provided external." OFF)
ENDIF()
OPTION(WITH_STATIC_EXTERNAL "With static external libraries" OFF)
OPTION(WITH_STATIC_RUNTIMES "Use only static C++ runtimes" OFF)
IF(UNIX AND NOT APPLE)
OPTION(WITH_UNIX_STRUCTURE "Use UNIX structure (bin, include, lib)" ON )
ELSE()
@ -246,6 +247,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON )
OPTION(WITH_ASSIMP "Use assimp exporter" OFF)
OPTION(WITH_LIBGSF "Use libgsf for max file library" OFF)
###
# GUI toolkits
@ -373,8 +375,14 @@ MACRO(ADD_PLATFORM_LINKFLAGS _FLAGS)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${_FLAGS}")
ENDMACRO()
MACRO(NL_SETUP_BUILD)
MACRO(CONVERT_VERSION_NUMBER _VERSION_NUMBER _BASE)
SET(${_VERSION_NUMBER} 0)
FOREACH(_ARG ${ARGN})
MATH(EXPR ${_VERSION_NUMBER} "${${_VERSION_NUMBER}} * ${_BASE} + ${_ARG}")
ENDFOREACH()
ENDMACRO()
MACRO(NL_SETUP_BUILD)
#-----------------------------------------------------------------------------
# Setup the buildmode variables.
#
@ -560,6 +568,11 @@ MACRO(NL_SETUP_BUILD)
ADD_PLATFORM_FLAGS("-DENABLE_LOGS")
ENDIF()
SET(CUSTOM_FLAGS "" CACHE STRING "Custom compile flags (useful for /MPn)")
IF(NOT ${CUSTOM_FLAGS} STREQUAL "")
ADD_PLATFORM_FLAGS(${CUSTOM_FLAGS})
ENDIF()
IF(MSVC)
# Ignore default include paths
ADD_PLATFORM_FLAGS("/X")
@ -636,8 +649,14 @@ MACRO(NL_SETUP_BUILD)
SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}")
ENDIF()
SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}")
SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}")
IF(WITH_STATIC_RUNTIMES)
SET(RUNTIME_FLAG "/MT")
ELSE()
SET(RUNTIME_FLAG "/MD")
ENDIF()
SET(NL_DEBUG_CFLAGS "/Zi ${RUNTIME_FLAG}d /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}")
SET(NL_RELEASE_CFLAGS "${RUNTIME_FLAG} /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}")
SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt ${MSVC_INCREMENTAL_YES_FLAG} ${NL_DEBUG_LINKFLAGS}")
SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}")
@ -665,7 +684,7 @@ MACRO(NL_SETUP_BUILD)
IF(APPLE)
SET(OBJC_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch -fobjc-weak)
IF(NOT XCODE)
IF(CMAKE_OSX_ARCHITECTURES)
SET(TARGETS_COUNT 0)
@ -874,7 +893,9 @@ MACRO(NL_SETUP_BUILD)
ENDIF()
# use c++0x standard to use std::unique_ptr and std::shared_ptr
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -std=c++0x")
IF(CMAKE_CXX11_EXTENSION_COMPILE_OPTION)
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}")
ENDIF()
ADD_PLATFORM_FLAGS("-D_REENTRANT")
@ -950,8 +971,6 @@ MACRO(NL_SETUP_BUILD)
ADD_PLATFORM_FLAGS("-fPIC")
ENDIF()
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48")
# hardening
ADD_PLATFORM_FLAGS("-fstack-protector --param=ssp-buffer-size=4")
@ -965,6 +984,10 @@ MACRO(NL_SETUP_BUILD)
IF(NOT APPLE)
ADD_PLATFORM_LINKFLAGS("-Wl,--no-undefined -Wl,--as-needed")
IF(WITH_STATIC_RUNTIMES)
ADD_PLATFORM_LINKFLAGS("-static-libstdc++")
ENDIF()
ENDIF()
IF(NOT APPLE)
@ -1023,6 +1046,12 @@ MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE)
ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX)
MACRO(NL_SETUP_PREFIX_PATHS)
IF(TARGET_X64 AND WIN32)
SET(LIB_SUFFIX "64")
ELSE()
SET(LIB_SUFFIX "")
ENDIF()
## Allow override of install_prefix/etc path.
IF(NOT NL_ETC_PREFIX)
IF(WITH_UNIX_STRUCTURE)
@ -1046,7 +1075,7 @@ MACRO(NL_SETUP_PREFIX_PATHS)
## Allow override of install_prefix/sbin path.
IF(NOT NL_SBIN_PREFIX)
IF(WITH_UNIX_STRUCTURE)
SET(NL_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.")
SET(NL_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.")
ELSE()
SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
ENDIF()
@ -1056,7 +1085,7 @@ MACRO(NL_SETUP_PREFIX_PATHS)
## Allow override of install_prefix/bin path.
IF(NOT NL_BIN_PREFIX)
IF(WITH_UNIX_STRUCTURE)
SET(NL_BIN_PREFIX "bin" CACHE PATH "Installation path for tools and applications.")
SET(NL_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools and applications.")
ELSE()
SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ENDIF()
@ -1068,7 +1097,7 @@ MACRO(NL_SETUP_PREFIX_PATHS)
IF(LIBRARY_ARCHITECTURE)
SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.")
ELSE()
SET(NL_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.")
SET(NL_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.")
ENDIF()
ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX)
@ -1079,7 +1108,11 @@ MACRO(NL_SETUP_PREFIX_PATHS)
IF(LIBRARY_ARCHITECTURE)
SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.")
ELSE()
SET(NL_DRIVER_PREFIX "lib/nel" CACHE PATH "Installation path for drivers.")
IF(WIN32)
SET(NL_DRIVER_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for drivers.")
ELSE()
SET(NL_DRIVER_PREFIX "lib${LIB_SUFFIX}/nel" CACHE PATH "Installation path for drivers.")
ENDIF()
ENDIF()
ELSE()
SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.")
@ -1112,7 +1145,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS)
## Allow override of install_prefix/sbin path.
IF(NOT RYZOM_SBIN_PREFIX)
IF(WITH_UNIX_STRUCTURE)
SET(RYZOM_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.")
SET(RYZOM_SBIN_PREFIX "sbin${LIB_SUFFIX}" CACHE PATH "Installation path for admin tools and services.")
ELSE()
SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
ENDIF()
@ -1122,7 +1155,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS)
## Allow override of install_prefix/bin path.
IF(NOT RYZOM_BIN_PREFIX)
IF(WITH_UNIX_STRUCTURE)
SET(RYZOM_BIN_PREFIX "bin" CACHE PATH "Installation path for tools.")
SET(RYZOM_BIN_PREFIX "bin${LIB_SUFFIX}" CACHE PATH "Installation path for tools.")
ELSE()
SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ENDIF()
@ -1134,7 +1167,7 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS)
IF(LIBRARY_ARCHITECTURE)
SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.")
ELSE()
SET(RYZOM_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.")
SET(RYZOM_LIB_PREFIX "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries.")
ENDIF()
ENDIF()
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX)
@ -1210,4 +1243,4 @@ MACRO(SETUP_EXTERNAL)
FIND_PACKAGE(MSVC REQUIRED)
FIND_PACKAGE(WindowsSDK REQUIRED)
ENDIF()
ENDMACRO(SETUP_EXTERNAL)
ENDMACRO()

View file

@ -20,6 +20,7 @@ ENDIF()
IF(WITH_SOUND)
FIND_PACKAGE(Ogg)
FIND_PACKAGE(Vorbis)
FIND_PACKAGE(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL SWRESAMPLE)
IF(WITH_DRIVER_OPENAL)
FIND_PACKAGE(OpenAL)

View file

@ -178,6 +178,10 @@ public:
CVertexBuffer Vertices;
CMaterial *Material;
CRGBA Color;
ucstring Text;
uint32 CacheVersion;
/// The width of the string, in pixels (eg: 30)
float StringWidth;
/// The height of the string, in pixels (eg: 10)
@ -223,6 +227,7 @@ public:
*/
CComputedString (bool bSetupVB=true)
{
CacheVersion = 0;
StringWidth = 0;
StringHeight = 0;
if (bSetupVB)

View file

@ -224,7 +224,7 @@ public:
// @{
// first param is the associated window.
// Must be a HWND for Windows (WIN32).
virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show = true, bool resizeable = true) throw(EBadDisplay) = 0;
virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show = true, bool resizeable = true) = 0;
// Must be called after a setDisplay that initialize the mode
virtual bool setMode(const GfxMode &mode) = 0;
virtual bool getModes(std::vector<GfxMode> &modes) = 0;

View file

@ -134,14 +134,14 @@ class CDRU
public:
/// Portable Function which create a GL Driver (using gl dll...).
static IDriver *createGlDriver() throw(EDru);
static IDriver *createGlDriver();
/// Portable Function which create a GL ES Driver (using gl dll...).
static IDriver *createGlEsDriver() throw(EDru);
static IDriver *createGlEsDriver();
#ifdef NL_OS_WINDOWS
/// Windows Function which create a Direct3d Driver.
static IDriver *createD3DDriver() throw(EDru);
static IDriver *createD3DDriver();
#endif // NL_OS_WINDOWS
/// \name 2D render.

View file

@ -21,8 +21,12 @@
#undef NL_DONT_USE_EXTERNAL_CODE
#ifndef NL_DONT_USE_EXTERNAL_CODE
#include <ft2build.h>
#include FT_FREETYPE_H
// forward declarations to avoid including freetype.h in headers
typedef int FT_Error;
typedef struct FT_LibraryRec_ *FT_Library;
typedef struct FT_FaceRec_* FT_Face;
#else // NL_DONT_USE_EXTERNAL_CODE
#endif // NL_DONT_USE_EXTERNAL_CODE
@ -74,6 +78,8 @@ public:
uint32 getUID() { return _UID; }
std::string getFontFileName() const;
private:
static uint32 _FontGeneratorCounterUID;

View file

@ -59,6 +59,9 @@ class CFontManager
CSmartPtr<CMaterial> _MatFont;
CSmartPtr<CTextureFont> _TexFont;
// Keep track number of textures created to properly report cache version
uint32 _TexCacheNr;
public:
/**
@ -71,6 +74,7 @@ public:
_NbChar = 0;
_MatFont = NULL;
_TexFont = NULL;
_TexCacheNr = 0;
}
@ -94,7 +98,6 @@ public:
*/
CMaterial* getFontMaterial();
/**
* Compute primitive blocks and materials of each character of
* the string.
@ -152,7 +155,8 @@ public:
void dumpCache (const char *filename)
{
_TexFont->dumpTextureFont (filename);
if (_TexFont)
_TexFont->dumpTextureFont (filename);
}
/**
@ -160,6 +164,15 @@ public:
*/
void invalidate();
// get font atlas rebuild count
uint32 getCacheVersion() const
{
if (_TexFont)
return (_TexFont->getCacheVersion() << 16) + _TexCacheNr;
return 0;
}
};

View file

@ -168,9 +168,9 @@ public:
void clear();
/// Verify the binding of patchs of all zones. throw EBadBind if error.
void checkBinds() throw(EBadBind);
void checkBinds();
/// Verify the binding of patchs of one zone. throw EBadBind if error. nop if zone not loaded.
void checkBinds(uint16 zoneId) throw(EBadBind);
void checkBinds(uint16 zoneId);
/**
* Build tileBank. Call this after loading the near and far tile banks.

View file

@ -64,7 +64,7 @@ public:
*
* You can access the driver with CNELU::Driver.
*/
static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false, bool direct3d=false) throw(EDru);
static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false, bool direct3d=false);
/** Init all that we need for a Scene.
* - register scene basics models,
@ -108,7 +108,7 @@ public:
* - initScene();
* - initEventServer();
*/
static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false, bool direct3d = false) throw(EDru);
static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false, bool direct3d = false);
/** Delete all:
* - releaseEventServer();

View file

@ -88,7 +88,7 @@ public:
void setShadeOutline (bool b) { _ShadeOutline = b; }
void setShadeExtent (float shext) { _ShadeExtent = shext; }
void setShadeExtent (float x, float y) { _ShadeExtentX = x; _ShadeExtentY = y; }
/// The alpha of the shade is multiplied at each draw with the alpha of the color. Default: (0,0,0,255)
void setShadeColor (NLMISC::CRGBA color) { _ShadeColor = color; }
@ -150,6 +150,10 @@ public:
{
nlassert (index < _CacheStrings.size());
CComputedString &rCS = _CacheStrings[index];
if (rCS.CacheVersion != _FontManager->getCacheVersion())
{
computeString(rCS.Text, rCS);
}
if (_Shaded)
{
CRGBA bkup = rCS.Color;
@ -157,19 +161,20 @@ public:
rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8);
if (_ShadeOutline)
{
float rext = _ShadeExtent * 0.7071f;
rCS.render2D(*_Driver, x+rext, z-rext, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x-rext, z-rext, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x-rext, z+rext, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x+rext, z+rext, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x+_ShadeExtent, z, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x-_ShadeExtent, z, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ);
float rextX = _ShadeExtentX * 0.7071f;
float rextY = _ShadeExtentY * 0.7071f;
rCS.render2D(*_Driver, x+rextX, z-rextY, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x-rextX, z-rextY, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x-rextX, z+rextY, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x+rextX, z+rextY, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x+_ShadeExtentX, z, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x-_ShadeExtentX, z, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ);
}
else
{
rCS.render2D(*_Driver, x+_ShadeExtent, z-_ShadeExtent, _HotSpot, _ScaleX, _ScaleZ);
rCS.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ);
}
rCS.Color= bkup;
}
@ -183,6 +188,10 @@ public:
{
nlassert (index < _CacheStrings.size());
CComputedString &rCS = _CacheStrings[index];
if (rCS.CacheVersion != _FontManager->getCacheVersion())
{
computeString(rCS.Text, rCS);
}
if(_Shaded)
{
CRGBA bkup = rCS.Color;
@ -190,19 +199,20 @@ public:
rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8);
if (_ShadeOutline)
{
float rext = _ShadeExtent * 0.7071f;
rCS.render2DClip(*_Driver, rdrBuffer, x+rext, z-rext, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x-rext, z-rext, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x-rext, z+rext, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x+rext, z+rext, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtent, z, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x, z+_ShadeExtent, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x, z-_ShadeExtent, xmin, ymin, xmax, ymax);
float rextX = _ShadeExtentX * 0.7071f;
float rextY = _ShadeExtentY * 0.7071f;
rCS.render2DClip(*_Driver, rdrBuffer, x+rextX, z-rextY, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x-rextX, z-rextY, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x-rextX, z+rextY, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x+rextX, z+rextY, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtentX, z, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x-_ShadeExtentX, z, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x, z+_ShadeExtentY, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x, z-_ShadeExtentY, xmin, ymin, xmax, ymax);
}
else
{
rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtent, z-_ShadeExtent, xmin, ymin, xmax, ymax);
rCS.render2DClip(*_Driver, rdrBuffer, x+_ShadeExtentX, z-_ShadeExtentY, xmin, ymin, xmax, ymax);
}
rCS.Color= bkup;
}
@ -216,6 +226,11 @@ public:
{
nlassert (index < _CacheStrings.size());
CComputedString &rCS = _CacheStrings[index];
if (rCS.CacheVersion != _FontManager->getCacheVersion())
{
computeString(rCS.Text, rCS);
}
if (_Shaded)
{
CRGBA bkup = rCS.Color;
@ -223,19 +238,20 @@ public:
rCS.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8);
if (_ShadeOutline)
{
float rext = _ShadeExtent * 0.7071f;
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rext, y-rext, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rext, y-rext, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rext, y+rext, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rext, y+rext, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtent, y, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y+_ShadeExtent, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax);
float rextX = _ShadeExtentX * 0.7071f;
float rextY = _ShadeExtentY * 0.7071f;
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rextX, y-rextY, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rextX, y-rextY, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-rextX, y+rextY, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+rextX, y+rextY, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtentX, y, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x-_ShadeExtentX, y, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y+_ShadeExtentY, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x, y-_ShadeExtentY, depth, xmin, ymin, xmax, ymax);
}
else
{
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtent, y-_ShadeExtent, depth, xmin, ymin, xmax, ymax);
rCS.render2DUnProjected (*_Driver, renderBuffer, frustum, scaleMatrix, x+_ShadeExtentX, y-_ShadeExtentY, depth, xmin, ymin, xmax, ymax);
}
rCS.Color= bkup;
}
@ -258,19 +274,20 @@ public:
_TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8);
if (_ShadeOutline)
{
float rext = _ShadeExtent * 0.7071f;
_TempString.render2D(*_Driver,x+rext,z-rext,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-rext,z-rext,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-rext,z+rext,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x+rext,z+rext,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x+_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
float rextX = _ShadeExtentX * 0.7071f;
float rextY = _ShadeExtentY * 0.7071f;
_TempString.render2D(*_Driver,x+rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x+rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x+_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x,z+_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x,z-_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ);
}
else
{
_TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ);
}
_TempString.Color = bkup;
}
@ -297,19 +314,20 @@ public:
_TempString.Color.A = (uint8)((uint(bkup.A) * uint(_ShadeColor.A)+1)>>8);
if (_ShadeOutline)
{
float rext = _ShadeExtent * 0.7071f;
_TempString.render2D(*_Driver,x+rext,z-rext,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-rext,z-rext,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-rext,z+rext,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x+rext,z+rext,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x+_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-_ShadeExtent,z,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x,z+_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
float rextX = _ShadeExtentX * 0.7071f;
float rextY = _ShadeExtentY * 0.7071f;
_TempString.render2D(*_Driver,x+rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-rextX,z-rextY,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x+rextX,z+rextY,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x+_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x-_ShadeExtentX,z,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x,z+_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver,x,z-_ShadeExtentY,_HotSpot,_ScaleX,_ScaleZ);
}
else
{
_TempString.render2D(*_Driver,x+_ShadeExtent,z-_ShadeExtent,_HotSpot,_ScaleX,_ScaleZ);
_TempString.render2D(*_Driver, x+_ShadeExtentX, z-_ShadeExtentY, _HotSpot, _ScaleX, _ScaleZ);
}
_TempString.Color = bkup;
}
@ -412,7 +430,8 @@ private:
bool _ShadeOutline;
/// shade's extent (shadow size)
float _ShadeExtent;
float _ShadeExtentX;
float _ShadeExtentY;
/// Shade color (default is black)
NLMISC::CRGBA _ShadeColor;

View file

@ -80,7 +80,7 @@ public:
bool getShaded() const;
void setShadeOutline(bool b);
bool getShadeOutline() const;
void setShadeExtent(float shext) ;
void setShadeExtent(float x, float y);
void setShadeColor (NLMISC::CRGBA sc);
NLMISC::CRGBA getShadeColor () const;
void setKeep800x600Ratio(bool keep);

View file

@ -18,6 +18,7 @@
#define NL_TEXTURE_FONT_H
#include "nel/misc/types_nl.h"
#include "nel/misc/rect.h"
#include "nel/3d/texture.h"
namespace NL3D
@ -25,9 +26,6 @@ namespace NL3D
class CFontGenerator;
#define TEXTUREFONT_NBCATEGORY 5 // Config 1
//#define TEXTUREFONT_NBCATEGORY 4
// ****************************************************************************
/**
* CTextureFont
@ -37,32 +35,59 @@ class CTextureFont : public ITexture
public:
struct SLetterInfo
// Holds info for glyphs rendered on atlas
struct SGlyphInfo
{
// To generate the letter
ucchar Char;
CFontGenerator *FontGenerator;
// font atlas info
uint32 CacheVersion;
// atlas region with padding
uint32 X, Y, W, H;
// rendered glyph size without padding
uint32 CharWidth;
uint32 CharHeight;
// UV coords for rendered glyph without padding
float U0, V0, U1, V1;
uint32 GlyphIndex;
sint Size;
bool Embolden;
bool Oblique;
CFontGenerator *FontGenerator;
SGlyphInfo()
: CacheVersion(0),
U0(0.f), V0(0.f), U1(0.f), V1(0.f),
X(0), Y(0), W(0), H(0), CharWidth(0), CharHeight(0),
GlyphIndex(0), Size(0), Embolden(false), Oblique(false), FontGenerator(NULL)
{
}
};
// The less recently used infos
SLetterInfo *Next, *Prev;
// Holds info for glyphs displayed on screen
struct SLetterInfo
{
ucchar Char;
sint Size;
bool Embolden;
bool Oblique;
CFontGenerator *FontGenerator;
uint Cat; // 8x8, 16x16, 24x24, 32x32
//////////////////////////////////////////////////////////////////////
float U ,V;
uint32 CharWidth;
uint32 CharHeight;
uint32 GlyphIndex; // number of the character in the this font
uint32 GlyphIndex;
uint32 CharWidth; // Displayed glyph height
uint32 CharHeight; // Displayed glyph height
sint32 Top; // Distance between origin and top of the texture
sint32 Left; // Distance between origin and left of the texture
sint32 AdvX; // Advance to the next caracter
SLetterInfo():Char(0), FontGenerator(NULL), Size(0), Embolden(false), Oblique(false), Next(NULL), Prev(NULL), Cat(0), CharWidth(0), CharHeight(0), GlyphIndex(0), Top(0), Left(0), AdvX(0)
SGlyphInfo* glyph;
SLetterInfo()
: Char(0), Size(0), Embolden(false), Oblique(false), FontGenerator(NULL),
GlyphIndex(0), CharWidth(0), CharHeight(0), Top(0), Left(0), AdvX(0),
glyph(NULL)
{
}
};
@ -70,14 +95,13 @@ public:
struct SLetterKey
{
ucchar Char;
CFontGenerator *FontGenerator;
sint Size;
bool Embolden;
bool Oblique;
CFontGenerator *FontGenerator;
// Does not use FontGenerator in return value
uint32 getVal();
//bool operator < (const SLetterKey&k) const;
//bool operator == (const SLetterKey&k) const;
SLetterKey():Char(0), FontGenerator(NULL), Size(0), Embolden(false), Oblique(false)
{
@ -96,19 +120,76 @@ public:
void doGenerate (bool async = false);
// This function manage the cache if the letter wanted does not exist
SLetterInfo* getLetterInfo (SLetterKey& k);
// \param render Set to true if letter is currently visible on screen
SLetterInfo* getLetterInfo (SLetterKey& k, bool render);
void dumpTextureFont (const char *filename);
// Version is increased with each rebuild of font atlas
uint32 getCacheVersion() const { return _CacheVersion; }
private:
uint32 _CacheVersion;
// current texture size
uint32 _TextureSizeX;
uint32 _TextureSizeY;
// maximum texture size allowed
uint32 _TextureMaxW;
uint32 _TextureMaxH;
// padding around glyphs
uint8 _PaddingL, _PaddingT;
uint8 _PaddingR, _PaddingB;
// To find a letter in the texture
std::map<uint32, SLetterInfo*> Accel;
std::vector<SLetterInfo> Letters[TEXTUREFONT_NBCATEGORY];
SLetterInfo *Front[TEXTUREFONT_NBCATEGORY], *Back[TEXTUREFONT_NBCATEGORY];
// Keep track of available space in main texture
std::vector<NLMISC::CRect> _AtlasNodes;
void rebuildLetter (sint cat, sint x, sint y);
std::vector <SLetterInfo> _Letters;
// lookup letter from letter cache or create new
SLetterInfo* findLetter(SLetterKey& k, bool insert);
// lower/upper bound of glyphs to render, sizes outside are scaled bitmaps
uint _MinGlyphSize;
uint _MaxGlyphSize;
// start using size stem from this font size
uint _GlyphSizeStepMin;
// every n'th font size is rendered, intermediates are using bitmap scaling
uint _GlyphSizeStep;
// rendered glyph cache
std::list<SGlyphInfo> _GlyphCache;
SGlyphInfo* findLetterGlyph(SLetterInfo *letter, bool insert);
// render letter glyph into glyph cache
SGlyphInfo* renderLetterGlyph(SLetterInfo *letter, uint32 bitmapFontSize);
// copy glyph bitmap into texture and invalidate that region
void copyGlyphBitmap(uint8* bitmap, uint32 bitmapW, uint32 bitmapH, uint32 atlasX, uint32 atlasY);
// Find best fit for WxH rect in atlas
uint fitRegion(uint index, uint width, uint height);
// Return top/left from font texture or false if there is no more room
bool reserveAtlas(const uint32 width, const uint32 height, uint32 &x, uint32 &y);
// repack glyphs, resize texture, and invalidate unused glyphs.
void repackAtlas();
void repackAtlas(uint32 width, uint32 height);
// resize texture,
bool resizeAtlas();
// remove all glyphs from atlas, clear glyph cache, letter info is kept
void clearAtlas();
// if return true: newW, newH contains next size font atlas should be resized
// if return false: _TextureMaxW and _TextureMaxH is reached
bool getNextTextureSize(uint32 &newW, uint32 &newH) const;
/// Todo: serialize a font texture.
public:

View file

@ -205,7 +205,7 @@ public:
* set the shadow's size
* \param the shade extent
*/
virtual void setShadeExtent (float shext) = 0;
virtual void setShadeExtent (float x, float y) = 0;
/**
* set the shadow's color
* The alpha of the shade is multiplied at each draw with the alpha of the color. Default: (0,0,0,255)

View file

@ -0,0 +1,150 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_CSS_PARSER_H
#define CL_CSS_PARSER_H
#include "nel/misc/types_nl.h"
#include "nel/gui/css_style.h"
#include "nel/gui/css_selector.h"
namespace NLGUI
{
/**
* \brief CSS style parsing
* \date 2019-03-15 10:50 GMT
* \author Meelis Mägi (Nimetu)
*/
class CCssParser {
public:
// parse style declaration, eg "color: red; font-size: 10px;"
static TStyle parseDecls(const std::string &styleString);
// parse css stylesheet
void parseStylesheet(const std::string &cssString, std::vector<CCssStyle::SStyleRule> &rules);
private:
// stylesheet currently parsed
ucstring _Style;
// keep track of current position in _Style
size_t _Position;
std::vector<CCssStyle::SStyleRule> _Rules;
private:
// @media ( .. ) { .. }
void readAtRule();
// a#id.class[attr=val] { .. }
void readRule();
// move past whitespace
void skipWhitespace();
// skip valid IDENT
bool skipIdentifier();
// skip over {}, (), or [] block
void skipBlock();
// skip over string quoted with ' or "
void skipString();
// backslash escape
void escape();
// normalize newline chars and remove comments
void preprocess();
// parse selectors + combinators
std::vector<CCssSelector> parse_selector(const ucstring &sel, std::string &pseudoElement) const;
// parse selector and style
void parseRule(const ucstring &selectorString, const ucstring &styleString);
inline bool is_eof() const
{
return _Position >= _Style.size();
}
inline bool is_whitespace(ucchar ch) const
{
return (ch == (ucchar)' ' || ch == (ucchar)'\t' || ch == (ucchar)'\n');
}
inline bool is_hex(ucchar ch) const
{
return ((ch >= (ucchar)'0' && ch <= (ucchar)'9') ||
(ch >= (ucchar)'a' && ch <= (ucchar)'f') ||
(ch >= (ucchar)'A' && ch <= (ucchar)'F'));
}
inline bool maybe_escape() const
{
// escaping newline (\n) only allowed inside strings
return (_Style.size() - _Position) >= 1 && _Style[_Position] == (ucchar)'\\' && _Style[_Position+1] != '\n';
}
inline bool is_quote(ucchar ch) const
{
return ch== (ucchar)'"' || ch == (ucchar)'\'';
}
inline bool is_block_open(ucchar ch) const
{
return ch == (ucchar)'{' || ch == (ucchar)'[' || ch == (ucchar)'(';
}
inline bool is_block_close(ucchar ch, ucchar open) const
{
return ((open == '{' && ch == (ucchar)'}') ||
(open == '[' && ch == (ucchar)']') ||
(open == '(' && ch == (ucchar)')'));
}
inline bool is_comment_open() const
{
if (_Position+1 > _Style.size())
return false;
return _Style[_Position] == (ucchar)'/' && _Style[_Position+1] == (ucchar)'*';
}
inline bool is_nonascii(ucchar ch) const
{
return ch >= 0x80 /*&& ch <= 255*/;
}
inline bool is_alpha(ucchar ch) const
{
return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
}
inline bool is_digit(ucchar ch) const
{
return ch >= '0' && ch <= '9';
}
inline bool is_nmchar(ucchar ch) const
{
// checking escape here does not check if next char is '\n' or not
return ch == '_' || ch == '-' || is_alpha(ch) || is_digit(ch) || is_nonascii(ch) || ch == '\\'/*is_escape(ch)*/;
}
};
}//namespace
#endif // CL_CSS_PARSER_H

View file

@ -0,0 +1,107 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_CSS_SELECTOR_H
#define CL_CSS_SELECTOR_H
#include "nel/misc/types_nl.h"
namespace NLGUI
{
class CHtmlElement;
/**
* \brief CSS selector
* \date 2019-03-15 10:50 GMT
* \author Meelis Mägi (Nimetu)
*/
class CCssSelector
{
public:
enum ECombinator {
NONE = 0,
GENERAL_CHILD,
ADJACENT_SIBLING,
GENERAL_SIBLING,
CHILD_OF
};
struct SAttribute {
std::string key;
std::string value;
char op; // =, ~, |, ^, $, *
SAttribute(const std::string &k, const std::string &v, char o)
:key(k),value(v),op(o)
{}
};
std::string Element;
std::string Id;
std::vector<std::string> Class;
std::vector<SAttribute> Attr;
std::vector<std::string> PseudoClass;
// css combinator or \0 missing (first element)
char Combinator;
public:
// TODO: rewrite for ECombinator enum
CCssSelector(std::string elm="", std::string id="", std::string cls="", char comb = '\0');
// helper for sorting
uint32 specificity() const;
// set classes used, eg 'class1 class2'
void setClass(const std::string &cls);
// add attribute to selector
// ' ' op means 'key exists, ignore value'
void addAttribute(const std::string &key, const std::string &val = "", char op = ' ');
// add pseudo class to selector, eg 'first-child'
void addPseudoClass(const std::string &key);
// true if no rules have been defined
bool empty() const
{
return Element.empty() && Id.empty() && Class.empty() && Attr.empty() && PseudoClass.empty();
}
// Test current selector to html DOM element
// NOTE: Does not check combinator
bool match(const CHtmlElement &elm) const;
private:
bool matchClass(const CHtmlElement &elm) const;
bool matchAttributes(const CHtmlElement &elm) const;
bool matchPseudoClass(const CHtmlElement &elm) const;
// match An+B rule to child index (1 based)
bool matchNth(sint childNr, sint a, sint b) const;
// parse nth-child string to 'a' and 'b' components
// :nth-child(odd)
// :nth-child(even)
// :nth-child(An+B)
// :nth-child(-An+b)
void parseNth(const std::string &pseudo, sint &a, sint &b) const;
};
}//namespace
#endif // CL_CSS_SELECTOR_H

View file

@ -0,0 +1,227 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_CSS_STYLE_H
#define CL_CSS_STYLE_H
#include "nel/misc/types_nl.h"
#include "nel/misc/rgba.h"
#include "nel/gui/css_selector.h"
namespace NLGUI
{
class CHtmlElement;
typedef std::map<std::string, std::string> TStyle;
/**
* \brief CSS style rules
* \date 2019-03-15 10:50 GMT
* \author Meelis Mägi (Nimetu)
*/
class CStyleParams
{
public:
struct STextShadow
{
public:
STextShadow(bool enabled = false, bool outline = false, sint32 x=1, sint32 y=1, NLMISC::CRGBA color=NLMISC::CRGBA::Black)
: Enabled(enabled), Outline(outline), X(x), Y(y), Color(color)
{ }
bool Enabled;
bool Outline;
sint32 X;
sint32 Y;
NLMISC::CRGBA Color;
};
public:
CStyleParams () : FontFamily(""), TextColor(255,255,255,255), TextShadow()
{
FontSize=10;
FontWeight=400;
FontOblique=false;
Underlined=false;
StrikeThrough=false;
GlobalColor=false;
Width=-1;
Height=-1;
MaxWidth=-1;
MaxHeight=-1;
BorderWidth=1;
BackgroundColor=NLMISC::CRGBA::Black;
BackgroundColorOver=NLMISC::CRGBA::Black;
}
bool hasStyle(const std::string &key) const
{
return StyleRules.find(key) != StyleRules.end();
}
std::string getStyle(const std::string &key) const
{
TStyle::const_iterator it = StyleRules.find(key);
return (it != StyleRules.end() ? it->second : "");
}
public:
uint FontSize;
uint FontWeight;
bool FontOblique;
std::string FontFamily;
NLMISC::CRGBA TextColor;
STextShadow TextShadow;
bool GlobalColor;
bool Underlined;
bool StrikeThrough;
sint32 Width;
sint32 Height;
sint32 MaxWidth;
sint32 MaxHeight;
sint32 BorderWidth;
NLMISC::CRGBA BackgroundColor;
NLMISC::CRGBA BackgroundColorOver;
std::string WhiteSpace;
std::string TextAlign;
std::string VerticalAlign;
TStyle StyleRules;
};
class CCssStyle {
public:
struct SStyleRule {
std::vector<CCssSelector> Selector;
TStyle Properties;
// pseudo element like ':before'
std::string PseudoElement;
// returns selector specificity
uint specificity() const;
};
// 'browser' style, overwriten with '<html>'
CStyleParams Root;
// current element style
CStyleParams Current;
// known style rules sorted by specificity
std::vector<SStyleRule> _StyleRules;
private:
std::vector<CStyleParams> _StyleStack;
// test if str is one of "thin/medium/thick" and return its pixel value
bool scanCssLength(const std::string& str, uint32 &px) const;
// read style attribute
void getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams &current) const;
void getStyleParams(const TStyle &styleRules, CStyleParams &style, const CStyleParams &current) const;
// extract from styleRules into style.StyleRules (expand shorthand, normalize, calculate current font-size)
void normalize(const TStyle &styleRules, CStyleParams &style, const CStyleParams &current) const;
// apply style.StyleRyles
void apply(CStyleParams &style, const CStyleParams &current) const;
// merge src into dest by overwriting key in dest
void merge(TStyle &dst, const TStyle &src) const;
// match selector to dom path
bool match(const std::vector<CCssSelector> &selector, const CHtmlElement &elm) const;
// parse 'background' into 'background-color', 'background-image', etc
void parseBackgroundShorthand(const std::string &value, CStyleParams &style) const;
public:
void reset();
// parse <style>..</style> tag or css file content
void parseStylesheet(const std::string &styleString);
// set element style from matching css rules
void getStyleFor(CHtmlElement &elm) const;
inline uint getFontSizeSmaller() const
{
if (Current.FontSize < 5)
return 3;
return Current.FontSize-2;
}
sint styleStackIndex = 0;
inline void pushStyle()
{
styleStackIndex++;
_StyleStack.push_back(Current);
Current.Width=-1;
Current.Height=-1;
Current.MaxWidth=-1;
Current.MaxHeight=-1;
Current.BorderWidth=1;
Current.StyleRules.clear();
}
inline void popStyle()
{
styleStackIndex--;
if (_StyleStack.empty())
{
Current = Root;
}
else
{
Current = _StyleStack.back();
_StyleStack.pop_back();
}
}
// apply style to this.Root
void applyRootStyle(const std::string &styleString);
void applyRootStyle(const TStyle &styleRules);
// apply style to this.Current
void applyStyle(const std::string &styleString);
void applyStyle(const TStyle &styleRules);
void applyCssMinMax(sint32 &width, sint32 &height, sint32 minw=0, sint32 minh=0, sint32 maxw=0, sint32 maxh=0) const;
// check if current style property matches value
bool checkStyle(const std::string &key, const std::string &val) const
{
return Current.hasStyle(key) && Current.getStyle(key) == val;
}
bool hasStyle(const std::string &key) const
{
return Current.hasStyle(key);
}
std::string getStyle(const std::string &key) const
{
return Current.getStyle(key);
}
};
}//namespace
#endif // CL_CSS_STYLE_H

View file

@ -175,6 +175,7 @@ namespace NLGUI
bool _CallingAH : 1;
bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button
bool _Frozen : 1;
bool _Scale : 1;
// For Target Scroller only: the target offset step in pixel.
sint32 _TargetStepX;

View file

@ -111,9 +111,19 @@ namespace NLGUI
sint32 getWMin() const { return _WMin; }
void setWMin( sint32 wmin ) { _WMin = wmin; }
sint32 getHMin() const { return _HMin; }
void setHMin( sint32 hmin ) { _HMin = hmin; }
// Compute Size according to bitmap and Text (Ensure as big as possible button)
sint32 getWMax() const;
// Set texture directly without _l.tga, _m.tga, _r.tga convention
// Texture size is only read from normal textures
// If updateHeight == false, then _BmpH will keep its value
void setTexture(const std::string &l, const std::string &m, const std::string &r, bool updateHeight = true);
void setTexturePushed(const std::string &l, const std::string &m, const std::string &r);
void setTextureOver(const std::string &l, const std::string &m, const std::string &r);
int luaGetViewText(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton)
@ -122,6 +132,7 @@ namespace NLGUI
REFLECT_SINT32("text_x", getTextX, setTextX)
REFLECT_SINT32("wmargin", getWMargin, setWMargin)
REFLECT_SINT32("wmin", getWMin, setWMin)
REFLECT_SINT32("hmin", getHMin, setHMin)
REFLECT_LUA_METHOD("getViewText", luaGetViewText)
REFLECT_EXPORT_END
@ -151,8 +162,8 @@ namespace NLGUI
sint32 _BmpLeftW, _BmpMiddleW, _BmpRightW, _BmpH;
// Value to add to TextW to get button W.
sint32 _WMargin;
// Min W Value
sint32 _WMin;
// Min W, H Value
sint32 _WMin, _HMin;
sint32 _TextY;
sint32 _TextX;
THotSpot _TextPosRef;

View file

@ -17,19 +17,22 @@
#ifndef CL_CURL_CERTIFICATES_HTML_H
#define CL_CURL_CERTIFICATES_HTML_H
#include <curl/curl.h>
#include "nel/misc/types_nl.h"
// forward declaration to avoid curl.h inclusion everywhere
typedef void CURL;
namespace NLGUI
{
#if defined(NL_OS_WINDOWS)
class CCurlCertificates {
class CCurlCertificates
{
public:
// cURL SSL certificate loading
static CURLcode sslCtxFunction(CURL *curl, void *sslctx, void *parm);
// allow to use custom PEM certificates
static void addCertificateFile(const std::string &cert);
// set all CURL options to use custom SSL context function
static void useCertificates(CURL *curl);
};
#endif // NL_OS_WINDOWS
} // namespace
#endif

View file

@ -85,6 +85,7 @@ namespace NLGUI
// view text
void setViewText(const ucstring & text);
ucstring getViewText() const;
CViewText *getViewText();
void setTexture(uint i, const ucstring &texture);

View file

@ -17,21 +17,22 @@
#ifndef CL_GROUP_HTML_H
#define CL_GROUP_HTML_H
#include <curl/curl.h>
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/group_scrolltext.h"
#include "nel/gui/group_tree.h"
#include "nel/gui/ctrl_button.h"
#include "nel/gui/group_table.h"
#include "nel/gui/libwww_types.h"
#include "nel/gui/html_element.h"
#include "nel/gui/css_style.h"
typedef std::map<std::string, std::string> TStyle;
// forward declaration
typedef void CURLM;
namespace NLGUI
{
class CCtrlButton;
class CCtrlTextButton;
class CCtrlScroll;
class CGroupList;
class CGroupMenu;
@ -67,43 +68,17 @@ namespace NLGUI
/// Maximum concurrent MultiCurl connections per CGroupHTML instance
sint32 curlMaxConnections;
SWebOptions(): curlMaxConnections(2)
SWebOptions(): curlMaxConnections(5)
{
}
};
static SWebOptions options;
class CStyleParams
{
public:
CStyleParams () : FontFamily(""), TextColor(255,255,255,255)
{
FontSize=10;
FontWeight=400;
FontOblique=false;
Underlined=false;
StrikeThrough=false;
GlobalColor=false;
Width=-1;
Height=-1;
MaxWidth=-1;
MaxHeight=-1;
}
uint FontSize;
uint FontWeight;
bool FontOblique;
std::string FontFamily;
NLMISC::CRGBA TextColor;
bool GlobalColor;
bool Underlined;
bool StrikeThrough;
sint32 Width;
sint32 Height;
sint32 MaxWidth;
sint32 MaxHeight;
};
// ImageDownload system
enum TDataType {ImgType= 0, BnpType, StylesheetType};
enum TImageType {NormalImage=0, OverImage};
// Constructor
CGroupHTML(const TCtorParam &param);
~CGroupHTML();
@ -122,8 +97,11 @@ namespace NLGUI
// Browse
virtual void browse (const char *url);
// load css from local file and insert into active stylesheet collection
void parseStylesheetFile(const std::string &fname);
// parse html string using libxml2 parser
virtual bool parseHtml(std::string htmlString);
bool parseHtml(const std::string &htmlString);
// Refresh
void refresh();
@ -134,13 +112,8 @@ namespace NLGUI
// Browse error
void browseError (const char *msg);
// stop browse
void stopBrowse ();
bool isBrowsing();
void clean() { stopBrowse(); updateRefreshButton(); removeContent(); }
// Update coords
void updateCoords();
@ -149,6 +122,10 @@ namespace NLGUI
// End of the paragraph
void endParagraph();
// add image download (used by view_bitmap.cpp to load web images)
void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage);
std::string localImageName(const std::string &url);
// Timeout
void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);}
@ -237,6 +214,8 @@ namespace NLGUI
void browseUndo ();
// Redo browse: Browse the precedent url undoed. no op if none
void browseRedo ();
// disable refresh button
void clearRefresh();
// clear undo/redo
void clearUndoRedo();
@ -245,14 +224,14 @@ namespace NLGUI
void setURL(const std::string &url);
int luaClearRefresh(CLuaState &ls);
int luaClearUndoRedo(CLuaState &ls);
int luaBrowse(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);
int luaParseHtml(CLuaState &ls);
int luaRenderHtml(CLuaState &ls);
@ -260,43 +239,38 @@ namespace NLGUI
REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText)
REFLECT_LUA_METHOD("browse", luaBrowse)
REFLECT_LUA_METHOD("refresh", luaRefresh)
REFLECT_LUA_METHOD("clearUndoRedo", luaClearUndoRedo)
REFLECT_LUA_METHOD("clearRefresh", luaClearRefresh)
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_LUA_METHOD("parseHtml", luaParseHtml)
REFLECT_LUA_METHOD("renderHtml", luaRenderHtml)
REFLECT_STRING("url", getURL, setURL)
REFLECT_FLOAT("timeout", getTimeout, setTimeout)
REFLECT_STRING("title", getTitle, setTitle)
REFLECT_EXPORT_END
protected :
// \name callback from libwww
// Begin of the parsing of a HTML document
// Begin of the rendering of a HTML document
virtual void beginBuild ();
// End of the parsing of a HTML document
// End of the rendering of a HTML document
virtual void endBuild ();
// A new text block has been parsed
virtual void addText (const char * buf, int len);
// A new begin HTML element has been parsed (<IMG> for exemple)
virtual void beginElement (uint element_number, const std::vector<bool> &present, const std::vector<const char *> &value);
virtual void beginElement(CHtmlElement &elm);
// A new end HTML element has been parsed (</IMG> for exemple)
virtual void endElement (uint element_number);
// A new begin unparsed element has been found
virtual void beginUnparsedElement(const char *buffer, int length);
// A new end unparsed element has been found
virtual void endUnparsedElement(const char *buffer, int length);
virtual void endElement(CHtmlElement &elm);
// Add GET params to the url
virtual void addHTTPGetParams (std::string &url, bool trustedDomain);
@ -304,16 +278,15 @@ namespace NLGUI
// Add POST params to the libwww list
virtual void addHTTPPostParams (SFormFields &formfields, bool trustedDomain);
// the current request is terminated
virtual void requestTerminated();
// libxml2 html parser functions
void htmlElement(xmlNode *node, int element_number);
void htmlWalkDOM(xmlNode *a_node);
// Get Home URL
virtual std::string home();
// parse dom node and all child nodes recursively
void renderDOM(CHtmlElement &elm);
// Clear style stack and restore default style
void resetCssStyle();
// Parse style html tag
TStyle parseStyle(const std::string &str_styles);
@ -341,7 +314,7 @@ namespace NLGUI
void addString(const ucstring &str);
// Add an image in the current paragraph
void addImage(const char *image, bool reloadImg=false, const CStyleParams &style = CStyleParams());
void addImage(const std::string &id, const std::string &img, bool reloadImg=false, const CStyleParams &style = CStyleParams());
// Add a text area in the current paragraph
CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content, uint maxlength);
@ -366,6 +339,8 @@ namespace NLGUI
// Set the title
void setTitle (const ucstring &title);
void setTitle (const std::string &title);
std::string getTitle() const;
// Lookup a url in local file system
bool lookupLocalFile (std::string &result, const char *url, bool isUrl);
@ -378,6 +353,14 @@ namespace NLGUI
// Current URL
std::string _DocumentUrl;
std::string _DocumentDomain;
std::string _DocumentHtml; // not updated, only set by first render
// If true, then render _DocumentHtml on next update (replaces content)
bool _RenderNextTime;
// true if renderer is waiting for css files to finish downloading (link rel=stylesheet)
bool _WaitingForStylesheet;
// list of css file urls that are queued up for download
std::vector<std::string> _StylesheetQueue;
// Valid base href was found
bool _IgnoreBaseUrlTag;
// Fragment from loading url
@ -410,7 +393,6 @@ namespace NLGUI
// Browsing..
bool _Browsing;
bool _Connecting;
double _TimeoutValue; // the timeout in seconds
double _ConnectingTimeout;
sint _RedirectsRemaining;
@ -495,79 +477,13 @@ namespace NLGUI
// IL mode
bool _LI;
// Current text color
std::vector<NLMISC::CRGBA> _TextColor;
inline const NLMISC::CRGBA &getTextColor() const
{
if (_TextColor.empty())
return TextColor;
return _TextColor.back();
}
// Current global color flag
std::vector<bool> _GlobalColor;
inline bool getGlobalColor() const
{
if (_GlobalColor.empty())
return false;
return _GlobalColor.back();
}
// Current font name
std::vector<std::string> _FontFamily;
inline const char* getFontFamily() const
{
if (_FontFamily.empty())
return "";
return _FontFamily.back().c_str();
}
// Current font size
std::vector<uint> _FontSize;
inline uint getFontSize() const
{
if (_FontSize.empty())
return TextFontSize;
return _FontSize.back();
}
inline uint getFontSizeSmaller() const
{
if (getFontSize() < 5)
return 3;
return getFontSize()-2;
}
std::vector<uint> _FontWeight;
inline uint getFontWeight() const
{
if (_FontWeight.empty())
return 400;
return _FontWeight.back();
}
std::vector<bool> _FontOblique;
inline bool getFontOblique() const
{
if (_FontOblique.empty())
return false;
return _FontOblique.back();
}
std::vector<bool> _FontUnderlined;
inline bool getFontUnderlined() const
{
if (_FontUnderlined.empty())
return false;
return _FontUnderlined.back();
}
std::vector<bool> _FontStrikeThrough;
inline bool getFontStrikeThrough() const
{
if (_FontStrikeThrough.empty())
return false;
return _FontStrikeThrough.back();
}
// Keep track of current element style
CCssStyle _Style;
CHtmlElement _HtmlDOM;
CHtmlElement *_CurrentHTMLElement;
// Backup of CurrentHTMLElement->nextSibling before ::beginElement() is called
// for luaParseHtml() to insert nodes into right place in right order
CHtmlElement *_CurrentHTMLNextSibling;
// Current link
std::vector<std::string> _Link;
@ -720,6 +636,8 @@ namespace NLGUI
return 0;
return _Indent.back();
}
// Current node is a title
bool _Title;
@ -790,10 +708,6 @@ namespace NLGUI
typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap;
static TGroupHtmlByUIDMap _GroupHtmlByUID;
// read style attribute
void getStyleParams(const std::string &styleString, CStyleParams &style, bool inherit = true);
void applyCssMinMax(sint32 &width, sint32 &height, sint32 minw=0, sint32 minh=0, sint32 maxw=0, sint32 maxh=0);
// load and render local html file (from bnp for example)
void doBrowseLocalFile(const std::string &filename);
@ -807,12 +721,13 @@ namespace NLGUI
void buildHTTPPostParams (SFormFields &formfields);
private:
friend class CHtmlParser;
// move src->Children into CurrentHtmlElement.parent.children element
void spliceFragment(std::list<CHtmlElement>::iterator src);
// decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str);
// ImageDownload system
enum TDataType {ImgType= 0, BnpType};
enum TImageType {NormalImage=0, OverImage};
struct CDataImageDownload
{
@ -830,10 +745,11 @@ namespace NLGUI
{
public:
CDataDownload(const std::string &u, const std::string &d, TDataType t, CViewBase *i, const std::string &s, const std::string &m, const CStyleParams &style = CStyleParams(), const TImageType imagetype = NormalImage)
: data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0)
: data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0), ConnectionTimeout(60)
{
if (t == ImgType) imgs.push_back(CDataImageDownload(i, style, imagetype));
}
~CDataDownload();
public:
CCurlWWWData *data;
@ -845,40 +761,131 @@ namespace NLGUI
uint32 redirects;
FILE *fp;
std::vector<CDataImageDownload> imgs;
uint32 ConnectionTimeout;
};
std::vector<CDataDownload> Curls;
std::list<CDataDownload> Curls;
CURLM *MultiCurl;
int RunningCurls;
bool startCurlDownload(CDataDownload &download);
void finishCurlDownload(const CDataDownload &download);
void pumpCurlQueue();
void initImageDownload();
void checkImageDownload();
void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage);
std::string localImageName(const std::string &url);
std::string getAbsoluteUrl(const std::string &url);
bool isTrustedDomain(const std::string &domain);
void setImage(CViewBase *view, const std::string &file, const TImageType type);
void setImageSize(CViewBase *view, const CStyleParams &style = CStyleParams());
void setTextButtonStyle(CCtrlTextButton *ctrlButton, const CStyleParams &style);
void setTextStyle(CViewText *pVT, const CStyleParams &style);
// BnpDownload system
void initBnpDownload();
void checkBnpDownload();
bool addBnpDownload(std::string url, const std::string &action, const std::string &script, const std::string &md5sum);
std::string localBnpName(const std::string &url);
// add css file from <link href=".." rel="stylesheet"> to download queue
void addStylesheetDownload(std::vector<std::string> links);
// stop all curl downalods (html and data)
void releaseDownloads();
void checkDownloads();
// _CurlWWW download finished
void htmlDownloadFinished(bool success, const std::string &error);
// images, stylesheets, etc finished downloading
void dataDownloadFinished(bool success, const std::string &error, CDataDownload &data);
// HtmlType download finished
void htmlDownloadFinished(const std::string &content, const std::string &type, long code);
// cURL transfer callbacks
static size_t curlHeaderCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData);
static size_t curlDataCallback(char *buffer, size_t size, size_t nmemb, void *pCCurlWWWData);
static size_t curlProgressCallback(void *pCCurlWWWData, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
// stylesheet finished downloading. if local file does not exist, then it failed (404)
void cssDownloadFinished(const std::string &url, const std::string &local);
// read common table/tr/td parameters and push them to _CellParams
void getCellsParameters(const CHtmlElement &elm, bool inherit);
// render _HtmlDOM
void renderDocument();
// :before, :after rendering
void renderPseudoElement(const std::string &pseudo, const CHtmlElement &elm);
// apply background from current style (for html, body)
void applyBackground(const CHtmlElement &elm);
// HTML elements
void htmlA(const CHtmlElement &elm);
void htmlAend(const CHtmlElement &elm);
void htmlBASE(const CHtmlElement &elm);
void htmlBODY(const CHtmlElement &elm);
void htmlBR(const CHtmlElement &elm);
void htmlDD(const CHtmlElement &elm);
void htmlDDend(const CHtmlElement &elm);
//void htmlDEL(const CHtmlElement &elm);
void htmlDIV(const CHtmlElement &elm);
void htmlDIVend(const CHtmlElement &elm);
void htmlDL(const CHtmlElement &elm);
void htmlDLend(const CHtmlElement &elm);
void htmlDT(const CHtmlElement &elm);
void htmlDTend(const CHtmlElement &elm);
//void htmlEM(const CHtmlElement &elm);
void htmlFONT(const CHtmlElement &elm);
void htmlFORM(const CHtmlElement &elm);
void htmlH(const CHtmlElement &elm);
void htmlHend(const CHtmlElement &elm);
void htmlHEAD(const CHtmlElement &elm);
void htmlHEADend(const CHtmlElement &elm);
void htmlHR(const CHtmlElement &elm);
void htmlHTML(const CHtmlElement &elm);
void htmlI(const CHtmlElement &elm);
void htmlIend(const CHtmlElement &elm);
void htmlIMG(const CHtmlElement &elm);
void htmlINPUT(const CHtmlElement &elm);
void htmlLI(const CHtmlElement &elm);
void htmlLIend(const CHtmlElement &elm);
void htmlLUA(const CHtmlElement &elm);
void htmlLUAend(const CHtmlElement &elm);
void htmlMETA(const CHtmlElement &elm);
void htmlOBJECT(const CHtmlElement &elm);
void htmlOBJECTend(const CHtmlElement &elm);
void htmlOL(const CHtmlElement &elm);
void htmlOLend(const CHtmlElement &elm);
void htmlOPTION(const CHtmlElement &elm);
void htmlOPTIONend(const CHtmlElement &elm);
void htmlP(const CHtmlElement &elm);
void htmlPend(const CHtmlElement &elm);
void htmlPRE(const CHtmlElement &elm);
void htmlPREend(const CHtmlElement &elm);
void htmlSCRIPT(const CHtmlElement &elm);
void htmlSCRIPTend(const CHtmlElement &elm);
void htmlSELECT(const CHtmlElement &elm);
void htmlSELECTend(const CHtmlElement &elm);
//void htmlSMALL(const CHtmlElement &elm);
//void htmlSPAN(const CHtmlElement &elm);
//void htmlSTRONG(const CHtmlElement &elm);
void htmlSTYLE(const CHtmlElement &elm);
void htmlSTYLEend(const CHtmlElement &elm);
void htmlTABLE(const CHtmlElement &elm);
void htmlTABLEend(const CHtmlElement &elm);
void htmlTD(const CHtmlElement &elm);
void htmlTDend(const CHtmlElement &elm);
void htmlTEXTAREA(const CHtmlElement &elm);
void htmlTEXTAREAend(const CHtmlElement &elm);
void htmlTH(const CHtmlElement &elm);
void htmlTHend(const CHtmlElement &elm);
void htmlTITLE(const CHtmlElement &elm);
void htmlTITLEend(const CHtmlElement &elm);
void htmlTR(const CHtmlElement &elm);
void htmlTRend(const CHtmlElement &elm);
//void htmlU(const CHtmlElement &elm);
void htmlUL(const CHtmlElement &elm);
void htmlULend(const CHtmlElement &elm);
};
// adapter group that store y offset for inputs inside an html form

View file

@ -351,6 +351,9 @@ namespace NLGUI
void setMinW(sint32 minW);
void setMinH(sint32 minH);
// change fontsize for new menu items
void setFontSize(uint32 fontSize);
// Gray a line on the RootMenu
void setGrayedLine(uint line, bool g);

View file

@ -206,6 +206,11 @@ namespace NLGUI
invalidateContent();
}
/// temporarily enable mouse over effect
// will be automatically disabled when mouse leaves element
void enableTempOver() { _TempOver = true; }
void disableTempOver() { _TempOver = false; }
/// \from CInterfaceElement
void onInvalidateContent();
sint32 getMaxUsedW() const;
@ -233,6 +238,8 @@ namespace NLGUI
// Do we have a color under the element pointed by the mouse
bool _Over;
// Temporarily force mouse over effect. Deactivated when mouse moves away
bool _TempOver;
// If over is true so we have a color
NLMISC::CRGBA _OverColor;

View file

@ -0,0 +1,86 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_HTML_ELEMENT_H
#define CL_HTML_ELEMENT_H
#include "nel/misc/types_nl.h"
#include "nel/gui/css_style.h"
namespace NLGUI
{
/**
* \brief HTML element
* \date 2019-04-25 18:23 GMT
* \author Meelis Mägi (Nimetu)
*/
class CHtmlElement
{
public:
enum ENodeType {
NONE = 0,
ELEMENT_NODE = 1,
TEXT_NODE = 3,
};
uint ID; // libwww element enum
ENodeType Type;
std::string Value; // text node value or element node name
std::map<std::string, std::string> Attributes;
std::list<CHtmlElement> Children;
// class names for css matching
std::set<std::string> ClassNames;
// defined style and :before/:after pseudo elements
TStyle Style;
TStyle StyleBefore;
TStyle StyleAfter;
// hierarchy
CHtmlElement *parent;
CHtmlElement *previousSibling;
CHtmlElement *nextSibling;
// n'th ELEMENT_NODE in parent.Children, for :nth-child() rules
uint childIndex;
CHtmlElement(ENodeType type = NONE, std::string value = "");
// returns true if rhs is same pointer
friend bool operator==(const CHtmlElement &lhs, const CHtmlElement &rhs)
{
return &lhs == &rhs;
}
bool hasAttribute(const std::string &key) const;
bool hasNonEmptyAttribute(const std::string &key) const;
std::string getAttribute(const std::string &key) const;
bool hasClass(const std::string &key) const;
// update Children index/parent/next/prevSibling pointers
void reindexChilds();
// debug
std::string toString(bool tree = false, uint depth = 0) const;
};
}
#endif

View file

@ -0,0 +1,52 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_HTML_PARSER_H
#define CL_HTML_PARSER_H
#include "nel/misc/types_nl.h"
namespace NLGUI
{
class CHtmlElement;
/**
* \brief HTML parsing
* \date 2019-03-15 10:50 GMT
* \author Meelis Mägi (Nimetu)
*/
class CHtmlParser
{
public:
bool parseHtml(std::string htmlString) const;
// parse html string into DOM, extract <style> tags into styleString, <link stylesheet> urls into links
void getDOM(std::string htmlString, CHtmlElement &parent, std::string &styleString, std::vector<std::string> &links) const;
private:
// iterate over libxml html tree, build DOM, and join all <style> tags together
void parseNode(xmlNode *a_node, CHtmlElement &parent, std::string &styleString, std::vector<std::string> &links) const;
// read <style> tag and add its content to styleString
void parseStyle(xmlNode *a_node, std::string &styleString) const;
// update parent/sibling in elm.Children
void reindexChilds(CHtmlElement &elm) const;
};
}
#endif

View file

@ -42,7 +42,7 @@ namespace NLGUI
class CStrictTransportSecurity
{
public:
typedef std::map<std::string, SHSTSObject> THSTSObject;
typedef std::map<std::string, SHSTSObject> THSTSObjectMap;
static CStrictTransportSecurity* getInstance();
static void release();
@ -66,7 +66,7 @@ namespace NLGUI
~CStrictTransportSecurity();
std::string _Filename;
THSTSObject _Domains;
THSTSObjectMap _Domains;
};
}

View file

@ -38,6 +38,16 @@ namespace NLGUI
class IActionHandler;
class CGroupParagraph;
/**
* Interface for UI scale change event
*/
class IInterfaceScaleWatcher
{
public:
virtual ~IInterfaceScaleWatcher(){}
virtual void onInterfaceScaleChanged()=0;
};
/**
* A visitor to walk a tree of interface elements and apply a teartment on them.
*
@ -66,7 +76,7 @@ namespace NLGUI
* \author Nevrax France
* \date 2002
*/
class CInterfaceElement : public CReflectableRefPtrTarget, public NLMISC::IStreamable
class CInterfaceElement : public IInterfaceScaleWatcher, public CReflectableRefPtrTarget, public NLMISC::IStreamable
{
public:
@ -182,6 +192,9 @@ namespace NLGUI
void setMarginLeft(sint32 m) { _MarginLeft = m; }
sint32 getMarginLeft() const { return _MarginLeft; }
// Return inner width for child elements
virtual sint32 getInnerWidth() const;
/**
* Get the max width used by the window.
*
@ -406,6 +419,10 @@ namespace NLGUI
*/
virtual void onInvalidateContent() {}
/* Element UI scale change event callback
*/
virtual void onInterfaceScaleChanged() {}
// called by interfaceManager for master window only
void resetInvalidCoords();

View file

@ -164,6 +164,7 @@ namespace NLGUI
sint32 getMaxH () const { return _MaxH; }
sint32 getMaxWReal () const { return _Active ? _MaxWReal : 0; }
sint32 getMaxHReal () const { return _Active ? _MaxHReal : 0; }
sint32 getInnerWidth () const;
sint32 getOfsX () const { return _OffsetX; }
sint32 getOfsY () const { return _OffsetY; }
bool getResizeFromChildW() const { return _ResizeFromChildW; }

View file

@ -20,10 +20,10 @@
#ifndef CL_LIB_WWW_H
#define CL_LIB_WWW_H
#include <curl/curl.h>
#include "nel/misc/rgba.h"
#include "nel/gui/libwww_types.h"
// forward declaration to avoid curl.h inclusion everywhere
typedef void CURL;
namespace NLGUI
{
@ -31,244 +31,157 @@ namespace NLGUI
class CCtrlScroll;
class CGroupList;
// ***************************************************************************
// List of HTML elements. Does not need to be sorted
typedef enum _HTMLElement {
HTML_HTML,
HTML_BODY,
// meta
HTML_BASE,
HTML_HEAD,
HTML_LINK,
HTML_META,
HTML_STYLE,
HTML_TITLE,
// content sectioning
HTML_ADDRESS,
HTML_ARTICLE,
HTML_ASIDE,
HTML_FOOTER,
HTML_HEADER,
HTML_H1,
HTML_H2,
HTML_H3,
HTML_H4,
HTML_H5,
HTML_H6,
HTML_HGROUP,
HTML_MAIN,
HTML_NAV,
HTML_SECTION,
// text content
HTML_BLOCKQUOTE,
HTML_DD,
HTML_DIR,
HTML_DIV,
HTML_DL,
HTML_DT,
HTML_FIGCAPTION,
HTML_FIGURE,
HTML_HR,
HTML_LI,
HTML_OL,
HTML_P,
HTML_PRE,
HTML_UL,
// inline text
HTML_A,
HTML_ABBR,
HTML_B,
HTML_BDI,
HTML_BDO,
HTML_BR,
HTML_CITE,
HTML_CODE,
HTML_DATA,
HTML_DFN,
HTML_EM,
HTML_I,
HTML_KBD,
HTML_MARK,
HTML_Q,
HTML_RB,
HTML_RP,
HTML_RT,
HTML_RTC,
HTML_RUBY,
HTML_S,
HTML_SAMP,
HTML_SMALL,
HTML_SPAN,
HTML_STRONG,
HTML_SUB,
HTML_SUP,
HTML_TIME,
HTML_TT,
HTML_U,
HTML_VAR,
HTML_WBR,
// image, multimedia
HTML_AREA,
HTML_AUDIO,
HTML_IMG,
HTML_MAP,
HTML_TRACK,
HTML_VIDEO,
// embedded content
HTML_APPLET,
HTML_EMBED,
HTML_IFRAME,
HTML_NOEMBED,
HTML_OBJECT,
HTML_PARAM,
HTML_PICTURE,
HTML_SOURCE,
// scripting
HTML_CANVAS,
HTML_NOSCRIPT,
HTML_SCRIPT,
// demarcating edits
HTML_DEL,
HTML_INS,
// table
HTML_CAPTION,
HTML_COL,
HTML_COLGROUP,
HTML_TABLE,
HTML_TBODY,
HTML_TD,
HTML_TFOOT,
HTML_TH,
HTML_THEAD,
HTML_TR,
// forms
HTML_BUTTON,
HTML_DATALIST,
HTML_FIELDSET,
HTML_FORM,
HTML_INPUT,
HTML_LABEL,
HTML_LEGEND,
HTML_METER,
HTML_OPTGROUP,
HTML_OPTION,
HTML_OUTPUT,
HTML_PROGRESS,
HTML_SELECT,
HTML_TEXTAREA,
// interactive elements
HTML_DETAILS,
HTML_DIALOG,
HTML_MENU,
HTML_MENUITEM,
HTML_SUMMARY,
// -- tags for ryzom --
HTML_FONT,
HTML_LUA,
// last entry for unknown elements
HTML_NB_ELEMENTS
} HTMLElement;
// Legacy function from libwww
SGML_dtd * HTML_dtd (void);
// Init the libwww
void initLibWWW();
// case insensitive lookup for HTMLElement enum by name
// return HTML_NB_ELEMENTS if no match
HTMLElement htmlElementLookup(const char *name);
// ***************************************************************************
// Some DTD table
// Here, modify the DTD table to change the HTML parser (add new tags for exemples)
#undef HTML_ATTR
#define HTML_ATTR(t,a) MY_HTML_##t##_##a
enum
{
HTML_ATTR(A,ACCESSKEY) = 0,
HTML_ATTR(A,CHARSET),
HTML_ATTR(A,CLASS),
HTML_ATTR(A,COORDS),
HTML_ATTR(A,DIR),
HTML_ATTR(A,HREF),
HTML_ATTR(A,HREFLANG),
HTML_ATTR(A,ID),
HTML_ATTR(A,NAME),
HTML_ATTR(A,REL),
HTML_ATTR(A,REV),
HTML_ATTR(A,SHAPE),
HTML_ATTR(A,STYLE),
HTML_ATTR(A,TABINDEX),
HTML_ATTR(A,TARGET),
HTML_ATTR(A,TYPE),
HTML_ATTR(A,TITLE),
HTML_ATTR(A,Z_ACTION_CATEGORY),
HTML_ATTR(A,Z_ACTION_PARAMS),
HTML_ATTR(A,Z_ACTION_SHORTCUT),
};
enum
{
HTML_ATTR(TABLE,ALIGN) = 0,
HTML_ATTR(TABLE,BGCOLOR),
HTML_ATTR(TABLE,BORDER),
HTML_ATTR(TABLE,BORDERCOLOR),
HTML_ATTR(TABLE,CELLPADDING),
HTML_ATTR(TABLE,CELLSPACING),
HTML_ATTR(TABLE,CLASS),
HTML_ATTR(TABLE,DIR),
HTML_ATTR(TABLE,FRAME),
HTML_ATTR(TABLE,ID),
HTML_ATTR(TABLE,L_MARGIN),
HTML_ATTR(TABLE,LANG),
HTML_ATTR(TABLE,NOWRAP),
HTML_ATTR(TABLE,RULES),
HTML_ATTR(TABLE,SUMMARY),
HTML_ATTR(TABLE,STYLE),
HTML_ATTR(TABLE,TITLE),
HTML_ATTR(TABLE,VALIGN),
HTML_ATTR(TABLE,WIDTH)
};
enum
{
HTML_ATTR(TR,ALIGN) = 0,
HTML_ATTR(TR,BGCOLOR),
HTML_ATTR(TR,L_MARGIN),
HTML_ATTR(TR,NOWRAP),
HTML_ATTR(TR,VALIGN),
};
enum
{
HTML_ATTR(TD,ABBR) = 0,
HTML_ATTR(TD,ALIGN),
HTML_ATTR(TD,AXIS),
HTML_ATTR(TD,BGCOLOR),
HTML_ATTR(TD,CHAR),
HTML_ATTR(TD,CHAROFF),
HTML_ATTR(TD,CLASS),
HTML_ATTR(TD,COLSPAN),
HTML_ATTR(TD,DIR),
HTML_ATTR(TD,ID),
HTML_ATTR(TD,HEADERS),
HTML_ATTR(TD,HEIGHT),
HTML_ATTR(TD,L_MARGIN),
HTML_ATTR(TD,LANG),
HTML_ATTR(TD,NOWRAP),
HTML_ATTR(TD,ROWSPAN),
HTML_ATTR(TD,SCOPE),
HTML_ATTR(TD,STYLE),
HTML_ATTR(TD,TITLE),
HTML_ATTR(TD,VALIGN),
HTML_ATTR(TD,WIDTH),
};
enum
{
HTML_ATTR(IMG,ALIGN) = 0,
HTML_ATTR(IMG,ALT),
HTML_ATTR(IMG,BORDER),
HTML_ATTR(IMG,CLASS),
HTML_ATTR(IMG,DIR),
HTML_ATTR(IMG,GLOBAL_COLOR),
HTML_ATTR(IMG,HEIGHT),
HTML_ATTR(IMG,HSPACE),
HTML_ATTR(IMG,ID),
HTML_ATTR(IMG,ISMAP),
HTML_ATTR(IMG,LANG),
HTML_ATTR(IMG,LONGDESC),
HTML_ATTR(IMG,SRC),
HTML_ATTR(IMG,STYLE),
HTML_ATTR(IMG,TITLE),
HTML_ATTR(IMG,USEMAP),
HTML_ATTR(IMG,VSPACE),
HTML_ATTR(IMG,WIDTH),
// not sorted to keep enum values
HTML_ATTR(IMG,DATA_OVER_SRC),
};
enum
{
HTML_ATTR(INPUT,ACCEPT) = 0,
HTML_ATTR(INPUT,ACCESSKEY),
HTML_ATTR(INPUT,ALIGN),
HTML_ATTR(INPUT,ALT),
HTML_ATTR(INPUT,CHECKED),
HTML_ATTR(INPUT,CLASS),
HTML_ATTR(INPUT,DIR),
HTML_ATTR(INPUT,DISABLED),
HTML_ATTR(INPUT,GLOBAL_COLOR),
HTML_ATTR(INPUT,ID),
HTML_ATTR(INPUT,LANG),
HTML_ATTR(INPUT,MAXLENGTH),
HTML_ATTR(INPUT,NAME),
HTML_ATTR(INPUT,READONLY),
HTML_ATTR(INPUT,SIZE),
HTML_ATTR(INPUT,SRC),
HTML_ATTR(INPUT,STYLE),
HTML_ATTR(INPUT,TABINDEX),
HTML_ATTR(INPUT,TITLE),
HTML_ATTR(INPUT,TYPE),
HTML_ATTR(INPUT,USEMAP),
HTML_ATTR(INPUT,VALUE),
HTML_ATTR(INPUT,Z_BTN_TMPL),
HTML_ATTR(INPUT,Z_INPUT_TMPL),
HTML_ATTR(INPUT,Z_INPUT_WIDTH),
};
enum
{
HTML_ATTR(TEXTAREA,CLASS) = 0,
HTML_ATTR(TEXTAREA,COLS),
HTML_ATTR(TEXTAREA,DIR),
HTML_ATTR(TEXTAREA,DISABLED),
HTML_ATTR(TEXTAREA,ID),
HTML_ATTR(TEXTAREA,LANG),
HTML_ATTR(TEXTAREA,MAXLENGTH),
HTML_ATTR(TEXTAREA,NAME),
HTML_ATTR(TEXTAREA,READONLY),
HTML_ATTR(TEXTAREA,ROWS),
HTML_ATTR(TEXTAREA,STYLE),
HTML_ATTR(TEXTAREA,TABINDEX),
HTML_ATTR(TEXTAREA,TITLE),
HTML_ATTR(TEXTAREA,Z_INPUT_TMPL),
};
enum
{
HTML_ATTR(P,QUICK_HELP_CONDITION) = 0,
HTML_ATTR(P,QUICK_HELP_EVENTS),
HTML_ATTR(P,QUICK_HELP_LINK),
HTML_ATTR(P,NAME),
};
enum
{
HTML_ATTR(DIV,CLASS) = 0,
HTML_ATTR(DIV,ID),
HTML_ATTR(DIV,NAME),
HTML_ATTR(DIV,STYLE),
};
enum
{
HTML_ATTR(SPAN,CLASS) = 0,
HTML_ATTR(SPAN,ID),
HTML_ATTR(SPAN,STYLE),
};
enum
{
HTML_ATTR(H1,CLASS) = 0,
HTML_ATTR(H1,ID),
HTML_ATTR(H1,STYLE),
};
enum
{
HTML_ATTR(H2,CLASS) = 0,
HTML_ATTR(H2,ID),
HTML_ATTR(H2,STYLE),
};
enum
{
HTML_ATTR(H3,CLASS) = 0,
HTML_ATTR(H3,ID),
HTML_ATTR(H3,STYLE),
};
enum
{
HTML_ATTR(H4,CLASS) = 0,
HTML_ATTR(H4,ID),
HTML_ATTR(H4,STYLE),
};
enum
{
HTML_ATTR(H5,CLASS) = 0,
HTML_ATTR(H5,ID),
HTML_ATTR(H5,STYLE),
};
enum
{
HTML_ATTR(H6,CLASS) = 0,
HTML_ATTR(H6,ID),
HTML_ATTR(H6,STYLE),
};
#undef HTML_ATTR
// Read HTML color value from src and set dest
// Can handle #rgb(a), #rrggbb(aa) or rgb()/rgba(), hsl(), hsla() formats
// or color name directly
bool scanHTMLColor(const char *src, NLMISC::CRGBA &dest);
// ***************************************************************************
// Read a CSS length value, return true if one of supported units '%, rem, em, px, pt'
// On failure: 'value' and 'unit' values are undefined
bool getCssLength (float &value, std::string &unit, const std::string &str);
// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false
bool getPercentage (sint32 &width, float &percent, const char *str);
@ -278,6 +191,9 @@ namespace NLGUI
// Parse a HTML color
NLMISC::CRGBA getColor (const char *color);
// return css color in rgba() format
std::string getRGBAString(const NLMISC::CRGBA &color);
// ***************************************************************************
const std::string &setCurrentDomain(const std::string &uri);

File diff suppressed because it is too large Load diff

View file

@ -118,7 +118,7 @@ namespace NLGUI
/** read/write between values on a lua stack & a property exported from a 'CReflectable' derived object
* (throws on error)
*/
static void luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException);
static void luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property);
// push a reflected property on the stack
// NB : no check is done that 'property' is part of the class info of 'reflectedObject'

View file

@ -110,7 +110,7 @@ namespace NLGUI
/** create a sub table for this object, with a string as a key
* This object must be a table or an exception if thrown
*/
CLuaObject newTable(const char *tableName) throw(ELuaNotATable);
CLuaObject newTable(const char *tableName);
/** Set a value in a table.
@ -118,29 +118,29 @@ namespace NLGUI
* NB : value should came from the same lua environment
* \TODO other type of keys
*/
void setValue(const char *key, const CLuaObject &value) throw(ELuaNotATable);
void setValue(const std::string &key, const CLuaObject &value) throw(ELuaNotATable) { setValue(key.c_str(), value); }
void setValue(const char *key, const std::string &value) throw(ELuaNotATable);
void setValue(const char *key, const char *value) throw(ELuaNotATable);
void setValue(const char *key, bool value) throw(ELuaNotATable);
void setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable);
void setValue(const char *key, double value) throw(ELuaNotATable);
void setValue(const char *key, uint32 value) throw(ELuaNotATable);
void setValue(const char *key, sint32 value) throw(ELuaNotATable);
void setValue(const char *key, sint64 value) throw(ELuaNotATable);
void setValue(const std::string &key, const std::string &value) throw(ELuaNotATable) { setValue(key.c_str(), value); }
void setNil(const char *key) throw(ELuaNotATable);
void setNil(const std::string &key) throw(ELuaNotATable) { setNil(key.c_str()); }
void setValue(const char *key, const CLuaObject &value);
void setValue(const std::string &key, const CLuaObject &value) { setValue(key.c_str(), value); }
void setValue(const char *key, const std::string &value);
void setValue(const char *key, const char *value);
void setValue(const char *key, bool value);
void setValue(const char *key, TLuaWrappedFunction value);
void setValue(const char *key, double value);
void setValue(const char *key, uint32 value);
void setValue(const char *key, sint32 value);
void setValue(const char *key, sint64 value);
void setValue(const std::string &key, const std::string &value) { setValue(key.c_str(), value); }
void setNil(const char *key);
void setNil(const std::string &key) { setNil(key.c_str()); }
/** Erase a value in a table by its key.
* If this object is not a table then an exception is thrown.
* \TODO other type of keys
*/
void eraseValue(const char *key) throw(ELuaNotATable);
void eraseValue(const std::string &key) throw(ELuaNotATable) { eraseValue(key.c_str()); }
void eraseValue(const char *key);
void eraseValue(const std::string &key) { eraseValue(key.c_str()); }
// test is this object is enumerable
bool isEnumerable() const;
// Enumeration of a table. If the object is not a table, an exception is thrown.
CLuaEnumeration enumerate() throw(ELuaNotATable);
CLuaEnumeration enumerate();
// retrieve metatable of an object (or nil if object has no metatable)
CLuaObject getMetaTable() const;
// set metatable for this object
@ -155,7 +155,7 @@ namespace NLGUI
CLuaObject operator[](const std::string &key) const { return operator[](key.c_str()); }
/** Checked access to a sub element of a table. An exception is thrown is the element is not a table.
*/
CLuaObject at(const char *key) const throw (ELuaNotATable);
CLuaObject at(const char *key) const;
CLuaObject at(const std::string &key) const { return at(key.c_str()); }
// Test is that table has the given key. The object must be a table or an exception is thrown

View file

@ -176,6 +176,13 @@ namespace NLGUI
*/
void getScreenOOSize (float &oow, float &ooh);
/*
* UI scaling
*/
void setInterfaceScale(float scale, sint32 width = 0, sint32 height = 0);
float getInterfaceScale() const { return _InterfaceScale; }
void setBilinearFiltering(bool b) { _Bilinear = b; }
/*
* is the Screen minimized?
*/
@ -185,7 +192,7 @@ namespace NLGUI
* drawBitmap : this is the interface with all the views
*
*/
void drawRotFlipBitmap (sint layerId, sint32 x, sint32 y, sint32 width, sint32 height, uint8 rot, bool flipv,
void drawRotFlipBitmap (sint layerId, float x, float y, float width, float height, uint8 rot, bool flipv,
sint32 nTxId, const NLMISC::CRGBA &col = NLMISC::CRGBA(255,255,255,255));
/*
@ -526,6 +533,14 @@ namespace NLGUI
float _OneOverScreenW, _OneOverScreenH;
bool _IsMinimized;
// UI scaling
float _InterfaceScale;
float _InterfaceUserScale;
sint32 _InterfaceBaseW, _InterfaceBaseH;
sint32 _EffectiveScreenW, _EffectiveScreenH;
bool _Bilinear;
void updateInterfaceScale();
//map linking a uint to a bitmap. Used to display figurs
std::vector<sint32> _IndexesToTextureIds;
@ -596,7 +611,6 @@ namespace NLGUI
/// Set of hw cursor images
static std::set< std::string > *hwCursors;
static float hwCursorScale;
};

View file

@ -37,7 +37,7 @@ namespace NLGUI
class CViewText : public CViewBase
{
public:
enum TTextMode { ClipWord, DontClipWord, Justified };
enum TTextMode { ClipWord, DontClipWord, Justified, Centered };
public:
DECLARE_UI_CLASS(CViewText)
@ -70,6 +70,7 @@ namespace NLGUI
virtual void checkCoords();
virtual void updateCoords();
virtual void onAddToGroup();
virtual void onInterfaceScaleChanged();
/// From CInterfaceElement
sint32 getMaxUsedW() const;
@ -81,14 +82,16 @@ namespace NLGUI
void setText (const ucstring &text);
void setFontName (const std::string &name);
void setFontSize (sint nFontSize);
void setFontSize (sint nFontSize, bool coef = true);
void setEmbolden (bool nEmbolden);
void setOblique (bool nOblique);
void setColor (const NLMISC::CRGBA &color);
void setShadow (bool bShadow);
void setShadowOutline (bool bShadowOutline);
void setShadowColor (const NLMISC::CRGBA &color);
void setShadowOffset (sint x, sint y);
void setLineMaxW (sint nMaxW, bool invalidate=true);
void setOverflowText(const ucstring &text) { _OverflowText = text; }
void setMultiLine (bool bMultiLine);
void setMultiLineSpace (sint nMultiLineSpace);
void setMultiLineMaxWOnly (bool state);
@ -97,6 +100,9 @@ namespace NLGUI
void setMultiMaxLine(uint l) { _MultiMaxLine = l; }
void setMultiMinLine(uint l) { _MultiMinLine = l; }
// Override chars used to compute font size
void setFontSizing(const std::string &chars, const std::string &fallback);
// Force only a subset of letter to be displayed. Default is 0/0xFFFFFFFF
void enableStringSelection(uint start, uint end);
void disableStringSelection();
@ -112,7 +118,9 @@ namespace NLGUI
bool getShadow() { return _Shadow; }
bool getShadowOutline() { return _ShadowOutline; }
NLMISC::CRGBA getShadowColor() { return _ShadowColor; }
void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; }
sint getLineMaxW() const { return _LineMaxW; }
ucstring getOverflowText() const { return _OverflowText; }
bool getMultiLine() const { return _MultiLine; }
sint getMultiLineSpace() const { return _MultiLineSpace; }
bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; }
@ -126,6 +134,8 @@ namespace NLGUI
uint getFontHeight() const;
// get current font leg height, in pixels
uint getFontLegHeight() const;
// get current line height, in pixels
float getLineHeight() const;
// Set the display mode (supported with multiline only for now)
void setTextMode(TTextMode mode);
TTextMode getTextMode() const { return _TextMode; }
@ -146,11 +156,11 @@ namespace NLGUI
* When looking at standard edit box, we see that if a line is split accross to line with no
* This also returns the height of the line
*/
void getCharacterPositionFromIndex(sint index, bool lineEnd, sint &x, sint &y, sint &height) const;
void getCharacterPositionFromIndex(sint index, bool lineEnd, float &x, float &y, float &height) const;
/** From a coordinate relative to the BR BR corner of the text, return the index of a character.
* If no character is found at the given position, the closest character is returned (first or last character, for the line or the whole text)
*/
void getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &lineEnd) const;
void getCharacterIndexFromPosition(float x, float y, uint &index, bool &lineEnd) const;
/** From a character index, get the index of the line it belongs to, or -1 if the index is invalid
* \param cursorDisplayedAtEndOfPreviousLine true if the cursor is displayed at the end of the previous line that match its index
*/
@ -233,20 +243,28 @@ namespace NLGUI
std::string _FontName;
/// the font size
sint _FontSize;
bool _FontSizeCoef;
bool _Embolden;
bool _Oblique;
// width of the font in pixel. Just a Hint for tabing format (computed with '_')
uint _FontWidth;
float _FontWidth;
// strings to use when computing font size
ucstring _FontSizingChars;
ucstring _FontSizingFallback;
// height of the font in pixel.
// use getFontHeight
uint _FontHeight;
uint _FontLegHeight;
float _FontHeight;
float _FontLegHeight;
float _SpaceWidth;
/// last UI scale used to calculate font size
float _Scale;
/// the text color
NLMISC::CRGBA _Color;
/// the shadow mode
bool _Shadow;
bool _ShadowOutline;
sint32 _ShadowX;
sint32 _ShadowY;
/// the case mode
TCaseMode _CaseMode;
/// the text shadow color
@ -256,6 +274,7 @@ namespace NLGUI
sint32 _LineMaxW;
/// For single line, true if the text is clamped (ie displayed with "...")
bool _SingleLineTextClamped;
ucstring _OverflowText;
/// Multiple lines handling
bool _MultiLine;
@ -337,8 +356,8 @@ namespace NLGUI
// Clear the line & remove text contexts
void clear(NL3D::UTextContext &textContext);
// Add a new word (and its context) in the line + a number of spaces to append at the end of the line
void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth, NL3D::UTextContext &textContext);
void addWord(const CWord &word, uint fontWidth);
void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, float fontWidth, NL3D::UTextContext &textContext);
void addWord(const CWord &word, float fontWidth);
uint getNumWords() const { return (uint)_Words.size(); }
CWord &getWord(uint index) { return _Words[index]; }
float getSpaceWidth() const { return _SpaceWidth; }
@ -398,7 +417,7 @@ namespace NLGUI
uint _TextSelectionEnd;
// First line X coordinate
sint _FirstLineX;
float _FirstLineX;
/// Dynamic tooltips
std::vector<CCtrlToolTip*> _Tooltips;
@ -423,9 +442,9 @@ namespace NLGUI
// Clear all the lines and free their datas
void clearLines();
// Update in the case of a multiline text
void updateTextContextMultiLine(uint nMaxWidth);
void updateTextContextMultiLine(float nMaxWidth);
// Update in the case of a multiline text with justification
void updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces);
void updateTextContextMultiLineJustified(float nMaxWidth, bool expandSpaces);
// Recompute font size info
void computeFontSize ();

View file

@ -49,6 +49,7 @@ namespace NLGUI
class CProcedure;
class IEditorSelectionWatcher;
class IWidgetAdditionWatcher;
class IInterfaceScaleWatcher;
/**
GUI Widget Manager
@ -530,6 +531,11 @@ namespace NLGUI
bool unGroupSelection();
void setMultiSelection( bool b ){ multiSelection = b; }
float getInterfaceScale() const { return _InterfaceScale; }
void notifyInterfaceScaleWatchers();
void registerInterfaceScaleWatcher(IInterfaceScaleWatcher *watcher);
void unregisterInterfaceScaleWatcher(IInterfaceScaleWatcher *watcher);
bool createNewGUI( const std::string &project, const std::string &window );
private:
@ -615,6 +621,7 @@ namespace NLGUI
uint32 _ScreenH;
uint32 _ScreenW;
float _InterfaceScale;
std::vector< CInterfaceAnim* > activeAnims;
@ -622,6 +629,7 @@ namespace NLGUI
std::vector< IOnWidgetsDrawnHandler* > onWidgetsDrawnHandlers;
std::vector< IEditorSelectionWatcher* > selectionWatchers;
std::vector< IWidgetWatcher* > widgetWatchers;
std::vector< IInterfaceScaleWatcher* > scaleWatchers;
std::vector< std::string > editorSelection;
bool _GroupSelection;

View file

@ -1,3 +1,7 @@
CONVERT_VERSION_NUMBER(NL_VERSION_NUM 100 ${NL_VERSION_MAJOR} ${NL_VERSION_MINOR} ${NL_VERSION_PATCH})
CONFIGURE_FILE(version_nl.cmake ${CMAKE_BINARY_DIR}/version_nl.h)
FILE(GLOB HEADERS *.h)
INSTALL(FILES ${HEADERS} DESTINATION include/nel/misc COMPONENT headers)
INSTALL(FILES ${HEADERS} ${CMAKE_BINARY_DIR}/version_nl.h DESTINATION include/nel/misc COMPONENT headers)

View file

@ -23,6 +23,7 @@
namespace NLMISC
{
class IStream;
// ***************************************************************************
/**
@ -52,6 +53,13 @@ public:
//CClassId& operator=(const CClassId &o) { Uid = o.Uid; return *this;}
operator uint64() const {return Uid;}
inline uint32 a() const { return (uint32)(Uid >> 32); }
inline uint32 b() const { return (uint32)(Uid & 0xFFFFFFFFL); }
inline void setA(uint32 a) { Uid = ((uint64)a<<32) | (Uid & 0xFFFFFFFFL); }
inline void setB(uint32 b) { Uid = (Uid & 0xFFFFFFFF00000000L) | b; }
void serial(NLMISC::IStream &s);
std::string toString() const;
};
/**

View file

@ -86,10 +86,10 @@ public:
static void release();
/// Register your class for future Instanciation.
static void registerClass(const std::string &className, IClassable* (*creator)(), const std::string &typeidCheck) throw(ERegistry);
static void registerClass(const std::string &className, IClassable* (*creator)(), const std::string &typeidCheck);
/// Create an object from his class name.
static IClassable *create(const std::string &className) throw(ERegistry);
static IClassable *create(const std::string &className);
/// check if the object has been correctly registered. Must be used for debug only, and Must compile with RTTI.
static bool checkObject(IClassable* obj);

View file

@ -222,6 +222,7 @@ inline double isValidDouble (double v)
* \param str a string to transform to lower case
*/
std::string toLower ( const char *str );
std::string toLower ( const std::string &str );
void toLower ( char *str );
char toLower ( const char ch ); // convert only one character
@ -275,6 +276,17 @@ template <class T> T trimRightWhiteSpaces (const T &str)
return str.substr (0, end);
}
// if both first and last char are quotes (' or "), then remove them
template <class T> T trimQuotes (const T &str)
{
typename T::size_type size = str.size();
if (size == 0)
return str;
if (str[0] != str[size-1] && (str[0] != '"' || str[0] != '\''))
return str;
return str.substr(1, size - 1);
}
//////////////////////////////////////////////////////////////////////////
// **** DEPRECATED *****: PLEASE DON'T USE THESE METHODS BUT FUNCTIONS ABOVE toLower() and toUpper()
//////////////////////////////////////////////////////////////////////////
@ -302,28 +314,23 @@ inline sint nlstricmp(const std::string &lhs, const std::string &rhs) { return s
inline sint nlstricmp(const std::string &lhs, const char *rhs) { return stricmp(lhs.c_str(),rhs); }
inline sint nlstricmp(const char *lhs, const std::string &rhs) { return stricmp(lhs,rhs.c_str()); }
// macros helper to convert UTF-8 std::string and wchar_t*
#define wideToUtf8(str) (ucstring((ucchar*)str).toUtf8())
#define utf8ToWide(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str())
// macros helper to convert UTF-8 std::string and TCHAR*
#ifdef _UNICODE
#define tStrToUtf8(str) (ucstring((ucchar*)(LPCWSTR)str).toUtf8())
#define utf8ToTStr(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str())
#else
#define tStrToUtf8(str) (std::string((LPCSTR)str))
#define utf8ToTStr(str) (str.c_str())
#if (NL_COMP_VC_VERSION <= 90)
inline float nlroundf(float x)
{
return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f);
}
#define roundf(x) NLMISC::nlroundf(x)
#endif
// wrapper for fopen to be able to open files with an UTF-8 filename
FILE* nlfopen(const std::string &filename, const std::string &mode);
// Wrapper for fopen to be able to open files with an UTF-8 filename
FILE *nlfopen(const std::string &filename, const std::string &mode);
/** Signed 64 bit fseek. Same interface as fseek
*/
int nlfseek64( FILE *stream, sint64 offset, int origin );
int nlfseek64(FILE *stream, sint64 offset, int origin);
// Retrieve position in a file, same interface as ftell
sint64 nlftell64(FILE *stream);
sint64 nlftell64(FILE *stream);
/**
* Base class for all NeL exception.

View file

@ -108,9 +108,9 @@ public: // Advanced Usage.
/// flush the file.
void flush();
/// Seek the file
bool seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStream);
bool seek (sint32 offset, IStream::TSeekOrigin origin) const;
/// Get the location of the file pointer
sint32 getPos () const throw(EStream);
sint32 getPos () const;
// Imp the Name of the stream as the name of the file.
virtual std::string getStreamName() const;
@ -125,7 +125,7 @@ public: // Advanced Usage.
// return true if there's nothing more to read (same as ifstream)
bool eof ();
virtual void serialBuffer(uint8 *buf, uint len)throw(EReadError);
virtual void serialBuffer(uint8 *buf, uint len);
/// \name Statistics
@ -148,7 +148,7 @@ public: // Advanced Usage.
static void clearDump ();
protected:
virtual void serialBit(bool &bit) throw(EReadError);
virtual void serialBit(bool &bit);
virtual uint getDbgStreamSize() const;
@ -223,20 +223,20 @@ public: // Advanced Usage.
/// flush the file.
void flush();
/// Seek the file
bool seek (sint32 offset, IStream::TSeekOrigin origin) const throw(EStream);
bool seek (sint32 offset, IStream::TSeekOrigin origin) const;
/// Get the location of the file pointer
sint32 getPos () const throw(EStream);
sint32 getPos () const;
// Imp the Name of the stream as the name of the file.
virtual std::string getStreamName() const;
// very useful to serialize string in text mode (without the size)
virtual void serialBuffer(uint8 *buf, uint len) throw(EWriteError);
virtual void serialBuffer(uint8 *buf, uint len);
protected:
/// Internal close.
void internalClose(bool success);
virtual void serialBit(bool &bit) throw(EWriteError);
virtual void serialBit(bool &bit);
private:
FILE *_F;

View file

@ -197,7 +197,7 @@ public:
* \return true if seek sucessfull.
* \see ESeekNotSupported SeekOrigin getPos
*/
virtual bool seek (sint32 offset, TSeekOrigin origin) const throw(EStream);
virtual bool seek (sint32 offset, TSeekOrigin origin) const;
/**
* Get the location of the stream pointer.
@ -210,7 +210,7 @@ public:
* \return the new offset regarding from the origin.
* \see ESeekNotSupported SeekOrigin seek
*/
virtual sint32 getPos () const throw(EStream)
virtual sint32 getPos () const
{
return sint32(_Buffer.Pos);
}

View file

@ -226,7 +226,7 @@ public:
std::string toString() { if(Ptr) return toString(*Ptr); else return "<null>"; }
// serial using serialPtr
void serialPtr(NLMISC::IStream &f) throw(NLMISC::EStream )
void serialPtr(NLMISC::IStream &f)
{
T* obj= NULL;
if(f.isReading())
@ -242,7 +242,7 @@ public:
}
}
// serial using serialPloyPtr
void serialPolyPtr(NLMISC::IStream &f) throw(NLMISC::EStream )
void serialPolyPtr(NLMISC::IStream &f)
{
T* obj= NULL;
if(f.isReading())
@ -337,7 +337,7 @@ public:
void kill();
// serial using serialPloyPtr
void serialPolyPtr(NLMISC::IStream &f) throw(NLMISC::EStream )
void serialPolyPtr(NLMISC::IStream &f)
{
T* obj= NULL;
if(f.isReading())

View file

@ -242,54 +242,11 @@ inline bool fromString(const std::string &str, sint64 &val) { bool ret = sscanf(
inline bool fromString(const std::string &str, float &val) { bool ret = sscanf(str.c_str(), "%f", &val) == 1; if (!ret) val = 0.0f; return ret; }
inline bool fromString(const std::string &str, double &val) { bool ret = sscanf(str.c_str(), "%lf", &val) == 1; if (!ret) val = 0.0; return ret; }
inline bool fromString(const std::string &str, bool &val)
{
if (str.length() == 1)
{
const char c = str[0];
// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, anything else is undefined.
// (str[0] == '1' || (str[0] & 0xD2) == 0x50)
// - Kaetemi
switch(c)
{
case '1':
case 't':
case 'T':
case 'y':
case 'Y':
val = true;
break;
case '0':
case 'f':
case 'F':
case 'n':
case 'N':
val = false;
break;
default:
val = false;
return false;
}
}
else
{
if (str == "true" || str == "yes")
{
val = true;
}
else if (str == "false" || str == "no")
{
val = false;
}
else
{
val = false;
return false;
}
}
return true;
}
bool fromString(const std::string &str, bool &val);
inline bool fromString(const std::string &str, std::string &val) { val = str; return true; }
@ -300,6 +257,105 @@ inline bool fromString(const std::string &str, uint &val) { return sscanf(str.c_
inline bool fromString(const std::string &str, sint &val) { return sscanf(str.c_str(), "%d", &val) == 1; }
#endif // NL_COMP_VC6
// Convert local codepage to UTF-8
// On Windows, the local codepage is undetermined
// On Linux, the local codepage is always UTF-8 (no-op)
std::string mbcsToUtf8(const char *str, size_t len = 0);
std::string mbcsToUtf8(const std::string &str);
// Convert wide codepage to UTF-8
// On Windows, the wide codepage is UTF-16
// On Linux, the wide codepage is UTF-32
std::string wideToUtf8(const wchar_t *str, size_t len = 0);
std::string wideToUtf8(const std::wstring &str);
// Convert UTF-8 to wide character set
std::wstring utf8ToWide(const char *str, size_t len = 0);
std::wstring utf8ToWide(const std::string &str);
// Convert UTF-8 to local multibyte character set
std::string utf8ToMbcs(const char *str, size_t len = 0);
std::string utf8ToMbcs(const std::string &str);
// Convert wide to local multibyte character set
std::string wideToMbcs(const wchar_t *str, size_t len = 0);
std::string wideToMbcs(const std::wstring &str);
// Convert local multibyte to wide character set
std::wstring mbcsToWide(const char *str, size_t len = 0);
std::wstring mbcsToWide(const std::string &str);
inline const char *asCStr(const char *str) { return str; }
inline const char *asCStr(const std::string &str) { return str.c_str(); }
inline const wchar_t *asCStr(const wchar_t *str) { return str; }
inline const wchar_t *asCStr(const std::wstring &str) { return str.c_str(); }
#if defined(NL_OS_WINDOWS)
#define nlUtf8ToMbcs(str) (NLMISC::utf8ToMbcs(str).c_str())
#define nlMbcsToUtf8(str) (NLMISC::mbcsToUtf8(str).c_str())
#else
#define nlUtf8ToMbcs(str) (NLMISC::asCStr(str))
#define nlMbcsToUtf8(str) (NLMISC::asCStr(str))
#endif
#define nlWideToUtf8(str) (NLMISC::wideToUtf8(str).c_str())
#define nlUtf8ToWide(str) (NLMISC::utf8ToWide(str).c_str())
#define nlWideToMbcs(str) (NLMISC::wideToMbcs(str).c_str())
#define nlMbcsToWide(str) (NLMISC::mbcsToWide(str).c_str())
// On Windows, tstring is either local multibyte or utf-16 wide
// On Linux, tstring is always utf-8
#if defined(NL_OS_WINDOWS) && (defined(UNICODE) || defined(_UNICODE))
typedef std::wstring tstring;
typedef wchar_t tchar;
inline std::string tStrToUtf8(const tchar *str) { return wideToUtf8((const wchar_t *)str); }
inline std::string tStrToUtf8(const tstring &str) { return wideToUtf8((const std::wstring &)str); }
inline std::wstring tStrToWide(const tchar *str) { return (const wchar_t *)str; }
inline std::wstring tStrToWide(const tstring &str) { return (const std::wstring &)str; }
inline std::string tStrToMbcs(const tchar *str) { return wideToMbcs((const wchar_t *)str); }
inline std::string tStrToMbcs(const tstring &str) { return wideToMbcs((const std::wstring &)str); }
#define nlTStrToUtf8(str) (NLMISC::tStrToUtf8(str).c_str())
#define nlTStrToWide(str) ((const wchar_t *)NLMISC::asCStr(str))
#define nlTStrToMbcs(str) (NLMISC::tStrToMbcs(str).c_str())
inline tstring utf8ToTStr(const char *str) {return (const tstring &)utf8ToWide(str); }
inline tstring utf8ToTStr(const std::string &str) { return (const tstring &)utf8ToWide(str); }
inline tstring wideToTStr(const wchar_t *str) { return (const tchar *)str; }
inline tstring wideToTStr(const std::wstring &str) { return (const tstring &)str; }
inline tstring mbcsToTStr(const char *str) { return (const tstring &)mbcsToWide(str); }
inline tstring mbcsToTStr(const std::string &str) { return (const tstring &)mbcsToWide(str); }
#define nlUtf8ToTStr(str) (NLMISC::utf8ToTStr(str).c_str())
#define nlWideToTStr(str) ((const tchar *)NLMISC::asCStr(str))
#define nlMbcsToTStr(str) (NLMISC::mbcsToTStr(str).c_str())
#else
typedef std::string tstring;
typedef char tchar;
inline std::string tStrToUtf8(const tchar *str) { return mbcsToUtf8((const char *)str); }
inline std::string tStrToUtf8(const tstring &str) { return mbcsToUtf8((const std::string &)str); }
inline std::wstring tStrToWide(const tchar *str) { return mbcsToWide((const char *)str); }
inline std::wstring tStrToWide(const tstring &str) { return mbcsToWide((const std::string &)str); }
inline std::string tStrToMbcs(const tchar *str) { return (const char *)str; }
inline std::string tStrToMbcs(const tstring &str) { return (const std::string &)str; }
#if defined(NL_OS_WINDOWS)
#define nlTStrToUtf8(str) (NLMISC::tStrToUtf8(str).c_str())
#else
#define nlTStrToUtf8(str) ((const char *)NLMISC::asCStr(str))
#endif
#define nlTStrToWide(str) (NLMISC::tStrToWide(str).c_str())
#define nlTStrToMbcs(str) ((const char *)NLMISC::asCStr(str))
inline tstring utf8ToTStr(const char *str) { return (const tstring &)utf8ToMbcs(str); }
inline tstring utf8ToTStr(const std::string &str) { return (const tstring &)utf8ToMbcs(str); }
inline tstring wideToTStr(const wchar_t *str) { return (const tstring &)wideToMbcs(str); }
inline tstring wideToTStr(const std::wstring &str) { return (const tstring &)wideToMbcs(str); }
inline tstring mbcsToTStr(const char *str) { return (const tchar *)str; }
inline tstring mbcsToTStr(const std::string &str) { return (const tstring &)str; }
#if defined(NL_OS_WINDOWS)
#define nlUtf8ToTStr(str) (NLMISC::utf8ToTStr(str).c_str())
#else
#define nlUtf8ToTStr(str) ((const tchar *)NLMISC::asCStr(str))
#endif
#define nlWideToTStr(str) (NLMISC::wideToTStr(str).c_str())
#define nlMbcsToTStr(str) ((const tchar *)NLMISC::asCStr(str))
#endif
} // NLMISC

View file

@ -177,10 +177,10 @@ public:
uint32 getCount() { return _IdCounter; }
// helper serialize a string id as a string
void serial(NLMISC::IStream &f, TSStringId &strId) throw(EStream);
void serial(NLMISC::IStream &f, TSStringId &strId);
// helper serialize a string id vector
void serial(NLMISC::IStream &f, std::vector<TSStringId> &strIdVect) throw(EStream);
void serial(NLMISC::IStream &f, std::vector<TSStringId> &strIdVect);
};

View file

@ -70,10 +70,10 @@ public:
static void setRootKey(const std::string &root);
/// Read a value from registry.
static std::string getRegKey(const std::string &Entry);
static std::string getRegKey(const std::string &entry);
/// Write a value to registry.
static bool setRegKey(const std::string &ValueName, const std::string &Value);
static bool setRegKey(const std::string &valueName, const std::string &value);
/// Get desktop current color depth without using UDriver.
static uint getCurrentColorDepth();

View file

@ -79,6 +79,9 @@
# elif _MSC_VER >= 1600
# define NL_COMP_VC10
# define NL_COMP_VC_VERSION 100
# ifdef _HAS_CPP0X
# undef _HAS_CPP0X // VC++ 2010 doesn't implement C++11 stuff we need
# endif
# elif _MSC_VER >= 1500
# define NL_COMP_VC9
# define NL_COMP_VC_VERSION 90
@ -170,6 +173,12 @@
# define NL_NO_EXCEPTION_SPECS
#endif
#if defined(NL_COMP_VC) && (NL_COMP_VC_VERSION >= 140)
#define nlmove(v) std::move(v)
#else
#define nlmove(v) (v)
#endif
// 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
@ -217,6 +226,7 @@
# 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
# endif // NL_COMP_VC8 || NL_COMP_VC9
# pragma warning (disable : 26495) // Variable is uninitialized. Always initialize a member variable. (On purpose for performance.)
#endif // NL_OS_WINDOWS
@ -409,8 +419,16 @@ typedef unsigned int uint; // at least 32bits (depend of processor)
#define NL_DEFAULT_MEMORY_ALIGNMENT 16
#define NL_ALIGN_SSE2 NL_ALIGN(NL_DEFAULT_MEMORY_ALIGNMENT)
#ifndef NL_CPU_X86_64
#ifdef NL_CPU_X86_64
// on x86_64, new and delete are already aligned on 16 bytes
#elif (defined(NL_COMP_VC) && defined(NL_DEBUG))
// don't use aligned memory if debugging with VC++ in 32 bits
#else
// use aligned memory in all other cases
#define NL_USE_ALIGNED_MEMORY_OPERATORS
#endif
#ifdef NL_USE_ALIGNED_MEMORY_OPERATORS
#ifdef NL_NO_EXCEPTION_SPECS
extern void *operator new(size_t size);
@ -422,9 +440,9 @@ extern void *operator new(size_t size) throw(std::bad_alloc);
extern void *operator new[](size_t size) throw(std::bad_alloc);
extern void operator delete(void *p) throw();
extern void operator delete[](void *p) throw();
#endif
#endif /* NL_NO_EXCEPTION_SPECS */
#endif
#endif /* NL_USE_ALIGNED_MEMORY_OPERATORS */
#else /* NL_HAS_SSE2 */
@ -508,6 +526,15 @@ template<> struct hash<uint64>
*/
typedef uint16 ucchar;
#if defined(NL_OS_WINDOWS) && (defined(UNICODE) || defined(_UNICODE))
#define nltmain wmain
#define nltWinMain wWinMain
#else
#define nltmain main
#if defined(NL_OS_WINDOWS)
#define nltWinMain WinMain
#endif
#endif
// To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234)
#ifdef NL_COMP_VC

View file

@ -0,0 +1,14 @@
#ifndef NL_VERSION_H
#define NL_VERSION_H
#define NL_VERSION "${NL_VERSION}"
#define NL_VERSION_MAJOR ${NL_VERSION_MAJOR}
#define NL_VERSION_MINOR ${NL_VERSION_MINOR}
#define NL_VERSION_PATCH ${NL_VERSION_PATCH}
#define NL_VERSION_NUM ${NL_VERSION_NUM}
#define NL_REVISION ${REVISION}
#define NL_BUILD_DATE "${BUILD_DATE}"
#endif

View file

@ -146,7 +146,7 @@ public:
return _LengthR;
}
virtual sint32 getPos () const throw(NLMISC::EStream)
virtual sint32 getPos() const
{
// return (_BufPos - _Buffer.getPtr()) - _SubMessagePosR;
return _Buffer.Pos - _SubMessagePosR;

View file

@ -213,18 +213,14 @@ namespace NLNET
* Note that a module can be plugged in several socket at the same
* time, but not twice in the same socket.
*/
virtual void plugModule(IModuleSocket *moduleSocket)
throw (EModuleAlreadyPluggedHere)
=0;
virtual void plugModule(IModuleSocket *moduleSocket) =0;
/** Unplug this module from the specified socket.
* Note that a module can be plugged in several socket at the same
* time, but not twice in the same socket.
* Throw an exception if the socket is not currently plug into
* the specified socket.
*/
virtual void unplugModule(IModuleSocket *moduleSocket)
throw (EModuleNotPluggedHere)
=0;
virtual void unplugModule(IModuleSocket *moduleSocket) =0;
/** Fill resultList vector with the list of socket into
* witch this module is currently plugged.
* This method don't clear the result vector before filling it.
@ -265,9 +261,7 @@ namespace NLNET
* The call is blocking until receptions of the operation
* result message (or detection of the dest module module is down)
*/
virtual void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg)
throw (EInvokeFailed)
=0;
virtual void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) =0;
//@}
@ -448,9 +442,7 @@ namespace NLNET
* This method do the job of finding a valid socket to effectively send
* the message.
*/
virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message)
throw (EModuleNotReachable)
=0;
virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message) =0;
/** Return the first item of the security item list
* If no security data are available, the method
@ -779,10 +771,10 @@ namespace NLNET
// Init base module, init module name
bool initModule(const TParsedCommandLine &initInfo);
void plugModule(IModuleSocket *moduleSocket) throw (EModuleAlreadyPluggedHere);
void unplugModule(IModuleSocket *moduleSocket) throw (EModuleNotPluggedHere);
void plugModule(IModuleSocket *moduleSocket);
void unplugModule(IModuleSocket *moduleSocket);
void getPluggedSocketList(std::vector<IModuleSocket*> &resultList);
void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg) throw (EInvokeFailed);
void invokeModuleOperation(IModuleProxy *destModule, const NLNET::CMessage &opMsg, NLNET::CMessage &resultMsg);
void _onModuleUp(IModuleProxy *removedProxy);
void _onModuleDown(IModuleProxy *removedProxy);
@ -879,8 +871,7 @@ namespace NLNET
/** Send a message to the module.
*/
virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message)
throw (EModuleNotReachable);
virtual void sendModuleMessage(IModule *senderModule, const NLNET::CMessage &message);
virtual const TSecurityData *getFirstSecurityData() const
{

View file

@ -171,8 +171,7 @@ namespace NLNET
virtual void setTransportPeerInvisible(const std::string &transportInstanceName, bool peerInvisible) =0;
/// Activate/stop firewalling mode on a transport
virtual void setTransportFirewallMode(const std::string &transportInstanceName, bool firewalled)
throw (EGatewayFirewallBreak) =0;
virtual void setTransportFirewallMode(const std::string &transportInstanceName, bool firewalled) =0;
/// Send a command to a transport
virtual void transportCommand(const TParsedCommandLine &commandLine) =0;
@ -233,9 +232,7 @@ namespace NLNET
/** Disclose module information to a connected gateway.
* This can also be this gateway itself.
*/
virtual void discloseModule(IModuleProxy *moduleProxy)
throw (EGatewayNotConnected)
=0;
virtual void discloseModule(IModuleProxy *moduleProxy) =0;
/** Retrieve the proxy for a locally plugged module.
* Each local module plugged in a gateway has an associated
@ -346,9 +343,9 @@ namespace NLNET
virtual const std::string &getClassName() const =0;
/// The gateway send a command message to the transport
virtual void onCommand(const CMessage &command) throw (EInvalidCommand) = 0;
virtual void onCommand(const CMessage &command) = 0;
/// The gateway send a textual command to the transport
virtual bool onCommand(const TParsedCommandLine &command) throw (EInvalidCommand) = 0;
virtual bool onCommand(const TParsedCommandLine &command) = 0;
/// The gateway update the transport regularly
virtual void update() =0;

View file

@ -42,15 +42,11 @@ namespace NLNET
* If the destination module is not accessible through this socket,
* an exception is thrown.
*/
virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message )
throw (EModuleNotPluggedHere)
=0;
virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) =0;
/** A plugged module send a message to all the module reachable
* with this socket.
*/
virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message)
throw (EModuleNotPluggedHere)
=0;
virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) =0;
/** Fill the resultList with the list of module that are
* reachable with this socket.
@ -95,21 +91,15 @@ namespace NLNET
virtual void _onModulePlugged(const TModulePtr &pluggedModule);
virtual void _onModuleUnplugged(const TModulePtr &pluggedModule);
virtual void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message )
throw (EModuleNotPluggedHere, NLNET::EModuleNotReachable)
=0;
virtual void _sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message) =0;
virtual void _broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message)
throw (EModuleNotPluggedHere)
=0;
virtual void _broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message) =0;
virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message )
throw (EModuleNotPluggedHere);
virtual void sendModuleMessage(IModule *senderModule, TModuleId destModuleProxyId, const NLNET::CMessage &message);
/** A plugged module send a message to all the module reachable
* with this socket.
*/
virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message)
throw (EModuleNotPluggedHere);
virtual void broadcastModuleMessage(IModule *senderModule, const NLNET::CMessage &message);
};

View file

@ -54,7 +54,17 @@ struct HINSTANCE__;
typedef struct HINSTANCE__ *HINSTANCE;
typedef char CHAR;
typedef wchar_t WCHAR;
typedef CHAR *LPSTR;
typedef WCHAR *LPWSTR;
#if defined(UNICODE) || defined(_UNICODE)
typedef LPWSTR LPTSTR;
#else
typedef LPSTR LPTSTR;
#endif
#endif
namespace NLNET
@ -117,11 +127,11 @@ class IServiceUpdatable;
#if defined(NL_OS_WINDOWS) && defined(_WINDOWS)
#define NLNET_SERVICE_MAIN(__ServiceClassName, __ServiceShortName, __ServiceLongName, __ServicePort, __ServiceCallbackArray, __ConfigDir, __LogDir) \
\
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) \
int APIENTRY nltWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) \
{ \
NLMISC::CApplicationContext serviceContext; \
__ServiceClassName *scn = new __ServiceClassName; \
scn->setArgs (lpCmdLine); \
scn->setArgs (nlTStrToUtf8(lpCmdLine)); \
createDebug(NULL,!scn->haveLongArg("nolog"));\
scn->setCallbackArray (__ServiceCallbackArray, sizeof(__ServiceCallbackArray)/sizeof(__ServiceCallbackArray[0])); \
sint retval = scn->main (__ServiceShortName, __ServiceLongName, __ServicePort, __ConfigDir, __LogDir, __DATE__ " " __TIME__); \
@ -132,7 +142,7 @@ int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
#else
#define NLNET_SERVICE_MAIN(__ServiceClassName, __ServiceShortName, __ServiceLongName, __ServicePort, __ServiceCallbackArray, __ConfigDir, __LogDir) \
\
int main(int argc, const char **argv) \
int nltmain(int argc, const NLMISC::tchar **argv) \
{ \
NLMISC::CApplicationContext serviceContext; \
__ServiceClassName *scn = new __ServiceClassName; \
@ -340,6 +350,9 @@ public:
/// Sets the command line and init _Args variable. You must call this before calling main()
void setArgs (int argc, const char **argv);
/// Sets the command line and init _Args variable. You must call this before calling main()
void setArgs (int argc, const wchar_t **argv);
/// Sets the command line and init _Args variable. You must call this before calling main()
void setArgs (const char *args);

View file

@ -0,0 +1,108 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2018 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NLSOUND_AUDIO_DECODER_FFMPEG_H
#define NLSOUND_AUDIO_DECODER_FFMPEG_H
#include <nel/misc/types_nl.h>
#include <nel/sound/audio_decoder.h>
struct AVCodecContext;
struct AVFormatContext;
struct AVIOContext;
struct AVPacket;
struct SwrContext;
namespace NLSOUND {
/**
* \brief CAudioDecoderFfmpeg
* \date 2018-10-21 08:08GMT
* \author Meelis Mägi (Nimetu)
* CAudioDecoderFfmpeg
* Create trough IAudioDecoder
*/
class CAudioDecoderFfmpeg : public IAudioDecoder
{
protected:
NLMISC::IStream *_Stream;
bool _IsSupported;
bool _Loop;
bool _IsMusicEnded;
sint32 _StreamOffset;
sint32 _StreamSize;
AVIOContext *_AvioContext;
AVFormatContext *_FormatContext;
AVCodecContext *_AudioContext;
SwrContext *_SwrContext;
// selected stream
sint32 _AudioStreamIndex;
// output buffer for decoded frame
SwrContext *_ConvertContext;
private:
// called from constructor if ffmpeg fails to initialize
// or from destructor to cleanup ffmpeg pointers
void release();
public:
CAudioDecoderFfmpeg(NLMISC::IStream *stream, bool loop);
virtual ~CAudioDecoderFfmpeg();
inline NLMISC::IStream *getStream() { return _Stream; }
inline sint32 getStreamSize() { return _StreamSize; }
inline sint32 getStreamOffset() { return _StreamOffset; }
// Return true if ffmpeg is able to decode the stream
bool isFormatSupported() const;
/// Get information on a music file (only artist and title at the moment).
static bool getInfo(NLMISC::IStream *stream, std::string &artist, std::string &title, float &length);
/// Get how many bytes the music buffer requires for output minimum.
virtual uint32 getRequiredBytes();
/// Get an amount of bytes between minimum and maximum (can be lower than minimum if at end).
virtual uint32 getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum);
/// Get the amount of channels (2 is stereo) in output.
virtual uint8 getChannels();
/// Get the samples per second (often 44100) in output.
virtual uint getSamplesPerSec();
/// Get the bits per sample (often 16) in output.
virtual uint8 getBitsPerSample();
/// Get if the music has ended playing (never true if loop).
virtual bool isMusicEnded();
/// Get the total time in seconds.
virtual float getLength();
/// Set looping
virtual void setLooping(bool loop);
}; /* class CAudioDecoderFfmpeg */
} /* namespace NLSOUND */
#endif // NLSOUND_AUDIO_DECODER_FFMPEG_H
/* end of file */

View file

@ -0,0 +1,100 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2018 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NLSOUND_AUDIO_DECODER_MP3_H
#define NLSOUND_AUDIO_DECODER_MP3_H
#include <nel/misc/types_nl.h>
#if (NL_COMP_VC_VERSION > 90) /* VS2008 does not have stdint.h */
#include <nel/sound/audio_decoder.h>
// disable drmp3_init_file()
#define DR_MP3_NO_STDIO
#include <nel/sound/decoder/dr_mp3.h>
namespace NLSOUND {
/**
* \brief CAudioDecoderMP3
* \date 2019-01-13 12:39GMT
* \author Meelis Mägi (Nimetu)
* CAudioDecoderMP3
* Create trough IAudioDecoder, type "mp3"
*/
class CAudioDecoderMP3 : public IAudioDecoder
{
protected:
NLMISC::IStream *_Stream;
bool _IsSupported;
bool _Loop;
bool _IsMusicEnded;
sint32 _StreamOffset;
sint32 _StreamSize;
drmp3 _Decoder;
// set to total pcm frames after getLength() is called
uint64 _PCMFrameCount;
public:
CAudioDecoderMP3(NLMISC::IStream *stream, bool loop);
virtual ~CAudioDecoderMP3();
inline NLMISC::IStream *getStream() { return _Stream; }
inline sint32 getStreamSize() { return _StreamSize; }
inline sint32 getStreamOffset() { return _StreamOffset; }
// Return true if mp3 is valid
bool isFormatSupported() const;
/// Get information on a music file (only ID3v1 tag is read.
static bool getInfo(NLMISC::IStream *stream, std::string &artist, std::string &title, float &length);
/// Get how many bytes the music buffer requires for output minimum.
virtual uint32 getRequiredBytes();
/// Get an amount of bytes between minimum and maximum (can be lower than minimum if at end).
virtual uint32 getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum);
/// Get the amount of channels (2 is stereo) in output.
virtual uint8 getChannels();
/// Get the samples per second (often 44100) in output.
virtual uint getSamplesPerSec();
/// Get the bits per sample (often 16) in output.
virtual uint8 getBitsPerSample();
/// Get if the music has ended playing (never true if loop).
virtual bool isMusicEnded();
/// Get the total time in seconds.
virtual float getLength();
/// Set looping
virtual void setLooping(bool loop);
}; /* class CAudioDecoderMP3 */
} /* namespace NLSOUND */
#endif /* (NL_COMP_VC_VERSION > 90) */
#endif // NLSOUND_AUDIO_DECODER_MP3_H
/* end of file */

File diff suppressed because it is too large Load diff

View file

@ -98,8 +98,9 @@ private:
NLMISC::IThread *m_Thread;
IAudioDecoder *m_AudioDecoder;
bool m_Paused;
bool m_DecodingEnded;
}; /* class CStreamFileSource */

View file

@ -1328,7 +1328,7 @@ const D3DFORMAT FinalPixelFormat[ITexture::UploadFormatCount][CDriverD3D::FinalP
// ***************************************************************************
bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay)
bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable)
{
H_AUTO_D3D(CDriver3D_setDisplay);
@ -1810,7 +1810,7 @@ emptyProc CDriverD3D::getWindowProc()
IDriver::TMessageBoxId CDriverD3D::systemMessageBox (const char* message, const char* title, TMessageBoxType type, TMessageBoxIcon icon)
{
switch (::MessageBoxW (_HWnd, utf8ToWide(message), utf8ToWide(title), ((type==retryCancelType)?MB_RETRYCANCEL:
switch (::MessageBoxW(_HWnd, nlUtf8ToWide(message), nlUtf8ToWide(title), ((type == retryCancelType) ? MB_RETRYCANCEL :
(type==yesNoCancelType)?MB_YESNOCANCEL:
(type==okCancelType)?MB_OKCANCEL:
(type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE:

View file

@ -849,7 +849,7 @@ public:
// Mode initialisation, requests
virtual bool init (uintptr_t windowIcon = 0, emptyProc exitFunc = 0);
virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay);
virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable);
virtual bool release();
virtual bool setMode(const GfxMode& mode);
virtual bool getModes(std::vector<GfxMode> &modes);

View file

@ -325,7 +325,7 @@ public:
virtual void disableHardwareVertexArrayAGP();
virtual void disableHardwareTextureShader();
virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay);
virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable);
virtual bool setMode(const GfxMode& mode);
virtual bool getModes(std::vector<GfxMode> &modes);
virtual bool getCurrentScreenMode(GfxMode &mode);

View file

@ -611,7 +611,7 @@ void CDriverGL::setWindowIcon(const std::vector<NLMISC::CBitmap> &bitmaps)
}
// --------------------------------------------------
bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable) throw(EBadDisplay)
bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable)
{
H_AUTO_OGL(CDriverGL_setDisplay)
@ -2644,7 +2644,7 @@ IDriver::TMessageBoxId CDriverGL::systemMessageBox (const char* message, const c
{
H_AUTO_OGL(CDriverGL_systemMessageBox)
#ifdef NL_OS_WINDOWS
switch (::MessageBoxW (NULL, utf8ToWide(message), utf8ToWide(title), ((type==retryCancelType)?MB_RETRYCANCEL:
switch (::MessageBoxW(NULL, nlUtf8ToWide(message), nlUtf8ToWide(title), ((type == retryCancelType) ? MB_RETRYCANCEL :
(type==yesNoCancelType)?MB_YESNOCANCEL:
(type==okCancelType)?MB_OKCANCEL:
(type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE:

View file

@ -77,7 +77,7 @@ extern IDriver* createGlEsDriverInstance ();
#endif
// ***************************************************************************
IDriver *CDRU::createGlDriver() throw (EDru)
IDriver *CDRU::createGlDriver()
{
#ifdef NL_STATIC
@ -131,7 +131,7 @@ IDriver *CDRU::createGlDriver() throw (EDru)
}
// ***************************************************************************
IDriver *CDRU::createGlEsDriver() throw (EDru)
IDriver *CDRU::createGlEsDriver()
{
#ifdef NL_STATIC
@ -188,7 +188,7 @@ IDriver *CDRU::createGlEsDriver() throw (EDru)
#ifdef NL_OS_WINDOWS
IDriver *CDRU::createD3DDriver() throw (EDru)
IDriver *CDRU::createD3DDriver()
{
#ifdef NL_STATIC

View file

@ -81,6 +81,11 @@ const char *CFontGenerator::getFT2Error(FT_Error fte)
return ukn;
}
std::string CFontGenerator::getFontFileName() const
{
return _FontFileName;
}
CFontGenerator *newCFontGenerator(const std::string &fontFileName)
{
return new CFontGenerator(fontFileName);
@ -456,33 +461,6 @@ CFontGenerator::CFontGenerator (const std::string &fontFileName, const std::stri
SetTextAlign (hdcDib, TA_TOP | TA_LEFT | TA_NOUPDATECP);
SetBkColor (hdcDib, RGB (0,0,0));
SetTextColor (hdcDib, RGB (255, 255, 255));
/*FT_Error error;
if (!_LibraryInit)
{
error = FT_Init_FreeType (&_Library);
if (error)
{
nlerror ("FT_Init_FreeType() failed: %s", getFT2Error(error));
}
_LibraryInit = true;
}
error = FT_New_Face (_Library, fontFileName.c_str (), 0, &_Face);
if (error)
{
nlerror ("FT_New_Face() failed with file '%s': %s", fontFileName.c_str(), getFT2Error(error));
}
if (!fontExFileName.empty())
{
error = FT_Attach_File (_Face, fontExFileName.c_str ());
if (error)
{
nlwarning ("FT_Attach_File() failed with file '%s': %s", fontExFileName.c_str(), getFT2Error(error));
}
}*/
}
CFontGenerator::~CFontGenerator ()
@ -494,28 +472,6 @@ CFontGenerator::~CFontGenerator ()
void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &height)
{
/* FT_Error error;
error = FT_Set_Pixel_Sizes (_Face, size, size);
if (error)
{
nlerror ("FT_Set_Pixel_Sizes() failed: %s", getFT2Error(error));
}
// retrieve glyph index from character code
FT_UInt glyph_index = FT_Get_Char_Index (_Face, c);
// load glyph image into the slot (erase previous one)
error = FT_Load_Glyph (_Face, glyph_index, FT_LOAD_DEFAULT);
if (error)
{
nlerror ("FT_Load_Glyph() failed: %s", getFT2Error(error));
}
// convert 24.6 fixed point into integer
width = _Face->glyph->metrics.width >> 6;
height = _Face->glyph->metrics.height >> 6;
*/
}
HFONT hFont = NULL;
@ -523,57 +479,6 @@ uint32 CurrentFontSize = 0;
uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex)
{
/* FT_Error error;
error = FT_Set_Pixel_Sizes (_Face, size, size);
if (error)
{
nlerror ("FT_Set_Pixel_Sizes() failed: %s", getFT2Error(error));
}
// retrieve glyph index from character code
FT_UInt glyph_index = FT_Get_Char_Index (_Face, c);
// load glyph image into the slot (erase previous one)
error = FT_Load_Glyph (_Face, glyph_index, FT_LOAD_DEFAULT);
if (error)
{
nlerror ("FT_Load_Glyph() failed: %s", getFT2Error(error));
}
if (size == 0)
{
width = 0;
height = 0;
pitch = 0;
left = 0;
top = 0;
advx = 0;
glyphIndex = glyph_index;
return NULL;
}
// convert to an anti-aliased bitmap
error = FT_Render_Glyph (_Face->glyph, ft_render_mode_normal);
if (error)
{
nlerror ("FT_Render_Glyph() failed: %s", getFT2Error(error));
}
width = _Face->glyph->bitmap.width;
height = _Face->glyph->bitmap.rows;
pitch = _Face->glyph->bitmap.pitch;
left = _Face->glyph->bitmap_left;
top = _Face->glyph->bitmap_top;
advx = _Face->glyph->advance.x >> 6;
glyphIndex = glyph_index;
return (uint8 *) _Face->glyph->bitmap.buffer;
*/
if (size == 0)
{
width = 0;
@ -700,12 +605,6 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl
advx = point.x;
WORD ag = 0;
/*uint t = GetGlyphIndices (hdcDib, &cc, 1, &ag, 0);
if (t == GDI_ERROR)
{
nlstop;
}
*/
glyphIndex = ag;
top = -_top;
@ -737,27 +636,12 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl
void CFontGenerator::getKerning (ucchar left, ucchar right, sint32 &kernx)
{
/* if (!FT_HAS_KERNING(_Face))
{
kernx = 0;
}
else
{
FT_Vector kerning;
FT_Error error = FT_Get_Kerning (_Face, left, right, ft_kerning_default, &kerning);
if (error)
{
nlerror ("FT_Get_Kerning() failed: %s", getFT2Error(error));
}
kernx = kerning.x;
}*/
}
uint32 CFontGenerator::getCharIndex (ucchar c)
{
// return FT_Get_Char_Index (_Face, c);
return 0;
}

View file

@ -46,6 +46,7 @@ CMaterial* CFontManager::getFontMaterial()
if (_TexFont == NULL)
{
_TexFont = new CTextureFont;
_TexCacheNr++;
}
if (_MatFont == NULL)
@ -142,11 +143,17 @@ void CFontManager::computeString (const ucstring &s,
sint32 nMaxZ = -1000000, nMinZ = 1000000;
output.StringHeight = 0;
// save string info for later rebuild as needed
output.Text = s;
output.CacheVersion = getCacheVersion();
uint j = 0;
{
CVertexBufferReadWrite vba;
output.Vertices.lock (vba);
hlfPixScrW = 0.f;
hlfPixScrH = 0.f;
// For all chars
for (uint i = 0; i < s.size(); i++)
@ -157,38 +164,43 @@ void CFontManager::computeString (const ucstring &s,
k.Size = fontSize;
k.Embolden = embolden;
k.Oblique = oblique;
CTextureFont::SLetterInfo *pLI = pTexFont->getLetterInfo (k);
// render letter
CTextureFont::SLetterInfo *pLI = pTexFont->getLetterInfo (k, true);
if(pLI != NULL)
{
if ((pLI->CharWidth > 0) && (pLI->CharHeight > 0))
if (pLI->glyph)
{
// If letter is heavily upscaled, then there is noticeable clipping on edges
// fixing UV will make it bit better
if ((pLI->Size >> 1) > pLI->glyph->Size)
{
hlfPixTexW = 0.5f * TexRatioW;
hlfPixTexH = 0.5f * TexRatioH;
}
// Creating vertices
dx = pLI->Left;
dz = -((sint32)pLI->CharHeight-(sint32)(pLI->Top));
u1 = pLI->U - hlfPixTexW;
v1 = pLI->V - hlfPixTexH;
u2 = pLI->U + ((float)pLI->CharWidth) * TexRatioW + hlfPixTexW;
v2 = pLI->V + ((float)pLI->CharHeight) * TexRatioH + hlfPixTexH;
dz = -((sint32)pLI->CharHeight - (sint32)(pLI->Top));
x1 = (penx + dx) - hlfPixScrW;
z1 = (penz + dz) - hlfPixScrH;
x2 = (penx + dx + (sint32)pLI->CharWidth) + hlfPixScrW;
x2 = (penx + dx + (sint32)pLI->CharWidth) + hlfPixScrW;
z2 = (penz + dz + (sint32)pLI->CharHeight) + hlfPixScrH;
vba.setVertexCoord (j, x1, 0, z1);
vba.setTexCoord (j, 0, u1, v2);
vba.setTexCoord (j, 0, pLI->glyph->U0-hlfPixTexW, pLI->glyph->V1+hlfPixTexH);
++j;
vba.setVertexCoord (j, x2, 0, z1);
vba.setTexCoord (j, 0, u2, v2);
vba.setTexCoord (j, 0, pLI->glyph->U1+hlfPixTexW, pLI->glyph->V1+hlfPixTexH);
++j;
vba.setVertexCoord (j, x2, 0, z2);
vba.setTexCoord (j, 0, u2, v1);
vba.setTexCoord (j, 0, pLI->glyph->U1+hlfPixTexW, pLI->glyph->V0-hlfPixTexH);
++j;
vba.setVertexCoord (j, x1, 0, z2);
vba.setTexCoord (j, 0, u1, v1);
vba.setTexCoord (j, 0, pLI->glyph->U0-hlfPixTexW, pLI->glyph->V0-hlfPixTexH);
++j;
// String Bound
@ -245,6 +257,19 @@ void CFontManager::computeStringInfo ( const ucstring &s,
{
output.Color = color;
// save string info for later rebuild as needed
output.Text = s;
output.CacheVersion = 0;
if (s.empty())
{
output.StringWidth = 0.f;
output.StringHeight = 0;
output.StringLine = 0;
return;
}
// resize fontSize if window not of 800x600.
if (keep800x600Ratio)
{
@ -273,7 +298,7 @@ void CFontManager::computeStringInfo ( const ucstring &s,
k.Size = fontSize;
k.Embolden = embolden;
k.Oblique = oblique;
pLI = pTexFont->getLetterInfo (k);
pLI = pTexFont->getLetterInfo (k, false);
if(pLI != NULL)
{
if ((pLI->CharWidth > 0) && (pLI->CharHeight > 0))
@ -318,7 +343,11 @@ void CFontManager::invalidate()
{
if (_TexFont)
_TexFont = NULL;
_TexFont = new CTextureFont;
_TexCacheNr++;
getFontMaterial()->setTexture(0, _TexFont);
}

View file

@ -2423,7 +2423,7 @@ void CLandscape::checkZoneBinds(CZone &curZone, EBadBind &bindError)
// ***************************************************************************
void CLandscape::checkBinds() throw(EBadBind)
void CLandscape::checkBinds()
{
EBadBind bindError;
@ -2439,7 +2439,7 @@ void CLandscape::checkBinds() throw(EBadBind)
// ***************************************************************************
void CLandscape::checkBinds(uint16 zoneId) throw(EBadBind)
void CLandscape::checkBinds(uint16 zoneId)
{
EBadBind bindError;

View file

@ -51,7 +51,7 @@ CEventServer CNELU::EventServer;
CEventListenerAsync CNELU::AsyncListener;
bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru)
bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d)
{
// Init debug system
// NLMISC::InitDebug();
@ -183,7 +183,7 @@ void CNELU::releaseDriver()
}
}
bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru)
bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d)
{
NL3D::registerSerial3d();
if (initDriver(w,h,bpp,windowed,systemWindow,offscreen,direct3d))

View file

@ -47,7 +47,8 @@ CTextContext::CTextContext()
_Shaded = false;
_ShadeOutline = false;
_ShadeExtent = 0.001f;
_ShadeExtentX = 0.001f;
_ShadeExtentY = 0.001f;
_ShadeColor = NLMISC::CRGBA(0,0,0);
_Keep800x600Ratio= true;
@ -73,25 +74,9 @@ uint32 CTextContext::textPush (const char *format, ...)
char *str;
NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize);
if (_CacheNbFreePlaces == 0)
{
CComputedString csTmp;
_CacheStrings.push_back (csTmp);
if (_CacheFreePlaces.empty())
_CacheFreePlaces.resize (1);
_CacheFreePlaces[0] = (uint32)_CacheStrings.size()-1;
_CacheNbFreePlaces = 1;
}
// compute the string.
uint32 index = _CacheFreePlaces[_CacheNbFreePlaces-1];
CComputedString &strToFill = _CacheStrings[index];
_FontManager->computeString (str, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio);
_CacheNbFreePlaces--;
return index;
ucstring uc;
uc.fromUtf8((const char *)str);
return textPush(uc);
}
// ------------------------------------------------------------------------------------------------
@ -114,8 +99,10 @@ uint32 CTextContext::textPush (const ucstring &str)
uint32 index = _CacheFreePlaces[_CacheNbFreePlaces-1];
nlassert (index < _CacheStrings.size());
CComputedString &strToFill = _CacheStrings[index];
_FontManager->computeString (str, _FontGen, _Color
, _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio);
_FontManager->computeString (str, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio);
// just compute letters, glyphs are rendered on demand before first draw
//_FontManager->computeStringInfo(str, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio);
_CacheNbFreePlaces--;

View file

@ -187,11 +187,11 @@ bool CTextContextUser::getShadeOutline() const
return _TextContext.getShadeOutline();
}
void CTextContextUser::setShadeExtent(float shext)
void CTextContextUser::setShadeExtent(float x, float y)
{
H_AUTO2;
_TextContext.setShadeExtent(shext);
_TextContext.setShadeExtent(x, y);
}
void CTextContextUser::setShadeColor (NLMISC::CRGBA sc)
{

View file

@ -23,7 +23,7 @@
#include "nel/misc/common.h"
#include "nel/misc/rect.h"
#include "nel/misc/file.h"
#include "nel/misc/path.h"
using namespace std;
using namespace NLMISC;
@ -35,37 +35,14 @@ using namespace NLMISC;
namespace NL3D
{
// Config 1
const int TextureSizeX = 1024;
const int TextureSizeY = 1024; // If change this value -> change NbLine too
const int Categories[TEXTUREFONT_NBCATEGORY] = { 8, 16, 24, 32, 64 };
const int NbLine[TEXTUREFONT_NBCATEGORY] = { 8, 24, 16, 4, 1 }; // Based on textsize
/*
const int TextureSizeX = 256;
const int TextureSizeY = 256;
const int Categories[TEXTUREFONT_NBCATEGORY] = { 8, 16, 24, 32 };
const int NbLine[TEXTUREFONT_NBCATEGORY] = { 4, 6, 4, 1 }; // Based on textsize
*/
// ---------------------------------------------------------------------------
inline uint32 CTextureFont::SLetterKey::getVal()
{
// this limits Size to 6bits
// Large sizes already render wrong when many
// different glyphs are used due to limited texture atlas
uint8 eb = ((uint)Embolden) + ((uint)Oblique << 1);
if (FontGenerator == NULL)
return Char + ((Size&255)<<16) + (eb << 22);
else
return Char + ((Size&255)<<16) + (eb << 22) + ((FontGenerator->getUID()&0xFF)<<24);
}
// ---------------------------------------------------------------------------
CTextureFont::CTextureFont()
: _CacheVersion(1),
_TextureSizeX(512), _TextureSizeY(512), _TextureMaxW(4096), _TextureMaxH(4096),
_PaddingL(0), _PaddingT(0), _PaddingR(1), _PaddingB(1),
_MinGlyphSize(5), _MaxGlyphSize(200),
_GlyphSizeStepMin(50), _GlyphSizeStep(5)
{
uint i;
setFilterMode (ITexture::Linear, ITexture::LinearMipMapOff);
setWrapS (ITexture::Repeat);
@ -75,53 +52,9 @@ CTextureFont::CTextureFont()
setReleasable (false);
resize (TextureSizeX, TextureSizeY, CBitmap::Alpha);
for(i = 0; i < TextureSizeX*TextureSizeY; ++i)
getPixels()[i] = 0;
// convertToType (CBitmap::Alpha);
resize (_TextureSizeX, _TextureSizeY, CBitmap::Alpha, true);
sint posY = 0;
for(i = 0; i < TEXTUREFONT_NBCATEGORY; ++i)
{
// Number of chars per cache
Letters[i].resize ((TextureSizeX/Categories[i])*NbLine[i]);
for(uint32 j = 0; j < Letters[i].size(); ++j)
{
SLetterInfo &rLetter = Letters[i][j];
rLetter.Char = 0xffff;
rLetter.FontGenerator = NULL;
rLetter.Size= 0;
rLetter.Embolden = false;
rLetter.Oblique = false;
// The less recently used infos
if (j < Letters[i].size()-1)
rLetter.Next = &Letters[i][j+1];
else
rLetter.Next = NULL;
if (j > 0)
rLetter.Prev = &Letters[i][j-1];
else
rLetter.Prev = NULL;
rLetter.Cat = i;
sint sizeX = TextureSizeX/Categories[i];
rLetter.U = (Categories[i]*(j%sizeX)) / ((float)TextureSizeX);
rLetter.V = (posY + Categories[i]*((sint)(j/sizeX))) / ((float)TextureSizeY);
/////////////////////////////////////////////////
rLetter.CharWidth = rLetter.CharHeight = 0;
rLetter.GlyphIndex = rLetter.Top = rLetter.Left = rLetter.AdvX = 0;
}
Front[i] = &Letters[i][0];
Back[i] = &Letters[i][Letters[i].size()-1];
posY += NbLine[i] * Categories[i];
}
_AtlasNodes.push_back(CRect(0, 0, _TextureSizeX, _TextureSizeY));
}
@ -129,17 +62,16 @@ CTextureFont::~CTextureFont()
{
}
// ---------------------------------------------------------------------------
void CTextureFont::dumpTextureFont(const char *filename)
{
CBitmap b;
COFile f( filename );
b.resize (TextureSizeX, TextureSizeY, CBitmap::RGBA);
b.resize (_TextureSizeX, _TextureSizeY, CBitmap::RGBA);
CObjectVector<uint8>&bits = b.getPixels();
CObjectVector<uint8>&src = getPixels();
for (uint i = 0; i < (TextureSizeX*TextureSizeY); ++i)
for (uint i = 0; i < (_TextureSizeX*_TextureSizeY); ++i)
{
bits[i*4+0] = bits[i*4+1] = bits[i*4+2] = bits[i*4+3] = src[i];
}
@ -147,242 +79,471 @@ void CTextureFont::dumpTextureFont(const char *filename)
b.writeTGA (f, 32);
}
// ---------------------------------------------------------------------------
bool CTextureFont::getNextTextureSize(uint32 &newW, uint32 &newH) const
{
// width will be resized first (256x256 -> 512x256)
if (_TextureSizeX <= _TextureSizeY)
{
newW = _TextureSizeX * 2;
newH = _TextureSizeY;
}
else
{
newW = _TextureSizeX;
newH = _TextureSizeY * 2;
}
// no more room
return newW <= _TextureMaxW && newH <= _TextureMaxH;
}
// ---------------------------------------------------------------------------
// cat : categories where the letter is
// x : pos x of the letter
// y : pos y of the letter
void CTextureFont::rebuildLetter (sint cat, sint x, sint y)
// out of room, clear everything and rebuild glyphs on demand
// note: text will display wrong until glyphs get rendered again
void CTextureFont::clearAtlas()
{
sint sizex = TextureSizeX / Categories[cat];
sint index = x + y*sizex;
SLetterInfo &rLetter = Letters[cat][index];
nlwarning("Glyph cache will be cleared.");
if (rLetter.FontGenerator == NULL)
return;
_AtlasNodes.clear();
_AtlasNodes.push_back(CRect(0, 0, _TextureSizeX, _TextureSizeY));
sint catTopY = 0;
sint c = 0;
while (c < cat)
// clear texture
_Data[0].fill(0);
// clear glyph cache
for(uint i = 0; i< _Letters.size(); ++i)
{
catTopY += NbLine[c] * Categories[c];
++c;
_Letters[i].glyph = NULL;
}
// Destination position in pixel of the letter
sint posx = x * Categories[cat];
sint posy = catTopY + y * Categories[cat];
_GlyphCache.clear();
uint32 pitch = 0;
uint8 *bitmap = rLetter.FontGenerator->getBitmap ( rLetter.Char, rLetter.Size, rLetter.Embolden, rLetter.Oblique,
rLetter.CharWidth, rLetter.CharHeight,
pitch, rLetter.Left, rLetter.Top,
rLetter.AdvX, rLetter.GlyphIndex );
_CacheVersion++;
// Copy FreeType buffer
uint i;
for (i = 0; i < rLetter.CharHeight; ++i)
touch();
}
// ---------------------------------------------------------------------------
void CTextureFont::repackAtlas()
{
repackAtlas(_TextureSizeX, _TextureSizeY);
}
// ---------------------------------------------------------------------------
// backup old glyphs and move them to newly resized texture
// new atlas will be sorted if _GlyphCache is
void CTextureFont::repackAtlas(uint32 newW, uint32 newH)
{
uint32 newCacheVersion = _CacheVersion+1;
CBitmap btm;
uint32 oldW, oldH;
oldW = _TextureSizeX;
oldH = _TextureSizeY;
btm.resize(oldW, oldH, CBitmap::Alpha, true);
btm.blit(this, 0, 0);
// resize texture
if (_TextureSizeX != newW || _TextureSizeY != newH)
{
uint8 *pDst = &_Data[0][posx + (posy+i)*TextureSizeY];
uint8 *pSrc = &bitmap[i*pitch];
for (uint j = 0; j < rLetter.CharWidth; ++j)
_TextureSizeX = newW;
_TextureSizeY = newH;
resize (_TextureSizeX, _TextureSizeY, CBitmap::Alpha, true);
}
else
{
_Data[0].fill(0);
}
// release atlas and rebuild
_AtlasNodes.clear();
_AtlasNodes.push_back(CRect(0, 0, _TextureSizeX, _TextureSizeY));
CObjectVector<uint8>&src = btm.getPixels();
for(std::list<SGlyphInfo>::iterator it = _GlyphCache.begin(); it != _GlyphCache.end(); ++it)
{
if (it->CacheVersion != _CacheVersion)
{
*pDst = *pSrc;
++pDst;
++pSrc;
// TODO: must remove glyph from all letters before removing glyph from cache
//continue;
}
SGlyphInfo &glyph = *it;
glyph.CacheVersion = newCacheVersion;
uint32 atlasX, atlasY;
if (reserveAtlas(glyph.W, glyph.H, atlasX, atlasY))
{
for (uint y = 0; y < glyph.H; ++y)
{
uint8 *pDst = &_Data[0][(atlasY + y) * _TextureSizeX + atlasX];
for (uint x = 0; x < glyph.W; ++x)
{
*pDst = src[(glyph.Y + y) * oldW + glyph.X + x];
++pDst;
}
}
// TODO: dup code with renderGlyph
glyph.U0 = (atlasX+_PaddingL) / (float)_TextureSizeX;
glyph.V0 = (atlasY+_PaddingT) / (float)_TextureSizeY;
glyph.U1 = (atlasX+_PaddingL+glyph.CharWidth) / (float)_TextureSizeX;
glyph.V1 = (atlasY+_PaddingT+glyph.CharHeight) / (float)_TextureSizeY;
glyph.X = atlasX;
glyph.Y = atlasY;
}
}
// Black border bottom and right
for (i = 0; i < rLetter.CharHeight+1; ++i)
_CacheVersion = newCacheVersion;
// invalidate full texture
touch();
}
// ---------------------------------------------------------------------------
bool CTextureFont::resizeAtlas()
{
uint32 newW, newH;
if (!getNextTextureSize(newW, newH))
{
_Data[0][posx + rLetter.CharWidth + (posy+i)*TextureSizeY] = 0;
nlwarning("Font texture at maximum (%d,%d). Resize failed.", _TextureSizeX, _TextureSizeY);
return false;
}
for (i = 0; i < rLetter.CharWidth+1; ++i)
{
_Data[0][posx + i + (posy+rLetter.CharHeight)*TextureSizeY] = 0;
}
/*
dumpTextureFont (this);
int a = 5;
a++;
*/
// resize and redraw
repackAtlas(newW, newH);
return true;
}
// ---------------------------------------------------------------------------
void CTextureFont::doGenerate(bool async)
{
// Rectangle invalidate ?
if (_ListInvalidRect.begin()!=_ListInvalidRect.end())
{
// Yes, rebuild only those rectangles.
// For each rectangle to compute
std::list<NLMISC::CRect>::iterator ite=_ListInvalidRect.begin();
while (ite!=_ListInvalidRect.end())
{
// Compute rectangle coordinates
sint x = ite->left();
sint y = ite->bottom();
// Look in which category is the rectangle
sint cat = 0;
sint catTopY = 0;
sint catBotY = NbLine[cat] * Categories[cat];
while (y > catBotY)
{
if (y < catBotY)
break;
++cat;
nlassert (cat < TEXTUREFONT_NBCATEGORY);
catTopY = catBotY;
catBotY += NbLine[cat] * Categories[cat];
}
x = x / Categories[cat];
y = ite->top();
y = y - catTopY;
y = y / Categories[cat];
rebuildLetter (cat, x, y);
// Next rectangle
ite++;
}
}
else
{
for(int cat = 0; cat < TEXTUREFONT_NBCATEGORY; ++cat)
{
sint sizex = TextureSizeX / Categories[cat];
sint sizey = NbLine[cat];
for (sint y = 0; y < sizey; y++)
for (sint x = 0; x < sizex; x++)
{
rebuildLetter (cat, x, y);
}
}
}
/*
dumpTextureFont (this);
int a = 5;
*/
/*
nlinfo("doGenerate: Letters(%d/%d), Glyphs(%d/%d)\n", _Letters.size(), _Letters.size() * sizeof(SLetterInfo),
_GlyphCache.size(), _GlyphCache.size() * sizeof(SGlyphInfo));
//std::string fname = CFile::findNewFile("/tmp/font-texture.tga");
std::string fname = toString("/tmp/font-texture-%p-%03d.tga", this, _CacheVersion);
dumpTextureFont (fname.c_str());
*/
}
// ---------------------------------------------------------------------------
CTextureFont::SLetterInfo* CTextureFont::getLetterInfo (SLetterKey& k)
uint CTextureFont::fitRegion(uint index, uint width, uint height)
{
sint cat;
uint32 nTmp = k.getVal();
map<uint32, SLetterInfo*>::iterator itAccel = Accel.find (nTmp);
if (itAccel != Accel.end())
if (_AtlasNodes[index].X + width > _TextureSizeX - 1)
{
// Put it in the first place
SLetterInfo *pLetterToMove = itAccel->second;
cat = pLetterToMove->Cat;
if (pLetterToMove != Front[cat])
return -1;
}
uint x = _AtlasNodes[index].X;
uint y = _AtlasNodes[index].Y;
sint widthLeft = width;
while(widthLeft > 0)
{
if (_AtlasNodes[index].Y > y)
{
// unlink
nlassert(pLetterToMove->Prev);
pLetterToMove->Prev->Next = pLetterToMove->Next;
if (pLetterToMove == Back[cat])
{
Back[cat] = pLetterToMove->Prev;
}
else
{
pLetterToMove->Next->Prev = pLetterToMove->Prev;
}
// link to front
pLetterToMove->Prev = NULL;
pLetterToMove->Next = Front[cat];
Front[cat]->Prev = pLetterToMove;
Front[cat] = pLetterToMove;
y = _AtlasNodes[index].Y;
}
return pLetterToMove;
// _AtlasNodes[0] for margin is not used here
if (_AtlasNodes[index].Y + height > _TextureSizeY - 1)
{
return -1;
}
widthLeft -= _AtlasNodes[index].Width;
index++;
}
// The letter is not already present
// Found the category of the new letter
uint32 width, height;
return y;
}
//k.FontGenerator->getSizes (k.Char, k.Size, width, height);
// \todo mat : Temp !!! Try to use freetype cache
uint32 nPitch, nGlyphIndex;
sint32 nLeft, nTop, nAdvX;
k.FontGenerator->getBitmap (k.Char, k.Size, k.Embolden, k.Oblique, width, height, nPitch, nLeft, nTop,
nAdvX, nGlyphIndex );
bool CTextureFont::reserveAtlas(const uint32 width, const uint32 height, uint32 &x, uint32 &y)
{
if (_AtlasNodes.empty())
{
nlwarning("No available space in texture atlas (_AtlasNodes.empty() == true)");
return false;
}
// Add 1 pixel space for black border to get correct category
cat = 0;
if (((sint)width+1 > Categories[TEXTUREFONT_NBCATEGORY-1]) ||
((sint)height+1 > Categories[TEXTUREFONT_NBCATEGORY-1]))
x = 0;
y = 0;
sint bestIndex = -1;
sint bestWidth = _TextureSizeX;
sint bestHeight = _TextureSizeY;
sint selY=0;
for (uint i = 0; i < _AtlasNodes.size(); ++i)
{
selY = fitRegion(i, width, height);
if (selY >=0)
{
if (((selY + height) < bestHeight) || ((selY + height) == bestHeight && _AtlasNodes[i].Width > 0 && _AtlasNodes[i].Width < bestWidth))
{
bestHeight = selY + height;
bestIndex = i;
bestWidth = _AtlasNodes[i].Width;
x = _AtlasNodes[i].X;
y = selY;
}
}
}
if (bestIndex == -1)
{
x = 0;
y = 0;
return false;
}
CRect r(x, y + height, width, 0);
_AtlasNodes.insert(_AtlasNodes.begin() + bestIndex, r);
// shrink or remove nodes overlaping with newly inserted node
for(uint i = bestIndex+1; i< _AtlasNodes.size(); i++)
{
if (_AtlasNodes[i].X < (_AtlasNodes[i-1].X + _AtlasNodes[i-1].Width))
{
sint shrink = _AtlasNodes[i-1].X + _AtlasNodes[i-1].Width - _AtlasNodes[i].X;
_AtlasNodes[i].X += shrink;
if (_AtlasNodes[i].Width > shrink)
{
_AtlasNodes[i].Width -= shrink;
break;
}
_AtlasNodes.erase(_AtlasNodes.begin() + i);
i--;
}
else break;
}
// merge nearby nodes from same row
for(uint i = 0; i < _AtlasNodes.size() - 1; i++)
{
if (_AtlasNodes[i].Y == _AtlasNodes[i+1].Y)
{
_AtlasNodes[i].Width += _AtlasNodes[i+1].Width;
_AtlasNodes.erase(_AtlasNodes.begin() + i + 1);
i--;
}
}
return true;
}
// ---------------------------------------------------------------------------
// bitmap : texture data
// bitmapW : bitmap width
// bitmapH : bitmap height
// atlasX : pos x in font texture
// atlasY : pos y in font texture
void CTextureFont::copyGlyphBitmap(uint8* bitmap, uint32 bitmapW, uint32 bitmapH, uint32 atlasX, uint32 atlasY)
{
for (uint bY = 0; bY < bitmapH; ++bY)
{
uint8 *pDst = &_Data[0][(atlasY+_PaddingT+bY) * _TextureSizeX+atlasX+_PaddingL];
for (uint bX = 0; bX < bitmapW; ++bX)
{
*pDst = bitmap[bY * bitmapW+bX];
++pDst;
}
}
if (_PaddingR > 0 || _PaddingB > 0 || _PaddingL > 0 || _PaddingT > 0)
{
for(uint i = 0; i<(bitmapH+_PaddingT+_PaddingB); ++i)
{
if (_PaddingT > 0) _Data[0][(atlasY + i) * _TextureSizeX + atlasX ] = 0;
if (_PaddingB > 0) _Data[0][(atlasY + i) * _TextureSizeX + atlasX + _PaddingL + bitmapW] = 0;
}
for (uint i = 0; i<(bitmapW+_PaddingL+_PaddingR); ++i)
{
if (_PaddingL > 0) _Data[0][atlasY * _TextureSizeX + atlasX + i] = 0;
if (_PaddingB > 0) _Data[0][(atlasY + _PaddingT + bitmapH) * _TextureSizeX + atlasX + i] = 0;
}
}
CRect r(atlasX, atlasY, bitmapW + _PaddingL + _PaddingR, bitmapH + _PaddingT + _PaddingB);
touchRect(r);
}
// ---------------------------------------------------------------------------
CTextureFont::SGlyphInfo* CTextureFont::renderLetterGlyph(SLetterInfo *letter, uint bitmapFontSize)
{
uint32 nPitch;
sint32 left;
sint32 top;
sint32 advx;
uint32 charWidth;
uint32 charHeight;
uint32 glyphIndex;
uint8 *bitmap = letter->FontGenerator->getBitmap (letter->Char, bitmapFontSize, letter->Embolden, letter->Oblique,
charWidth, charHeight,
nPitch, left, top,
advx, glyphIndex );
uint32 atlasX, atlasY;
uint32 rectW, rectH;
rectW = charWidth + _PaddingL + _PaddingR;
rectH = charHeight + _PaddingT + _PaddingB;
if (!reserveAtlas(rectW, rectH, atlasX, atlasY))
{
// no room
return NULL;
}
copyGlyphBitmap(bitmap, charWidth, charHeight, atlasX, atlasY);
while (((sint)width+1 > Categories[cat]) || ((sint)height+1 > Categories[cat]))
SGlyphInfo* glyphInfo = NULL;
{
++cat;
nlassert (cat != TEXTUREFONT_NBCATEGORY);
// keep cache sorted by height (smaller first)
std::list<SGlyphInfo>::iterator it = _GlyphCache.begin();
while(it != _GlyphCache.end() && it->CharHeight < charHeight)
{
++it;
}
it = _GlyphCache.insert(it, SGlyphInfo());
glyphInfo = &(*it);
}
// And replace the less recently used letter
SLetterKey k2;
k2.Char = Back[cat]->Char;
k2.FontGenerator = Back[cat]->FontGenerator;
k2.Size = Back[cat]->Size;
k2.Embolden = Back[cat]->Embolden;
k2.Oblique = Back[cat]->Oblique;
glyphInfo->GlyphIndex = glyphIndex;
glyphInfo->Size = bitmapFontSize;
glyphInfo->Embolden = letter->Embolden;
glyphInfo->Oblique = letter->Oblique;
glyphInfo->FontGenerator = letter->FontGenerator;
glyphInfo->CacheVersion = _CacheVersion;
itAccel = Accel.find (k2.getVal());
if (itAccel != Accel.end())
glyphInfo->U0 = (atlasX+_PaddingL) / (float)_TextureSizeX;
glyphInfo->V0 = (atlasY+_PaddingT) / (float)_TextureSizeY;
glyphInfo->U1 = (atlasX+_PaddingL+charWidth) / (float)_TextureSizeX;
glyphInfo->V1 = (atlasY+_PaddingT+charHeight) / (float)_TextureSizeY;
glyphInfo->CharWidth = charWidth;
glyphInfo->CharHeight = charHeight;
glyphInfo->X = atlasX;
glyphInfo->Y = atlasY;
glyphInfo->W = rectW;
glyphInfo->H = rectH;
return glyphInfo;
}
// ---------------------------------------------------------------------------
CTextureFont::SGlyphInfo* CTextureFont::findLetterGlyph(SLetterInfo *letter, bool insert)
{
uint bitmapFontSize = max((sint)_MinGlyphSize, min((sint)_MaxGlyphSize, letter->Size));
if (_GlyphSizeStep > 1 && bitmapFontSize > _GlyphSizeStepMin)
{
Accel.erase (itAccel);
bitmapFontSize = (bitmapFontSize / _GlyphSizeStep) * _GlyphSizeStep;
}
SLetterInfo *NewBack = Back[cat]->Prev;
NewBack->Next = NULL;
Back[cat]->Cat = cat;
Back[cat]->Char = k.Char;
Back[cat]->FontGenerator = k.FontGenerator;
Back[cat]->Size = k.Size;
Back[cat]->Embolden = k.Embolden;
Back[cat]->Oblique = k.Oblique;
Back[cat]->CharWidth = width;
Back[cat]->CharHeight = height;
Back[cat]->Top = nTop;
Back[cat]->Left = nLeft;
Back[cat]->AdvX = nAdvX;
Back[cat]->Prev = NULL;
Back[cat]->Next = Front[cat];
Front[cat]->Prev = Back[cat];
Front[cat] = Back[cat];
Back[cat] = NewBack;
Accel.insert (map<uint32, SLetterInfo*>::value_type(k.getVal(),Front[cat]));
// Invalidate the zone
sint index = (sint)(Front[cat] - &Letters[cat][0]);// / sizeof (SLetterInfo);
sint sizex = TextureSizeX / Categories[cat];
sint x = index % sizex;
sint y = index / sizex;
x = x * Categories[cat];
y = y * Categories[cat];
sint c = 0;
while (c < cat)
// CacheVersion not checked, all glyphs in cache must be rendered on texture
for(std::list<SGlyphInfo>::iterator it = _GlyphCache.begin(); it != _GlyphCache.end(); ++it)
{
y = y + NbLine[c] * Categories[c];
++c;
if (it->GlyphIndex == letter->GlyphIndex &&
it->Size == bitmapFontSize &&
it->Embolden == letter->Embolden &&
it->Oblique == letter->Oblique &&
it->FontGenerator == letter->FontGenerator)
{
return &(*it);
}
}
// must update the char, WITH the black borders
CRect r (x, y, width+1, height+1);
if (insert)
{
return renderLetterGlyph(letter, bitmapFontSize);
}
touchRect (r);
return NULL;
}
return Front[cat];
// ---------------------------------------------------------------------------
CTextureFont::SLetterInfo* CTextureFont::findLetter(SLetterKey &k, bool insert)
{
// TODO: use std::map<uint64>
for(uint i = 0; i < _Letters.size(); ++i)
{
if (_Letters[i].Char == k.Char && _Letters[i].Size == k.Size &&
_Letters[i].Embolden == k.Embolden && _Letters[i].Oblique == k.Oblique &&
_Letters[i].FontGenerator == k.FontGenerator)
{
return &_Letters[i];
}
}
if (insert)
{
_Letters.push_back(SLetterInfo());
SLetterInfo* letter = &_Letters.back();
// get metrics for requested size
letter->Char = k.Char;
letter->Size = k.Size;
letter->Embolden = k.Embolden;
letter->Oblique = k.Oblique;
letter->FontGenerator = k.FontGenerator;
uint32 nPitch;
letter->FontGenerator->getBitmap(letter->Char, letter->Size, letter->Embolden, letter->Oblique,
letter->CharWidth, letter->CharHeight,
nPitch, letter->Left, letter->Top,
letter->AdvX, letter->GlyphIndex );
return letter;
}
return NULL;
}
// ---------------------------------------------------------------------------
CTextureFont::SLetterInfo* CTextureFont::getLetterInfo (SLetterKey& k, bool render)
{
// find already cached letter or create new one
SLetterInfo* letter = findLetter(k, true);
// letter not found (=NULL) or render not requested
if (!letter || !render) return letter;
// nothing to render, ie space char
if (letter->CharWidth == 0 || letter->CharHeight == 0) return letter;
if (!letter->glyph || letter->glyph->CacheVersion != _CacheVersion)
{
// render glyph
letter->glyph = findLetterGlyph(letter, true);
if (letter->glyph == NULL)
{
// resize/repack and try again
if (!resizeAtlas()) repackAtlas();
letter->glyph = findLetterGlyph(letter, true);
if (letter->glyph == NULL)
{
// make room by clearing all glyphs and reduce max size for glyphs
clearAtlas();
if (_MaxGlyphSize > _MinGlyphSize)
{
_MaxGlyphSize = max(_MinGlyphSize, _MaxGlyphSize - 10);
}
letter->glyph = findLetterGlyph(letter, true);
}
}
}
return letter;
}
} // NL3D

View file

@ -25,6 +25,8 @@ using namespace NLMISC;
#define new DEBUG_NEW
#endif
void vertex_buffer_heap_dummy_cpp() { }
// This code is not used actually and doesn't compile
// just preproc comment it
#if 0

View file

@ -677,7 +677,7 @@ void CWaterHeightMap::setWaves(float intensity, float period, uint radius, bool
void CWaterHeightMap::serial(NLMISC::IStream &f)
{
f.xmlPushBegin("WaterHeightMap");
f.xmlSetAttrib ("NAME") ;
f.xmlSetAttrib ("NAME");
f.serial (_Name);
f.xmlPushEnd();
(void)f.serialVersion(0);

View file

@ -6,9 +6,10 @@ SOURCE_GROUP("src" FILES ${SRC})
NL_TARGET_LIB(nelgui ${SRC} ${HEADERS})
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${CURL_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${LUABIND_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES})
TARGET_LINK_LIBRARIES(nelgui nelmisc nel3d ${LUA_LIBRARIES} ${LUABIND_LIBRARIES} ${CURL_LIBRARIES})
NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI")
NL_ADD_RUNTIME_FLAGS(nelgui)

View file

@ -748,8 +748,12 @@ namespace NLGUI
{
virtual void execute (CCtrlBase *pCaller, const std::string &params)
{
if (!CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(params))
ucstring s;
s.fromUtf8(params);
if (!CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(s))
{
nlwarning("Copy to clipboard failed: '%s'", params.c_str());
}
}
};
REGISTER_ACTION_HANDLER(CAHCopyToClipboard, "copy_to_clipboard");

View file

@ -0,0 +1,716 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include <string>
#include "nel/misc/types_nl.h"
#include "nel/gui/css_parser.h"
#include "nel/gui/css_style.h"
#include "nel/gui/css_selector.h"
using namespace NLMISC;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLGUI
{
// ***************************************************************************
// Parse style declarations style, eg. "color:red; font-size: 10px;"
//
// key is converted to lowercase
// value is left as is
TStyle CCssParser::parseDecls(const std::string &styleString)
{
TStyle styles;
std::vector<std::string> elements;
NLMISC::splitString(styleString, ";", elements);
for(uint i = 0; i < elements.size(); ++i)
{
std::string::size_type pos;
pos = elements[i].find_first_of(':');
if (pos != std::string::npos)
{
std::string key = trim(toLower(elements[i].substr(0, pos)));
std::string value = trim(elements[i].substr(pos+1));
styles[key] = value;
}
}
return styles;
}
// ***************************************************************************
// Parse stylesheet, eg content from main.css file
//
// Return all found rules
void CCssParser::parseStylesheet(const std::string &cssString, std::vector<CCssStyle::SStyleRule> &result)
{
_Rules.clear();
_Style.clear();
_Style.fromUtf8(cssString);
preprocess();
_Position = 0;
while(!is_eof())
{
skipWhitespace();
if (_Style[_Position] == (ucchar)'@')
readAtRule();
else
readRule();
}
result.insert(result.end(), _Rules.begin(), _Rules.end());
_Rules.clear();
}
// ***************************************************************************
// Parse selector with style string
// selector: "a#id .class"
// style: "color: red; font-size: 10px;"
//
// @internal
void CCssParser::parseRule(const ucstring &selectorString, const ucstring &styleString)
{
std::vector<ucstring> selectors;
NLMISC::explode(selectorString, ucstring(","), selectors);
TStyle props;
props = parseDecls(styleString.toUtf8());
// duplicate props to each selector in selector list,
// example 'div > p, h1' creates 'div>p' and 'h1'
for(uint i=0; i<selectors.size(); ++i)
{
CCssStyle::SStyleRule rule;
rule.Selector = parse_selector(trim(selectors[i]), rule.PseudoElement);
rule.Properties = props;
if (!rule.Selector.empty())
{
_Rules.push_back(rule);
}
}
}
// ***************************************************************************
// Skip over at-rule
// @import ... ;
// @charset ... ;
// @media query { .. }
//
// @internal
void CCssParser::readAtRule()
{
// skip '@'
_Position++;
// skip 'import', 'media', etc
skipIdentifier();
// skip at-rule statement
while(!is_eof() && _Style[_Position] != (ucchar)';')
{
if (maybe_escape())
{
escape();
}
else if (is_quote(_Style[_Position]))
{
skipString();
}
else if (is_block_open(_Style[_Position]))
{
bool mustBreak = (_Style[_Position] == '{');
skipBlock();
if(mustBreak)
{
break;
}
}
else
{
_Position++;
}
}
// skip ';' or '}'
_Position++;
}
// ***************************************************************************
// skip over "elm#id.selector[attr]:peseudo, .sel2 { rule }" block
// @internal
void CCssParser::readRule()
{
size_t start;
// selector
start = _Position;
while(!is_eof())
{
if (maybe_escape())
_Position++;
else if (is_quote(_Style[_Position]))
skipString();
else if (_Style[_Position] == (ucchar)'[')
skipBlock();
else if (_Style[_Position] == (ucchar)'{')
break;
else
_Position++;
}
if (!is_eof())
{
ucstring selector;
selector.append(_Style, start, _Position - start);
skipWhitespace();
// declaration block
start = _Position;
skipBlock();
if (_Position <= _Style.size())
{
ucstring rules;
rules.append(_Style, start + 1, _Position - start - 2);
parseRule(selector, rules);
}
}
}
// ***************************************************************************
// skip over \abcdef escaped sequence or escaped newline char
// @internal
void CCssParser::escape()
{
// skip '\'
_Position++;
if (is_hex(_Style[_Position]))
{
// TODO: '\abc def' should be considered one string
for(uint i=0; i<6 && is_hex(_Style[_Position]); i++)
_Position++;
if (_Style[_Position] == (ucchar)' ')
_Position++;
}
else if (_Style[_Position] != 0x0A)
_Position++;
}
// ***************************************************************************
// @internal
bool CCssParser::skipIdentifier()
{
size_t start = _Position;
bool valid = true;
while(!is_eof() && valid)
{
if (maybe_escape())
{
escape();
continue;
}
else if (is_alpha(_Style[_Position]))
{
// valid
}
else if (is_digit(_Style[_Position]))
{
if (_Position == start)
{
// cannot start with digit
valid = false;
}
else if ((_Position - start) == 0 && _Style[_Position-1] == (ucchar)'-')
{
// cannot start with -#
valid = false;
}
}
else if (_Style[_Position] == (ucchar)'_')
{
// valid
}
else if (_Style[_Position] >= 0x0080)
{
// valid
}
else if (_Style[_Position] == (ucchar)'-')
{
if ((_Position - start) == 1 && _Style[_Position-1] == (ucchar)'-')
{
// cannot start with --
valid = false;
}
}
else
{
// we're done
break;
}
_Position++;
}
return valid && !is_eof();
}
// ***************************************************************************
// skip over (..), [..], or {..} blocks
// @internal
void CCssParser::skipBlock()
{
ucchar startChar = _Style[_Position];
// block start
_Position++;
while(!is_eof() && !is_block_close(_Style[_Position], startChar))
{
if (maybe_escape())
// skip backslash and next char
_Position += 2;
else if (is_quote(_Style[_Position]))
skipString();
else if (is_block_open(_Style[_Position]))
skipBlock();
else
_Position++;
}
// block end
_Position++;
}
// ***************************************************************************
// skip over quoted string
// @internal
void CCssParser::skipString()
{
ucchar endChar = _Style[_Position];
// quote start
_Position++;
while(!is_eof() && _Style[_Position] != endChar)
{
if (maybe_escape())
_Position++;
_Position++;
}
// quote end
_Position++;
}
// ***************************************************************************
// @internal
void CCssParser::skipWhitespace()
{
while(!is_eof() && is_whitespace(_Style[_Position]))
_Position++;
}
// ***************************************************************************
// parse selector list
// @internal
std::vector<CCssSelector> CCssParser::parse_selector(const ucstring &sel, std::string &pseudoElement) const
{
std::vector<CCssSelector> result;
CCssSelector current;
pseudoElement.clear();
bool failed = false;
ucstring::size_type start = 0, pos = 0;
while(pos < sel.size())
{
ucstring uc;
uc = sel[pos];
if (is_nmchar(sel[pos]) && current.empty())
{
pos++;
while(pos < sel.size() && is_nmchar(sel[pos]))
pos++;
current.Element = toLower(sel.substr(start, pos - start).toUtf8());
start = pos;
continue;
}
if(sel[pos] == '#')
{
pos++;
start=pos;
while(pos < sel.size() && is_nmchar(sel[pos]))
pos++;
current.Id = toLower(sel.substr(start, pos - start).toUtf8());
start = pos;
}
else if (sel[pos] == '.')
{
pos++;
start=pos;
// .classA.classB
while(pos < sel.size() && (is_nmchar(sel[pos]) || sel[pos] == '.'))
pos++;
current.setClass(toLower(sel.substr(start, pos - start).toUtf8()));
start = pos;
}
else if (sel[pos] == '[')
{
pos++;
start = pos;
if (is_whitespace(sel[pos]))
{
while(pos < sel.size() && is_whitespace(sel[pos]))
pos++;
start = pos;
}
ucstring key;
ucstring value;
ucchar op = ' ';
// key
while(pos < sel.size() && is_nmchar(sel[pos]))
pos++;
key = sel.substr(start, pos - start);
if (pos == sel.size()) break;
if (is_whitespace(sel[pos]))
{
while(pos < sel.size() && is_whitespace(sel[pos]))
pos++;
if (pos == sel.size()) break;
}
if (sel[pos] == ']')
{
current.addAttribute(key.toUtf8());
}
else
{
// operand
op = sel[pos];
if (op == '~' || op == '|' || op == '^' || op == '$' || op == '*')
{
pos++;
if (pos == sel.size()) break;
}
// invalid rule?, eg [attr^value]
if (sel[pos] != '=')
{
while(pos < sel.size() && sel[pos] != ']')
pos++;
if (pos == sel.size()) break;
start = pos;
}
else
{
// skip '='
pos++;
if (is_whitespace(sel[pos]))
{
while(pos < sel.size() && is_whitespace(sel[pos]))
pos++;
if (pos == sel.size()) break;
}
// value
start = pos;
bool quote = false;
char quoteOpen;
while(pos < sel.size())
{
if (sel[pos] == '\'' || sel[pos] == '"')
{
// value is quoted
start = pos;
pos++;
while(pos < sel.size() && sel[pos] != sel[start])
{
if (sel[pos] == '\\')
{
pos++;
}
pos++;
}
if (pos == sel.size()) break;
value = sel.substr(start + 1, pos - start - 1);
break;
}
else if (sel[pos] == '\\')
{
pos++;
}
else if (!quote && sel[pos] == ']')
{
// unquoted value
value = sel.substr(start, pos - start);
break;
}
pos++;
} // while 'value'
// TODO: scan for sel[pos] == ']'
if (pos == sel.size()) break;
// whitespace between quote and ], ie '[ attr $= "val" ]'
if (sel[pos] != ']')
{
while(pos < sel.size() && sel[pos] != ']')
pos++;
}
if (pos == sel.size()) break;
current.addAttribute(key.toUtf8(), value.toUtf8(), (char)op);
} // op error
} // no value
// skip ']'
pos++;
start = pos;
}
else if (sel[pos] == ':')
{
pos++;
start=pos;
// pseudo element, eg '::before'
if (pos < sel.size() && sel[pos] == ':')
{
pos++;
}
// :first-child
// :nth-child(2n+0)
// :not(h1, div#main)
// :not(:nth-child(2n+0))
// has no support for quotes, eg :not(h1[attr=")"]) fails
while(pos < sel.size() && (is_nmchar(sel[pos]) || sel[pos] == '('))
{
if (sel[pos] == '(')
{
uint open = 1;
pos++;
while(pos < sel.size() && open > 0)
{
if (sel[pos] == ')')
open--;
else if (sel[pos] == '(')
open++;
pos++;
}
break;
}
else
{
pos++;
}
}
std::string key = toLower(sel.substr(start, pos - start).toUtf8());
if (key.empty())
{
failed = true;
break;
}
if (key[0] == ':' || key == "after" || key == "before" || key == "cue" || key == "first-letter" || key == "first-line")
{
if (!pseudoElement.empty())
{
failed = true;
break;
}
if (key[0] != ':')
{
pseudoElement = ":" + key;
}
else
{
pseudoElement = key;
}
}
else
{
current.addPseudoClass(key);
}
start = pos;
}
else if (!current.empty())
{
// pseudo element like ':before' can only be set on the last selector
// user action pseudo classes can be used after pseudo element (ie, :focus, :hover)
// there is no support for those and its safe to just fail the selector
if (!result.empty() && !pseudoElement.empty())
{
failed = true;
break;
}
// start new selector as combinator is part of next selector
result.push_back(current);
current = CCssSelector();
// detect and remove whitespace around combinator, eg ' > '
bool isSpace = is_whitespace(sel[pos]);;
while(pos < sel.size() && is_whitespace(sel[pos]))
pos++;
if (sel[pos] == '>' || sel[pos] == '+' || sel[pos] == '~')
{
current.Combinator = sel[pos];
pos++;
while(pos < sel.size() && is_whitespace(sel[pos]))
pos++;
}
else if (isSpace)
{
current.Combinator = ' ';
}
else
{
// unknown
current.Combinator = sel[pos];
pos++;
}
start = pos;
}
else
{
pos++;
}
}
if (failed)
{
result.clear();
}
else if (result.empty() || !current.empty())
{
// pseudo element like ':before' can only be set on the last selector
if (!result.empty() && !pseudoElement.empty())
{
// failed
result.clear();
}
else
{
result.push_back(current);
}
}
return result;
}
// ***************************************************************************
// @internal
void CCssParser::preprocess()
{
_Position = 0;
size_t start;
size_t charsLeft;
bool quote = false;
ucchar quoteChar;
while(!is_eof())
{
charsLeft = _Style.size() - _Position - 1;
// FF, CR
if (_Style[_Position] == 0x0C || _Style[_Position] == 0x0D)
{
uint len = 1;
// CR, LF
if (charsLeft >= 1 && _Style[_Position] == 0x0D && _Style[_Position+1] == 0x0A)
len++;
ucstring tmp;
tmp += 0x000A;
_Style.replace(_Position, 1, tmp);
}
else if (_Style[_Position] == 0x00)
{
// Unicode replacement character
_Style[_Position] = 0xFFFD;
}
else
{
// strip comments for easier parsing
if (_Style[_Position] == '\\')
{
_Position++;
}
else if (is_quote(_Style[_Position]))
{
if (!quote)
quoteChar = _Style[_Position];
if (quote && _Style[_Position] == quoteChar)
quote = !quote;
}
else if (!quote && is_comment_open())
{
size_t pos = _Style.find(ucstring("*/"), _Position + 2);
if (pos == std::string::npos)
pos = _Style.size();
_Style.erase(_Position, pos - _Position + 2);
ucstring uc;
uc = _Style[_Position];
// _Position is already at correct place
continue;
}
}
_Position++;
}
}
} // namespace

View file

@ -0,0 +1,314 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include <string>
#include "nel/misc/types_nl.h"
#include "nel/gui/css_selector.h"
#include "nel/gui/html_element.h"
using namespace NLMISC;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLGUI
{
CCssSelector::CCssSelector(std::string elm, std::string id, std::string cls, char comb)
: Element(elm), Id(id), Class(), Attr(), PseudoClass(), Combinator(comb)
{
if (!cls.empty())
{
setClass(cls);
}
}
uint32 CCssSelector::specificity() const
{
uint ret = 0;
if (!Element.empty() && Element != "*") ret += 0x000001;
// Pseudo Element is added in CCssStyle
//if (!PseudoElement.empty()) ret += 0x000001;
if (!Class.empty()) ret += 0x000100 * Class.size();
if (!Attr.empty()) ret += 0x000100 * Attr.size();
// TODO: has different cases
if (!PseudoClass.empty()) ret += 0x000100 * PseudoClass.size();
if (!Id.empty()) ret += 0x010000;
return ret;
}
void CCssSelector::setClass(const std::string &cls)
{
std::vector<std::string> parts;
NLMISC::splitString(toLower(cls), ".", parts);
for(uint i = 0; i< parts.size(); i++)
{
std::string cname = trim(parts[i]);
if (!cname.empty())
{
Class.push_back(cname);
}
}
}
void CCssSelector::addAttribute(const std::string &key, const std::string &val, char op)
{
Attr.push_back(SAttribute(key, val, op));
}
void CCssSelector::addPseudoClass(const std::string &key)
{
if (key.empty()) return;
PseudoClass.push_back(key);
}
bool CCssSelector::match(const CHtmlElement &elm) const
{
if (!Element.empty() && Element != "*" && Element != elm.Value)
{
return false;
}
if (!Id.empty() && Id != elm.getAttribute("id"))
{
return false;
}
if (!Class.empty() && !matchClass(elm))
{
return false;
}
if (!Attr.empty() && !matchAttributes(elm))
{
return false;
}
if (!PseudoClass.empty() && !matchPseudoClass(elm))
{
return false;
}
return true;
}
bool CCssSelector::matchClass(const CHtmlElement &elm) const
{
// make sure all class names we have, other has as well
for(uint i = 0; i< Class.size(); ++i)
{
if (!elm.hasClass(Class[i]))
{
return false;
}
}
return true;
}
bool CCssSelector::matchAttributes(const CHtmlElement &elm) const
{
// TODO: refactor into matchAttributeSelector
for(uint i = 0; i< Attr.size(); ++i)
{
if (!elm.hasAttribute(Attr[i].key)) return false;
std::string value = elm.getAttribute(Attr[i].key);
switch(Attr[i].op)
{
case '=':
if (Attr[i].value != value) return false;
break;
case '~':
{
// exact match to any of whitespace separated words from element attribute
if (Attr[i].value.empty()) return false;
std::vector<std::string> parts;
NLMISC::splitString(value, " ", parts);
bool found = false;
for(uint j = 0; j < parts.size(); j++)
{
if (Attr[i].value == parts[j])
{
found = true;
break;
}
}
if (!found) return false;
}
break;
case '|':
// exact value, or start with val+'-'
if (value != Attr[i].value && value.find(Attr[i].value + "-") == std::string::npos) return false;
break;
case '^':
// prefix, starts with
if (Attr[i].value.empty()) return false;
if (value.find(Attr[i].value) != 0) return false;
break;
case '$':
// suffic, ends with
if (Attr[i].value.empty() || value.size() < Attr[i].value.size()) return false;
if (Attr[i].value == value.substr(value.size() - Attr[i].value.size())) return false;
break;
case '*':
if (Attr[i].value.empty()) return false;
if (value.find(Attr[i].value) == std::string::npos) return false;
break;
case ' ':
// contains key, ignore value
break;
default:
// unknown comparison
return false;
}
}
return true;
}
bool CCssSelector::matchPseudoClass(const CHtmlElement &elm) const
{
for(uint i = 0; i< PseudoClass.size(); i++)
{
if (PseudoClass[i] == "root")
{
// ':root' is just 'html' with higher specificity
if (elm.Value != "html") return false;
}
else if (PseudoClass[i] == "only-child")
{
if (elm.parent && !elm.parent->Children.empty()) return false;
}
else
{
if (PseudoClass[i] == "first-child")
{
if (elm.previousSibling) return false;
}
else if (PseudoClass[i] == "last-child")
{
if (elm.nextSibling) return false;
}
else if (PseudoClass[i].find("nth-child(") != std::string::npos)
{
sint a, b;
// TODO: there might be multiple :nth-child() on single selector, so current can't cache it
parseNth(PseudoClass[i], a, b);
// 1st child should be '1' and not '0'
if (!matchNth(elm.childIndex+1, a, b)) return false;
}
else
{
return false;
}
}
}
return true;
}
void CCssSelector::parseNth(const std::string &pseudo, sint &a, sint &b) const
{
a = 0;
b = 0;
std::string::size_type start = pseudo.find_first_of("(") + 1;
std::string::size_type end = pseudo.find_first_of(")");
if (start == std::string::npos) return;
std::string expr = toLower(pseudo.substr(start, end - start));
if (expr.empty()) return;
if (expr == "even")
{
// 2n+0
a = 2;
b = 0;
}
else if (expr == "odd")
{
// 2n+1
a = 2;
b = 1;
}
else
{
// -An+B, An+B, An-B
std::string::size_type pos;
start = 0;
pos = expr.find_first_of("n", start);
if (pos == std::string::npos)
{
fromString(expr, b);
}
else if (pos == 0)
{
// 'n' == '1n'
a = 1;
}
else if (expr[0] == '-' && pos == 1)
{
// '-n' == '-1n'
a = -1;
}
else
{
fromString(expr.substr(start, pos - start), a);
}
start = pos;
pos = expr.find_first_of("+-", start);
if (pos != std::string::npos && (expr[pos] == '+' || expr[pos] == '-'))
{
// copy with sign char
fromString(expr.substr(pos, end - pos), b);
}
}
}
bool CCssSelector::matchNth(sint childNr, sint a, sint b) const
{
if (a == 0)
{
return childNr == b;
}
else if (a > 0)
{
return childNr >= b && (childNr - b) % a == 0;
}
else
{
// a is negative from '-An+B'
return childNr <= b && (b - childNr) % (-a) == 0;
}
}
} // namespace

File diff suppressed because it is too large Load diff

View file

@ -68,6 +68,7 @@ namespace NLGUI
_StepValue = 0;
_TileM = false;
_Frozen = false;
_Scale = false;
}
// ------------------------------------------------------------------------------------------------
@ -108,6 +109,11 @@ namespace NLGUI
return getTextureTopOrRight();
}
else
if( name == "scale" )
{
return toString( _Scale );
}
else
if( name == "vertical" )
{
return toString( _Vertical );
@ -244,6 +250,14 @@ namespace NLGUI
return;
}
else
if( name =="scale" )
{
bool b;
if (fromString( value, b ) )
_Scale = b;
return;
}
else
if( name == "vertical" )
{
bool b;
@ -408,6 +422,7 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "tx_bottomleft", BAD_CAST getTextureBottomOrLeft().c_str() );
xmlSetProp( node, BAD_CAST "tx_middle", BAD_CAST getTextureMiddle().c_str() );
xmlSetProp( node, BAD_CAST "tx_topright", BAD_CAST getTextureTopOrRight().c_str() );
xmlSetProp( node, BAD_CAST "scale", BAD_CAST toString( _Scale ).c_str() );
xmlSetProp( node, BAD_CAST "vertical", BAD_CAST toString( _Vertical ).c_str() );
std::string align;
@ -480,6 +495,10 @@ namespace NLGUI
if(prop) setTextureTopOrRight(string((const char*)prop));
else setTextureTopOrRight ("w_scroll_l0_t.tga");
// Override texture size (w for vertical, h for horizontal)
prop = (char*) xmlGetProp( node, (xmlChar*)"scale" );
if (prop) _Scale = convertBool((const char*)prop);
// Read properties
prop = (char*) xmlGetProp( node, (xmlChar*)"vertical" );
if (prop) _Vertical = convertBool((const char*)prop);
@ -606,13 +625,13 @@ namespace NLGUI
if (_Vertical)
{
_W = w;
if (!_Scale) _W = w;
_H = _Target->getMaxHReal();
}
else
{
_W = _Target->getMaxWReal();
_H = h;
if (!_Scale) _H = h;
}
CCtrlBase::updateCoords ();
@ -885,7 +904,7 @@ namespace NLGUI
}
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel && _Vertical)
{
moveTrackY (eventDesc.getWheel() * 12);
moveTargetY (-(eventDesc.getWheel() * 12));
return true;
}
}
@ -1226,6 +1245,12 @@ namespace NLGUI
if(hReal <= maxHReal)
return;
if (_TargetStepY > 1)
{
sint sign = (0 < dy) - (dy < 0);
dy = sign * max(1, (dy / _TargetStepY)) * _TargetStepY;
}
// compute the new ofsY.
sint32 ofsY= _Target->getOfsY();
ofsY+= dy;

View file

@ -46,6 +46,7 @@ namespace NLGUI
_BmpLeftW= _BmpMiddleW= _BmpRightW= _BmpH= 0;
_WMargin= 0;
_WMin= 0;
_HMin= 0;
_TextX= 0;
_TextY= 0;
_Setuped= false;
@ -124,6 +125,11 @@ namespace NLGUI
return toString( _WMin );
}
else
if( name == "hmin" )
{
return toString( _HMin );
}
else
if( name == "hardtext" )
{
if( _ViewText != NULL )
@ -296,6 +302,14 @@ namespace NLGUI
return;
}
else
if( name == "hmin" )
{
sint32 i;
if( fromString( value, i ) )
_HMin = i;
return;
}
else
if( name == "hardtext" )
{
if( _ViewText != NULL )
@ -469,6 +483,7 @@ namespace NLGUI
xmlNewProp( node, BAD_CAST "wmargin", BAD_CAST toString( _WMargin ).c_str() );
xmlNewProp( node, BAD_CAST "wmin", BAD_CAST toString( _WMin ).c_str() );
xmlNewProp( node, BAD_CAST "hmin", BAD_CAST toString( _HMin ).c_str() );
xmlNewProp( node, BAD_CAST "hardtext", BAD_CAST _ViewText->getText().toString().c_str() );
xmlNewProp( node, BAD_CAST "text_y", BAD_CAST toString( _TextY ).c_str() );
xmlNewProp( node, BAD_CAST "text_x", BAD_CAST toString( _TextX ).c_str() );
@ -519,7 +534,6 @@ namespace NLGUI
return false;
}
// *** Read Textures.
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" );
if (prop)
@ -604,6 +618,15 @@ namespace NLGUI
// _WMin is at least the size of All W Bitmaps
_WMin= max(_WMin, _BmpLeftW + _BmpMiddleW + _BmpRightW);
// hmin
_HMin= 0;
prop = (char*) xmlGetProp( cur, (xmlChar*)"hmin" );
if (prop)
{
fromString((const char *) prop, _HMin);
}
_HMin= max(_HMin, _BmpH);
// TextY
_TextY= 0;
prop = (char*) xmlGetProp( cur, (xmlChar*)"text_y" );
@ -705,6 +728,43 @@ namespace NLGUI
return true;
}
// ***************************************************************************
void CCtrlTextButton::setTexture(const std::string &l, const std::string &m, const std::string &r, bool updateHeight)
{
nlctassert(NumTexture==3);
_TextureIdNormal[0].setTexture(l.c_str());
_TextureIdNormal[1].setTexture(m.c_str());
_TextureIdNormal[2].setTexture(r.c_str());
sint32 newH;
// Compute Bmp Sizes
CViewRenderer &rVR = *CViewRenderer::getInstance();
rVR.getTextureSizeFromId(_TextureIdNormal[0], _BmpLeftW, newH);
rVR.getTextureSizeFromId(_TextureIdNormal[1], _BmpMiddleW, newH);
rVR.getTextureSizeFromId(_TextureIdNormal[2], _BmpRightW, newH);
if (updateHeight) _BmpH = newH;
}
// ***************************************************************************
void CCtrlTextButton::setTexturePushed(const std::string &l, const std::string &m, const std::string &r)
{
nlctassert(NumTexture==3);
_TextureIdPushed[0].setTexture(l.c_str());
_TextureIdPushed[1].setTexture(m.c_str());
_TextureIdPushed[2].setTexture(r.c_str());
}
// ***************************************************************************
void CCtrlTextButton::setTextureOver(const std::string &l, const std::string &m, const std::string &r)
{
nlctassert(NumTexture==3);
_TextureIdOver[0].setTexture(l.c_str());
_TextureIdOver[1].setTexture(m.c_str());
_TextureIdOver[2].setTexture(r.c_str());
}
// ***************************************************************************
void CCtrlTextButton::draw ()
{
@ -899,7 +959,8 @@ namespace NLGUI
}
if (!(_SizeRef & 2))
{
_H= _BmpH;
_H= max(_BmpH, _ViewText->getH());
_H= max(_H, _HMin);
}
CViewBase::updateCoords();

View file

@ -21,12 +21,18 @@
#include <openssl/x509.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#if defined(NL_OS_WINDOWS)
#pragma comment(lib, "crypt32.lib")
#pragma comment(lib, "cryptui.lib")
#include <curl/curl.h>
// for compatibility with older versions
#ifndef CURL_AT_LEAST_VERSION
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z)
#define CURL_AT_LEAST_VERSION(x,y,z) \
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
#endif
using namespace std;
using namespace NLMISC;
@ -36,36 +42,143 @@ using namespace NLMISC;
namespace NLGUI
{
#if defined(NL_OS_WINDOWS)
static std::vector<X509 *> x509CertList;
//
// x509CertList lifetime manager
//
class SX509Certificates {
class SX509Certificates
{
public:
SX509Certificates()
struct CertEntry
{
curl_version_info_data *data;
data = curl_version_info(CURLVERSION_NOW);
if (!(data && data->features & CURL_VERSION_SSPI))
X509 *cert;
std::string name;
std::string file;
bool operator == (const std::string &str)
{
addCertificatesFrom("CA");
addCertificatesFrom("AuthRoot");
addCertificatesFrom("ROOT");
return file == str;
}
};
std::vector<CertEntry> CertList;
bool isUsingOpenSSLBackend;
bool isInitialized;
SX509Certificates():isUsingOpenSSLBackend(false), isInitialized(false)
{
init();
}
~SX509Certificates()
{
for (uint i = 0; i < x509CertList.size(); ++i)
for (uint i = 0; i < CertList.size(); ++i)
{
X509_free(x509CertList[i]);
X509_free(CertList[i].cert);
}
x509CertList.clear();
CertList.clear();
}
void init()
{
// init CURL
CURL *curl = curl_easy_init();
if (!curl) return;
// get information on CURL
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
bool useOpenSSLBackend = false;
#if CURL_AT_LEAST_VERSION(7, 34, 0)
// get more information on CURL session
curl_tlssessioninfo *sessionInfo;
CURLINFO info;
#if CURL_AT_LEAST_VERSION(7, 48, 0)
info = CURLINFO_TLS_SSL_PTR;
#else
info = CURLINFO_TLS_SESSION;
#endif
CURLcode res = curl_easy_getinfo(curl, info, &sessionInfo);
// CURL using OpenSSL backend
if ((res == CURLE_OK) && sessionInfo && sessionInfo->backend == CURLSSLBACKEND_OPENSSL) useOpenSSLBackend = true;
#elif CURL_AT_LEAST_VERSION(7, 12, 3)
// get a list of OpenSSL engines
struct curl_slist *engines;
CURLcode res = curl_easy_getinfo(curl, CURLINFO_SSL_ENGINES, &engines);
// CURL using OpenSSL backend
// With OpenSSL compiled without any engine, engines will too return NULL
// Fortunately, if OpenSSL isn't compiled with engines means we compiled it ourself and CURL is a recent version
if ((res == CURLE_OK) && engines)
{
// free engines
curl_slist_free_all(engines);
useOpenSSLBackend = true;
}
#else
// TODO: implement an equivalent, but CURL 7.12 was released in 2004
#endif
// only use OpenSSL callback if not using Windows SSPI and using OpenSSL backend
if (useOpenSSLBackend && !(data && data->features & CURL_VERSION_SSPI))
{
#ifdef NL_OS_WINDOWS
// load native Windows CA Certs
addCertificatesFrom("CA");
addCertificatesFrom("AuthRoot");
addCertificatesFrom("ROOT");
#endif
isUsingOpenSSLBackend = true;
}
else
{
// if CURL is using SSPI or SChannel under Windows or DarwinSSL under OS X, we'll use native system CA Certs
isUsingOpenSSLBackend = false;
}
// clean up CURL
curl_easy_cleanup(curl);
isInitialized = true;
}
static std::string getCertName(X509 *cert)
{
// NULL certificate
if (!cert) return "";
X509_NAME *subject = X509_get_subject_name(cert);
std::string name;
unsigned char *tmp = NULL;
// construct a multiline string with name
for (int j = 0, jlen = X509_NAME_entry_count(subject); j < jlen; ++j)
{
X509_NAME_ENTRY *e = X509_NAME_get_entry(subject, j);
ASN1_STRING *d = X509_NAME_ENTRY_get_data(e);
if (ASN1_STRING_to_UTF8(&tmp, d) > 0)
{
name += NLMISC::toString("%s\n", tmp);
OPENSSL_free(tmp);
}
}
return name;
}
#ifdef NL_OS_WINDOWS
void addCertificatesFrom(LPCSTR root)
{
HCERTSTORE hStore;
@ -78,36 +191,154 @@ namespace NLGUI
{
x509 = NULL;
x509 = d2i_X509(NULL, (const unsigned char **)&pContext->pbCertEncoded, pContext->cbCertEncoded);
if (x509)
{
x509CertList.push_back(x509);
CertEntry entry;
entry.cert = x509;
entry.file = root;
entry.name = getCertName(x509);
CertList.push_back(entry);
}
}
CertFreeCertificateContext(pContext);
CertCloseStore(hStore, 0);
}
// this is called before debug context is set and log ends up in log.log
//nlinfo("Loaded %d certificates from '%s' certificate store", List.size(), root);
//nlinfo("Loaded %d certificates from '%s' certificate store", (int)CertList.size(), root);
}
#endif
void addCertificatesFromFile(const std::string &cert)
{
if (!isInitialized)
{
nlwarning("CURL not initialized! Check if there are another errors");
return;
}
if (!isUsingOpenSSLBackend)
{
nlinfo("CURL not using OpenSSL backend! Unable to use custom certificates");
return;
}
else
{
nlinfo("CURL using OpenSSL backend!");
}
// this file was already loaded
if (std::find(CertList.begin(), CertList.end(), cert) != CertList.end()) return;
// look for certificate in search paths
string path = CPath::lookup(cert, false);
if (path.empty())
{
nlwarning("Unable to find %s", cert.c_str());
return;
}
nlinfo("CURL CA bundle '%s'", path.c_str());
CIFile file;
// open certificate
if (!file.open(path))
{
nlwarning("Unable to open %s", path.c_str());
return;
}
// load certificate content into memory
std::vector<uint8> buffer(file.getFileSize());
file.serialBuffer(&buffer[0], file.getFileSize());
// get a BIO
BIO *bio = BIO_new_mem_buf(&buffer[0], file.getFileSize());
if (bio)
{
// use it to read the PEM formatted certificate from memory into an X509
// structure that SSL can use
STACK_OF(X509_INFO) *info = PEM_X509_INFO_read_bio(bio, NULL, NULL, NULL);
if (info)
{
// iterate over all entries from the PEM file, add them to the x509_store one by one
for (sint i = 0; i < sk_X509_INFO_num(info); ++i)
{
X509_INFO *itmp = sk_X509_INFO_value(info, i);
if (itmp && itmp->x509)
{
CertEntry entry;
entry.cert = X509_dup(itmp->x509);
entry.file = cert;
entry.name = getCertName(entry.cert);
CertList.push_back(entry);
}
}
// cleanup
sk_X509_INFO_pop_free(info, X509_INFO_free);
}
else
{
nlwarning("Unable to read PEM info");
}
// decrease reference counts
BIO_free(bio);
}
else
{
nlwarning("Unable to allocate BIO buffer for certificates");
}
}
};
/// this will be initialized on startup and cleared on exit
static SX509Certificates x509CertListManager;
// ***************************************************************************
// static
CURLcode CCurlCertificates::sslCtxFunction(CURL *curl, void *sslctx, void *parm)
// cURL SSL certificate loading
static CURLcode sslCtxFunction(CURL *curl, void *sslctx, void *parm)
{
if (x509CertList.size() > 0)
CURLcode res = CURLE_OK;
if (x509CertListManager.CertList.size() > 0)
{
SSL_CTX *ctx = (SSL_CTX*)sslctx;
X509_STORE *x509store = SSL_CTX_get_cert_store(ctx);
if (x509store)
{
for (uint i = 0; i < x509CertList.size(); ++i)
char errorBuffer[1024];
for (uint i = 0, ilen = x509CertListManager.CertList.size(); i < ilen; ++i)
{
X509_STORE_add_cert(x509store, x509CertList[i]);
SX509Certificates::CertEntry entry = x509CertListManager.CertList[i];
// add our certificate to this store
if (X509_STORE_add_cert(x509store, entry.cert) == 0)
{
uint errCode = ERR_get_error();
// ignore already in hash table errors
if (ERR_GET_LIB(errCode) != ERR_LIB_X509 || ERR_GET_REASON(errCode) != X509_R_CERT_ALREADY_IN_HASH_TABLE)
{
ERR_error_string_n(errCode, errorBuffer, 1024);
nlwarning("Error adding certificate %s: %s", entry.name.c_str(), errorBuffer);
res = CURLE_SSL_CACERT;
}
}
else
{
nldebug("Added certificate %s", entry.name.c_str());
}
}
}
else
@ -115,9 +346,40 @@ namespace NLGUI
nlwarning("SSL_CTX_get_cert_store returned NULL");
}
}
return CURLE_OK;
else
{
res = CURLE_SSL_CACERT;
}
return res;
}
// ***************************************************************************
// static
void CCurlCertificates::addCertificateFile(const std::string &cert)
{
x509CertListManager.addCertificatesFromFile(cert);
}
// ***************************************************************************
// static
void CCurlCertificates::useCertificates(CURL *curl)
{
// CURL must be valid, using OpenSSL backend and certificates must be loaded, else return
if (!curl || !x509CertListManager.isInitialized || !x509CertListManager.isUsingOpenSSLBackend || x509CertListManager.CertList.empty()) return;
curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
// would allow to provide the CA in memory instead of using CURLOPT_CAINFO, but needs to include and link OpenSSL
if (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, &sslCtxFunction) != CURLE_OK)
{
nlwarning("Unable to support CURLOPT_SSL_CTX_FUNCTION, curl not compiled with OpenSSL ?");
}
// set both CURLOPT_CAINFO and CURLOPT_CAPATH to NULL to be sure we won't use default values (these files can be missing and generate errors)
curl_easy_setopt(curl, CURLOPT_CAINFO, NULL);
curl_easy_setopt(curl, CURLOPT_CAPATH, NULL);
}
#endif // NL_OS_WINDOWS
}// namespace

View file

@ -473,6 +473,12 @@ namespace NLGUI
return _ViewText->getText();
}
// ***************************************************************************
CViewText *CDBGroupComboBox::getViewText()
{
return _ViewText;
}
// ***************************************************************************
std::string CDBGroupComboBox::getSelectionText() const
{
@ -633,6 +639,9 @@ namespace NLGUI
{
nlassert(groupMenu);
if (_ViewText)
groupMenu->setFontSize(_ViewText->getFontSize());
// Setup the menu with combo action.
groupMenu->reset();
for(uint i=0; i<getNumTexts(); i++)

View file

@ -2473,7 +2473,7 @@ namespace NLGUI
if (_LayerSetup == 0)
{
_List->forceSizeW(_W - pLayer->W_M_Open);
_List->forceSizeW(_W - (pLayer->W_M_Open + pLayer->W_R) );
}
else
{
@ -2748,6 +2748,9 @@ namespace NLGUI
if (_Content != NULL)
h += _Content->getHReal();
if (_List != NULL)
h += _List->getHReal();
h -= _ContentYOffset;
}
else

View file

@ -702,9 +702,9 @@ namespace NLGUI
sint32 maxPos= max(_CursorPos, _SelectCursorPos) + (sint32)_Prompt.length();
// get its position on screen
sint cxMinPos, cyMinPos;
sint cxMaxPos, cyMaxPos;
sint height;
float cxMinPos, cyMinPos;
float cxMaxPos, cyMaxPos;
float height;
_ViewText->getCharacterPositionFromIndex(minPos, false, cxMinPos, cyMinPos, height);
_ViewText->getCharacterPositionFromIndex(maxPos, false, cxMaxPos, cyMaxPos, height);
@ -755,8 +755,8 @@ namespace NLGUI
if (_BlinkState) // is the cursor shown ?
{
// get its position on screen
sint cx, cy;
sint height;
float cx, cy;
float height;
_ViewText->getCharacterPositionFromIndex(_CursorPos + (sint)_Prompt.length(), _CursorAtPreviousLineEnd, cx, cy, height);
// display the cursor
// get the texture for the cursor
@ -1005,7 +1005,6 @@ namespace NLGUI
{
case KeyESCAPE:
_CurrentHistoricIndex= -1;
CWidgetManager::getInstance()->setCaptureKeyboard(NULL);
// stop selection
_CurrSelection = NULL;
_CursorAtPreviousLineEnd = false;
@ -1014,6 +1013,7 @@ namespace NLGUI
setInputString(ucstring(""));
triggerOnChangeAH();
}
CWidgetManager::getInstance()->setCaptureKeyboard(NULL);
break;
case KeyTAB:
makeTopWindow();
@ -1482,7 +1482,7 @@ namespace NLGUI
if (_ViewText->getWReal() > _WReal)
{
// Check if cursor visible
sint xCursVT, xCurs, yTmp, hTmp;
float xCursVT, xCurs, yTmp, hTmp;
// Get the cursor pos from the BL of the viewtext
_ViewText->getCharacterPositionFromIndex(_CursorPos+(sint)_Prompt.size(), false, xCursVT, yTmp, hTmp);
// Get the cursor pos from the BL of the edit box

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