option(BUILD_RADIANT "Build the GUI" ON)
option(BUILD_CRUNCH "Build Crunch image support" OFF)
+option(USE_WERROR "Build with -Werror -pedantic-errors" OFF)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install" CACHE PATH "..." FORCE)
addflags("-fvisibility=hidden")
endif ()
-if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+if (USE_WERROR)
addflags("-Werror")
addflags("-pedantic-errors")
endif ()
#-----------------------------------------------------------------------
option(DOWNLOAD_GAMEPACKS "Download game packs" ON)
-add_custom_target(game_packs_free
- COMMAND ${CMAKE_COMMAND} -E make_directory games
- COMMAND DOWNLOAD_GAMEPACKS=yes SOURCE_DIR="${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/install-gamepacks.sh" "${PROJECT_BINARY_DIR}"
- COMMENT "Downloading free game packs"
- )
-add_custom_target(game_packs_all
- COMMAND ${CMAKE_COMMAND} -E make_directory games
- COMMAND DOWNLOAD_GAMEPACKS=all SOURCE_DIR="${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/install-gamepacks.sh" "${PROJECT_BINARY_DIR}"
- COMMENT "Downloading all game packs"
- )
+
+set(GAMEPACKS_LICENSE_LIST free CACHE STRING "Download game packs by license")
+set(GAMEPACKS_NAME_LIST none CACHE STRING "Download game packs by name")
if (DOWNLOAD_GAMEPACKS)
- set(DOWNLOAD_GAMEPACKS "all")
+ add_custom_target(game_packs ALL
+ COMMAND "${PROJECT_SOURCE_DIR}/gamepack-manager" --license ${GAMEPACKS_LICENSE_LIST} --name ${GAMEPACKS_NAME_LIST} --download-dir "${PROJECT_BINARY_DIR}/download" --install-dir "${PROJECT_BINARY_DIR}" --download --install
+ COMMENT "Downloading ${GAMEPACKS_LICENSE_LIST} game packs"
+ )
endif()
-if ("${DOWNLOAD_GAMEPACKS}" STREQUAL "free")
- add_custom_target(game_packs_go ALL DEPENDS game_packs_free)
-elseif ("${DOWNLOAD_GAMEPACKS}" STREQUAL "all")
- add_custom_target(game_packs_go ALL DEPENDS game_packs_all)
-endif ()
#-----------------------------------------------------------------------
# Install
DESTINATION .
)
-set(GAME_FILES
- DarkPlaces
- Nexuiz
- OpenArena
- Osirion
- Q3
- Quake2
- Quake
- Quetoo
- Tremulous
- UFOAI
- Unvanquished
- Warsow
- Xonotic
- )
-unset(_tmp)
-foreach (it ${GAME_FILES})
- set(dir "${PROJECT_BINARY_DIR}/games/${it}Pack")
- string(TOLOWER "${it}" it)
- list(APPEND _tmp "${dir}/games")
- list(APPEND _tmp "${dir}/${it}.game")
-endforeach ()
-set(GAME_FILES ${_tmp})
-
-install(
- DIRECTORY
- ${GAME_FILES}
- DESTINATION .
- OPTIONAL
+install(CODE "execute_process(COMMAND \"${PROJECT_SOURCE_DIR}/gamepack-manager\" --license ${GAMEPACKS_LICENSE_LIST} --name ${GAMEPACKS_NAME_LIST} --download-dir \"${PROJECT_BINARY_DIR}/download\" --install-dir \"${CMAKE_INSTALL_PREFIX}\" --install)"
)
include(cmake/scripts/package.cmake)
# warning: this directory may NOT contain any files other than the ones written by this Makefile!
# NEVER SET THIS TO A SYSTEM WIDE "bin" DIRECTORY!
INSTALLDIR ?= install
+DOWNLOADDIR ?= build/download
CC ?= gcc
CXX ?= g++
CAT ?= cat
MKDIR ?= mkdir -p
CP ?= cp
-CP_R ?= $(CP) -r
+CP_R ?= $(CP) -r --preserve=timestamps
LN ?= ln
LN_SNF ?= $(LN) -snf
RM ?= rm
CPPFLAGS_PNG ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libpng --cflags $(STDERR_TO_DEVNULL))
LIBS_PNG ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libpng --libs-only-L $(STDERR_TO_DEVNULL)) \
$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libpng --libs-only-l $(STDERR_TO_DEVNULL))
+CPPFLAGS_WEBP ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libwebp --cflags $(STDERR_TO_DEVNULL))
+LIBS_WEBP ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libwebp --libs-only-L $(STDERR_TO_DEVNULL)) \
+ $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libwebp --libs-only-l $(STDERR_TO_DEVNULL))
CPPFLAGS_GTK ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtk+-2.0 --cflags $(STDERR_TO_DEVNULL))
LIBS_GTK ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtk+-2.0 --libs-only-L $(STDERR_TO_DEVNULL)) \
$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtk+-2.0 --libs-only-l $(STDERR_TO_DEVNULL))
checkheader libglib2.0-dev glib.h g_path_is_absolute "$(CPPFLAGS_GLIB)" "$(LIBS_GLIB)"; \
checkheader libxml2-dev libxml/xpath.h xmlXPathInit "$(CPPFLAGS_XML)" "$(LIBS_XML)"; \
checkheader libpng12-dev png.h png_create_read_struct "$(CPPFLAGS_PNG)" "$(LIBS_PNG)"; \
+ checkheader libwebp-dev webp/decode.h WebPGetInfo "$(CPPFLAGS_WEBP)" "$(LIBS_WEBP)"; \
checkheader "mesa-common-dev (or another OpenGL library)" GL/gl.h glClear "$(CPPFLAGS_GL)" "$(LIBS_GL)"; \
checkheader libgtk2.0-dev gtk/gtkdialog.h gtk_dialog_run "$(CPPFLAGS_GTK)" "$(LIBS_GTK)"; \
checkheader libpango1.0-dev pango/pangoft2.h pango_ft2_font_map_new "$(CPPFLAGS_PANGOFT2)" "$(LIBS_PANGOFT2)"; \
$(INSTALLDIR)/modules/image.$(DLL) \
$(INSTALLDIR)/modules/imagehl.$(DLL) \
$(INSTALLDIR)/modules/imagepng.$(DLL) \
+ $(INSTALLDIR)/modules/imagewebp.$(DLL) \
$(INSTALLDIR)/modules/imageq2.$(DLL) \
$(INSTALLDIR)/modules/mapq3.$(DLL) \
$(INSTALLDIR)/modules/mapxml.$(DLL) \
.PHONY: clean
clean:
$(RM_R) $(INSTALLDIR_BASE)/
+ $(RM_R) $(DOWNLOADDIR)/
$(FIND) . \( -name \*.o -o -name \*.d -o -name \*.$(DLL) -o -name \*.$(A) -o -name \*.$(EXE) \) -exec $(RM) {} \;
$(RM) icons/*.rc
$(CC) $< $(CFLAGS) $(CFLAGS_COMMON) $(CPPFLAGS_EXTRA) $(CPPFLAGS_COMMON) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@
-$(INSTALLDIR)/q3map2.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB) $(LIBS_PNG) $(LIBS_JPEG) $(LIBS_ZLIB)
-$(INSTALLDIR)/q3map2.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_PNG) $(CPPFLAGS_JPEG) -Itools/quake3/common -Ilibs -Iinclude
+$(INSTALLDIR)/q3map2.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB) $(LIBS_PNG) $(LIBS_JPEG) $(LIBS_WEBP) $(LIBS_ZLIB)
+$(INSTALLDIR)/q3map2.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_PNG) $(CPPFLAGS_JPEG) $(CPPFLAGS_WEBP) -Itools/quake3/common -Ilibs -Iinclude
$(INSTALLDIR)/q3map2.$(EXE): \
tools/quake3/common/cmdlib.o \
tools/quake3/common/imagelib.o \
$(INSTALLDIR)/modules/imagepng.$(DLL): \
plugins/imagepng/plugin.o \
+$(INSTALLDIR)/modules/imagewebp.$(DLL): LIBS_EXTRA := $(LIBS_WEBP)
+$(INSTALLDIR)/modules/imagewebp.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_WEBP) -Ilibs -Iinclude
+$(INSTALLDIR)/modules/imagewebp.$(DLL): \
+ plugins/imagewebp/plugin.o \
+
$(INSTALLDIR)/modules/mapq3.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) -Ilibs -Iinclude
$(INSTALLDIR)/modules/mapq3.$(DLL): \
plugins/mapq3/parse.o \
.PHONY: install-data
install-data: binaries
$(MKDIR) $(INSTALLDIR)/games
- $(FIND) $(INSTALLDIR_BASE)/ -name .svn -exec $(RM_R) {} \; -prune
- DOWNLOAD_GAMEPACKS="$(DOWNLOAD_GAMEPACKS)" GIT="$(GIT)" SVN="$(SVN)" WGET="$(WGET)" RM_R="$(RM_R)" MV="$(MV)" UNZIPPER="$(UNZIPPER)" ECHO="$(ECHO)" SH="$(SH)" CP="$(CP)" CP_R="$(CP_R)" $(SH) install-gamepacks.sh "$(INSTALLDIR)"
+ DOWNLOAD_GAMEPACKS="$(DOWNLOAD_GAMEPACKS)" DOWNLOADDIR="$(DOWNLOADDIR)" INSTALLDIR="$(INSTALLDIR)" GIT="$(GIT)" SVN="$(SVN)" WGET="$(WGET)" RM_R="$(RM_R)" MV="$(MV)" UNZIPPER="$(UNZIPPER)" ECHO="$(ECHO)" SH="$(SH)" CP="$(CP)" CP_R="$(CP_R)" $(SH) gamepack-manager
$(ECHO) $(RADIANT_MAJOR_VERSION) > $(INSTALLDIR)/RADIANT_MAJOR
$(ECHO) $(RADIANT_MINOR_VERSION) > $(INSTALLDIR)/RADIANT_MINOR
$(ECHO) $(RADIANT_PATCH_VERSION) > $(INSTALLDIR)/RADIANT_PATCH
$(CP_R) setup/data/tools/* $(INSTALLDIR)/
$(MKDIR) $(INSTALLDIR)/docs
$(CP_R) docs/* $(INSTALLDIR)/docs/
- $(FIND) $(INSTALLDIR_BASE)/ -name .svn -exec $(RM_R) {} \; -prune
.PHONY: install-dll
ifeq ($(OS),Win32)
NetRadiant
==========
-The open source, cross platform level editor for idtech games (Radiant fork)
+![NetRadiant logo](setup/data/tools/bitmaps/splash.png)
+
+The open source, cross platform level editor for idtech games (Radiant fork).
# Getting the Sources
The git client can be obtained from the Git website:
http://git-scm.org
-To get a copy of the source using the commandline git client:
+To get a copy of the source using the command line git client:
+
```
git clone --recursive https://gitlab.com/xonotic/netradiant.git
cd netradiant
* GtkGLExt
* LibJpeg
* LibPng
+ * LibWebp
* Minizip
* ZLib
### 32 bit:
```
-pacman -S --needed base-devel mingw-w64-i686-{toolchain,cmake,make,gtk2,gtkglext}
+pacman -S --needed base-devel mingw-w64-i686-{toolchain,cmake,make,gtk2,gtkglexti,libwebp}
```
### 64 bit:
```
-pacman -S --needed base-devel mingw-w64-x86_64-{toolchain,cmake,make,gtk2,gtkglext}
+pacman -S --needed base-devel mingw-w64-x86_64-{toolchain,cmake,make,gtk2,gtkglext,libwebp}
```
## OS X:
```
brew install gtkglext
+brew install webp
brew install Caskroom/cask/xquartz
brew link --force gettext
```
# Submodules
- * Crunch
+ * Crunch (optional, disabled by default, only supported with CMake build)
-If you forgot to add `--recursive` option at `git clone` time, fetch it this way:
+If you have not used `--recursive` option at `git clone` time, you can fetch Crunch this way (run it within the NetRadiant repository):
```
## More Compilation Details
options:
- * `DOWNLOAD_GAMEPACKS=ON`
+
+ * `DOWNLOAD_GAMEPACKS=ON`
Automatically download the gamepack data during the first compilation
- * `RADIANT_ABOUTMSG="Custom build"`
+ * `BUILD_CRUNCH=ON`
+ Enable crunch support
+ * `RADIANT_ABOUTMSG="Custom build"`
A message shown in the about dialog
targets:
+
* `radiant` Compiles the radiant core binary
* `modules` Compiles all modules (each module has its own target as well)
* `plugins` Compiles all plugins (each plugin has its own target as well)
## Note about Crunch
-The crnlib used to decode `.crn` files is the one from [Dæmon](http://github.com/DaemonEngine/Daemon) which is just the one by [Unity](https://github.com/Unity-Technologies/crunch/tree/unity) made cross-platform. Since Unity brokes compatibility with [BinomialLLC's legacy tree](https://github.com/BinomialLLC/crunch) it's required to use either crunch from Dæmon or the one from Unity to compress textures that have to be read by radiant or q3map2.
+The crnlib used to decode `.crn` files is the one from [Dæmon](http://github.com/DaemonEngine/Daemon) which is the one by [Unity](https://github.com/Unity-Technologies/crunch/tree/unity) made cross-platform and slightly improved. Since Unity brokes compatibility with [BinomialLLC's legacy tree](https://github.com/BinomialLLC/crunch) it's required to use either the `crunch` tool from Dæmon or the one from Unity to compress textures that have to be read by radiant or q3map2.
--- /dev/null
+# - Find WebP library
+# Find the native WebP headers and libraries.
+#
+# WEBP_INCLUDE_DIRS - where to find webp/decode.h, etc.
+# WEBP_LIBRARIES - List of libraries when using webp.
+# WEBP_FOUND - True if webp is found.
+
+#=============================================================================
+#Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+#All rights reserved.
+#
+#Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#* Redistributions of source code must retain the above copyright notice,
+#this list of conditions and the following disclaimer.
+#
+#* Redistributions in binary form must reproduce the above copyright notice,
+#this list of conditions and the following disclaimer in the documentation
+#and/or other materials provided with the distribution.
+#
+#* Neither the names of Kitware, Inc., the Insight Software Consortium, nor
+#the names of their contributors may be used to endorse or promote products
+#derived from this software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+#ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+#INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+#CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+#ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+#POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+# Look for the header file.
+FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h)
+MARK_AS_ADVANCED(WEBP_INCLUDE_DIR)
+
+# Look for the library.
+FIND_LIBRARY(WEBP_LIBRARY NAMES webp)
+MARK_AS_ADVANCED(WEBP_LIBRARY)
+
+# handle the QUIETLY and REQUIRED arguments and set WEBFOUND_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(WebP DEFAULT_MSG WEBP_LIBRARY WEBP_INCLUDE_DIR)
+
+SET(WEBP_LIBRARIES ${WEBP_LIBRARY})
+SET(WEBP_INCLUDE_DIRS ${WEBP_INCLUDE_DIR})
+
+SET(_WEBP_RQ_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
+
+if(NOT DEFINED _WEBP_COMPILATION_TEST)
+ INCLUDE (CheckCSourceCompiles)
+ SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${WEBP_INCLUDE_DIRS})
+ CHECK_C_SOURCE_COMPILES("#include <webp/decode.h>
+ int main(void) {
+ #if WEBP_DECODER_ABI_VERSION < 0x0200
+ error; // Deliberate compile-time error
+ #endif
+ return 0;
+ }"
+ _WEBP_COMPILATION_TEST)
+ SET(CMAKE_REQUIRED_INCLUDES ${_WEBP_RQ_INCLUDES})
+endif()
+
+if(NOT _WEBP_COMPILATION_TEST)
+ set( USE_INTERNAL_WEBP 1 )
+endif()
+++ /dev/null
-#!/bin/sh
-
-# Usage:
-# sh download-gamepack.sh
-# LICENSEFILTER=GPL,BSD BATCH=1 sh download-gamepack.sh
-
-: ${GIT:=git}
-: ${SVN:=svn}
-: ${WGET:=wget}
-: ${ECHO:=echo}
-: ${MKDIR:=mkdir}
-: ${RM_R:=rm -f -r}
-: ${MV:=mv}
-: ${UNZIPPER:=unzip}
-
-set -e
-
-extra_urls()
-{
- if [ -f "$1/extra-urls.txt" ]; then
- while IFS=" " read -r FILE URL; do
- $WGET -O "$1/$FILE" "$URL"
- done < "$1/extra-urls.txt"
- fi
-}
-
-pack()
-{
- pack=$1; shift
- license=$1; shift
- sourcetype=$1; shift
- source=$1; shift
-
- if [ -d "games/$pack" ]; then
- $ECHO "Updating $pack..."
- case "$sourcetype" in
- svn)
- $SVN update "games/$pack" "$@" || true
- ;;
- zip1)
- $RM_R zipdownload
- $MKDIR zipdownload
- cd zipdownload
- $WGET "$source" "$@" || true
- $UNZIPPER *.zip || true
- cd ..
- $RM_R "games/$pack"
- $MKDIR "games/$pack"
- $MV zipdownload/*/* "games/$pack/" || true
- $RM_R zipdownload
- ;;
- gitdir)
- $RM_R "games/$pack"
- cd games
- $GIT archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf - || true
- cd ..
- ;;
- git)
- cd "games/$pack"
- $GIT pull || true
- cd ../..
- ;;
- esac
- extra_urls "games/$pack"
- return
- fi
-
- $ECHO
- $ECHO "Available pack: $pack"
- $ECHO " License: $license"
- $ECHO " Download via $sourcetype from $source"
- $ECHO
- case " $PACKFILTER " in
- " ")
- ;;
- *" $pack "*)
- ;;
- *)
- $ECHO "Pack $pack rejected because it is not in PACKFILTER."
- return
- ;;
- esac
- case " $LICENSEFILTER " in
- " ")
- ;;
- *)
- if ! echo "$LICENSEFILTER" | tr ',' '\n' | grep -F -q -x "$license"
- then
- $ECHO "Pack $pack rejected because its license is not in LICENSEFILTER."
- return
- fi
- ;;
- esac
- case "$BATCH" in
- '')
- while :; do
- $ECHO "Download this pack? (y/n)"
- read -r P
- case "$P" in
- y*)
- break
- ;;
- n*)
- return
- ;;
- esac
- done
- ;;
- *)
- ;;
- esac
-
- $ECHO "Downloading $pack..."
- case "$sourcetype" in
- svn)
- $SVN checkout "$source" "games/$pack" "$@" || true
- ;;
- zip1)
- $RM_R zipdownload
- $MKDIR zipdownload
- cd zipdownload
- $WGET "$source" "$@" || true
- $UNZIPPER *.zip || true
- cd ..
- $MKDIR "games/$pack"
- $MV zipdownload/*/* "games/$pack/" || true
- $RM_R zipdownload
- ;;
- gitdir)
- cd games
- $GIT archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf - || true
- cd ..
- ;;
- git)
- cd games
- $GIT clone "$source" "$pack" || true
- cd ..
- ;;
- esac
- extra_urls "games/$pack"
- good=false
- for D in "games/$pack"/*.game; do
- if [ -d "$D" ]; then
- good=true
- fi
- done
- $good || rm -rf "$D"
-}
-
-mkdir -p games
-pack DarkPlacesPack GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/DarkPlacesPack/branches/1.5/
-pack Doom3Pack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Doom3Pack/branches/1.5/
-pack ETPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/ETPack/branches/1.5/
-pack Heretic2Pack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Her2Pack/branches/1.5/
-pack JediAcademyPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/JAPack/branches/1.5/
-pack NeverballPack proprietary zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/NeverballPack.zip
-pack NexuizPack GPL gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
-#pack OpenArenaPack unknown zip1 http://ingar.satgnu.net/files/netradiant/gamepacks/OpenArenaPack.zip
-pack OpenArenaPack GPL git https://github.com/NeonKnightOA/oagamepack.git
-pack OsirionPack GPL zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/OsirionPack.zip
-pack PreyPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/PreyPack/trunk/
-pack Q3Pack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q3Pack/trunk/ -r29
-pack Quake2Pack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q2Pack/branches/1.5/
-pack Quake4Pack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q4Pack/branches/1.5/
-#pack QuakePack proprietary zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/QuakePack.zip
-pack QuakePack GPL zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/Quake1Pack.zip
-#pack Quake2WorldPack GPL svn svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
-pack QuetooPack GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/QuetooPack/branches/1.5/
-#pack TremulousPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/TremulousPack/branches/1.5/
-pack TremulousPack proprietary zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/TremulousPack.zip
-pack TurtleArenaPack proprietary git https://github.com/Turtle-Arena/turtle-arena-radiant-pack.git
-pack UFOAIPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/UFOAIPack/branches/1.5/
-#pack UnvanquishedPack unknown zip1 http://ingar.intranifty.net/gtkradiant/files/gamepacks/UnvanquishedPack.zip
-pack UnvanquishedPack BSD svn https://github.com/Unvanquished/unvanquished-mapeditor-support.git/trunk/build/netradiant
-#pack WarsowPack GPL svn https://svn.bountysource.com/wswpack/trunk/netradiant/games/WarsowPack/
-#pack WarsowPack GPL zip1 http://ingar.intranifty.net/files/netradiant/gamepacks/WarsowPack.zip
-pack WarsowPack GPL git https://github.com/Warsow/NetRadiantPack.git
-pack WolfPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/WolfPack/branches/1.5/
-pack XonoticPack GPL git https://gitlab.com/xonotic/netradiant-xonoticpack.git
--- /dev/null
+#! /usr/bin/env bash
+
+# get usage help this way:
+# ./gamepack_manager -h
+
+: "${CP:=cp -v}"
+: "${CP_R:=cp -r --preserve=timestamps}"
+: "${GIT:=git}"
+: "${SVN:=svn}"
+: "${WGET:=wget}"
+: "${ECHO:=echo}"
+: "${MKDIR:=mkdir -v}"
+: "${MKDIR_P:=mkdir -vp}"
+: "${RM_R:=rm -vrf}"
+: "${MV:=mv -v}"
+: "${TAR:=tar}"
+: "${UNZIPPER:=unzip}"
+
+set -e
+
+default_download_dir='build/download'
+default_install_dir='build'
+
+games_dir='games'
+pack_suffix='Pack'
+
+free_license_list='BSD GPL'
+
+printRawDB () {
+cat <<\EOF
+#######################################################
+# #
+# IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT #
+# #
+# Use two whitespaces or more as column separator #
+# #
+#######################################################
+
+#######################################################
+# Obsolete packs #
+#######################################################
+
+# Quake2World was renamed as Quetoo
+# Other gamepacks have better version available
+
+# OpenArena unknown zip http://ingar.intranifty.net/files/netradiant/gamepacks/OpenArenaPack.zip
+# Quake proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/QuakePack.zip
+# Quake2World GPL svn svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
+# Tremulous proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/TremulousPack/branches/1.5/
+# Unvanquished unknown zip http://ingar.intranifty.net/gtkradiant/files/gamepacks/UnvanquishedPack.zip
+# Warsow GPL svn https://svn.bountysource.com/wswpack/trunk/netradiant/games/WarsowPack/
+# Warsow GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/WarsowPack.zip
+
+#######################################################
+# Usable packs #
+#######################################################
+
+DarkPlaces GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/DarkPlacesPack/branches/1.5/
+Doom3 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Doom3Pack/branches/1.5/
+ET proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/ETPack/branches/1.5/
+Heretic2 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Her2Pack/branches/1.5/
+JediAcademy proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/JAPack/branches/1.5/
+Neverball proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/NeverballPack.zip
+Nexuiz GPL gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
+OpenArena GPL git https://github.com/NeonKnightOA/oagamepack.git
+Osirion GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/OsirionPack.zip
+Prey proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/PreyPack/trunk/
+Q3 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q3Pack/trunk/ 29
+Quake2 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q2Pack/branches/1.5/
+Quake4 proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q4Pack/branches/1.5/
+Quake GPL zip http://ingar.intranifty.net/files/netradiant/gamepacks/Quake1Pack.zip
+Quetoo GPL svn svn://svn.icculus.org/gtkradiant-gamepacks/QuetooPack/branches/1.5/
+Tremulous proprietary zip http://ingar.intranifty.net/files/netradiant/gamepacks/TremulousPack.zip
+TurtleArena proprietary git https://github.com/Turtle-Arena/turtle-arena-radiant-pack.git
+UFOAI proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/UFOAIPack/branches/1.5/
+Unvanquished BSD git https://github.com/Unvanquished/unvanquished-mapeditor-support.git
+Warsow GPL git https://github.com/Warsow/NetRadiantPack.git
+Wolf proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/WolfPack/branches/1.5/
+Xonotic GPL git https://gitlab.com/xonotic/netradiant-xonoticpack.git
+EOF
+}
+
+sanitizeDB () {
+ sed -e 's/#.*//;s/[ \t][ \t][ \t]*/\t/g;s/^[ \t]*//;s/[ \t]*$//' \
+ | grep -v '^$'
+}
+
+inList () {
+ [ "$(grep "^${1}$")" = "${1}" ]
+}
+
+printList () {
+ echo "${1}" \
+ | tr ' ' '\n' \
+ | grep -v '^$' \
+ | sort -u
+}
+
+dedupeList () {
+ printList "${1}" \
+ | tr '\n' ' ' \
+ | sed -e 's/ $//'
+}
+
+printGamePackDB () {
+ printRawDB \
+ | sanitizeDB
+}
+
+printLicenseList () {
+ printGamePackDB \
+ | awk '{ print $2 }' \
+ | sort -u
+}
+
+printNameList () {
+ printGamePackDB \
+ | awk '{ print $1 }' \
+ | sort -u
+}
+
+printNameListByLicense () {
+ local arg_license_list
+ local license_list
+ local license
+
+ arg_license_list="${1}"
+ license_list=''
+
+ for license in ${arg_license_list}
+ do
+ case "${license}" in
+ 'none')
+ break
+ ;;
+ 'all')
+ license_list="$(printLicenseList)"
+ break
+ ;;
+ 'free')
+ license_list="${license_list} ${free_license_list}"
+ ;;
+ *)
+ if printLicenseList | inList "${license}"
+ then
+ license_list="${license_list} ${license}"
+ else
+ printError "unknown license: ${license}"
+ fi
+ ;;
+ esac
+ done
+
+ license_list="$(dedupeList "${license_list}")"
+
+ for license in ${license_list}
+ do
+ printGamePackDB \
+ | awk '$2 == "'"${license}"'"' \
+ | awk '{ print $1 }'
+ done
+}
+
+printNameListByName () {
+ local argname_list
+ local name_list
+ local name
+
+ argname_list="${1}"
+ name_list=''
+
+ for name in ${argname_list}
+ do
+ case "${name}" in
+ 'none')
+ break
+ ;;
+ 'all')
+ local name_list
+ name_list="$(printNameList)"
+ break
+ ;;
+ *)
+ if printNameList | inList "${name}"
+ then
+ local name_list
+ name_list="${name_list} ${name}"
+ else
+ printError "unknown name: ${name}"
+ fi
+ ;;
+ esac
+ done
+
+ name_list="$(dedupeList "${name_list}")"
+
+ for name in ${name_list}
+ do
+ printGamePackDB \
+ | awk '$1 == "'"${name}"'"' \
+ | awk '{ print $1 }'
+ done
+}
+
+printPackLine () {
+ local name
+
+ name="${1}"
+
+ printGamePackDB \
+ | awk '$1 == "'"${name}"'"'
+}
+
+getValue () {
+ local name
+ local key
+
+ name="${1}"
+ key="${2}"
+
+ printPackLine "${name}" \
+ | awk '{ print $'"${key}"' }'
+}
+
+downloadExtraUrls ()
+{
+ local dir
+
+ dir="${1}"
+
+ if [ -f "${dir}/extra-urls.txt" ]
+ then
+ while IFS=' ' read -r FILE URL
+ do
+ (
+ ${WGET} -O "${dir}/${FILE}" "${URL}"
+ ) </dev/null
+ done < "${dir}/extra-urls.txt"
+ fi
+}
+
+downloadPack () {
+ local download_dir
+ local name
+ local license
+ local source_type
+ local source_url
+ local pack
+ local reference
+ local subdir
+ local branch
+
+ download_dir="${1}"
+ name="${2}"
+
+ license="$(getValue "${name}" '2')"
+ source_type="$(getValue "${name}" '3')"
+ source_url="$(getValue "${name}" '4')"
+
+ pack="${name}${pack_suffix}"
+
+ ${MKDIR_P} "${download_dir}"
+
+ (
+ cd "${download_dir}"
+
+ ${ECHO} ''
+ ${ECHO} "Available pack: ${pack}"
+ ${ECHO} " License: ${license}"
+ ${ECHO} " Download via ${source_type} from ${source_url}"
+ ${ECHO} ''
+
+ if [ -d "${download_dir}/${pack}" ]
+ then
+ ${ECHO} "Updating ${name}…"
+ else
+ ${ECHO} "Downloading ${pack}…"
+ fi
+
+ case "${source_type}" in
+ 'svn')
+ reference="$(getValue "${name}" '5')"
+ if [ -z "${reference}" ]
+ then
+ reference='HEAD'
+ fi
+
+ if [ -d "${pack}" ]
+ then
+ if [ -d "${pack}/.git" ]
+ then
+ (
+ cd "${pack}"
+ ${GIT} svn fetch
+ )
+ else
+ ${SVN} update -r"${reference}" "${pack}"
+ fi
+ else
+ ${SVN} checkout -r"${reference}" "${source_url}" "${pack}" \
+ || ${GIT} svn clone "${source_url}" "${pack}"
+ fi
+ ;;
+ 'zip')
+ ${RM_R} 'zipdownload'
+ ${MKDIR} 'zipdownload'
+ (
+ cd 'zipdownload'
+ ${WGET} "${source_url}"
+ ${UNZIPPER} './'*.zip
+ )
+ ${RM_R} "${pack}"
+ ${MKDIR} "${pack}"
+ ${MV} 'zipdownload/'*'/'* "${pack}/"
+ ${RM_R} 'zipdownload'
+ ;;
+ 'gitdir')
+ local subdir="$(getValue "${name}" '5')"
+ local branch="$(getValue "${name}" '6')"
+ ${RM_R} "${pack}"
+ ${GIT} archive --remote="${source_url}" --prefix="${pack}/" "${branch}":"${subdir}" \
+ | ${TAR} xvf -
+ ;;
+ 'git')
+ if [ -d "${pack}" ]
+ then
+ (
+ cd "${pack}"
+ ${GIT} pull
+ )
+ else
+ ${GIT} clone "${source_url}" "${pack}"
+ fi
+ ;;
+ esac
+
+ if [ -d "${download_dir}/${pack}" ]
+ then
+ (
+ cd "${download_dir}/${pack}"
+ downloadExtraUrls "${pack}"
+ )
+ fi
+
+ )
+}
+
+downloadPackList () {
+ local download_dir
+ local name_list
+
+ download_dir="${1}"
+ name_list="${2}"
+
+ for name in ${name_list}
+ do
+ if printNameList | inList "${name}"
+ then
+ downloadPack "${download_dir}" "${name}"
+ else
+ printError "unknown name: ${name}"
+ fi
+ done
+}
+
+installPack () {
+ local download_dir
+ local install_dir
+ local name
+ local pack
+ local path
+ local game_file
+ local game_dir
+
+ download_dir="${1}"
+ install_dir="${2}"
+ name="${3}"
+
+ pack="${name}${pack_suffix}"
+
+ ${MKDIR_P} "${install_dir}/${games_dir}"
+
+ # Some per-game workaround for malformed gamepack
+ case "${name}" in
+ 'JediAcademy')
+ pack="${pack}/Tools"
+ ;;
+ 'Prey'|'Q3')
+ pack="${pack}/tools"
+ ;;
+ 'Wolf')
+ pack="${pack}/bin"
+ ;;
+ esac
+
+ # mkeditorpacks-based gamepack
+ if [ -d "${download_dir}/${pack}/build/netradiant" ]
+ then
+ pack="${pack}/build/netradiant"
+ fi
+
+ path="${download_dir}/${pack}"
+
+ for game_file in "${path}/${games_dir}/"*'.game'
+ do
+ if [ x"${game_file}" != x"${path}/"*'.game' ]
+ then
+ ${CP} "${game_file}" "${real_install_dir}/${games_dir}/"
+ fi
+ done
+
+ for game_dir in "${path}/"*'.game'
+ do
+ if [ x"${game_dir}" != x"${path}/"*'.game' ]
+ then
+ ${CP_R} "${game_dir}" "${real_install_dir}/"
+ fi
+ done
+}
+
+installPackList () {
+ local download_dir
+ local install_dir
+ local name_list
+
+ download_dir="${1}"
+ install_dir="${2}"
+ name_list="${3}"
+
+ for name in ${name_list}
+ do
+ if printNameList | inList "${name}"
+ then
+ installPack "${download_dir}" "${install_dir}" "${name}"
+ else
+ printError "unknown name: ${name}"
+ fi
+ done
+}
+
+printError () {
+ printf 'ERROR: %s\n' "${1}" >&2
+ exit 1
+}
+
+printHelp () {
+ local tab
+ local prog_name
+
+ tab="$(printf '\t')"
+ prog_name="$(basename "$(readlink -f "${0}")")"
+
+ cat <<-EOF
+ Usage: ${prog_name} [OPTION] [SELECTION <ARGUMENTS>] [ACTION]
+
+ OPTIONS:
+ ${tab}-dd, --download-dir DIRNAME
+ ${tab}${tab}store downloaded games to DIRNAME (default: ${default_download_dir})
+
+ ${tab}-id, --install-dir DIRNAME
+ ${tab}${tab}store installed games to DIRNAME (default: ${default_install_dir})
+
+ SELECTIONS:
+ ${tab}-n, --name NAMES…
+ ${tab}${tab}select games by name (default: none)
+ ${tab}${tab}special keyword: all, none
+ ${tab}${tab}available games:
+ $(printNameList | sed -e 's/^/\t\t\t/')
+
+ ${tab}-l, --license LICENSES…
+ ${tab}${tab}select games by license (default: none)
+ ${tab}${tab}special keyword: free, all, none
+ ${tab}${tab}available licenses:
+ $(printLicenseList | sed -e 's/^/\t\t\t/')
+
+ ACTIONS:
+ ${tab}-ln, --list-names
+ ${tab}${tab}list all game names
+
+ ${tab}-ll, --list-licenses
+ ${tab}${tab}list all game licenses
+
+ ${tab}-ls, --list
+ ${tab}${tab}list selected games
+
+ ${tab}-d, --download
+ ${tab}${tab}download selected games
+
+ ${tab}-i, --install
+ ${tab}${tab}install selected games
+
+ ${tab}-h, --help
+ ${tab}${tab}print this help
+
+ Example:
+ ${tab}${prog_name} --license GPL BSD --download --install
+
+ EOF
+
+ exit
+}
+
+option_list=''
+
+list_selected='false'
+list_licenses='false'
+list_names='false'
+
+download_packs='false'
+install_packs='false'
+
+mkdir_download='false'
+mkdir_install='false'
+
+by_license='false'
+by_name='false'
+
+arg_type=''
+selected_list=''
+license_list=''
+name_list=''
+install_dir=''
+
+while ! [ -z "${1}" ]
+do
+
+ if printList "${option_list}" | inList "${1}"
+ then
+ printError "option called more than once: ${1}"
+ fi
+
+ if echo "${@}" | tr ' ' '\n' | inList '--help'
+ then
+ printHelp
+ elif echo "${@}" | tr ' ' '\n' | inList '-h'
+ then
+ printHelp
+ fi
+
+ case "${1}" in
+ '--list-licenses'|'-ll')
+ arg_type=''
+ list_licenses='true'
+ option_list="${option_list} ${1}"
+ ;;
+ '--list-names'|'-ln')
+ arg_type=''
+ list_names='true'
+ option_list="${option_list} ${1}"
+ ;;
+ '--list-selected'|'-ls')
+ arg_type=''
+ list_selected='true'
+ option_list="${option_list} ${1}"
+ ;;
+ '--download'|'-d')
+ arg_type=''
+ download_packs='true'
+ mkdir_download='true'
+ option_list="${option_list} ${1}"
+ ;;
+ '--install'|'-i')
+ arg_type=''
+ install_packs='true'
+ mkdir_download='true'
+ mkdir_install='true'
+ option_list="${option_list} ${1}"
+ ;;
+ '--license'|'-l')
+ by_license='true'
+ arg_type='pack-license'
+ option_list="${option_list} ${1}"
+ ;;
+ '--name'|'-n')
+ by_name='true'
+ arg_type='pack-name'
+ option_list="${option_list} ${1}"
+ ;;
+ '--download-dir'|'-dd')
+ arg_type='download-dir'
+ option_list="${option_list} ${1}"
+ ;;
+ '--install-dir'|'-id')
+ arg_type='install-dir'
+ option_list="${option_list} ${1}"
+ ;;
+ '-'*)
+ printError "unknown option: ${1}"
+ ;;
+ *)
+ case "${arg_type}" in
+ 'pack-license')
+ license_list="${license_list} ${1}"
+ ;;
+ 'pack-name')
+ name_list="${name_list} ${1}"
+ ;;
+ 'download-dir')
+ if [ -z "${download_dir}" ]
+ then
+ download_dir="${1}"
+ else
+ printError "more than one download dir: ${1}"
+ fi
+ ;;
+ 'install-dir')
+ if [ -z "${install_dir}" ]
+ then
+ install_dir="${1}"
+ else
+ printError "more than one install dir: ${1}"
+ fi
+ ;;
+ *)
+ printError "misplaced argument: ${1}"
+ ;;
+ esac
+ ;;
+ esac
+
+ shift
+done
+
+# compatibility with legacy Makefile
+if [ "${DOWNLOAD_GAMEPACKS}" = 'yes' ]
+then
+ ! [ -z "${DOWNLOADDIR}" ] && download_dir="${DOWNLOADDIR}"
+ ! [ -z "${INSTALLDIR}" ] && install_dir="${INSTALDIR}"
+ license_list='free'
+ by_license='true'
+ download_packs='true'
+ install_packs='true'
+fi
+
+if [ -z "${download_dir}" ]
+then
+ download_dir="${default_download_dir}"
+fi
+
+if [ -z "${install_dir}" ]
+then
+ install_dir="${default_install_dir}"
+fi
+
+if "${by_license}"
+then
+ selected_list="${selected_list} $(printNameListByLicense "${license_list}")"
+fi
+
+if "${by_name}"
+then
+ selected_list="${selected_list} $(printNameListByName "${name_list}")"
+fi
+
+selected_list="$(dedupeList "${selected_list}")"
+
+if "${mkdir_download}"
+then
+ ${MKDIR_P} "${download_dir}"
+ real_download_dir="$(readlink -f "${download_dir}")"
+fi
+
+if "${mkdir_install}"
+then
+ ${MKDIR_P} "${install_dir}"
+ real_install_dir="$(readlink -f "${install_dir}")"
+fi
+
+if "${list_licenses}"
+then
+ printLicenseList
+fi
+
+if "${list_names}"
+then
+ printNameList
+fi
+if "${list_selected}"
+then
+ printList "${selected_list}"
+fi
+
+if "${download_packs}"
+then
+ downloadPackList "${real_download_dir}" "${selected_list}"
+fi
+
+if "${install_packs}"
+then
+ installPackList "${real_download_dir}" "${real_install_dir}" "${selected_list}"
+fi
+
+#EOF
+++ /dev/null
-#!/bin/sh
-
-# installs a game pack
-# Usage:
-# install-gamepack.sh gamepack installdir
-
-set -ex
-
-: ${CP:=cp}
-: ${CP_R:=cp -r}
-
-pack=$1
-dest=$2
-
-# Some per-game workaround for malformed gamepack
-case $pack in
- */JediAcademyPack)
- pack="$pack/Tools"
- ;;
- */PreyPack|*/Q3Pack)
- pack="$pack/tools"
- ;;
- */WolfPack)
- pack="$pack/bin"
- ;;
-esac
-
-for GAMEFILE in "$pack/games"/*.game; do
- if [ x"$GAMEFILE" != x"$pack/games/*.game" ]; then
- $CP "$GAMEFILE" "$dest/games/"
- fi
-done
-for GAMEDIR in "$pack"/*.game; do
- if [ x"$GAMEDIR" != x"$pack/*.game" ]; then
- $CP_R "$GAMEDIR" "$dest/"
- fi
-done
+++ /dev/null
-#!/bin/sh
-
-: ${ECHO:=echo}
-: ${SH:=sh}
-: ${CP:=cp}
-: ${CP_R:=cp -r}
-: ${SOURCE_DIR:=.}
-
-dest=$1
-
-case "$DOWNLOAD_GAMEPACKS" in
- yes)
- LICENSEFILTER=GPL,BSD BATCH=1 $SH "$SOURCE_DIR/download-gamepacks.sh"
- ;;
- all)
- BATCH=1 $SH "$SOURCE_DIR/download-gamepacks.sh"
- ;;
- *)
- ;;
-esac
-
-set -e
-for GAME in games/*Pack; do
- if [ "$GAME" = "games/*Pack" ]; then
- $ECHO "Game packs not found, please run"
- $ECHO " $SOURCE_DIR/download-gamepacks.sh"
- $ECHO "and then try again!"
- else
- $SH "$SOURCE_DIR/install-gamepack.sh" "$GAME" "$dest"
- fi
-done
/* validate material name */
if ( name == NULL || !strlen( name ) ) {
- _pico_printf( PICO_ERROR,"Missing material name in MTL, line %d.",p->curLine );
+ _pico_printf( PICO_ERROR,"Missing material name in MTL %s, line %d.",fileName,p->curLine );
_obj_mtl_error_return;
}
/* create a new pico shader */
/* validate map name */
if ( mapName == NULL || !strlen( mapName ) ) {
- _pico_printf( PICO_ERROR,"Missing material map name in MTL, line %d.",p->curLine );
+ _pico_printf( PICO_ERROR,"Missing material map name in MTL %s, line %d.",fileName,p->curLine );
_obj_mtl_error_return;
}
/* create a new pico shader */
int i;
if ( curSurface == NULL ) {
- _pico_printf( PICO_WARNING,"No group defined for faces, so creating an autoSurface in OBJ, line %d.",p->curLine );
+ _pico_printf( PICO_WARNING,"No group defined for faces, so creating an autoSurface in OBJ %s, line %d.",model->fileName,p->curLine );
AUTO_GROUPNAME( autoGroupNameBuf );
NEW_SURFACE( autoGroupNameBuf );
}
name = _pico_parse( p,0 );
if ( curFace != 0 || curSurface == NULL ) {
- _pico_printf( PICO_WARNING,"No group defined for usemtl, so creating an autoSurface in OBJ, line %d.",p->curLine );
+ _pico_printf( PICO_WARNING,"No group defined for usemtl, so creating an autoSurface in OBJ %s, line %d.",model->fileName,p->curLine );
AUTO_GROUPNAME( autoGroupNameBuf );
NEW_SURFACE( autoGroupNameBuf );
}
/* validate material name */
if ( name == NULL || !strlen( name ) ) {
- _pico_printf( PICO_ERROR,"Missing material name in OBJ, line %d.",p->curLine );
+ _pico_printf( PICO_ERROR,"Missing material name in OBJ %s, line %d.",model->fileName,p->curLine );
}
else
{
shader = PicoFindShader( model, name, 1 );
if ( shader == NULL ) {
- _pico_printf( PICO_WARNING,"Undefined material name in OBJ, line %d. Making a default shader.",p->curLine );
+ _pico_printf( PICO_WARNING,"Undefined material name \"%s\" in OBJ %s, line %d. Making a default shader.",name,model->fileName,p->curLine );
/* create a new pico shader */
shader = PicoNewShader( model );
add_subdirectory(imagehl)
add_subdirectory(imagepng)
add_subdirectory(imageq2)
+add_subdirectory(imagewebp)
add_subdirectory(iqmmodel)
add_subdirectory(mapq3)
add_subdirectory(mapxml)
--- /dev/null
+radiant_plugin(imagewebp
+ plugin.cpp
+ )
+
+find_package(WebP REQUIRED)
+target_include_directories(imagewebp PRIVATE ${WEBP_INCLUDE_DIR})
+target_link_libraries(imagewebp PRIVATE ${WEBP_LIBRARIES})
--- /dev/null
+; imagewebp.def : Declares the module parameters for the DLL.
+
+LIBRARY "IMAGEWEBP"
+
+EXPORTS
+ ; Explicit exports can go here
+ Radiant_RegisterModules @1
--- /dev/null
+/*
+ Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+ This file is part of NetRadiant.
+
+ NetRadiant is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ NetRadiant 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NetRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "plugin.h"
+#include "debugging/debugging.h"
+#include "ifilesystem.h"
+#include "iimage.h"
+
+#include "imagelib.h"
+
+// ====== WEBP loader functionality ======
+
+#include "webp/decode.h"
+
+Image* LoadWEBPBuff( unsigned char* buffer, size_t buffer_length ){
+ int image_width;
+ int image_height;
+
+ if ( !WebPGetInfo( (byte *) buffer, buffer_length, &image_width, &image_height) ){
+ globalErrorStream() << "libwebp error: WebPGetInfo: can't get image info\n";
+ return 0;
+ }
+
+ // allocate the pixel buffer
+ RGBAImage* image = new RGBAImage( image_width, image_height );
+ int out_stride = image_width *sizeof(RGBAPixel);
+ int out_size = image_height * out_stride;
+
+ if ( !WebPDecodeRGBAInto( (byte *) buffer, buffer_length, image->getRGBAPixels(), out_size, out_stride ) )
+ {
+ return 0;
+ }
+
+ return image;
+}
+
+Image* LoadWEBP( ArchiveFile& file ){
+ ScopedArchiveBuffer buffer( file );
+ return LoadWEBPBuff( buffer.buffer, buffer.length );
+}
+
+
+#include "modulesystem/singletonmodule.h"
+
+
+class ImageDependencies : public GlobalFileSystemModuleRef
+{
+};
+
+class ImageWEBPAPI
+{
+_QERPlugImageTable m_imagewebp;
+public:
+typedef _QERPlugImageTable Type;
+STRING_CONSTANT( Name, "webp" );
+
+ImageWEBPAPI(){
+ m_imagewebp.loadImage = LoadWEBP;
+}
+_QERPlugImageTable* getTable(){
+ return &m_imagewebp;
+}
+};
+
+typedef SingletonModule<ImageWEBPAPI, ImageDependencies> ImageWEBPModule;
+
+ImageWEBPModule g_ImageWEBPModule;
+
+
+extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
+ initialiseModule( server );
+
+ g_ImageWEBPModule.selfRegister();
+}
--- /dev/null
+/*
+ Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+ This file is part of NetRadiant.
+
+ NetRadiant is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ NetRadiant 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with NetRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if !defined( INCLUDED_PLUGIN_H )
+#define INCLUDED_PLUGIN_H
+
+#endif
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
+find_package(WebP REQUIRED)
+include_directories(${WEBP_INCLUDE_DIR})
+
find_package(LibXml2 REQUIRED)
include_directories(${LIBXML2_INCLUDE_DIR})
${GLIB_LIBRARIES}
${JPEG_LIBRARIES}
${PNG_LIBRARIES}
+ ${WEBP_LIBRARIES}
${LIBXML2_LIBRARIES}
${Minizip_LIBRARIES}
${ZLIB_LIBRARIES}
/* dependencies */
#include "q3map2.h"
-
+#include "webp/decode.h"
/* -------------------------------------------------------------------------------
+static void LoadWEBPBuffer( byte *buffer, int size, byte **pixels, int *width, int *height ){
+
+ int image_width;
+ int image_height;
+
+ if ( !WebPGetInfo( buffer, ( size_t) size, &image_width, &image_height ) )
+ {
+ Sys_Printf( "WARNING: An error occurred reading WEBP image info\n" );
+ return;
+ }
+
+ /* create image pixel buffer */
+ *pixels = safe_malloc( image_width * image_height * 4 );
+ *width = image_width;
+ *height = image_height;
+
+ int out_stride = image_width * 4;
+ int out_size = image_height * out_stride;
+
+ if ( !WebPDecodeRGBAInto( buffer, (size_t) size, *pixels, out_size, out_stride ) )
+ {
+ Sys_FPrintf( SYS_WRN, "WARNING: An error occurred reading WEBP image\n" );
+ return;
+ }
+}
+
+
+
/*
ImageInit()
implicitly called by every function to set up image list
size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
if ( size > 0 ) {
LoadTGABuffer( buffer, buffer + size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
}
- else
- {
- /* attempt to load png */
- StripExtension( name );
- strcat( name, ".png" );
- size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
- if ( size > 0 ) {
- LoadPNGBuffer( buffer, size, &image->pixels, &image->width, &image->height );
- }
- else
- {
- /* attempt to load jpg */
- StripExtension( name );
- strcat( name, ".jpg" );
- size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
- if ( size > 0 ) {
- if ( LoadJPGBuff( buffer, size, &image->pixels, &image->width, &image->height ) == -1 && image->pixels != NULL ) {
- // On error, LoadJPGBuff might store a pointer to the error message in image->pixels
- Sys_FPrintf( SYS_WRN, "WARNING: LoadJPGBuff: %s\n", (unsigned char*) image->pixels );
- }
- alphaHack = qtrue;
- }
- else
- {
- /* attempt to load dds */
- StripExtension( name );
- strcat( name, ".dds" );
- size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
- if ( size > 0 ) {
- LoadDDSBuffer( buffer, size, &image->pixels, &image->width, &image->height );
-
- /* debug code */
- #if 1
- {
- ddsPF_t pf;
- DDSGetInfo( (ddsBuffer_t*) buffer, NULL, NULL, &pf );
- Sys_Printf( "pf = %d\n", pf );
- if ( image->width > 0 ) {
- StripExtension( name );
- strcat( name, "_converted.tga" );
- WriteTGA( "C:\\games\\quake3\\baseq3\\textures\\rad\\dds_converted.tga", image->pixels, image->width, image->height );
- }
- }
- #endif
- }
- else
- {
- /* attempt to load ktx */
- StripExtension( name );
- strcat( name, ".ktx" );
- size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
- if ( size > 0 ) {
- LoadKTXBufferFirstImage( buffer, size, &image->pixels, &image->width, &image->height );
- }
- #ifdef BUILD_CRUNCH
- else
- {
- /* attempt to load crn */
- StripExtension( name );
- strcat( name, ".crn" );
- size = vfsLoadFile( ( const char* ) name, ( void** ) &buffer, 0 );
- if ( size > 0 ) {
- LoadCRNBuffer( buffer, size, &image->pixels, &image->width, &image->height );
- }
- }
- #endif // BUILD_CRUNCH
- }
- }
+
+ /* attempt to load png */
+ StripExtension( name );
+ strcat( name, ".png" );
+ size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
+ if ( size > 0 ) {
+ LoadPNGBuffer( buffer, size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
+ }
+
+ /* attempt to load jpg */
+ StripExtension( name );
+ strcat( name, ".jpg" );
+ size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
+ if ( size > 0 ) {
+ if ( LoadJPGBuff( buffer, size, &image->pixels, &image->width, &image->height ) == -1 && image->pixels != NULL ) {
+ // On error, LoadJPGBuff might store a pointer to the error message in image->pixels
+ Sys_FPrintf( SYS_WRN, "WARNING: LoadJPGBuff: %s\n", (unsigned char*) image->pixels );
}
+ alphaHack = qtrue;
+ goto image_load_success;
}
+ /* attempt to load dds */
+ StripExtension( name );
+ strcat( name, ".dds" );
+ size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
+ if ( size > 0 ) {
+ LoadDDSBuffer( buffer, size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
+ }
+
+ /* attempt to load ktx */
+ StripExtension( name );
+ strcat( name, ".ktx" );
+ size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
+ if ( size > 0 ) {
+ LoadKTXBufferFirstImage( buffer, size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
+ }
+
+ #ifdef BUILD_CRUNCH
+ /* attempt to load crn */
+ StripExtension( name );
+ strcat( name, ".crn" );
+ size = vfsLoadFile( ( const char* ) name, ( void** ) &buffer, 0 );
+ if ( size > 0 ) {
+ LoadCRNBuffer( buffer, size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
+ }
+ #endif // BUILD_CRUNCH
+
+ /* attempt to load webp */
+ StripExtension( name );
+ strcat( name, ".webp" );
+ size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
+ if ( size > 0 ) {
+ LoadWEBPBuffer( buffer, size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
+ }
+
+ image_load_success:
+
/* free file buffer */
free( buffer );